use of java.sql.SQLWarning 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 java.sql.SQLWarning 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 java.sql.SQLWarning in project jaybird by FirebirdSQL.
the class TestServiceListenerDispatcher method testWarningReceived.
/**
* Tests if calls to {@link ServiceListenerDispatcher#warningReceived(FbService, SQLWarning)}
* forwarded correctly.
*/
@Test
public void testWarningReceived() {
final Expectations expectations = new Expectations();
final SQLWarning warning = new SQLWarning();
expectations.exactly(1).of(listener).warningReceived(service, warning);
context.checking(expectations);
dispatcher.warningReceived(service, warning);
}
use of java.sql.SQLWarning in project jaybird by FirebirdSQL.
the class TestStatementListenerDispatcher method testWarningReceived_withException.
/**
* Tests if listeners throwing exceptions will still cause other listeners to be notified and not result in
* exceptions thrown to call of the dispatcher.
*/
@Test
public void testWarningReceived_withException() {
final StatementListener listener2 = context.mock(StatementListener.class, "listener2");
dispatcher.addListener(listener2);
final SQLWarning warning = new SQLWarning();
final Expectations expectations = new Expectations();
for (StatementListener currentListener : Arrays.asList(listener, listener2)) {
expectations.exactly(1).of(currentListener).warningReceived(statement, warning);
expectations.will(throwException(new RuntimeException()));
}
context.checking(expectations);
dispatcher.warningReceived(statement, warning);
}
use of java.sql.SQLWarning in project jaybird by FirebirdSQL.
the class TestStatementListenerDispatcher method testWarningReceived.
/**
* Test if call to {@link org.firebirdsql.gds.ng.listeners.StatementListenerDispatcher#warningReceived(org.firebirdsql.gds.ng.FbStatement, java.sql.SQLWarning)}
* is forwarded correctly.
*/
@Test
public void testWarningReceived() {
final Expectations expectations = new Expectations();
final SQLWarning warning = new SQLWarning();
expectations.exactly(1).of(listener).warningReceived(statement, warning);
context.checking(expectations);
dispatcher.warningReceived(statement, warning);
}
Aggregations