From bb34617bbcc957828d9d28950fa6e0ee0f520235 Mon Sep 17 00:00:00 2001 From: Tamas Balog Date: Sun, 24 Sep 2023 09:37:17 +0200 Subject: [PATCH] #995: Fix code snippets in the documentation --- src/manual/endpoint-channel.adoc | 4 +--- src/manual/endpoint-direct.adoc | 4 +--- src/manual/endpoint-http.adoc | 8 ++++---- src/manual/endpoint-jms.adoc | 9 +++++---- src/manual/endpoint-kafka.adoc | 20 ++++++++++---------- src/manual/validation-matchers.adoc | 4 ++-- 6 files changed, 23 insertions(+), 26 deletions(-) diff --git a/src/manual/endpoint-channel.adoc b/src/manual/endpoint-channel.adoc index e5d72d8bdf..f8461ecb9d 100644 --- a/src/manual/endpoint-channel.adoc +++ b/src/manual/endpoint-channel.adoc @@ -148,8 +148,7 @@ reply to that channel. The basic configuration for a synchronous channel endpoin public ChannelSyncEndpoint helloEndpoint() { return new ChannelSyncEndpointBuilder() .channel("helloChannel") - .replyTimeout(1000L) - .pollingInterval(1000L) + .pollingInterval(1000) .build(); } ---- @@ -159,7 +158,6 @@ public ChannelSyncEndpoint helloEndpoint() { ---- ---- diff --git a/src/manual/endpoint-direct.adoc b/src/manual/endpoint-direct.adoc index d38702ee0e..68a608ada2 100644 --- a/src/manual/endpoint-direct.adoc +++ b/src/manual/endpoint-direct.adoc @@ -122,8 +122,7 @@ reply to that queue. The basic configuration for a synchronous direct endpoint c public ChannelSyncEndpoint helloEndpoint() { return new ChannelSyncEndpointBuilder() .queue("helloChannel") - .replyTimeout(1000L) - .pollingInterval(1000L) + .pollingInterval(1000) .build(); } ---- @@ -133,7 +132,6 @@ public ChannelSyncEndpoint helloEndpoint() { ---- ---- diff --git a/src/manual/endpoint-http.adoc b/src/manual/endpoint-http.adoc index 2a0008e31e..f1d49ad3ee 100644 --- a/src/manual/endpoint-http.adoc +++ b/src/manual/endpoint-http.adoc @@ -445,7 +445,7 @@ Http response. In the next section you will see how to simulate server side Http ---- @Bean public HttpServer httpServer() { - return new HttpClientBuilder() + return new HttpServerBuilder() .port(8080) .autoStart(true) .build(); @@ -752,7 +752,7 @@ http().server("httpServer") ---- -Once more we set the custom header entry (*X-CustomHeaderId*) and a Http reserved header (*Content-Type*) for the response +Once more we set the custom header entry (*X-CustomHeaderId*) and an Http reserved header (*Content-Type*) for the response message. On top of this we are able to set the response status for the Http response. We use the reserved header names *status* in order to mark the success of the server operation. With this mechanism we can easily simulate different server behaviour such as Http error response codes (e.g. 404 - Not found, 500 - Internal error). Let us have a closer look at the generated @@ -1248,10 +1248,10 @@ public BasicAuthClientHttpRequestFactory basicAuthFactory() { BasicAuthClientHttpRequestFactory factory = new BasicAuthClientHttpRequestFactory(); AuthScope scope = new AuthScope("localhost", "8080", "", "basic"); - factory.setAuthScope(); + factory.setAuthScope(scope); UsernamePasswordCredentials credentials = new UsernamePasswordCredentials("someUsername", "somePassword"); - factory.setCredentials(); + factory.setCredentials(credentials); return factory; } diff --git a/src/manual/endpoint-jms.adoc b/src/manual/endpoint-jms.adoc index f3241b89b0..3f4a03dfe1 100644 --- a/src/manual/endpoint-jms.adoc +++ b/src/manual/endpoint-jms.adoc @@ -144,7 +144,7 @@ bean names. public JmsEndpoint helloServiceEndpoint() { return new JmsEndpointBuilder() .destination("Citrus.HelloService.Request.Queue") - .connectionFactory("myConnectionFactory") + .connectionFactory(myConnectionFactory()) .build(); } ---- @@ -166,7 +166,7 @@ As an alternative to that you may want to use a special Spring JMS template impl public JmsEndpoint helloServiceEndpoint() { return new JmsEndpointBuilder() .destination("Citrus.HelloService.Request.Queue") - .jmsTemplate("myJmsTemplate") + .jmsTemplate(myJmsTemplate()) .build(); } ---- @@ -241,7 +241,7 @@ a JMS connection factory in the configuration as the component needs to connect ---- @Bean public JmsSyncEndpoint helloServiceSyncEndpoint() { - return new JmsEndpointBuilder() + return new JmsSyncEndpointBuilder() .destination("Citrus.HelloService.InOut.Queue") .build(); } @@ -313,7 +313,7 @@ component as follows. ---- @Bean public JmsSyncEndpoint helloServiceSyncEndpoint() { - return new JmsEndpointBuilder() + return new JmsSyncEndpointBuilder() .destination("Citrus.HelloService.InOut.Queue") .replyDestination("Citrus.HelloService.Reply.Queue") .build(); @@ -527,6 +527,7 @@ public JmsSyncEndpoint helloServiceSyncEndpoint() { return new JmsEndpointBuilder() .destination("Citrus.HelloService.Topic") .pubSubDomain(true) + .durableSubscription(true) .autoStart(true) .build(); } diff --git a/src/manual/endpoint-kafka.adoc b/src/manual/endpoint-kafka.adoc index 74708b39d3..60daafd48e 100644 --- a/src/manual/endpoint-kafka.adoc +++ b/src/manual/endpoint-kafka.adoc @@ -303,9 +303,9 @@ can set or verify those headers in send and receive actions as follows: ---- send(helloKafkaEndpoint) .message() - .header("KafkaMessageHeaders.TOPIC", "my.very.special.topic") - .header("KafkaMessageHeaders.MESSAGE_KEY", "myKey") - .header("KafkaMessageHeaders.PARTITION", 1); + .header(KafkaMessageHeaders.TOPIC, "my.very.special.topic") + .header(KafkaMessageHeaders.MESSAGE_KEY, "myKey") + .header(KafkaMessageHeaders.PARTITION, 1); ---- .XML @@ -332,7 +332,7 @@ the Kafka endpoint configuration. ---- send(helloKafkaEndpoint) .message() - .header("KafkaMessageHeaders.MESSAGE_KEY", 1L); + .header(KafkaMessageHeaders.MESSAGE_KEY, 1L); ---- .XML @@ -351,11 +351,11 @@ an expected behavior. ---- receive(helloKafkaEndpoint) .message() - .header("KafkaMessageHeaders.TIMESTAMP", Matchers.greaterThan(0)) - .header("KafkaMessageHeaders.TOPIC", "my.expected.topic") - .header("KafkaMessageHeaders.MESSAGE_KEY", "myKey") - .header("KafkaMessageHeaders.PARTITION", 1) - .header("KafkaMessageHeaders.OFFSET", Matchers.greaterThanOrEqualTo(0)); + .header(KafkaMessageHeaders.TIMESTAMP, Matchers.greaterThan(0)) + .header(KafkaMessageHeaders.TOPIC, "my.expected.topic") + .header(KafkaMessageHeaders.MESSAGE_KEY, "myKey") + .header(KafkaMessageHeaders.PARTITION, 1) + .header(KafkaMessageHeaders.OFFSET, Matchers.greaterThanOrEqualTo(0)); ---- .XML @@ -436,7 +436,7 @@ test as follows: send("kafka:hello") .message() .body("foo") - .header("KafkaMessageHeaders.MESSAGE_KEY", 1); + .header(KafkaMessageHeaders.MESSAGE_KEY, 1); ---- .XML diff --git a/src/manual/validation-matchers.adoc b/src/manual/validation-matchers.adoc index 7e4ebf3684..cfd1faa5e4 100644 --- a/src/manual/validation-matchers.adoc +++ b/src/manual/validation-matchers.adoc @@ -48,8 +48,8 @@ As you can see the library defines one to many validation matcher members either [source,xml] ---- @foo:isNumber()@ - @foo:contains()@ - @foo:customMatcher()@ +@foo:contains()@ +@foo:customMatcher()@ ---- TIP: You can add custom validation matcher implementations and custom validation matcher libraries. Just use a custom prefix for your library. The default Citrus validation matcher library uses no prefix. See now the following sections describing the default validation matcher in Citrus.