@Test
public void getShortMessageUserData() {

    Assert.assertNull(GsmUtil.getShortMessageUserData(null));
    Assert.assertArrayEquals(HexUtil.toByteArray(""), GsmUtil.getShortMessageUserData(HexUtil.toByteArray("")));
    Assert.assertArrayEquals(HexUtil.toByteArray("02"), GsmUtil.getShortMessageUserData(HexUtil.toByteArray("0002")));
    Assert.assertArrayEquals(HexUtil.toByteArray(""), GsmUtil.getShortMessageUserData(HexUtil.toByteArray("0102")));
    Assert.assertArrayEquals(HexUtil.toByteArray("0304050607"), GsmUtil.getShortMessageUserData(HexUtil.toByteArray("01020304050607")));
    // make sure "signed" byte of user data header works
    Assert.assertArrayEquals(HexUtil.toByteArray("08"), GsmUtil.getShortMessageUserData(HexUtil.toByteArray("80000102030405060708090001020304050607080900010203040506070809000102030405060708090001020304050607080900010203040506070809000102030405060708090001020304050607080900010203040506070809000102030405060708090001020304050607080900010203040506070809000102030405060708")));
    try {
        // UDH length exceeds payload
        Assert.assertArrayEquals(HexUtil.toByteArray("01"), GsmUtil.getShortMessageUserData(HexUtil.toByteArray("01")));
        Assert.fail();
    } catch (IllegalArgumentException e) {
        // correct behavior
    }
}