Search in sources :

Example 11 with ByteBuffer

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());
}
Also used : ByteBuffer(org.smpp.util.ByteBuffer) Test(org.junit.Test)

Example 12 with ByteBuffer

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();
}
Also used : ByteBuffer(org.smpp.util.ByteBuffer) Test(org.junit.Test)

Example 13 with ByteBuffer

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();
}
Also used : ByteBuffer(org.smpp.util.ByteBuffer) Test(org.junit.Test)

Example 14 with ByteBuffer

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());
}
Also used : ByteBuffer(org.smpp.util.ByteBuffer) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 15 with ByteBuffer

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;
}
Also used : ByteBuffer(org.smpp.util.ByteBuffer)

Aggregations

ByteBuffer (org.smpp.util.ByteBuffer)21 Test (org.junit.Test)9 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)2 PDU (org.smpp.pdu.PDU)2 UnknownCommandIdException (org.smpp.pdu.UnknownCommandIdException)2 HeaderIncompleteException (org.smpp.pdu.HeaderIncompleteException)1 MessageIncompleteException (org.smpp.pdu.MessageIncompleteException)1 PDUException (org.smpp.pdu.PDUException)1 NotEnoughDataInByteBufferException (org.smpp.util.NotEnoughDataInByteBufferException)1