aboutsummaryrefslogtreecommitdiff
path: root/tests/src
diff options
context:
space:
mode:
authorSundong Ahn <sundongahn@google.com>2021-01-22 10:46:24 +0900
committerSundong Ahn <sundongahn@google.com>2021-01-26 13:46:14 +0900
commit7a302b3b16394f36a8894c6c636af6eac0d6dcd9 (patch)
tree889209712ec370276513258667044919fe16bff5 /tests/src
parentfad6161a8fd950cf244a2a1c690cdbdad6ebb4f9 (diff)
downloadxsdc-7a302b3b16394f36a8894c6c636af6eac0d6dcd9.tar.gz
Support base64Binary and hexBinary
The xml generator is not supported the base64Binary and hexBinary. So, the base64Binary and hexBinary were treated specially unlike other types. Bug: 178068675 Test: m -j && atest xsdc-java-tests && atest xsdc-cpp-tests Change-Id: I0261dec0548cc6e2b886d2187c721655fe568e99
Diffstat (limited to 'tests/src')
-rw-r--r--tests/src/com/android/xsdc/tests/XmlParserTest.java18
1 files changed, 17 insertions, 1 deletions
diff --git a/tests/src/com/android/xsdc/tests/XmlParserTest.java b/tests/src/com/android/xsdc/tests/XmlParserTest.java
index ed9aa08..f3b5eaf 100644
--- a/tests/src/com/android/xsdc/tests/XmlParserTest.java
+++ b/tests/src/com/android/xsdc/tests/XmlParserTest.java
@@ -180,7 +180,8 @@ public class XmlParserTest {
assertThat(miscTypes.getAnyURI(), is("https://www.google.com"));
assertThat(miscTypes.getBase64Binary(), is(Base64.getDecoder().decode("Z29vZ2xl")));
assertThat(miscTypes.get_boolean(), is(true));
- assertThat(miscTypes.getHexBinary(), is(new BigInteger("516a75cb56d7e7", 16)));
+ assertThat(miscTypes.getHexBinary(),
+ is(predefined.types.HexBinaryHelper.hexStringToByteArray("016a75cb56d7e7")));
assertThat(miscTypes.getQName(), is("abcd"));
assertThat(miscTypes.getIDREF(), is("abcd"));
assertThat(miscTypes.getIDREFS(), is(Arrays.asList("abcd", "abcd")));
@@ -203,6 +204,21 @@ public class XmlParserTest {
assertThat(listPrimitiveTypes.getListFloat(), is(Arrays.asList(123.4f, 456.1f)));
assertThat(listPrimitiveTypes.getListBoolean(), is(Arrays.asList(true, false)));
}
+
+ String actualStr, expectedStr;
+ try (InputStream str = this.getClass().getClassLoader().getResourceAsStream(
+ "predefined_types.xml")) {
+ expectedStr = new String(str.readAllBytes());
+ }
+ try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
+ try(predefined.types.XmlWriter writer =
+ new predefined.types.XmlWriter(new PrintWriter(baos))) {
+ predefined.types.XmlWriter.write(writer, type);
+ }
+ actualStr = new String(baos.toByteArray());
+ }
+
+ assertThat(new String(actualStr), is(expectedStr));
}
@Test