use of com.yahoo.fs4.ErrorPacket in project vespa by vespa-engine.
the class PacketDecoderTestCase method testErrorPacket.
@Test
public void testErrorPacket() throws BufferTooSmallException {
ByteBuffer b = ByteBuffer.allocate(100);
b.putInt(0);
b.putInt(203);
b.putInt(1);
b.putInt(37);
b.putInt(5);
b.put(new byte[] { (byte) 'n', (byte) 'a', (byte) 'l', (byte) 'l', (byte) 'e' });
b.putInt(0, b.position() - 4);
b.flip();
DecodedPacket p = PacketDecoder.extractPacket(b);
ErrorPacket e = (ErrorPacket) p.packet;
assertEquals("nalle (37)", e.toString());
assertEquals(203, e.getCode());
assertEquals(37, e.getErrorCode());
b = ByteBuffer.allocate(100);
// warn if encoding support is added untested
e.encode(b);
b.position(0);
assertEquals(4, b.getInt());
assertEquals(203, b.getInt());
assertFalse(b.hasRemaining());
}
Aggregations