use of io.fabric8.dosgi.io.ProtocolCodec.BufferState in project fabric8 by jboss-fuse.
the class LengthPrefixedCodecTest method testWrite$Twice.
@Test
public void testWrite$Twice() throws Exception {
final Buffer value1 = Buffer.ascii("TESTDATA");
final Buffer value2 = Buffer.ascii("TESTDATA");
codec.write(value1);
final BufferState state = codec.write(value2);
assertEquals(BufferState.NOT_EMPTY, state);
assertEquals(false, codec.full());
assertEquals(false, codec.empty());
assertEquals(0l, codec.getWriteCounter());
}
use of io.fabric8.dosgi.io.ProtocolCodec.BufferState in project fabric8 by jboss-fuse.
the class LengthPrefixedCodecTest method testWrite.
@Test
public void testWrite() throws Exception {
final Buffer value = Buffer.ascii("TESTDATA");
final BufferState state = codec.write(value);
assertEquals(BufferState.WAS_EMPTY, state);
assertEquals(false, codec.full());
assertEquals(false, codec.empty());
assertEquals(0l, codec.getWriteCounter());
}
use of io.fabric8.dosgi.io.ProtocolCodec.BufferState in project fabric8 by jboss-fuse.
the class LengthPrefixedCodecTest method testFlush$Partially.
@Test
public void testFlush$Partially() throws Exception {
final Buffer value = Buffer.ascii("TESTDATA");
codec.write(value);
final int bytesThatWillBeWritten = value.length() / 2;
expect(writableByteChannel.write((ByteBuffer) anyObject())).andAnswer(createWriteAnswer(bytesThatWillBeWritten));
replay(writableByteChannel);
final BufferState state = codec.flush();
assertEquals(BufferState.NOT_EMPTY, state);
assertEquals(false, codec.full());
assertEquals(false, codec.empty());
assertEquals(bytesThatWillBeWritten, codec.getWriteCounter());
}
use of io.fabric8.dosgi.io.ProtocolCodec.BufferState in project fabric8 by jboss-fuse.
the class LengthPrefixedCodecTest method testFlush.
@Test
public void testFlush() throws Exception {
final Buffer value = Buffer.ascii("TESTDATA");
codec.write(value);
final int bytesThatWillBeWritten = value.length();
expect(writableByteChannel.write((ByteBuffer) anyObject())).andAnswer(createWriteAnswer(bytesThatWillBeWritten));
replay(writableByteChannel);
final BufferState state = codec.flush();
assertEquals(BufferState.EMPTY, state);
assertEquals(false, codec.full());
assertEquals(true, codec.empty());
assertEquals(bytesThatWillBeWritten, codec.getWriteCounter());
assertEquals(BufferState.WAS_EMPTY, codec.flush());
}
Aggregations