@Test public void testTwoConcatsFirstOneOmitted() throws Exception { byte[] data = new byte[] { 0xa /*UDHL*/, 0x0 /*IE ID*/, 0x3 /*IE Len*/, 0x30 /*REF*/, (byte) 0x40 /*MAX*/, 0x8 /*SEQ*/, 0x0 /*IE ID*/, 0x3 /*IE Len*/, 0x22 /*REF*/, (byte) 0xff /*MAX*/, 0x12 /*SEQ*/ }; Map<Integer, AbsIE> IEs = UDH.decode(data); Assert.assertEquals(IEs.size(), 1); AbsIE ie = IEs.get(AbsIE.CONCATENATED_SHORT_MESSAGES); Assert.assertEquals(ie.getId(), AbsIE.CONCATENATED_SHORT_MESSAGES); Assert.assertEquals(ie.getLength(), 3); ConcatenatedSM csm = (ConcatenatedSM) ie; Assert.assertEquals(csm.getReferenceNumber(), 0x22); Assert.assertEquals(csm.getMaxShortMessages(), (byte) 0xff); Assert.assertEquals(csm.getSeqNumber(), 0x12); }
@Test public void testConcatAndAppPort() throws Exception { byte[] data = new byte[] { 0x9 /*UDHL*/, 0x0 /*IE ID*/, 0x3 /*IE Len*/, (byte) 0xd0 /*REF*/, (byte) 0xcc /*MAX*/, (byte) 0xbb /*SEQ*/, 0x4 /*IE ID*/, 0x2 /*IE Len*/, (byte) 0xab /*SRC*/, (byte) 0xbc /*DST*/ }; Map<Integer, AbsIE> IEs = UDH.decode(data); Assert.assertEquals(IEs.size(), 2); AbsIE ie = IEs.get(AbsIE.CONCATENATED_SHORT_MESSAGES); Assert.assertEquals(ie.getId(), AbsIE.CONCATENATED_SHORT_MESSAGES); Assert.assertEquals(ie.getLength(), 3); ConcatenatedSM csm = (ConcatenatedSM) ie; Assert.assertEquals(csm.getReferenceNumber(), (byte) 0xd0); Assert.assertEquals(csm.getMaxShortMessages(), (byte) 0xcc); Assert.assertEquals(csm.getSeqNumber(), (byte) 0xbb); ie = IEs.get(AbsIE.APPLICATION_PORT_ADDRESSING_SCHEME_8BIT); Assert.assertEquals(ie.getId(), AbsIE.APPLICATION_PORT_ADDRESSING_SCHEME_8BIT); Assert.assertEquals(ie.getLength(), 2); ApplicationPort ap = (ApplicationPort) ie; Assert.assertEquals(ap.getSrcPort(), (short) 0xab); Assert.assertEquals(ap.getDstPort(), (short) 0xbc); }
@Test(expectedExceptions = NullPointerException.class) public void testNullPointerException() throws Exception { UDH.decode(null); }