public void testPack() throws Exception { ISOField field = new ISOField(12, "ABCD"); IFB_LLLCHAR packager = new IFB_LLLCHAR(10, "Should be 004ABCD"); TestUtils.assertEquals(new byte[] {0x00, 0x04, 0x41, 0x42, 0x43, 0x44}, packager.pack(field)); }
public void testUnpack() throws Exception { byte[] raw = new byte[] {0x00, 0x04, 0x41, 0x42, 0x43, 0x44}; IFB_LLLCHAR packager = new IFB_LLLCHAR(10, "Should be 04ABCD"); ISOField field = new ISOField(12); packager.unpack(field, raw, 0); assertEquals("ABCD", (String) field.getValue()); }
@Test public void testConstructor() throws Throwable { ISOPackager msgPackager = new ISOBaseValidatingPackager(); ISOMsgFieldValidatingPackager iSOMsgFieldValidatingPackager = new ISOMsgFieldValidatingPackager(new IFB_LLLCHAR(), msgPackager); assertNull("iSOMsgFieldValidatingPackager.getDescription()", iSOMsgFieldValidatingPackager.getDescription()); assertEquals("iSOMsgFieldValidatingPackager.getMaxPackedLength()", -1, iSOMsgFieldValidatingPackager.getMaxPackedLength()); assertEquals("iSOMsgFieldValidatingPackager.getLength()", -1, iSOMsgFieldValidatingPackager.getLength()); }
@Test public void testUnpackThrowsNullPointerException1() throws Throwable { EuroSubFieldPackager euroSubFieldPackager = new EuroSubFieldPackager(); ISOFieldPackager[] fld = new ISOFieldPackager[4]; fld[0] = new IFB_LLLCHAR(); euroSubFieldPackager.setFieldPackager(fld); byte[] b = new byte[3]; try { euroSubFieldPackager.unpack(null, b); fail("Expected NullPointerException to be thrown"); } catch (NullPointerException ex) { assertNull("ex.getMessage()", ex.getMessage()); } } }
public void testReversability() throws Exception { String origin = "Abc123:.-"; ISOField f = new ISOField(12, origin); IFB_LLLCHAR packager = new IFB_LLLCHAR(10, "Should be Abc123:.-"); ISOField unpack = new ISOField(12); packager.unpack(unpack, packager.pack(f), 0); assertEquals(origin, (String) unpack.getValue()); } }