@Test
public void testListConsumerGroups() throws Exception {

    CreateConsumerGroupRequest request = new CreateConsumerGroupRequest();
    final String destination = "/foo/bar";
    final String consumerGroup = "TestConsumerGroup";
    final int lockTimeout = new Random().nextInt();
    final int maxDelivery = new Random().nextInt();
    final String email = "foo@bar.com";
    final int skipOlder = new Random().nextInt();
    final long timestamp = new Date().getTime();
    request.setDestinationPath(destination);
    request.setConsumerGroupName(consumerGroup);
    request.setLockTimeoutInSeconds(lockTimeout);
    request.setMaxDeliveryCount(maxDelivery);
    request.setOwnerEmail(email);
    request.setSkipOlderMessagesInSeconds(skipOlder);
    request.setStartFrom(timestamp);
    client.createConsumerGroup(request);
    ListConsumerGroupRequest listRequest = new ListConsumerGroupRequest();
    listRequest.setDestinationPath(destination);
    listRequest.setConsumerGroupName(consumerGroup);
    //Simple test case of returning list of an existing ConsumerGroup
    client.listConsumerGroups(listRequest);
    //Client should not be able to list nonexistent ConsumerGroup
    thrown.expect(BadRequestError.class);
    listRequest.setDestinationPath("/invalid/Path");
    client.listConsumerGroups(listRequest);
}