You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Update configuration code samples to use Citrus bean, Spring bean and Spring XML bean configurations
- Update code samples with proper test case in Java, XML, YAML and Spring XML
Copy file name to clipboardExpand all lines: src/manual/endpoint-docker.adoc
+59-3Lines changed: 59 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -39,12 +39,31 @@ After that you are able to use customized Citrus XML elements in order to define
39
39
40
40
Citrus operates with the Docker remote REST API in order to interact with the Docker daemon. The Docker client is defined as Spring bean component in the configuration as follows:
41
41
42
-
[source,xml]
42
+
.Citrus Bean
43
+
[source,java,indent=0,role="primary"]
44
+
----
45
+
@BindToRegistry
46
+
public DockerClient dockerClient() {
47
+
return new DockerClientBuilder().build();
48
+
}
49
+
----
50
+
51
+
.Spring Bean
52
+
[source,java,indent=0,role="secondary"]
53
+
----
54
+
@Bean
55
+
public DockerClient dockerClient() {
56
+
return new DockerClientBuilder().build();
57
+
}
58
+
----
59
+
60
+
.Spring XML
61
+
[source,xml,indent=0,role="secondary"]
43
62
----
44
63
<citrus-docker:client id="dockerClient"/>
45
64
----
46
65
47
-
The Docker client component above is using all default configuration values. By default Citrus is searching the system properties as well as environment variables for default Docker settings such as:
66
+
The Docker client component above is using all default configuration values. By default, Citrus is searching the system properties as well as environment variables for default Docker settings such as:
48
67
49
68
[horizontal]
50
69
DOCKER_HOST:: tcp://localhost:2376
@@ -54,7 +73,44 @@ DOCKER_MACHINE_NAME:: default
54
73
55
74
In case these settings are not settable in your environment you can also use explicit settings in the Docker client component:
@@ -8,54 +8,170 @@ In chapter link:#message-channels[message-channels] we have discussed the native
8
8
9
9
We want to use the Spring Integration file adapter for both reading and writing files with a local directory. Citrus can easily connect to this file adapter implementation with its message channel support. Citrus message sender and receiver speak to message channels that are connected to the Spring Integration file adapters.
return new ChannelEndpointAdapter(endpointConfiguration);
19
+
}
20
+
21
+
@BindToRegistry
22
+
public MessageChannel fileChannel() {
23
+
return new DirectChannel();
24
+
}
25
+
26
+
@BindToRegistry
27
+
public FileWritingMessageHandler fileOutboundAdapter() {
28
+
FileWritingMessageHandler messageHandler = new FileWritingMessageHandler(new File("some/directory"));
29
+
messageHandler.setOutboundChannel(fileChannel());
30
+
return messageHandler;
31
+
}
20
32
----
21
33
22
-
The configuration above describes a Citrus message channel endpoint connected to a Spring Integration outbound file adapter that writes messages to a storage directory. With this combination you are able to write files to a directory in your Citrus test case. The test case uses the channel endpoint in its send action and the endpoint interacts with the Spring Integration file adapter so sending out the file.
23
-
24
-
NOTE: The Spring Integration file adapter configuration components add a new namespace to our Spring application context. See this template which holds all necessary namespaces and schema locations:
34
+
.Spring Bean
35
+
[source,java,indent=0,role="secondary"]
36
+
----
37
+
@Bean
38
+
public ChannelEndpointAdapter fileEndpoint() {
39
+
ChannelSyncEndpointConfiguration endpointConfiguration = new ChannelSyncEndpointConfiguration();
The configuration above describes a Citrus message channel endpoint connected to a Spring Integration outbound file adapter that writes messages to a storage directory.
88
+
With this combination you are able to write files to a directory in your Citrus test case.
89
+
The test case uses the channel endpoint in its send action and the endpoint interacts with the Spring Integration file adapter so sending out the file.
90
+
91
+
NOTE: The Spring Integration file adapter configuration component adds new namespaces (`si`, `si-file`, `citrus-si`) to the Spring XML application context. Please see the individual XML schema locations for details of the supported component in these namespaces.
92
+
45
93
[[read-files]]
46
94
== Read files
47
95
48
96
The next program listing shows a possible inbound file communication. So the Spring Integration file inbound adapter will read files from a storage directory and publish the file contents to a message channel. Citrus can then receive those files as messages in a test case via the channel endpoint and validate the file contents for instance.
49
97
50
-
[source,xml]
98
+
.Citrus Bean
99
+
[source,java,indent=0,role="primary"]
100
+
----
101
+
@BindToRegistry
102
+
public ChannelEndpointAdapter fileEndpoint() {
103
+
ChannelSyncEndpointConfiguration endpointConfiguration = new ChannelSyncEndpointConfiguration();
IMPORTANT: The file inbound adapter constructs Java file objects as the message payload by default. Citrus can only work on String message payloads. So we need a file transformer that converts the file objects to String payloads representing the file's content.
Copy file name to clipboardExpand all lines: src/manual/endpoint-ftp.adoc
+29-10Lines changed: 29 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -594,18 +594,26 @@ Listing files results in a command result that gives us the list of files on the
594
594
595
595
Now that we are able to access FTP as a client we might also want to simulate the server side. Therefore Citrus offers a server component that is listening on a port for incoming FTP connections. The server has a default home directory on the local file system specified. But you can also define home directories per user. For now let us have a look at the server configuration component:
The ftp server configuration is quite simple. The server starts automatically and binds to a port. With `autoLogin` and `autoHandleCommands` we can specify the behavior of the server.
@@ -627,7 +646,7 @@ have to verify those commands in a test case. The server will automatically resp
627
646
628
647
The user configuration is read from a *user-manager-property* file. Let us have a look at the content of this user management file:
0 commit comments