Search in sources :

Example 1 with AvaticaClientRuntimeException

use of org.apache.calcite.avatica.AvaticaClientRuntimeException in project calcite-avatica by apache.

the class AvaticaClientRuntimeExceptionTest method testGetters.

@Test
public void testGetters() {
    final String errorMsg = "My error message";
    final int errorCode = 10;
    final String sqlState = "abc12";
    final AvaticaSeverity severity = AvaticaSeverity.ERROR;
    final List<String> stacktraces = Arrays.asList("my stack trace");
    final RpcMetadataResponse metadata = new RpcMetadataResponse("localhost:8765");
    AvaticaClientRuntimeException e = new AvaticaClientRuntimeException(errorMsg, errorCode, sqlState, severity, stacktraces, metadata);
    assertEquals(errorMsg, e.getMessage());
    assertEquals(errorCode, e.getErrorCode());
    assertEquals(severity, e.getSeverity());
    assertEquals(stacktraces, e.getServerExceptions());
    assertEquals(metadata, e.getRpcMetadata());
}
Also used : AvaticaSeverity(org.apache.calcite.avatica.AvaticaSeverity) AvaticaClientRuntimeException(org.apache.calcite.avatica.AvaticaClientRuntimeException) RpcMetadataResponse(org.apache.calcite.avatica.remote.Service.RpcMetadataResponse) Test(org.junit.Test)

Example 2 with AvaticaClientRuntimeException

use of org.apache.calcite.avatica.AvaticaClientRuntimeException in project calcite-avatica by apache.

the class ErrorResponseTest method testToClientRTE.

@Test
public void testToClientRTE() {
    final String message = "There was an error";
    final int code = 23;
    final String state = "a1b2c";
    final AvaticaSeverity severity = AvaticaSeverity.ERROR;
    final List<String> exceptions = Arrays.asList("Server Stacktrace 1", "Server Stacktace 2");
    final RpcMetadataResponse metadata = new RpcMetadataResponse("localhost:8765");
    final ErrorResponse resp = new ErrorResponse(message, code, state, severity, exceptions, metadata);
    AvaticaClientRuntimeException exception = resp.toException();
    assertTrue("Expected error message to end with '" + resp.errorMessage + "', but was '" + exception.getMessage() + "'", exception.getMessage().endsWith(resp.errorMessage));
    assertEquals(resp.errorCode, exception.getErrorCode());
    assertEquals(resp.severity, exception.getSeverity());
    assertEquals(resp.sqlState, exception.getSqlState());
    assertEquals(resp.exceptions, exception.getServerExceptions());
    assertEquals(resp.rpcMetadata, exception.getRpcMetadata());
}
Also used : AvaticaSeverity(org.apache.calcite.avatica.AvaticaSeverity) AvaticaClientRuntimeException(org.apache.calcite.avatica.AvaticaClientRuntimeException) RpcMetadataResponse(org.apache.calcite.avatica.remote.Service.RpcMetadataResponse) ErrorResponse(org.apache.calcite.avatica.remote.Service.ErrorResponse) Test(org.junit.Test)

Aggregations

AvaticaClientRuntimeException (org.apache.calcite.avatica.AvaticaClientRuntimeException)2 AvaticaSeverity (org.apache.calcite.avatica.AvaticaSeverity)2 RpcMetadataResponse (org.apache.calcite.avatica.remote.Service.RpcMetadataResponse)2 Test (org.junit.Test)2 ErrorResponse (org.apache.calcite.avatica.remote.Service.ErrorResponse)1