diff options
author | Gunhyeong Kim <gunhyeong@google.com> | 2018-08-28 16:02:59 +0900 |
---|---|---|
committer | Gunhyeong Kim <gunhyeong@google.com> | 2018-08-28 16:02:59 +0900 |
commit | d047615b0b0b38bacb1da9af32899ff88ab1cb04 (patch) | |
tree | 40f6c5667445f1464c1bf8d62e772d9c1daafc8b /tests/src | |
parent | ae3e5a452f197e718ef88cccfdf3247ebcf99d54 (diff) | |
download | xsdc-d047615b0b0b38bacb1da9af32899ff88ab1cb04.tar.gz |
Bugfix for element reference
This will correctly parse multiply occurring referenced elements.
Also added a test case.
Test: 'm -j xsdc', 'm -j xsdc-tests'
Change-Id: I62815afcc6e48493f874b579896a2de38cd58780
Diffstat (limited to 'tests/src')
-rw-r--r-- | tests/src/com/android/xsdc/tests/XmlParserTest.java | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/src/com/android/xsdc/tests/XmlParserTest.java b/tests/src/com/android/xsdc/tests/XmlParserTest.java index ab4bc18..154790d 100644 --- a/tests/src/com/android/xsdc/tests/XmlParserTest.java +++ b/tests/src/com/android/xsdc/tests/XmlParserTest.java @@ -328,4 +328,26 @@ public class XmlParserTest { assertThat(listInt, is(Arrays.asList(1, 2, 3, 4, 5))); assertThat(uniontest, is(Arrays.asList("100"))); } + + @Test + public void testReference() throws Exception { + TestCompilationResult result; + try (InputStream in = this.getClass().getClassLoader().getResourceAsStream( + "reference.xsd")) { + result = TestHelper.parseXsdAndCompile(in); + } + + Class<?> xmlParser = result.loadClass("XmlParser"); + Class<?> cls = result.loadClass("Class"); + + Object instance; + try (InputStream in = this.getClass().getClassLoader().getResourceAsStream( + "reference.xml")) { + instance = xmlParser.getMethod("read", InputStream.class).invoke(null, in); + } + + List student = (List) cls.getMethod("getStudent").invoke(instance); + + assertThat(student, is(Arrays.asList("Sam", "Paul", "Peter"))); + } }
\ No newline at end of file |