Beispiel #1
0
 public void testUnpack() throws Exception {
   byte[] raw = "1234".getBytes();
   IFA_BINARY packager = new IFA_BINARY(2, "Should be 1234");
   ISOBinaryField field = new ISOBinaryField(12);
   packager.unpack(field, raw, 0);
   TestUtils.assertEquals(new byte[] {0x12, 0x34}, (byte[]) field.getValue());
 }
Beispiel #2
0
 @Test
 public void test() {
   U4 u4 = new U4();
   u4.addValue(0);
   u4.addValue(1);
   u4.addValue(255);
   u4.addValue(256);
   u4.addValue(257);
   u4.addValue(65535);
   u4.addValue(0xffffffffL);
   u4.addValue(new byte[] {0x11, 0x22, 0x33, 0x44});
   u4.addValue(
       new byte[] {
         (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
       });
   Assert.assertEquals(9, u4.length());
   Assert.assertEquals("U4:9 {0 1 255 256 257 65535 4294967295 287454020 4294967295}", u4.toSml());
   TestUtils.assertEquals(
       new byte[] {
         (byte) 0xb1,
         0x24,
         0x00,
         0x00,
         0x00,
         0x00,
         0x00,
         0x00,
         0x00,
         0x01,
         0x00,
         0x00,
         0x00,
         (byte) 0xff,
         0x00,
         0x00,
         0x01,
         0x00,
         0x00,
         0x00,
         0x01,
         0x01,
         0x00,
         0x00,
         (byte) 0xff,
         (byte) 0xff,
         (byte) 0xff,
         (byte) 0xff,
         (byte) 0xff,
         (byte) 0xff,
         0x11,
         0x22,
         0x33,
         0x44,
         (byte) 0xff,
         (byte) 0xff,
         (byte) 0xff,
         (byte) 0xff
       },
       u4.toByteArray());
 }
Beispiel #3
0
  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 testReversabilityGreaterThan16() throws Exception {
    byte[] origin =
        new byte[] {
          0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
          0x10, 0x11
        };
    ISOBinaryField f = new ISOBinaryField(1, origin);
    IFB_LLLBINARY packager =
        new IFB_LLLBINARY(999, "Should be x'0102030405060708090a0b0c0d0e0f1011'");

    ISOBinaryField unpack = new ISOBinaryField(12);
    packager.unpack(unpack, packager.pack(f), 0);
    TestUtils.assertEquals(origin, (byte[]) unpack.getValue());
  }
Beispiel #5
0
  @Test
  public void test() {
    I1 i1 = new I1();
    Assert.assertEquals(0, i1.length());
    Assert.assertEquals("<I1>", i1.toSml());

    i1.addValue(0);
    i1.addValue(1);
    i1.addValue(-1);
    i1.addValue(127);
    i1.addValue(-128);
    Assert.assertEquals(5, i1.length());
    Assert.assertEquals("<I1 0 1 -1 127 -128>", i1.toSml());
    TestUtils.assertEquals(
        new byte[] {0x65, 0x05, 0x00, 0x01, (byte) 0xff, 0x7f, (byte) 0x80}, i1.toByteArray());
  }
 public void testUnpackGreaterThan16() throws Exception {
   byte[] raw =
       new byte[] {
         0x00, 0x17, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d,
         0x0e, 0x0f, 0x10, 0x11
       };
   IFB_LLLBINARY packager = new IFB_LLLBINARY(999, "Should be 17 bytes 01 through 11");
   ISOBinaryField field = new ISOBinaryField(1);
   packager.unpack(field, raw, 0);
   TestUtils.assertEquals(
       new byte[] {
         0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
         0x10, 0x11
       },
       (byte[]) field.getValue());
 }
 public void testPackGreaterThan16() throws Exception {
   ISOBinaryField field =
       new ISOBinaryField(
           1,
           new byte[] {
             0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
             0x0f, 0x10, 0x11
           });
   IFB_LLLBINARY packager = new IFB_LLLBINARY(1, "Should be 1234");
   TestUtils.assertEquals(
       new byte[] {
         0x00, 0x17, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d,
         0x0e, 0x0f, 0x10, 0x11
       },
       packager.pack(field));
 }
Beispiel #8
0
 public void testPack() throws Exception {
   ISOField field = new ISOField(12, "1234");
   IFE_NUMERIC packager = new IFE_NUMERIC(10, "Should be 0000001234");
   TestUtils.assertEquals(
       new byte[] {
         (byte) 0xF0,
         (byte) 0xF0,
         (byte) 0xF0,
         (byte) 0xF0,
         (byte) 0xF0,
         (byte) 0xF0,
         (byte) 0xF1,
         (byte) 0xF2,
         (byte) 0xF3,
         (byte) 0xF4
       },
       packager.pack(field));
 }
Beispiel #9
0
 public void testPack() throws Exception {
   ISOBinaryField field = new ISOBinaryField(12, new byte[] {0x12, 0x34});
   IFA_BINARY packager = new IFA_BINARY(2, "Should be 1234");
   TestUtils.assertEquals("1234".getBytes(), packager.pack(field));
 }
Beispiel #10
0
 public void testPack() throws Exception {
   ISOField field = new ISOField(12, "D123");
   IFE_AMOUNT packager = new IFE_AMOUNT(6, "Should be C4F0F0F1F2F3");
   TestUtils.assertEquals(ISOUtil.hex2byte("C4F0F0F1F2F3"), 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));
 }
Beispiel #12
0
 public void testPack() throws Exception {
   ISOField field = new ISOField(12, "D123");
   IFA_AMOUNT packager = new IFA_AMOUNT(6, "Should be D00123");
   TestUtils.assertEquals(new byte[] {68, 48, 48, 49, 50, 51}, packager.pack(field));
 }
Beispiel #13
0
 public void testPack() throws Exception {
   ISOField field = new ISOField(12, "1234");
   IFB_LLLNUM packager = new IFB_LLLNUM(10, "Should be 00041234", true);
   TestUtils.assertEquals(new byte[] {0x00, 0x04, 0x12, 0x34}, packager.pack(field));
 }