setUp("deflate", 6);
boolean bound = false;
AvroSource source;
Channel sourceChannel;
int selectedPort;
source = new AvroSource();
sourceChannel = new MemoryChannel();
Configurables.configure(sourceChannel, new Context());
List<Channel> channels = new ArrayList<Channel>();
channels.add(sourceChannel);
ChannelSelector rcs = new ReplicatingChannelSelector();
rcs.setChannels(channels);
source.setChannelProcessor(new ChannelProcessor(rcs));
Context context = new Context();
context.put("port", port.toString());
context.put("bind", hostname);
context.put("threads", "50");
context.put("compression-type", "deflate");
context.put("ssl", String.valueOf(true));
context.put("keystore", "src/test/resources/server.p12");
context.put("keystore-password", "password");
context.put("keystore-type", "PKCS12");
Configurables.configure(source, context);
source.start();
Assert
.assertTrue("Reached start or error", LifecycleController.waitForOneOf(
source, LifecycleState.START_OR_ERROR));
Assert.assertEquals("Server is started", LifecycleState.START,
source.getLifecycleState());
Event event = EventBuilder.withBody("Hello avro",
Charset.forName("UTF8"));
context = new Context();
context.put("hostname", hostname);
context.put("port", String.valueOf(port));
context.put("ssl", String.valueOf(true));
context.put("trust-all-certs", String.valueOf(true));
context.put("batch-size", String.valueOf(2));
context.put("connect-timeout", String.valueOf(2000L));
context.put("request-timeout", String.valueOf(3000L));
context.put("compression-type", "deflate");
context.put("compression-level", Integer.toString(6));
Configurables.configure(sink, context);
sink.start();
Transaction sickTransaction = channel.getTransaction();
sickTransaction.begin();
for (int i = 0; i < 10; i++) {
channel.put(event);
}
sickTransaction.commit();
sickTransaction.close();
for (int i = 0; i < 5; i++) {
Sink.Status status = sink.process();
logger.debug("Calling Process " + i + " times:" + status);
Assert.assertEquals(Sink.Status.READY, status);
}
sink.stop();
Transaction sourceTransaction = sourceChannel.getTransaction();
sourceTransaction.begin();
Event sourceEvent = sourceChannel.take();
Assert.assertNotNull(sourceEvent);
Assert.assertEquals("Channel contained our event", "Hello avro",
new String(sourceEvent.getBody()));
sourceTransaction.commit();
sourceTransaction.close();