コード例 #1
0
 public void testSingleRootElement() throws Exception {
   XMLStreamUnwrapper tokenizer =
       new XMLStreamUnwrapper(new ByteArrayInputStream("<root><test></test></root>".getBytes()));
   int i = 0;
   while (tokenizer.hasMoreElements()) {
     i++;
     final String element = tokenizer.nextElement();
     assertEquals("<test/>", element);
   }
   assertEquals(1, i);
 }
コード例 #2
0
 public void testAttribute() throws Exception {
   XMLStreamUnwrapper tokenizer =
       new XMLStreamUnwrapper(
           new ByteArrayInputStream(
               "<root><test><value1 attribute=\"test\">value</value1></test><test><value1 attribute=\"test\">value</value1></test></root>"
                   .getBytes()));
   int i = 0;
   while (tokenizer.hasMoreElements()) {
     i++;
     final String element = tokenizer.nextElement();
     assertEquals("<test><value1 attribute=\"test\">value</value1></test>", element);
   }
   assertEquals(2, i);
 }
コード例 #3
0
 public void testNSAttributes() throws Exception {
   XMLStreamUnwrapper tokenizer =
       new XMLStreamUnwrapper(
           new ByteArrayInputStream(
               "<root><test xmlns:tmdm=\"http://www.talend.com/mdm\"><value1 tmdm:type=\"test\">value</value1></test><test xmlns:tmdm=\"http://www.talend.com/mdm\"><value1 tmdm:type=\"test\">value</value1></test></root>"
                   .getBytes()));
   int i = 0;
   while (tokenizer.hasMoreElements()) {
     i++;
     final String element = tokenizer.nextElement();
     assertEquals(
         "<test xmlns:tmdm=\"http://www.talend.com/mdm\"><value1 tmdm:type=\"test\">value</value1></test>",
         element);
   }
   assertEquals(2, i);
 }
コード例 #4
0
 public void testEmptyRootElement() throws Exception {
   XMLStreamUnwrapper tokenizer =
       new XMLStreamUnwrapper(new ByteArrayInputStream("<root>\n</root>".getBytes()));
   assertFalse(tokenizer.hasMoreElements());
 }