[Jiemamy-notify:1392] commit [2632] XMLの比較にxmlunitを導入。

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2009年 2月 8日 (日) 21:48:33 JST


Revision: 2632
          http://svn.sourceforge.jp/view?root=jiemamy&view=rev&rev=2632
Author:   daisuke_m
Date:     2009-02-08 21:48:33 +0900 (Sun, 08 Feb 2009)

Log Message:
-----------
XMLの比較にxmlunitを導入。

Modified Paths:
--------------
    artemis/trunk/jiemamy-artemis-test/pom.xml
    artemis/trunk/jiemamy-artemis-test/src/test/java/org/jiemamy/serializer/SerializationTest.java


-------------- next part --------------
Modified: artemis/trunk/jiemamy-artemis-test/pom.xml
===================================================================
--- artemis/trunk/jiemamy-artemis-test/pom.xml	2009-02-08 12:13:30 UTC (rev 2631)
+++ artemis/trunk/jiemamy-artemis-test/pom.xml	2009-02-08 12:48:33 UTC (rev 2632)
@@ -56,6 +56,12 @@
       <scope>test</scope>
     </dependency>
     <dependency>
+      <groupId>xmlunit</groupId>
+      <artifactId>xmlunit</artifactId>
+      <version>1.2</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
       <groupId>${project.groupId}</groupId>
       <artifactId>jiemamy-core</artifactId>
       <version>${project.version}</version>

Modified: artemis/trunk/jiemamy-artemis-test/src/test/java/org/jiemamy/serializer/SerializationTest.java
===================================================================
--- artemis/trunk/jiemamy-artemis-test/src/test/java/org/jiemamy/serializer/SerializationTest.java	2009-02-08 12:13:30 UTC (rev 2631)
+++ artemis/trunk/jiemamy-artemis-test/src/test/java/org/jiemamy/serializer/SerializationTest.java	2009-02-08 12:48:33 UTC (rev 2632)
@@ -38,7 +38,7 @@
 import org.apache.commons.jxpath.JXPathContext;
 import org.apache.commons.lang.CharEncoding;
 import org.apache.commons.lang.ClassUtils;
-import org.apache.commons.lang.SystemUtils;
+import org.custommonkey.xmlunit.Diff;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -224,7 +224,6 @@
 		
 		// rootModel1 -> xml1
 		String xml1 = convertRootModelToXml(serializer1, rootModel1);
-		xml1 = xml1.replaceAll(SystemUtils.LINE_SEPARATOR, "\n");
 		
 		// xml1 -> rootModel2
 		RootModel rootModel2 = convertXmlToRootModel(xml1, serializer2);
@@ -236,7 +235,6 @@
 		
 		// rootModel2 -> xml2
 		String xml2 = convertRootModelToXml(serializer2, rootModel2);
-		xml2 = xml2.replaceAll(SystemUtils.LINE_SEPARATOR, "\n");
 		
 		// 参考のため、targetディレクトリに出力XMLを記録
 		FileUtils.writeStringToFile(new File("./target/" + ClassUtils.getShortClassName(this.getClass())
@@ -253,7 +251,7 @@
 		FileUtils.writeStringToFile(new File("./target/" + ClassUtils.getShortClassName(this.getClass())
 				+ "_test1_gtree2.txt"), EqualsUtil.leftGTree, CharEncoding.UTF_8);
 		
-		assertEquals(xml1, xml2);
+		assertThat(new Diff(xml1, xml2).similar(), is(true));
 		assertEquals(EqualsUtil.rightGTree, EqualsUtil.leftGTree);
 	}
 	
@@ -271,7 +269,6 @@
 		Validator validator = new AllValidator();
 		
 		String xml1 = IOUtils.toString(SerializationTest.class.getResourceAsStream("/sample.xml"), CharEncoding.UTF_8);
-		xml1 = xml1.replaceAll(SystemUtils.LINE_SEPARATOR, "\n");
 		
 		// xml1 -> rootModel1
 		RootModel rootModel1 = convertXmlToRootModel(xml1, serializer1);
@@ -279,7 +276,6 @@
 		
 		// rootModel1 -> xml2
 		String xml2 = convertRootModelToXml(serializer2, rootModel1);
-		xml2 = xml2.replaceAll(SystemUtils.LINE_SEPARATOR, "\n");
 		
 		// xml1 -> rootModel2
 		RootModel rootModel2 = convertXmlToRootModel(xml2, serializer2);
@@ -300,7 +296,7 @@
 		FileUtils.writeStringToFile(new File("./target/" + ClassUtils.getShortClassName(this.getClass())
 				+ "_test2_gtree2.txt"), EqualsUtil.leftGTree, CharEncoding.UTF_8);
 		
-		assertEquals(xml1, xml2);
+		assertThat(new Diff(xml1, xml2).similar(), is(true));
 		assertEquals(EqualsUtil.rightGTree, EqualsUtil.leftGTree);
 	}
 	



Jiemamy-notify メーリングリストの案内
Back to archive index