@Test
public void testSslProcessWithTrustStore() throws InterruptedException,
EventDeliveryException, InstantiationException, IllegalAccessException {
setUp();
Event event = EventBuilder.withBody("test event 1", Charsets.UTF_8);
Server server = createSslServer(new MockAvroServer());
server.start();
Context context = new Context();
context.put("hostname", hostname);
context.put("port", String.valueOf(port));
context.put("ssl", String.valueOf(true));
context.put("truststore", "src/test/resources/truststore.jks");
context.put("truststore-password", "password");
context.put("batch-size", String.valueOf(2));
context.put("connect-timeout", String.valueOf(2000L));
context.put("request-timeout", String.valueOf(3000L));
Configurables.configure(sink, context);
sink.start();
Assert.assertTrue(LifecycleController.waitForOneOf(sink,
LifecycleState.START_OR_ERROR, 5000));
Transaction transaction = channel.getTransaction();
transaction.begin();
for (int i = 0; i < 10; i++) {
channel.put(event);
}
transaction.commit();
transaction.close();
for (int i = 0; i < 5; i++) {
Sink.Status status = sink.process();
Assert.assertEquals(Sink.Status.READY, status);
}
Assert.assertEquals(Sink.Status.BACKOFF, sink.process());
sink.stop();
Assert.assertTrue(LifecycleController.waitForOneOf(sink,
LifecycleState.STOP_OR_ERROR, 5000));
server.close();
}