Search in sources :

Example 1 with InvalidStreamNameException

use of org.apache.bookkeeper.clients.exceptions.InvalidStreamNameException in project bookkeeper by apache.

the class TestProtocolInternalUtils method testCreateRootRangeException.

// 
// Test Exceptions related utils
// 
@Test
public void testCreateRootRangeException() {
    String name = "test-create-root-range-exception";
    // stream exists exception
    Throwable cause1 = createRootRangeException(name, StatusCode.STREAM_EXISTS);
    assertTrue(cause1 instanceof StreamExistsException);
    StreamExistsException see = (StreamExistsException) cause1;
    // stream not found
    Throwable cause2 = createRootRangeException(name, StatusCode.STREAM_NOT_FOUND);
    assertTrue(cause2 instanceof StreamNotFoundException);
    StreamNotFoundException snfe = (StreamNotFoundException) cause2;
    // invalid stream name
    Throwable invalidStreamNameCause = createRootRangeException(name, StatusCode.INVALID_STREAM_NAME);
    assertTrue(invalidStreamNameCause instanceof InvalidStreamNameException);
    InvalidStreamNameException isne = (InvalidStreamNameException) invalidStreamNameCause;
    // failure
    Throwable cause3 = createRootRangeException(name, StatusCode.FAILURE);
    ClientException se = (ClientException) cause3;
    assertEquals("fail to access its root range : code = " + StatusCode.FAILURE, se.getMessage());
    // namespace exists exception
    Throwable cause5 = createRootRangeException(name, StatusCode.NAMESPACE_EXISTS);
    assertTrue(cause5 instanceof NamespaceExistsException);
    // namespace not-found exception
    Throwable cause6 = createRootRangeException(name, StatusCode.NAMESPACE_NOT_FOUND);
    assertTrue(cause6 instanceof NamespaceNotFoundException);
    // invalid namespace name
    Throwable cause7 = createRootRangeException(name, StatusCode.INVALID_NAMESPACE_NAME);
    assertTrue(cause7 instanceof InvalidNamespaceNameException);
}
Also used : InvalidStreamNameException(org.apache.bookkeeper.clients.exceptions.InvalidStreamNameException) InvalidNamespaceNameException(org.apache.bookkeeper.clients.exceptions.InvalidNamespaceNameException) StreamNotFoundException(org.apache.bookkeeper.clients.exceptions.StreamNotFoundException) StreamExistsException(org.apache.bookkeeper.clients.exceptions.StreamExistsException) ClientException(org.apache.bookkeeper.clients.exceptions.ClientException) NamespaceExistsException(org.apache.bookkeeper.clients.exceptions.NamespaceExistsException) NamespaceNotFoundException(org.apache.bookkeeper.clients.exceptions.NamespaceNotFoundException) Test(org.junit.Test)

Aggregations

ClientException (org.apache.bookkeeper.clients.exceptions.ClientException)1 InvalidNamespaceNameException (org.apache.bookkeeper.clients.exceptions.InvalidNamespaceNameException)1 InvalidStreamNameException (org.apache.bookkeeper.clients.exceptions.InvalidStreamNameException)1 NamespaceExistsException (org.apache.bookkeeper.clients.exceptions.NamespaceExistsException)1 NamespaceNotFoundException (org.apache.bookkeeper.clients.exceptions.NamespaceNotFoundException)1 StreamExistsException (org.apache.bookkeeper.clients.exceptions.StreamExistsException)1 StreamNotFoundException (org.apache.bookkeeper.clients.exceptions.StreamNotFoundException)1 Test (org.junit.Test)1