Search in sources :

Example 1 with Attributes2Impl

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));
}
Also used : Attributes2Impl(org.xml.sax.ext.Attributes2Impl)

Example 2 with Attributes2Impl

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());
    }
}
Also used : Attributes2Impl(org.xml.sax.ext.Attributes2Impl) Attributes(org.xml.sax.Attributes) Test(org.junit.Test)

Example 3 with Attributes2Impl

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());
    }
}
Also used : Attributes2Impl(org.xml.sax.ext.Attributes2Impl) Attributes(org.xml.sax.Attributes) SAXException(org.xml.sax.SAXException) Test(org.junit.Test)

Example 4 with Attributes2Impl

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());
    }
}
Also used : AttributesImpl(org.xml.sax.helpers.AttributesImpl) Attributes2Impl(org.xml.sax.ext.Attributes2Impl) Attributes(org.xml.sax.Attributes) Test(org.junit.Test)

Example 5 with Attributes2Impl

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());
    }
}
Also used : Attributes2Impl(org.xml.sax.ext.Attributes2Impl) Attributes(org.xml.sax.Attributes) SAXException(org.xml.sax.SAXException) Test(org.junit.Test)

Aggregations

Attributes2Impl (org.xml.sax.ext.Attributes2Impl)13 Test (org.junit.Test)7 Attributes (org.xml.sax.Attributes)7 SAXException (org.xml.sax.SAXException)5 AttributesImpl (org.xml.sax.helpers.AttributesImpl)3 PsiElement (com.intellij.psi.PsiElement)1 Logger (org.jpos.util.Logger)1 SimpleLogListener (org.jpos.util.SimpleLogListener)1 Before (org.junit.Before)1