diff --git a/pom.xml b/pom.xml
index 0dd55d2e1..fc9af4529 100644
--- a/pom.xml
+++ b/pom.xml
@@ -23,10 +23,10 @@
3.11.0
1.18.20
- 4.0.0-M2
- 3.1.2
- 6.0.9
- 3.1.3
+ 4.0.0
+ 3.1.5
+ 6.0.13
+ 4.0.7
7.5.1
1.6.3
2.12.1
@@ -34,7 +34,7 @@
2.20.0
- 1.4.8
+ 1.4.11
v18.18.0
9.8.1
diff --git a/simulator-samples/sample-swagger/src/main/java/org/citrusframework/simulator/sample/Simulator.java b/simulator-samples/sample-swagger/src/main/java/org/citrusframework/simulator/sample/Simulator.java
index dc1b03d56..4c04c57d8 100644
--- a/simulator-samples/sample-swagger/src/main/java/org/citrusframework/simulator/sample/Simulator.java
+++ b/simulator-samples/sample-swagger/src/main/java/org/citrusframework/simulator/sample/Simulator.java
@@ -27,10 +27,10 @@
import org.citrusframework.simulator.http.HttpScenarioGenerator;
import org.citrusframework.simulator.http.SimulatorRestAdapter;
import org.citrusframework.simulator.http.SimulatorRestConfigurationProperties;
+import org.citrusframework.spi.Resources;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
-import org.springframework.core.io.ClassPathResource;
import org.springframework.http.HttpStatus;
/**
@@ -66,7 +66,7 @@ protected Message handleMessageInternal(Message message) {
@Bean
public static HttpScenarioGenerator scenarioGenerator() {
- HttpScenarioGenerator generator = new HttpScenarioGenerator(new ClassPathResource("swagger/petstore-api.json"));
+ HttpScenarioGenerator generator = new HttpScenarioGenerator(new Resources.ClasspathResource("swagger/petstore-api.json"));
generator.setContextPath("/petstore");
return generator;
}
diff --git a/simulator-samples/sample-swagger/src/test/java/org/citrusframework/simulator/SimulatorSwaggerIT.java b/simulator-samples/sample-swagger/src/test/java/org/citrusframework/simulator/SimulatorSwaggerIT.java
index fcbbeb190..9b12c5ce1 100644
--- a/simulator-samples/sample-swagger/src/test/java/org/citrusframework/simulator/SimulatorSwaggerIT.java
+++ b/simulator-samples/sample-swagger/src/test/java/org/citrusframework/simulator/SimulatorSwaggerIT.java
@@ -23,6 +23,7 @@
import org.citrusframework.http.client.HttpClient;
import org.citrusframework.message.MessageType;
import org.citrusframework.simulator.sample.Simulator;
+import org.citrusframework.spi.Resources;
import org.citrusframework.testng.spring.TestNGCitrusSpringSupport;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
@@ -30,7 +31,6 @@
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
-import org.springframework.core.io.ClassPathResource;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.test.context.ContextConfiguration;
@@ -92,7 +92,7 @@ public void testAddPet() {
.message()
.accept(MediaType.APPLICATION_JSON_VALUE)
.contentType(MediaType.APPLICATION_JSON_VALUE)
- .body(new ClassPathResource("templates/pet.json")));
+ .body(new Resources.ClasspathResource("templates/pet.json")));
$(http().client(petstoreClient)
.receive()
@@ -127,7 +127,7 @@ public void testGetPetById() {
.response(HttpStatus.OK)
.message()
.contentType(MediaType.APPLICATION_JSON_VALUE)
- .body(new ClassPathResource("templates/pet-control.json")));
+ .body(new Resources.ClasspathResource("templates/pet-control.json")));
}
@CitrusTest
@@ -143,7 +143,7 @@ public void testUpdatePet() {
.message()
.accept(MediaType.APPLICATION_JSON_VALUE)
.contentType(MediaType.APPLICATION_JSON_VALUE)
- .body(new ClassPathResource("templates/pet.json")));
+ .body(new Resources.ClasspathResource("templates/pet.json")));
$(http().client(petstoreClient)
.receive()
@@ -205,7 +205,7 @@ public void testPlaceOrder() {
.message()
.accept(MediaType.APPLICATION_JSON_VALUE)
.contentType(MediaType.APPLICATION_JSON_VALUE)
- .body(new ClassPathResource("templates/order.json")));
+ .body(new Resources.ClasspathResource("templates/order.json")));
$(http().client(petstoreClient)
.receive()
diff --git a/simulator-samples/sample-wsdl/src/main/java/org/citrusframework/simulator/sample/Simulator.java b/simulator-samples/sample-wsdl/src/main/java/org/citrusframework/simulator/sample/Simulator.java
index 05fe874da..1bf3f859e 100644
--- a/simulator-samples/sample-wsdl/src/main/java/org/citrusframework/simulator/sample/Simulator.java
+++ b/simulator-samples/sample-wsdl/src/main/java/org/citrusframework/simulator/sample/Simulator.java
@@ -19,6 +19,7 @@
import org.citrusframework.endpoint.EndpointAdapter;
import org.citrusframework.endpoint.adapter.StaticEndpointAdapter;
import org.citrusframework.message.Message;
+import org.citrusframework.spi.Resources;
import org.citrusframework.ws.message.SoapFault;
import org.citrusframework.simulator.ws.SimulatorWebServiceAdapter;
import org.citrusframework.simulator.ws.SimulatorWebServiceConfigurationProperties;
@@ -26,7 +27,6 @@
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
-import org.springframework.core.io.ClassPathResource;
/**
* @author Christoph Deppisch
@@ -58,7 +58,7 @@ protected Message handleMessageInternal(Message message) {
@Bean
public static WsdlScenarioGenerator scenarioGenerator() {
- WsdlScenarioGenerator generator = new WsdlScenarioGenerator(new ClassPathResource("xsd/Hello.wsdl"));
+ WsdlScenarioGenerator generator = new WsdlScenarioGenerator(new Resources.ClasspathResource("xsd/Hello.wsdl"));
return generator;
}
}
diff --git a/simulator-samples/sample-wsdl/src/main/resources/application.properties b/simulator-samples/sample-wsdl/src/main/resources/application.properties
index d1aaf978d..83a11b72f 100644
--- a/simulator-samples/sample-wsdl/src/main/resources/application.properties
+++ b/simulator-samples/sample-wsdl/src/main/resources/application.properties
@@ -21,7 +21,3 @@ citrus.simulator.defaultScenario=Default
# Should Citrus validate incoming messages on syntax and semantics
citrus.simulator.templateValidation=true
-
-
-logging.level.root=DEBUG
-logging.level.web=TRACE
diff --git a/simulator-starter/src/main/java/org/citrusframework/simulator/SimulatorAutoConfiguration.java b/simulator-starter/src/main/java/org/citrusframework/simulator/SimulatorAutoConfiguration.java
index 91214686e..68daa3b86 100644
--- a/simulator-starter/src/main/java/org/citrusframework/simulator/SimulatorAutoConfiguration.java
+++ b/simulator-starter/src/main/java/org/citrusframework/simulator/SimulatorAutoConfiguration.java
@@ -31,6 +31,7 @@
import org.citrusframework.simulator.dictionary.OutboundXmlDataDictionary;
import org.citrusframework.simulator.repository.RepositoryConfig;
import org.citrusframework.simulator.scenario.ScenarioBeanNameGenerator;
+import org.citrusframework.spi.CitrusResourceWrapper;
import org.citrusframework.variable.dictionary.json.JsonPathMappingDataDictionary;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -75,8 +76,10 @@
@ConditionalOnProperty(prefix = "citrus.simulator", value = "enabled", havingValue = "true", matchIfMissing = true)
public class SimulatorAutoConfiguration {
- /** Logger */
- private static Logger log = LoggerFactory.getLogger(SimulatorAutoConfiguration.class);
+ /**
+ * Logger
+ */
+ private static final Logger logger = LoggerFactory.getLogger(SimulatorAutoConfiguration.class);
/** Application version */
private static String version;
@@ -91,7 +94,7 @@ public class SimulatorAutoConfiguration {
versionProperties.load(in);
version = versionProperties.get("app.version").toString();
} catch (IOException e) {
- log.warn("Unable to read application version information", e);
+ logger.warn("Unable to read application version information", e);
version = "";
}
}
@@ -143,7 +146,7 @@ public JsonPathMappingDataDictionary inboundJsonDataDictionary() {
Resource mappingFile = new PathMatchingResourcePatternResolver().getResource(simulatorConfiguration.getInboundJsonDictionary());
if (mappingFile.exists()) {
- inboundJsonDataDictionary.setMappingFile(mappingFile);
+ inboundJsonDataDictionary.setMappingFile(new CitrusResourceWrapper(mappingFile));
}
return inboundJsonDataDictionary;
@@ -159,7 +162,7 @@ public JsonPathMappingDataDictionary outboundJsonDataDictionary() {
Resource mappingFile = new PathMatchingResourcePatternResolver().getResource(simulatorConfiguration.getOutboundJsonDictionary());
if (mappingFile.exists()) {
- outboundJsonDataDictionary.setMappingFile(mappingFile);
+ outboundJsonDataDictionary.setMappingFile(new CitrusResourceWrapper(mappingFile));
}
return outboundJsonDataDictionary;
diff --git a/simulator-starter/src/main/java/org/citrusframework/simulator/dictionary/InboundXmlDataDictionary.java b/simulator-starter/src/main/java/org/citrusframework/simulator/dictionary/InboundXmlDataDictionary.java
index 8a8cdf945..95fc025c6 100644
--- a/simulator-starter/src/main/java/org/citrusframework/simulator/dictionary/InboundXmlDataDictionary.java
+++ b/simulator-starter/src/main/java/org/citrusframework/simulator/dictionary/InboundXmlDataDictionary.java
@@ -1,9 +1,14 @@
package org.citrusframework.simulator.dictionary;
+import static org.citrusframework.simulator.dictionary.XmlUtils.loadXMLMappingFile;
+
import org.citrusframework.context.TestContext;
import org.citrusframework.simulator.config.SimulatorConfigurationProperties;
+import org.citrusframework.spi.CitrusResourceWrapper;
import org.citrusframework.variable.dictionary.xml.XpathMappingDataDictionary;
import org.citrusframework.xml.xpath.XPathUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.Resource;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
@@ -20,6 +25,8 @@
*/
public class InboundXmlDataDictionary extends XpathMappingDataDictionary {
+ private static final Logger logger = LoggerFactory.getLogger(InboundXmlDataDictionary.class);
+
/**
* Default constructor setting default mappings and mappings file.
*/
@@ -29,10 +36,18 @@ public InboundXmlDataDictionary(SimulatorConfigurationProperties simulatorConfig
Resource inboundMappingFile = new PathMatchingResourcePatternResolver().getResource(simulatorConfiguration.getInboundXmlDictionary());
if (inboundMappingFile.exists()) {
- mappingFile = inboundMappingFile;
+ mappingFile = new CitrusResourceWrapper(inboundMappingFile);
}
}
+ @Override
+ public void initialize() {
+ loadXMLMappingFile(logger, mappingFile, mappings);
+
+ mappings.put("//*[string-length(normalize-space(text())) > 0]", "@ignore@");
+ mappings.put("//@*", "@ignore@");
+ }
+
@Override
public T translate(Node node, T value, TestContext context) {
for (Map.Entry expressionEntry : mappings.entrySet()) {
@@ -53,6 +68,7 @@ public T translate(Node node, T value, TestContext context) {
/**
* Checks if given node set contains node.
+ *
* @param findings
* @param node
* @return
@@ -66,12 +82,4 @@ private boolean containsNode(NodeList findings, Node node) {
return false;
}
-
- @Override
- public void initialize() {
- super.initialize();
-
- mappings.put("//*[string-length(normalize-space(text())) > 0]", "@ignore@");
- mappings.put("//@*", "@ignore@");
- }
}
diff --git a/simulator-starter/src/main/java/org/citrusframework/simulator/dictionary/OutboundXmlDataDictionary.java b/simulator-starter/src/main/java/org/citrusframework/simulator/dictionary/OutboundXmlDataDictionary.java
index 9e4bf508f..4fe7df55d 100644
--- a/simulator-starter/src/main/java/org/citrusframework/simulator/dictionary/OutboundXmlDataDictionary.java
+++ b/simulator-starter/src/main/java/org/citrusframework/simulator/dictionary/OutboundXmlDataDictionary.java
@@ -1,8 +1,13 @@
package org.citrusframework.simulator.dictionary;
+import static org.citrusframework.simulator.dictionary.XmlUtils.loadXMLMappingFile;
+
import org.citrusframework.context.TestContext;
import org.citrusframework.simulator.config.SimulatorConfigurationProperties;
+import org.citrusframework.spi.CitrusResourceWrapper;
import org.citrusframework.variable.dictionary.xml.XpathMappingDataDictionary;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.Resource;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
@@ -13,6 +18,8 @@
*/
public class OutboundXmlDataDictionary extends XpathMappingDataDictionary {
+ private static final Logger logger = LoggerFactory.getLogger(OutboundXmlDataDictionary.class);
+
/**
* Default constructor setting default mappings and mappings file.
*/
@@ -20,10 +27,15 @@ public class OutboundXmlDataDictionary extends XpathMappingDataDictionary {
public OutboundXmlDataDictionary(SimulatorConfigurationProperties simulatorConfiguration) {
Resource outboundMappingFile = new PathMatchingResourcePatternResolver().getResource(simulatorConfiguration.getOutboundXmlDictionary());
if (outboundMappingFile.exists()) {
- mappingFile = outboundMappingFile;
+ mappingFile = new CitrusResourceWrapper(outboundMappingFile);
}
}
+ @Override
+ public void initialize() {
+ loadXMLMappingFile(logger, mappingFile, mappings);
+ }
+
@Override
public T translate(Node node, T value, TestContext context) {
if (value instanceof String) {
diff --git a/simulator-starter/src/main/java/org/citrusframework/simulator/dictionary/XmlUtils.java b/simulator-starter/src/main/java/org/citrusframework/simulator/dictionary/XmlUtils.java
new file mode 100644
index 000000000..53b311723
--- /dev/null
+++ b/simulator-starter/src/main/java/org/citrusframework/simulator/dictionary/XmlUtils.java
@@ -0,0 +1,44 @@
+package org.citrusframework.simulator.dictionary;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Map;
+import java.util.Properties;
+import org.citrusframework.exceptions.CitrusRuntimeException;
+import org.citrusframework.spi.Resource;
+import org.slf4j.Logger;
+
+class XmlUtils {
+
+ private XmlUtils(){
+ // Temporary utility class
+ }
+
+ // TODO: Remove if PR has been resolved and released: https://github.com/citrusframework/citrus/pull/1044
+ static void loadXMLMappingFile(Logger logger, Resource mappingFile, Map mappings) {
+ if (mappingFile != null) {
+ logger.debug("Reading data dictionary mapping: {}", mappingFile.getLocation());
+
+ Properties props = new Properties();
+ try (InputStream inputStream = mappingFile.getInputStream()) {
+ props.loadFromXML(inputStream);
+ } catch (IOException e) {
+ throw new CitrusRuntimeException(e);
+ }
+
+ for (Map.Entry