public void testReversability() throws Exception { byte[] origin = new byte[] {0x12, 0x34, 0x56, 0x78}; ISOBinaryField f = new ISOBinaryField(12, origin); IFB_LLLBINARY packager = new IFB_LLLBINARY(100, "Should be 12345678"); ISOBinaryField unpack = new ISOBinaryField(12); packager.unpack(unpack, packager.pack(f), 0); TestUtils.assertEquals(origin, (byte[])unpack.getValue()); }
public void testReversability() throws Exception { byte[] origin = new byte[] {0x12, 0x34, 0x56, 0x78}; ISOBinaryField f = new ISOBinaryField(12, origin); IFA_BINARY packager = new IFA_BINARY(4, "Should be 12345678"); ISOBinaryField unpack = new ISOBinaryField(12); packager.unpack(unpack, packager.pack(f), 0); TestUtils.assertEquals(origin, (byte[])unpack.getValue()); } }
public void testReversability() throws Exception { byte[] origin = new byte[] {0x12, 0x34, 0x56, 0x78}; ISOBinaryField f = new ISOBinaryField(12, origin); IFB_LLHFBINARY packager = new IFB_LLHFBINARY(10, "Should be 12345678"); ISOBinaryField unpack = new ISOBinaryField(12); packager.unpack(unpack, packager.pack(f), 0); TestUtils.assertEquals(origin, (byte[])unpack.getValue()); } }
public void testReversability() throws Exception { byte[] origin = new byte[] {0x12, 0x34, 0x56, 0x78}; ISOBinaryField f = new ISOBinaryField(12, origin); IFB_LLLHBINARY packager = new IFB_LLLHBINARY(10, "Should be 12345678"); ISOBinaryField unpack = new ISOBinaryField(12); packager.unpack(unpack, packager.pack(f), 0); TestUtils.assertEquals(origin, (byte[])unpack.getValue()); } }
public void testPack() throws Exception { ISOBinaryField field = new ISOBinaryField(12, new byte[] {0x12, 0x34}); IFA_LLLBINARY packager = new IFA_LLLBINARY(2, "Should be 1234"); TestUtils.assertEquals(new byte[] {0x30, 0x30, 0x32, 0x12, 0x34}, packager.pack(field)); }
public void testPack() throws Exception { ISOBinaryField field = new ISOBinaryField(12, new byte[] {0x12, 0x34}); IFB_LLLBINARY packager = new IFB_LLLBINARY(100, "Should be 1234"); TestUtils.assertEquals(new byte[] {0x00, 0x02, 0x12, 0x34}, packager.pack(field)); }
public void testPack() throws Exception { ISOBinaryField field = new ISOBinaryField(12, new byte[] {0x12, 0x34}); IFB_LLBINARY packager = new IFB_LLBINARY(2, "Should be 1234"); TestUtils.assertEquals(new byte[] {0x02, 0x12, 0x34}, packager.pack(field)); }
public void testUnpack() throws Exception { byte[] raw = new byte[] {0x30, 0x30, 0x32, 0x12, 0x34}; IFA_LLLBINARY packager = new IFA_LLLBINARY(2, "Should be 1234"); ISOBinaryField field = new ISOBinaryField(12); packager.unpack(field, raw, 0); TestUtils.assertEquals(new byte[] {0x12, 0x34}, (byte[])field.getValue()); }
public void testUnpack() throws Exception { byte[] raw = new byte[] {0x02, 0x12, 0x34, 0x00, 0x00}; IFB_LLHFBINARY packager = new IFB_LLHFBINARY(4, "Should be 1234"); ISOBinaryField field = new ISOBinaryField(12); packager.unpack(field, raw, 0); TestUtils.assertEquals(new byte[] {0x12, 0x34}, (byte[])field.getValue()); }
public void testUnpack() throws Exception { byte[] raw = new byte[] {0x02, 0x12, 0x34}; IFB_LLBINARY packager = new IFB_LLBINARY(2, "Should be 1234"); ISOBinaryField field = new ISOBinaryField(12); packager.unpack(field, raw, 0); TestUtils.assertEquals(new byte[] {0x12, 0x34}, (byte[])field.getValue()); }
public void testUnpack() throws Exception { byte[] raw = new byte[] {0x02, 0x12, 0x34}; IFB_LLHBINARY packager = new IFB_LLHBINARY(10, "Should be 1234"); ISOBinaryField field = new ISOBinaryField(12); packager.unpack(field, raw, 0); TestUtils.assertEquals(new byte[] {0x12, 0x34}, (byte[])field.getValue()); }
public void testUnpack() throws Exception { byte[] raw = new byte[] {0x00, 0x02, 0x12, 0x34}; IFB_LLLHBINARY packager = new IFB_LLLHBINARY(4, "Should be 1234"); ISOBinaryField field = new ISOBinaryField(12); packager.unpack(field, raw, 0); TestUtils.assertEquals(new byte[] {0x12, 0x34}, (byte[])field.getValue()); }
@Test public void testPackAnEmptyArray() throws Exception { ISOBinaryField field = new ISOBinaryField(9, new byte[]{}); IFE_LBINARY packager = new IFE_LBINARY(9, "testing packing an empty Array"); TestUtils.assertEquals(new byte[] {(byte)0xF0}, packager.pack(field)); }
@Test public void testPackANonEmptyArray() throws Exception { ISOBinaryField field = new ISOBinaryField(9, new byte[] {0x30, 0x31}); IFE_LBINARY packager = new IFE_LBINARY(9, "testing packing a non empty Array"); TestUtils.assertEquals(new byte[] {(byte) 0xF2, 0x30, 0x31}, packager.pack(field)); }
public void testUnpack() throws Exception { byte[] raw = new byte[] {(byte)0xF0, (byte)0xF0, (byte)0xF2, (byte)0x30, (byte)0x31}; IFE_LLLBINARY packager = new IFE_LLLBINARY(100, "Should be 1234"); ISOBinaryField field = new ISOBinaryField(12); packager.unpack(field, raw, 0); TestUtils.assertEquals(new byte[] {0x30, 0x31}, (byte[])field.getValue()); }
@Test public void testUnpackOffsetArray() throws Exception { byte[] raw = new byte[] {0x30, 0x31, (byte) 0xF2, 0x30, 0x31}; IFE_LBINARY packager = new IFE_LBINARY(9, "testing unpacking a non empty Array with an offset"); ISOBinaryField field = new ISOBinaryField(9); packager.unpack(field, raw, 2); TestUtils.assertEquals(new byte[] {0x30, 0x31}, (byte[])field.getValue()); } }
@Test public void testUnpackZeroLengthArray() throws Exception { byte[] raw = new byte[] {(byte) 0xF0}; IFE_LBINARY packager = new IFE_LBINARY(9, "testing unpacking an empty Array"); ISOBinaryField field = new ISOBinaryField(9); packager.unpack(field, raw, 0); TestUtils.assertEquals(new byte[]{}, (byte[])field.getValue()); }
@Test public void testPackThrowsISOException1() throws Throwable { try { new CTCSubFieldPackager().pack(new ISOBinaryField(100)); fail("Expected ISOException to be thrown"); } catch (ISOException ex) { assertEquals("ex.getMessage()", "null: null", ex.getMessage()); assertNull("ex.getNested().getMessage()", ex.getNested().getMessage()); } }
@Test public void testValidateThrowsISOException() throws Throwable { try { new MSGTEST(true).validate(new ISOBinaryField()); fail("Expected ISOException to be thrown"); } catch (ISOException ex) { assertEquals("ex.getMessage()", "Can't call validate on non Composite", ex.getMessage()); assertNull("ex.getNested()", ex.getNested()); } }
@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()); } }