use of org.jpos.iso.ISOException in project jPOS by jpos.
the class GenericPackagerTest method testConstructorThrowsISOException1.
@Test
public void testConstructorThrowsISOException1() throws Throwable {
try {
new GenericPackager(new ByteArrayInputStream("".getBytes()));
fail("Expected ISOException to be thrown");
} catch (ISOException ex) {
assertEquals("ex.getNested().getClass()", SAXParseException.class, ex.getNested().getClass());
assertEquals("ex.getNested().getMessage()", "Premature end of file.", ex.getNested().getMessage());
}
}
use of org.jpos.iso.ISOException in project jPOS by jpos.
the class GenericSubFieldPackagerTest method testUnpackThrowsISOException5.
@Test
public void testUnpackThrowsISOException5() throws Throwable {
byte[] b = new byte[2];
try {
new GenericSubFieldPackager().unpack(new ISOBinaryField(), b);
fail("Expected ISOException to be thrown");
} catch (ISOException ex) {
assertEquals("ex.getMessage()", "Can't call packager on non Composite", ex.getMessage());
assertNull("ex.getNested()", ex.getNested());
}
}
use of org.jpos.iso.ISOException in project jPOS by jpos.
the class GenericSubFieldPackagerTest method testUnpackThrowsISOException2.
@Test
public void testUnpackThrowsISOException2() throws Throwable {
ISOFieldPackager[] fld = new ISOFieldPackager[2];
fld[1] = new IFA_LCHAR(0, "testGenericSubFieldPackagerDescription");
GenericSubFieldPackager genericSubFieldPackager = new GenericSubFieldPackager();
genericSubFieldPackager.setFieldPackager(fld);
byte[] b = new byte[3];
try {
genericSubFieldPackager.unpack(new ISOMsg(100), b);
fail("Expected ISOException to be thrown");
} catch (ISOException ex) {
assertEquals("ex.getMessage()", "org.jpos.iso.IFA_LCHAR: Problem unpacking field -1", ex.getMessage());
assertNull("ex.getNested().getMessage()", ex.getNested().getMessage());
}
}
use of org.jpos.iso.ISOException in project jPOS by jpos.
the class GenericSubFieldPackagerTest method testPackThrowsISOException2.
@Test
public void testPackThrowsISOException2() throws Throwable {
ISOFieldPackager[] fld = new ISOFieldPackager[3];
fld[1] = new IFA_LCHAR(0, "testGenericSubFieldPackagerDescription");
GenericSubFieldPackager genericSubFieldPackager = new GenericSubFieldPackager();
genericSubFieldPackager.setFieldPackager(fld);
try {
genericSubFieldPackager.pack(new ISOBinaryField(100));
fail("Expected ISOException to be thrown");
} catch (ISOException ex) {
assertEquals("ex.getMessage()", "org.jpos.iso.IFA_LCHAR: Problem packing field unknown", ex.getMessage());
assertNull("ex.getNested().getMessage()", ex.getNested().getMessage());
}
}
use of org.jpos.iso.ISOException in project jPOS by jpos.
the class GenericValidatingPackagerTest method testConstructorThrowsISOException1.
@Ignore("test fails - GenericValidatingPackager to be deprecated")
@Test
public void testConstructorThrowsISOException1() throws Throwable {
try {
new GenericValidatingPackager(new ByteArrayInputStream("x".getBytes()));
fail("Expected ISOException to be thrown");
} catch (ISOException ex) {
assertEquals("ex.getMessage()", "org.xml.sax.SAXParseException: Content is not allowed in prolog.", ex.getMessage());
assertEquals("ex.getNested().getMessage()", "Content is not allowed in prolog.", ex.getNested().getMessage());
}
}
Aggregations