Skip to content

Commit

Permalink
chore(#162): Update to Citrus 4.x
Browse files Browse the repository at this point in the history
- Remove ScenarioDesigner as designer concept has been removed in Citrus 4.x
- Use ScenarioRunner as only successor for running test actions
  • Loading branch information
christophd committed Sep 11, 2023
1 parent 034acf9 commit e6e1a1f
Show file tree
Hide file tree
Showing 143 changed files with 2,189 additions and 2,036 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ repositories {
mavenCentral()
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
sourceCompatibility = 17
targetCompatibility = 17
dependencies {
implementation("org.springframework.boot:spring-boot-starter-web")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
public class DefaultScenario extends AbstractSimulatorScenario {

@Override
public void run(ScenarioDesigner scenario) {
public void run(ScenarioRunner scenario) {
scenario
.receive();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
public class GoodByeScenario extends AbstractSimulatorScenario {

@Override
public void run(ScenarioDesigner scenario) {
public void run(ScenarioRunner scenario) {
scenario
.receive()
.payload("<GoodBye xmlns=\"http://citrusframework.org/schemas/hello\">" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class GoodNightScenario extends AbstractSimulatorScenario {
private static final String CORRELATION_ID = "correlationId";

@Override
public void run(ScenarioDesigner scenario) {
public void run(ScenarioRunner scenario) {
scenario
.receive()
.payload("<GoodNight xmlns=\"http://citrusframework.org/schemas/hello\">" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
public class HelloScenario extends AbstractSimulatorScenario {

@Override
public void run(ScenarioDesigner scenario) {
public void run(ScenarioRunner scenario) {
scenario.echo("Simulator: ${simulator.name}");

scenario
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
public class DefaultScenario extends AbstractSimulatorScenario {

@Override
public void run(ScenarioDesigner scenario) {
public void run(ScenarioRunner scenario) {
scenario
.receive();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
public class GoodByeScenario extends AbstractSimulatorScenario {

@Override
public void run(ScenarioDesigner scenario) {
public void run(ScenarioRunner scenario) {
scenario
.receive()
.payload("<mail-message xmlns=\"http://www.citrusframework.org/schema/mail/message\">" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
public class GoodNightScenario extends AbstractSimulatorScenario {

@Override
public void run(ScenarioDesigner scenario) {
public void run(ScenarioRunner scenario) {
scenario
.receive()
.payload("<mail-message xmlns=\"http://www.citrusframework.org/schema/mail/message\">" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
public class HelloScenario extends AbstractSimulatorScenario {

@Override
public void run(ScenarioDesigner scenario) {
public void run(ScenarioRunner scenario) {
scenario.echo("Simulator: ${simulator.name}");

scenario
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class GoodByeStarter extends AbstractScenarioStarter {
private TemplateService templateService;

@Override
public void run(ScenarioDesigner scenario) {
public void run(ScenarioRunner scenario) {
scenario.echo("GoodBye starter was executed!");
scenario.echo("${payload}");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
public class DefaultScenario extends AbstractSimulatorScenario {

@Override
public void run(ScenarioDesigner scenario) {
public void run(ScenarioRunner scenario) {
scenario
.receive();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
public class GoodByeScenario extends AbstractSimulatorScenario {

@Override
public void run(ScenarioDesigner scenario) {
public void run(ScenarioRunner scenario) {
scenario
.http()
.receive()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class GoodNightScenario extends AbstractSimulatorScenario {
private static final String CORRELATION_ID = "x-correlationid";

@Override
public void run(ScenarioDesigner scenario) {
public void run(ScenarioRunner scenario) {
scenario
.http()
.receive()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
public class HelloScenario extends AbstractSimulatorScenario {

@Override
public void run(ScenarioDesigner scenario) {
public void run(ScenarioRunner scenario) {
scenario.echo("Simulator: ${simulator.name}");

scenario
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class GoodByeStarter extends AbstractScenarioStarter {
private TemplateService templateService;

@Override
public void run(ScenarioDesigner scenario) {
public void run(ScenarioRunner scenario) {
scenario.echo("GoodBye starter was executed!");
scenario.echo("${payload}");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
public class DefaultScenario extends AbstractSimulatorScenario {

@Override
public void run(ScenarioDesigner scenario) {
public void run(ScenarioRunner scenario) {
scenario
.soap()
.sendFault()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
public class GoodByeScenario extends AbstractSimulatorScenario {

@Override
public void run(ScenarioDesigner scenario) {
public void run(ScenarioRunner scenario) {
scenario
.soap()
.receive()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
public class GoodNightScenario extends AbstractSimulatorScenario {

@Override
public void run(ScenarioDesigner scenario) {
public void run(ScenarioRunner scenario) {
scenario.correlation().start()
.withHandler(this);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
public class HelloScenario extends AbstractSimulatorScenario {

@Override
public void run(ScenarioDesigner scenario) {
public void run(ScenarioRunner scenario) {
scenario
.soap()
.receive()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
public class DefaultScenario extends AbstractSimulatorScenario {

@Override
public void run(ScenarioDesigner scenario) {
public void run(ScenarioRunner scenario) {
scenario
.soap()
.sendFault()
Expand Down
2 changes: 1 addition & 1 deletion simulator-docs/src/main/asciidoc/endpoint-support.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ scenarios for different mail messages.
public class HelloScenario extends AbstractSimulatorScenario {
@Override
public void run(ScenarioDesigner scenario) {
public void run(ScenarioRunner scenario) {
scenario
.receive()
.payload("<mail-message xmlns=\"http://www.citrusframework.org/schema/mail/message\">" +
Expand Down
2 changes: 1 addition & 1 deletion simulator-docs/src/main/asciidoc/installation.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,6 @@ favorite Java IDE. Build tools like Maven and Gradle compile and package the sim
The simulator web application should start within seconds. Once the application is up and running on your local machine
you can open your browser and point to link:http://localhost:8080[http://localhost:8080].

Now everything is set up and you can start to create some simulator scenarios.
Now everything is set up and you can start to create some simulator scenarios.

That's it you are ready to use the Citrus simulator.
4 changes: 2 additions & 2 deletions simulator-docs/src/main/asciidoc/intermediate-messages.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Let us clarify this with a simple example.
public class GoodNightScenario extends AbstractSimulatorScenario {
@Override
public void run(ScenarioDesigner scenario) {
public void run(ScenarioRunner scenario) {
scenario
.receive()
.payload("<GoodNight xmlns=\"http://citrusframework.org/schemas/hello\">" +
Expand Down Expand Up @@ -58,7 +58,7 @@ public class FaxCancelledScenario extends AbstractFaxScenario {
public static final String REFERENCE_ID_XPATH = "//fax:referenceId";
@Override
public void run(ScenarioDesigner scenario) {
public void run(ScenarioRunner scenario) {
scenario
.receive()
.xpath(ROOT_ELEMENT_XPATH, "SendFaxMessage")
Expand Down
4 changes: 2 additions & 2 deletions simulator-docs/src/main/asciidoc/jms-support.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ public class HelloJmsScenario extends AbstractSimulatorScenario {
private JmsEndpoint replyEndpoint;
@Override
public void run(ScenarioDesigner scenario) {
public void run(ScenarioRunner scenario) {
scenario
.receive()
.payload("<Hello xmlns=\"http://citrusframework.org/schemas/hello\">" +
Expand Down Expand Up @@ -224,7 +224,7 @@ provided to the waiting producer on the reply destination.
public class HelloJmsScenario extends AbstractSimulatorScenario {
@Override
public void run(ScenarioDesigner scenario) {
public void run(ScenarioRunner scenario) {
scenario
.receive()
.payload("<Hello xmlns=\"http://citrusframework.org/schemas/hello\">" +
Expand Down
4 changes: 2 additions & 2 deletions simulator-docs/src/main/asciidoc/rest-support.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ This looks like follows:
public class HelloScenario extends AbstractSimulatorScenario {
@Override
public void run(ScenarioDesigner scenario) {
public void run(ScenarioRunner scenario) {
scenario
.receive()
.payload("<Hello xmlns=\"http://citrusframework.org/schemas/hello\">" +
Expand Down Expand Up @@ -229,7 +229,7 @@ You can specify the Http status code very easy when using the Citrus Java DSL me
public class HelloScenario extends AbstractSimulatorScenario {
@Override
public void run(ScenarioDesigner scenario) {
public void run(ScenarioRunner scenario) {
scenario
.http()
.receive()
Expand Down
4 changes: 2 additions & 2 deletions simulator-docs/src/main/asciidoc/scenarios.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ So a typical simulator scenario can look like the following code sample.
public class HelloScenario extends AbstractSimulatorScenario {
@Override
public void run(ScenarioDesigner scenario) {
public void run(ScenarioRunner scenario) {
scenario
.receive()
.payload("<Hello xmlns=\"http://citrusframework.org/schemas/hello\">" +
Expand Down Expand Up @@ -61,7 +61,7 @@ So we could also extract dynamic values from the request in order to reuse those
public class HelloScenario extends AbstractSimulatorScenario {
@Override
public void run(ScenarioDesigner scenario) {
public void run(ScenarioRunner scenario) {
scenario
.receive()
.payload("<Hello xmlns=\"http://citrusframework.org/schemas/hello\">" +
Expand Down
2 changes: 1 addition & 1 deletion simulator-docs/src/main/asciidoc/ws-support.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ within the simulator we can simply send back a response message in the scenario.
public class HelloScenario extends AbstractSimulatorScenario {
@Override
public void run(ScenarioDesigner scenario) {
public void run(ScenarioRunner scenario) {
scenario
.soap()
.receive()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
/*
* Copyright 2006-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.citrusframework.simulator.sample.config;

import java.io.IOException;
import java.net.URL;
import java.security.KeyManagementException;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.security.cert.CertificateException;
import javax.net.ssl.SSLContext;

import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
import org.apache.hc.client5.http.impl.classic.HttpClients;
import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager;
import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManagerBuilder;
import org.apache.hc.client5.http.ssl.NoopHostnameVerifier;
import org.apache.hc.client5.http.ssl.SSLConnectionSocketFactory;
import org.apache.hc.client5.http.ssl.TrustSelfSignedStrategy;
import org.apache.hc.core5.ssl.SSLContexts;
import org.citrusframework.dsl.endpoint.CitrusEndpoints;
import org.citrusframework.http.client.HttpClient;
import org.springframework.beans.factory.BeanCreationException;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;

@Configuration
public class HttpClientConfig {

@Value("${citrus.simulator.defaultTimeout}")
private long defaultTimeout;

@Value("${server.port}")
private int port;

@Value("${server.ssl.key-store}")
private URL keyStore;

@Value("${server.ssl.key-store-password}")
private String keyStorePassword;

@Bean
public HttpClient simulatorHttpClientEndpoint() {
return CitrusEndpoints.http()
.client()
.timeout(defaultTimeout)
.requestUrl(String.format("https://localhost:%s/", port))
.requestFactory(sslRequestFactory())
.build();
}

@Bean
public CloseableHttpClient httpClient() {
try {
SSLContext sslcontext = SSLContexts.custom()
.loadTrustMaterial(keyStore, keyStorePassword.toCharArray(),
new TrustSelfSignedStrategy())
.build();

SSLConnectionSocketFactory sslSocketFactory = new SSLConnectionSocketFactory(
sslcontext, NoopHostnameVerifier.INSTANCE);

PoolingHttpClientConnectionManager connectionManager = PoolingHttpClientConnectionManagerBuilder.create()
.setSSLSocketFactory(sslSocketFactory)
.build();

return HttpClients.custom()
.setConnectionManager(connectionManager)
.build();
} catch (IOException | CertificateException | NoSuchAlgorithmException | KeyStoreException | KeyManagementException e) {
throw new BeanCreationException("Failed to create http client for ssl connection", e);
}
}

@Bean
public HttpComponentsClientHttpRequestFactory sslRequestFactory() {
return new HttpComponentsClientHttpRequestFactory(httpClient());
}

}
Loading

0 comments on commit e6e1a1f

Please sign in to comment.