diff --git a/CHANGELOG.md b/CHANGELOG.md index 743055d..74da5ce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +# 0.2.8 (20/08/2016) +- Bug fixes + # 0.2.8 (29/07/2016) - Added request routing feature diff --git a/src/main/java/wssimulator/WSSimulator.java b/src/main/java/wssimulator/WSSimulator.java index da6f19b..18a90cd 100644 --- a/src/main/java/wssimulator/WSSimulator.java +++ b/src/main/java/wssimulator/WSSimulator.java @@ -226,6 +226,7 @@ public final class WSSimulator { * @param yamlString YAML as a String */ public static void addSimulation(@NotNull String yamlString) { + LOG.info("adding simulation string: {}", yamlString); YamlToSimulation yamlToSimulation = new YamlToSimulation(yamlString); wsSimulatorServiceManager.add(yamlToSimulation.simulatorSimulation()); } @@ -237,6 +238,7 @@ public static void addSimulation(@NotNull String yamlString) { * @param classpathLocation YAML location on classpath */ public static void addSimulationOnClasspath(@NotNull String classpathLocation) { + LOG.info("adding simulation on classpath: {}", classpathLocation); YamlToSimulation yamlToSimulation = new YamlToSimulation(new File(WSSimulator.class.getResource(classpathLocation).getFile())); wsSimulatorServiceManager.add(yamlToSimulation.simulatorSimulation()); } @@ -259,6 +261,7 @@ public static int addSimulation(@NotNull WSSimulation WSSimulation) { * @return the id of this simulation */ public static int addSimulation(@NotNull File echoSimulationAsYaml) { + LOG.info("adding simulation file: {}", echoSimulationAsYaml); YamlToSimulation yamlToSimulation = new YamlToSimulation(echoSimulationAsYaml); return addSimulation(yamlToSimulation.simulatorSimulation()); } @@ -267,6 +270,7 @@ public static int addSimulation(@NotNull File echoSimulationAsYaml) { * Shuts down the simulator */ public static void shutdown() { + LOG.info("Shutting down server"); wsSimulatorServiceManager.shutdown(); } @@ -276,6 +280,7 @@ public static void shutdown() { * @param port the port number */ public static void setPort(int port) { + LOG.info("setting port to {}", port); Spark.port(port); } diff --git a/src/main/java/wssimulator/WSSimulatorServiceManager.java b/src/main/java/wssimulator/WSSimulatorServiceManager.java index 4d8a62b..64ece76 100644 --- a/src/main/java/wssimulator/WSSimulatorServiceManager.java +++ b/src/main/java/wssimulator/WSSimulatorServiceManager.java @@ -218,6 +218,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.concurrent.locks.ReentrantLock; import static spark.Spark.*; @@ -227,6 +228,7 @@ public class WSSimulatorServiceManager { private int counter = 0; private Map handlers = new HashMap<>(); + private Map validSimulations = new HashMap<>(); private static final org.slf4j.Logger LOG = org.slf4j.LoggerFactory.getLogger(WSSimulatorServiceManager.class); @@ -268,7 +270,7 @@ private static WSSimulatorServiceManager startup() { return new WSSimulatorServiceManager(); } - private Map validSimulations = new HashMap<>(); + /** * Adds and starts a web service simulator simulation @@ -340,9 +342,10 @@ else if ("application/json".equals(wsSimulation.consumes)) * Shuts down the simulator. */ public void shutdown() { - LOG.info("Shutting down server"); Spark.stop(); validSimulations.clear(); + handlers.clear(); + counter=0; } /** diff --git a/src/main/resources/wssimulator-version.txt b/src/main/resources/wssimulator-version.txt index 08456a4..d81f1c3 100644 --- a/src/main/resources/wssimulator-version.txt +++ b/src/main/resources/wssimulator-version.txt @@ -1 +1 @@ -0.2.8 \ No newline at end of file +0.2.9 \ No newline at end of file diff --git a/src/test/groovy/wssimulator/RouteFilterSimulationSpecification.groovy b/src/test/groovy/wssimulator/RouteFilterSimulationSpecification.groovy index 109e56f..53f37d5 100644 --- a/src/test/groovy/wssimulator/RouteFilterSimulationSpecification.groovy +++ b/src/test/groovy/wssimulator/RouteFilterSimulationSpecification.groovy @@ -206,42 +206,54 @@ package wssimulator import io.restassured.http.ContentType +import org.slf4j.Logger import spock.lang.Specification import static io.restassured.RestAssured.given import static org.hamcrest.core.IsEqual.equalTo +import static org.slf4j.LoggerFactory.* /** * Tests reading all yaml files for XML files. */ class RouteFilterSimulationSpecification extends Specification { + private static final Logger LOG = getLogger(RouteFilterSimulationSpecification.class); def "Validate the route filter feature"() { setup: + LOG.info("Validate the route filter feature:setup") int port = TestUtils.randomPort() - when: WSSimulator.setPort(port) + when: WSSimulator.addSimulation(new File(getClass().getResource("/route/route1.yml").toURI())) WSSimulator.addSimulation(new File(getClass().getResource("/route/route2.yml").toURI())) WSSimulator.addSimulation(new File(getClass().getResource("/route/route3.yml").toURI())) then: + LOG.info("Validate the route filter feature:then") + given().port(port) .contentType(ContentType.XML) .body("This is just random test with Action1 contained within it") .post("/publish").then().assertThat() .statusCode(200).and().body(equalTo("FilteredByAction1")) + LOG.info("Validate the route filter feature:then-1") + given().port(port) .contentType(ContentType.XML) .body("This is just random test with Action2 contained within it") .post("/publish").then().assertThat() .statusCode(200).and().body(equalTo("FilteredByAction2")) + LOG.info("Validate the route filter feature:then-2") + given().port(port) .contentType(ContentType.XML) .body("This is just random test with Action3 contained within it") .post("/publish").then().assertThat() .statusCode(200).and().body(equalTo("FilteredByAction3")) + LOG.info("Validate the route filter feature:end") cleanup: + LOG.info("Validate the route filter feature:cleanup") WSSimulator.shutdown() } diff --git a/src/test/groovy/wssimulator/SOAPTestSpecification.groovy b/src/test/groovy/wssimulator/SOAPTestSpecification.groovy index 7c372e3..258ddcb 100644 --- a/src/test/groovy/wssimulator/SOAPTestSpecification.groovy +++ b/src/test/groovy/wssimulator/SOAPTestSpecification.groovy @@ -226,10 +226,7 @@ class SOAPTestSpecification extends Specification { .body(new File(getClass().getResource("/soap/payload.xml").toURI())) .post("/CurrencyConvertor.asmx").then().assertThat() .statusCode(200) - println "THEN FINISHED!!" cleanup: - println "CLEANUP STARTEE!!" - WSSimulator.shutdown() }