Skip to content

Commit a2fd087

Browse files
Thorsten Schlathoelterbbortt
authored andcommitted
feat(#285): support OpenAPI 3.0 from HttpOperationScenario
1 parent 2810b4d commit a2fd087

File tree

44 files changed

+4031
-1030
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+4031
-1030
lines changed

pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -522,4 +522,5 @@
522522
</profile>
523523

524524
</profiles>
525+
525526
</project>

simulator-samples/sample-bank-service/src/main/java/org/citrusframework/simulator/sample/config/HttpClientConfig.java

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@
4141
import java.security.NoSuchAlgorithmException;
4242
import java.security.cert.CertificateException;
4343

44+
import static java.lang.String.format;
45+
4446
@Configuration
4547
public class HttpClientConfig {
4648

@@ -62,32 +64,33 @@ public HttpClientConfig(SimulatorConfigurationProperties simulatorConfigurationP
6264
@Bean
6365
public HttpClient simulatorHttpClientEndpoint() {
6466
return CitrusEndpoints.http()
65-
.client()
66-
.timeout(simulatorConfigurationProperties.getDefaultTimeout())
67-
.requestUrl(String.format("https://localhost:%s/", port))
68-
.requestFactory(sslRequestFactory())
69-
.build();
67+
.client()
68+
.timeout(simulatorConfigurationProperties.getDefaultTimeout())
69+
.requestUrl(format("https://localhost:%s/", port))
70+
.requestFactory(sslRequestFactory())
71+
.build();
7072
}
7173

7274
@Bean
7375
public CloseableHttpClient httpClient() {
7476
try {
7577
SSLContext sslcontext = SSLContexts.custom()
76-
.loadTrustMaterial(keyStore, keyStorePassword.toCharArray(),
77-
new TrustSelfSignedStrategy())
78-
.build();
78+
.loadTrustMaterial(keyStore, keyStorePassword.toCharArray(),
79+
new TrustSelfSignedStrategy())
80+
.build();
7981

8082
SSLConnectionSocketFactory sslSocketFactory = new SSLConnectionSocketFactory(
81-
sslcontext, NoopHostnameVerifier.INSTANCE);
83+
sslcontext, NoopHostnameVerifier.INSTANCE);
8284

8385
PoolingHttpClientConnectionManager connectionManager = PoolingHttpClientConnectionManagerBuilder.create()
84-
.setSSLSocketFactory(sslSocketFactory)
85-
.build();
86+
.setSSLSocketFactory(sslSocketFactory)
87+
.build();
8688

8789
return HttpClients.custom()
88-
.setConnectionManager(connectionManager)
89-
.build();
90-
} catch (IOException | CertificateException | NoSuchAlgorithmException | KeyStoreException | KeyManagementException e) {
90+
.setConnectionManager(connectionManager)
91+
.build();
92+
} catch (IOException | CertificateException | NoSuchAlgorithmException | KeyStoreException |
93+
KeyManagementException e) {
9194
throw new BeanCreationException("Failed to create http client for ssl connection", e);
9295
}
9396
}

simulator-samples/sample-combined/src/test/java/org/citrusframework/simulator/EndpointConfig.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@
4040

4141
import java.util.Collections;
4242

43+
import static java.lang.String.format;
44+
4345
/**
4446
* @author Christoph Deppisch
4547
*/
@@ -56,14 +58,14 @@ public XsdSchemaRepository schemaRepository() {
5658
@Bean
5759
public HttpClient simulatorRESTClient() {
5860
return CitrusEndpoints.http().client()
59-
.requestUrl(String.format("http://localhost:%s/services/rest/simulator", 8080))
60-
.build();
61+
.requestUrl(format("http://localhost:%s/services/rest/simulator", 8080))
62+
.build();
6163
}
6264

6365
@Bean
6466
public WebServiceClient simulatorWSClient(LoggingClientInterceptor loggingClientInterceptor, SaajSoapMessageFactory messageFactory) {
6567
return CitrusEndpoints.soap().client()
66-
.defaultUri(String.format("http://localhost:%s/services/ws/simulator", 8080))
68+
.defaultUri(format("http://localhost:%s/services/ws/simulator", 8080))
6769
.interceptor(loggingClientInterceptor)
6870
.messageFactory(messageFactory)
6971
.faultStrategy(ErrorHandlingStrategy.PROPAGATE)
@@ -98,11 +100,11 @@ public ActiveMQConnectionFactory connectionFactory() {
98100
@Bean
99101
public JmsSyncEndpoint simulatorEndpoint() {
100102
return CitrusEndpoints.jms()
101-
.synchronous()
102-
.connectionFactory(connectionFactory())
103-
.destination("Citrus.Simulator.Inbound")
104-
.timeout(10000L)
105-
.build();
103+
.synchronous()
104+
.connectionFactory(connectionFactory())
105+
.destination("Citrus.Simulator.Inbound")
106+
.timeout(10000L)
107+
.build();
106108
}
107109

108110
@Bean

simulator-samples/sample-jms-fax/src/test/java/org/citrusframework/simulator/SimulatorJmsFaxIT.java

Lines changed: 68 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@
1616

1717
package org.citrusframework.simulator;
1818

19-
import java.util.Arrays;
20-
import java.util.Collections;
21-
2219
import org.apache.activemq.artemis.core.config.impl.SecurityConfiguration;
2320
import org.apache.activemq.artemis.core.server.embedded.EmbeddedActiveMQ;
2421
import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
@@ -51,17 +48,21 @@
5148
import org.springframework.context.annotation.Configuration;
5249
import org.springframework.context.annotation.DependsOn;
5350
import org.springframework.http.HttpStatus;
54-
import org.springframework.http.MediaType;
5551
import org.springframework.integration.support.json.Jackson2JsonObjectMapper;
5652
import org.springframework.test.context.ContextConfiguration;
5753
import org.testng.annotations.Test;
5854

55+
import java.util.Arrays;
56+
import java.util.Collections;
57+
58+
import static java.lang.String.format;
5959
import static org.citrusframework.actions.ReceiveMessageAction.Builder.receive;
6060
import static org.citrusframework.actions.ReceiveTimeoutAction.Builder.receiveTimeout;
6161
import static org.citrusframework.actions.SendMessageAction.Builder.send;
6262
import static org.citrusframework.actions.SleepAction.Builder.sleep;
6363
import static org.citrusframework.http.actions.HttpActionBuilder.http;
6464
import static org.citrusframework.jms.actions.PurgeJmsQueuesAction.Builder.purgeQueues;
65+
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
6566

6667
/**
6768
* @author Martin Maher
@@ -94,18 +95,18 @@ public void testFaxQueuedScenario() {
9495
FaxType fax = payloadHelper.createFaxType("Joe Bloggs", "Testing the default scenario", "01-223344", "01-556677");
9596

9697
$(send(simulatorInboundEndpoint)
97-
.message()
98-
.body(new MarshallingPayloadBuilder(payloadHelper.generateSendFaxMessage("Non-Matchable Scenario", fax, referenceId.getValue(), true),
99-
payloadHelper.getMarshaller())));
98+
.message()
99+
.body(new MarshallingPayloadBuilder(payloadHelper.generateSendFaxMessage("Non-Matchable Scenario", fax, referenceId.getValue(), true),
100+
payloadHelper.getMarshaller())));
100101

101102
$(receive(simulatorStatusEndpoint)
102-
.message()
103-
.body(new MarshallingPayloadBuilder(payloadHelper.generateFaxStatusMessage(referenceId.getValue(), FaxStatusEnumType.QUEUED, "The fax message has been queued and will be send shortly"),
104-
payloadHelper.getMarshaller())));
103+
.message()
104+
.body(new MarshallingPayloadBuilder(payloadHelper.generateFaxStatusMessage(referenceId.getValue(), FaxStatusEnumType.QUEUED, "The fax message has been queued and will be send shortly"),
105+
payloadHelper.getMarshaller())));
105106

106107
// check no other status messages are sent; the default scenario only sends one status message
107108
$(receiveTimeout(simulatorStatusEndpoint)
108-
.timeout(3000));
109+
.timeout(3000));
109110
}
110111

111112
/**
@@ -118,21 +119,21 @@ public void testFaxSentScenario() {
118119
FaxType fax = payloadHelper.createFaxType("Joe Bloggs", "Testing the FaxSent scenario", "01-223344", "01-556677");
119120

120121
$(send(simulatorInboundEndpoint)
121-
.message()
122-
.body(new MarshallingPayloadBuilder(payloadHelper.generateSendFaxMessage("FaxSent", fax, referenceId.getValue(), true),
123-
payloadHelper.getMarshaller())));
122+
.message()
123+
.body(new MarshallingPayloadBuilder(payloadHelper.generateSendFaxMessage("FaxSent", fax, referenceId.getValue(), true),
124+
payloadHelper.getMarshaller())));
124125

125126
$(receive(simulatorStatusEndpoint)
126-
.message()
127-
.body(new MarshallingPayloadBuilder(payloadHelper.generateFaxStatusMessage(referenceId.getValue(), FaxStatusEnumType.QUEUED, "The fax message has been queued and will be send shortly"),
128-
payloadHelper.getMarshaller())));
127+
.message()
128+
.body(new MarshallingPayloadBuilder(payloadHelper.generateFaxStatusMessage(referenceId.getValue(), FaxStatusEnumType.QUEUED, "The fax message has been queued and will be send shortly"),
129+
payloadHelper.getMarshaller())));
129130

130131
$(sleep().milliseconds(2000L));
131132

132133
$(receive(simulatorStatusEndpoint)
133-
.message()
134-
.body(new MarshallingPayloadBuilder(payloadHelper.generateFaxStatusMessage(referenceId.getValue(), FaxStatusEnumType.SUCCESS, "The fax message has been successfully sent"),
135-
payloadHelper.getMarshaller())));
134+
.message()
135+
.body(new MarshallingPayloadBuilder(payloadHelper.generateFaxStatusMessage(referenceId.getValue(), FaxStatusEnumType.SUCCESS, "The fax message has been successfully sent"),
136+
payloadHelper.getMarshaller())));
136137
}
137138

138139
/**
@@ -145,24 +146,24 @@ public void testFaxCancelledScenario() {
145146
FaxType fax = payloadHelper.createFaxType("Joe Bloggs", "Testing the FaxCancelled scenario", "01-223344", "01-556677");
146147

147148
$(send(simulatorInboundEndpoint)
148-
.message()
149-
.body(new MarshallingPayloadBuilder(payloadHelper.generateSendFaxMessage("FaxCancelled", fax, referenceId.getValue(), true),
150-
payloadHelper.getMarshaller())));
149+
.message()
150+
.body(new MarshallingPayloadBuilder(payloadHelper.generateSendFaxMessage("FaxCancelled", fax, referenceId.getValue(), true),
151+
payloadHelper.getMarshaller())));
151152

152153
$(receive(simulatorStatusEndpoint)
153-
.message()
154-
.body(new MarshallingPayloadBuilder(payloadHelper.generateFaxStatusMessage(referenceId.getValue(), FaxStatusEnumType.QUEUED, "The fax message has been queued and will be send shortly"),
155-
payloadHelper.getMarshaller())));
154+
.message()
155+
.body(new MarshallingPayloadBuilder(payloadHelper.generateFaxStatusMessage(referenceId.getValue(), FaxStatusEnumType.QUEUED, "The fax message has been queued and will be send shortly"),
156+
payloadHelper.getMarshaller())));
156157

157158
$(send(simulatorInboundEndpoint)
158-
.message()
159-
.body(new MarshallingPayloadBuilder(payloadHelper.generateCancelFaxMessage(referenceId.getValue()),
160-
payloadHelper.getMarshaller())));
159+
.message()
160+
.body(new MarshallingPayloadBuilder(payloadHelper.generateCancelFaxMessage(referenceId.getValue()),
161+
payloadHelper.getMarshaller())));
161162

162163
$(receive(simulatorStatusEndpoint)
163-
.message()
164-
.body(new MarshallingPayloadBuilder(payloadHelper.generateFaxStatusMessage(referenceId.getValue(), FaxStatusEnumType.CANCELLED, "The fax message has been cancelled"),
165-
payloadHelper.getMarshaller())));
164+
.message()
165+
.body(new MarshallingPayloadBuilder(payloadHelper.generateFaxStatusMessage(referenceId.getValue(), FaxStatusEnumType.CANCELLED, "The fax message has been cancelled"),
166+
payloadHelper.getMarshaller())));
166167
}
167168

168169
/**
@@ -175,19 +176,19 @@ public void testFaxBusyScenario() {
175176
FaxType fax = payloadHelper.createFaxType("Joe Bloggs", "Testing the FaxBusy scenario", "01-223344", "01-556677");
176177

177178
$(send(simulatorInboundEndpoint)
178-
.message()
179-
.body(new MarshallingPayloadBuilder(payloadHelper.generateSendFaxMessage("FaxBusy", fax, referenceId.getValue(), true),
180-
payloadHelper.getMarshaller())));
179+
.message()
180+
.body(new MarshallingPayloadBuilder(payloadHelper.generateSendFaxMessage("FaxBusy", fax, referenceId.getValue(), true),
181+
payloadHelper.getMarshaller())));
181182

182183
$(receive(simulatorStatusEndpoint)
183-
.message()
184-
.body(new MarshallingPayloadBuilder(payloadHelper.generateFaxStatusMessage(referenceId.getValue(), FaxStatusEnumType.QUEUED, "The fax message has been queued and will be send shortly"),
185-
payloadHelper.getMarshaller())));
184+
.message()
185+
.body(new MarshallingPayloadBuilder(payloadHelper.generateFaxStatusMessage(referenceId.getValue(), FaxStatusEnumType.QUEUED, "The fax message has been queued and will be send shortly"),
186+
payloadHelper.getMarshaller())));
186187

187188
$(receive(simulatorStatusEndpoint)
188-
.message()
189-
.body(new MarshallingPayloadBuilder(payloadHelper.generateFaxStatusMessage(referenceId.getValue(), FaxStatusEnumType.ERROR, "Error transmitting fax: The receiving fax was busy"),
190-
payloadHelper.getMarshaller())));
189+
.message()
190+
.body(new MarshallingPayloadBuilder(payloadHelper.generateFaxStatusMessage(referenceId.getValue(), FaxStatusEnumType.ERROR, "Error transmitting fax: The receiving fax was busy"),
191+
payloadHelper.getMarshaller())));
191192
}
192193

193194
/**
@@ -200,19 +201,19 @@ public void testFaxNoAnswerScenario() {
200201
FaxType fax = payloadHelper.createFaxType("Joe Bloggs", "Testing the FaxNoAnswer scenario", "01-223344", "01-556677");
201202

202203
$(send(simulatorInboundEndpoint)
203-
.message()
204-
.body(new MarshallingPayloadBuilder(payloadHelper.generateSendFaxMessage("FaxNoAnswer", fax, referenceId.getValue(), true),
205-
payloadHelper.getMarshaller())));
204+
.message()
205+
.body(new MarshallingPayloadBuilder(payloadHelper.generateSendFaxMessage("FaxNoAnswer", fax, referenceId.getValue(), true),
206+
payloadHelper.getMarshaller())));
206207

207208
$(receive(simulatorStatusEndpoint)
208-
.message()
209-
.body(new MarshallingPayloadBuilder(payloadHelper.generateFaxStatusMessage(referenceId.getValue(), FaxStatusEnumType.QUEUED, "The fax message has been queued and will be send shortly"),
210-
payloadHelper.getMarshaller())));
209+
.message()
210+
.body(new MarshallingPayloadBuilder(payloadHelper.generateFaxStatusMessage(referenceId.getValue(), FaxStatusEnumType.QUEUED, "The fax message has been queued and will be send shortly"),
211+
payloadHelper.getMarshaller())));
211212

212213
$(receive(simulatorStatusEndpoint)
213-
.message()
214-
.body(new MarshallingPayloadBuilder(payloadHelper.generateFaxStatusMessage(referenceId.getValue(), FaxStatusEnumType.ERROR, "Error transmitting fax: No answer from the receiving fax"),
215-
payloadHelper.getMarshaller())));
214+
.message()
215+
.body(new MarshallingPayloadBuilder(payloadHelper.generateFaxStatusMessage(referenceId.getValue(), FaxStatusEnumType.ERROR, "Error transmitting fax: No answer from the receiving fax"),
216+
payloadHelper.getMarshaller())));
216217
}
217218

218219
/**
@@ -230,10 +231,10 @@ public void testUpdateFaxStatusStarter() {
230231
.send()
231232
.post("/api/scenarios/UpdateFaxStatus/launch")
232233
.message()
233-
.contentType(MediaType.APPLICATION_JSON_VALUE)
234+
.contentType(APPLICATION_JSON_VALUE)
234235
.body(asJson(referenceId.asScenarioParameter(),
235-
status.asScenarioParameter(),
236-
statusMessage.asScenarioParameter())
236+
status.asScenarioParameter(),
237+
statusMessage.asScenarioParameter())
237238
));
238239

239240
$(http()
@@ -242,9 +243,9 @@ public void testUpdateFaxStatusStarter() {
242243

243244

244245
$(receive(simulatorStatusEndpoint)
245-
.message()
246-
.body(new MarshallingPayloadBuilder(payloadHelper.generateFaxStatusMessage(referenceId.getValue(), FaxStatusEnumType.QUEUED, statusMessage.getValue()),
247-
payloadHelper.getMarshaller())));
246+
.message()
247+
.body(new MarshallingPayloadBuilder(payloadHelper.generateFaxStatusMessage(referenceId.getValue(), FaxStatusEnumType.QUEUED, statusMessage.getValue()),
248+
payloadHelper.getMarshaller())));
248249

249250
}
250251

@@ -284,27 +285,27 @@ public ActiveMQConnectionFactory connectionFactory() {
284285
@Bean
285286
public JmsEndpoint simulatorInboundEndpoint() {
286287
return CitrusEndpoints.jms()
287-
.asynchronous()
288-
.connectionFactory(connectionFactory())
289-
.destination("Fax.Inbound")
290-
.build();
288+
.asynchronous()
289+
.connectionFactory(connectionFactory())
290+
.destination("Fax.Inbound")
291+
.build();
291292
}
292293

293294
@Bean
294295
public JmsEndpoint simulatorStatusEndpoint() {
295296
return CitrusEndpoints.jms()
296-
.asynchronous()
297-
.connectionFactory(connectionFactory())
298-
.destination("Fax.Status")
299-
.build();
297+
.asynchronous()
298+
.connectionFactory(connectionFactory())
299+
.destination("Fax.Status")
300+
.build();
300301
}
301302

302303
@Bean
303304
public HttpClient simulatorRestEndpoint() {
304305
return CitrusEndpoints.http().client()
305-
.requestUrl(String.format("http://localhost:%s", 8080))
306-
.contentType(MediaType.APPLICATION_JSON_VALUE)
307-
.build();
306+
.requestUrl(format("http://localhost:%s", 8080))
307+
.contentType(APPLICATION_JSON_VALUE)
308+
.build();
308309
}
309310

310311
@Bean

0 commit comments

Comments
 (0)