Repository: authorjapps/zerocode
Pull request #35 (2018-02-23 20:47:06)

Zcode sonatype release branch


Patch:
diff --git a/pom.xml b/pom.xml
index 3ea343c4..1763aa53 100644
--- a/pom.xml
+++ b/pom.xml
@@ -9,7 +9,7 @@
 
     <artifactId>zerocode-rest-bdd</artifactId>
     <groupId>org.jsmart</groupId>
-    <version>1.1.25-SNAPSHOT</version>
+    <version>1.1.26-SNAPSHOT</version>
 
     <packaging>jar</packaging>
     <name>ZeroCode REST BDD</name>
@@ -53,7 +53,7 @@
     <properties>
         <!-- this project properties -->
         <junit.version>4.12</junit.version>
-        <jackson-databind.version>2.7.1</jackson-databind.version>
+        <jackson-databind.version>2.8.2</jackson-databind.version>
         <guava.version>16.0</guava.version>
         <jsonassert.version>1.2.3</jsonassert.version>
         <classpath-explorer.version>1.0</classpath-explorer.version>
@@ -78,6 +78,11 @@
     </properties>
 
     <dependencies>
+        <dependency>
+            <groupId>org.json</groupId>
+            <artifactId>json</artifactId>
+            <version>20160810</version>
+        </dependency>
         <dependency>
             <groupId>org.apache.velocity</groupId>
             <artifactId>velocity</artifactId>
diff --git a/src/main/java/org/jsmart/zerocode/converter/Converter.java b/src/main/java/org/jsmart/zerocode/converter/Converter.java
new file mode 100644
index 00000000..c8c41d2c
--- /dev/null
+++ b/src/main/java/org/jsmart/zerocode/converter/Converter.java
@@ -0,0 +1,17 @@
+package org.jsmart.zerocode.converter;
+
+import com.fasterxml.jackson.databind.JsonNode;
+
+import java.io.IOException;
+
+public interface Converter {
+    Object xmlToJson(String xmlObject);
+
+    Object jsonToJson(String jsonString) throws IOException;
+
+    Object jsonBlockToJson(JsonNode jsonNode) throws IOException;
+
+    default Object jsonNodeToJson(JsonNode jsonNode) throws IOException {
+        return jsonBlockToJson(jsonNode);
+    }
+}
diff --git a/src/main/java/org/jsmart/zerocode/converter/MimeTypeConverter.java b/src/main/java/org/jsmart/zerocode/converter/MimeTypeConverter.java
new file mode 100644
index 00000000..361048ba
--- /dev/null
+++ b/src/main/java/org/jsmart/zerocode/converter/MimeTypeConverter.java
@@ -0,0 +1,117 @@
+package org.jsmart.zerocode.converter;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.inject.Inject;
+import org.json.XML;
+
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Source;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.transform.stream.StreamSource;
+import java.io.IOException;
+import java.io.StringReader;
+import java.io.StringWriter;
+
+import static org.slf4j.LoggerFactory.getLogger;
+
+public class MimeTypeConverter implements Converter {
+
+    private static final org.slf4j.Logger LOGGER = getLogger(MimeTypeConverter.class);
+
+    private final ObjectMapper mapper;
+
+    @Inject
+    public MimeTypeConverter(ObjectMapper mapper) {
+        this.mapper = mapper;
+    }
+
+    @Override
+    public Object xmlToJson(String xmlContent) {
+        final String xmlFormated = prettyFormat(xmlContent);
+
+        LOGGER.info("\n------------------------- XML -----------------------------\n"
+                + xmlFormated +
+                "\n------------------------- * -----------------------------\n");
+
+        String jsonNotPretty = XML.toJSONObject(xmlContent).toString();
+
+        try {
+            return mapper.readTree(jsonNotPretty);
+
+        } catch (IOException e) {
+            e.printStackTrace();
+            throw new RuntimeException("XmlToJson conversion problem-  " + e.getMessage());
+        }
+
+    }
+
+    /**
+     * Converts input JSON string (usually escaped e.g. "{\"a\": \"b\", \"active\": true}" ) to JSON block
+     * See also- method jsonBlockToJson for unescaped json to json block.
+     *
+     * @param jsonString
+     * @return
+     * @throws IOException
+     */
+    @Override
+    public Object jsonToJson(String jsonString) throws IOException {
+        return mapper.readValue(jsonString, JsonNode.class);
+    }
+
+    /**
+     * Converts JSON Block({"a": "b", "active": true}) to JSON block
+     * See also- jsonNodeToJson which is identical to jsonBlockToJson.
+     *
+     * @param jsonNode
+     * @return
+     * @throws IOException
+     */
+    public Object jsonBlockToJson(JsonNode jsonNode) throws IOException {
+        return jsonNode;
+    }
+
+    public static String prettyFormat(String input) {
+        return prettyFormat(input, 2);
+    }
+
+    public static String prettyFormat(String originalXml, int indentType) {
+        try {
+            Source xmlInput = new StreamSource(new StringReader(originalXml));
+            StringWriter stringWriter = new StringWriter();
+            StreamResult xmlOutput = new StreamResult(stringWriter);
+            TransformerFactory transformerFactory = TransformerFactory.newInstance();
+            // This statement works with JDK 6
+            transformerFactory.setAttribute("indent-number", indentType);
+
+            Transformer transformer = transformerFactory.newTransformer();
+            transformer.setOutputProperty(OutputKeys.INDENT, "yes");
+            transformer.transform(xmlInput, xmlOutput);
+            return xmlOutput.getWriter().toString();
+        } catch (Throwable e) {
+            e.printStackTrace();
+            // You'll come here if you are using JDK 1.5
+            // you are getting an the following exeption
+            // java.lang.IllegalArgumentException: Not supported: indent-number
+            // Use this code (Set the output property in transformer.
+            try {
+                Source xmlInput = new StreamSource(new StringReader(originalXml));
+                StringWriter stringWriter = new StringWriter();
+                StreamResult xmlOutput = new StreamResult(stringWriter);
+                TransformerFactory transformerFactory = TransformerFactory.newInstance();
+                Transformer transformer = transformerFactory.newTransformer();
+                transformer.setOutputProperty(OutputKeys.INDENT, "yes");
+                transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", String.valueOf(indentType));
+                transformer.transform(xmlInput, xmlOutput);
+                return xmlOutput.getWriter().toString();
+            } catch (Throwable t) {
+                e.printStackTrace();
+                return originalXml;
+            }
+        }
+    }
+
+
+}


