diff options
author | Sundong Ahn <sundongahn@google.com> | 2021-01-21 15:28:16 +0900 |
---|---|---|
committer | Sundong Ahn <sundongahn@google.com> | 2021-01-21 17:44:27 +0900 |
commit | fad6161a8fd950cf244a2a1c690cdbdad6ebb4f9 (patch) | |
tree | a08c6d4be9de599a1c15d72332bf29344e448adb /tests/src | |
parent | 1c0769028da7cdeb3ebaad985373f6d2ee8c66a1 (diff) | |
download | xsdc-fad6161a8fd950cf244a2a1c690cdbdad6ebb4f9.tar.gz |
Fix the type name error
The type name is changed to element value name. And Add java test to
check write() function.
Bug: 177999772
Test: m -j && xsdc-java-tests
Change-Id: Ie0b6f92c39b8964ce763012578a1065600ed0dc4
Diffstat (limited to 'tests/src')
-rw-r--r-- | tests/src/com/android/xsdc/tests/XmlParserTest.java | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/tests/src/com/android/xsdc/tests/XmlParserTest.java b/tests/src/com/android/xsdc/tests/XmlParserTest.java index 0e901c7..ed9aa08 100644 --- a/tests/src/com/android/xsdc/tests/XmlParserTest.java +++ b/tests/src/com/android/xsdc/tests/XmlParserTest.java @@ -51,6 +51,21 @@ public class XmlParserTest { assertThat(orderType.getShipTo().get(0).getStreet(), is("street1")); assertThat(orderType.getShipTo().get(1).getZip(), is(new BigInteger("-7922816251426433759"))); + + String actualStr, expectedStr; + try (InputStream str = this.getClass().getClassLoader().getResourceAsStream( + "purchase_simple.xml")) { + expectedStr = new String(str.readAllBytes()); + } + try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) { + try(purchase.simple.XmlWriter writer = + new purchase.simple.XmlWriter(new PrintWriter(baos))) { + purchase.simple.XmlWriter.write(writer, orderType); + } + actualStr = new String(baos.toByteArray()); + } + + assertThat(new String(actualStr), is(expectedStr)); } @Test @@ -78,6 +93,21 @@ public class XmlParserTest { assertThat(person.getUSAddressP().getStreet(), is("street fighter")); assertThat(person.getUSAddressP().getZipcode(), is(new BigInteger("323232318329852"))); assertThat(person.getKRAddress().getStreet(), is("Nokdu Street")); + + String actualStr, expectedStr; + try (InputStream str = this.getClass().getClassLoader().getResourceAsStream( + "simple_complex_content.xml")) { + expectedStr = new String(str.readAllBytes()); + } + try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) { + try(simple.complex.content.XmlWriter writer = + new simple.complex.content.XmlWriter(new PrintWriter(baos))) { + simple.complex.content.XmlWriter.write(writer, person); + } + actualStr = new String(baos.toByteArray()); + } + + assertThat(new String(actualStr), is(expectedStr)); } @Test @@ -185,6 +215,20 @@ public class XmlParserTest { assertThat(simples.getListInt(), is(Arrays.asList(1, 2, 3, 4, 5))); assertThat(simples.getUnionTest(), is(Arrays.asList("100"))); + + String actualStr, expectedStr; + try (InputStream str = this.getClass().getClassLoader().getResourceAsStream( + "simple_type.xml")) { + expectedStr = new String(str.readAllBytes()); + } + try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) { + try(simple.type.XmlWriter writer = new simple.type.XmlWriter(new PrintWriter(baos))) { + simple.type.XmlWriter.write(writer, simples); + } + actualStr = new String(baos.toByteArray()); + } + + assertThat(new String(actualStr), is(expectedStr)); } @Test @@ -196,5 +240,19 @@ public class XmlParserTest { } assertThat(_class.getStudent(), is(Arrays.asList("Sam", "Paul", "Peter"))); + + String actualStr, expectedStr; + try (InputStream str = this.getClass().getClassLoader().getResourceAsStream( + "reference.xml")) { + expectedStr = new String(str.readAllBytes()); + } + try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) { + try(reference.XmlWriter writer = new reference.XmlWriter(new PrintWriter(baos))) { + reference.XmlWriter.write(writer, _class); + } + actualStr = new String(baos.toByteArray()); + } + + assertThat(new String(actualStr), is(expectedStr)); } } |