Java Code Examples for org.jmock.Expectations#will()
The following examples show how to use
org.jmock.Expectations#will() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestPooledConnectionHandlerMock.java From jaybird with GNU Lesser General Public License v2.1 | 6 votes |
private void connectionHandleReleaseExpectations(Expectations expectations, FirebirdConnection physicalConnection) throws SQLException { expectations.allowing(physicalConnection).getAutoCommit(); expectations.will(Expectations.returnValue(true)); expectations.allowing(physicalConnection).isWrapperFor(FirebirdConnection.class); expectations.will(Expectations.returnValue(true)); expectations.allowing(physicalConnection).unwrap(FirebirdConnection.class); expectations.will(Expectations.returnValue(physicalConnection)); expectations.allowing(physicalConnection).isUseFirebirdAutoCommit(); expectations.will(Expectations.returnValue(FBTestProperties.USE_FIREBIRD_AUTOCOMMIT)); if (FBTestProperties.USE_FIREBIRD_AUTOCOMMIT) { expectations.oneOf(physicalConnection).setAutoCommit(false); expectations.oneOf(physicalConnection).setAutoCommit(true); } expectations.allowing(physicalConnection).clearWarnings(); }
Example 2
Source File: TestV10InputBlobMock.java From jaybird with GNU Lesser General Public License v2.1 | 6 votes |
/** * Test if {@link org.firebirdsql.gds.ng.wire.version10.V10InputBlob#getSegment(int)} on closed blob * throws exception */ @Test public void testGetSegment_blobClosed() throws Exception { expectedException.expect(SQLNonTransientException.class); expectedException.expect(allOf( errorCodeEquals(ISCConstants.isc_bad_segstr_handle), fbMessageStartsWith(ISCConstants.isc_bad_segstr_handle) )); V10InputBlob blob = new V10InputBlob(db, transaction, null, 1); final Expectations exp = new Expectations(); exp.oneOf(db).isAttached(); exp.will(returnValue(true)); exp.oneOf(transaction).getState(); exp.will(returnValue(TransactionState.ACTIVE)); context.checking(exp); blob.getSegment(1); }
Example 3
Source File: TestTransactionHelper.java From jaybird with GNU Lesser General Public License v2.1 | 5 votes |
private FbTransaction setupTransaction(TransactionState transactionState) { final FbTransaction transaction = context.mock(FbTransaction.class); final Expectations expectations = new Expectations(); expectations.oneOf(transaction).getState(); expectations.will(returnValue(transactionState)); context.checking(expectations); return transaction; }
Example 4
Source File: TestServiceListenerDispatcher.java From jaybird with GNU Lesser General Public License v2.1 | 5 votes |
/** * 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 testDetaching_withException() { final ServiceListener listener2 = context.mock(ServiceListener.class, "listener2"); dispatcher.addListener(listener2); final Expectations expectations = new Expectations(); for (ServiceListener currentListener : Arrays.asList(listener, listener2)) { expectations.exactly(1).of(currentListener).detaching(service); expectations.will(throwException(new RuntimeException())); } context.checking(expectations); dispatcher.detaching(service); }
Example 5
Source File: TestServiceListenerDispatcher.java From jaybird with GNU Lesser General Public License v2.1 | 5 votes |
/** * 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 testDetached_withException() { final ServiceListener listener2 = context.mock(ServiceListener.class, "listener2"); dispatcher.addListener(listener2); final Expectations expectations = new Expectations(); for (ServiceListener currentListener : Arrays.asList(listener, listener2)) { expectations.exactly(1).of(currentListener).detached(service); expectations.will(throwException(new RuntimeException())); } context.checking(expectations); dispatcher.detached(service); }
Example 6
Source File: TestServiceListenerDispatcher.java From jaybird with GNU Lesser General Public License v2.1 | 5 votes |
/** * 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 ServiceListener listener2 = context.mock(ServiceListener.class, "listener2"); dispatcher.addListener(listener2); final SQLWarning warning = new SQLWarning(); final Expectations expectations = new Expectations(); for (ServiceListener currentListener : Arrays.asList(listener, listener2)) { expectations.exactly(1).of(currentListener).warningReceived(service, warning); expectations.will(throwException(new RuntimeException())); } context.checking(expectations); dispatcher.warningReceived(service, warning); }
Example 7
Source File: TestStatementListenerDispatcher.java From jaybird with GNU Lesser General Public License v2.1 | 5 votes |
/** * 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 testReceivedRow_withException() { final StatementListener listener2 = context.mock(StatementListener.class, "listener2"); dispatcher.addListener(listener2); final Expectations expectations = new Expectations(); for (StatementListener currentListener : Arrays.asList(listener, listener2)) { expectations.exactly(1).of(currentListener).receivedRow(statement, RowValue.EMPTY_ROW_VALUE); expectations.will(throwException(new RuntimeException())); } context.checking(expectations); dispatcher.receivedRow(statement, RowValue.EMPTY_ROW_VALUE); }
Example 8
Source File: TestStatementListenerDispatcher.java From jaybird with GNU Lesser General Public License v2.1 | 5 votes |
/** * 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 testAllRowsFetched_withException() { final StatementListener listener2 = context.mock(StatementListener.class, "listener2"); dispatcher.addListener(listener2); final Expectations expectations = new Expectations(); for (StatementListener currentListener : Arrays.asList(listener, listener2)) { expectations.exactly(1).of(currentListener).allRowsFetched(statement); expectations.will(throwException(new RuntimeException())); } context.checking(expectations); dispatcher.allRowsFetched(statement); }
Example 9
Source File: TestStatementListenerDispatcher.java From jaybird with GNU Lesser General Public License v2.1 | 5 votes |
/** * 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 testStatementExecuted_withException() { final StatementListener listener2 = context.mock(StatementListener.class, "listener2"); dispatcher.addListener(listener2); final Expectations expectations = new Expectations(); for (StatementListener currentListener : Arrays.asList(listener, listener2)) { expectations.exactly(1).of(currentListener).statementExecuted(statement, true, false); expectations.will(throwException(new RuntimeException())); } context.checking(expectations); dispatcher.statementExecuted(statement, true, false); }
Example 10
Source File: TestStatementListenerDispatcher.java From jaybird with GNU Lesser General Public License v2.1 | 5 votes |
/** * 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 testStatementStateChanged_withException() { final StatementListener listener2 = context.mock(StatementListener.class, "listener2"); dispatcher.addListener(listener2); final Expectations expectations = new Expectations(); for (StatementListener currentListener : Arrays.asList(listener, listener2)) { expectations.exactly(1).of(currentListener).statementStateChanged(statement, StatementState.CLOSED, StatementState.CLOSING); expectations.will(throwException(new RuntimeException())); } context.checking(expectations); dispatcher.statementStateChanged(statement, StatementState.CLOSED, StatementState.CLOSING); }
Example 11
Source File: TestStatementListenerDispatcher.java From jaybird with GNU Lesser General Public License v2.1 | 5 votes |
/** * 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); }
Example 12
Source File: TestStatementListenerDispatcher.java From jaybird with GNU Lesser General Public License v2.1 | 5 votes |
/** * 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 testSqlCounts_withException() { final StatementListener listener2 = context.mock(StatementListener.class, "listener2"); dispatcher.addListener(listener2); final SqlCountHolder count = new SqlCountHolder(1, 2 ,3, 4); final Expectations expectations = new Expectations(); for (StatementListener currentListener : Arrays.asList(listener, listener2)) { expectations.exactly(1).of(currentListener).sqlCounts(statement, count); expectations.will(throwException(new RuntimeException())); } context.checking(expectations); dispatcher.sqlCounts(statement, count); }
Example 13
Source File: TestDatabaseListenerDispatcher.java From jaybird with GNU Lesser General Public License v2.1 | 5 votes |
/** * 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 testDetaching_withException() { final DatabaseListener listener2 = context.mock(DatabaseListener.class, "listener2"); dispatcher.addListener(listener2); final Expectations expectations = new Expectations(); for (DatabaseListener currentListener : Arrays.asList(listener, listener2)) { expectations.exactly(1).of(currentListener).detaching(database); expectations.will(throwException(new RuntimeException())); } context.checking(expectations); dispatcher.detaching(database); }
Example 14
Source File: TestDatabaseListenerDispatcher.java From jaybird with GNU Lesser General Public License v2.1 | 5 votes |
/** * 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 testDetached_withException() { final DatabaseListener listener2 = context.mock(DatabaseListener.class, "listener2"); dispatcher.addListener(listener2); final Expectations expectations = new Expectations(); for (DatabaseListener currentListener : Arrays.asList(listener, listener2)) { expectations.exactly(1).of(currentListener).detached(database); expectations.will(throwException(new RuntimeException())); } context.checking(expectations); dispatcher.detached(database); }
Example 15
Source File: TestDatabaseListenerDispatcher.java From jaybird with GNU Lesser General Public License v2.1 | 5 votes |
/** * 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 DatabaseListener listener2 = context.mock(DatabaseListener.class, "listener2"); dispatcher.addListener(listener2); final SQLWarning warning = new SQLWarning(); final Expectations expectations = new Expectations(); for (DatabaseListener currentListener : Arrays.asList(listener, listener2)) { expectations.exactly(1).of(currentListener).warningReceived(database, warning); expectations.will(throwException(new RuntimeException())); } context.checking(expectations); dispatcher.warningReceived(database, warning); }
Example 16
Source File: TestTransactionListenerDispatcher.java From jaybird with GNU Lesser General Public License v2.1 | 5 votes |
/** * 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 testTransactionStateChanged_withException() { final TransactionListener listener2 = context.mock(TransactionListener.class, "listener2"); dispatcher.addListener(listener2); final Expectations expectations = new Expectations(); for (TransactionListener currentListener : Arrays.asList(listener, listener2)) { expectations.exactly(1).of(currentListener).transactionStateChanged(transaction, TransactionState.ROLLING_BACK, TransactionState.COMMITTED); expectations.will(throwException(new RuntimeException())); } context.checking(expectations); dispatcher.transactionStateChanged(transaction, TransactionState.ROLLING_BACK, TransactionState.COMMITTED); }