Test patch:
diff --git a/src/main/java/org/jsmart/zerocode/core/engine/preprocessor/ZeroCodeJsonTestProcesorImpl.java b/src/main/java/org/jsmart/zerocode/core/engine/preprocessor/ZeroCodeJsonTestProcesorImpl.java
index 03bc05a6..e08a7e47 100644
--- a/src/main/java/org/jsmart/zerocode/core/engine/preprocessor/ZeroCodeJsonTestProcesorImpl.java
+++ b/src/main/java/org/jsmart/zerocode/core/engine/preprocessor/ZeroCodeJsonTestProcesorImpl.java
@@ -28,6 +28,7 @@ import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.HashMap;
 import java.util.Iterator;
+import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Random;
@@ -35,9 +36,13 @@ import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
 import static java.lang.String.format;
+import static org.apache.commons.lang.StringEscapeUtils.escapeJavaScript;
+import static org.slf4j.LoggerFactory.getLogger;
 
 public class ZeroCodeJsonTestProcesorImpl implements ZeroCodeJsonTestProcesor {
 
+    private static final org.slf4j.Logger LOGGER = getLogger(ZeroCodeJsonTestProcesorImpl.class);
+
     /*
      * General place holders
      */
@@ -70,6 +75,7 @@ public class ZeroCodeJsonTestProcesorImpl implements ZeroCodeJsonTestProcesor {
     public static final String ASSERT_VALUE_GREATER_THAN = "$GT.";
     public static final String ASSERT_VALUE_LESSER_THAN = "$LT.";
     public static final String ASSERT_PATH_VALUE_NODE = "$";
+    private static final String RAW_BODY = ".rawBody";
 
     private final ObjectMapper mapper;
 
@@ -102,6 +108,7 @@ public class ZeroCodeJsonTestProcesorImpl implements ZeroCodeJsonTestProcesor {
                         String formatPattern = runTimeToken.substring(LOCALDATE_TODAY.length());
                         DateTimeFormatter formatter = DateTimeFormatter.ofPattern(formatPattern);
                         parammap.put(runTimeToken, LocalDate.now().format(formatter));
+
                     } else if (runTimeToken.startsWith(LOCALDATETIME_NOW)) {
                         String formatPattern = runTimeToken.substring(LOCALDATETIME_NOW.length());
                         DateTimeFormatter formatter = DateTimeFormatter.ofPattern(formatPattern);
@@ -137,7 +144,30 @@ public class ZeroCodeJsonTestProcesorImpl implements ZeroCodeJsonTestProcesor {
 
         jsonPaths.forEach(thisPath -> {
             try {
-                paramMap.put(thisPath, JsonPath.read(scenarioState, thisPath));
+
+                if(thisPath.endsWith(RAW_BODY)){
+                    /**
+                     * In case the rawBody is used anywhere in the steps as $.step_name.response.rawBody,
+                     * then it must be escaped as the content was not a simple string convertible to json.
+                     */
+                    String escapedString = escapeJavaScript(JsonPath.read(scenarioState, thisPath));
+                    paramMap.put(thisPath, escapedString);
+
+                } else {
+                    // if it is a json block/node or array, this return value is LinkedHashMap.
+                    if(JsonPath.read(scenarioState, thisPath) instanceof LinkedHashMap){
+                        final String pathValue = mapper.writeValueAsString(JsonPath.read(scenarioState, thisPath));
+                        String escapedPathValue = escapeJavaScript(pathValue);
+                        paramMap.put(thisPath, escapedPathValue);
+
+                    } else {
+                        // Usual flow
+                        paramMap.put(thisPath, JsonPath.read(scenarioState, thisPath));
+
+                    }
+
+                }
+
             } catch (Exception e) {
                 throw new RuntimeException("\nJSON:" + jsonString + "\nPossibly comments in the JSON found or bad JSON path found: " + thisPath + ", Details: " + e);
             }
diff --git a/src/test/java/org/jsmart/zerocode/converter/ConverterEndToEndTest.java b/src/test/java/org/jsmart/zerocode/converter/ConverterEndToEndTest.java
new file mode 100644
index 00000000..75876943
--- /dev/null
+++ b/src/test/java/org/jsmart/zerocode/converter/ConverterEndToEndTest.java
@@ -0,0 +1,31 @@
+package org.jsmart.zerocode.converter;
+
+import org.jsmart.zerocode.core.domain.JsonTestCase;
+import org.jsmart.zerocode.core.runner.ZeroCodeUnitRunner;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+//@HostProperties(host="http://localhost", port=9998, context = "") //Not needed for java execution
+@RunWith(ZeroCodeUnitRunner.class)
+public class ConverterEndToEndTest {
+    
+    /**
+     * Mock end points are in test/resources: simulators/test_purpose_end_points.json
+     */
+
+    @Test
+    @JsonTestCase("17_xml_to_json_converter/10_xml_to_json_format_happy.json")
+    public void testConverterAt_runTime() throws Exception {
+    
+    }
+
+    @Test
+    @JsonTestCase("17_xml_to_json_converter/20_json_to_json.json")
+    public void testJsonToJson_runTime() throws Exception {
+
+    }
+
+}
+
+
+
diff --git a/src/test/java/org/jsmart/zerocode/converter/MimeTypeConverterTest.java b/src/test/java/org/jsmart/zerocode/converter/MimeTypeConverterTest.java
new file mode 100644
index 00000000..69e7b6e7
--- /dev/null
+++ b/src/test/java/org/jsmart/zerocode/converter/MimeTypeConverterTest.java
@@ -0,0 +1,178 @@
+package org.jsmart.zerocode.converter;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.jayway.jsonpath.JsonPath;
+import org.jsmart.zerocode.core.di.ObjectMapperProvider;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+public class MimeTypeConverterTest {
+
+    private ObjectMapper mapper = new ObjectMapperProvider().get();
+
+    private Converter xmlToJsonConverter;
+
+    @Before
+    public void setUpStuffs() throws Exception {
+        xmlToJsonConverter = new MimeTypeConverter(mapper);
+    }
+
+    @Test
+    public void testXmlToJson_happy() throws Exception {
+
+        String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
+                "<addresses>\n" +
+                "  <address>\n" +
+                "    <postCode>4005</postCode>\n" +
+                "    <message>The field 'quantity' is invalid.</message>\n" +
+                "  </address>\n" +
+                "  <address>\n" +
+                "    <postCode>500</postCode>\n" +
+                "    <message>new message</message>\n" +
+                "  </address>\n" +
+                "</addresses>";
+
+        JsonNode jsonNode = (JsonNode)xmlToJsonConverter.xmlToJson(xml);
+
+        String prettyJson = mapper.writeValueAsString(jsonNode);
+
+        System.out.println("---prettyJson:\n" + prettyJson);
+
+        assertThat(prettyJson, containsString("\"postCode\":500"));
+        assertThat(prettyJson, containsString("\"address\":["));
+        assertThat(prettyJson, containsString("{\"addresses\":{"));
+    }
+
+    @Test
+    public void testJsonToJson() throws Exception {
+
+        String jsonString = "{\n" +
+                "  \"soap:Envelope\" : {\n" +
+                "    \"xmlns:xsd\" : \"http://www.w3.org/2001/XMLSchema\",\n" +
+                "    \"xmlns:soap\" : \"http://schemas.xmlsoap.org/soap/envelope/\",\n" +
+                "    \"xmlns:xsi\" : \"http://www.w3.org/2001/XMLSchema-instance\",\n" +
+                "    \"soap:Body\" : {\n" +
+                "      \"ConversionRateResponse\" : {\n" +
+                "        \"xmlns\" : \"http://www.webserviceX.NET/\",\n" +
+                "        \"ConversionRateResult\" : -1\n" +
+                "      }\n" +
+                "    }\n" +
+                "  }\n" +
+                "}";
+
+        JsonNode jsonNode = (JsonNode)xmlToJsonConverter.jsonToJson(jsonString);
+
+        System.out.println("--- jsonNode:\n" + jsonNode.toString());
+
+        assertThat(jsonNode.toString(), containsString("{\"soap:Envelope\":{\"xmlns:xsd\":"));
+
+    }
+
+    @Test
+    public void testJsonNodeToJson() throws Exception {
+        String jsonNodeString = "{\n" +
+                "  \"soap:Envelope\" : {\n" +
+                "    \"xmlns:xsd\" : \"http://www.w3.org/2001/XMLSchema\",\n" +
+                "    \"xmlns:soap\" : \"http://schemas.xmlsoap.org/soap/envelope/\",\n" +
+                "    \"xmlns:xsi\" : \"http://www.w3.org/2001/XMLSchema-instance\",\n" +
+                "    \"soap:Body\" : {\n" +
+                "      \"ConversionRateResponse\" : {\n" +
+                "        \"xmlns\" : \"http://www.webserviceX.NET/\",\n" +
+                "        \"ConversionRateResult\" : -1\n" +
+                "      }\n" +
+                "    }\n" +
+                "  }\n" +
+                "}";
+        JsonNode jsonNodeInput = mapper.readTree(jsonNodeString);
+
+        Object jsonNodeOutput = xmlToJsonConverter.jsonNodeToJson(jsonNodeInput);
+
+        System.out.println("---- jsonNodeOutput:\n" + jsonNodeOutput);
+
+        assertThat(jsonNodeOutput.toString(), containsString("{\"soap:Envelope\":{\"xmlns:xsd\":"));
+
+
+    }
+
+    @Test
+    public void testJsonArrayToJson() throws Exception {
+
+        String jsonArrayInput = "[\n" +
+                "        {\n" +
+                "            \"postCode\": 4005,\n" +
+                "            \"message\": \"The field 'quantity' is invalid.\"\n" +
+                "        },\n" +
+                "        {\n" +
+                "            \"postCode\": 500,\n" +
+                "            \"message\": \"new message\"\n" +
+                "        }\n" +
+                "    ]";
+        JsonNode jsonNodeInput = mapper.readTree(jsonArrayInput);
+
+        Object jsonNodeOutput = (JsonNode)xmlToJsonConverter.jsonNodeToJson(jsonNodeInput);
+
+        System.out.println("--- jsonNodeOutput:\n" + jsonNodeOutput);
+
+        assertThat(jsonNodeOutput.toString(), containsString("[{\"postCode\":"));
+    }
+
+    @Test
+    public void testJsonBlockToJson() throws Exception {
+        String jsonBlockString = "{\n" +
+                "            \"addresses\": {\n" +
+                "                \"address\": [\n" +
+                "                    {\n" +
+                "                        \"postCode\": 4005,\n" +
+                "                        \"message\": \"The field 'quantity' is invalid.\"\n" +
+                "                    },\n" +
+                "                    {\n" +
+                "                        \"postCode\": 500,\n" +
+                "                        \"message\": \"new message\"\n" +
+                "                    }\n" +
+                "                ]\n" +
+                "            }\n" +
+                "        }";
+        JsonNode jsonNodeInput = mapper.readTree(jsonBlockString);
+
+        Object jsonNodeOutput = xmlToJsonConverter.jsonBlockToJson(jsonNodeInput);
+
+        System.out.println("--- jsonBlockOutput:\n" + jsonNodeOutput);
+
+        assertThat(jsonNodeOutput.toString(), containsString("{\"addresses\":{\"address\":[{"));
+
+    }
+
+    @Test
+    public void testJsonArrayBlockToJson() throws Exception {
+        String jsonBlockString = "{\n" +
+                "            \"addresses\": {\n" +
+                "                \"address\": [\n" +
+                "                    {\n" +
+                "                        \"postCode\": 4005,\n" +
+                "                        \"message\": \"The field 'quantity' is invalid.\"\n" +
+                "                    },\n" +
+                "                    {\n" +
+                "                        \"postCode\": 500,\n" +
+                "                        \"message\": \"new message\"\n" +
+                "                    }\n" +
+                "                ]\n" +
+                "            }\n" +
+                "        }";
+
+        String jsonArrayString = JsonPath.read(jsonBlockString, "$.addresses.address").toString();
+        System.out.println("--- jsonArray: \n" + jsonArrayString);
+
+        JsonNode jsonNodeInput = mapper.readTree(jsonArrayString);
+
+        Object jsonNodeOutput = xmlToJsonConverter.jsonBlockToJson(jsonNodeInput);
+
+        System.out.println("--- jsonArrayBlockOutput:\n" + jsonNodeOutput);
+
+        assertThat(jsonNodeOutput.toString(), containsString("[{\"postCode\":4005"));
+
+    }
+}
\ No newline at end of file
diff --git a/src/test/java/org/jsmart/zerocode/core/soap/SoapEndPointTest.java b/src/test/java/org/jsmart/zerocode/core/soap/SoapEndPointTest.java
new file mode 100644
index 00000000..8d5a40ef
--- /dev/null
+++ b/src/test/java/org/jsmart/zerocode/core/soap/SoapEndPointTest.java
@@ -0,0 +1,24 @@
+package org.jsmart.zerocode.core.soap;
+
+import org.jsmart.zerocode.core.domain.JsonTestCase;
+import org.jsmart.zerocode.core.domain.TargetEnv;
+import org.jsmart.zerocode.core.domain.UseHttpClient;
+import org.jsmart.zerocode.core.httpclient.ssl.SslTrustHttpClient;
+import org.jsmart.zerocode.core.runner.ZeroCodeUnitRunner;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+@UseHttpClient(SslTrustHttpClient.class) //Needed only for https connections
+@TargetEnv("soap_host.properties")
+@RunWith(ZeroCodeUnitRunner.class)
+public class SoapEndPointTest {
+
+    @Ignore("This works. Ignored only to avoid build failure when the internet site is down")
+    @Test
+    @JsonTestCase("16_soap/soap_endpoint_soap_action_post_200.json")
+    public void testSoapEndPointWith_SOAPAction() throws Exception {
+
+    }
+}
+
diff --git a/src/test/resources/14_env_prop/22_env_property_dynamic_runtime.json b/src/test/resources/14_env_prop/22_env_property_dynamic_runtime.json
index 5b4659d2..204f7c58 100644
--- a/src/test/resources/14_env_prop/22_env_property_dynamic_runtime.json
+++ b/src/test/resources/14_env_prop/22_env_property_dynamic_runtime.json
@@ -1,20 +1,20 @@
 {
-  "scenarioName": "22_env_property_dynamic_runtime",
-  "steps": [
-    {
-      "name": "get_hotel_resource for ci jenkins",
-      "url": "/home/bathroom/google_id_01",
-      "operation": "GET",
-      "request": {
-      },
-      "assertions": {
-        "status": 200,
-        "body": {
-          "id" : 1,
-          "name" : "G Hotel Shower",
-          "availability" : true
+    "scenarioName": "22_env_property_dynamic_runtime",
+    "steps": [
+        {
+            "name": "get_hotel_resource for ci jenkins",
+            "url": "/home/bathroom/google_id_01",
+            "operation": "GET",
+            "request": {
+            },
+            "assertions": {
+                "status": 200,
+                "body": {
+                    "id": 1,
+                    "name": "G Hotel Shower",
+                    "availability": true
+                }
+            }
         }
-      }
-    }
-  ]
+    ]
 }
diff --git a/src/test/resources/16_soap/soap_endpoint_soap_action_post_200.json b/src/test/resources/16_soap/soap_endpoint_soap_action_post_200.json
new file mode 100644
index 00000000..f7b25312
--- /dev/null
+++ b/src/test/resources/16_soap/soap_endpoint_soap_action_post_200.json
@@ -0,0 +1,42 @@
+{
+    "scenarioName": "GIVEN a SOAP end point WHEN I invoke a method with a request XML, THEN I will get the SOAP response in XML",
+    "steps": [
+        {
+            "name": "invoke_currency_conversion",
+            "url": "/CurrencyConvertor.asmx",
+            "operation": "POST",
+            "request": {
+                "headers": {
+                    "Content-Type": "text/xml; charset=utf-8",
+                    //"SOAPAction": "\"http://www.webserviceX.NET/ConversionRate\""
+                    "SOAPAction": "http://www.webserviceX.NET/ConversionRate"
+                },
+                "body": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">\n  <soap:Body>\n    <ConversionRate xmlns=\"http://www.webserviceX.NET/\">\n      <FromCurrency>AFA</FromCurrency>\n      <ToCurrency>GBP</ToCurrency>\n    </ConversionRate>\n  </soap:Body>\n</soap:Envelope>"
+            },
+            "assertions": {
+                "status": 200,
+                "rawBody": "$CONTAINS.STRING:<ConversionRateResult>-1</ConversionRateResult>"
+            }
+        },
+        {
+            "name": "response_xml_to_json",
+            "url": "org.jsmart.zerocode.converter.MimeTypeConverter",
+            "operation": "xmlToJson",
+            "request": "${$.invoke_currency_conversion.response.rawBody}",
+            "assertions": {
+                "soap:Envelope": {
+                    "xmlns:xsd": "http://www.w3.org/2001/XMLSchema",
+                    "xmlns:soap": "http://schemas.xmlsoap.org/soap/envelope/",
+                    "xmlns:xsi": "http://www.w3.org/2001/XMLSchema-instance",
+                    "soap:Body": {
+                        "ConversionRateResponse": {
+                            "xmlns": "http://www.webserviceX.NET/",
+                            "ConversionRateResult": -1
+                        }
+                    }
+                }
+            }
+        }
+
+    ]
+}
diff --git a/src/test/resources/17_xml_to_json_converter/10_xml_to_json_format_happy.json b/src/test/resources/17_xml_to_json_converter/10_xml_to_json_format_happy.json
new file mode 100755
index 00000000..0fad282e
--- /dev/null
+++ b/src/test/resources/17_xml_to_json_converter/10_xml_to_json_format_happy.json
@@ -0,0 +1,45 @@
+{
+  "scenarioName": "Given xml input Give me json output",
+  "steps": [
+    {
+      "name": "xml_to_json",
+        "url": "org.jsmart.zerocode.converter.MimeTypeConverter",
+        "operation": "xmlToJson",
+      "request": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">\n  <soap:Body>\n    <ConversionRate xmlns=\"http://www.webserviceX.NET/\">\n      <FromCurrency>AFA</FromCurrency>\n      <ToCurrency>GBP</ToCurrency>\n    </ConversionRate>\n  </soap:Body>\n</soap:Envelope>",
+      "assertions": {
+        "soap:Envelope" : {
+          "xmlns:xsd" : "http://www.w3.org/2001/XMLSchema",
+          "xmlns:soap" : "http://schemas.xmlsoap.org/soap/envelope/",
+          "xmlns:xsi" : "http://www.w3.org/2001/XMLSchema-instance",
+          "soap:Body" : {
+            "ConversionRate" : {
+              "xmlns" : "http://www.webserviceX.NET/",
+              "FromCurrency" : "AFA",
+              "ToCurrency" : "GBP"
+            }
+          }
+        }
+      }
+    },
+    {
+      "name": "xml_to_json_json_path",
+      "url": "org.jsmart.zerocode.converter.MimeTypeConverter",
+      "operation": "xmlToJson",
+      "request": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">\n  <soap:Body>\n    <ConversionRate xmlns=\"http://www.webserviceX.NET/\">\n      <FromCurrency>AFA</FromCurrency>\n      <ToCurrency>GBP</ToCurrency>\n    </ConversionRate>\n  </soap:Body>\n</soap:Envelope>",
+      "assertions": {
+        "soap:Envelope" : {
+          "xmlns:xsd" : "${$.xml_to_json.response.soap:Envelope.xmlns:xsd}",
+          "xmlns:soap" : "http://schemas.xmlsoap.org/soap/envelope/",
+          "soap:Body" : {
+            "ConversionRate" : {
+              "FromCurrency" : "${$.xml_to_json.response.soap:Envelope.soap:Body.ConversionRate.FromCurrency}",
+              "ToCurrency" : "GBP"
+            }
+          }
+        }
+      }
+    }
+
+
+  ]
+}
diff --git a/src/test/resources/17_xml_to_json_converter/20_json_to_json.json b/src/test/resources/17_xml_to_json_converter/20_json_to_json.json
new file mode 100644
index 00000000..0b41f198
--- /dev/null
+++ b/src/test/resources/17_xml_to_json_converter/20_json_to_json.json
@@ -0,0 +1,99 @@
+{
+    "scenarioName": "Given a json string or json block, convert to equivalent json block",
+    "steps": [
+        {
+            "name": "json_block_to_json",
+            "url": "org.jsmart.zerocode.converter.MimeTypeConverter",
+            "operation": "jsonBlockToJson",
+            "request": {
+                "headers": {
+                    "hdrX": "valueX"
+                },
+                "body": {
+                    "id": 1001,
+                    "addresses": [
+                        {
+                            "postCode": "PXY"
+                        },
+                        {
+                            "postCode": "LMZ DDD"
+                        }
+                    ]
+                }
+            },
+            "assertions": {
+                "headers": {
+                    "hdrX": "valueX"
+                },
+                "body": {
+                    "id": 1001,
+                    "addresses": [
+                        {
+                            "postCode": "PXY"
+                        },
+                        {
+                            "postCode": "${$.json_block_to_json.request.body.addresses[1].postCode}"
+                        }
+                    ]
+                }
+            }
+        },
+        {
+            "name": "json_to_json",
+            "url": "org.jsmart.zerocode.converter.MimeTypeConverter",
+            "operation": "jsonToJson",
+            "request": "${$.json_block_to_json.request.headers}",
+            "assertions": {
+                "hdrX": "valueX"
+            }
+        },
+        {
+            "name": "body_json_to_json",
+            "url": "org.jsmart.zerocode.converter.MimeTypeConverter",
+            "operation": "jsonToJson",
+            "request": "${$.json_block_to_json.request.body}",
+            "assertions": {
+                "id": 1001,
+                "addresses": [
+                    {
+                        "postCode": "PXY"
+                    },
+                    {
+                        "postCode": "LMZ DDD"
+                    }
+                ]
+            }
+        },
+        {
+            "name": "json_node_to_json",
+            "url": "org.jsmart.zerocode.converter.MimeTypeConverter",
+            "operation": "jsonBlockToJson",
+            "request": {
+                "headers": {
+                    "hdrX": "valueX"
+                },
+                "body": {
+                    "id": 1001,
+                    "addresses": [
+                        {
+                            "postCode": "PXY"
+                        }
+                    ]
+                }
+            },
+            "assertions": {
+                "headers": {
+                    "hdrX": "valueX"
+                },
+                "body": {
+                    "id": 1001,
+                    "addresses": [
+                        {
+                            "postCode": "${$.json_block_to_json.request.body.addresses[0].postCode}"
+                        }
+                    ]
+                }
+            }
+        }
+    ]
+}
diff --git a/src/test/resources/soap_host.properties b/src/test/resources/soap_host.properties
new file mode 100755
index 00000000..1f96a583
--- /dev/null
+++ b/src/test/resources/soap_host.properties
@@ -0,0 +1,6 @@
+#
+restful.application.endpoint.host=http://www.webservicex.net
+restful.application.endpoint.port=80
+
+# Google Map Service Context
+restful.application.endpoint.context=