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());
}
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());
}
Aggregations