Search in sources :

Example 1 with ServerSideErrorException

use of com.yahoo.pulsar.client.admin.PulsarAdminException.ServerSideErrorException in project pulsar by yahoo.

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(com.yahoo.pulsar.client.admin.PulsarAdmin) BrokerStatsImpl(com.yahoo.pulsar.client.admin.internal.BrokerStatsImpl) ConflictException(com.yahoo.pulsar.client.admin.PulsarAdminException.ConflictException) ServerSideErrorException(com.yahoo.pulsar.client.admin.PulsarAdminException.ServerSideErrorException) ClientErrorException(javax.ws.rs.ClientErrorException) NotFoundException(com.yahoo.pulsar.client.admin.PulsarAdminException.NotFoundException) PreconditionFailedException(com.yahoo.pulsar.client.admin.PulsarAdminException.PreconditionFailedException) PulsarAdminException(com.yahoo.pulsar.client.admin.PulsarAdminException) NotAuthorizedException(com.yahoo.pulsar.client.admin.PulsarAdminException.NotAuthorizedException) ServerErrorException(javax.ws.rs.ServerErrorException) URL(java.net.URL) Test(org.testng.annotations.Test)

Aggregations

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