Skip to content

Commit 1512ff8

Browse files
authored
Merge pull request #96 from srl295/xmlunit
Use XMLUnit to match
2 parents e7156ce + 60dfd06 commit 1512ff8

2 files changed

Lines changed: 17 additions & 6 deletions

File tree

gp-res-filter/pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,5 +100,11 @@
100100
<version>4.12</version>
101101
<scope>test</scope>
102102
</dependency>
103+
<dependency>
104+
<groupId>org.xmlunit</groupId>
105+
<artifactId>xmlunit-matchers</artifactId>
106+
<version>2.5.1</version>
107+
<scope>test</scope>
108+
</dependency>
103109
</dependencies>
104110
</project>

gp-res-filter/src/test/java/com/ibm/g11n/pipeline/resfilter/impl/XLIFFResourceTest.java

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
package com.ibm.g11n.pipeline.resfilter.impl;
1717

1818
import static org.junit.Assert.assertEquals;
19+
import static org.junit.Assert.assertThat;
1920
import static org.junit.Assert.assertTrue;
2021

2122
import java.io.File;
@@ -32,6 +33,7 @@
3233
import java.util.Locale;
3334

3435
import org.junit.Test;
36+
import org.xmlunit.matchers.CompareMatcher;
3537

3638
import com.ibm.g11n.pipeline.resfilter.FilterOptions;
3739
import com.ibm.g11n.pipeline.resfilter.LanguageBundle;
@@ -62,7 +64,8 @@ public class XLIFFResourceTest {
6264
List<ResourceString> lst = new LinkedList<>();
6365

6466
lst.add(ResourceString.with("1", "Quetzal").sequenceNumber(1).build());
65-
lst.add(ResourceString.with("3", "An application to manipulate and process XLIFF documents").sequenceNumber(2).build());
67+
lst.add(ResourceString.with("3", "An application to manipulate and process XLIFF documents").sequenceNumber(2)
68+
.build());
6669
lst.add(ResourceString.with("4", "XLIFF Data Manager").sequenceNumber(3).build());
6770
Collections.sort(lst, new ResourceStringComparator());
6871
EXPECTED_INPUT_RES_LIST = lst;
@@ -72,8 +75,8 @@ public class XLIFFResourceTest {
7275

7376
static {
7477
LanguageBundleBuilder bundleBuilder = new LanguageBundleBuilder(false);
75-
bundleBuilder.addResourceString("3", "XLIFF 文書を編集、または処理 するアプリケーションです。", 2,
76-
null, "An application to manipulate and process XLIFF documents");
78+
bundleBuilder.addResourceString("3", "XLIFF 文書を編集、または処理 するアプリケーションです。", 2, null,
79+
"An application to manipulate and process XLIFF documents");
7780
bundleBuilder.addResourceString("4", "XLIFF データ・マネージャ", 3, null, "XLIFF Data Manager");
7881
bundleBuilder.addResourceString("1", "Quetzal", 1, null, "Quetzal");
7982

@@ -115,7 +118,7 @@ public void testWrite() throws IOException, ResourceFilterException {
115118
try (OutputStream os = new FileOutputStream(tempFile)) {
116119
res.write(os, WRITE_BUNDLE, new FilterOptions(Locale.JAPANESE));
117120
os.flush();
118-
assertTrue(ResourceTestUtil.compareFiles(EXPECTED_WRITE_FILE, tempFile));
121+
assertThat(EXPECTED_WRITE_FILE, CompareMatcher.isIdenticalTo(tempFile));
119122
}
120123
}
121124

@@ -132,7 +135,8 @@ public void testMerge() throws IOException, ResourceFilterException {
132135
res.merge(is, os, MERGE_BUNDLE, new FilterOptions(Locale.ENGLISH));
133136
os.flush();
134137
// TODO: Not ready yet
135-
// assertTrue(ResourceTestUtil.compareFiles(EXPECTED_MERGE_1_FILE, tempFile));
138+
// assertTrue(ResourceTestUtil.compareFiles(EXPECTED_MERGE_1_FILE,
139+
// tempFile));
136140
}
137141

138142
tempFile = File.createTempFile(this.getClass().getSimpleName(), ".xlf");
@@ -143,7 +147,8 @@ public void testMerge() throws IOException, ResourceFilterException {
143147
res.merge(is, os, MERGE_BUNDLE, new FilterOptions(Locale.JAPANESE));
144148
os.flush();
145149
// TODO: Not ready yet
146-
// assertTrue(ResourceTestUtil.compareFiles(EXPECTED_MERGE_2_FILE, tempFile));
150+
// assertTrue(ResourceTestUtil.compareFiles(EXPECTED_MERGE_2_FILE,
151+
// tempFile));
147152
}
148153
}
149154
}

0 commit comments

Comments
 (0)