use of org.smpp.util.ByteBuffer in project opensmpp by OpenSmpp.
the class ByteBufferTest method testReadBytesWithCountReadFirst.
@Test
public void testReadBytesWithCountReadFirst() throws Exception {
buffer = bufferOf(A, B, C);
ByteBuffer b = buffer.readBytes(2);
assertArrayEquals(new byte[] { A, B }, b.getBuffer());
}
use of org.smpp.util.ByteBuffer in project opensmpp by OpenSmpp.
the class ByteBufferTest method testRemoveByteFromEmptyThrowsException.
@Test
public void testRemoveByteFromEmptyThrowsException() throws Exception {
thrown.expect(NotEnoughDataInByteBufferException.class);
thrown.expect(notEnoughData(1, 0));
buffer = new ByteBuffer(new byte[] {});
buffer.removeByte();
}
use of org.smpp.util.ByteBuffer in project opensmpp by OpenSmpp.
the class ByteBufferTest method testRemoveCStringFromEmptyThrowsException.
@Test
public void testRemoveCStringFromEmptyThrowsException() throws Exception {
thrown.expect(NotEnoughDataInByteBufferException.class);
thrown.expect(notEnoughData(1, 0));
buffer = new ByteBuffer(new byte[] {});
buffer.removeCString();
}
use of org.smpp.util.ByteBuffer in project opensmpp by OpenSmpp.
the class AddressTest method testSetData.
@Test
public void testSetData() throws Exception {
ByteBuffer buffer = mock(ByteBuffer.class);
when(buffer.removeByte()).thenReturn((byte) 0x01, (byte) 0x02);
when(buffer.removeCString()).thenReturn("1234567890");
address.setData(buffer);
assertEquals(0x01, address.getTon());
assertEquals(0x02, address.getNpi());
assertEquals("1234567890", address.getAddress());
}
use of org.smpp.util.ByteBuffer in project opensmpp by OpenSmpp.
the class TLVByte method getValueData.
protected ByteBuffer getValueData() throws ValueNotSetException {
ByteBuffer valueBuf = new ByteBuffer();
valueBuf.appendByte(getValue());
return valueBuf;
}
Aggregations