Search in sources :

Example 1 with BrokerStatsImpl

use of org.apache.pulsar.client.admin.internal.BrokerStatsImpl in project incubator-pulsar by apache.

the class PulsarBrokerStatsClientTest method testServiceException.

@Test
public void testServiceException() throws Exception {
    URL url = new URL("http://localhost:15000");
    PulsarAdmin admin = new PulsarAdmin(url, (Authentication) null);
    BrokerStatsImpl client = (BrokerStatsImpl) spy(admin.brokerStats());
    try {
        client.getLoadReport();
    } catch (PulsarAdminException e) {
    // Ok
    }
    try {
        client.getPendingBookieOpsStats();
    } catch (PulsarAdminException e) {
    // Ok
    }
    try {
        client.getBrokerResourceAvailability("prop/cluster/ns");
    } catch (PulsarAdminException e) {
    // Ok
    }
    assertTrue(client.getApiException(new ClientErrorException(403)) instanceof NotAuthorizedException);
    assertTrue(client.getApiException(new ClientErrorException(404)) instanceof NotFoundException);
    assertTrue(client.getApiException(new ClientErrorException(409)) instanceof ConflictException);
    assertTrue(client.getApiException(new ClientErrorException(412)) instanceof PreconditionFailedException);
    assertTrue(client.getApiException(new ClientErrorException(400)) instanceof PulsarAdminException);
    assertTrue(client.getApiException(new ServerErrorException(500)) instanceof ServerSideErrorException);
    assertTrue(client.getApiException(new ServerErrorException(503)) instanceof PulsarAdminException);
    log.info("Client: ", client);
    admin.close();
}
Also used : PulsarAdmin(org.apache.pulsar.client.admin.PulsarAdmin) BrokerStatsImpl(org.apache.pulsar.client.admin.internal.BrokerStatsImpl) ConflictException(org.apache.pulsar.client.admin.PulsarAdminException.ConflictException) ServerSideErrorException(org.apache.pulsar.client.admin.PulsarAdminException.ServerSideErrorException) ClientErrorException(javax.ws.rs.ClientErrorException) NotFoundException(org.apache.pulsar.client.admin.PulsarAdminException.NotFoundException) PreconditionFailedException(org.apache.pulsar.client.admin.PulsarAdminException.PreconditionFailedException) PulsarAdminException(org.apache.pulsar.client.admin.PulsarAdminException) NotAuthorizedException(org.apache.pulsar.client.admin.PulsarAdminException.NotAuthorizedException) ServerErrorException(javax.ws.rs.ServerErrorException) URL(java.net.URL) Test(org.testng.annotations.Test)

Aggregations

URL (java.net.URL)1 ClientErrorException (javax.ws.rs.ClientErrorException)1 ServerErrorException (javax.ws.rs.ServerErrorException)1 PulsarAdmin (org.apache.pulsar.client.admin.PulsarAdmin)1 PulsarAdminException (org.apache.pulsar.client.admin.PulsarAdminException)1 ConflictException (org.apache.pulsar.client.admin.PulsarAdminException.ConflictException)1 NotAuthorizedException (org.apache.pulsar.client.admin.PulsarAdminException.NotAuthorizedException)1 NotFoundException (org.apache.pulsar.client.admin.PulsarAdminException.NotFoundException)1 PreconditionFailedException (org.apache.pulsar.client.admin.PulsarAdminException.PreconditionFailedException)1 ServerSideErrorException (org.apache.pulsar.client.admin.PulsarAdminException.ServerSideErrorException)1 BrokerStatsImpl (org.apache.pulsar.client.admin.internal.BrokerStatsImpl)1 Test (org.testng.annotations.Test)1