@Test public void shouldCreateTopic() { ZkClient zkClient = KafkaUtils.createZkClient(KAFKA.getZkConnectString()); assertThat(KAFKA.isTopicAvailable(TOPIC), is(true)); checkLists(Lists.newArrayList(TOPIC), KafkaUtils.listTopics(zkClient)); assertThat(KafkaUtils.listPartitions(zkClient, TOPIC).size(), is(TOPIC_PART)); }
@Test public void shouldSendAndReceiveLogs() throws InterruptedException { List<SimplifiedLog> expected = createTestData(); KAFKA.produce(expected, TOPIC); List<SimplifiedLog> retrieved = KAFKA.consume(TOPIC, TOPIC_PART, (MSG_AMOUNT / TOPIC_PART)); checkLists(expected, retrieved); }
@Override protected void after() { try { KAFKA.stop(); } catch (IOException ignored) { } }
@Override protected void before() throws Exception { KAFKA.start(); KAFKA.createTopic(TOPIC, TOPIC_PART); }