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); }
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); }
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); }
public void testEmptyRootElement() throws Exception { XMLStreamUnwrapper tokenizer = new XMLStreamUnwrapper(new ByteArrayInputStream("<root>\n</root>".getBytes())); assertFalse(tokenizer.hasMoreElements()); }