@Test
public void testSubscription() {

    KafkaConsumer<byte[], byte[]> consumer = newConsumer();
    consumer.subscribe(Collections.singletonList(topic));
    assertEquals(singleton(topic), consumer.subscription());
    assertTrue(consumer.assignment().isEmpty());
    consumer.subscribe(Collections.<String>emptyList());
    assertTrue(consumer.subscription().isEmpty());
    assertTrue(consumer.assignment().isEmpty());
    consumer.assign(Collections.singletonList(tp0));
    assertTrue(consumer.subscription().isEmpty());
    assertEquals(singleton(tp0), consumer.assignment());
    consumer.unsubscribe();
    assertTrue(consumer.subscription().isEmpty());
    assertTrue(consumer.assignment().isEmpty());
    consumer.close();
}