From a517a5cc22edc911fa2bd4d2e7d8f432b904b8c5 Mon Sep 17 00:00:00 2001 From: Paul Podgorsek Date: Tue, 5 Feb 2019 08:47:25 +0000 Subject: [PATCH 1/2] Issue #6 - Add support for JUnit 5 --- eclipse/eclipse-code-formatter.xml | 2 +- eclipse/org.eclipse.jdt.core.prefs | 6 +- eclipse/org.eclipse.jdt.ui.prefs | 35 ++++--- pom.xml | 24 +++-- ...bUnitTestExecutionListenerPrepareTest.java | 58 ++++++------ .../TestExecutionListenerChainTest.java | 91 +++++++++++-------- ...actionDbUnitTestExecutionListenerTest.java | 4 +- .../bean/DatabaseConfigBeanTest.java | 36 ++++---- ...seDataSourceConnectionFactoryBeanTest.java | 71 ++++++++------- .../config/CoreTestConfiguration.java | 14 +-- .../dataset/FlatXmlDataSetLoaderTest.java | 19 ++-- .../dataset/ReplacementDataSetLoaderTest.java | 15 +-- .../dataset/XmlDataSetLoaderTest.java | 17 ++-- .../springtestdbunit/entity/EntityAssert.java | 14 +-- .../entity/HibernateImportTest.java | 11 +-- .../entity/OtherEntityAssert.java | 14 +-- .../entity/OtherSampleEntity.java | 8 +- .../springtestdbunit/entity/SampleEntity.java | 9 +- .../expected/ExpectedFailureOnClassTest.java | 9 +- .../expected/ExpectedFailureOnMethodTest.java | 11 +-- ...lureOnMethodWithRepeatableReverseTest.java | 11 +-- ...ctedFailureOnMethodWithRepeatableTest.java | 11 +-- .../ExpectedNonStrictOnClassTest.java | 11 +-- .../ExpectedNonStrictOnMethodTest.java | 11 +-- ...ExpectedNonStrictUnorderedOnClassTest.java | 11 +-- ...xpectedNonStrictUnorderedOnMethodTest.java | 11 +-- .../ExpectedNonStrictWithDtdTest.java | 11 +-- .../ExpectedOnClassAndMethodTest.java | 11 +-- ...edOnClassAndMethodWithoutOverrideTest.java | 11 +-- .../ExpectedQueryFailureOnMethodTest.java | 9 +- ...ctedQueryNonStrictFailureOnMethodTest.java | 9 +- .../ExpectedQueryNonStrictOnMethodTest.java | 9 +- .../expected/ExpectedQueryOnMethodTest.java | 9 +- ...ExpectedQueryWithModifierOnMethodTest.java | 9 +- .../ExpectedTableNonStrictOnClassTest.java | 11 +-- .../multiconnection/MultiConnectionTest.java | 19 ++-- .../DefaultDatabaseOperationLookupTest.java | 4 +- ...crosoftSqlDatabaseOperationLookupTest.java | 4 +- .../setup/CleanInsertSetupOnClassTest.java | 11 +-- .../setup/CleanInsertSetupOnMethodTest.java | 15 ++- .../setup/DeleteAllSetupOnClassTest.java | 12 +-- .../setup/DeleteAllSetupOnMethodTest.java | 13 +-- .../setup/DeleteSetupOnClassTest.java | 11 +-- .../setup/DeleteSetupOnMethodTest.java | 11 +-- .../setup/InsertSetupOnClassTest.java | 11 +-- .../setup/InsertSetupOnMethodTest.java | 11 +-- .../setup/MixedSetupOnClassAndMethodTest.java | 13 +-- .../setup/MultipleInsertSetupOnClassTest.java | 11 +-- .../setup/RefereshSetupOnClassTest.java | 11 +-- .../setup/RefereshSetupOnMethodTest.java | 11 +-- .../setup/TruncateSetupOnClassTest.java | 11 +-- .../setup/TruncateSetupOnMethodTest.java | 13 +-- .../setup/UpdateSetupOnClassTest.java | 11 +-- .../setup/UpdateSetupOnMethodTest.java | 11 +-- .../teardown/CleanInsertTearDownOnClass.java | 13 +-- .../teardown/CleanInsertTearDownOnMethod.java | 13 +-- .../teardown/DeleteAllTearDownOnClass.java | 13 +-- .../teardown/DeleteAllTearDownOnMethod.java | 13 +-- .../teardown/DeleteTearDownOnClass.java | 13 +-- .../teardown/DeleteTearDownOnMethod.java | 13 +-- .../teardown/InsertTearDownOnClass.java | 13 +-- .../teardown/InsertTearDownOnMethod.java | 13 +-- .../MixedTearDownOnClassAndMethodTest.java | 13 +-- .../MultipleInsertTearDownOnClassTest.java | 13 +-- .../teardown/RefreshTearDownOnClass.java | 13 +-- .../teardown/RefreshTearDownOnMethod.java | 13 +-- .../teardown/TruncateTearDownOnClass.java | 13 +-- .../teardown/TruncateTearDownOnMethod.java | 13 +-- .../teardown/UpdateTearDownOnClass.java | 13 +-- .../teardown/UpdateTearDownOnMethod.java | 13 +-- .../testutils/ExtendedTestContextManager.java | 4 +- .../MustFailDbUnitTestExecutionListener.java | 5 +- .../sample/service/PersonServiceTest.java | 15 ++- spring-test-dbunit-test/pom.xml | 16 +++- 74 files changed, 489 insertions(+), 596 deletions(-) diff --git a/eclipse/eclipse-code-formatter.xml b/eclipse/eclipse-code-formatter.xml index 05ba9eef..a419388e 100644 --- a/eclipse/eclipse-code-formatter.xml +++ b/eclipse/eclipse-code-formatter.xml @@ -48,7 +48,7 @@ - + diff --git a/eclipse/org.eclipse.jdt.core.prefs b/eclipse/org.eclipse.jdt.core.prefs index 9897e1cc..7e2236c6 100644 --- a/eclipse/org.eclipse.jdt.core.prefs +++ b/eclipse/org.eclipse.jdt.core.prefs @@ -11,9 +11,9 @@ org.eclipse.jdt.core.codeComplete.staticFieldSuffixes= org.eclipse.jdt.core.codeComplete.staticFinalFieldPrefixes= org.eclipse.jdt.core.codeComplete.staticFinalFieldSuffixes= org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.5 +org.eclipse.jdt.core.compiler.compliance=1.8 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate @@ -102,7 +102,7 @@ org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disa org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning -org.eclipse.jdt.core.compiler.source=1.5 +org.eclipse.jdt.core.compiler.source=1.8 org.eclipse.jdt.core.formatter.align_type_members_on_columns=false org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0 diff --git a/eclipse/org.eclipse.jdt.ui.prefs b/eclipse/org.eclipse.jdt.ui.prefs index 5efd6092..87141cbf 100644 --- a/eclipse/org.eclipse.jdt.ui.prefs +++ b/eclipse/org.eclipse.jdt.ui.prefs @@ -1,28 +1,29 @@ -#Sat Mar 10 15:36:37 PST 2012 cleanup.add_default_serial_version_id=true cleanup.add_generated_serial_version_id=false cleanup.add_missing_annotations=true cleanup.add_missing_deprecated_annotations=true -cleanup.add_missing_methods=false +cleanup.add_missing_methods=true cleanup.add_missing_nls_tags=false cleanup.add_missing_override_annotations=true cleanup.add_missing_override_annotations_interface_methods=true cleanup.add_serial_version_id=false cleanup.always_use_blocks=true -cleanup.always_use_parentheses_in_expressions=true -cleanup.always_use_this_for_non_static_field_access=true +cleanup.always_use_parentheses_in_expressions=false +cleanup.always_use_this_for_non_static_field_access=false cleanup.always_use_this_for_non_static_method_access=false -cleanup.convert_to_enhanced_for_loop=false -cleanup.correct_indentation=false +cleanup.convert_functional_interfaces=true +cleanup.convert_to_enhanced_for_loop=true +cleanup.correct_indentation=true cleanup.format_source_code=true cleanup.format_source_code_changes_only=false -cleanup.make_local_variable_final=true -cleanup.make_parameters_final=false +cleanup.insert_inferred_type_arguments=false +cleanup.make_local_variable_final=false +cleanup.make_parameters_final=true cleanup.make_private_fields_final=true cleanup.make_type_abstract_if_missing_method=false -cleanup.make_variable_declarations_final=false +cleanup.make_variable_declarations_final=true cleanup.never_use_blocks=false -cleanup.never_use_parentheses_in_expressions=false +cleanup.never_use_parentheses_in_expressions=true cleanup.organize_imports=true cleanup.qualify_static_field_accesses_with_declaring_class=false cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true @@ -30,6 +31,8 @@ cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=tru cleanup.qualify_static_member_accesses_with_declaring_class=true cleanup.qualify_static_method_accesses_with_declaring_class=false cleanup.remove_private_constructors=true +cleanup.remove_redundant_modifiers=true +cleanup.remove_redundant_type_arguments=true cleanup.remove_trailing_whitespaces=true cleanup.remove_trailing_whitespaces_all=true cleanup.remove_trailing_whitespaces_ignore_empty=false @@ -43,12 +46,14 @@ cleanup.remove_unused_private_methods=true cleanup.remove_unused_private_types=true cleanup.sort_members=false cleanup.sort_members_all=false +cleanup.use_anonymous_class_creation=false cleanup.use_blocks=true cleanup.use_blocks_only_for_return_and_throw=false +cleanup.use_lambda=true cleanup.use_parentheses_in_expressions=true cleanup.use_this_for_non_static_field_access=true -cleanup.use_this_for_non_static_field_access_only_if_necessary=false -cleanup.use_this_for_non_static_method_access=false +cleanup.use_this_for_non_static_field_access_only_if_necessary=true +cleanup.use_this_for_non_static_method_access=true cleanup.use_this_for_non_static_method_access_only_if_necessary=true cleanup_profile=_Spring Cleanup Conventions cleanup_settings_version=2 @@ -73,7 +78,7 @@ sp_cleanup.add_missing_override_annotations_interface_methods=false sp_cleanup.add_serial_version_id=false sp_cleanup.always_use_blocks=true sp_cleanup.always_use_parentheses_in_expressions=true -sp_cleanup.always_use_this_for_non_static_field_access=true +sp_cleanup.always_use_this_for_non_static_field_access=false sp_cleanup.always_use_this_for_non_static_method_access=false sp_cleanup.convert_to_enhanced_for_loop=false sp_cleanup.correct_indentation=false @@ -111,6 +116,6 @@ sp_cleanup.use_blocks=false sp_cleanup.use_blocks_only_for_return_and_throw=false sp_cleanup.use_parentheses_in_expressions=true sp_cleanup.use_this_for_non_static_field_access=true -sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=false -sp_cleanup.use_this_for_non_static_method_access=false +sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true +sp_cleanup.use_this_for_non_static_method_access=true sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true diff --git a/pom.xml b/pom.xml index bfda1825..2ce034b7 100644 --- a/pom.xml +++ b/pom.xml @@ -84,7 +84,7 @@ 5.4.0.Final 3.3.0 2.4.1 - 4.12 + 5.3.2 2.23.4 1.7.25 5.1.4.RELEASE @@ -148,18 +148,11 @@ test - com.zaxxer HikariCP ${hikaricp.version} - - junit - junit - ${junit.version} - - org.dbunit dbunit @@ -181,6 +174,21 @@ hsqldb ${hsqldb.version} + + org.junit.jupiter + junit-jupiter-api + ${junit-jupiter.version} + + + org.junit.jupiter + junit-jupiter-engine + ${junit-jupiter.version} + + + org.junit.jupiter + junit-jupiter-params + ${junit-jupiter.version} + org.mockito mockito-core diff --git a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/DbUnitTestExecutionListenerPrepareTest.java b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/DbUnitTestExecutionListenerPrepareTest.java index 47c29783..59a5fe08 100644 --- a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/DbUnitTestExecutionListenerPrepareTest.java +++ b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/DbUnitTestExecutionListenerPrepareTest.java @@ -16,12 +16,12 @@ package com.github.springtestdbunit; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.BDDMockito.given; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.eq; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoMoreInteractions; @@ -31,8 +31,8 @@ import org.dbunit.database.DatabaseDataSourceConnection; import org.dbunit.database.IDatabaseConnection; import org.dbunit.dataset.IDataSet; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.context.ApplicationContext; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.ContextLoader; @@ -61,29 +61,29 @@ public class DbUnitTestExecutionListenerPrepareTest { private DataSource dataSource; - @Before + @BeforeEach public void setup() { - this.applicationContext = mock(ApplicationContext.class); - this.databaseConnection = mock(IDatabaseConnection.class); - this.dataSource = mock(DataSource.class); - DbUnitTestExecutionListenerPrepareTest.applicationContextThreadLocal.set(this.applicationContext); + applicationContext = mock(ApplicationContext.class); + databaseConnection = mock(IDatabaseConnection.class); + dataSource = mock(DataSource.class); + DbUnitTestExecutionListenerPrepareTest.applicationContextThreadLocal.set(applicationContext); } @SuppressWarnings("unchecked") private void addBean(String beanName, Object bean) { - given(this.applicationContext.containsBean(beanName)).willReturn(true); - given(this.applicationContext.getBean(beanName)).willReturn(bean); - given(this.applicationContext.getBean(eq(beanName), (Class) any())).willReturn(bean); + given(applicationContext.containsBean(beanName)).willReturn(true); + given(applicationContext.getBean(beanName)).willReturn(bean); + given(applicationContext.getBean(eq(beanName), (Class) any())).willReturn(bean); } @Test public void shouldUseSensibleDefaultsOnClassWithNoDbUnitConfiguration() throws Exception { - addBean("dbUnitDatabaseConnection", this.databaseConnection); + addBean("dbUnitDatabaseConnection", databaseConnection); ExtendedTestContextManager testContextManager = new ExtendedTestContextManager(NoDbUnitConfiguration.class); testContextManager.prepareTestInstance(); DatabaseConnections databaseConnections = (DatabaseConnections) testContextManager .getTestContextAttribute(DbUnitTestExecutionListener.CONNECTION_ATTRIBUTE); - assertSame(this.databaseConnection, databaseConnections.get("dbUnitDatabaseConnection")); + assertSame(databaseConnection, databaseConnections.get("dbUnitDatabaseConnection")); assertEquals(FlatXmlDataSetLoader.class, testContextManager .getTestContextAttribute(DbUnitTestExecutionListener.DATA_SET_LOADER_ATTRIBUTE).getClass()); assertEquals(DefaultDatabaseOperationLookup.class, testContextManager @@ -101,19 +101,19 @@ public void shouldTryBeanFactoryForCommonBeanNamesWithEmptyDatabaseConnection() } private void testCommonBeanNames(Class testClass) throws Exception { - addBean("dataSource", this.dataSource); + addBean("dataSource", dataSource); ExtendedTestContextManager testContextManager = new ExtendedTestContextManager(testClass); testContextManager.prepareTestInstance(); - verify(this.applicationContext).containsBean("dbUnitDataSetLoader"); - verify(this.applicationContext).containsBean("dbUnitDatabaseConnection"); - verify(this.applicationContext).containsBean("dataSource"); - verify(this.applicationContext).getBean("dataSource"); - verifyNoMoreInteractions(this.applicationContext); + verify(applicationContext).containsBean("dbUnitDataSetLoader"); + verify(applicationContext).containsBean("dbUnitDatabaseConnection"); + verify(applicationContext).containsBean("dataSource"); + verify(applicationContext).getBean("dataSource"); + verifyNoMoreInteractions(applicationContext); } @Test public void shouldConvertDatasetDatabaseConnection() throws Exception { - addBean("dataSource", this.dataSource); + addBean("dataSource", dataSource); ExtendedTestContextManager testContextManager = new ExtendedTestContextManager(NoDbUnitConfiguration.class); testContextManager.prepareTestInstance(); DatabaseConnections databaseConnections = (DatabaseConnections) testContextManager @@ -146,13 +146,13 @@ public void shouldFailIfDatabaseConnectionOfWrongTypeIsFound() throws Exception @Test public void shouldSupportAllDbUnitConfigurationAttributes() throws Exception { - addBean("customBean", this.databaseConnection); + addBean("customBean", databaseConnection); ExtendedTestContextManager testContextManager = new ExtendedTestContextManager(CustomConfiguration.class); testContextManager.prepareTestInstance(); - verify(this.applicationContext).getBean("customBean"); + verify(applicationContext).getBean("customBean"); DatabaseConnections databaseConnections = (DatabaseConnections) testContextManager .getTestContextAttribute(DbUnitTestExecutionListener.CONNECTION_ATTRIBUTE); - assertSame(this.databaseConnection, databaseConnections.get("customBean")); + assertSame(databaseConnection, databaseConnections.get("customBean")); assertEquals(CustomDataSetLoader.class, testContextManager .getTestContextAttribute(DbUnitTestExecutionListener.DATA_SET_LOADER_ATTRIBUTE).getClass()); assertEquals(CustomDatabaseOperationLookup.class, testContextManager @@ -161,7 +161,7 @@ public void shouldSupportAllDbUnitConfigurationAttributes() throws Exception { @Test public void shouldFailIfDatasetLoaderCannotBeCreated() throws Exception { - addBean("dbUnitDatabaseConnection", this.databaseConnection); + addBean("dbUnitDatabaseConnection", databaseConnection); ExtendedTestContextManager testContextManager = new ExtendedTestContextManager(NonCreatableDataSetLoader.class); try { testContextManager.prepareTestInstance(); @@ -174,7 +174,7 @@ public void shouldFailIfDatasetLoaderCannotBeCreated() throws Exception { @Test public void shouldSupportCustomLoaderBean() throws Exception { - addBean("dataSource", this.dataSource); + addBean("dataSource", dataSource); addBean("dbUnitDataSetLoader", new CustomDataSetLoader()); ExtendedTestContextManager testContextManager = new ExtendedTestContextManager(EmptyDbUnitConfiguration.class); testContextManager.prepareTestInstance(); diff --git a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/TestExecutionListenerChainTest.java b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/TestExecutionListenerChainTest.java index 57dcc899..a49ec5af 100644 --- a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/TestExecutionListenerChainTest.java +++ b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/TestExecutionListenerChainTest.java @@ -16,16 +16,21 @@ package com.github.springtestdbunit; -import static org.junit.Assert.*; -import static org.mockito.Mockito.*; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; +import static org.mockito.Mockito.doThrow; +import static org.mockito.Mockito.inOrder; +import static org.mockito.Mockito.mock; import java.io.IOError; import java.io.IOException; import java.util.Arrays; import java.util.List; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.InOrder; import org.springframework.test.context.TestContext; import org.springframework.test.context.TestExecutionListener; @@ -48,12 +53,12 @@ public class TestExecutionListenerChainTest { private TestExecutionListener l2; - @Before + @BeforeEach public void setup() { - this.l1 = mock(TestExecutionListener.class); - this.l2 = mock(TestExecutionListener.class); - this.ordered = inOrder(this.l1, this.l2); - this.chain = new TestExecutionListenerChain() { + l1 = mock(TestExecutionListener.class); + l2 = mock(TestExecutionListener.class); + ordered = inOrder(l1, l2); + chain = new TestExecutionListenerChain() { @Override protected Class[] getChain() { return null; @@ -61,21 +66,21 @@ protected Class[] getChain() { @Override protected List createChain() { - return Arrays.asList(TestExecutionListenerChainTest.this.l1, TestExecutionListenerChainTest.this.l2); + return Arrays.asList(l1, l2); }; }; - this.testContext = mock(TestContext.class); + testContext = mock(TestContext.class); } @Test public void shouldCreateChainFromClasses() throws Exception { - this.chain = new TestExecutionListenerChain() { + chain = new TestExecutionListenerChain() { @Override protected Class[] getChain() { return new Class[] { TestListener1.class, TestListener2.class }; }; }; - List list = this.chain.createChain(); + List list = chain.createChain(); assertEquals(2, list.size()); assertTrue(list.get(0) instanceof TestListener1); assertTrue(list.get(1) instanceof TestListener2); @@ -84,7 +89,7 @@ protected Class[] getChain() { @Test public void shouldNotCreateWithIllegalConstructor() throws Exception { try { - this.chain = new TestExecutionListenerChain() { + chain = new TestExecutionListenerChain() { @Override protected Class[] getChain() { return new Class[] { InvalidTestListener.class }; @@ -99,53 +104,61 @@ protected Class[] getChain() { @Test public void shouldChainBeforeTestClass() throws Exception { - this.chain.beforeTestClass(this.testContext); - this.ordered.verify(this.l1).beforeTestClass(this.testContext); - this.ordered.verify(this.l2).beforeTestClass(this.testContext); + chain.beforeTestClass(testContext); + ordered.verify(l1).beforeTestClass(testContext); + ordered.verify(l2).beforeTestClass(testContext); } @Test public void shouldChainPrepareTestInstance() throws Exception { - this.chain.prepareTestInstance(this.testContext); - this.ordered.verify(this.l1).prepareTestInstance(this.testContext); - this.ordered.verify(this.l2).prepareTestInstance(this.testContext); + chain.prepareTestInstance(testContext); + ordered.verify(l1).prepareTestInstance(testContext); + ordered.verify(l2).prepareTestInstance(testContext); } @Test public void shouldChainBeforeTestMethod() throws Exception { - this.chain.beforeTestMethod(this.testContext); - this.ordered.verify(this.l1).beforeTestMethod(this.testContext); - this.ordered.verify(this.l2).beforeTestMethod(this.testContext); + chain.beforeTestMethod(testContext); + ordered.verify(l1).beforeTestMethod(testContext); + ordered.verify(l2).beforeTestMethod(testContext); } @Test public void shouldChainAfterTestMethod() throws Exception { - this.chain.afterTestMethod(this.testContext); - this.ordered.verify(this.l2).afterTestMethod(this.testContext); - this.ordered.verify(this.l1).afterTestMethod(this.testContext); + chain.afterTestMethod(testContext); + ordered.verify(l2).afterTestMethod(testContext); + ordered.verify(l1).afterTestMethod(testContext); } - @Test(expected = Exception.class) + @Test public void shouldChainAfterTestMethodEvenOnException() throws Exception { - doThrow(new IOError(null)).when(this.l2).afterTestMethod(this.testContext); - this.chain.afterTestMethod(this.testContext); - this.ordered.verify(this.l2).afterTestMethod(this.testContext); - this.ordered.verify(this.l1).afterTestMethod(this.testContext); + + doThrow(new IOError(null)).when(l2).afterTestMethod(testContext); + + Assertions.assertThrows(Exception.class, () -> { + chain.afterTestMethod(testContext); + ordered.verify(l2).afterTestMethod(testContext); + ordered.verify(l1).afterTestMethod(testContext); + }); } @Test public void shouldChainAfterTestClass() throws Exception { - this.chain.afterTestClass(this.testContext); - this.ordered.verify(this.l2).afterTestClass(this.testContext); - this.ordered.verify(this.l1).afterTestClass(this.testContext); + chain.afterTestClass(testContext); + ordered.verify(l2).afterTestClass(testContext); + ordered.verify(l1).afterTestClass(testContext); } - @Test(expected = IOException.class) + @Test public void shouldChainAfterTestClassEvenOnException() throws Exception { - doThrow(new IOException()).when(this.l2).afterTestClass(this.testContext); - this.chain.afterTestClass(this.testContext); - this.ordered.verify(this.l2).afterTestClass(this.testContext); - this.ordered.verify(this.l1).afterTestClass(this.testContext); + + doThrow(new IOException()).when(l2).afterTestClass(testContext); + + Assertions.assertThrows(IOException.class, () -> { + chain.afterTestClass(testContext); + ordered.verify(l2).afterTestClass(testContext); + ordered.verify(l1).afterTestClass(testContext); + }); } public static class TestListener1 extends AbstractTestExecutionListener { diff --git a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/TransactionDbUnitTestExecutionListenerTest.java b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/TransactionDbUnitTestExecutionListenerTest.java index 1416f7ef..425ae975 100644 --- a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/TransactionDbUnitTestExecutionListenerTest.java +++ b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/TransactionDbUnitTestExecutionListenerTest.java @@ -16,9 +16,9 @@ package com.github.springtestdbunit; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.test.context.transaction.TransactionalTestExecutionListener; /** diff --git a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/bean/DatabaseConfigBeanTest.java b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/bean/DatabaseConfigBeanTest.java index cfe7c693..f5e2cbdf 100644 --- a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/bean/DatabaseConfigBeanTest.java +++ b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/bean/DatabaseConfigBeanTest.java @@ -16,7 +16,9 @@ package com.github.springtestdbunit.bean; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.fail; import static org.mockito.Mockito.mock; import java.util.HashSet; @@ -29,8 +31,8 @@ import org.dbunit.database.statement.IStatementFactory; import org.dbunit.dataset.datatype.IDataTypeFactory; import org.dbunit.dataset.filter.IColumnFilter; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.beans.BeanWrapper; import org.springframework.beans.BeanWrapperImpl; @@ -54,21 +56,21 @@ public class DatabaseConfigBeanTest { private BeanWrapper configBeanWrapper; - @Before + @BeforeEach public void setup() { - this.configBean = new DatabaseConfigBean(); - this.configBeanWrapper = new BeanWrapperImpl(this.configBean); + configBean = new DatabaseConfigBean(); + configBeanWrapper = new BeanWrapperImpl(configBean); } @Test public void shouldAllowSetOfNonMandatoryFieldToNull() throws Exception { - this.configBean.setPrimaryKeyFilter(null); + configBean.setPrimaryKeyFilter(null); } @Test public void shouldFailWhenSetingMandatoryFieldToNull() throws Exception { try { - this.configBean.setDatatypeFactory(null); + configBean.setDatatypeFactory(null); fail(); } catch (IllegalArgumentException ex) { assertEquals("dataTypeFactory cannot be null", ex.getMessage()); @@ -147,23 +149,23 @@ public void testSkipOracleRecyclebinTables() { } private void doTest(String propertyName, String databaseConfigProperty, Object newValue) { - Object initialValue = this.configBeanWrapper.getPropertyValue(propertyName); - Object expectedInitialValue = this.defaultConfig.getProperty(databaseConfigProperty); + Object initialValue = configBeanWrapper.getPropertyValue(propertyName); + Object expectedInitialValue = defaultConfig.getProperty(databaseConfigProperty); if ((initialValue != null) && CLASS_COMPARE_ONLY.contains(initialValue.getClass())) { - assertEquals("Initial value is not as expected", initialValue.getClass(), expectedInitialValue.getClass()); + assertEquals(initialValue.getClass(), expectedInitialValue.getClass(), "Initial value is not as expected"); } else { - assertEquals("Initial value is not as expected", initialValue, expectedInitialValue); + assertEquals(initialValue, expectedInitialValue, "Initial value is not as expected"); } - assertFalse("Unable to test if new value is same as intial value", newValue.equals(initialValue)); - this.configBeanWrapper.setPropertyValue(propertyName, newValue); + assertFalse(newValue.equals(initialValue), "Unable to test if new value is same as intial value"); + configBeanWrapper.setPropertyValue(propertyName, newValue); DatabaseConfig appliedConfig = new DatabaseConfig(); - this.configBean.apply(appliedConfig); + configBean.apply(appliedConfig); - assertEquals("Did not replace " + propertyName + " value", newValue, - appliedConfig.getProperty(databaseConfigProperty)); + assertEquals(newValue, appliedConfig.getProperty(databaseConfigProperty), + "Did not replace " + propertyName + " value"); } diff --git a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/bean/DatabaseDataSourceConnectionFactoryBeanTest.java b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/bean/DatabaseDataSourceConnectionFactoryBeanTest.java index d91cd546..8445df3e 100644 --- a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/bean/DatabaseDataSourceConnectionFactoryBeanTest.java +++ b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/bean/DatabaseDataSourceConnectionFactoryBeanTest.java @@ -16,9 +16,14 @@ package com.github.springtestdbunit.bean; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; import static org.mockito.BDDMockito.given; -import static org.mockito.Mockito.*; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; import java.sql.Connection; @@ -26,8 +31,8 @@ import org.dbunit.database.DatabaseDataSourceConnection; import org.dbunit.database.IDatabaseConnection; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy; /** @@ -39,15 +44,15 @@ public class DatabaseDataSourceConnectionFactoryBeanTest { private DatabaseDataSourceConnectionFactoryBean factoryBean; - @Before + @BeforeEach public void setup() { - this.factoryBean = new DatabaseDataSourceConnectionFactoryBean(); + factoryBean = new DatabaseDataSourceConnectionFactoryBean(); } @Test public void shouldNotAllowObjectWithoutDataSet() throws Exception { try { - this.factoryBean.getObject(); + factoryBean.getObject(); fail(); } catch (IllegalArgumentException ex) { assertEquals("The dataSource is required", ex.getMessage()); @@ -59,8 +64,8 @@ public void shouldCreateDatabaseDataSourceConnection() throws Exception { DataSource dataSource = mock(DataSource.class); Connection connection = mock(Connection.class); given(dataSource.getConnection()).willReturn(connection); - this.factoryBean.setDataSource(dataSource); - DatabaseDataSourceConnection bean = this.factoryBean.getObject(); + factoryBean.setDataSource(dataSource); + DatabaseDataSourceConnection bean = factoryBean.getObject(); assertNotNull(bean); bean.getConnection().createStatement(); verify(dataSource).getConnection(); @@ -69,10 +74,10 @@ public void shouldCreateDatabaseDataSourceConnection() throws Exception { @Test public void shouldAcceptUsernameAndPassword() throws Exception { DataSource dataSource = mock(DataSource.class); - this.factoryBean.setDataSource(dataSource); - this.factoryBean.setUsername("username"); - this.factoryBean.setPassword("password"); - DatabaseDataSourceConnection bean = this.factoryBean.getObject(); + factoryBean.setDataSource(dataSource); + factoryBean.setUsername("username"); + factoryBean.setPassword("password"); + DatabaseDataSourceConnection bean = factoryBean.getObject(); assertNotNull(bean); bean.getConnection(); verify(dataSource).getConnection("username", "password"); @@ -81,51 +86,53 @@ public void shouldAcceptUsernameAndPassword() throws Exception { @Test public void shouldSupportSchema() throws Exception { DataSource dataSource = mock(DataSource.class); - this.factoryBean.setDataSource(dataSource); - this.factoryBean.setSchema("schema"); - DatabaseDataSourceConnection bean = this.factoryBean.getObject(); + factoryBean.setDataSource(dataSource); + factoryBean.setSchema("schema"); + DatabaseDataSourceConnection bean = factoryBean.getObject(); assertEquals("schema", bean.getSchema()); } @Test public void shouldSupportDatabaseConfigBean() throws Exception { DataSource dataSource = mock(DataSource.class); - this.factoryBean.setDataSource(dataSource); + factoryBean.setDataSource(dataSource); DatabaseConfigBean databaseConfig = mock(DatabaseConfigBean.class); - this.factoryBean.setDatabaseConfig(databaseConfig); - DatabaseDataSourceConnection bean = this.factoryBean.getObject(); + factoryBean.setDatabaseConfig(databaseConfig); + DatabaseDataSourceConnection bean = factoryBean.getObject(); assertNotNull(bean); verify(databaseConfig).apply(bean.getConfig()); } @Test public void shouldBeSingleton() throws Exception { - assertTrue(this.factoryBean.isSingleton()); + assertTrue(factoryBean.isSingleton()); } @Test public void shouldBeCorrectClass() throws Exception { - assertEquals(DatabaseDataSourceConnection.class, this.factoryBean.getObjectType()); + assertEquals(DatabaseDataSourceConnection.class, factoryBean.getObjectType()); } @Test public void shouldCreateCreateTransactionAwareConnection() throws Exception { DataSource dataSource = mock(DataSource.class); - this.factoryBean.setDataSource(dataSource); - DatabaseDataSourceConnection dataSourceConnection = this.factoryBean.getObject(); + factoryBean.setDataSource(dataSource); + DatabaseDataSourceConnection dataSourceConnection = factoryBean.getObject(); Connection connection = dataSourceConnection.getConnection(); - assertTrue(connection.toString() + " is not transaction aware", - connection.toString().startsWith("Transaction-aware proxy")); + assertTrue(connection.toString().startsWith("Transaction-aware proxy"), + connection.toString() + " is not transaction aware"); } @Test public void shouldNotWrapCreateTransactionAwareConnection() throws Exception { DataSource dataSource = new TransactionAwareDataSourceProxy(mock(DataSource.class)); - this.factoryBean.setDataSource(dataSource); - DatabaseDataSourceConnection dataSourceConnection = this.factoryBean.getObject(); + factoryBean.setDataSource(dataSource); + DatabaseDataSourceConnection dataSourceConnection = factoryBean.getObject(); Connection connection = dataSourceConnection.getConnection(); - assertTrue(connection.toString() + " is not transaction aware", connection.toString() - .startsWith("Transaction-aware proxy for target Connection from DataSource [Mock for DataSource")); + assertTrue( + connection.toString().startsWith( + "Transaction-aware proxy for target Connection from DataSource [Mock for DataSource"), + connection.toString() + " is not transaction aware"); } @Test @@ -133,9 +140,9 @@ public void shouldRespectTransactionAwareAttribute() throws Exception { DataSource dataSource = mock(DataSource.class); Connection connection = mock(Connection.class); given(dataSource.getConnection()).willReturn(connection); - this.factoryBean.setDataSource(dataSource); - this.factoryBean.setTransactionAware(false); - DatabaseDataSourceConnection dataSourceConnection = this.factoryBean.getObject(); + factoryBean.setDataSource(dataSource); + factoryBean.setTransactionAware(false); + DatabaseDataSourceConnection dataSourceConnection = factoryBean.getObject(); Connection actual = dataSourceConnection.getConnection(); assertSame(connection, actual); } diff --git a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/config/CoreTestConfiguration.java b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/config/CoreTestConfiguration.java index d375db86..fadb7497 100644 --- a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/config/CoreTestConfiguration.java +++ b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/config/CoreTestConfiguration.java @@ -73,7 +73,7 @@ public class CoreTestConfiguration { public DatabaseConfigBean databaseConfig() { DatabaseConfigBean databaseConfig = new DatabaseConfigBean(); - databaseConfig.setDatatypeFactory(this.dataTypeFactory); + databaseConfig.setDatatypeFactory(dataTypeFactory); return databaseConfig; } @@ -82,7 +82,7 @@ public DatabaseConfigBean databaseConfig() { public DatabaseDataSourceConnectionFactoryBean databaseDataSourceConnectionFactory() { DatabaseDataSourceConnectionFactoryBean databaseDataSourceConnectionFactory = new DatabaseDataSourceConnectionFactoryBean( - this.dataSource); + dataSource); databaseDataSourceConnectionFactory.setDatabaseConfig(databaseConfig()); return databaseDataSourceConnectionFactory; @@ -116,11 +116,11 @@ public List hibernatePackagesToScan() { public HikariConfig hikariConfig2() { HikariConfig hikariConfig = new HikariConfig(); - hikariConfig.setPoolName(this.dataSourcePoolName + "2"); - hikariConfig.setDriverClassName(this.dataSourceDriver); - hikariConfig.setJdbcUrl(this.dataSourceUrl + "2"); - hikariConfig.setUsername(this.dataSourceUsername); - hikariConfig.setPassword(this.dataSourcePassword); + hikariConfig.setPoolName(dataSourcePoolName + "2"); + hikariConfig.setDriverClassName(dataSourceDriver); + hikariConfig.setJdbcUrl(dataSourceUrl + "2"); + hikariConfig.setUsername(dataSourceUsername); + hikariConfig.setPassword(dataSourcePassword); hikariConfig.setMaximumPoolSize(50); return hikariConfig; diff --git a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/dataset/FlatXmlDataSetLoaderTest.java b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/dataset/FlatXmlDataSetLoaderTest.java index c848f4e4..788b821f 100644 --- a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/dataset/FlatXmlDataSetLoaderTest.java +++ b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/dataset/FlatXmlDataSetLoaderTest.java @@ -16,11 +16,12 @@ package com.github.springtestdbunit.dataset; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; import org.dbunit.dataset.IDataSet; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.test.context.TestContext; import com.github.springtestdbunit.testutils.ExtendedTestContextManager; @@ -36,29 +37,29 @@ public class FlatXmlDataSetLoaderTest { private FlatXmlDataSetLoader loader; - @Before + @BeforeEach public void setup() throws Exception { - this.loader = new FlatXmlDataSetLoader(); + loader = new FlatXmlDataSetLoader(); ExtendedTestContextManager manager = new ExtendedTestContextManager(getClass()); - this.testContext = manager.accessTestContext(); + testContext = manager.accessTestContext(); } @Test public void shouldSenseColumns() throws Exception { - IDataSet dataset = this.loader.loadDataSet(this.testContext.getTestClass(), "test-column-sensing.xml"); + IDataSet dataset = loader.loadDataSet(testContext.getTestClass(), "test-column-sensing.xml"); assertEquals(null, dataset.getTable("Sample").getValue(0, "name")); assertEquals("test", dataset.getTable("Sample").getValue(1, "name")); } @Test public void shouldLoadFromRelativeFile() throws Exception { - IDataSet dataset = this.loader.loadDataSet(this.testContext.getTestClass(), "test.xml"); + IDataSet dataset = loader.loadDataSet(testContext.getTestClass(), "test.xml"); assertEquals("Sample", dataset.getTableNames()[0]); } @Test public void shouldReturnNullOnMissingFile() throws Exception { - IDataSet dataset = this.loader.loadDataSet(this.testContext.getTestClass(), "doesnotexist.xml"); + IDataSet dataset = loader.loadDataSet(testContext.getTestClass(), "doesnotexist.xml"); assertNull(dataset); } diff --git a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/dataset/ReplacementDataSetLoaderTest.java b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/dataset/ReplacementDataSetLoaderTest.java index 4d60cf24..de0413dc 100644 --- a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/dataset/ReplacementDataSetLoaderTest.java +++ b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/dataset/ReplacementDataSetLoaderTest.java @@ -1,11 +1,12 @@ package com.github.springtestdbunit.dataset; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; import org.dbunit.dataset.IDataSet; import org.dbunit.dataset.ITable; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.test.context.TestContext; import com.github.springtestdbunit.testutils.ExtendedTestContextManager; @@ -21,16 +22,16 @@ public class ReplacementDataSetLoaderTest { private ReplacementDataSetLoader loader; - @Before + @BeforeEach public void setup() throws Exception { - this.loader = new ReplacementDataSetLoader(); + loader = new ReplacementDataSetLoader(); ExtendedTestContextManager manager = new ExtendedTestContextManager(getClass()); - this.testContext = manager.accessTestContext(); + testContext = manager.accessTestContext(); } @Test public void shouldReplaceNulls() throws Exception { - IDataSet dataset = this.loader.loadDataSet(this.testContext.getTestClass(), "test-replacement.xml"); + IDataSet dataset = loader.loadDataSet(testContext.getTestClass(), "test-replacement.xml"); assertEquals("Sample", dataset.getTableNames()[0]); ITable table = dataset.getTable("Sample"); assertEquals(1, table.getRowCount()); diff --git a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/dataset/XmlDataSetLoaderTest.java b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/dataset/XmlDataSetLoaderTest.java index 0aec38d3..d28f55db 100644 --- a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/dataset/XmlDataSetLoaderTest.java +++ b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/dataset/XmlDataSetLoaderTest.java @@ -1,10 +1,11 @@ package com.github.springtestdbunit.dataset; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; import org.dbunit.dataset.IDataSet; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.test.context.TestContext; import com.github.springtestdbunit.testutils.ExtendedTestContextManager; @@ -20,22 +21,22 @@ public class XmlDataSetLoaderTest { private XmlDataSetLoader loader; - @Before + @BeforeEach public void setup() throws Exception { - this.loader = new XmlDataSetLoader(); + loader = new XmlDataSetLoader(); ExtendedTestContextManager manager = new ExtendedTestContextManager(getClass()); - this.testContext = manager.accessTestContext(); + testContext = manager.accessTestContext(); } @Test public void shouldLoadFromRelativeFile() throws Exception { - IDataSet dataset = this.loader.loadDataSet(this.testContext.getTestClass(), "non-flat-xmldataset.xml"); + IDataSet dataset = loader.loadDataSet(testContext.getTestClass(), "non-flat-xmldataset.xml"); assertEquals("Sample", dataset.getTableNames()[0]); } @Test public void shouldReturnNullOnMissingFile() throws Exception { - IDataSet dataset = this.loader.loadDataSet(this.testContext.getTestClass(), "doesnotexist.xml"); + IDataSet dataset = loader.loadDataSet(testContext.getTestClass(), "doesnotexist.xml"); assertNull(dataset); } diff --git a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java index e1520d06..3ca44be7 100644 --- a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java +++ b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java @@ -16,7 +16,7 @@ package com.github.springtestdbunit.entity; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.util.Arrays; import java.util.List; @@ -47,22 +47,22 @@ public class EntityAssert implements InitializingBean { public void afterPropertiesSet() throws Exception { - CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); - this.criteriaQuery = cb.createQuery(SampleEntity.class); - Root from = this.criteriaQuery.from(SampleEntity.class); - this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); + CriteriaBuilder cb = entityManager.getCriteriaBuilder(); + criteriaQuery = cb.createQuery(SampleEntity.class); + Root from = criteriaQuery.from(SampleEntity.class); + criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); } public void assertValues(String... values) { SortedSet expected = new TreeSet(Arrays.asList(values)); SortedSet actual = new TreeSet(); - TypedQuery query = this.entityManager.createQuery(this.criteriaQuery); + TypedQuery query = entityManager.createQuery(criteriaQuery); List results = query.getResultList(); for (SampleEntity sampleEntity : results) { actual.add(sampleEntity.getValue()); - this.entityManager.detach(sampleEntity); + entityManager.detach(sampleEntity); } assertEquals(expected, actual); diff --git a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/entity/HibernateImportTest.java b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/entity/HibernateImportTest.java index 9f2ed8a8..a0911662 100644 --- a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/entity/HibernateImportTest.java +++ b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/entity/HibernateImportTest.java @@ -18,10 +18,8 @@ import javax.annotation.Resource; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.junit.jupiter.api.Test; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; import com.github.springtestdbunit.config.CoreTestConfiguration; @@ -30,8 +28,7 @@ * * @author Phillip Webb */ -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = CoreTestConfiguration.class) +@SpringJUnitConfig(CoreTestConfiguration.class) public class HibernateImportTest { @Resource @@ -39,7 +36,7 @@ public class HibernateImportTest { @Test public void shouldHaveUpdatedData() throws Exception { - this.entityAssert.assertValues("existing1", "existing2"); + entityAssert.assertValues("existing1", "existing2"); } } diff --git a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/entity/OtherEntityAssert.java b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/entity/OtherEntityAssert.java index c3359f80..3efafa58 100644 --- a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/entity/OtherEntityAssert.java +++ b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/entity/OtherEntityAssert.java @@ -16,7 +16,7 @@ package com.github.springtestdbunit.entity; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.util.Arrays; import java.util.List; @@ -47,22 +47,22 @@ public class OtherEntityAssert implements InitializingBean { public void afterPropertiesSet() throws Exception { - CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); - this.criteriaQuery = cb.createQuery(OtherSampleEntity.class); - Root from = this.criteriaQuery.from(OtherSampleEntity.class); - this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); + CriteriaBuilder cb = entityManager.getCriteriaBuilder(); + criteriaQuery = cb.createQuery(OtherSampleEntity.class); + Root from = criteriaQuery.from(OtherSampleEntity.class); + criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); } public void assertValues(String... values) { SortedSet expected = new TreeSet(Arrays.asList(values)); SortedSet actual = new TreeSet(); - TypedQuery query = this.entityManager.createQuery(this.criteriaQuery); + TypedQuery query = entityManager.createQuery(criteriaQuery); List results = query.getResultList(); for (OtherSampleEntity sampleEntity : results) { actual.add(sampleEntity.getValue()); - this.entityManager.detach(sampleEntity); + entityManager.detach(sampleEntity); } assertEquals(expected, actual); diff --git a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/entity/OtherSampleEntity.java b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/entity/OtherSampleEntity.java index 81061615..6f2aaa90 100644 --- a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/entity/OtherSampleEntity.java +++ b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/entity/OtherSampleEntity.java @@ -23,16 +23,16 @@ public class OtherSampleEntity { private String value; public String getValue() { - return this.value; + return value; } - public void setValue(String value) { - this.value = value; + public void setValue(String newValue) { + value = newValue; } @Override public String toString() { - return "OtherSampleEntity{" + "id=" + this.id + ", value='" + this.value + '\'' + '}'; + return "OtherSampleEntity{" + "id=" + id + ", value='" + value + '\'' + '}'; } } diff --git a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/entity/SampleEntity.java b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/entity/SampleEntity.java index e03ffa4d..0d159371 100644 --- a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/entity/SampleEntity.java +++ b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/entity/SampleEntity.java @@ -42,15 +42,16 @@ public class SampleEntity { private String value; public String getValue() { - return this.value; + return value; } - public void setValue(String value) { - this.value = value; + public void setValue(String newValue) { + value = newValue; } @Override public String toString() { - return new ToStringCreator(this).append("id", this.id).append("value", this.value).toString(); + return new ToStringCreator(this).append("id", id).append("value", value).toString(); } + } diff --git a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/expected/ExpectedFailureOnClassTest.java b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/expected/ExpectedFailureOnClassTest.java index 006ecffc..5573519d 100644 --- a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/expected/ExpectedFailureOnClassTest.java +++ b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/expected/ExpectedFailureOnClassTest.java @@ -16,12 +16,10 @@ package com.github.springtestdbunit.expected; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; @@ -30,8 +28,7 @@ import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.MustFailDbUnitTestExecutionListener; -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = CoreTestConfiguration.class) +@SpringJUnitConfig(CoreTestConfiguration.class) @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, MustFailDbUnitTestExecutionListener.class }) @ExpectedDatabase("/META-INF/db/expectedfail.xml") @Transactional diff --git a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/expected/ExpectedFailureOnMethodTest.java b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/expected/ExpectedFailureOnMethodTest.java index a7b40f5c..0afabc4d 100644 --- a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/expected/ExpectedFailureOnMethodTest.java +++ b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/expected/ExpectedFailureOnMethodTest.java @@ -16,12 +16,10 @@ package com.github.springtestdbunit.expected; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; @@ -30,8 +28,7 @@ import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.MustFailDbUnitTestExecutionListener; -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = CoreTestConfiguration.class) +@SpringJUnitConfig(CoreTestConfiguration.class) @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, MustFailDbUnitTestExecutionListener.class }) @Transactional public class ExpectedFailureOnMethodTest { @@ -42,7 +39,7 @@ public class ExpectedFailureOnMethodTest { @Test @ExpectedDatabase("/META-INF/db/expectedfail.xml") public void test() throws Exception { - this.entityAssert.assertValues("existing1", "existing2"); + entityAssert.assertValues("existing1", "existing2"); } } diff --git a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/expected/ExpectedFailureOnMethodWithRepeatableReverseTest.java b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/expected/ExpectedFailureOnMethodWithRepeatableReverseTest.java index f8b47135..dcdfc6ba 100644 --- a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/expected/ExpectedFailureOnMethodWithRepeatableReverseTest.java +++ b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/expected/ExpectedFailureOnMethodWithRepeatableReverseTest.java @@ -16,12 +16,10 @@ package com.github.springtestdbunit.expected; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; @@ -31,8 +29,7 @@ import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.MustFailDbUnitTestExecutionListener; -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = CoreTestConfiguration.class) +@SpringJUnitConfig(CoreTestConfiguration.class) @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, MustFailDbUnitTestExecutionListener.class }) @Transactional public class ExpectedFailureOnMethodWithRepeatableReverseTest { @@ -44,7 +41,7 @@ public class ExpectedFailureOnMethodWithRepeatableReverseTest { @ExpectedDatabases({ @ExpectedDatabase("/META-INF/db/expectedsuccess.xml"), @ExpectedDatabase("/META-INF/db/expectedfail.xml") }) public void test() throws Exception { - this.entityAssert.assertValues("existing1", "existing2"); + entityAssert.assertValues("existing1", "existing2"); } } diff --git a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/expected/ExpectedFailureOnMethodWithRepeatableTest.java b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/expected/ExpectedFailureOnMethodWithRepeatableTest.java index 72e7411f..9db6eb49 100644 --- a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/expected/ExpectedFailureOnMethodWithRepeatableTest.java +++ b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/expected/ExpectedFailureOnMethodWithRepeatableTest.java @@ -16,12 +16,10 @@ package com.github.springtestdbunit.expected; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; @@ -31,8 +29,7 @@ import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.MustFailDbUnitTestExecutionListener; -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = CoreTestConfiguration.class) +@SpringJUnitConfig(CoreTestConfiguration.class) @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, MustFailDbUnitTestExecutionListener.class }) @Transactional public class ExpectedFailureOnMethodWithRepeatableTest { @@ -44,7 +41,7 @@ public class ExpectedFailureOnMethodWithRepeatableTest { @ExpectedDatabases({ @ExpectedDatabase("/META-INF/db/expectedfail.xml"), @ExpectedDatabase("/META-INF/db/expectedsuccess.xml") }) public void test() throws Exception { - this.entityAssert.assertValues("existing1", "existing2"); + entityAssert.assertValues("existing1", "existing2"); } } diff --git a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/expected/ExpectedNonStrictOnClassTest.java b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/expected/ExpectedNonStrictOnClassTest.java index 18a3a3b7..1e047b58 100644 --- a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/expected/ExpectedNonStrictOnClassTest.java +++ b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/expected/ExpectedNonStrictOnClassTest.java @@ -16,12 +16,10 @@ package com.github.springtestdbunit.expected; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; @@ -31,8 +29,7 @@ import com.github.springtestdbunit.config.CoreTestConfiguration; import com.github.springtestdbunit.entity.EntityAssert; -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = CoreTestConfiguration.class) +@SpringJUnitConfig(CoreTestConfiguration.class) @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, DbUnitTestExecutionListener.class }) @ExpectedDatabase(value = "/META-INF/db/expected_nonstrict.xml", assertionMode = DatabaseAssertionMode.NON_STRICT) @Transactional @@ -43,7 +40,7 @@ public class ExpectedNonStrictOnClassTest { @Test public void shouldNotFailEvenThoughExpectedTableDoesNotSpecifyAllColumns() throws Exception { - this.entityAssert.assertValues("existing1", "existing2"); + entityAssert.assertValues("existing1", "existing2"); } } diff --git a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/expected/ExpectedNonStrictOnMethodTest.java b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/expected/ExpectedNonStrictOnMethodTest.java index a62a761b..6ae4dde4 100644 --- a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/expected/ExpectedNonStrictOnMethodTest.java +++ b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/expected/ExpectedNonStrictOnMethodTest.java @@ -16,12 +16,10 @@ package com.github.springtestdbunit.expected; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; @@ -31,8 +29,7 @@ import com.github.springtestdbunit.config.CoreTestConfiguration; import com.github.springtestdbunit.entity.EntityAssert; -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = CoreTestConfiguration.class) +@SpringJUnitConfig(CoreTestConfiguration.class) @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, DbUnitTestExecutionListener.class }) @Transactional public class ExpectedNonStrictOnMethodTest { @@ -43,7 +40,7 @@ public class ExpectedNonStrictOnMethodTest { @Test @ExpectedDatabase(value = "/META-INF/db/expected_nonstrict.xml", assertionMode = DatabaseAssertionMode.NON_STRICT) public void shouldNotFailEvenThoughExpectedTableDoesNotSpecifyAllColumns() { - this.entityAssert.assertValues("existing1", "existing2"); + entityAssert.assertValues("existing1", "existing2"); } } diff --git a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/expected/ExpectedNonStrictUnorderedOnClassTest.java b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/expected/ExpectedNonStrictUnorderedOnClassTest.java index a0b149fa..2b7c1706 100644 --- a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/expected/ExpectedNonStrictUnorderedOnClassTest.java +++ b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/expected/ExpectedNonStrictUnorderedOnClassTest.java @@ -16,12 +16,10 @@ package com.github.springtestdbunit.expected; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; @@ -31,8 +29,7 @@ import com.github.springtestdbunit.config.CoreTestConfiguration; import com.github.springtestdbunit.entity.EntityAssert; -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = CoreTestConfiguration.class) +@SpringJUnitConfig(CoreTestConfiguration.class) @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, DbUnitTestExecutionListener.class }) @ExpectedDatabase(value = "/META-INF/db/expected_nonstrict_unordered.xml", assertionMode = DatabaseAssertionMode.NON_STRICT_UNORDERED) @Transactional @@ -44,7 +41,7 @@ public class ExpectedNonStrictUnorderedOnClassTest { @Test public void shouldNotFailEvenThoughExpectedTableDoesNotSpecifyAllColumnsAndDoesNotMatchColumnOrders() throws Exception { - this.entityAssert.assertValues("existing1", "existing2"); + entityAssert.assertValues("existing1", "existing2"); } } diff --git a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/expected/ExpectedNonStrictUnorderedOnMethodTest.java b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/expected/ExpectedNonStrictUnorderedOnMethodTest.java index efaafe17..78de2e3d 100644 --- a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/expected/ExpectedNonStrictUnorderedOnMethodTest.java +++ b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/expected/ExpectedNonStrictUnorderedOnMethodTest.java @@ -16,12 +16,10 @@ package com.github.springtestdbunit.expected; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; @@ -31,8 +29,7 @@ import com.github.springtestdbunit.config.CoreTestConfiguration; import com.github.springtestdbunit.entity.EntityAssert; -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = CoreTestConfiguration.class) +@SpringJUnitConfig(CoreTestConfiguration.class) @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, DbUnitTestExecutionListener.class }) @Transactional public class ExpectedNonStrictUnorderedOnMethodTest { @@ -43,7 +40,7 @@ public class ExpectedNonStrictUnorderedOnMethodTest { @Test @ExpectedDatabase(value = "/META-INF/db/expected_nonstrict_unordered.xml", assertionMode = DatabaseAssertionMode.NON_STRICT_UNORDERED) public void shouldNotFailEvenThoughExpectedTableDoesNotSpecifyAllColumnsAndDoesNotMatchColumnOrders() { - this.entityAssert.assertValues("existing1", "existing2"); + entityAssert.assertValues("existing1", "existing2"); } } diff --git a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/expected/ExpectedNonStrictWithDtdTest.java b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/expected/ExpectedNonStrictWithDtdTest.java index d7a5b310..b8b41ada 100644 --- a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/expected/ExpectedNonStrictWithDtdTest.java +++ b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/expected/ExpectedNonStrictWithDtdTest.java @@ -18,12 +18,10 @@ import org.dbunit.dataset.Column; import org.dbunit.dataset.filter.IColumnFilter; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; @@ -33,8 +31,7 @@ import com.github.springtestdbunit.config.CoreTestConfiguration; import com.github.springtestdbunit.entity.EntityAssert; -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = CoreTestConfiguration.class) +@SpringJUnitConfig(CoreTestConfiguration.class) @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, DbUnitTestExecutionListener.class }) @Transactional public class ExpectedNonStrictWithDtdTest { @@ -46,7 +43,7 @@ public class ExpectedNonStrictWithDtdTest { @ExpectedDatabase(value = "/META-INF/db/expected_nonstrict_with_dtd.xml", assertionMode = DatabaseAssertionMode.NON_STRICT, columnFilters = { SampleEntityIdExclusionFilter.class }) public void shouldNotFailEvenThoughExpectedTableDoesNotSpecifyAllColumns() { - this.entityAssert.assertValues("existing1", "existing2"); + entityAssert.assertValues("existing1", "existing2"); } public static class SampleEntityIdExclusionFilter implements IColumnFilter { diff --git a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/expected/ExpectedOnClassAndMethodTest.java b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/expected/ExpectedOnClassAndMethodTest.java index 153a7024..5785e6e8 100644 --- a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/expected/ExpectedOnClassAndMethodTest.java +++ b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/expected/ExpectedOnClassAndMethodTest.java @@ -16,12 +16,10 @@ package com.github.springtestdbunit.expected; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; @@ -31,8 +29,7 @@ import com.github.springtestdbunit.config.CoreTestConfiguration; import com.github.springtestdbunit.entity.EntityAssert; -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = CoreTestConfiguration.class) +@SpringJUnitConfig(CoreTestConfiguration.class) @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, DbUnitTestExecutionListener.class }) @ExpectedDatabase(value = "/META-INF/db/expectedfail.xml") @Transactional @@ -44,7 +41,7 @@ public class ExpectedOnClassAndMethodTest { @Test @ExpectedDatabase(value = "/META-INF/db/expected_nonstrict.xml", assertionMode = DatabaseAssertionMode.NON_STRICT) public void shouldUseMethodExpectation() { - this.entityAssert.assertValues("existing1", "existing2"); + entityAssert.assertValues("existing1", "existing2"); } } diff --git a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/expected/ExpectedOnClassAndMethodWithoutOverrideTest.java b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/expected/ExpectedOnClassAndMethodWithoutOverrideTest.java index e61fd3c6..cb85df56 100644 --- a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/expected/ExpectedOnClassAndMethodWithoutOverrideTest.java +++ b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/expected/ExpectedOnClassAndMethodWithoutOverrideTest.java @@ -16,12 +16,10 @@ package com.github.springtestdbunit.expected; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; @@ -31,8 +29,7 @@ import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.MustFailDbUnitTestExecutionListener; -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = CoreTestConfiguration.class) +@SpringJUnitConfig(CoreTestConfiguration.class) @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, MustFailDbUnitTestExecutionListener.class }) @ExpectedDatabase(value = "/META-INF/db/expectedfail.xml") @Transactional @@ -44,7 +41,7 @@ public class ExpectedOnClassAndMethodWithoutOverrideTest { @Test @ExpectedDatabase(value = "/META-INF/db/expected_nonstrict.xml", assertionMode = DatabaseAssertionMode.NON_STRICT, override = false) public void shouldUseMethodExpectation() { - this.entityAssert.assertValues("existing1", "existing2"); + entityAssert.assertValues("existing1", "existing2"); } } diff --git a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/expected/ExpectedQueryFailureOnMethodTest.java b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/expected/ExpectedQueryFailureOnMethodTest.java index 4a74ede4..6ec226fc 100644 --- a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/expected/ExpectedQueryFailureOnMethodTest.java +++ b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/expected/ExpectedQueryFailureOnMethodTest.java @@ -16,11 +16,9 @@ package com.github.springtestdbunit.expected; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.test.context.ContextConfiguration; +import org.junit.jupiter.api.Test; import org.springframework.test.context.TestExecutionListeners; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; @@ -28,8 +26,7 @@ import com.github.springtestdbunit.config.CoreTestConfiguration; import com.github.springtestdbunit.testutils.MustFailDbUnitTestExecutionListener; -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = CoreTestConfiguration.class) +@SpringJUnitConfig(CoreTestConfiguration.class) @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, MustFailDbUnitTestExecutionListener.class }) @Transactional public class ExpectedQueryFailureOnMethodTest { diff --git a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/expected/ExpectedQueryNonStrictFailureOnMethodTest.java b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/expected/ExpectedQueryNonStrictFailureOnMethodTest.java index 05e61672..05699511 100644 --- a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/expected/ExpectedQueryNonStrictFailureOnMethodTest.java +++ b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/expected/ExpectedQueryNonStrictFailureOnMethodTest.java @@ -16,11 +16,9 @@ package com.github.springtestdbunit.expected; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.test.context.ContextConfiguration; +import org.junit.jupiter.api.Test; import org.springframework.test.context.TestExecutionListeners; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; @@ -29,8 +27,7 @@ import com.github.springtestdbunit.config.CoreTestConfiguration; import com.github.springtestdbunit.testutils.MustFailDbUnitTestExecutionListener; -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = CoreTestConfiguration.class) +@SpringJUnitConfig(CoreTestConfiguration.class) @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, MustFailDbUnitTestExecutionListener.class }) @Transactional public class ExpectedQueryNonStrictFailureOnMethodTest { diff --git a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/expected/ExpectedQueryNonStrictOnMethodTest.java b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/expected/ExpectedQueryNonStrictOnMethodTest.java index fbebda05..7207515d 100644 --- a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/expected/ExpectedQueryNonStrictOnMethodTest.java +++ b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/expected/ExpectedQueryNonStrictOnMethodTest.java @@ -16,11 +16,9 @@ package com.github.springtestdbunit.expected; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.test.context.ContextConfiguration; +import org.junit.jupiter.api.Test; import org.springframework.test.context.TestExecutionListeners; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; @@ -29,8 +27,7 @@ import com.github.springtestdbunit.assertion.DatabaseAssertionMode; import com.github.springtestdbunit.config.CoreTestConfiguration; -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = CoreTestConfiguration.class) +@SpringJUnitConfig(CoreTestConfiguration.class) @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, DbUnitTestExecutionListener.class }) @Transactional public class ExpectedQueryNonStrictOnMethodTest { diff --git a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/expected/ExpectedQueryOnMethodTest.java b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/expected/ExpectedQueryOnMethodTest.java index 6b270ade..50234626 100644 --- a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/expected/ExpectedQueryOnMethodTest.java +++ b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/expected/ExpectedQueryOnMethodTest.java @@ -16,11 +16,9 @@ package com.github.springtestdbunit.expected; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.test.context.ContextConfiguration; +import org.junit.jupiter.api.Test; import org.springframework.test.context.TestExecutionListeners; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; @@ -28,8 +26,7 @@ import com.github.springtestdbunit.annotation.ExpectedDatabase; import com.github.springtestdbunit.config.CoreTestConfiguration; -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = CoreTestConfiguration.class) +@SpringJUnitConfig(CoreTestConfiguration.class) @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, DbUnitTestExecutionListener.class }) @Transactional public class ExpectedQueryOnMethodTest { diff --git a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/expected/ExpectedQueryWithModifierOnMethodTest.java b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/expected/ExpectedQueryWithModifierOnMethodTest.java index 96ac7695..75f00376 100644 --- a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/expected/ExpectedQueryWithModifierOnMethodTest.java +++ b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/expected/ExpectedQueryWithModifierOnMethodTest.java @@ -17,11 +17,9 @@ package com.github.springtestdbunit.expected; import org.dbunit.dataset.ReplacementDataSet; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.test.context.ContextConfiguration; +import org.junit.jupiter.api.Test; import org.springframework.test.context.TestExecutionListeners; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; @@ -31,8 +29,7 @@ import com.github.springtestdbunit.dataset.ReplacementDataSetModifier; import com.github.springtestdbunit.expected.ExpectedQueryWithModifierOnMethodTest.OuterModifier; -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = CoreTestConfiguration.class) +@SpringJUnitConfig(CoreTestConfiguration.class) @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, DbUnitTestExecutionListener.class }) @Transactional @ExpectedDatabase(modifiers = OuterModifier.class) diff --git a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/expected/ExpectedTableNonStrictOnClassTest.java b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/expected/ExpectedTableNonStrictOnClassTest.java index ec921cd5..d947baf0 100644 --- a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/expected/ExpectedTableNonStrictOnClassTest.java +++ b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/expected/ExpectedTableNonStrictOnClassTest.java @@ -16,12 +16,10 @@ package com.github.springtestdbunit.expected; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; @@ -31,8 +29,7 @@ import com.github.springtestdbunit.config.CoreTestConfiguration; import com.github.springtestdbunit.entity.EntityAssert; -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = CoreTestConfiguration.class) +@SpringJUnitConfig(CoreTestConfiguration.class) @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, DbUnitTestExecutionListener.class }) @ExpectedDatabase(value = "/META-INF/db/expected_nonstrict.xml", assertionMode = DatabaseAssertionMode.NON_STRICT, table = "SampleEntity") @Transactional @@ -43,7 +40,7 @@ public class ExpectedTableNonStrictOnClassTest { @Test public void shouldNotFailEvenThoughExpectedTableDoesNotSpecifyAllColumns() throws Exception { - this.entityAssert.assertValues("existing1", "existing2"); + entityAssert.assertValues("existing1", "existing2"); } } diff --git a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/multiconnection/MultiConnectionTest.java b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/multiconnection/MultiConnectionTest.java index eaf6f2e0..b9a2726d 100644 --- a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/multiconnection/MultiConnectionTest.java +++ b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/multiconnection/MultiConnectionTest.java @@ -16,7 +16,7 @@ package com.github.springtestdbunit.multiconnection; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.util.Arrays; import java.util.HashSet; @@ -24,14 +24,12 @@ import javax.sql.DataSource; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.jdbc.core.JdbcTemplate; -import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; @@ -43,8 +41,7 @@ import com.github.springtestdbunit.config.CoreTestConfiguration; import com.github.springtestdbunit.entity.EntityAssert; -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = CoreTestConfiguration.class) +@SpringJUnitConfig(CoreTestConfiguration.class) @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, TransactionDbUnitTestExecutionListener.class, }) @DbUnitConfiguration(databaseConnection = { "dataSource", "dataSource2" }) @@ -64,7 +61,7 @@ public class MultiConnectionTest { @DatabaseSetup(value = "/META-INF/db/insert2.xml", type = DatabaseOperation.INSERT) @DatabaseSetup(connection = "dataSource2", value = "/META-INF/db/multi-insert2.xml", type = DatabaseOperation.INSERT) public void testInsert() throws Exception { - this.entityAssert.assertValues("fromDbUnit", "fromDbUnit2"); + entityAssert.assertValues("fromDbUnit", "fromDbUnit2"); assertSecondDataSourceValues("fromDbUnitSecondConnection", "fromDbUnitSecondConnection2"); } @@ -72,19 +69,19 @@ public void testInsert() throws Exception { @DatabaseSetup(value = "/META-INF/db/refresh.xml", type = DatabaseOperation.REFRESH) @DatabaseSetup(connection = "dataSource2", value = "/META-INF/db/multi-refresh.xml", type = DatabaseOperation.REFRESH) public void testRefresh() throws Exception { - this.entityAssert.assertValues("addedFromDbUnit", "replacedFromDbUnit"); + entityAssert.assertValues("addedFromDbUnit", "replacedFromDbUnit"); assertSecondDataSourceValues("addedFromDbUnitSecondConnection", "replacedFromDbUnitSecondConnection"); } @Test @ExpectedDatabase(connection = "dataSource2", value = "/META-INF/db/multi-expected.xml") public void testExpected() throws Exception { - JdbcTemplate jdbc = new JdbcTemplate(this.dataSource); + JdbcTemplate jdbc = new JdbcTemplate(dataSource); jdbc.execute("insert into second(id, value) values (200, 'abc')"); } private void assertSecondDataSourceValues(String... expected) { - JdbcTemplate jdbc = new JdbcTemplate(this.dataSource); + JdbcTemplate jdbc = new JdbcTemplate(dataSource); List actual = jdbc.queryForList("select value from second", String.class); assertEquals(new HashSet(Arrays.asList(expected)), new HashSet(actual)); } diff --git a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/operation/DefaultDatabaseOperationLookupTest.java b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/operation/DefaultDatabaseOperationLookupTest.java index 40b2f242..d2218b6b 100644 --- a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/operation/DefaultDatabaseOperationLookupTest.java +++ b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/operation/DefaultDatabaseOperationLookupTest.java @@ -16,9 +16,9 @@ package com.github.springtestdbunit.operation; -import static org.junit.Assert.assertSame; +import static org.junit.jupiter.api.Assertions.assertSame; -import org.junit.Test; +import org.junit.jupiter.api.Test; import com.github.springtestdbunit.annotation.DatabaseOperation; diff --git a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/operation/MicrosoftSqlDatabaseOperationLookupTest.java b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/operation/MicrosoftSqlDatabaseOperationLookupTest.java index f0f852d8..9545cb15 100644 --- a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/operation/MicrosoftSqlDatabaseOperationLookupTest.java +++ b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/operation/MicrosoftSqlDatabaseOperationLookupTest.java @@ -16,10 +16,10 @@ package com.github.springtestdbunit.operation; -import static org.junit.Assert.assertSame; +import static org.junit.jupiter.api.Assertions.assertSame; import org.dbunit.ext.mssql.InsertIdentityOperation; -import org.junit.Test; +import org.junit.jupiter.api.Test; import com.github.springtestdbunit.annotation.DatabaseOperation; diff --git a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/setup/CleanInsertSetupOnClassTest.java b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/setup/CleanInsertSetupOnClassTest.java index 67660efc..faf05aed 100644 --- a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/setup/CleanInsertSetupOnClassTest.java +++ b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/setup/CleanInsertSetupOnClassTest.java @@ -16,12 +16,10 @@ package com.github.springtestdbunit.setup; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; @@ -31,8 +29,7 @@ import com.github.springtestdbunit.config.CoreTestConfiguration; import com.github.springtestdbunit.entity.EntityAssert; -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = CoreTestConfiguration.class) +@SpringJUnitConfig(CoreTestConfiguration.class) @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, TransactionDbUnitTestExecutionListener.class }) @DatabaseSetup(type = DatabaseOperation.CLEAN_INSERT, value = "/META-INF/db/insert.xml") @@ -44,7 +41,7 @@ public class CleanInsertSetupOnClassTest { @Test public void test() throws Exception { - this.entityAssert.assertValues("fromDbUnit"); + entityAssert.assertValues("fromDbUnit"); } } diff --git a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/setup/CleanInsertSetupOnMethodTest.java b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/setup/CleanInsertSetupOnMethodTest.java index 91bf34b3..bcaeffaa 100644 --- a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/setup/CleanInsertSetupOnMethodTest.java +++ b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/setup/CleanInsertSetupOnMethodTest.java @@ -16,12 +16,10 @@ package com.github.springtestdbunit.setup; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; @@ -32,8 +30,7 @@ import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.entity.OtherEntityAssert; -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = CoreTestConfiguration.class) +@SpringJUnitConfig(CoreTestConfiguration.class) @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, TransactionDbUnitTestExecutionListener.class }) @Transactional @@ -48,16 +45,16 @@ public class CleanInsertSetupOnMethodTest { @Test @DatabaseSetup(type = DatabaseOperation.CLEAN_INSERT, value = "/META-INF/db/insert.xml") public void test() throws Exception { - this.entityAssert.assertValues("fromDbUnit"); + entityAssert.assertValues("fromDbUnit"); } @Test @DatabaseSetup(type = DatabaseOperation.CLEAN_INSERT, value = { "/META-INF/db/insert.xml", "/META-INF/db/insert_Other.xml" }) public void testSeveralSetupFiles() throws Exception { - this.entityAssert.assertValues("fromDbUnit"); + entityAssert.assertValues("fromDbUnit"); // OtherSampleEntity is populated using import.sql imitating dirty state of the table - this.otherEntityAssert.assertValues("fromDbUnit"); + otherEntityAssert.assertValues("fromDbUnit"); } } diff --git a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/setup/DeleteAllSetupOnClassTest.java b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/setup/DeleteAllSetupOnClassTest.java index 8bc5e6e9..0ae69665 100644 --- a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/setup/DeleteAllSetupOnClassTest.java +++ b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/setup/DeleteAllSetupOnClassTest.java @@ -16,12 +16,10 @@ package com.github.springtestdbunit.setup; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; @@ -31,8 +29,7 @@ import com.github.springtestdbunit.config.CoreTestConfiguration; import com.github.springtestdbunit.entity.EntityAssert; -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = CoreTestConfiguration.class) +@SpringJUnitConfig(CoreTestConfiguration.class) @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, TransactionDbUnitTestExecutionListener.class }) @Transactional @@ -44,6 +41,7 @@ public class DeleteAllSetupOnClassTest { @Test public void test() throws Exception { - this.entityAssert.assertValues(); + entityAssert.assertValues(); } + } diff --git a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/setup/DeleteAllSetupOnMethodTest.java b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/setup/DeleteAllSetupOnMethodTest.java index ec48488d..38c80db3 100644 --- a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/setup/DeleteAllSetupOnMethodTest.java +++ b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/setup/DeleteAllSetupOnMethodTest.java @@ -16,12 +16,10 @@ package com.github.springtestdbunit.setup; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; @@ -31,8 +29,7 @@ import com.github.springtestdbunit.config.CoreTestConfiguration; import com.github.springtestdbunit.entity.EntityAssert; -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = CoreTestConfiguration.class) +@SpringJUnitConfig(CoreTestConfiguration.class) @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, TransactionDbUnitTestExecutionListener.class }) @Transactional @@ -44,13 +41,13 @@ public class DeleteAllSetupOnMethodTest { @Test @DatabaseSetup(type = DatabaseOperation.DELETE_ALL, value = "/META-INF/db/delete.xml") public void test() throws Exception { - this.entityAssert.assertValues(); + entityAssert.assertValues(); } @Test @DatabaseSetup(type = DatabaseOperation.DELETE_ALL) public void testAllTables() throws Exception { - this.entityAssert.assertValues(); + entityAssert.assertValues(); } } diff --git a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/setup/DeleteSetupOnClassTest.java b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/setup/DeleteSetupOnClassTest.java index 10612fc8..4d267f64 100644 --- a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/setup/DeleteSetupOnClassTest.java +++ b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/setup/DeleteSetupOnClassTest.java @@ -16,12 +16,10 @@ package com.github.springtestdbunit.setup; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; @@ -31,8 +29,7 @@ import com.github.springtestdbunit.config.CoreTestConfiguration; import com.github.springtestdbunit.entity.EntityAssert; -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = CoreTestConfiguration.class) +@SpringJUnitConfig(CoreTestConfiguration.class) @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, TransactionDbUnitTestExecutionListener.class }) @DatabaseSetup(type = DatabaseOperation.DELETE, value = "/META-INF/db/delete.xml") @@ -44,7 +41,7 @@ public class DeleteSetupOnClassTest { @Test public void test() throws Exception { - this.entityAssert.assertValues("existing2"); + entityAssert.assertValues("existing2"); } } diff --git a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/setup/DeleteSetupOnMethodTest.java b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/setup/DeleteSetupOnMethodTest.java index 64c917db..d8d3ee77 100644 --- a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/setup/DeleteSetupOnMethodTest.java +++ b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/setup/DeleteSetupOnMethodTest.java @@ -16,12 +16,10 @@ package com.github.springtestdbunit.setup; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; @@ -31,8 +29,7 @@ import com.github.springtestdbunit.config.CoreTestConfiguration; import com.github.springtestdbunit.entity.EntityAssert; -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = CoreTestConfiguration.class) +@SpringJUnitConfig(CoreTestConfiguration.class) @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, TransactionDbUnitTestExecutionListener.class }) @Transactional @@ -44,7 +41,7 @@ public class DeleteSetupOnMethodTest { @Test @DatabaseSetup(type = DatabaseOperation.DELETE, value = "/META-INF/db/delete.xml") public void test() throws Exception { - this.entityAssert.assertValues("existing2"); + entityAssert.assertValues("existing2"); } } diff --git a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/setup/InsertSetupOnClassTest.java b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/setup/InsertSetupOnClassTest.java index 97d5f945..74d77f71 100644 --- a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/setup/InsertSetupOnClassTest.java +++ b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/setup/InsertSetupOnClassTest.java @@ -16,12 +16,10 @@ package com.github.springtestdbunit.setup; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; @@ -31,8 +29,7 @@ import com.github.springtestdbunit.config.CoreTestConfiguration; import com.github.springtestdbunit.entity.EntityAssert; -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = CoreTestConfiguration.class) +@SpringJUnitConfig(CoreTestConfiguration.class) @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, TransactionDbUnitTestExecutionListener.class }) @DatabaseSetup(type = DatabaseOperation.INSERT, value = "/META-INF/db/insert.xml") @@ -44,7 +41,7 @@ public class InsertSetupOnClassTest { @Test public void test() throws Exception { - this.entityAssert.assertValues("existing1", "existing2", "fromDbUnit"); + entityAssert.assertValues("existing1", "existing2", "fromDbUnit"); } } diff --git a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/setup/InsertSetupOnMethodTest.java b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/setup/InsertSetupOnMethodTest.java index c748f1dc..42cf12ab 100644 --- a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/setup/InsertSetupOnMethodTest.java +++ b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/setup/InsertSetupOnMethodTest.java @@ -16,12 +16,10 @@ package com.github.springtestdbunit.setup; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; @@ -31,8 +29,7 @@ import com.github.springtestdbunit.config.CoreTestConfiguration; import com.github.springtestdbunit.entity.EntityAssert; -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = CoreTestConfiguration.class) +@SpringJUnitConfig(CoreTestConfiguration.class) @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, TransactionDbUnitTestExecutionListener.class }) @Transactional @@ -44,7 +41,7 @@ public class InsertSetupOnMethodTest { @Test @DatabaseSetup(type = DatabaseOperation.INSERT, value = "/META-INF/db/insert.xml") public void test() throws Exception { - this.entityAssert.assertValues("existing1", "existing2", "fromDbUnit"); + entityAssert.assertValues("existing1", "existing2", "fromDbUnit"); } } diff --git a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/setup/MixedSetupOnClassAndMethodTest.java b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/setup/MixedSetupOnClassAndMethodTest.java index e5a6002f..3611e7b9 100644 --- a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/setup/MixedSetupOnClassAndMethodTest.java +++ b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/setup/MixedSetupOnClassAndMethodTest.java @@ -16,12 +16,10 @@ package com.github.springtestdbunit.setup; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; @@ -31,8 +29,7 @@ import com.github.springtestdbunit.config.CoreTestConfiguration; import com.github.springtestdbunit.entity.EntityAssert; -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = CoreTestConfiguration.class) +@SpringJUnitConfig(CoreTestConfiguration.class) @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, TransactionDbUnitTestExecutionListener.class }) @DatabaseSetup("/META-INF/db/insert.xml") @@ -45,13 +42,13 @@ public class MixedSetupOnClassAndMethodTest { @Test @DatabaseSetup(value = "/META-INF/db/insert2.xml", type = DatabaseOperation.INSERT) public void testInsert() throws Exception { - this.entityAssert.assertValues("fromDbUnit", "fromDbUnit2"); + entityAssert.assertValues("fromDbUnit", "fromDbUnit2"); } @Test @DatabaseSetup(type = DatabaseOperation.REFRESH, value = "/META-INF/db/refresh.xml") public void testRefresh() throws Exception { - this.entityAssert.assertValues("addedFromDbUnit", "replacedFromDbUnit"); + entityAssert.assertValues("addedFromDbUnit", "replacedFromDbUnit"); } } diff --git a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/setup/MultipleInsertSetupOnClassTest.java b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/setup/MultipleInsertSetupOnClassTest.java index a9624e30..88698384 100644 --- a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/setup/MultipleInsertSetupOnClassTest.java +++ b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/setup/MultipleInsertSetupOnClassTest.java @@ -16,12 +16,10 @@ package com.github.springtestdbunit.setup; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; @@ -31,8 +29,7 @@ import com.github.springtestdbunit.config.CoreTestConfiguration; import com.github.springtestdbunit.entity.EntityAssert; -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = CoreTestConfiguration.class) +@SpringJUnitConfig(CoreTestConfiguration.class) @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, TransactionDbUnitTestExecutionListener.class }) @DatabaseSetup(type = DatabaseOperation.CLEAN_INSERT, value = { "/META-INF/db/insert.xml", "/META-INF/db/insert2.xml" }) @@ -44,7 +41,7 @@ public class MultipleInsertSetupOnClassTest { @Test public void test() throws Exception { - this.entityAssert.assertValues("fromDbUnit", "fromDbUnit2"); + entityAssert.assertValues("fromDbUnit", "fromDbUnit2"); } } diff --git a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/setup/RefereshSetupOnClassTest.java b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/setup/RefereshSetupOnClassTest.java index 49fd0edb..70045a5d 100644 --- a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/setup/RefereshSetupOnClassTest.java +++ b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/setup/RefereshSetupOnClassTest.java @@ -16,12 +16,10 @@ package com.github.springtestdbunit.setup; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; @@ -31,8 +29,7 @@ import com.github.springtestdbunit.config.CoreTestConfiguration; import com.github.springtestdbunit.entity.EntityAssert; -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = CoreTestConfiguration.class) +@SpringJUnitConfig(CoreTestConfiguration.class) @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, TransactionDbUnitTestExecutionListener.class }) @DatabaseSetup(type = DatabaseOperation.REFRESH, value = "/META-INF/db/refresh.xml") @@ -44,7 +41,7 @@ public class RefereshSetupOnClassTest { @Test public void test() throws Exception { - this.entityAssert.assertValues("existing2", "addedFromDbUnit", "replacedFromDbUnit"); + entityAssert.assertValues("existing2", "addedFromDbUnit", "replacedFromDbUnit"); } } diff --git a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/setup/RefereshSetupOnMethodTest.java b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/setup/RefereshSetupOnMethodTest.java index 43ab7084..ba8a3dbb 100644 --- a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/setup/RefereshSetupOnMethodTest.java +++ b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/setup/RefereshSetupOnMethodTest.java @@ -16,12 +16,10 @@ package com.github.springtestdbunit.setup; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; @@ -31,8 +29,7 @@ import com.github.springtestdbunit.config.CoreTestConfiguration; import com.github.springtestdbunit.entity.EntityAssert; -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = CoreTestConfiguration.class) +@SpringJUnitConfig(CoreTestConfiguration.class) @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, TransactionDbUnitTestExecutionListener.class }) @Transactional @@ -44,7 +41,7 @@ public class RefereshSetupOnMethodTest { @Test @DatabaseSetup(type = DatabaseOperation.REFRESH, value = "/META-INF/db/refresh.xml") public void test() throws Exception { - this.entityAssert.assertValues("existing2", "addedFromDbUnit", "replacedFromDbUnit"); + entityAssert.assertValues("existing2", "addedFromDbUnit", "replacedFromDbUnit"); } } diff --git a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/setup/TruncateSetupOnClassTest.java b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/setup/TruncateSetupOnClassTest.java index b0eb20d8..588bdef3 100644 --- a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/setup/TruncateSetupOnClassTest.java +++ b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/setup/TruncateSetupOnClassTest.java @@ -16,12 +16,10 @@ package com.github.springtestdbunit.setup; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; @@ -31,8 +29,7 @@ import com.github.springtestdbunit.config.CoreTestConfiguration; import com.github.springtestdbunit.entity.EntityAssert; -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = CoreTestConfiguration.class) +@SpringJUnitConfig(CoreTestConfiguration.class) @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, TransactionDbUnitTestExecutionListener.class }) @Transactional @@ -44,7 +41,7 @@ public class TruncateSetupOnClassTest { @Test public void test() throws Exception { - this.entityAssert.assertValues(); + entityAssert.assertValues(); } } diff --git a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/setup/TruncateSetupOnMethodTest.java b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/setup/TruncateSetupOnMethodTest.java index 88530938..33c7f385 100644 --- a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/setup/TruncateSetupOnMethodTest.java +++ b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/setup/TruncateSetupOnMethodTest.java @@ -16,12 +16,10 @@ package com.github.springtestdbunit.setup; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; @@ -31,8 +29,7 @@ import com.github.springtestdbunit.config.CoreTestConfiguration; import com.github.springtestdbunit.entity.EntityAssert; -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = CoreTestConfiguration.class) +@SpringJUnitConfig(CoreTestConfiguration.class) @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, TransactionDbUnitTestExecutionListener.class }) @Transactional @@ -44,13 +41,13 @@ public class TruncateSetupOnMethodTest { @Test @DatabaseSetup(type = DatabaseOperation.TRUNCATE_TABLE, value = "/META-INF/db/delete.xml") public void test() throws Exception { - this.entityAssert.assertValues(); + entityAssert.assertValues(); } @Test @DatabaseSetup(type = DatabaseOperation.TRUNCATE_TABLE) public void testAllTables() throws Exception { - this.entityAssert.assertValues(); + entityAssert.assertValues(); } } diff --git a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/setup/UpdateSetupOnClassTest.java b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/setup/UpdateSetupOnClassTest.java index 42638bf0..0beac2b5 100644 --- a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/setup/UpdateSetupOnClassTest.java +++ b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/setup/UpdateSetupOnClassTest.java @@ -16,12 +16,10 @@ package com.github.springtestdbunit.setup; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; @@ -31,8 +29,7 @@ import com.github.springtestdbunit.config.CoreTestConfiguration; import com.github.springtestdbunit.entity.EntityAssert; -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = CoreTestConfiguration.class) +@SpringJUnitConfig(CoreTestConfiguration.class) @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, TransactionDbUnitTestExecutionListener.class }) @DatabaseSetup(type = DatabaseOperation.UPDATE, value = "/META-INF/db/update.xml") @@ -44,7 +41,7 @@ public class UpdateSetupOnClassTest { @Test public void test() throws Exception { - this.entityAssert.assertValues("existing2", "fromDbUnit"); + entityAssert.assertValues("existing2", "fromDbUnit"); } } diff --git a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/setup/UpdateSetupOnMethodTest.java b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/setup/UpdateSetupOnMethodTest.java index f05c84cf..4474fc18 100644 --- a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/setup/UpdateSetupOnMethodTest.java +++ b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/setup/UpdateSetupOnMethodTest.java @@ -16,12 +16,10 @@ package com.github.springtestdbunit.setup; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; @@ -31,8 +29,7 @@ import com.github.springtestdbunit.config.CoreTestConfiguration; import com.github.springtestdbunit.entity.EntityAssert; -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = CoreTestConfiguration.class) +@SpringJUnitConfig(CoreTestConfiguration.class) @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, TransactionDbUnitTestExecutionListener.class }) @Transactional @@ -44,7 +41,7 @@ public class UpdateSetupOnMethodTest { @Test @DatabaseSetup(type = DatabaseOperation.UPDATE, value = "/META-INF/db/update.xml") public void test() throws Exception { - this.entityAssert.assertValues("existing2", "fromDbUnit"); + entityAssert.assertValues("existing2", "fromDbUnit"); } } diff --git a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/teardown/CleanInsertTearDownOnClass.java b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/teardown/CleanInsertTearDownOnClass.java index 67543547..305a9d0c 100644 --- a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/teardown/CleanInsertTearDownOnClass.java +++ b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/teardown/CleanInsertTearDownOnClass.java @@ -16,12 +16,10 @@ package com.github.springtestdbunit.teardown; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; @@ -31,8 +29,7 @@ import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.AfterTearDownDbUnitTestExecutionListener; -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = CoreTestConfiguration.class) +@SpringJUnitConfig(CoreTestConfiguration.class) @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, AfterTearDownDbUnitTestExecutionListener.class }) @DatabaseTearDown(type = DatabaseOperation.CLEAN_INSERT, value = "/META-INF/db/insert.xml") @@ -44,11 +41,11 @@ public class CleanInsertTearDownOnClass { @Test public void test() throws Exception { - this.entityAssert.assertValues("existing1", "existing2"); + entityAssert.assertValues("existing1", "existing2"); } public void afterTest() throws Exception { - this.entityAssert.assertValues("fromDbUnit"); + entityAssert.assertValues("fromDbUnit"); } } diff --git a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/teardown/CleanInsertTearDownOnMethod.java b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/teardown/CleanInsertTearDownOnMethod.java index e93d0860..d210a759 100644 --- a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/teardown/CleanInsertTearDownOnMethod.java +++ b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/teardown/CleanInsertTearDownOnMethod.java @@ -16,12 +16,10 @@ package com.github.springtestdbunit.teardown; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; @@ -31,8 +29,7 @@ import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.AfterTearDownDbUnitTestExecutionListener; -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = CoreTestConfiguration.class) +@SpringJUnitConfig(CoreTestConfiguration.class) @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, AfterTearDownDbUnitTestExecutionListener.class }) @Transactional @@ -44,11 +41,11 @@ public class CleanInsertTearDownOnMethod { @Test @DatabaseTearDown(type = DatabaseOperation.CLEAN_INSERT, value = "/META-INF/db/insert.xml") public void test() throws Exception { - this.entityAssert.assertValues("existing1", "existing2"); + entityAssert.assertValues("existing1", "existing2"); } public void afterTest() throws Exception { - this.entityAssert.assertValues("fromDbUnit"); + entityAssert.assertValues("fromDbUnit"); } } diff --git a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/teardown/DeleteAllTearDownOnClass.java b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/teardown/DeleteAllTearDownOnClass.java index 74ba02aa..8a0c01a0 100644 --- a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/teardown/DeleteAllTearDownOnClass.java +++ b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/teardown/DeleteAllTearDownOnClass.java @@ -16,12 +16,10 @@ package com.github.springtestdbunit.teardown; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; @@ -32,8 +30,7 @@ import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.AfterTearDownDbUnitTestExecutionListener; -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = CoreTestConfiguration.class) +@SpringJUnitConfig(CoreTestConfiguration.class) @DbUnitConfiguration(databaseConnection = "databaseDataSourceConnectionFactory") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, AfterTearDownDbUnitTestExecutionListener.class }) @@ -46,11 +43,11 @@ public class DeleteAllTearDownOnClass { @Test public void test() { - this.entityAssert.assertValues("existing1", "existing2"); + entityAssert.assertValues("existing1", "existing2"); } public void afterTest() { - this.entityAssert.assertValues("existing2"); + entityAssert.assertValues("existing2"); } } diff --git a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/teardown/DeleteAllTearDownOnMethod.java b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/teardown/DeleteAllTearDownOnMethod.java index a87ece92..a87c1618 100644 --- a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/teardown/DeleteAllTearDownOnMethod.java +++ b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/teardown/DeleteAllTearDownOnMethod.java @@ -16,12 +16,10 @@ package com.github.springtestdbunit.teardown; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; @@ -31,8 +29,7 @@ import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.AfterTearDownDbUnitTestExecutionListener; -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = CoreTestConfiguration.class) +@SpringJUnitConfig(CoreTestConfiguration.class) @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, AfterTearDownDbUnitTestExecutionListener.class }) @Transactional @@ -44,11 +41,11 @@ public class DeleteAllTearDownOnMethod { @Test @DatabaseTearDown(type = DatabaseOperation.DELETE, value = "/META-INF/db/delete.xml") public void test() throws Exception { - this.entityAssert.assertValues("existing1", "existing2"); + entityAssert.assertValues("existing1", "existing2"); } public void afterTest() throws Exception { - this.entityAssert.assertValues("existing2"); + entityAssert.assertValues("existing2"); } } diff --git a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/teardown/DeleteTearDownOnClass.java b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/teardown/DeleteTearDownOnClass.java index cd8e7f66..5aff960d 100644 --- a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/teardown/DeleteTearDownOnClass.java +++ b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/teardown/DeleteTearDownOnClass.java @@ -16,12 +16,10 @@ package com.github.springtestdbunit.teardown; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; @@ -31,8 +29,7 @@ import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.AfterTearDownDbUnitTestExecutionListener; -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = CoreTestConfiguration.class) +@SpringJUnitConfig(CoreTestConfiguration.class) @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, AfterTearDownDbUnitTestExecutionListener.class }) @DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/META-INF/db/delete.xml") @@ -44,11 +41,11 @@ public class DeleteTearDownOnClass { @Test public void test() throws Exception { - this.entityAssert.assertValues("existing1", "existing2"); + entityAssert.assertValues("existing1", "existing2"); } public void afterTest() throws Exception { - this.entityAssert.assertValues(); + entityAssert.assertValues(); } } diff --git a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/teardown/DeleteTearDownOnMethod.java b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/teardown/DeleteTearDownOnMethod.java index f6f2ad7b..ca1c7012 100644 --- a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/teardown/DeleteTearDownOnMethod.java +++ b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/teardown/DeleteTearDownOnMethod.java @@ -16,12 +16,10 @@ package com.github.springtestdbunit.teardown; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; @@ -31,8 +29,7 @@ import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.AfterTearDownDbUnitTestExecutionListener; -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = CoreTestConfiguration.class) +@SpringJUnitConfig(CoreTestConfiguration.class) @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, AfterTearDownDbUnitTestExecutionListener.class }) @Transactional @@ -44,11 +41,11 @@ public class DeleteTearDownOnMethod { @Test @DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/META-INF/db/delete.xml") public void test() throws Exception { - this.entityAssert.assertValues("existing1", "existing2"); + entityAssert.assertValues("existing1", "existing2"); } public void afterTest() throws Exception { - this.entityAssert.assertValues(); + entityAssert.assertValues(); } } diff --git a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/teardown/InsertTearDownOnClass.java b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/teardown/InsertTearDownOnClass.java index ac3bbda9..d1ac7c24 100644 --- a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/teardown/InsertTearDownOnClass.java +++ b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/teardown/InsertTearDownOnClass.java @@ -16,12 +16,10 @@ package com.github.springtestdbunit.teardown; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; @@ -31,8 +29,7 @@ import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.AfterTearDownDbUnitTestExecutionListener; -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = CoreTestConfiguration.class) +@SpringJUnitConfig(CoreTestConfiguration.class) @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, AfterTearDownDbUnitTestExecutionListener.class }) @DatabaseTearDown(type = DatabaseOperation.INSERT, value = "/META-INF/db/insert.xml") @@ -44,11 +41,11 @@ public class InsertTearDownOnClass { @Test public void test() throws Exception { - this.entityAssert.assertValues("existing1", "existing2"); + entityAssert.assertValues("existing1", "existing2"); } public void afterTest() throws Exception { - this.entityAssert.assertValues("existing1", "existing2", "fromDbUnit"); + entityAssert.assertValues("existing1", "existing2", "fromDbUnit"); } } diff --git a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/teardown/InsertTearDownOnMethod.java b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/teardown/InsertTearDownOnMethod.java index 3ee5ce44..4d6e0429 100644 --- a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/teardown/InsertTearDownOnMethod.java +++ b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/teardown/InsertTearDownOnMethod.java @@ -16,12 +16,10 @@ package com.github.springtestdbunit.teardown; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; @@ -31,8 +29,7 @@ import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.AfterTearDownDbUnitTestExecutionListener; -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = CoreTestConfiguration.class) +@SpringJUnitConfig(CoreTestConfiguration.class) @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, AfterTearDownDbUnitTestExecutionListener.class }) @Transactional @@ -44,11 +41,11 @@ public class InsertTearDownOnMethod { @Test @DatabaseTearDown(type = DatabaseOperation.INSERT, value = "/META-INF/db/insert.xml") public void test() throws Exception { - this.entityAssert.assertValues("existing1", "existing2"); + entityAssert.assertValues("existing1", "existing2"); } public void afterTest() throws Exception { - this.entityAssert.assertValues("existing1", "existing2", "fromDbUnit"); + entityAssert.assertValues("existing1", "existing2", "fromDbUnit"); } } diff --git a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/teardown/MixedTearDownOnClassAndMethodTest.java b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/teardown/MixedTearDownOnClassAndMethodTest.java index e44a5a21..41d5cef7 100644 --- a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/teardown/MixedTearDownOnClassAndMethodTest.java +++ b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/teardown/MixedTearDownOnClassAndMethodTest.java @@ -16,12 +16,10 @@ package com.github.springtestdbunit.teardown; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; @@ -31,8 +29,7 @@ import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.AfterTearDownDbUnitTestExecutionListener; -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = CoreTestConfiguration.class) +@SpringJUnitConfig(CoreTestConfiguration.class) @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, AfterTearDownDbUnitTestExecutionListener.class }) @DatabaseTearDown("/META-INF/db/insert.xml") @@ -45,10 +42,10 @@ public class MixedTearDownOnClassAndMethodTest { @Test @DatabaseTearDown(value = "/META-INF/db/insert2.xml", type = DatabaseOperation.INSERT) public void testInsert() throws Exception { - this.entityAssert.assertValues("existing1", "existing2"); + entityAssert.assertValues("existing1", "existing2"); } public void afterTest() throws Exception { - this.entityAssert.assertValues("fromDbUnit", "fromDbUnit2"); + entityAssert.assertValues("fromDbUnit", "fromDbUnit2"); } } diff --git a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/teardown/MultipleInsertTearDownOnClassTest.java b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/teardown/MultipleInsertTearDownOnClassTest.java index 6896c1c5..8fc64740 100644 --- a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/teardown/MultipleInsertTearDownOnClassTest.java +++ b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/teardown/MultipleInsertTearDownOnClassTest.java @@ -16,12 +16,10 @@ package com.github.springtestdbunit.teardown; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; @@ -31,8 +29,7 @@ import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.AfterTearDownDbUnitTestExecutionListener; -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = CoreTestConfiguration.class) +@SpringJUnitConfig(CoreTestConfiguration.class) @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, AfterTearDownDbUnitTestExecutionListener.class }) @DatabaseTearDown(type = DatabaseOperation.CLEAN_INSERT, value = { "/META-INF/db/insert.xml", @@ -45,10 +42,10 @@ public class MultipleInsertTearDownOnClassTest { @Test public void test() throws Exception { - this.entityAssert.assertValues("existing1", "existing2"); + entityAssert.assertValues("existing1", "existing2"); } public void afterTest() throws Exception { - this.entityAssert.assertValues("fromDbUnit", "fromDbUnit2"); + entityAssert.assertValues("fromDbUnit", "fromDbUnit2"); } } diff --git a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/teardown/RefreshTearDownOnClass.java b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/teardown/RefreshTearDownOnClass.java index 3ce19e3c..b955e6d1 100644 --- a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/teardown/RefreshTearDownOnClass.java +++ b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/teardown/RefreshTearDownOnClass.java @@ -16,12 +16,10 @@ package com.github.springtestdbunit.teardown; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; @@ -31,8 +29,7 @@ import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.AfterTearDownDbUnitTestExecutionListener; -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = CoreTestConfiguration.class) +@SpringJUnitConfig(CoreTestConfiguration.class) @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, AfterTearDownDbUnitTestExecutionListener.class }) @DatabaseTearDown(type = DatabaseOperation.REFRESH, value = "/META-INF/db/refresh.xml") @@ -44,11 +41,11 @@ public class RefreshTearDownOnClass { @Test public void test() throws Exception { - this.entityAssert.assertValues("existing1", "existing2"); + entityAssert.assertValues("existing1", "existing2"); } public void afterTest() throws Exception { - this.entityAssert.assertValues("addedFromDbUnit", "existing2", "replacedFromDbUnit"); + entityAssert.assertValues("addedFromDbUnit", "existing2", "replacedFromDbUnit"); } } diff --git a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/teardown/RefreshTearDownOnMethod.java b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/teardown/RefreshTearDownOnMethod.java index a02d00f2..1f2d93b4 100644 --- a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/teardown/RefreshTearDownOnMethod.java +++ b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/teardown/RefreshTearDownOnMethod.java @@ -16,12 +16,10 @@ package com.github.springtestdbunit.teardown; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; @@ -31,8 +29,7 @@ import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.AfterTearDownDbUnitTestExecutionListener; -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = CoreTestConfiguration.class) +@SpringJUnitConfig(CoreTestConfiguration.class) @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, AfterTearDownDbUnitTestExecutionListener.class }) @Transactional @@ -44,11 +41,11 @@ public class RefreshTearDownOnMethod { @Test @DatabaseTearDown(type = DatabaseOperation.REFRESH, value = "/META-INF/db/refresh.xml") public void test() throws Exception { - this.entityAssert.assertValues("existing1", "existing2"); + entityAssert.assertValues("existing1", "existing2"); } public void afterTest() throws Exception { - this.entityAssert.assertValues("addedFromDbUnit", "existing2", "replacedFromDbUnit"); + entityAssert.assertValues("addedFromDbUnit", "existing2", "replacedFromDbUnit"); } } diff --git a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/teardown/TruncateTearDownOnClass.java b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/teardown/TruncateTearDownOnClass.java index 5feb6fff..7a04d00e 100644 --- a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/teardown/TruncateTearDownOnClass.java +++ b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/teardown/TruncateTearDownOnClass.java @@ -16,12 +16,10 @@ package com.github.springtestdbunit.teardown; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; @@ -31,8 +29,7 @@ import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.AfterTearDownDbUnitTestExecutionListener; -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = CoreTestConfiguration.class) +@SpringJUnitConfig(CoreTestConfiguration.class) @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, AfterTearDownDbUnitTestExecutionListener.class }) @DatabaseTearDown(type = DatabaseOperation.TRUNCATE_TABLE, value = "/META-INF/db/delete.xml") @@ -44,11 +41,11 @@ public class TruncateTearDownOnClass { @Test public void test() throws Exception { - this.entityAssert.assertValues("existing1", "existing2"); + entityAssert.assertValues("existing1", "existing2"); } public void afterTest() throws Exception { - this.entityAssert.assertValues(); + entityAssert.assertValues(); } } diff --git a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/teardown/TruncateTearDownOnMethod.java b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/teardown/TruncateTearDownOnMethod.java index 29bc53e6..178c5b60 100644 --- a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/teardown/TruncateTearDownOnMethod.java +++ b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/teardown/TruncateTearDownOnMethod.java @@ -16,12 +16,10 @@ package com.github.springtestdbunit.teardown; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; @@ -31,8 +29,7 @@ import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.AfterTearDownDbUnitTestExecutionListener; -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = CoreTestConfiguration.class) +@SpringJUnitConfig(CoreTestConfiguration.class) @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, AfterTearDownDbUnitTestExecutionListener.class }) @Transactional @@ -44,11 +41,11 @@ public class TruncateTearDownOnMethod { @Test @DatabaseTearDown(type = DatabaseOperation.TRUNCATE_TABLE, value = "/META-INF/db/delete.xml") public void test() throws Exception { - this.entityAssert.assertValues("existing1", "existing2"); + entityAssert.assertValues("existing1", "existing2"); } public void afterTest() throws Exception { - this.entityAssert.assertValues(); + entityAssert.assertValues(); } } diff --git a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/teardown/UpdateTearDownOnClass.java b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/teardown/UpdateTearDownOnClass.java index 145a6ff4..6c4dcf59 100644 --- a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/teardown/UpdateTearDownOnClass.java +++ b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/teardown/UpdateTearDownOnClass.java @@ -16,12 +16,10 @@ package com.github.springtestdbunit.teardown; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; @@ -31,8 +29,7 @@ import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.AfterTearDownDbUnitTestExecutionListener; -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = CoreTestConfiguration.class) +@SpringJUnitConfig(CoreTestConfiguration.class) @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, AfterTearDownDbUnitTestExecutionListener.class }) @DatabaseTearDown(type = DatabaseOperation.UPDATE, value = "/META-INF/db/update.xml") @@ -44,11 +41,11 @@ public class UpdateTearDownOnClass { @Test public void test() throws Exception { - this.entityAssert.assertValues("existing1", "existing2"); + entityAssert.assertValues("existing1", "existing2"); } public void afterTest() throws Exception { - this.entityAssert.assertValues("existing2", "fromDbUnit"); + entityAssert.assertValues("existing2", "fromDbUnit"); } } diff --git a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/teardown/UpdateTearDownOnMethod.java b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/teardown/UpdateTearDownOnMethod.java index ded85ec5..f7fb40cf 100644 --- a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/teardown/UpdateTearDownOnMethod.java +++ b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/teardown/UpdateTearDownOnMethod.java @@ -16,12 +16,10 @@ package com.github.springtestdbunit.teardown; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; @@ -31,8 +29,7 @@ import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.AfterTearDownDbUnitTestExecutionListener; -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = CoreTestConfiguration.class) +@SpringJUnitConfig(CoreTestConfiguration.class) @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, AfterTearDownDbUnitTestExecutionListener.class }) @Transactional @@ -44,11 +41,11 @@ public class UpdateTearDownOnMethod { @Test @DatabaseTearDown(type = DatabaseOperation.UPDATE, value = "/META-INF/db/update.xml") public void test() throws Exception { - this.entityAssert.assertValues("existing1", "existing2"); + entityAssert.assertValues("existing1", "existing2"); } public void afterTest() throws Exception { - this.entityAssert.assertValues("existing2", "fromDbUnit"); + entityAssert.assertValues("existing2", "fromDbUnit"); } } diff --git a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/testutils/ExtendedTestContextManager.java b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/testutils/ExtendedTestContextManager.java index 6dc44771..9893ea57 100644 --- a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/testutils/ExtendedTestContextManager.java +++ b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/testutils/ExtendedTestContextManager.java @@ -36,11 +36,11 @@ public ExtendedTestContextManager(Class testClass) throws Exception { getTestContext().markApplicationContextDirty(HierarchyMode.CURRENT_LEVEL); Constructor constructor = testClass.getDeclaredConstructor(); constructor.setAccessible(true); - this.testInstance = constructor.newInstance(); + testInstance = constructor.newInstance(); } public void prepareTestInstance() throws Exception { - prepareTestInstance(this.testInstance); + prepareTestInstance(testInstance); } public Object getTestContextAttribute(String name) { diff --git a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/testutils/MustFailDbUnitTestExecutionListener.java b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/testutils/MustFailDbUnitTestExecutionListener.java index 96c66fa5..6df7bdaa 100644 --- a/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/testutils/MustFailDbUnitTestExecutionListener.java +++ b/spring-test-dbunit-core/src/test/java/com/github/springtestdbunit/testutils/MustFailDbUnitTestExecutionListener.java @@ -16,7 +16,8 @@ package com.github.springtestdbunit.testutils; -import org.junit.Assert; +import static org.junit.jupiter.api.Assertions.assertNotNull; + import org.springframework.test.context.TestContext; import com.github.springtestdbunit.TransactionDbUnitTestExecutionListener; @@ -36,7 +37,7 @@ public void afterTestMethod(TestContext testContext) throws Exception { } catch (Throwable ex) { caught = ex; } - Assert.assertNotNull("Test did not fail", caught); + assertNotNull(caught, "Test did not fail"); } } diff --git a/spring-test-dbunit-sample/src/test/java/com/github/springtestdbunit/sample/service/PersonServiceTest.java b/spring-test-dbunit-sample/src/test/java/com/github/springtestdbunit/sample/service/PersonServiceTest.java index e51d9b91..1d0543ea 100644 --- a/spring-test-dbunit-sample/src/test/java/com/github/springtestdbunit/sample/service/PersonServiceTest.java +++ b/spring-test-dbunit-sample/src/test/java/com/github/springtestdbunit/sample/service/PersonServiceTest.java @@ -15,17 +15,15 @@ */ package com.github.springtestdbunit.sample.service; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.util.List; import javax.annotation.Resource; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.test.context.ContextConfiguration; +import org.junit.jupiter.api.Test; import org.springframework.test.context.TestExecutionListeners; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import com.github.springtestdbunit.DbUnitTestExecutionListener; @@ -34,8 +32,7 @@ import com.github.springtestdbunit.sample.config.SampleTestConfiguration; import com.github.springtestdbunit.sample.entity.Person; -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = SampleTestConfiguration.class) +@SpringJUnitConfig(SampleTestConfiguration.class) @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, DbUnitTestExecutionListener.class }) public class PersonServiceTest { @@ -45,7 +42,7 @@ public class PersonServiceTest { @Test @DatabaseSetup("sampleData.xml") public void testFind() throws Exception { - List personList = this.personService.find("hil"); + List personList = personService.find("hil"); assertEquals(1, personList.size()); assertEquals("Phillip", personList.get(0).getFirstName()); } @@ -54,7 +51,7 @@ public void testFind() throws Exception { @DatabaseSetup("sampleData.xml") @ExpectedDatabase("expectedData.xml") public void testRemove() throws Exception { - this.personService.remove(1); + personService.remove(1); } } diff --git a/spring-test-dbunit-test/pom.xml b/spring-test-dbunit-test/pom.xml index 063db53b..0da3b50f 100644 --- a/spring-test-dbunit-test/pom.xml +++ b/spring-test-dbunit-test/pom.xml @@ -66,10 +66,6 @@ com.zaxxer HikariCP - - junit - junit - org.hibernate hibernate-core @@ -78,6 +74,18 @@ org.hsqldb hsqldb + + org.junit.jupiter + junit-jupiter-api + + + org.junit.jupiter + junit-jupiter-engine + + + org.junit.jupiter + junit-jupiter-params + org.mockito mockito-core From fd703f06cb6245644efc94a479ea038f86ae4ebd Mon Sep 17 00:00:00 2001 From: Paul Podgorsek Date: Tue, 5 Feb 2019 08:48:33 +0000 Subject: [PATCH 2/2] Issue #6 - Add support for JUnit 5 * Updated the README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 438597f7..a8f49fa0 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ The dependencies used are: * Spring Framework 5 * DBUnit 2.6 -* JUnit 4 +* JUnit 5 ## How to use this project