Search in sources :

Example 6 with ClientErrorException

use of javax.ws.rs.ClientErrorException 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

ClientErrorException (javax.ws.rs.ClientErrorException)6 Timed (com.codahale.metrics.annotation.Timed)2 PulsarAdminException (com.yahoo.pulsar.client.admin.PulsarAdminException)2 ApiOperation (io.swagger.annotations.ApiOperation)2 ApiResponses (io.swagger.annotations.ApiResponses)2 URL (java.net.URL)2 NotFoundException (javax.ws.rs.NotFoundException)2 PUT (javax.ws.rs.PUT)2 Path (javax.ws.rs.Path)2 ServerErrorException (javax.ws.rs.ServerErrorException)2 AuditEvent (org.graylog2.audit.jersey.AuditEvent)2 DefaultIndexSetConfig (org.graylog2.indexer.indexset.DefaultIndexSetConfig)2 IndexSetConfig (org.graylog2.indexer.indexset.IndexSetConfig)2 Test (org.testng.annotations.Test)2 MockedPulsarServiceBaseTest (com.yahoo.pulsar.broker.auth.MockedPulsarServiceBaseTest)1 NamespaceEphemeralData (com.yahoo.pulsar.broker.namespace.NamespaceEphemeralData)1 RestException (com.yahoo.pulsar.broker.web.RestException)1 PulsarAdmin (com.yahoo.pulsar.client.admin.PulsarAdmin)1 ConflictException (com.yahoo.pulsar.client.admin.PulsarAdminException.ConflictException)1 NotAuthorizedException (com.yahoo.pulsar.client.admin.PulsarAdminException.NotAuthorizedException)1