@Test
public void testHexStringToByteArray() {

    assertEquals(null, StringHelper.hexStringToByteArray(null));
    assertEq(new byte[]{}, StringHelper.hexStringToByteArray(""));
    assertEq(new byte[]{0, 1, 2}, StringHelper.hexStringToByteArray("000102"));
    assertEq(new byte[]{14, 15, 16}, StringHelper.hexStringToByteArray("0E0F10"));
    assertEq(new byte[]{-128, -1}, StringHelper.hexStringToByteArray("80FF"));
    assertEq(new byte[]{26}, StringHelper.hexStringToByteArray("1a"));
    assertEq(new byte[]{-2}, StringHelper.hexStringToByteArray("fE"));
    try {
        StringHelper.hexStringToByteArray("1");
        fail("exception expected");
    } catch (Exception e) {
        // expected
    }
    try {
        StringHelper.hexStringToByteArray("1X");
        fail("exception expected");
    } catch (Exception e) {
        // expected
    }
    try {
        StringHelper.hexStringToByteArray("X1");
        fail("exception expected");
    } catch (Exception e) {
        // expected
    }
}