@Test
public void testDeleteConsumerGroup() throws Exception {

    //Create a ConsumerGroup to delete
    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);

    ConsumerGroupDescription response = client.createConsumerGroup(request);

    assert (response.getDestinationPath().equals(destination));
    assert (response.getConsumerGroupName().equals(consumerGroup));

    DeleteConsumerGroupRequest deleteRequest = new DeleteConsumerGroupRequest();

    deleteRequest.setDestinationPath(destination);
    deleteRequest.setConsumerGroupName(consumerGroup);
    // Simple test case where we delete an existing ConsumerGroup
    try {
        client.deleteConsumerGroup(deleteRequest);
    } catch (RuntimeException e) {
        assert (false);
    }

    // Client should not be able to delete a nonexistent ConsumerGroup
    thrown.expect(EntityNotExistsError.class);
    client.deleteConsumerGroup(deleteRequest);
}