diff --git a/spring-orm/src/test/java/org/springframework/orm/jpa/AbstractContainerEntityManagerFactoryIntegrationTests.java b/spring-orm/src/test/java/org/springframework/orm/jpa/AbstractContainerEntityManagerFactoryIntegrationTests.java index 2718bcc4e49..718f3d6e8e0 100644 --- a/spring-orm/src/test/java/org/springframework/orm/jpa/AbstractContainerEntityManagerFactoryIntegrationTests.java +++ b/spring-orm/src/test/java/org/springframework/orm/jpa/AbstractContainerEntityManagerFactoryIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,6 +18,7 @@ package org.springframework.orm.jpa; import java.lang.reflect.Proxy; import java.util.List; + import javax.persistence.EntityManager; import javax.persistence.EntityNotFoundException; import javax.persistence.FlushModeType; @@ -144,7 +145,7 @@ public abstract class AbstractContainerEntityManagerFactoryIntegrationTests protected final void insertPerson(String firstName) { String INSERT_PERSON = "INSERT INTO PERSON (ID, FIRST_NAME, LAST_NAME) VALUES (?, ?, ?)"; - simpleJdbcTemplate.update(INSERT_PERSON, 1, firstName, "Blair"); + jdbcTemplate.update(INSERT_PERSON, 1, firstName, "Blair"); } public void testEntityManagerProxyRejectsProgrammaticTxManagement() { diff --git a/spring-orm/src/test/java/org/springframework/orm/jpa/AbstractEntityManagerFactoryIntegrationTests.java b/spring-orm/src/test/java/org/springframework/orm/jpa/AbstractEntityManagerFactoryIntegrationTests.java index 84ac09fd5fe..90f5ec57419 100644 --- a/spring-orm/src/test/java/org/springframework/orm/jpa/AbstractEntityManagerFactoryIntegrationTests.java +++ b/spring-orm/src/test/java/org/springframework/orm/jpa/AbstractEntityManagerFactoryIntegrationTests.java @@ -26,6 +26,7 @@ import org.springframework.transaction.support.TransactionSynchronizationManager * @author Rod Johnson * @author Juergen Hoeller */ +@SuppressWarnings("deprecation") public abstract class AbstractEntityManagerFactoryIntegrationTests extends AbstractJpaTests { public static final String[] ECLIPSELINK_CONFIG_LOCATIONS = new String[] { diff --git a/spring-orm/src/test/java/org/springframework/orm/jpa/ApplicationManagedEntityManagerIntegrationTests.java b/spring-orm/src/test/java/org/springframework/orm/jpa/ApplicationManagedEntityManagerIntegrationTests.java index d98197ff67d..2593604cb93 100644 --- a/spring-orm/src/test/java/org/springframework/orm/jpa/ApplicationManagedEntityManagerIntegrationTests.java +++ b/spring-orm/src/test/java/org/springframework/orm/jpa/ApplicationManagedEntityManagerIntegrationTests.java @@ -35,6 +35,7 @@ import org.springframework.transaction.annotation.Transactional; * @author Rod Johnson * @since 2.0 */ +@SuppressWarnings("deprecation") public class ApplicationManagedEntityManagerIntegrationTests extends AbstractEntityManagerFactoryIntegrationTests { @NotTransactional diff --git a/spring-orm/src/test/java/org/springframework/orm/jpa/ContainerManagedEntityManagerIntegrationTests.java b/spring-orm/src/test/java/org/springframework/orm/jpa/ContainerManagedEntityManagerIntegrationTests.java index 844f41bdbcb..51f5de0b33e 100644 --- a/spring-orm/src/test/java/org/springframework/orm/jpa/ContainerManagedEntityManagerIntegrationTests.java +++ b/spring-orm/src/test/java/org/springframework/orm/jpa/ContainerManagedEntityManagerIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -36,6 +36,7 @@ import org.springframework.test.annotation.NotTransactional; * @author Rod Johnson * @since 2.0 */ +@SuppressWarnings("deprecation") public class ContainerManagedEntityManagerIntegrationTests extends AbstractEntityManagerFactoryIntegrationTests { @NotTransactional diff --git a/spring-orm/src/test/java/org/springframework/orm/jpa/eclipselink/EclipseLinkEntityManagerFactoryIntegrationTests.java b/spring-orm/src/test/java/org/springframework/orm/jpa/eclipselink/EclipseLinkEntityManagerFactoryIntegrationTests.java index f621f7ea67f..129c4cba6ce 100644 --- a/spring-orm/src/test/java/org/springframework/orm/jpa/eclipselink/EclipseLinkEntityManagerFactoryIntegrationTests.java +++ b/spring-orm/src/test/java/org/springframework/orm/jpa/eclipselink/EclipseLinkEntityManagerFactoryIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,6 +26,7 @@ import org.springframework.orm.jpa.EntityManagerFactoryInfo; * * @author Juergen Hoeller */ +@SuppressWarnings("deprecation") public class EclipseLinkEntityManagerFactoryIntegrationTests extends AbstractContainerEntityManagerFactoryIntegrationTests { @Override diff --git a/spring-orm/src/test/java/org/springframework/orm/jpa/hibernate/HibernateEntityManagerFactoryIntegrationTests.java b/spring-orm/src/test/java/org/springframework/orm/jpa/hibernate/HibernateEntityManagerFactoryIntegrationTests.java index 3a6b77b0d69..daf5b26e00a 100644 --- a/spring-orm/src/test/java/org/springframework/orm/jpa/hibernate/HibernateEntityManagerFactoryIntegrationTests.java +++ b/spring-orm/src/test/java/org/springframework/orm/jpa/hibernate/HibernateEntityManagerFactoryIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,6 +35,7 @@ import org.springframework.test.annotation.IfProfileValue; */ // Essentially @Ignore-d since AnnotationBeanConfigurerAspect cannot be found @IfProfileValue(name="test-group", value="broken") +@SuppressWarnings("deprecation") public class HibernateEntityManagerFactoryIntegrationTests extends AbstractContainerEntityManagerFactoryIntegrationTests { diff --git a/spring-orm/src/test/java/org/springframework/orm/jpa/hibernate/HibernateMultiEntityManagerFactoryIntegrationTests.java b/spring-orm/src/test/java/org/springframework/orm/jpa/hibernate/HibernateMultiEntityManagerFactoryIntegrationTests.java index 8e66b709713..b26d6c45654 100644 --- a/spring-orm/src/test/java/org/springframework/orm/jpa/hibernate/HibernateMultiEntityManagerFactoryIntegrationTests.java +++ b/spring-orm/src/test/java/org/springframework/orm/jpa/hibernate/HibernateMultiEntityManagerFactoryIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,6 +26,7 @@ import org.springframework.orm.jpa.AbstractContainerEntityManagerFactoryIntegrat * * @author Juergen Hoeller */ +@SuppressWarnings("deprecation") public class HibernateMultiEntityManagerFactoryIntegrationTests extends AbstractContainerEntityManagerFactoryIntegrationTests { diff --git a/spring-orm/src/test/java/org/springframework/orm/jpa/openjpa/OpenJpaEntityManagerFactoryIntegrationTests.java b/spring-orm/src/test/java/org/springframework/orm/jpa/openjpa/OpenJpaEntityManagerFactoryIntegrationTests.java index e823e57a32f..4f491baba7a 100644 --- a/spring-orm/src/test/java/org/springframework/orm/jpa/openjpa/OpenJpaEntityManagerFactoryIntegrationTests.java +++ b/spring-orm/src/test/java/org/springframework/orm/jpa/openjpa/OpenJpaEntityManagerFactoryIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,6 +37,7 @@ import org.springframework.transaction.support.TransactionTemplate; * * @author Costin Leau */ +@SuppressWarnings("deprecation") public class OpenJpaEntityManagerFactoryIntegrationTests extends AbstractContainerEntityManagerFactoryIntegrationTests { @Override diff --git a/spring-orm/src/test/java/org/springframework/orm/jpa/support/PersistenceInjectionIntegrationTests.java b/spring-orm/src/test/java/org/springframework/orm/jpa/support/PersistenceInjectionIntegrationTests.java index 5c598e00c99..4e708c81fb6 100644 --- a/spring-orm/src/test/java/org/springframework/orm/jpa/support/PersistenceInjectionIntegrationTests.java +++ b/spring-orm/src/test/java/org/springframework/orm/jpa/support/PersistenceInjectionIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2007 the original author or authors. + * Copyright 2002-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,6 +27,7 @@ import org.springframework.orm.jpa.support.PersistenceInjectionTests.DefaultPubl * @author Rod Johnson * @author Juergen Hoeller */ +@SuppressWarnings("deprecation") public class PersistenceInjectionIntegrationTests extends AbstractEntityManagerFactoryIntegrationTests { @Autowired diff --git a/spring-orm/src/test/java/org/springframework/test/annotation/AbstractAnnotationAwareTransactionalTests.java b/spring-orm/src/test/java/org/springframework/test/annotation/AbstractAnnotationAwareTransactionalTests.java index 03a76601538..d1808d94493 100644 --- a/spring-orm/src/test/java/org/springframework/test/annotation/AbstractAnnotationAwareTransactionalTests.java +++ b/spring-orm/src/test/java/org/springframework/test/annotation/AbstractAnnotationAwareTransactionalTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,12 +20,9 @@ import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.util.Map; -import javax.sql.DataSource; - import junit.framework.AssertionFailedError; import org.springframework.context.ApplicationContext; -import org.springframework.jdbc.core.simple.SimpleJdbcTemplate; import org.springframework.test.AbstractTransactionalDataSourceSpringContextTests; import org.springframework.transaction.TransactionDefinition; import org.springframework.transaction.annotation.AnnotationTransactionAttributeSource; @@ -35,8 +32,8 @@ import org.springframework.util.Assert; /** *

* Java 5 specific subclass of - * {@link AbstractTransactionalDataSourceSpringContextTests}, exposing a - * {@link SimpleJdbcTemplate} and obeying annotations for transaction control. + * {@link AbstractTransactionalDataSourceSpringContextTests}, obeying annotations + * for transaction control. *

*

* For example, test methods can be annotated with the regular Spring @@ -74,8 +71,6 @@ import org.springframework.util.Assert; public abstract class AbstractAnnotationAwareTransactionalTests extends AbstractTransactionalDataSourceSpringContextTests { - protected SimpleJdbcTemplate simpleJdbcTemplate; - private final TransactionAttributeSource transactionAttributeSource = new AnnotationTransactionAttributeSource(); /** @@ -109,13 +104,6 @@ public abstract class AbstractAnnotationAwareTransactionalTests extends } - @Override - public void setDataSource(DataSource dataSource) { - super.setDataSource(dataSource); - // JdbcTemplate will be identically configured - this.simpleJdbcTemplate = new SimpleJdbcTemplate(this.jdbcTemplate); - } - /** * Search for a unique {@link ProfileValueSource} in the supplied * {@link ApplicationContext}. If found, the diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/AbstractTransactionalSpringRunnerTests.java b/spring-test/src/test/java/org/springframework/test/context/junit4/AbstractTransactionalSpringRunnerTests.java index e5c0b7bdf85..532ef517d02 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit4/AbstractTransactionalSpringRunnerTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit4/AbstractTransactionalSpringRunnerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,7 +17,7 @@ package org.springframework.test.context.junit4; import org.springframework.dao.DataAccessException; -import org.springframework.jdbc.core.simple.SimpleJdbcTemplate; +import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.test.context.ContextConfiguration; import org.springframework.transaction.annotation.Transactional; @@ -31,7 +31,6 @@ import org.springframework.transaction.annotation.Transactional; * @see MethodLevelTransactionalSpringRunnerTests * @see Transactional */ -@SuppressWarnings("deprecation") @ContextConfiguration("transactionalTests-context.xml") public abstract class AbstractTransactionalSpringRunnerTests { @@ -43,29 +42,29 @@ public abstract class AbstractTransactionalSpringRunnerTests { protected static final String YODA = "yoda"; - protected static int clearPersonTable(SimpleJdbcTemplate simpleJdbcTemplate) { - return simpleJdbcTemplate.update("DELETE FROM person"); + protected static int clearPersonTable(JdbcTemplate jdbcTemplate) { + return jdbcTemplate.update("DELETE FROM person"); } - protected static void createPersonTable(SimpleJdbcTemplate simpleJdbcTemplate) { + protected static void createPersonTable(JdbcTemplate jdbcTemplate) { try { - simpleJdbcTemplate.update("CREATE TABLE person (name VARCHAR(20) NOT NULL, PRIMARY KEY(name))"); + jdbcTemplate.update("CREATE TABLE person (name VARCHAR(20) NOT NULL, PRIMARY KEY(name))"); } catch (DataAccessException dae) { // ignore } } - protected static int countRowsInPersonTable(SimpleJdbcTemplate simpleJdbcTemplate) { - return simpleJdbcTemplate.queryForInt("SELECT COUNT(0) FROM person"); + protected static int countRowsInPersonTable(JdbcTemplate jdbcTemplate) { + return jdbcTemplate.queryForObject("SELECT COUNT(0) FROM person", Integer.class); } - protected static int addPerson(SimpleJdbcTemplate simpleJdbcTemplate, String name) { - return simpleJdbcTemplate.update("INSERT INTO person VALUES(?)", name); + protected static int addPerson(JdbcTemplate jdbcTemplate, String name) { + return jdbcTemplate.update("INSERT INTO person VALUES(?)", name); } - protected static int deletePerson(SimpleJdbcTemplate simpleJdbcTemplate, String name) { - return simpleJdbcTemplate.update("DELETE FROM person WHERE name=?", name); + protected static int deletePerson(JdbcTemplate jdbcTemplate, String name) { + return jdbcTemplate.update("DELETE FROM person WHERE name=?", name); } } diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/BeforeAndAfterTransactionAnnotationTests.java b/spring-test/src/test/java/org/springframework/test/context/junit4/BeforeAndAfterTransactionAnnotationTests.java index 7dc2af2c636..9eeda704f79 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit4/BeforeAndAfterTransactionAnnotationTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit4/BeforeAndAfterTransactionAnnotationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2008 the original author or authors. + * Copyright 2002-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,9 +16,6 @@ package org.springframework.test.context.junit4; -import static org.junit.Assert.assertEquals; -import static org.springframework.test.transaction.TransactionTestUtils.assertInTransaction; - import javax.annotation.Resource; import javax.sql.DataSource; @@ -27,7 +24,7 @@ import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; import org.junit.runner.RunWith; -import org.springframework.jdbc.core.simple.SimpleJdbcTemplate; +import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.transaction.AfterTransaction; @@ -35,6 +32,9 @@ import org.springframework.test.context.transaction.BeforeTransaction; import org.springframework.test.context.transaction.TransactionalTestExecutionListener; import org.springframework.transaction.annotation.Transactional; +import static org.junit.Assert.*; +import static org.springframework.test.transaction.TransactionTestUtils.*; + /** * JUnit 4 based integration test which verifies * {@link BeforeTransaction @BeforeTransaction} and @@ -43,13 +43,12 @@ import org.springframework.transaction.annotation.Transactional; * @author Sam Brannen * @since 2.5 */ -@SuppressWarnings("deprecation") @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration -@TestExecutionListeners({ TransactionalTestExecutionListener.class }) +@TestExecutionListeners(TransactionalTestExecutionListener.class) public class BeforeAndAfterTransactionAnnotationTests extends AbstractTransactionalSpringRunnerTests { - protected static SimpleJdbcTemplate simpleJdbcTemplate; + protected static JdbcTemplate jdbcTemplate; protected static int numBeforeTransactionCalls = 0; protected static int numAfterTransactionCalls = 0; @@ -66,7 +65,7 @@ public class BeforeAndAfterTransactionAnnotationTests extends AbstractTransactio @AfterClass public static void afterClass() { assertEquals("Verifying the final number of rows in the person table after all tests.", 3, - countRowsInPersonTable(simpleJdbcTemplate)); + countRowsInPersonTable(jdbcTemplate)); assertEquals("Verifying the total number of calls to beforeTransaction().", 2, BeforeAndAfterTransactionAnnotationTests.numBeforeTransactionCalls); assertEquals("Verifying the total number of calls to afterTransaction().", 2, @@ -78,8 +77,8 @@ public class BeforeAndAfterTransactionAnnotationTests extends AbstractTransactio assertInTransaction(false); this.inTransaction = true; BeforeAndAfterTransactionAnnotationTests.numBeforeTransactionCalls++; - clearPersonTable(simpleJdbcTemplate); - assertEquals("Adding yoda", 1, addPerson(simpleJdbcTemplate, YODA)); + clearPersonTable(jdbcTemplate); + assertEquals("Adding yoda", 1, addPerson(jdbcTemplate, YODA)); } @AfterTransaction @@ -87,44 +86,44 @@ public class BeforeAndAfterTransactionAnnotationTests extends AbstractTransactio assertInTransaction(false); this.inTransaction = false; BeforeAndAfterTransactionAnnotationTests.numAfterTransactionCalls++; - assertEquals("Deleting yoda", 1, deletePerson(simpleJdbcTemplate, YODA)); + assertEquals("Deleting yoda", 1, deletePerson(jdbcTemplate, YODA)); assertEquals("Verifying the number of rows in the person table after a transactional test method.", 0, - countRowsInPersonTable(simpleJdbcTemplate)); + countRowsInPersonTable(jdbcTemplate)); } @Before public void before() { assertEquals("Verifying the number of rows in the person table before a test method.", (this.inTransaction ? 1 - : 0), countRowsInPersonTable(simpleJdbcTemplate)); + : 0), countRowsInPersonTable(jdbcTemplate)); } @Test @Transactional public void transactionalMethod1() { assertInTransaction(true); - assertEquals("Adding jane", 1, addPerson(simpleJdbcTemplate, JANE)); + assertEquals("Adding jane", 1, addPerson(jdbcTemplate, JANE)); assertEquals("Verifying the number of rows in the person table within transactionalMethod1().", 2, - countRowsInPersonTable(simpleJdbcTemplate)); + countRowsInPersonTable(jdbcTemplate)); } @Test @Transactional public void transactionalMethod2() { assertInTransaction(true); - assertEquals("Adding jane", 1, addPerson(simpleJdbcTemplate, JANE)); - assertEquals("Adding sue", 1, addPerson(simpleJdbcTemplate, SUE)); + assertEquals("Adding jane", 1, addPerson(jdbcTemplate, JANE)); + assertEquals("Adding sue", 1, addPerson(jdbcTemplate, SUE)); assertEquals("Verifying the number of rows in the person table within transactionalMethod2().", 3, - countRowsInPersonTable(simpleJdbcTemplate)); + countRowsInPersonTable(jdbcTemplate)); } @Test public void nonTransactionalMethod() { assertInTransaction(false); - assertEquals("Adding luke", 1, addPerson(simpleJdbcTemplate, LUKE)); - assertEquals("Adding leia", 1, addPerson(simpleJdbcTemplate, LEIA)); - assertEquals("Adding yoda", 1, addPerson(simpleJdbcTemplate, YODA)); + assertEquals("Adding luke", 1, addPerson(jdbcTemplate, LUKE)); + assertEquals("Adding leia", 1, addPerson(jdbcTemplate, LEIA)); + assertEquals("Adding yoda", 1, addPerson(jdbcTemplate, YODA)); assertEquals("Verifying the number of rows in the person table without a transaction.", 3, - countRowsInPersonTable(simpleJdbcTemplate)); + countRowsInPersonTable(jdbcTemplate)); } @@ -132,8 +131,8 @@ public class BeforeAndAfterTransactionAnnotationTests extends AbstractTransactio @Resource void setDataSource(DataSource dataSource) { - simpleJdbcTemplate = new SimpleJdbcTemplate(dataSource); - createPersonTable(simpleJdbcTemplate); + jdbcTemplate = new JdbcTemplate(dataSource); + createPersonTable(jdbcTemplate); } } diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/ClassLevelTransactionalSpringRunnerTests.java b/spring-test/src/test/java/org/springframework/test/context/junit4/ClassLevelTransactionalSpringRunnerTests.java index 6775b9d3b82..ae27449685f 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit4/ClassLevelTransactionalSpringRunnerTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit4/ClassLevelTransactionalSpringRunnerTests.java @@ -16,9 +16,6 @@ package org.springframework.test.context.junit4; -import static org.junit.Assert.assertEquals; -import static org.springframework.test.transaction.TransactionTestUtils.assertInTransaction; - import javax.annotation.Resource; import javax.sql.DataSource; @@ -26,7 +23,7 @@ import org.junit.AfterClass; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; -import org.springframework.jdbc.core.simple.SimpleJdbcTemplate; +import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListener; import org.springframework.test.context.TestExecutionListeners; @@ -36,6 +33,9 @@ import org.springframework.test.context.transaction.TransactionalTestExecutionLi import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; +import static org.junit.Assert.*; +import static org.springframework.test.transaction.TransactionTestUtils.*; + /** *

* JUnit 4 based integration test which verifies support of Spring's @@ -59,48 +59,47 @@ import org.springframework.transaction.annotation.Transactional; * @since 2.5 * @see MethodLevelTransactionalSpringRunnerTests */ -@SuppressWarnings("deprecation") @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration @Transactional public class ClassLevelTransactionalSpringRunnerTests extends AbstractTransactionalSpringRunnerTests { - protected static SimpleJdbcTemplate simpleJdbcTemplate; + protected static JdbcTemplate jdbcTemplate; @AfterClass public static void verifyFinalTestData() { assertEquals("Verifying the final number of rows in the person table after all tests.", 4, - countRowsInPersonTable(simpleJdbcTemplate)); + countRowsInPersonTable(jdbcTemplate)); } @Before public void verifyInitialTestData() { - clearPersonTable(simpleJdbcTemplate); - assertEquals("Adding bob", 1, addPerson(simpleJdbcTemplate, BOB)); + clearPersonTable(jdbcTemplate); + assertEquals("Adding bob", 1, addPerson(jdbcTemplate, BOB)); assertEquals("Verifying the initial number of rows in the person table.", 1, - countRowsInPersonTable(simpleJdbcTemplate)); + countRowsInPersonTable(jdbcTemplate)); } @Test public void modifyTestDataWithinTransaction() { assertInTransaction(true); - assertEquals("Deleting bob", 1, deletePerson(simpleJdbcTemplate, BOB)); - assertEquals("Adding jane", 1, addPerson(simpleJdbcTemplate, JANE)); - assertEquals("Adding sue", 1, addPerson(simpleJdbcTemplate, SUE)); + assertEquals("Deleting bob", 1, deletePerson(jdbcTemplate, BOB)); + assertEquals("Adding jane", 1, addPerson(jdbcTemplate, JANE)); + assertEquals("Adding sue", 1, addPerson(jdbcTemplate, SUE)); assertEquals("Verifying the number of rows in the person table within a transaction.", 2, - countRowsInPersonTable(simpleJdbcTemplate)); + countRowsInPersonTable(jdbcTemplate)); } @Test @Transactional(propagation = Propagation.NOT_SUPPORTED) public void modifyTestDataWithoutTransaction() { assertInTransaction(false); - assertEquals("Adding luke", 1, addPerson(simpleJdbcTemplate, LUKE)); - assertEquals("Adding leia", 1, addPerson(simpleJdbcTemplate, LEIA)); - assertEquals("Adding yoda", 1, addPerson(simpleJdbcTemplate, YODA)); + assertEquals("Adding luke", 1, addPerson(jdbcTemplate, LUKE)); + assertEquals("Adding leia", 1, addPerson(jdbcTemplate, LEIA)); + assertEquals("Adding yoda", 1, addPerson(jdbcTemplate, YODA)); assertEquals("Verifying the number of rows in the person table without a transaction.", 4, - countRowsInPersonTable(simpleJdbcTemplate)); + countRowsInPersonTable(jdbcTemplate)); } @@ -108,8 +107,8 @@ public class ClassLevelTransactionalSpringRunnerTests extends AbstractTransactio @Resource public void setDataSource(DataSource dataSource) { - simpleJdbcTemplate = new SimpleJdbcTemplate(dataSource); - createPersonTable(simpleJdbcTemplate); + jdbcTemplate = new JdbcTemplate(dataSource); + createPersonTable(jdbcTemplate); } } diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/DefaultRollbackFalseTransactionalSpringRunnerTests.java b/spring-test/src/test/java/org/springframework/test/context/junit4/DefaultRollbackFalseTransactionalSpringRunnerTests.java index 08f91b536af..0030d05f810 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit4/DefaultRollbackFalseTransactionalSpringRunnerTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit4/DefaultRollbackFalseTransactionalSpringRunnerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,9 +16,6 @@ package org.springframework.test.context.junit4; -import static org.junit.Assert.assertEquals; -import static org.springframework.test.transaction.TransactionTestUtils.assertInTransaction; - import javax.annotation.Resource; import javax.sql.DataSource; @@ -26,11 +23,14 @@ import org.junit.AfterClass; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; -import org.springframework.jdbc.core.simple.SimpleJdbcTemplate; +import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.transaction.TransactionConfiguration; import org.springframework.transaction.annotation.Transactional; +import static org.junit.Assert.*; +import static org.springframework.test.transaction.TransactionTestUtils.*; + /** *

* JUnit 4 based integration test which verifies proper transactional behavior when the @@ -44,38 +44,37 @@ import org.springframework.transaction.annotation.Transactional; * @since 2.5 * @see TransactionConfiguration */ -@SuppressWarnings("deprecation") @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration @TransactionConfiguration(transactionManager = "txMgr", defaultRollback = false) @Transactional public class DefaultRollbackFalseTransactionalSpringRunnerTests extends AbstractTransactionalSpringRunnerTests { - protected static SimpleJdbcTemplate simpleJdbcTemplate; + protected static JdbcTemplate jdbcTemplate; @AfterClass public static void verifyFinalTestData() { assertEquals("Verifying the final number of rows in the person table after all tests.", 2, - countRowsInPersonTable(simpleJdbcTemplate)); + countRowsInPersonTable(jdbcTemplate)); } @Before public void verifyInitialTestData() { - clearPersonTable(simpleJdbcTemplate); - assertEquals("Adding bob", 1, addPerson(simpleJdbcTemplate, BOB)); + clearPersonTable(jdbcTemplate); + assertEquals("Adding bob", 1, addPerson(jdbcTemplate, BOB)); assertEquals("Verifying the initial number of rows in the person table.", 1, - countRowsInPersonTable(simpleJdbcTemplate)); + countRowsInPersonTable(jdbcTemplate)); } @Test public void modifyTestDataWithinTransaction() { assertInTransaction(true); - assertEquals("Deleting bob", 1, deletePerson(simpleJdbcTemplate, BOB)); - assertEquals("Adding jane", 1, addPerson(simpleJdbcTemplate, JANE)); - assertEquals("Adding sue", 1, addPerson(simpleJdbcTemplate, SUE)); + assertEquals("Deleting bob", 1, deletePerson(jdbcTemplate, BOB)); + assertEquals("Adding jane", 1, addPerson(jdbcTemplate, JANE)); + assertEquals("Adding sue", 1, addPerson(jdbcTemplate, SUE)); assertEquals("Verifying the number of rows in the person table within a transaction.", 2, - countRowsInPersonTable(simpleJdbcTemplate)); + countRowsInPersonTable(jdbcTemplate)); } @@ -83,8 +82,8 @@ public class DefaultRollbackFalseTransactionalSpringRunnerTests extends Abstract @Resource public void setDataSource(DataSource dataSource) { - simpleJdbcTemplate = new SimpleJdbcTemplate(dataSource); - createPersonTable(simpleJdbcTemplate); + jdbcTemplate = new JdbcTemplate(dataSource); + createPersonTable(jdbcTemplate); } } diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/DefaultRollbackTrueTransactionalSpringRunnerTests.java b/spring-test/src/test/java/org/springframework/test/context/junit4/DefaultRollbackTrueTransactionalSpringRunnerTests.java index d7bfb8c2cd4..fc49d18e6a6 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit4/DefaultRollbackTrueTransactionalSpringRunnerTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit4/DefaultRollbackTrueTransactionalSpringRunnerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,9 +16,6 @@ package org.springframework.test.context.junit4; -import static org.junit.Assert.assertEquals; -import static org.springframework.test.transaction.TransactionTestUtils.assertInTransaction; - import javax.annotation.Resource; import javax.sql.DataSource; @@ -26,11 +23,14 @@ import org.junit.AfterClass; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; -import org.springframework.jdbc.core.simple.SimpleJdbcTemplate; +import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.transaction.TransactionConfiguration; import org.springframework.transaction.annotation.Transactional; +import static org.junit.Assert.*; +import static org.springframework.test.transaction.TransactionTestUtils.*; + /** * JUnit 4 based integration test which verifies proper transactional behavior when the * {@link TransactionConfiguration#defaultRollback() defaultRollback} attribute @@ -40,7 +40,6 @@ import org.springframework.transaction.annotation.Transactional; * @since 2.5 * @see TransactionConfiguration */ -@SuppressWarnings("deprecation") @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration @TransactionConfiguration(defaultRollback = true) @@ -48,31 +47,31 @@ public class DefaultRollbackTrueTransactionalSpringRunnerTests extends AbstractT protected static int originalNumRows; - protected static SimpleJdbcTemplate simpleJdbcTemplate; + protected static JdbcTemplate jdbcTemplate; @AfterClass public static void verifyFinalTestData() { assertEquals("Verifying the final number of rows in the person table after all tests.", originalNumRows, - countRowsInPersonTable(simpleJdbcTemplate)); + countRowsInPersonTable(jdbcTemplate)); } @Before public void verifyInitialTestData() { - originalNumRows = clearPersonTable(simpleJdbcTemplate); - assertEquals("Adding bob", 1, addPerson(simpleJdbcTemplate, BOB)); + originalNumRows = clearPersonTable(jdbcTemplate); + assertEquals("Adding bob", 1, addPerson(jdbcTemplate, BOB)); assertEquals("Verifying the initial number of rows in the person table.", 1, - countRowsInPersonTable(simpleJdbcTemplate)); + countRowsInPersonTable(jdbcTemplate)); } @Test(timeout = 1000) @Transactional public void modifyTestDataWithinTransaction() { assertInTransaction(true); - assertEquals("Adding jane", 1, addPerson(simpleJdbcTemplate, JANE)); - assertEquals("Adding sue", 1, addPerson(simpleJdbcTemplate, SUE)); + assertEquals("Adding jane", 1, addPerson(jdbcTemplate, JANE)); + assertEquals("Adding sue", 1, addPerson(jdbcTemplate, SUE)); assertEquals("Verifying the number of rows in the person table within a transaction.", 3, - countRowsInPersonTable(simpleJdbcTemplate)); + countRowsInPersonTable(jdbcTemplate)); } @@ -80,8 +79,8 @@ public class DefaultRollbackTrueTransactionalSpringRunnerTests extends AbstractT @Resource public void setDataSource(DataSource dataSource) { - simpleJdbcTemplate = new SimpleJdbcTemplate(dataSource); - createPersonTable(simpleJdbcTemplate); + jdbcTemplate = new JdbcTemplate(dataSource); + createPersonTable(jdbcTemplate); } } diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/MethodLevelTransactionalSpringRunnerTests.java b/spring-test/src/test/java/org/springframework/test/context/junit4/MethodLevelTransactionalSpringRunnerTests.java index a3502fdada8..5fd48cbe275 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit4/MethodLevelTransactionalSpringRunnerTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit4/MethodLevelTransactionalSpringRunnerTests.java @@ -16,9 +16,6 @@ package org.springframework.test.context.junit4; -import static org.junit.Assert.assertEquals; -import static org.springframework.test.transaction.TransactionTestUtils.assertInTransaction; - import javax.annotation.Resource; import javax.sql.DataSource; @@ -26,7 +23,7 @@ import org.junit.AfterClass; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; -import org.springframework.jdbc.core.simple.SimpleJdbcTemplate; +import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListener; import org.springframework.test.context.TestExecutionListeners; @@ -35,6 +32,9 @@ import org.springframework.test.context.support.DirtiesContextTestExecutionListe import org.springframework.test.context.transaction.TransactionalTestExecutionListener; import org.springframework.transaction.annotation.Transactional; +import static org.junit.Assert.*; +import static org.springframework.test.transaction.TransactionTestUtils.*; + /** *

* JUnit 4 based integration test which verifies support of Spring's @@ -60,49 +60,48 @@ import org.springframework.transaction.annotation.Transactional; * @since 2.5 * @see ClassLevelTransactionalSpringRunnerTests */ -@SuppressWarnings("deprecation") @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, DirtiesContextTestExecutionListener.class, TransactionalTestExecutionListener.class }) public class MethodLevelTransactionalSpringRunnerTests extends AbstractTransactionalSpringRunnerTests { - protected static SimpleJdbcTemplate simpleJdbcTemplate; + protected static JdbcTemplate jdbcTemplate; @AfterClass public static void verifyFinalTestData() { assertEquals("Verifying the final number of rows in the person table after all tests.", 4, - countRowsInPersonTable(simpleJdbcTemplate)); + countRowsInPersonTable(jdbcTemplate)); } @Before public void verifyInitialTestData() { - clearPersonTable(simpleJdbcTemplate); - assertEquals("Adding bob", 1, addPerson(simpleJdbcTemplate, BOB)); + clearPersonTable(jdbcTemplate); + assertEquals("Adding bob", 1, addPerson(jdbcTemplate, BOB)); assertEquals("Verifying the initial number of rows in the person table.", 1, - countRowsInPersonTable(simpleJdbcTemplate)); + countRowsInPersonTable(jdbcTemplate)); } @Test @Transactional("transactionManager2") public void modifyTestDataWithinTransaction() { assertInTransaction(true); - assertEquals("Deleting bob", 1, deletePerson(simpleJdbcTemplate, BOB)); - assertEquals("Adding jane", 1, addPerson(simpleJdbcTemplate, JANE)); - assertEquals("Adding sue", 1, addPerson(simpleJdbcTemplate, SUE)); + assertEquals("Deleting bob", 1, deletePerson(jdbcTemplate, BOB)); + assertEquals("Adding jane", 1, addPerson(jdbcTemplate, JANE)); + assertEquals("Adding sue", 1, addPerson(jdbcTemplate, SUE)); assertEquals("Verifying the number of rows in the person table within a transaction.", 2, - countRowsInPersonTable(simpleJdbcTemplate)); + countRowsInPersonTable(jdbcTemplate)); } @Test public void modifyTestDataWithoutTransaction() { assertInTransaction(false); - assertEquals("Adding luke", 1, addPerson(simpleJdbcTemplate, LUKE)); - assertEquals("Adding leia", 1, addPerson(simpleJdbcTemplate, LEIA)); - assertEquals("Adding yoda", 1, addPerson(simpleJdbcTemplate, YODA)); + assertEquals("Adding luke", 1, addPerson(jdbcTemplate, LUKE)); + assertEquals("Adding leia", 1, addPerson(jdbcTemplate, LEIA)); + assertEquals("Adding yoda", 1, addPerson(jdbcTemplate, YODA)); assertEquals("Verifying the number of rows in the person table without a transaction.", 4, - countRowsInPersonTable(simpleJdbcTemplate)); + countRowsInPersonTable(jdbcTemplate)); } @@ -110,8 +109,8 @@ public class MethodLevelTransactionalSpringRunnerTests extends AbstractTransacti @Resource public void setDataSource2(DataSource dataSource) { - simpleJdbcTemplate = new SimpleJdbcTemplate(dataSource); - createPersonTable(simpleJdbcTemplate); + jdbcTemplate = new JdbcTemplate(dataSource); + createPersonTable(jdbcTemplate); } } diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/RollbackOverrideDefaultRollbackFalseTransactionalSpringRunnerTests.java b/spring-test/src/test/java/org/springframework/test/context/junit4/RollbackOverrideDefaultRollbackFalseTransactionalSpringRunnerTests.java index 231ea884b39..8ecee95b2e2 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit4/RollbackOverrideDefaultRollbackFalseTransactionalSpringRunnerTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit4/RollbackOverrideDefaultRollbackFalseTransactionalSpringRunnerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2008 the original author or authors. + * Copyright 2002-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,19 +16,19 @@ package org.springframework.test.context.junit4; -import static org.junit.Assert.assertEquals; -import static org.springframework.test.transaction.TransactionTestUtils.assertInTransaction; - import javax.annotation.Resource; import javax.sql.DataSource; import org.junit.AfterClass; import org.junit.Before; import org.junit.Test; -import org.springframework.jdbc.core.simple.SimpleJdbcTemplate; +import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.test.annotation.Rollback; import org.springframework.test.context.ContextConfiguration; +import static org.junit.Assert.*; +import static org.springframework.test.transaction.TransactionTestUtils.*; + /** * Extension of {@link DefaultRollbackFalseTransactionalSpringRunnerTests} which * tests method-level rollback override behavior via the @@ -38,29 +38,28 @@ import org.springframework.test.context.ContextConfiguration; * @since 2.5 * @see Rollback */ -@SuppressWarnings("deprecation") @ContextConfiguration public class RollbackOverrideDefaultRollbackFalseTransactionalSpringRunnerTests extends DefaultRollbackFalseTransactionalSpringRunnerTests { protected static int originalNumRows; - protected static SimpleJdbcTemplate simpleJdbcTemplate; + protected static JdbcTemplate jdbcTemplate; @AfterClass public static void verifyFinalTestData() { assertEquals("Verifying the final number of rows in the person table after all tests.", originalNumRows, - countRowsInPersonTable(simpleJdbcTemplate)); + countRowsInPersonTable(jdbcTemplate)); } @Before @Override public void verifyInitialTestData() { - originalNumRows = clearPersonTable(simpleJdbcTemplate); - assertEquals("Adding bob", 1, addPerson(simpleJdbcTemplate, BOB)); + originalNumRows = clearPersonTable(jdbcTemplate); + assertEquals("Adding bob", 1, addPerson(jdbcTemplate, BOB)); assertEquals("Verifying the initial number of rows in the person table.", 1, - countRowsInPersonTable(simpleJdbcTemplate)); + countRowsInPersonTable(jdbcTemplate)); } @Test @@ -68,11 +67,11 @@ public class RollbackOverrideDefaultRollbackFalseTransactionalSpringRunnerTests @Override public void modifyTestDataWithinTransaction() { assertInTransaction(true); - assertEquals("Deleting bob", 1, deletePerson(simpleJdbcTemplate, BOB)); - assertEquals("Adding jane", 1, addPerson(simpleJdbcTemplate, JANE)); - assertEquals("Adding sue", 1, addPerson(simpleJdbcTemplate, SUE)); + assertEquals("Deleting bob", 1, deletePerson(jdbcTemplate, BOB)); + assertEquals("Adding jane", 1, addPerson(jdbcTemplate, JANE)); + assertEquals("Adding sue", 1, addPerson(jdbcTemplate, SUE)); assertEquals("Verifying the number of rows in the person table within a transaction.", 2, - countRowsInPersonTable(simpleJdbcTemplate)); + countRowsInPersonTable(jdbcTemplate)); } @@ -80,8 +79,8 @@ public class RollbackOverrideDefaultRollbackFalseTransactionalSpringRunnerTests @Resource public void setDataSource(DataSource dataSource) { - simpleJdbcTemplate = new SimpleJdbcTemplate(dataSource); - createPersonTable(simpleJdbcTemplate); + jdbcTemplate = new JdbcTemplate(dataSource); + createPersonTable(jdbcTemplate); } } diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/RollbackOverrideDefaultRollbackTrueTransactionalSpringRunnerTests.java b/spring-test/src/test/java/org/springframework/test/context/junit4/RollbackOverrideDefaultRollbackTrueTransactionalSpringRunnerTests.java index a662b7b8bff..5d4e194e337 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit4/RollbackOverrideDefaultRollbackTrueTransactionalSpringRunnerTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit4/RollbackOverrideDefaultRollbackTrueTransactionalSpringRunnerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,20 +16,20 @@ package org.springframework.test.context.junit4; -import static org.junit.Assert.assertEquals; -import static org.springframework.test.transaction.TransactionTestUtils.assertInTransaction; - import javax.annotation.Resource; import javax.sql.DataSource; import org.junit.AfterClass; import org.junit.Before; import org.junit.Test; -import org.springframework.jdbc.core.simple.SimpleJdbcTemplate; +import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.test.annotation.Rollback; import org.springframework.test.context.ContextConfiguration; import org.springframework.transaction.annotation.Transactional; +import static org.junit.Assert.*; +import static org.springframework.test.transaction.TransactionTestUtils.*; + /** * Extension of {@link DefaultRollbackTrueTransactionalSpringRunnerTests} which * tests method-level rollback override behavior via the @@ -39,27 +39,26 @@ import org.springframework.transaction.annotation.Transactional; * @since 2.5 * @see Rollback */ -@SuppressWarnings("deprecation") @ContextConfiguration public class RollbackOverrideDefaultRollbackTrueTransactionalSpringRunnerTests extends DefaultRollbackTrueTransactionalSpringRunnerTests { - protected static SimpleJdbcTemplate simpleJdbcTemplate; + protected static JdbcTemplate jdbcTemplate; @AfterClass public static void verifyFinalTestData() { assertEquals("Verifying the final number of rows in the person table after all tests.", 3, - countRowsInPersonTable(simpleJdbcTemplate)); + countRowsInPersonTable(jdbcTemplate)); } @Override @Before public void verifyInitialTestData() { - clearPersonTable(simpleJdbcTemplate); - assertEquals("Adding bob", 1, addPerson(simpleJdbcTemplate, BOB)); + clearPersonTable(jdbcTemplate); + assertEquals("Adding bob", 1, addPerson(jdbcTemplate, BOB)); assertEquals("Verifying the initial number of rows in the person table.", 1, - countRowsInPersonTable(simpleJdbcTemplate)); + countRowsInPersonTable(jdbcTemplate)); } @Override @@ -68,10 +67,10 @@ public class RollbackOverrideDefaultRollbackTrueTransactionalSpringRunnerTests e @Rollback(false) public void modifyTestDataWithinTransaction() { assertInTransaction(true); - assertEquals("Adding jane", 1, addPerson(simpleJdbcTemplate, JANE)); - assertEquals("Adding sue", 1, addPerson(simpleJdbcTemplate, SUE)); + assertEquals("Adding jane", 1, addPerson(jdbcTemplate, JANE)); + assertEquals("Adding sue", 1, addPerson(jdbcTemplate, SUE)); assertEquals("Verifying the number of rows in the person table within a transaction.", 3, - countRowsInPersonTable(simpleJdbcTemplate)); + countRowsInPersonTable(jdbcTemplate)); } @@ -79,8 +78,8 @@ public class RollbackOverrideDefaultRollbackTrueTransactionalSpringRunnerTests e @Resource public void setDataSource(DataSource dataSource) { - simpleJdbcTemplate = new SimpleJdbcTemplate(dataSource); - createPersonTable(simpleJdbcTemplate); + jdbcTemplate = new JdbcTemplate(dataSource); + createPersonTable(jdbcTemplate); } }