source, LifecycleState.START_OR_ERROR));
Assert.assertEquals("Server is started", LifecycleState.START,
source.getLifecycleState());
AvroSourceProtocol client;
NettyTransceiver nettyTransceiver;
if (clientEnableCompression) {
nettyTransceiver = new NettyTransceiver(new InetSocketAddress(
selectedPort), new CompressionChannelFactory(compressionLevel));
client = SpecificRequestor.getClient(
AvroSourceProtocol.class, nettyTransceiver);
} else {
nettyTransceiver = new NettyTransceiver(new InetSocketAddress(selectedPort));
client = SpecificRequestor.getClient(
AvroSourceProtocol.class, nettyTransceiver);
}
AvroFlumeEvent avroEvent = new AvroFlumeEvent();
avroEvent.setHeaders(new HashMap<CharSequence, CharSequence>());
avroEvent.setBody(ByteBuffer.wrap("Hello avro".getBytes()));
Status status = client.append(avroEvent);
Assert.assertEquals(Status.OK, status);
Transaction transaction = channel.getTransaction();
transaction.begin();
Event event = channel.take();
Assert.assertNotNull(event);
Assert.assertEquals("Channel contained our event", "Hello avro",
new String(event.getBody()));
transaction.commit();
transaction.close();
logger.debug("Round trip event:{}", event);
nettyTransceiver.close();
source.stop();
Assert.assertTrue("Reached stop or error",
LifecycleController.waitForOneOf(source, LifecycleState.STOP_OR_ERROR));
Assert.assertEquals("Server is stopped", LifecycleState.STOP,
source.getLifecycleState());