Search in sources :

Example 1 with DrillPBError

use of org.apache.drill.exec.proto.UserBitShared.DrillPBError in project drill by axbaretto.

the class TestUserException method testBuildUserExceptionWithCause.

@Test
public void testBuildUserExceptionWithCause() {
    String message = "Test message";
    UserException uex = UserException.dataWriteError(new RuntimeException(message)).build(logger);
    DrillPBError error = uex.getOrCreatePBError(false);
    // cause message should be used
    Assert.assertEquals(ErrorType.DATA_WRITE, error.getErrorType());
    Assert.assertEquals(message, uex.getOriginalMessage());
}
Also used : DrillPBError(org.apache.drill.exec.proto.UserBitShared.DrillPBError) Test(org.junit.Test)

Example 2 with DrillPBError

use of org.apache.drill.exec.proto.UserBitShared.DrillPBError in project drill by axbaretto.

the class TestUserException method testBuildUserExceptionWithFormattedMessage.

@Test
public void testBuildUserExceptionWithFormattedMessage() {
    String format = "This is test #%d";
    UserException uex = UserException.connectionError().message(format, 5).build(logger);
    DrillPBError error = uex.getOrCreatePBError(false);
    Assert.assertEquals(ErrorType.CONNECTION, error.getErrorType());
    Assert.assertEquals(String.format(format, 5), uex.getOriginalMessage());
}
Also used : DrillPBError(org.apache.drill.exec.proto.UserBitShared.DrillPBError) Test(org.junit.Test)

Example 3 with DrillPBError

use of org.apache.drill.exec.proto.UserBitShared.DrillPBError in project drill by axbaretto.

the class TestUserException method testBuildUserExceptionWithCauseAndMessage.

@Test
public void testBuildUserExceptionWithCauseAndMessage() {
    String messageA = "Test message A";
    String messageB = "Test message B";
    UserException uex = UserException.dataWriteError(new RuntimeException(messageA)).message(messageB).build(logger);
    DrillPBError error = uex.getOrCreatePBError(false);
    // passed message should override the cause message
    Assert.assertEquals(ErrorType.DATA_WRITE, error.getErrorType());
    // messageA should not be part of the context
    Assert.assertFalse(error.getMessage().contains(messageA));
    Assert.assertEquals(messageB, uex.getOriginalMessage());
}
Also used : DrillPBError(org.apache.drill.exec.proto.UserBitShared.DrillPBError) Test(org.junit.Test)

Example 4 with DrillPBError

use of org.apache.drill.exec.proto.UserBitShared.DrillPBError in project drill by axbaretto.

the class TestUserException method testBuildUserExceptionWithMessage.

@Test
public void testBuildUserExceptionWithMessage() {
    String message = "Test message";
    UserException uex = UserException.dataWriteError().message(message).build(logger);
    DrillPBError error = uex.getOrCreatePBError(false);
    Assert.assertEquals(ErrorType.DATA_WRITE, error.getErrorType());
    Assert.assertEquals(message, uex.getOriginalMessage());
}
Also used : DrillPBError(org.apache.drill.exec.proto.UserBitShared.DrillPBError) Test(org.junit.Test)

Example 5 with DrillPBError

use of org.apache.drill.exec.proto.UserBitShared.DrillPBError in project drill by axbaretto.

the class TestUserException method testBuildUserExceptionWithUserExceptionCauseAndMessage.

@Test
public void testBuildUserExceptionWithUserExceptionCauseAndMessage() {
    String messageA = "Test message A";
    String messageB = "Test message B";
    UserException original = UserException.connectionError().message(messageA).build(logger);
    UserException uex = UserException.dataWriteError(wrap(original, 5)).message(messageB).build(logger);
    // builder should return the unwrapped original user exception and not build a new one
    Assert.assertEquals(original, uex);
    DrillPBError error = uex.getOrCreatePBError(false);
    Assert.assertEquals(messageA, uex.getOriginalMessage());
    // messageB should not be part of the context
    Assert.assertFalse(error.getMessage().contains(messageB));
}
Also used : DrillPBError(org.apache.drill.exec.proto.UserBitShared.DrillPBError) Test(org.junit.Test)

Aggregations

DrillPBError (org.apache.drill.exec.proto.UserBitShared.DrillPBError)23 Test (org.junit.Test)12 ArrayList (java.util.ArrayList)6 List (java.util.List)6 LikeFilter (org.apache.drill.exec.proto.UserProtos.LikeFilter)6 RequestStatus (org.apache.drill.exec.proto.UserProtos.RequestStatus)6 BaseTest (org.apache.drill.test.BaseTest)6 MetaImpl (org.apache.calcite.avatica.MetaImpl)4 SQLException (java.sql.SQLException)2 ExecutionException (java.util.concurrent.ExecutionException)2 QueryContext (org.apache.drill.exec.ops.QueryContext)2 ColumnMetadata (org.apache.drill.exec.proto.UserProtos.ColumnMetadata)2 GetColumnsResp (org.apache.drill.exec.proto.UserProtos.GetColumnsResp)2 GetQueryPlanFragments (org.apache.drill.exec.proto.UserProtos.GetQueryPlanFragments)2 GetSchemasResp (org.apache.drill.exec.proto.UserProtos.GetSchemasResp)2 GetServerMetaResp (org.apache.drill.exec.proto.UserProtos.GetServerMetaResp)2 GetTablesResp (org.apache.drill.exec.proto.UserProtos.GetTablesResp)2 QueryPlanFragments (org.apache.drill.exec.proto.UserProtos.QueryPlanFragments)2 SchemaMetadata (org.apache.drill.exec.proto.UserProtos.SchemaMetadata)2 TableMetadata (org.apache.drill.exec.proto.UserProtos.TableMetadata)2