@Test
  public void createFixedLengthStringTlv() throws Exception {
    Tlv tlv0 = null;

    tlv0 = TlvUtil.createFixedLengthStringTlv((short) 0x0001, null, 2, "ISO-8859-1");
    Assert.assertEquals((short) 0x0001, tlv0.getTag());
    Assert.assertArrayEquals(HexUtil.toByteArray("0000"), tlv0.getValue());

    tlv0 = TlvUtil.createFixedLengthStringTlv((short) 0x0001, "", 2);
    Assert.assertEquals((short) 0x0001, tlv0.getTag());
    Assert.assertArrayEquals(HexUtil.toByteArray("0000"), tlv0.getValue());

    tlv0 = TlvUtil.createFixedLengthStringTlv((short) 0x0001, "1", 2, "ISO-8859-1");
    Assert.assertEquals((short) 0x0001, tlv0.getTag());
    Assert.assertArrayEquals(HexUtil.toByteArray("3100"), tlv0.getValue());

    tlv0 = TlvUtil.createFixedLengthStringTlv((short) 0x0001, "12", 2);
    Assert.assertEquals((short) 0x0001, tlv0.getTag());
    Assert.assertArrayEquals(HexUtil.toByteArray("3132"), tlv0.getValue());

    try {
      tlv0 = TlvUtil.createFixedLengthStringTlv((short) 0x0001, "12", 1, "ISO-8859-1");
      Assert.fail();
    } catch (TlvConvertException e) {
      // correct behavior
    }
  }
  @Test
  public void createNullTerminatedStringTlv() throws Exception {
    Tlv tlv0 = null;

    // null string should just be 0x00
    tlv0 = TlvUtil.createNullTerminatedStringTlv((short) 0x0001, null, "ISO-8859-1");
    Assert.assertEquals((short) 0x0001, tlv0.getTag());
    Assert.assertArrayEquals(HexUtil.toByteArray("00"), tlv0.getValue());

    tlv0 = TlvUtil.createNullTerminatedStringTlv((short) 0x0001, "", "ISO-8859-1");
    Assert.assertEquals((short) 0x0001, tlv0.getTag());
    Assert.assertArrayEquals(HexUtil.toByteArray("00"), tlv0.getValue());

    tlv0 = TlvUtil.createNullTerminatedStringTlv((short) 0x0001, "a");
    Assert.assertEquals((short) 0x0001, tlv0.getTag());
    Assert.assertArrayEquals(HexUtil.toByteArray("6100"), tlv0.getValue());

    tlv0 = TlvUtil.createNullTerminatedStringTlv((short) 0x0001, "c1net");
    Assert.assertEquals((short) 0x0001, tlv0.getTag());
    Assert.assertArrayEquals(HexUtil.toByteArray("63316e657400"), tlv0.getValue());
  }