org.springframework.test.context.transaction.AfterTransaction Java Examples
The following examples show how to use
org.springframework.test.context.transaction.AfterTransaction.
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: ProgrammaticTxMgmtTests.java From java-technology-stack with MIT License | 6 votes |
@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); } } }
Example #2
Source File: TransactionalAnnotatedConfigClassesWithoutAtConfigurationTests.java From java-technology-stack with MIT License | 6 votes |
/** * 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"); }
Example #3
Source File: TransactionalAnnotatedConfigClassesWithoutAtConfigurationTests.java From spring-analysis-note with MIT License | 6 votes |
/** * 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"); }
Example #4
Source File: ProgrammaticTxMgmtTests.java From spring-analysis-note with MIT License | 6 votes |
@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); } } }
Example #5
Source File: ProgrammaticTxMgmtTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
@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); } } }
Example #6
Source File: ProgrammaticTxMgmtTestNGTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
@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); } } }
Example #7
Source File: ProgrammaticTxMgmtTestNGTests.java From java-technology-stack with MIT License | 6 votes |
@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); } } }
Example #8
Source File: TransactionalAnnotatedConfigClassesWithoutAtConfigurationTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
/** * 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"); }
Example #9
Source File: ProgrammaticTxMgmtTestNGTests.java From spring-analysis-note with MIT License | 6 votes |
@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); } } }
Example #10
Source File: LookUpTxMgrByTypeAndDefaultNameTests.java From java-technology-stack with MIT License | 5 votes |
@AfterTransaction public void afterTransaction() { assertEquals(1, txManager1.begun); assertEquals(0, txManager1.inflight); assertEquals(0, txManager1.commits); assertEquals(1, txManager1.rollbacks); }
Example #11
Source File: LookUpTxMgrViaTransactionManagementConfigurerTests.java From java-technology-stack with MIT License | 5 votes |
@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); }
Example #12
Source File: TransactionalAfterTestMethodSqlScriptsTests.java From spring-analysis-note with MIT License | 5 votes |
@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 */ } } }
Example #13
Source File: LookUpTxMgrByTypeAndNameTests.java From java-technology-stack with MIT License | 5 votes |
@AfterTransaction public void afterTransaction() { assertEquals(1, txManager1.begun); assertEquals(0, txManager1.inflight); assertEquals(0, txManager1.commits); assertEquals(1, txManager1.rollbacks); }
Example #14
Source File: LookUpTxMgrByTypeAndQualifierAtClassLevelTests.java From java-technology-stack with MIT License | 5 votes |
@AfterTransaction public void afterTransaction() { assertEquals(1, txManager1.begun); assertEquals(0, txManager1.inflight); assertEquals(0, txManager1.commits); assertEquals(1, txManager1.rollbacks); }
Example #15
Source File: BeforeAndAfterTransactionAnnotationTests.java From java-technology-stack with MIT License | 5 votes |
@AfterTransaction 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)); }
Example #16
Source File: LookUpTxMgrByTypeTests.java From java-technology-stack with MIT License | 5 votes |
@AfterTransaction public void afterTransaction() { assertEquals(1, txManager.begun); assertEquals(0, txManager.inflight); assertEquals(0, txManager.commits); assertEquals(1, txManager.rollbacks); }
Example #17
Source File: LookUpTxMgrViaTransactionManagementConfigurerTests.java From spring-analysis-note with MIT License | 5 votes |
@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); }
Example #18
Source File: LookUpTxMgrByTypeAndQualifierAtMethodLevelTests.java From java-technology-stack with MIT License | 5 votes |
@AfterTransaction public void afterTransaction() { assertEquals(1, txManager1.begun); assertEquals(0, txManager1.inflight); assertEquals(0, txManager1.commits); assertEquals(1, txManager1.rollbacks); }
Example #19
Source File: TransactionalAfterTestMethodSqlScriptsTests.java From java-technology-stack with MIT License | 5 votes |
@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 */ } } }
Example #20
Source File: JobManagerTests.java From OpenCue with Apache License 2.0 | 5 votes |
@AfterTransaction public void destroy() { for (String jobName : ImmutableList.of(JOB1, JOB2, JOB3)) { JobInterface job = jobDao.findJob(jobName); jobDao.updateJobFinished(job); jobDao.deleteJob(job); } }
Example #21
Source File: AdminServiceTransactionTest.java From apollo with Apache License 2.0 | 5 votes |
@AfterTransaction public void verifyFinalDatabaseState() { Assert.assertEquals(0, appRepository.count()); Assert.assertEquals(7, appNamespaceRepository.count()); Assert.assertEquals(0, namespaceRepository.count()); Assert.assertEquals(0, clusterRepository.count()); }
Example #22
Source File: BeforeAndAfterTransactionAnnotationTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@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)); }
Example #23
Source File: LookUpTxMgrViaTransactionManagementConfigurerTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@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); }
Example #24
Source File: LookUpTxMgrByTypeAndDefaultNameTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@AfterTransaction public void afterTransaction() { assertEquals(1, txManager1.begun); assertEquals(0, txManager1.inflight); assertEquals(0, txManager1.commits); assertEquals(1, txManager1.rollbacks); }
Example #25
Source File: LookUpTxMgrByTypeAndNameTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@AfterTransaction public void afterTransaction() { assertEquals(1, txManager1.begun); assertEquals(0, txManager1.inflight); assertEquals(0, txManager1.commits); assertEquals(1, txManager1.rollbacks); }
Example #26
Source File: LookUpTxMgrByTypeAndQualifierAtClassLevelTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@AfterTransaction public void afterTransaction() { assertEquals(1, txManager1.begun); assertEquals(0, txManager1.inflight); assertEquals(0, txManager1.commits); assertEquals(1, txManager1.rollbacks); }
Example #27
Source File: LookUpTxMgrByTypeTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@AfterTransaction public void afterTransaction() { assertEquals(1, txManager.begun); assertEquals(0, txManager.inflight); assertEquals(0, txManager.commits); assertEquals(1, txManager.rollbacks); }
Example #28
Source File: LookUpTxMgrByTypeAndQualifierAtMethodLevelTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@AfterTransaction public void afterTransaction() { assertEquals(1, txManager1.begun); assertEquals(0, txManager1.inflight); assertEquals(0, txManager1.commits); assertEquals(1, txManager1.rollbacks); }
Example #29
Source File: TransactionalAfterTestMethodSqlScriptsTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@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 */ } } }
Example #30
Source File: BaseRedisTest.java From spring-boot-email-tools with Apache License 2.0 | 5 votes |
@AfterTransaction public void assertAfterTransaction() { if (nonNull(afterTransactionAssertion)) { final RedisConnection connection = connectionFactory.getConnection(); afterTransactionAssertion.assertAfterTransaction(connection); connection.close(); } }