use of org.xml.sax.ext.Attributes2Impl in project robovm by robovm.
the class Attributes2ImplTest method testAddAttribute.
public void testAddAttribute() {
Attributes2Impl attrs = new Attributes2Impl();
// Ordinary case
attrs.addAttribute("http://yet.another.uri", "doe", "john:doe", "string", "abc");
assertEquals(1, attrs.getLength());
assertEquals("http://yet.another.uri", attrs.getURI(0));
assertEquals("doe", attrs.getLocalName(0));
assertEquals("john:doe", attrs.getQName(0));
assertEquals("string", attrs.getType(0));
assertEquals("abc", attrs.getValue(0));
assertEquals(true, attrs.isDeclared(0));
assertEquals(true, attrs.isSpecified(0));
// CDATA case
attrs.addAttribute("http://yet.another.uri", "doe", "jane:doe", "CDATA", "abc");
assertEquals(2, attrs.getLength());
assertEquals("http://yet.another.uri", attrs.getURI(1));
assertEquals("doe", attrs.getLocalName(1));
assertEquals("jane:doe", attrs.getQName(1));
assertEquals("CDATA", attrs.getType(1));
assertEquals("abc", attrs.getValue(1));
assertEquals(false, attrs.isDeclared(1));
assertEquals(true, attrs.isSpecified(1));
}
use of org.xml.sax.ext.Attributes2Impl in project jPOS by jpos.
the class XMLPackagerTest method testStartElementThrowsNullPointerException.
@Test
public void testStartElementThrowsNullPointerException() throws Throwable {
Attributes atts = new Attributes2Impl();
try {
xMLPackager.startElement("testXMLPackagerNs", null, "testXMLPackagerQName", atts);
fail("Expected NullPointerException to be thrown");
} catch (NullPointerException ex) {
assertNull("ex.getMessage()", ex.getMessage());
}
}
use of org.xml.sax.ext.Attributes2Impl in project jPOS by jpos.
the class GenericPackagerTest method testGenericContentHandlerStartElementThrowsSAXException4.
@Test
public void testGenericContentHandlerStartElementThrowsSAXException4() throws Throwable {
GenericPackager.GenericContentHandler genericContentHandler = new X92GenericPackager().new GenericContentHandler();
Attributes atts = new Attributes2Impl();
try {
genericContentHandler.startElement("testGenericContentHandlerNamespaceURI", "isofieldpackager", "testGenericContentHandlerQName", atts);
fail("Expected SAXException to be thrown");
} catch (SAXException ex) {
assertEquals("ex.getMessage()", "null", ex.getMessage());
assertEquals("ex.getException().getMessage()", "null", ex.getException().getMessage());
}
}
use of org.xml.sax.ext.Attributes2Impl in project jPOS by jpos.
the class GenericPackagerTest method testGenericContentHandlerEndElementThrowsClassCastException.
@Test
public void testGenericContentHandlerEndElementThrowsClassCastException() throws Throwable {
GenericPackager.GenericContentHandler genericContentHandler = new GenericPackager().new GenericContentHandler();
genericContentHandler.startDocument();
Attributes atts = new AttributesImpl(new Attributes2Impl());
genericContentHandler.startElement("testGenericContentHandlerNamespaceURI", "isopackager", "testGenericContentHandlerQName", atts);
genericContentHandler.startElement("testGenericContentHandlerNamespaceURI1", "isopackager", "testGenericContentHandlerQName1", atts);
try {
genericContentHandler.endElement("testGenericContentHandlerNamespaceURI", "isofieldpackager", "testGenericContentHandlerQName");
fail("Expected ClassCastException to be thrown");
} catch (ClassCastException ex) {
assertEquals("ex.getClass()", ClassCastException.class, ex.getClass());
}
}
use of org.xml.sax.ext.Attributes2Impl in project jPOS by jpos.
the class GenericPackagerTest method testGenericContentHandlerStartElementThrowsSAXException2.
@Test
public void testGenericContentHandlerStartElementThrowsSAXException2() throws Throwable {
GenericPackager.GenericContentHandler genericContentHandler = new GenericSubFieldPackager().new GenericContentHandler();
Attributes atts = new Attributes2Impl();
try {
genericContentHandler.startElement("testGenericContentHandlerNamespaceURI", null, "testGenericContentHandlerQName", atts);
fail("Expected SAXException to be thrown");
} catch (SAXException ex) {
assertNull("ex.getMessage()", ex.getMessage());
assertNull("ex.getException().getMessage()", ex.getException().getMessage());
}
}
Aggregations