List of usage examples for io.netty.buffer ByteBuf writeByte
public abstract ByteBuf writeByte(int value);
From source file:com.mobius.software.mqtt.parser.test.TestParser.java
License:Open Source License
@Test public void testNegativeNextIndexNotReset() throws MalformedMessageException { ByteBuf buf = Unpooled.buffer(103); buf.writeByte(0x82); buf.writeByte(0x66); //encoded l=104, actual l=103 buf.writeShort(10);/* www .j av a2 s .co m*/ buf.writeShort(97); buf.writeBytes(new byte[96]); buf.writeByte(1); try { MQParser.next(buf); } catch (MalformedMessageException e) { } assertEquals("buffer index was not reset", 0, buf.readerIndex()); }
From source file:com.mobius.software.mqtt.parser.test.TestParser.java
License:Open Source License
@Test public void testNextLengthIncomplete() throws MalformedMessageException { ByteBuf buf = Unpooled.buffer(2120207); buf.writeByte(0x82); buf.writeByte(0x8a);/*from ww w . jav a 2 s .c o m*/ buf.writeByte(0xB4); buf.writeByte(0x81); // one byte missing in length assertNull("Invalid next header length", MQParser.next(buf)); assertEquals("buffer index was not reset", 0, buf.readerIndex()); }
From source file:com.mobius.software.mqtt.parser.test.TestParser.java
License:Open Source License
@Test(expected = MalformedMessageException.class) public void testNextContentIncomplete() throws MalformedMessageException { ByteBuf buf = Unpooled.buffer(2120207); buf.writeByte(0x82); buf.writeByte(0x8a);//from w w w . j av a 2 s . c o m buf.writeByte(0xB4); buf.writeByte(0x81); buf.writeByte(0x01); buf.writeBytes(new byte[2120201]); // one byte missing in content MQParser.next(buf); assertEquals("buffer index was not reset", 0, buf.readerIndex()); }
From source file:com.mobius.software.mqtt.parser.test.TestParser.java
License:Open Source License
@Test public void testNextContentIncompleteBufferNotReset() throws MalformedMessageException { ByteBuf buf = Unpooled.buffer(2120207); buf.writeByte(0x82); buf.writeByte(0x8a);//from w w w . jav a 2s .c o m buf.writeByte(0xB4); buf.writeByte(0x81); buf.writeByte(0x01); buf.writeBytes(new byte[2120201]); // one byte missing in content try { MQParser.next(buf); } catch (MalformedMessageException e) { } assertEquals("buffer index was not reset", 0, buf.readerIndex()); }
From source file:com.mobius.software.mqtt.parser.test.TestParser.java
License:Open Source License
@Test public void testHeaderTypeNull() throws UnsupportedEncodingException, MalformedMessageException { expectedEx.expect(MalformedMessageException.class); ByteBuf buf = Unpooled.buffer(2); buf.writeByte(0); buf.writeByte(0);/* w ww .j a v a2 s.c om*/ MQParser.decode(buf); }
From source file:com.mobius.software.mqtt.parser.test.TestParser.java
License:Open Source License
@Test public void testConackCodeNull() throws UnsupportedEncodingException, MalformedMessageException { expectedEx.expect(MalformedMessageException.class); ByteBuf buf = Unpooled.buffer(3); buf.writeByte(0x20); buf.writeByte(2);/*from www . j av a 2 s . co m*/ buf.writeByte(0); buf.writeByte(6); MQParser.decode(buf); }
From source file:com.mobius.software.mqtt.parser.test.TestParser.java
License:Open Source License
@Test public void testSubackCodeNull() throws UnsupportedEncodingException, MalformedMessageException { expectedEx.expect(MalformedMessageException.class); ByteBuf buf = Unpooled.buffer(3); buf.writeByte(0x90); buf.writeByte(3);/* w w w .ja v a 2 s . com*/ buf.writeShort(10); buf.writeByte(3); MQParser.decode(buf); }
From source file:com.mobius.software.mqtt.parser.test.TestParser.java
License:Open Source License
@Test public void testDecodeLengthOne() { ByteBuf buf = Unpooled.buffer(114); buf.writeByte(0x82); buf.writeByte(0x66);/*from w ww. j av a 2 s . c om*/ buf.writeShort(10); buf.writeShort(97); buf.writeBytes(new byte[96]); buf.writeByte(1); buf.writeByte(0); }
From source file:com.mobius.software.mqtt.parser.test.TestParser.java
License:Open Source License
@Test public void testDecodeLengthTwo() { ByteBuf buf = Unpooled.buffer(205); buf.writeByte(0x82); buf.writeByte(0xCA);/*from w w w .ja va2 s . com*/ buf.writeByte(0x01); buf.writeShort(10); buf.writeShort(197); buf.writeBytes(new byte[196]); buf.writeByte(1); buf.writeByte(0); }
From source file:com.mobius.software.mqtt.parser.test.TestParser.java
License:Open Source License
@Test public void testDecodeLengthThree() { ByteBuf buf = Unpooled.buffer(20206); buf.writeByte(0x82); buf.writeByte(0xEA);/*from ww w.java 2 s.c om*/ buf.writeByte(0x9D); buf.writeByte(0x01); buf.writeShort(10); buf.writeShort(20197); buf.writeBytes(new byte[20196]); buf.writeByte(1); buf.writeByte(0); }