SLING-6906: Handle tick escaped json.
authorKarl Pauls <pauls@apache.org>
Thu, 1 Jun 2017 19:25:55 +0000 (19:25 +0000)
committerKarl Pauls <pauls@apache.org>
Thu, 1 Jun 2017 19:25:55 +0000 (19:25 +0000)
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1797247 13f79535-47bb-0310-9956-ffa450edef68

pom.xml
src/main/java/org/apache/sling/junit/remote/testrunner/SlingRemoteTest.java
src/main/java/org/apache/sling/junit/remote/testrunner/SlingRemoteTestRunner.java

diff --git a/pom.xml b/pom.xml
index 7d3d7a2..9ed48c2 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -60,6 +60,9 @@
                             *
                         </Import-Package>
                         <Sling-Test-Regexp>.*Test</Sling-Test-Regexp>
+                        <Embed-Dependency>
+                                org.apache.sling.jcr.contentparser;inline="org/apache/sling/jcr/contentparser/impl/JsonTicksConverter.class"
+                        </Embed-Dependency>
                     </instructions>
                 </configuration>
             </plugin>
             <groupId>javax.servlet</groupId>
             <artifactId>servlet-api</artifactId>
         </dependency>
+        <dependency>
+      <groupId>org.apache.sling</groupId>
+      <artifactId>org.apache.sling.jcr.contentparser</artifactId>
+      <version>1.2.3-SNAPSHOT</version>
+      <scope>provided</scope>
+      <exclusions>
+        <exclusion>
+            <groupId>*</groupId>
+            <artifactId>*</artifactId>
+        </exclusion>
+    </exclusions>
+    </dependency>
     </dependencies>
 </project>
index 694c665..8db1be3 100644 (file)
@@ -36,7 +36,7 @@ class SlingRemoteTest {
     
     SlingRemoteTest(Class<?> testClass, JsonObject json) throws JsonException {
         this.testClass = testClass;
-        description = json.getString(DESCRIPTION);
+        description = json.containsKey(DESCRIPTION) ? json.getString(DESCRIPTION) : null;
         failure = json.containsKey(FAILURE) ? json.getString(FAILURE) : null;
         if (failure != null) {
             trace = json.containsKey(TRACE) ? json.getString(TRACE) : null;
index 9f6ccd0..dd0d892 100644 (file)
@@ -24,6 +24,7 @@ import javax.json.Json;
 import javax.json.JsonArray;
 import javax.json.JsonObject;
 
+import org.apache.sling.jcr.contentparser.impl.JsonTicksConverter;
 import org.apache.sling.junit.remote.httpclient.RemoteTestHttpClient;
 import org.apache.sling.testing.tools.http.RequestCustomizer;
 import org.apache.sling.testing.tools.http.RequestExecutor;
@@ -113,14 +114,14 @@ public class SlingRemoteTestRunner extends ParentRunner<SlingRemoteTest> {
                 "json"
                 );
         executor.assertContentType("application/json");
-        final JsonArray json = Json.createReader(new StringReader(executor.getContent())).readArray();
+        final JsonArray json = Json.createReader(new StringReader(JsonTicksConverter.tickToDoubleQuote(executor.getContent()))).readArray();
 
         // Response contains an array of objects identified by 
         // their INFO_TYPE, extract the tests
         // based on this vlaue
         for(int i = 0 ; i < json.size(); i++) {
             final JsonObject obj = json.getJsonObject(i);
-            if("test".equals(obj.getString("INFO_TYPE"))) {
+            if(obj.containsKey("INFO_TYPE") && "test".equals(obj.getString("INFO_TYPE"))) {
                 children.add(new SlingRemoteTest(testClass, obj));
             }
         }