@AfterTransaction public void afterTransaction() { String method = testName.getMethodName(); switch (method) { case "commitTxAndStartNewTx": case "commitTxButDoNotStartNewTx": { assertUsers("Dogbert"); break; } case "rollbackTxAndStartNewTx": case "rollbackTxButDoNotStartNewTx": case "startTxWithExistingTransaction": { assertUsers("Dilbert"); break; } case "rollbackTxAndStartNewTxWithDefaultCommitSemantics": { assertUsers("Dilbert", "Dogbert"); break; } default: { fail("missing 'after transaction' assertion for test method: " + method); } } }
@AfterTransaction public void afterTransaction() { switch (method) { case "commitTxAndStartNewTx": case "commitTxButDoNotStartNewTx": { assertUsers("Dogbert"); break; } case "rollbackTxAndStartNewTx": case "rollbackTxButDoNotStartNewTx": case "startTxWithExistingTransaction": { assertUsers("Dilbert"); break; } case "rollbackTxAndStartNewTxWithDefaultCommitSemantics": { assertUsers("Dilbert", "Dogbert"); break; } default: { fail("missing 'after transaction' assertion for test method: " + method); } } }
/** * Overrides {@code afterTransaction()} in order to assert a different result. * * <p>See in-line comments for details. * * @see AbstractTransactionalAnnotatedConfigClassTests#afterTransaction() * @see AbstractTransactionalAnnotatedConfigClassTests#modifyTestDataWithinTransaction() */ @AfterTransaction @Override public void afterTransaction() { assertEquals("Deleting yoda", 1, deletePerson(YODA)); // NOTE: We would actually expect that there are now ZERO entries in the // person table, since the transaction is rolled back by the framework; // however, since our JdbcTemplate and the transaction manager used by // the Spring TestContext Framework use two different DataSource // instances, our insert statements were executed in transactions that // are not controlled by the test framework. Consequently, there was no // rollback for the two insert statements in // modifyTestDataWithinTransaction(). // assertNumRowsInPersonTable(2, "after a transactional test method"); }
@AfterTransaction public void verifyFinalDatabaseState() { Assert.assertEquals(0, appRepository.count()); Assert.assertEquals(7, appNamespaceRepository.count()); Assert.assertEquals(0, namespaceRepository.count()); Assert.assertEquals(0, clusterRepository.count()); }
@AfterTransaction public void afterTransaction() { assertInTransaction(false); this.inTransaction = false; BeforeAndAfterTransactionAnnotationTests.numAfterTransactionCalls++; assertEquals("Deleting yoda", 1, deletePerson(jdbcTemplate, YODA)); assertEquals("Verifying the number of rows in the person table after a transactional test method.", 0, countRowsInPersonTable(jdbcTemplate)); }
@AfterTransaction public void afterTransaction() { assertEquals(1, txManager1.begun); assertEquals(0, txManager1.inflight); assertEquals(0, txManager1.commits); assertEquals(1, txManager1.rollbacks); assertEquals(0, txManager2.begun); assertEquals(0, txManager2.inflight); assertEquals(0, txManager2.commits); assertEquals(0, txManager2.rollbacks); }
@AfterTransaction public void afterTransaction() { assertEquals(1, txManager1.begun); assertEquals(0, txManager1.inflight); assertEquals(0, txManager1.commits); assertEquals(1, txManager1.rollbacks); }
@AfterTransaction public void afterTransaction() { assertEquals(1, txManager.begun); assertEquals(0, txManager.inflight); assertEquals(0, txManager.commits); assertEquals(1, txManager.rollbacks); }
@AfterTransaction public void afterTransaction() { if ("test01".equals(testName.getMethodName())) { try { assertNumUsers(99); fail("Should throw a BadSqlGrammarException after test01, assuming 'drop-schema.sql' was executed"); } catch (BadSqlGrammarException e) { /* expected */ } } }
@AfterTransaction public void assertAfterTransaction() { if (nonNull(afterTransactionAssertion)) { final RedisConnection connection = connectionFactory.getConnection(); afterTransactionAssertion.assertAfterTransaction(connection); connection.close(); } }
/** * Override onteadDownAfterTransaction. * @throws Exception - if something is wrong this exception is thrown. */ @AfterTransaction public void onTearDownAfterTransaction() throws Exception { // Get a reference to the Session and bind it to the TransactionManager SessionHolder holder = (SessionHolder) TransactionSynchronizationManager.getResource(sessionFactory); Session s = holder.getSession(); TransactionSynchronizationManager.unbindResource(sessionFactory); // s.clear(); // clearSession(); SessionFactoryUtils.closeSession(s); }
@AfterTransaction public void afterTransaction() { assertInTransaction(false); this.inTransaction = false; BeforeAndAfterTransactionAnnotationTests.numAfterTransactionCalls++; assertEquals("Deleting yoda", 1, deletePerson(simpleJdbcTemplate, YODA)); assertEquals("Verifying the number of rows in the person table after a transactional test method.", 0, countRowsInPersonTable(simpleJdbcTemplate)); }
@AfterTransaction public void checkPostConditions() { int count = getJdbcWarehousePoland().queryForInt( "SELECT COUNT(*) FROM DEPOT"); // This change was rolled back by the test framework assertEquals(0, count); count = getJdbcWarehouseFinland().queryForInt( "SELECT COUNT(*) FROM DEPOT"); // This rolled back as well because of the XA assertEquals(0, count); }
@AfterTransaction public void afterTransaction() { lecturerRepository.delete(lecturer); }
@AfterTransaction public void afterTransaction() { studentRepository.delete(student); studentRepository.delete(adminaccount); }
@AfterTransaction public void afterTransaction() { assertEquals(deletePerson(YODA), 1, "Deleting yoda"); assertNumRowsInPersonTable(1, "after a transactional test method"); }
@AfterTransaction public void afterTransaction() { fail("always failing afterTransaction()"); }
@AfterTransaction public void afterTransaction() { org.testng.Assert.fail("always failing afterTransaction()"); }
@AfterTransaction public void afterTransaction() { assertEquals("Deleting yoda", 1, deletePerson(YODA)); assertNumRowsInPersonTable(0, "after a transactional test method"); }
@AfterTransaction public void afterTransaction() { assertEquals("Deleting yoda", 1, deletePerson(YODA)); assertEquals("Verifying the number of rows in the person table after a transactional test method.", 1, countRowsInPersonTable()); }
@BeforeTransaction @AfterTransaction public void verifyPreAndPostTransactionDatabaseState() { assertNumUsers(0); }
@AfterTransaction public void afterTransaction() { assertNumUsers(1); }