incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From enor...@apache.org
Subject svn commit: r983425 - in /sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest: JsonQueryServletTest.java JsonRenderingTest.java
Date Sun, 08 Aug 2010 15:30:15 GMT
Author: enorman
Date: Sun Aug  8 15:30:14 2010
New Revision: 983425

URL: http://svn.apache.org/viewvc?rev=983425&view=rev
Log:
SLING-1632 fix broken integration test

Modified:
    sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/JsonQueryServletTest.java
    sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/JsonRenderingTest.java

Modified: sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/JsonQueryServletTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/JsonQueryServletTest.java?rev=983425&r1=983424&r2=983425&view=diff
==============================================================================
--- sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/JsonQueryServletTest.java
(original)
+++ sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/JsonQueryServletTest.java
Sun Aug  8 15:30:14 2010
@@ -173,36 +173,22 @@ public class JsonQueryServletTest extend
         //tidy json text should have whitespace that makes it not be equivalent to the untidy
version
         assertNotSame(json, tidyJson);
 
-        //compare expected with actual
-        String expectedTidyJson = 
-        	"[{\n" +
-        	"    \"name\": \"node0\",\n" +
-        	"    \"jcr:score\": 1000,\n" +
-        	"    \"jcr:primaryType\": \"nt:unstructured\",\n" +
-        	"    \"jcr:path\": \"" + testPath + "/folderA/node0\"\n" +
-        	"  },{\n" +
-        	"    \"name\": \"node1\",\n" +
-        	"    \"jcr:score\": 1000,\n" +
-        	"    \"jcr:primaryType\": \"nt:unstructured\",\n" +
-        	"    \"jcr:path\": \"" + testPath + "/folderA/node1\"\n" +
-        	"  },{\n" +
-        	"    \"name\": \"node2\",\n" +
-        	"    \"jcr:score\": 1000,\n" +
-        	"    \"jcr:primaryType\": \"nt:unstructured\",\n" +
-        	"    \"jcr:path\": \"" + testPath + "/folderA/node2\"\n" +
-        	"  },{\n" +
-        	"    \"name\": \"node3\",\n" +
-        	"    \"jcr:score\": 1000,\n" +
-        	"    \"jcr:primaryType\": \"nt:unstructured\",\n" +
-        	"    \"jcr:path\": \"" + testPath + "/folderA/node3\"\n" +
-        	"  },{\n" +
-        	"    \"name\": \"node4\",\n" +
-        	"    \"jcr:score\": 1000,\n" +
-        	"    \"jcr:primaryType\": \"nt:unstructured\",\n" +
-        	"    \"jcr:path\": \"" + testPath + "/folderA/node4\"\n" +
-        	"  }\n" +
-        	"]";
-		assertEquals(expectedTidyJson.length(), tidyJson.length());
-        assertEquals(expectedTidyJson, tidyJson);
+    	int noTidyCount = countOccurences(json, '\n');
+    	int tidyCount = countOccurences(tidyJson, '\n');
+    	int delta = tidyCount - noTidyCount;
+
+    	// tidy output contains at least 25 additional EOL chars
+    	int min = 25;
+    	assertTrue("The .tidy selector should add at least 25 EOL chars to json output (delta="
+ delta + ")", delta > min);
     }
+    
+    protected static int countOccurences(String str, char toCount) {
+    	int result = 0;
+    	for(char c : str.toCharArray()) {
+    		if(c == toCount) {
+    			result++;
+    		}
+    	}
+    	return result;
+    }    
 }

Modified: sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/JsonRenderingTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/JsonRenderingTest.java?rev=983425&r1=983424&r2=983425&view=diff
==============================================================================
--- sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/JsonRenderingTest.java
(original)
+++ sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/JsonRenderingTest.java
Sun Aug  8 15:30:14 2010
@@ -234,7 +234,7 @@ public class JsonRenderingTest extends H
     	// Output contains 3 properties and a subnode with one, so at least 5 EOL chars
     	int min = 5;
     	
-    	assertTrue("The .tidy selector should add at least 2 EOL chars to json output (delta="
+ delta + ")", delta > min);
+    	assertTrue("The .tidy selector should add at least 5 EOL chars to json output (delta="
+ delta + ")", delta > min);
     }
     
     public void testRootNoRecursion() throws IOException {



Mime
View raw message