Search in sources :

Example 1 with AbstractFbWireDatabase

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);
}
Also used : SQLWarning(java.sql.SQLWarning) AbstractFbWireDatabase(org.firebirdsql.gds.ng.wire.AbstractFbWireDatabase) Test(org.junit.Test)

Example 2 with AbstractFbWireDatabase

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);
}
Also used : SQLWarning(java.sql.SQLWarning) AbstractFbWireDatabase(org.firebirdsql.gds.ng.wire.AbstractFbWireDatabase) Test(org.junit.Test)

Example 3 with AbstractFbWireDatabase

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();
}
Also used : AbstractFbWireDatabase(org.firebirdsql.gds.ng.wire.AbstractFbWireDatabase) Test(org.junit.Test)

Aggregations

AbstractFbWireDatabase (org.firebirdsql.gds.ng.wire.AbstractFbWireDatabase)3 Test (org.junit.Test)3 SQLWarning (java.sql.SQLWarning)2