You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by re...@apache.org on 2008/07/14 14:48:26 UTC

svn commit: r676574 - in /cocoon/whiteboard/corona/trunk: corona-pipeline/pom.xml corona-pipeline/src/test/java/org/apache/cocoon/corona/pipeline/PipelineTest.java parent/pom.xml

Author: reinhard
Date: Mon Jul 14 05:48:25 2008
New Revision: 676574

URL: http://svn.apache.org/viewvc?rev=676574&view=rev
Log:
use XMLUnit for XML diffs so that the tests don't rely on XML serializer internals

Modified:
    cocoon/whiteboard/corona/trunk/corona-pipeline/pom.xml
    cocoon/whiteboard/corona/trunk/corona-pipeline/src/test/java/org/apache/cocoon/corona/pipeline/PipelineTest.java
    cocoon/whiteboard/corona/trunk/parent/pom.xml

Modified: cocoon/whiteboard/corona/trunk/corona-pipeline/pom.xml
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/corona/trunk/corona-pipeline/pom.xml?rev=676574&r1=676573&r2=676574&view=diff
==============================================================================
--- cocoon/whiteboard/corona/trunk/corona-pipeline/pom.xml (original)
+++ cocoon/whiteboard/corona/trunk/corona-pipeline/pom.xml Mon Jul 14 05:48:25 2008
@@ -57,6 +57,11 @@
       <artifactId>junit</artifactId>
       <scope>test</scope>
     </dependency>
+    <dependency>
+      <groupId>xmlunit</groupId>
+      <artifactId>xmlunit</artifactId>
+      <scope>test</scope>
+    </dependency>    
   </dependencies>
 
 </project>

Modified: cocoon/whiteboard/corona/trunk/corona-pipeline/src/test/java/org/apache/cocoon/corona/pipeline/PipelineTest.java
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/corona/trunk/corona-pipeline/src/test/java/org/apache/cocoon/corona/pipeline/PipelineTest.java?rev=676574&r1=676573&r2=676574&view=diff
==============================================================================
--- cocoon/whiteboard/corona/trunk/corona-pipeline/src/test/java/org/apache/cocoon/corona/pipeline/PipelineTest.java (original)
+++ cocoon/whiteboard/corona/trunk/corona-pipeline/src/test/java/org/apache/cocoon/corona/pipeline/PipelineTest.java Mon Jul 14 05:48:25 2008
@@ -26,6 +26,7 @@
 
 import org.apache.cocoon.corona.pipeline.component.FileReaderComponent;
 import org.apache.cocoon.corona.pipeline.util.StringTransformation;
+import org.custommonkey.xmlunit.Diff;
 
 public class PipelineTest extends TestCase {
 
@@ -42,7 +43,8 @@
     public void testStringTransformation() throws Exception {
         String result = StringTransformation.transform("<x>test</x>", PipelineTest.class.getClassLoader().getResource(
                 "test.xslt"));
-        assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?><p/>", result);
+        Diff diff = new Diff("<?xml version=\"1.0\" encoding=\"UTF-8\"?><p></p>", result);
+        assertTrue("XSL transformation didn't work as expected " + diff, diff.identical());
     }
 
     public void testStringTransformationWithParameter() throws Exception {
@@ -50,7 +52,9 @@
         params.put("myParam", "abc");
         String result = StringTransformation.transform("<x>test</x>", params, PipelineTest.class.getClassLoader()
                 .getResource("test.xslt"));
-        assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?><p>abc</p>", result);
+        Diff diff = new Diff("<?xml version=\"1.0\" encoding=\"UTF-8\"?><p>abc</p>", result);
+        assertTrue("XSL transformation didn't work as expected " + diff, diff.identical());
+        assertTrue(result.startsWith("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"));
     }
 
     public void testStringTransformationWithProperties() throws Exception {
@@ -58,7 +62,9 @@
         props.put("encoding", "iso-8859-1");
         String result = StringTransformation.transform("<x>test</x>", props, PipelineTest.class.getClassLoader()
                 .getResource("test.xslt"));
-        assertEquals("<?xml version=\"1.0\" encoding=\"iso-8859-1\"?><p/>", result);
+        Diff diff = new Diff("<?xml version=\"1.0\" encoding=\"iso-8859-1\"?><p/>", result);
+        assertTrue("XSL transformation didn't work as expected " + diff, diff.identical());
+        assertTrue(result.startsWith("<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>"));
     }
 
     public void testStringTransformationWithPropertiesAndParameters() throws Exception {
@@ -68,6 +74,7 @@
         params.put("myParam", "abc");
         String result = StringTransformation.transform("<x>test</x>", params, props, PipelineTest.class
                 .getClassLoader().getResource("test.xslt"));
-        assertEquals("<?xml version=\"1.0\" encoding=\"iso-8859-1\"?><p>abc</p>", result);
+        Diff diff = new Diff("<?xml version=\"1.0\" encoding=\"iso-8859-1\"?><p>abc</p>", result);
+        assertTrue("XSL transformation didn't work as expected " + diff, diff.identical());
     }
 }

Modified: cocoon/whiteboard/corona/trunk/parent/pom.xml
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/corona/trunk/parent/pom.xml?rev=676574&r1=676573&r2=676574&view=diff
==============================================================================
--- cocoon/whiteboard/corona/trunk/parent/pom.xml (original)
+++ cocoon/whiteboard/corona/trunk/parent/pom.xml Mon Jul 14 05:48:25 2008
@@ -183,6 +183,12 @@
           </exclusion>
         </exclusions>
       </dependency>
+      <dependency>
+        <groupId>xmlunit</groupId>
+        <artifactId>xmlunit</artifactId>
+        <scope>test</scope>
+        <version>1.2</version>
+      </dependency>      
     </dependencies>
   </dependencyManagement>