diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/DataSourceTransactionManagerTests.java b/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/DataSourceTransactionManagerTests.java index ac836ce7a9a..39eae5fb4af 100644 --- a/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/DataSourceTransactionManagerTests.java +++ b/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/DataSourceTransactionManagerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2018 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. @@ -65,7 +65,7 @@ public class DataSourceTransactionManagerTests { @Before - public void setUp() throws Exception { + public void setup() throws Exception { ds = mock(DataSource.class); con = mock(Connection.class); given(ds.getConnection()).willReturn(con); diff --git a/spring-jms/src/test/java/org/springframework/jms/connection/JmsTransactionManagerTests.java b/spring-jms/src/test/java/org/springframework/jms/connection/JmsTransactionManagerTests.java index edca5bd166a..bd0fb1bd97a 100644 --- a/spring-jms/src/test/java/org/springframework/jms/connection/JmsTransactionManagerTests.java +++ b/spring-jms/src/test/java/org/springframework/jms/connection/JmsTransactionManagerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2018 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. @@ -49,7 +49,7 @@ import static org.mockito.BDDMockito.*; public class JmsTransactionManagerTests { @After - public void verifyTransactionSynchronizationManager() { + public void verifyTransactionSynchronizationManagerState() { assertTrue(TransactionSynchronizationManager.getResourceMap().isEmpty()); assertFalse(TransactionSynchronizationManager.isSynchronizationActive()); } diff --git a/spring-orm/src/test/java/org/springframework/orm/jpa/JpaTransactionManagerTests.java b/spring-orm/src/test/java/org/springframework/orm/jpa/JpaTransactionManagerTests.java index 9269a73b05b..3c3dbe7ff0b 100644 --- a/spring-orm/src/test/java/org/springframework/orm/jpa/JpaTransactionManagerTests.java +++ b/spring-orm/src/test/java/org/springframework/orm/jpa/JpaTransactionManagerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2018 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,14 +16,12 @@ package org.springframework.orm.jpa; -import java.sql.SQLException; import java.util.ArrayList; import java.util.List; import javax.persistence.EntityManager; import javax.persistence.EntityManagerFactory; import javax.persistence.EntityTransaction; import javax.persistence.RollbackException; -import javax.sql.DataSource; import org.junit.After; import org.junit.Before; @@ -47,7 +45,7 @@ import static org.mockito.BDDMockito.*; * @author Juergen Hoeller * @author Phillip Webb */ -@SuppressWarnings({ "unchecked", "rawtypes" }) +@SuppressWarnings({"unchecked", "rawtypes"}) public class JpaTransactionManagerTests { private EntityManagerFactory factory; @@ -62,7 +60,7 @@ public class JpaTransactionManagerTests { @Before - public void setUp() throws Exception { + public void setup() { factory = mock(EntityManagerFactory.class); manager = mock(EntityManager.class); tx = mock(EntityTransaction.class); @@ -76,7 +74,7 @@ public class JpaTransactionManagerTests { } @After - public void tearDown() throws Exception { + public void verifyTransactionSynchronizationManagerState() { assertTrue(TransactionSynchronizationManager.getResourceMap().isEmpty()); assertFalse(TransactionSynchronizationManager.isSynchronizationActive()); assertFalse(TransactionSynchronizationManager.isCurrentTransactionReadOnly()); @@ -758,39 +756,6 @@ public class JpaTransactionManagerTests { verify(manager).clear(); } - @Test - public void testTransactionCommitWithDataSource() throws SQLException { - DataSource ds = mock(DataSource.class); - tm.setDataSource(ds); - - given(manager.getTransaction()).willReturn(tx); - - final List l = new ArrayList<>(); - l.add("test"); - - assertTrue(!TransactionSynchronizationManager.hasResource(factory)); - assertTrue(!TransactionSynchronizationManager.isSynchronizationActive()); - - Object result = tt.execute(new TransactionCallback() { - @Override - public Object doInTransaction(TransactionStatus status) { - assertTrue(TransactionSynchronizationManager.hasResource(factory)); - assertTrue(TransactionSynchronizationManager.isSynchronizationActive()); - EntityManagerFactoryUtils.getTransactionalEntityManager(factory).flush(); - return l; - } - }); - - assertTrue(result == l); - - assertTrue(!TransactionSynchronizationManager.hasResource(factory)); - assertTrue(!TransactionSynchronizationManager.isSynchronizationActive()); - - verify(tx).commit(); - verify(manager).flush(); - verify(manager).close(); - } - @Test public void testInvalidIsolation() { tt.setIsolationLevel(TransactionDefinition.ISOLATION_SERIALIZABLE);