From f44acceea1b3a8d39ab3108b273380e542f43554 Mon Sep 17 00:00:00 2001 From: christophd Date: Sat, 30 Jun 2018 19:18:13 +0200 Subject: [PATCH] #15 Update to Spring Boot 2.0 --- pom.xml | 16 +- .../resources/archetype-resources/pom.xml | 128 ++++++++++----- .../resources/archetype-resources/pom.xml | 60 ++++--- .../resources/archetype-resources/pom.xml | 59 +++++-- .../resources/archetype-resources/pom.xml | 59 +++++-- .../resources/archetype-resources/pom.xml | 60 ++++--- .../resources/archetype-resources/pom.xml | 60 ++++--- simulator-samples/pom.xml | 2 +- simulator-samples/sample-bank-service/pom.xml | 57 ++++--- simulator-samples/sample-combined/pom.xml | 117 +++++++++----- simulator-samples/sample-jms-fax/pom.xml | 149 +++++++++++------- simulator-samples/sample-jms/pom.xml | 120 +++++++++----- simulator-samples/sample-mail/pom.xml | 55 +++++-- simulator-samples/sample-rest/pom.xml | 58 ++++--- .../citrus/simulator/SimulatorRestIT.java | 8 + simulator-samples/sample-swagger/pom.xml | 55 +++++-- simulator-samples/sample-ws-client/pom.xml | 58 ++++--- simulator-samples/sample-ws/pom.xml | 57 +++++-- simulator-samples/sample-wsdl/pom.xml | 55 +++++-- .../endpoint/SimulatorEndpointPoller.java | 1 - .../http/HttpRequestAnnotationMatcher.java | 25 +-- .../simulator/http/InterceptorHttp.java | 5 +- .../listener/SimulatorStatusListener.java | 8 +- .../simulator/service/ActivityService.java | 4 +- .../simulator/service/MessageService.java | 15 +- .../HttpRequestAnnotationMatcherTest.java | 67 ++++---- 26 files changed, 890 insertions(+), 468 deletions(-) diff --git a/pom.xml b/pom.xml index b8fedeabf..0f2f9245d 100644 --- a/pom.xml +++ b/pom.xml @@ -17,14 +17,14 @@ UTF-8 UTF-8 - 2.7.3 - 4.3.14.RELEASE - 2.4.2.RELEASE - 1.5.10.RELEASE + 2.8.0-SNAPSHOT + 5.0.7.RELEASE + 3.0.1.RELEASE + 2.0.3.RELEASE 1.7.25 1.2.3 - 6.11 - 1.16.18 + 6.14.3 + 1.18.0 -Xdoclint:none @@ -365,7 +365,7 @@ maven-surefire-plugin - 2.20.1 + 2.22.0 once false @@ -374,7 +374,7 @@ maven-failsafe-plugin - 2.20.1 + 2.22.0 false diff --git a/simulator-archetypes/archetype-jms/src/main/resources/archetype-resources/pom.xml b/simulator-archetypes/archetype-jms/src/main/resources/archetype-resources/pom.xml index 260ad8e45..abba2426b 100644 --- a/simulator-archetypes/archetype-jms/src/main/resources/archetype-resources/pom.xml +++ b/simulator-archetypes/archetype-jms/src/main/resources/archetype-resources/pom.xml @@ -13,11 +13,11 @@ UTF-8 UTF-8 - 2.7.3 + 2.7.8-SNAPSHOT 1.1.0-SNAPSHOT - 1.5.10.RELEASE - 5.15.2 - 6.11 + 2.0.3.RELEASE + 5.15.4 + 6.14.3 @@ -72,11 +72,6 @@ activemq-spring ${activemq.version} - - org.apache.xbean - xbean-spring - 4.4 - org.testng @@ -101,7 +96,7 @@ org.apache.maven.plugins maven-failsafe-plugin - 2.20 + 2.22.0 false @@ -131,26 +126,13 @@ ${activemq.version} false + + + log4j.configuration + log4j.properties + + - - - start-activemq - pre-integration-test - - run - - - true - - - - stop-activemq - post-integration-test - - stop - - - @@ -162,23 +144,11 @@ - pre-integration-test - - start - - - true - 1000 - 180 - - - - post-integration-test - stop + repackage - true + executable @@ -186,4 +156,76 @@ + + + activemq-embedded + + + embedded + + + + + + org.apache.activemq.tooling + activemq-maven-plugin + + + start-activemq + pre-integration-test + + run + + + true + + + + stop-activemq + post-integration-test + + stop + + + + + + + + + + simulator-embedded + + + embedded + + + + + + org.springframework.boot + spring-boot-maven-plugin + + true + + + + pre-integration-test + + start + + + + post-integration-test + + stop + + + + + + + + + \ No newline at end of file diff --git a/simulator-archetypes/archetype-mail/src/main/resources/archetype-resources/pom.xml b/simulator-archetypes/archetype-mail/src/main/resources/archetype-resources/pom.xml index d3fae6173..14434f636 100644 --- a/simulator-archetypes/archetype-mail/src/main/resources/archetype-resources/pom.xml +++ b/simulator-archetypes/archetype-mail/src/main/resources/archetype-resources/pom.xml @@ -13,10 +13,10 @@ UTF-8 UTF-8 + 2.7.8-SNAPSHOT 1.1.0-SNAPSHOT - 2.7.3 - 1.5.10.RELEASE - 6.11 + 2.0.3.RELEASE + 6.14.3 @@ -83,7 +83,7 @@ org.apache.maven.plugins maven-failsafe-plugin - 2.20 + 2.22.0 false @@ -116,23 +116,11 @@ - pre-integration-test - start + repackage - true - 1000 - 180 - - - - post-integration-test - - stop - - - true + executable @@ -140,4 +128,40 @@ + + + simulator-embedded + + + embedded + + + + + + org.springframework.boot + spring-boot-maven-plugin + + true + + + + pre-integration-test + + start + + + + post-integration-test + + stop + + + + + + + + + \ No newline at end of file diff --git a/simulator-archetypes/archetype-rest/src/main/resources/archetype-resources/pom.xml b/simulator-archetypes/archetype-rest/src/main/resources/archetype-resources/pom.xml index 1ce5e85dd..b6789f846 100644 --- a/simulator-archetypes/archetype-rest/src/main/resources/archetype-resources/pom.xml +++ b/simulator-archetypes/archetype-rest/src/main/resources/archetype-resources/pom.xml @@ -13,9 +13,10 @@ UTF-8 UTF-8 + 2.7.8-SNAPSHOT 1.1.0-SNAPSHOT - 1.5.10.RELEASE - 6.11 + 2.0.3.RELEASE + 6.14.3 @@ -75,7 +76,7 @@ org.apache.maven.plugins maven-failsafe-plugin - 2.20 + 2.22.0 false @@ -108,23 +109,11 @@ - pre-integration-test - start + repackage - true - 1000 - 180 - - - - post-integration-test - - stop - - - true + executable @@ -132,4 +121,40 @@ + + + simulator-embedded + + + embedded + + + + + + org.springframework.boot + spring-boot-maven-plugin + + true + + + + pre-integration-test + + start + + + + post-integration-test + + stop + + + + + + + + + \ No newline at end of file diff --git a/simulator-archetypes/archetype-swagger/src/main/resources/archetype-resources/pom.xml b/simulator-archetypes/archetype-swagger/src/main/resources/archetype-resources/pom.xml index 80dfbf334..3bbac4481 100644 --- a/simulator-archetypes/archetype-swagger/src/main/resources/archetype-resources/pom.xml +++ b/simulator-archetypes/archetype-swagger/src/main/resources/archetype-resources/pom.xml @@ -13,9 +13,10 @@ UTF-8 UTF-8 + 2.7.8-SNAPSHOT 1.1.0-SNAPSHOT - 1.5.10.RELEASE - 6.11 + 2.0.3.RELEASE + 6.14.3 @@ -75,7 +76,7 @@ org.apache.maven.plugins maven-failsafe-plugin - 2.20 + 2.22.0 false @@ -108,23 +109,11 @@ - pre-integration-test - start + repackage - true - 1000 - 180 - - - - post-integration-test - - stop - - - true + executable @@ -132,4 +121,40 @@ + + + simulator-embedded + + + embedded + + + + + + org.springframework.boot + spring-boot-maven-plugin + + true + + + + pre-integration-test + + start + + + + post-integration-test + + stop + + + + + + + + + \ No newline at end of file diff --git a/simulator-archetypes/archetype-ws/src/main/resources/archetype-resources/pom.xml b/simulator-archetypes/archetype-ws/src/main/resources/archetype-resources/pom.xml index 4b36475bf..8238e5f89 100644 --- a/simulator-archetypes/archetype-ws/src/main/resources/archetype-resources/pom.xml +++ b/simulator-archetypes/archetype-ws/src/main/resources/archetype-resources/pom.xml @@ -13,10 +13,10 @@ UTF-8 UTF-8 - 2.7.3 + 2.7.8-SNAPSHOT 1.1.0-SNAPSHOT - 1.5.10.RELEASE - 6.11 + 2.0.3.RELEASE + 6.14.3 @@ -83,7 +83,7 @@ org.apache.maven.plugins maven-failsafe-plugin - 2.20 + 2.22.0 false @@ -116,23 +116,11 @@ - pre-integration-test - start + repackage - true - 1000 - 180 - - - - post-integration-test - - stop - - - true + executable @@ -140,4 +128,40 @@ + + + simulator-embedded + + + embedded + + + + + + org.springframework.boot + spring-boot-maven-plugin + + true + + + + pre-integration-test + + start + + + + post-integration-test + + stop + + + + + + + + + \ No newline at end of file diff --git a/simulator-archetypes/archetype-wsdl/src/main/resources/archetype-resources/pom.xml b/simulator-archetypes/archetype-wsdl/src/main/resources/archetype-resources/pom.xml index 60bb0b9fb..88ff68f20 100644 --- a/simulator-archetypes/archetype-wsdl/src/main/resources/archetype-resources/pom.xml +++ b/simulator-archetypes/archetype-wsdl/src/main/resources/archetype-resources/pom.xml @@ -13,10 +13,10 @@ UTF-8 UTF-8 - 2.7.3 + 2.7.8-SNAPSHOT 1.1.0-SNAPSHOT - 1.5.10.RELEASE - 6.11 + 2.0.3.RELEASE + 6.14.3 @@ -83,7 +83,7 @@ org.apache.maven.plugins maven-failsafe-plugin - 2.20 + 2.22.0 false @@ -116,23 +116,11 @@ - pre-integration-test - start + repackage - true - 1000 - 180 - - - - post-integration-test - - stop - - - true + executable @@ -140,4 +128,40 @@ + + + simulator-embedded + + + embedded + + + + + + org.springframework.boot + spring-boot-maven-plugin + + true + + + + pre-integration-test + + start + + + + post-integration-test + + stop + + + + + + + + + \ No newline at end of file diff --git a/simulator-samples/pom.xml b/simulator-samples/pom.xml index a727cd3ca..cd4903b82 100644 --- a/simulator-samples/pom.xml +++ b/simulator-samples/pom.xml @@ -35,7 +35,7 @@ org.apache.maven.plugins maven-failsafe-plugin - 2.20 + 2.22.0 false diff --git a/simulator-samples/sample-bank-service/pom.xml b/simulator-samples/sample-bank-service/pom.xml index 5430d7e3d..b44e81a39 100644 --- a/simulator-samples/sample-bank-service/pom.xml +++ b/simulator-samples/sample-bank-service/pom.xml @@ -46,7 +46,6 @@ citrus-simulator-ui - commons-validator commons-validator @@ -92,36 +91,58 @@ org.springframework.boot spring-boot-maven-plugin + ${spring.boot.version} true - 1000 - 180 - pre-integration-test - - start - - - true - 1000 - 180 - - - - post-integration-test - stop + repackage - true + executable - + + + simulator-embedded + + + embedded + + + + + + org.springframework.boot + spring-boot-maven-plugin + + true + + + + pre-integration-test + + start + + + + post-integration-test + + stop + + + + + + + + + diff --git a/simulator-samples/sample-combined/pom.xml b/simulator-samples/sample-combined/pom.xml index 361425d5d..51ae96675 100644 --- a/simulator-samples/sample-combined/pom.xml +++ b/simulator-samples/sample-combined/pom.xml @@ -50,6 +50,7 @@ citrus-simulator-ui + com.consol.citrus citrus-jms @@ -86,11 +87,6 @@ activemq-spring ${activemq.version} - - org.apache.xbean - xbean-spring - 4.4 - @@ -130,60 +126,99 @@ - - - start-activemq - pre-integration-test - - run - - - true - - - - stop-activemq - post-integration-test - - stop - - - org.springframework.boot spring-boot-maven-plugin + ${spring.boot.version} true - 1000 - 180 - pre-integration-test - start + repackage - true - 1000 - 180 - - - - post-integration-test - - stop - - - true + executable - + + + activemq-embedded + + + embedded + + + + + + org.apache.activemq.tooling + activemq-maven-plugin + + + start-activemq + pre-integration-test + + run + + + true + + + + stop-activemq + post-integration-test + + stop + + + + + + + + + + simulator-embedded + + + embedded + + + + + + org.springframework.boot + spring-boot-maven-plugin + + true + + + + pre-integration-test + + start + + + + post-integration-test + + stop + + + + + + + + + diff --git a/simulator-samples/sample-jms-fax/pom.xml b/simulator-samples/sample-jms-fax/pom.xml index be97ae551..bb1cb8bf7 100644 --- a/simulator-samples/sample-jms-fax/pom.xml +++ b/simulator-samples/sample-jms-fax/pom.xml @@ -15,7 +15,7 @@ ${project.artifactId} - 5.15.2 + 5.15.4 @@ -99,8 +99,6 @@ org.apache.maven.plugins maven-failsafe-plugin - - integration-tests @@ -125,7 +123,6 @@ activemq-maven-plugin ${activemq.version} - broker:(tcp://localhost:61616)?useJmx=true&persistent=false false @@ -134,57 +131,6 @@ - - - start-activemq - pre-integration-test - - run - - - true - - - - stop-activemq - post-integration-test - - stop - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - true - 1000 - 180 - - - - pre-integration-test - - start - - - true - 1000 - 180 - - - - post-integration-test - - stop - - - true - - - @@ -210,7 +156,98 @@ + + + org.springframework.boot + spring-boot-maven-plugin + ${spring.boot.version} + + true + + + + + repackage + + + executable + + + + - + + + activemq-embedded + + + embedded + + + + + + org.apache.activemq.tooling + activemq-maven-plugin + + + start-activemq + pre-integration-test + + run + + + true + + + + stop-activemq + post-integration-test + + stop + + + + + + + + + + simulator-embedded + + + embedded + + + + + + org.springframework.boot + spring-boot-maven-plugin + + true + + + + pre-integration-test + + start + + + + post-integration-test + + stop + + + + + + + + + + \ No newline at end of file diff --git a/simulator-samples/sample-jms/pom.xml b/simulator-samples/sample-jms/pom.xml index 0915b290a..fab0a35b4 100644 --- a/simulator-samples/sample-jms/pom.xml +++ b/simulator-samples/sample-jms/pom.xml @@ -15,7 +15,7 @@ ${project.artifactId} - 5.15.2 + 5.15.4 @@ -73,11 +73,6 @@ activemq-spring ${activemq.version} - - org.apache.xbean - xbean-spring - 4.4 - @@ -117,60 +112,99 @@ - - - start-activemq - pre-integration-test - - run - - - true - - - - stop-activemq - post-integration-test - - stop - - - org.springframework.boot spring-boot-maven-plugin + ${spring.boot.version} true - 1000 - 180 - pre-integration-test - start + repackage - true - 1000 - 180 - - - - post-integration-test - - stop - - - true + executable - - + + + activemq-embedded + + + embedded + + + + + + org.apache.activemq.tooling + activemq-maven-plugin + + + start-activemq + pre-integration-test + + run + + + true + + + + stop-activemq + post-integration-test + + stop + + + + + + + + + + simulator-embedded + + + embedded + + + + + + org.springframework.boot + spring-boot-maven-plugin + + true + + + + pre-integration-test + + start + + + + post-integration-test + + stop + + + + + + + + + + \ No newline at end of file diff --git a/simulator-samples/sample-mail/pom.xml b/simulator-samples/sample-mail/pom.xml index 309e15baf..dbb332ffd 100644 --- a/simulator-samples/sample-mail/pom.xml +++ b/simulator-samples/sample-mail/pom.xml @@ -87,30 +87,17 @@ org.springframework.boot spring-boot-maven-plugin + ${spring.boot.version} true - 1000 - 180 - pre-integration-test - start + repackage - true - 1000 - 180 - - - - post-integration-test - - stop - - - true + executable @@ -118,4 +105,40 @@ + + + simulator-embedded + + + embedded + + + + + + org.springframework.boot + spring-boot-maven-plugin + + true + + + + pre-integration-test + + start + + + + post-integration-test + + stop + + + + + + + + + \ No newline at end of file diff --git a/simulator-samples/sample-rest/pom.xml b/simulator-samples/sample-rest/pom.xml index eb0a84d6a..cb399bf7b 100644 --- a/simulator-samples/sample-rest/pom.xml +++ b/simulator-samples/sample-rest/pom.xml @@ -80,36 +80,58 @@ org.springframework.boot spring-boot-maven-plugin + ${spring.boot.version} true - 1000 - 180 - pre-integration-test - - start - - - true - 1000 - 180 - - - - post-integration-test - stop + repackage - true + executable - - + + + simulator-embedded + + + embedded + + + + + + org.springframework.boot + spring-boot-maven-plugin + + true + + + + pre-integration-test + + start + + + + post-integration-test + + stop + + + + + + + + + + \ No newline at end of file diff --git a/simulator-samples/sample-rest/src/test/java/com/consol/citrus/simulator/SimulatorRestIT.java b/simulator-samples/sample-rest/src/test/java/com/consol/citrus/simulator/SimulatorRestIT.java index c6e67ae19..9824f8929 100644 --- a/simulator-samples/sample-rest/src/test/java/com/consol/citrus/simulator/SimulatorRestIT.java +++ b/simulator-samples/sample-rest/src/test/java/com/consol/citrus/simulator/SimulatorRestIT.java @@ -21,6 +21,7 @@ import com.consol.citrus.http.client.HttpClient; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; import org.testng.annotations.Test; /** @@ -43,6 +44,7 @@ public void testHelloRequest() { http().client(simulatorClient) .send() .post("hello") + .contentType(MediaType.APPLICATION_XML_VALUE) .payload("" + "Say Hello!" + ""); @@ -63,6 +65,7 @@ public void testGoodByeRequest() { http().client(simulatorClient) .send() .post("goodbye") + .contentType(MediaType.APPLICATION_XML_VALUE) .payload("" + "Say GoodBye!" + ""); @@ -83,6 +86,7 @@ public void testDefaultRequest() { http().client(simulatorClient) .send() .post() + .contentType(MediaType.APPLICATION_XML_VALUE) .payload("" + "Should trigger default scenario" + ""); @@ -103,6 +107,7 @@ public void testInterveningRequest() { http().client(simulatorClient) .send() .post("goodnight") + .contentType(MediaType.APPLICATION_XML_VALUE) .payload("" + "Go to sleep!" + "") @@ -122,6 +127,7 @@ public void testInterveningRequest() { http().client(simulatorClient) .send() .post() + .contentType(MediaType.APPLICATION_XML_VALUE) .payload("In between!"); http().client(simulatorClient) @@ -136,6 +142,7 @@ public void testInterveningRequest() { http().client(simulatorClient) .send() .post() + .contentType(MediaType.APPLICATION_XML_VALUE) .payload("In between!") .header("x-correlationid", "${correlationId}"); @@ -151,6 +158,7 @@ public void testInterveningRequest() { http().client(simulatorClient) .send() .post() + .contentType(MediaType.APPLICATION_XML_VALUE) .payload("In between!") .header("x-correlationid", "${correlationId}"); diff --git a/simulator-samples/sample-swagger/pom.xml b/simulator-samples/sample-swagger/pom.xml index 51643ed47..884cfab98 100644 --- a/simulator-samples/sample-swagger/pom.xml +++ b/simulator-samples/sample-swagger/pom.xml @@ -80,30 +80,17 @@ org.springframework.boot spring-boot-maven-plugin + ${spring.boot.version} true - 1000 - 180 - pre-integration-test - start + repackage - true - 1000 - 180 - - - - post-integration-test - - stop - - - true + executable @@ -111,4 +98,40 @@ + + + simulator-embedded + + + embedded + + + + + + org.springframework.boot + spring-boot-maven-plugin + + true + + + + pre-integration-test + + start + + + + post-integration-test + + stop + + + + + + + + + \ No newline at end of file diff --git a/simulator-samples/sample-ws-client/pom.xml b/simulator-samples/sample-ws-client/pom.xml index dd230d364..c42a273c4 100644 --- a/simulator-samples/sample-ws-client/pom.xml +++ b/simulator-samples/sample-ws-client/pom.xml @@ -86,36 +86,58 @@ org.springframework.boot spring-boot-maven-plugin + ${spring.boot.version} true - 1000 - 180 - pre-integration-test - - start - - - true - 1000 - 180 - - - - post-integration-test - stop + repackage - true + executable - - + + + simulator-embedded + + + embedded + + + + + + org.springframework.boot + spring-boot-maven-plugin + + true + + + + pre-integration-test + + start + + + + post-integration-test + + stop + + + + + + + + + + \ No newline at end of file diff --git a/simulator-samples/sample-ws/pom.xml b/simulator-samples/sample-ws/pom.xml index 850a11535..8324f91e7 100644 --- a/simulator-samples/sample-ws/pom.xml +++ b/simulator-samples/sample-ws/pom.xml @@ -86,30 +86,17 @@ org.springframework.boot spring-boot-maven-plugin + ${spring.boot.version} true - 1000 - 180 - pre-integration-test - start + repackage - true - 1000 - 180 - - - - post-integration-test - - stop - - - true + executable @@ -117,4 +104,40 @@ - + + + simulator-embedded + + + embedded + + + + + + org.springframework.boot + spring-boot-maven-plugin + + true + + + + pre-integration-test + + start + + + + post-integration-test + + stop + + + + + + + + + + \ No newline at end of file diff --git a/simulator-samples/sample-wsdl/pom.xml b/simulator-samples/sample-wsdl/pom.xml index a3d207044..03eab895a 100644 --- a/simulator-samples/sample-wsdl/pom.xml +++ b/simulator-samples/sample-wsdl/pom.xml @@ -86,30 +86,17 @@ org.springframework.boot spring-boot-maven-plugin + ${spring.boot.version} true - 1000 - 180 - pre-integration-test - start + repackage - true - 1000 - 180 - - - - post-integration-test - - stop - - - true + executable @@ -117,4 +104,40 @@ + + + simulator-embedded + + + embedded + + + + + + org.springframework.boot + spring-boot-maven-plugin + + true + + + + pre-integration-test + + start + + + + post-integration-test + + stop + + + + + + + + + \ No newline at end of file diff --git a/simulator-starter/src/main/java/com/consol/citrus/simulator/endpoint/SimulatorEndpointPoller.java b/simulator-starter/src/main/java/com/consol/citrus/simulator/endpoint/SimulatorEndpointPoller.java index 2dd8333e5..ee2edc0c6 100644 --- a/simulator-starter/src/main/java/com/consol/citrus/simulator/endpoint/SimulatorEndpointPoller.java +++ b/simulator-starter/src/main/java/com/consol/citrus/simulator/endpoint/SimulatorEndpointPoller.java @@ -153,7 +153,6 @@ protected Message processRequestMessage(Message request) { */ public void start() { running = true; - taskExecutor.setDaemon(true); taskExecutor.execute(this); } diff --git a/simulator-starter/src/main/java/com/consol/citrus/simulator/http/HttpRequestAnnotationMatcher.java b/simulator-starter/src/main/java/com/consol/citrus/simulator/http/HttpRequestAnnotationMatcher.java index e2acecd9a..cba4481a5 100644 --- a/simulator-starter/src/main/java/com/consol/citrus/simulator/http/HttpRequestAnnotationMatcher.java +++ b/simulator-starter/src/main/java/com/consol/citrus/simulator/http/HttpRequestAnnotationMatcher.java @@ -19,16 +19,11 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.http.HttpMethod; -import org.springframework.util.AntPathMatcher; -import org.springframework.util.PathMatcher; -import org.springframework.util.StringUtils; +import org.springframework.util.*; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Optional; +import java.util.*; import java.util.stream.Collectors; /** @@ -187,17 +182,11 @@ private List getAnnotatedQueryParams(RequestMapping requestMapping) { * @return the list of query parameters or an empty list */ private List getRequestQueryParams(HttpMessage request) { - final List queryParams = new ArrayList<>(); - final String queryParamsStr = request.getQueryParams(); - if (StringUtils.hasLength(queryParamsStr)) { - final String[] tokenizedQueryParams = StringUtils.tokenizeToStringArray(queryParamsStr, - ",", - false, - false); - queryParams.addAll(Arrays.asList(tokenizedQueryParams)); - - } - return queryParams; + return request.getQueryParams() + .entrySet() + .stream() + .map(entry -> entry.getKey() + "=" + entry.getValue()) + .collect(Collectors.toList()); } private List getQueryParamKeys(List queryParams) { diff --git a/simulator-starter/src/main/java/com/consol/citrus/simulator/http/InterceptorHttp.java b/simulator-starter/src/main/java/com/consol/citrus/simulator/http/InterceptorHttp.java index 53449e9a6..22e6d70ed 100644 --- a/simulator-starter/src/main/java/com/consol/citrus/simulator/http/InterceptorHttp.java +++ b/simulator-starter/src/main/java/com/consol/citrus/simulator/http/InterceptorHttp.java @@ -20,6 +20,7 @@ import com.consol.citrus.message.RawMessage; import com.consol.citrus.report.MessageListeners; import com.consol.citrus.util.FileUtils; +import com.consol.citrus.util.TypeConversionUtils; import org.springframework.http.ResponseEntity; import org.springframework.web.servlet.HandlerInterceptor; import org.springframework.web.servlet.ModelAndView; @@ -67,9 +68,9 @@ private String getRequestContent(HttpServletRequest request) throws IOException private String getResponseContent(HttpServletResponse response, Object handler) { if (handler instanceof HttpMessageController) { HttpMessageController handlerController = (HttpMessageController) handler; - ResponseEntity responseEntity = handlerController.getResponseCache(); + ResponseEntity responseEntity = handlerController.getResponseCache(); if (responseEntity != null) { - return responseEntity.getBody(); + return TypeConversionUtils.convertIfNecessary(responseEntity.getBody(), String.class); } } return "Could not extract Http Response"; diff --git a/simulator-starter/src/main/java/com/consol/citrus/simulator/listener/SimulatorStatusListener.java b/simulator-starter/src/main/java/com/consol/citrus/simulator/listener/SimulatorStatusListener.java index 2e09e692a..7f2766c72 100644 --- a/simulator-starter/src/main/java/com/consol/citrus/simulator/listener/SimulatorStatusListener.java +++ b/simulator-starter/src/main/java/com/consol/citrus/simulator/listener/SimulatorStatusListener.java @@ -62,7 +62,7 @@ public class SimulatorStatusListener extends AbstractTestListener implements Tes @Override public void onTestStart(TestCase test) { - runningTests.put(StringUtils.arrayToCommaDelimitedString(getParameters(test)), TestResult.success(test.getName(), test.getParameters())); + runningTests.put(StringUtils.arrayToCommaDelimitedString(getParameters(test)), TestResult.success(test.getName(), test.getTestClass().getSimpleName(), test.getParameters())); } @Override @@ -72,7 +72,7 @@ public void onTestFinish(TestCase test) { @Override public void onTestSuccess(TestCase test) { - TestResult result = TestResult.success(test.getName(), test.getParameters()); + TestResult result = TestResult.success(test.getName(), test.getTestClass().getSimpleName(), test.getParameters()); testResults.addResult(result); LOG.info(result.toString()); executionService.completeScenarioExecutionSuccess(test); @@ -80,11 +80,11 @@ public void onTestSuccess(TestCase test) { @Override public void onTestFailure(TestCase test, Throwable cause) { - TestResult result = TestResult.failed(test.getName(), cause, test.getParameters()); + TestResult result = TestResult.failed(test.getName(), test.getTestClass().getSimpleName(), cause, test.getParameters()); testResults.addResult(result); LOG.info(result.toString()); - LOG.info(result.getFailureCause()); + LOG.info(result.getFailureType()); executionService.completeScenarioExecutionFailure(test, cause); } diff --git a/simulator-starter/src/main/java/com/consol/citrus/simulator/service/ActivityService.java b/simulator-starter/src/main/java/com/consol/citrus/simulator/service/ActivityService.java index eb94261c1..60b29dc44 100644 --- a/simulator-starter/src/main/java/com/consol/citrus/simulator/service/ActivityService.java +++ b/simulator-starter/src/main/java/com/consol/citrus/simulator/service/ActivityService.java @@ -94,7 +94,7 @@ public Collection getScenarioExecutionsByStatus(ScenarioExecu } public ScenarioExecution getScenarioExecutionById(Long id) { - return scenarioExecutionRepository.findOne(id); + return scenarioExecutionRepository.findById(id).orElseThrow(() -> new CitrusRuntimeException(String.format("Failed to find scenario execution for id %s", id))); } /** @@ -207,7 +207,7 @@ private boolean skipTestAction(TestAction testAction) { } private ScenarioExecution lookupScenarioExecution(TestCase testCase) { - return scenarioExecutionRepository.findOne(lookupScenarioExecutionId(testCase)); + return scenarioExecutionRepository.findById(lookupScenarioExecutionId(testCase)).orElseThrow(() -> new CitrusRuntimeException(String.format("Failed to look up scenario execution for test %s", testCase.getName()))); } private long lookupScenarioExecutionId(TestCase testCase) { diff --git a/simulator-starter/src/main/java/com/consol/citrus/simulator/service/MessageService.java b/simulator-starter/src/main/java/com/consol/citrus/simulator/service/MessageService.java index 01f85e367..179efcb93 100644 --- a/simulator-starter/src/main/java/com/consol/citrus/simulator/service/MessageService.java +++ b/simulator-starter/src/main/java/com/consol/citrus/simulator/service/MessageService.java @@ -16,21 +16,16 @@ package com.consol.citrus.simulator.service; -import com.consol.citrus.simulator.model.Message; -import com.consol.citrus.simulator.model.MessageFilter; -import com.consol.citrus.simulator.model.MessageHeader; +import com.consol.citrus.exceptions.CitrusRuntimeException; +import com.consol.citrus.simulator.model.*; import com.consol.citrus.simulator.repository.MessageRepository; import org.apache.commons.lang.StringUtils; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.domain.PageRequest; -import org.springframework.data.domain.Pageable; -import org.springframework.data.domain.Sort; +import org.springframework.data.domain.*; import org.springframework.stereotype.Service; import javax.transaction.Transactional; -import java.time.LocalDate; -import java.time.LocalDateTime; -import java.time.ZoneOffset; +import java.time.*; import java.util.*; /** @@ -63,7 +58,7 @@ public Message saveMessage(Message.Direction direction, String payload, String c } public Message getMessageById(Long id) { - return messageRepository.findOne(id); + return messageRepository.findById(id).orElseThrow(() -> new CitrusRuntimeException(String.format("Failed to find message for id %s", id))); } public List getMessagesMatchingFilter(MessageFilter filter) { diff --git a/simulator-starter/src/test/java/com/consol/citrus/simulator/http/HttpRequestAnnotationMatcherTest.java b/simulator-starter/src/test/java/com/consol/citrus/simulator/http/HttpRequestAnnotationMatcherTest.java index 86a39bd33..a99d5ee2e 100644 --- a/simulator-starter/src/test/java/com/consol/citrus/simulator/http/HttpRequestAnnotationMatcherTest.java +++ b/simulator-starter/src/test/java/com/consol/citrus/simulator/http/HttpRequestAnnotationMatcherTest.java @@ -1,9 +1,7 @@ package com.consol.citrus.simulator.http; import com.consol.citrus.http.message.HttpMessage; -import com.consol.citrus.simulator.scenario.AbstractSimulatorScenario; -import com.consol.citrus.simulator.scenario.Scenario; -import com.consol.citrus.simulator.scenario.SimulatorScenario; +import com.consol.citrus.simulator.scenario.*; import org.mockito.Mockito; import org.springframework.core.annotation.AnnotationUtils; import org.springframework.http.HttpMethod; @@ -13,6 +11,11 @@ import org.testng.annotations.DataProvider; import org.testng.annotations.Test; +import java.util.Collections; +import java.util.Map; +import java.util.stream.Collectors; +import java.util.stream.Stream; + import static org.mockito.Mockito.when; public class HttpRequestAnnotationMatcherTest { @@ -32,175 +35,175 @@ public Object[][] dpScenarios() { return new Object[][]{ new Object[]{ REQ_MAP_WITH_PATH_NAME, - setupHttpMessage("/path/name", HttpMethod.GET, ""), + setupHttpMessage("/path/name", HttpMethod.GET, Collections.emptyMap()), true, true }, new Object[]{ REQ_MAP_WITH_PATH_NAME, - setupHttpMessage("/path/name", HttpMethod.GET, ""), + setupHttpMessage("/path/name", HttpMethod.GET, Collections.emptyMap()), false, true }, new Object[]{ REQ_MAP_WITH_PATH_NAME, - setupHttpMessage("/path/wrong-path", HttpMethod.GET, ""), + setupHttpMessage("/path/wrong-path", HttpMethod.GET, Collections.emptyMap()), true, false }, new Object[]{ REQ_MAP_WITH_PATH_NAME, - setupHttpMessage("", HttpMethod.GET, ""), + setupHttpMessage("", HttpMethod.GET, Collections.emptyMap()), true, false }, new Object[]{ REQ_MAP_WITH_PATH_VALUE, - setupHttpMessage("/path/value", HttpMethod.GET, ""), + setupHttpMessage("/path/value", HttpMethod.GET, Collections.emptyMap()), true, true }, new Object[]{ REQ_MAP_WITH_PATH_VALUE, - setupHttpMessage("/path/wrong-path", HttpMethod.GET, ""), + setupHttpMessage("/path/wrong-path", HttpMethod.GET, Collections.emptyMap()), true, false }, new Object[]{ REQ_MAP_WITH_PATH_VALUE, - setupHttpMessage("", HttpMethod.GET, ""), + setupHttpMessage("", HttpMethod.GET, Collections.emptyMap()), true, false }, new Object[]{ REQ_MAP_WITH_PATH_PLACEHOLDER, - setupHttpMessage("/path/place-holder/123", HttpMethod.GET, ""), + setupHttpMessage("/path/place-holder/123", HttpMethod.GET, Collections.emptyMap()), false, true }, new Object[]{ REQ_MAP_WITH_PATH_PLACEHOLDER, - setupHttpMessage("/path/place-holder/123", HttpMethod.GET, ""), + setupHttpMessage("/path/place-holder/123", HttpMethod.GET, Collections.emptyMap()), true, false }, new Object[]{ REQ_MAP_WITH_PATH_PLACEHOLDER, - setupHttpMessage("/path/wrong-path", HttpMethod.GET, ""), + setupHttpMessage("/path/wrong-path", HttpMethod.GET, Collections.emptyMap()), true, false }, new Object[]{ REQ_MAP_WITH_PATH_PLACEHOLDER, - setupHttpMessage("/path/wrong-path", HttpMethod.GET, ""), + setupHttpMessage("/path/wrong-path", HttpMethod.GET, Collections.emptyMap()), false, false }, new Object[]{ REQ_MAP_WITH_PATH_PATTERN, - setupHttpMessage("/path/pattern/match-me", HttpMethod.GET, ""), + setupHttpMessage("/path/pattern/match-me", HttpMethod.GET, Collections.emptyMap()), true, false }, new Object[]{ REQ_MAP_WITH_PATH_PATTERN, - setupHttpMessage("/path/pattern/match-me", HttpMethod.GET, ""), + setupHttpMessage("/path/pattern/match-me", HttpMethod.GET, Collections.emptyMap()), false, true }, new Object[]{ REQ_MAP_WITH_PATH_PATTERN, - setupHttpMessage("/path/wrong-pattern", HttpMethod.GET, ""), + setupHttpMessage("/path/wrong-pattern", HttpMethod.GET, Collections.emptyMap()), true, false }, new Object[]{ REQ_MAP_WITH_PATH_PATTERN, - setupHttpMessage("/path/wrong-pattern", HttpMethod.GET, ""), + setupHttpMessage("/path/wrong-pattern", HttpMethod.GET, Collections.emptyMap()), false, false }, new Object[]{ REQ_MAP_WITH_PATH_PATTERN, - setupHttpMessage("", HttpMethod.GET, ""), + setupHttpMessage("", HttpMethod.GET, Collections.emptyMap()), true, false }, new Object[]{ REQ_MAP_WITH_PATH_PATTERN, - setupHttpMessage("", HttpMethod.GET, ""), + setupHttpMessage("", HttpMethod.GET, Collections.emptyMap()), false, false }, new Object[]{ REQ_MAP_WITH_PUT_METHOD, - setupHttpMessage("/any-path", HttpMethod.PUT, ""), + setupHttpMessage("/any-path", HttpMethod.PUT, Collections.emptyMap()), true, true }, new Object[]{ REQ_MAP_WITH_PUT_METHOD, - setupHttpMessage("", HttpMethod.GET, ""), + setupHttpMessage("", HttpMethod.GET, Collections.emptyMap()), true, false }, new Object[]{ REQ_MAP_WITH_QUERY_PARAMS, - setupHttpMessage("/any-path", HttpMethod.GET, "a=1"), + setupHttpMessage("/any-path", HttpMethod.GET, Collections.singletonMap("a", "1")), true, true }, new Object[]{ REQ_MAP_WITH_QUERY_PARAMS, - setupHttpMessage("/any-path", HttpMethod.GET, "a="), + setupHttpMessage("/any-path", HttpMethod.GET, Collections.singletonMap("a", null)), true, true }, new Object[]{ REQ_MAP_WITH_QUERY_PARAMS, - setupHttpMessage("/any-path", HttpMethod.GET, "a=1,b=2"), + setupHttpMessage("/any-path", HttpMethod.GET, Stream.of("a=1","b=2").map(item -> item.split("=")).collect(Collectors.toMap(keyValuePair -> keyValuePair[0], keyValuePair -> keyValuePair[1]))), true, false }, new Object[]{ REQ_MAP_WITH_QUERY_PARAMS, - setupHttpMessage("/any-path", HttpMethod.GET, "c=3"), + setupHttpMessage("/any-path", HttpMethod.GET, Collections.singletonMap("c", "3")), true, false }, new Object[]{ REQ_MAP_WITH_QUERY_PARAMS, - setupHttpMessage("/any-path", HttpMethod.GET, ""), + setupHttpMessage("/any-path", HttpMethod.GET, Collections.emptyMap()), true, false }, new Object[]{ REQ_MAP_WITH_ALL_SUPPORTED_RESTRICTIONS, - setupHttpMessage("/path/value", HttpMethod.GET, "a=1"), + setupHttpMessage("/path/value", HttpMethod.GET, Collections.singletonMap("a", "1")), true, true }, new Object[]{ REQ_MAP_WITH_ALL_SUPPORTED_RESTRICTIONS, - setupHttpMessage("/wrong-path", HttpMethod.GET, "a=1"), + setupHttpMessage("/wrong-path", HttpMethod.GET, Collections.singletonMap("a", "1")), true, false }, new Object[]{ REQ_MAP_WITH_ALL_SUPPORTED_RESTRICTIONS, - setupHttpMessage("/path/value", HttpMethod.PUT, "a=1"), + setupHttpMessage("/path/value", HttpMethod.PUT, Collections.singletonMap("a", "1")), true, false }, new Object[]{ REQ_MAP_WITH_ALL_SUPPORTED_RESTRICTIONS, - setupHttpMessage("/path/value", HttpMethod.GET, ""), + setupHttpMessage("/path/value", HttpMethod.GET, Collections.emptyMap()), true, false }, @@ -254,7 +257,7 @@ private static RequestMapping getRequestMapping(SimulatorScenario scenario) { return AnnotationUtils.findAnnotation(scenario.getClass(), RequestMapping.class); } - private HttpMessage setupHttpMessage(String path, HttpMethod method, String queryParams) { + private HttpMessage setupHttpMessage(String path, HttpMethod method, Map queryParams) { final HttpMessage httpMessage = Mockito.mock(HttpMessage.class); when(httpMessage.getPath()).thenReturn(path); when(httpMessage.getRequestMethod()).thenReturn(method);