use of org.firebirdsql.gds.ng.wire.AbstractFbWireDatabase in project jaybird by FirebirdSQL.
the class TestV10Database method testWarningOnCallback_warningOnListener.
/**
* Test if a warning is registered with the callback if the response
* contains an exception that is a warning.
*/
@Test
public void testWarningOnCallback_warningOnListener() throws Exception {
AbstractFbWireDatabase db = createDummyDatabase();
SimpleDatabaseListener callback = new SimpleDatabaseListener();
db.addDatabaseListener(callback);
SQLWarning warning = new FbExceptionBuilder().warning(ISCConstants.isc_numeric_out_of_range).toSQLException(SQLWarning.class);
db.getDatabaseWarningCallback().processWarning(warning);
List<SQLWarning> warnings = callback.getWarnings();
assertEquals("Unexpected warnings registered or no warnings registered", Collections.singletonList(warning), warnings);
}
use of org.firebirdsql.gds.ng.wire.AbstractFbWireDatabase in project jaybird by FirebirdSQL.
the class TestV10Database method testProcessResponseWarnings_warning_noCallback.
/**
* Test if processing the response warning works even if no warning callback is registered.
*/
@Test
public void testProcessResponseWarnings_warning_noCallback() throws Exception {
AbstractFbWireDatabase db = createDummyDatabase();
SQLWarning warning = new FbExceptionBuilder().warning(ISCConstants.isc_numeric_out_of_range).toSQLException(SQLWarning.class);
db.getDatabaseWarningCallback().processWarning(warning);
}
use of org.firebirdsql.gds.ng.wire.AbstractFbWireDatabase in project jaybird by FirebirdSQL.
the class TestV10Database method testDetach_NotConnected.
@Test
public void testDetach_NotConnected() throws Exception {
AbstractFbWireDatabase db = createDummyDatabase();
expectedException.expect(SQLException.class);
expectedException.expectMessage(startsWith("No connection established to the database server"));
expectedException.expect(sqlStateEquals(SQLStateConstants.SQL_STATE_CONNECTION_CLOSED));
db.close();
}
Aggregations