diff options
author | Emmanuel Bourg <ebourg@apache.org> | 2016-04-03 01:07:52 +0200 |
---|---|---|
committer | Emmanuel Bourg <ebourg@apache.org> | 2016-04-03 01:07:52 +0200 |
commit | 5575b60c30c5a0c308c4ba3a2db93956d8c1746c (patch) | |
tree | 14eb3edc5dfb9f5bd0ce5cb99adac0f51573be94 /spring-tx/src/test/java/org/springframework | |
parent | da46d30e80e4c59a41cf52055d06faa1dbb7e383 (diff) |
Imported Upstream version 4.1.9
Diffstat (limited to 'spring-tx/src/test/java/org/springframework')
20 files changed, 355 insertions, 127 deletions
diff --git a/spring-tx/src/test/java/org/springframework/dao/annotation/PersistenceExceptionTranslationAdvisorTests.java b/spring-tx/src/test/java/org/springframework/dao/annotation/PersistenceExceptionTranslationAdvisorTests.java index c7c1970c..a8e4fb54 100644 --- a/spring-tx/src/test/java/org/springframework/dao/annotation/PersistenceExceptionTranslationAdvisorTests.java +++ b/spring-tx/src/test/java/org/springframework/dao/annotation/PersistenceExceptionTranslationAdvisorTests.java @@ -16,10 +16,10 @@ package org.springframework.dao.annotation; -import java.lang.annotation.Target; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; import javax.persistence.PersistenceException; import junit.framework.TestCase; diff --git a/spring-tx/src/test/java/org/springframework/dao/support/DataAccessUtilsTests.java b/spring-tx/src/test/java/org/springframework/dao/support/DataAccessUtilsTests.java index 74953d4d..a2e78864 100644 --- a/spring-tx/src/test/java/org/springframework/dao/support/DataAccessUtilsTests.java +++ b/spring-tx/src/test/java/org/springframework/dao/support/DataAccessUtilsTests.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,7 +37,7 @@ import org.springframework.dao.TypeMismatchDataAccessException; public class DataAccessUtilsTests extends TestCase { public void testWithEmptyCollection() { - Collection col = new HashSet(); + Collection<String> col = new HashSet<String>(); assertNull(DataAccessUtils.uniqueResult(col)); @@ -83,7 +83,7 @@ public class DataAccessUtilsTests extends TestCase { } public void testWithTooLargeCollection() { - Collection col = new HashSet(); + Collection<String> col = new HashSet<String>(2); col.add("test1"); col.add("test2"); @@ -139,33 +139,33 @@ public class DataAccessUtilsTests extends TestCase { } public void testWithInteger() { - Collection col = new HashSet(); - col.add(new Integer(5)); + Collection<Integer> col = new HashSet<Integer>(1); + col.add(5); - assertEquals(new Integer(5), DataAccessUtils.uniqueResult(col)); - assertEquals(new Integer(5), DataAccessUtils.requiredUniqueResult(col)); - assertEquals(new Integer(5), DataAccessUtils.objectResult(col, Integer.class)); + assertEquals(Integer.valueOf(5), DataAccessUtils.uniqueResult(col)); + assertEquals(Integer.valueOf(5), DataAccessUtils.requiredUniqueResult(col)); + assertEquals(Integer.valueOf(5), DataAccessUtils.objectResult(col, Integer.class)); assertEquals("5", DataAccessUtils.objectResult(col, String.class)); assertEquals(5, DataAccessUtils.intResult(col)); assertEquals(5, DataAccessUtils.longResult(col)); } public void testWithSameIntegerInstanceTwice() { - Integer i = new Integer(5); - Collection col = new ArrayList(); + Integer i = 5; + Collection<Integer> col = new ArrayList<Integer>(1); col.add(i); col.add(i); - assertEquals(new Integer(5), DataAccessUtils.uniqueResult(col)); - assertEquals(new Integer(5), DataAccessUtils.requiredUniqueResult(col)); - assertEquals(new Integer(5), DataAccessUtils.objectResult(col, Integer.class)); + assertEquals(Integer.valueOf(5), DataAccessUtils.uniqueResult(col)); + assertEquals(Integer.valueOf(5), DataAccessUtils.requiredUniqueResult(col)); + assertEquals(Integer.valueOf(5), DataAccessUtils.objectResult(col, Integer.class)); assertEquals("5", DataAccessUtils.objectResult(col, String.class)); assertEquals(5, DataAccessUtils.intResult(col)); assertEquals(5, DataAccessUtils.longResult(col)); } public void testWithEquivalentIntegerInstanceTwice() { - Collection col = new ArrayList(); + Collection<Integer> col = new ArrayList<Integer>(2); col.add(new Integer(5)); col.add(new Integer(5)); @@ -181,19 +181,19 @@ public class DataAccessUtilsTests extends TestCase { } public void testWithLong() { - Collection col = new HashSet(); - col.add(new Long(5)); + Collection<Long> col = new HashSet<Long>(1); + col.add(5L); - assertEquals(new Long(5), DataAccessUtils.uniqueResult(col)); - assertEquals(new Long(5), DataAccessUtils.requiredUniqueResult(col)); - assertEquals(new Long(5), DataAccessUtils.objectResult(col, Long.class)); + assertEquals(Long.valueOf(5L), DataAccessUtils.uniqueResult(col)); + assertEquals(Long.valueOf(5L), DataAccessUtils.requiredUniqueResult(col)); + assertEquals(Long.valueOf(5L), DataAccessUtils.objectResult(col, Long.class)); assertEquals("5", DataAccessUtils.objectResult(col, String.class)); assertEquals(5, DataAccessUtils.intResult(col)); assertEquals(5, DataAccessUtils.longResult(col)); } public void testWithString() { - Collection col = new HashSet(); + Collection<String> col = new HashSet<String>(1); col.add("test1"); assertEquals("test1", DataAccessUtils.uniqueResult(col)); @@ -219,7 +219,7 @@ public class DataAccessUtilsTests extends TestCase { public void testWithDate() { Date date = new Date(); - Collection col = new HashSet(); + Collection<Date> col = new HashSet<Date>(1); col.add(date); assertEquals(date, DataAccessUtils.uniqueResult(col)); @@ -262,9 +262,9 @@ public class DataAccessUtilsTests extends TestCase { public static class MapPersistenceExceptionTranslator implements PersistenceExceptionTranslator { /** - * Map<RuntimeException,RuntimeException>: in to out + * in to out */ - private Map translations = new HashMap(); + private Map<RuntimeException,RuntimeException> translations = new HashMap<RuntimeException,RuntimeException>(); public void addTranslation(RuntimeException in, RuntimeException out) { this.translations.put(in, out); diff --git a/spring-tx/src/test/java/org/springframework/jca/cci/CciLocalTransactionTests.java b/spring-tx/src/test/java/org/springframework/jca/cci/CciLocalTransactionTests.java index 9a5b2c12..7dcc4400 100644 --- a/spring-tx/src/test/java/org/springframework/jca/cci/CciLocalTransactionTests.java +++ b/spring-tx/src/test/java/org/springframework/jca/cci/CciLocalTransactionTests.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. @@ -25,6 +25,7 @@ import javax.resource.cci.LocalTransaction; import javax.resource.cci.Record; import org.junit.Test; + import org.springframework.dao.DataRetrievalFailureException; import org.springframework.jca.cci.connection.CciLocalTransactionManager; import org.springframework.jca.cci.core.CciTemplate; @@ -107,9 +108,9 @@ public class CciLocalTransactionTests { TransactionTemplate tt = new TransactionTemplate(tm); try { - tt.execute(new TransactionCallback() { + tt.execute(new TransactionCallback<Void>() { @Override - public Object doInTransaction(TransactionStatus status) { + public Void doInTransaction(TransactionStatus status) { assertTrue("Has thread connection", TransactionSynchronizationManager.hasResource(connectionFactory)); CciTemplate ct = new CciTemplate(connectionFactory); ct.execute(interactionSpec, record, record); diff --git a/spring-tx/src/test/java/org/springframework/jca/cci/CciTemplateTests.java b/spring-tx/src/test/java/org/springframework/jca/cci/CciTemplateTests.java index f934ebe7..614cdc5a 100644 --- a/spring-tx/src/test/java/org/springframework/jca/cci/CciTemplateTests.java +++ b/spring-tx/src/test/java/org/springframework/jca/cci/CciTemplateTests.java @@ -17,7 +17,6 @@ package org.springframework.jca.cci; import java.sql.SQLException; - import javax.resource.NotSupportedException; import javax.resource.ResourceException; import javax.resource.cci.Connection; @@ -32,6 +31,7 @@ import javax.resource.cci.RecordFactory; import javax.resource.cci.ResultSet; import org.junit.Test; + import org.springframework.jca.cci.connection.ConnectionSpecConnectionFactoryAdapter; import org.springframework.jca.cci.connection.NotSupportedRecordFactory; import org.springframework.jca.cci.core.CciTemplate; diff --git a/spring-tx/src/test/java/org/springframework/jca/cci/EisOperationTests.java b/spring-tx/src/test/java/org/springframework/jca/cci/EisOperationTests.java index e5e2f8a6..2a18f0bd 100644 --- a/spring-tx/src/test/java/org/springframework/jca/cci/EisOperationTests.java +++ b/spring-tx/src/test/java/org/springframework/jca/cci/EisOperationTests.java @@ -25,6 +25,7 @@ import javax.resource.cci.Record; import javax.resource.cci.RecordFactory; import org.junit.Test; + import org.springframework.jca.cci.core.RecordCreator; import org.springframework.jca.cci.object.MappingRecordOperation; import org.springframework.jca.cci.object.SimpleRecordOperation; diff --git a/spring-tx/src/test/java/org/springframework/transaction/MockCallbackPreferringTransactionManager.java b/spring-tx/src/test/java/org/springframework/transaction/MockCallbackPreferringTransactionManager.java index df160440..16c2eebd 100644 --- a/spring-tx/src/test/java/org/springframework/transaction/MockCallbackPreferringTransactionManager.java +++ b/spring-tx/src/test/java/org/springframework/transaction/MockCallbackPreferringTransactionManager.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. @@ -31,7 +31,7 @@ public class MockCallbackPreferringTransactionManager implements CallbackPreferr @Override - public Object execute(TransactionDefinition definition, TransactionCallback callback) throws TransactionException { + public <T> T execute(TransactionDefinition definition, TransactionCallback<T> callback) throws TransactionException { this.definition = definition; this.status = new SimpleTransactionStatus(); return callback.doInTransaction(this.status); diff --git a/spring-tx/src/test/java/org/springframework/transaction/TxNamespaceHandlerTests.java b/spring-tx/src/test/java/org/springframework/transaction/TxNamespaceHandlerTests.java index 813a905e..842c0505 100644 --- a/spring-tx/src/test/java/org/springframework/transaction/TxNamespaceHandlerTests.java +++ b/spring-tx/src/test/java/org/springframework/transaction/TxNamespaceHandlerTests.java @@ -21,10 +21,10 @@ import java.lang.reflect.Method; import junit.framework.TestCase; import org.springframework.aop.support.AopUtils; -import org.springframework.tests.sample.beans.ITestBean; -import org.springframework.tests.transaction.CallCountingTransactionManager; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; +import org.springframework.tests.sample.beans.ITestBean; +import org.springframework.tests.transaction.CallCountingTransactionManager; import org.springframework.transaction.interceptor.TransactionAttribute; import org.springframework.transaction.interceptor.TransactionAttributeSource; import org.springframework.transaction.interceptor.TransactionInterceptor; diff --git a/spring-tx/src/test/java/org/springframework/transaction/annotation/AnnotationTransactionNamespaceHandlerTests.java b/spring-tx/src/test/java/org/springframework/transaction/annotation/AnnotationTransactionNamespaceHandlerTests.java index 311038d7..91abc155 100644 --- a/spring-tx/src/test/java/org/springframework/transaction/annotation/AnnotationTransactionNamespaceHandlerTests.java +++ b/spring-tx/src/test/java/org/springframework/transaction/annotation/AnnotationTransactionNamespaceHandlerTests.java @@ -19,7 +19,6 @@ package org.springframework.transaction.annotation; import java.lang.management.ManagementFactory; import java.util.Collection; import java.util.Map; - import javax.management.MBeanServer; import javax.management.ObjectName; diff --git a/spring-tx/src/test/java/org/springframework/transaction/annotation/EnableTransactionManagementTests.java b/spring-tx/src/test/java/org/springframework/transaction/annotation/EnableTransactionManagementTests.java index 3ad212da..07893433 100644 --- a/spring-tx/src/test/java/org/springframework/transaction/annotation/EnableTransactionManagementTests.java +++ b/spring-tx/src/test/java/org/springframework/transaction/annotation/EnableTransactionManagementTests.java @@ -17,6 +17,7 @@ package org.springframework.transaction.annotation; import java.util.Map; +import javax.annotation.PostConstruct; import org.junit.Test; @@ -35,8 +36,6 @@ import org.springframework.transaction.annotation.AnnotationTransactionNamespace import static org.hamcrest.CoreMatchers.*; import static org.junit.Assert.*; -import javax.annotation.PostConstruct; - /** * Tests demonstrating use of @EnableTransactionManagement @Configuration classes. * diff --git a/spring-tx/src/test/java/org/springframework/transaction/interceptor/AbstractTransactionAspectTests.java b/spring-tx/src/test/java/org/springframework/transaction/interceptor/AbstractTransactionAspectTests.java index b097bf38..ef5a832d 100644 --- a/spring-tx/src/test/java/org/springframework/transaction/interceptor/AbstractTransactionAspectTests.java +++ b/spring-tx/src/test/java/org/springframework/transaction/interceptor/AbstractTransactionAspectTests.java @@ -18,7 +18,7 @@ package org.springframework.transaction.interceptor; import java.lang.reflect.Method; -import junit.framework.TestCase; +import org.junit.Test; import org.springframework.dao.OptimisticLockingFailureException; import org.springframework.tests.sample.beans.ITestBean; @@ -33,6 +33,7 @@ import org.springframework.transaction.TransactionSystemException; import org.springframework.transaction.UnexpectedRollbackException; import org.springframework.transaction.interceptor.TransactionAspectSupport.TransactionInfo; +import static org.junit.Assert.*; import static org.mockito.BDDMockito.*; /** @@ -47,7 +48,7 @@ import static org.mockito.BDDMockito.*; * @author Rod Johnson * @since 16.03.2003 */ -public abstract class AbstractTransactionAspectTests extends TestCase { +public abstract class AbstractTransactionAspectTests { protected Method exceptionalMethod; @@ -69,7 +70,8 @@ public abstract class AbstractTransactionAspectTests extends TestCase { } - public void testNoTransaction() throws Exception { + @Test + public void noTransaction() throws Exception { PlatformTransactionManager ptm = mock(PlatformTransactionManager.class); TestBean tb = new TestBean(); @@ -91,7 +93,8 @@ public abstract class AbstractTransactionAspectTests extends TestCase { /** * Check that a transaction is created and committed. */ - public void testTransactionShouldSucceed() throws Exception { + @Test + public void transactionShouldSucceed() throws Exception { TransactionAttribute txatt = new DefaultTransactionAttribute(); MapTransactionAttributeSource tas = new MapTransactionAttributeSource(); @@ -116,7 +119,8 @@ public abstract class AbstractTransactionAspectTests extends TestCase { * Check that a transaction is created and committed using * CallbackPreferringPlatformTransactionManager. */ - public void testTransactionShouldSucceedWithCallbackPreference() throws Exception { + @Test + public void transactionShouldSucceedWithCallbackPreference() throws Exception { TransactionAttribute txatt = new DefaultTransactionAttribute(); MapTransactionAttributeSource tas = new MapTransactionAttributeSource(); @@ -135,7 +139,8 @@ public abstract class AbstractTransactionAspectTests extends TestCase { assertFalse(ptm.getStatus().isRollbackOnly()); } - public void testTransactionExceptionPropagatedWithCallbackPreference() throws Throwable { + @Test + public void transactionExceptionPropagatedWithCallbackPreference() throws Throwable { TransactionAttribute txatt = new DefaultTransactionAttribute(); MapTransactionAttributeSource tas = new MapTransactionAttributeSource(); @@ -163,7 +168,8 @@ public abstract class AbstractTransactionAspectTests extends TestCase { /** * Check that two transactions are created and committed. */ - public void testTwoTransactionsShouldSucceed() throws Exception { + @Test + public void twoTransactionsShouldSucceed() throws Exception { TransactionAttribute txatt = new DefaultTransactionAttribute(); MapTransactionAttributeSource tas1 = new MapTransactionAttributeSource(); @@ -191,7 +197,8 @@ public abstract class AbstractTransactionAspectTests extends TestCase { /** * Check that a transaction is created and committed. */ - public void testTransactionShouldSucceedWithNotNew() throws Exception { + @Test + public void transactionShouldSucceedWithNotNew() throws Exception { TransactionAttribute txatt = new DefaultTransactionAttribute(); MapTransactionAttributeSource tas = new MapTransactionAttributeSource(); @@ -213,7 +220,8 @@ public abstract class AbstractTransactionAspectTests extends TestCase { verify(ptm).commit(status); } - public void testEnclosingTransactionWithNonTransactionMethodOnAdvisedInside() throws Throwable { + @Test + public void enclosingTransactionWithNonTransactionMethodOnAdvisedInside() throws Throwable { TransactionAttribute txatt = new DefaultTransactionAttribute(); MapTransactionAttributeSource tas = new MapTransactionAttributeSource(); @@ -258,7 +266,8 @@ public abstract class AbstractTransactionAspectTests extends TestCase { verify(ptm).commit(status); } - public void testEnclosingTransactionWithNestedTransactionOnAdvisedInside() throws Throwable { + @Test + public void enclosingTransactionWithNestedTransactionOnAdvisedInside() throws Throwable { final TransactionAttribute outerTxatt = new DefaultTransactionAttribute(); final TransactionAttribute innerTxatt = new DefaultTransactionAttribute(TransactionDefinition.PROPAGATION_NESTED); @@ -314,35 +323,43 @@ public abstract class AbstractTransactionAspectTests extends TestCase { verify(ptm).commit(outerStatus); } - public void testRollbackOnCheckedException() throws Throwable { + @Test + public void rollbackOnCheckedException() throws Throwable { doTestRollbackOnException(new Exception(), true, false); } - public void testNoRollbackOnCheckedException() throws Throwable { + @Test + public void noRollbackOnCheckedException() throws Throwable { doTestRollbackOnException(new Exception(), false, false); } - public void testRollbackOnUncheckedException() throws Throwable { + @Test + public void rollbackOnUncheckedException() throws Throwable { doTestRollbackOnException(new RuntimeException(), true, false); } - public void testNoRollbackOnUncheckedException() throws Throwable { + @Test + public void noRollbackOnUncheckedException() throws Throwable { doTestRollbackOnException(new RuntimeException(), false, false); } - public void testRollbackOnCheckedExceptionWithRollbackException() throws Throwable { + @Test + public void rollbackOnCheckedExceptionWithRollbackException() throws Throwable { doTestRollbackOnException(new Exception(), true, true); } - public void testNoRollbackOnCheckedExceptionWithRollbackException() throws Throwable { + @Test + public void noRollbackOnCheckedExceptionWithRollbackException() throws Throwable { doTestRollbackOnException(new Exception(), false, true); } - public void testRollbackOnUncheckedExceptionWithRollbackException() throws Throwable { + @Test + public void rollbackOnUncheckedExceptionWithRollbackException() throws Throwable { doTestRollbackOnException(new RuntimeException(), true, true); } - public void testNoRollbackOnUncheckedExceptionWithRollbackException() throws Throwable { + @Test + public void noRollbackOnUncheckedExceptionWithRollbackException() throws Throwable { doTestRollbackOnException(new RuntimeException(), false, true); } @@ -413,7 +430,8 @@ public abstract class AbstractTransactionAspectTests extends TestCase { /** * Test that TransactionStatus.setRollbackOnly works. */ - public void testProgrammaticRollback() throws Exception { + @Test + public void programmaticRollback() throws Exception { TransactionAttribute txatt = new DefaultTransactionAttribute(); Method m = getNameMethod; @@ -447,7 +465,8 @@ public abstract class AbstractTransactionAspectTests extends TestCase { * Simulate a transaction infrastructure failure. * Shouldn't invoke target method. */ - public void testCannotCreateTransaction() throws Exception { + @Test + public void cannotCreateTransaction() throws Exception { TransactionAttribute txatt = new DefaultTransactionAttribute(); Method m = getNameMethod; @@ -482,7 +501,8 @@ public abstract class AbstractTransactionAspectTests extends TestCase { * Check that the target method was invoked, but that the transaction * infrastructure exception was thrown to the client */ - public void testCannotCommitTransaction() throws Exception { + @Test + public void cannotCommitTransaction() throws Exception { TransactionAttribute txatt = new DefaultTransactionAttribute(); Method m = setNameMethod; diff --git a/spring-tx/src/test/java/org/springframework/transaction/interceptor/BeanFactoryTransactionTests.java b/spring-tx/src/test/java/org/springframework/transaction/interceptor/BeanFactoryTransactionTests.java index 268cee7b..84fc439b 100644 --- a/spring-tx/src/test/java/org/springframework/transaction/interceptor/BeanFactoryTransactionTests.java +++ b/spring-tx/src/test/java/org/springframework/transaction/interceptor/BeanFactoryTransactionTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2015 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,10 +20,11 @@ import java.lang.reflect.Method; import java.lang.reflect.Proxy; import java.util.Map; -import junit.framework.TestCase; - import org.aopalliance.intercept.MethodInterceptor; import org.aopalliance.intercept.MethodInvocation; +import org.junit.Before; +import org.junit.Test; + import org.springframework.aop.support.AopUtils; import org.springframework.aop.support.StaticMethodMatcherPointcut; import org.springframework.aop.target.HotSwappableTargetSource; @@ -40,31 +41,38 @@ import org.springframework.transaction.TransactionDefinition; import org.springframework.transaction.TransactionException; import org.springframework.transaction.TransactionStatus; +import static org.junit.Assert.*; import static org.mockito.BDDMockito.*; + /** * Test cases for AOP transaction management. * * @author Rod Johnson + * @author Juergen Hoeller * @since 23.04.2003 */ -public class BeanFactoryTransactionTests extends TestCase { +public class BeanFactoryTransactionTests { private DefaultListableBeanFactory factory; - @Override + + @Before public void setUp() { this.factory = new DefaultListableBeanFactory(); new XmlBeanDefinitionReader(this.factory).loadBeanDefinitions( new ClassPathResource("transactionalBeanFactory.xml", getClass())); } + + @Test public void testGetsAreNotTransactionalWithProxyFactory1() throws NoSuchMethodException { ITestBean testBean = (ITestBean) factory.getBean("proxyFactory1"); assertTrue("testBean is a dynamic proxy", Proxy.isProxyClass(testBean.getClass())); doTestGetsAreNotTransactional(testBean); } + @Test public void testGetsAreNotTransactionalWithProxyFactory2DynamicProxy() throws NoSuchMethodException { this.factory.preInstantiateSingletons(); ITestBean testBean = (ITestBean) factory.getBean("proxyFactory2DynamicProxy"); @@ -72,12 +80,14 @@ public class BeanFactoryTransactionTests extends TestCase { doTestGetsAreNotTransactional(testBean); } + @Test public void testGetsAreNotTransactionalWithProxyFactory2Cglib() throws NoSuchMethodException { ITestBean testBean = (ITestBean) factory.getBean("proxyFactory2Cglib"); assertTrue("testBean is CGLIB advised", AopUtils.isCglibProxy(testBean)); doTestGetsAreNotTransactional(testBean); } + @Test public void testProxyFactory2Lazy() throws NoSuchMethodException { ITestBean testBean = (ITestBean) factory.getBean("proxyFactory2Lazy"); assertFalse(factory.containsSingleton("target")); @@ -85,6 +95,7 @@ public class BeanFactoryTransactionTests extends TestCase { assertTrue(factory.containsSingleton("target")); } + @Test public void testCglibTransactionProxyImplementsNoInterfaces() throws NoSuchMethodException { ImplementsNoInterfaces ini = (ImplementsNoInterfaces) factory.getBean("cglibNoInterfaces"); assertTrue("testBean is CGLIB advised", AopUtils.isCglibProxy(ini)); @@ -99,6 +110,7 @@ public class BeanFactoryTransactionTests extends TestCase { assertEquals(2, ptm.commits); } + @Test public void testGetsAreNotTransactionalWithProxyFactory3() throws NoSuchMethodException { ITestBean testBean = (ITestBean) factory.getBean("proxyFactory3"); assertTrue("testBean is a full proxy", testBean instanceof DerivedTestBean); @@ -158,14 +170,16 @@ public class BeanFactoryTransactionTests extends TestCase { assertTrue(testBean.getAge() == age); } + @Test public void testGetBeansOfTypeWithAbstract() { - Map beansOfType = factory.getBeansOfType(ITestBean.class, true, true); + Map<String, ITestBean> beansOfType = factory.getBeansOfType(ITestBean.class, true, true); assertNotNull(beansOfType); } /** * Check that we fail gracefully if the user doesn't set any transaction attributes. */ + @Test public void testNoTransactionAttributeSource() { try { DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); @@ -181,6 +195,7 @@ public class BeanFactoryTransactionTests extends TestCase { /** * Test that we can set the target to a dynamic TargetSource. */ + @Test public void testDynamicTargetSource() throws NoSuchMethodException { // Install facade CallCountingTransactionManager txMan = new CallCountingTransactionManager(); @@ -211,7 +226,7 @@ public class BeanFactoryTransactionTests extends TestCase { int counter = 0; @Override - public boolean matches(Method method, Class clazz) { + public boolean matches(Method method, Class<?> clazz) { counter++; return true; } diff --git a/spring-tx/src/test/java/org/springframework/transaction/interceptor/MapTransactionAttributeSource.java b/spring-tx/src/test/java/org/springframework/transaction/interceptor/MapTransactionAttributeSource.java index e21ded17..269da2cd 100644 --- a/spring-tx/src/test/java/org/springframework/transaction/interceptor/MapTransactionAttributeSource.java +++ b/spring-tx/src/test/java/org/springframework/transaction/interceptor/MapTransactionAttributeSource.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,7 +35,7 @@ public class MapTransactionAttributeSource extends AbstractFallbackTransactionAt this.attributeMap.put(method, txAtt); } - public void register(Class clazz, TransactionAttribute txAtt) { + public void register(Class<?> clazz, TransactionAttribute txAtt) { this.attributeMap.put(clazz, txAtt); } @@ -46,7 +46,7 @@ public class MapTransactionAttributeSource extends AbstractFallbackTransactionAt } @Override - protected TransactionAttribute findTransactionAttribute(Class clazz) { + protected TransactionAttribute findTransactionAttribute(Class<?> clazz) { return this.attributeMap.get(clazz); } diff --git a/spring-tx/src/test/java/org/springframework/transaction/interceptor/RollbackRuleTests.java b/spring-tx/src/test/java/org/springframework/transaction/interceptor/RollbackRuleTests.java index 0a45d64b..9f426f1d 100644 --- a/spring-tx/src/test/java/org/springframework/transaction/interceptor/RollbackRuleTests.java +++ b/spring-tx/src/test/java/org/springframework/transaction/interceptor/RollbackRuleTests.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,15 +16,15 @@ package org.springframework.transaction.interceptor; -import static org.hamcrest.CoreMatchers.equalTo; -import static org.junit.Assert.assertThat; - import java.io.IOException; import junit.framework.TestCase; import org.springframework.beans.FatalBeanException; +import static org.hamcrest.CoreMatchers.*; +import static org.junit.Assert.*; + /** * Unit tests for the {@link RollbackRuleAttribute} class. * @@ -75,7 +75,7 @@ public class RollbackRuleTests extends TestCase { public void testCtorArgMustBeAThrowableClassWithNullThrowableType() { try { - new RollbackRuleAttribute((Class) null); + new RollbackRuleAttribute((Class<?>) null); fail("Cannot construct a RollbackRuleAttribute with a null-Throwable type"); } catch (IllegalArgumentException expected) { diff --git a/spring-tx/src/test/java/org/springframework/transaction/interceptor/RuleBasedTransactionAttributeTests.java b/spring-tx/src/test/java/org/springframework/transaction/interceptor/RuleBasedTransactionAttributeTests.java index be7d9c25..e6a3c78e 100644 --- a/spring-tx/src/test/java/org/springframework/transaction/interceptor/RuleBasedTransactionAttributeTests.java +++ b/spring-tx/src/test/java/org/springframework/transaction/interceptor/RuleBasedTransactionAttributeTests.java @@ -16,8 +16,6 @@ package org.springframework.transaction.interceptor; -import static org.junit.Assert.*; - import java.io.IOException; import java.rmi.RemoteException; import java.util.Collections; @@ -25,8 +23,11 @@ import java.util.LinkedList; import java.util.List; import org.junit.Test; + import org.springframework.transaction.TransactionDefinition; +import static org.junit.Assert.*; + /** * @author Rod Johnson * @author Juergen Hoeller diff --git a/spring-tx/src/test/java/org/springframework/transaction/interceptor/TransactionAttributeEditorTests.java b/spring-tx/src/test/java/org/springframework/transaction/interceptor/TransactionAttributeEditorTests.java index 327675aa..dbd329e5 100644 --- a/spring-tx/src/test/java/org/springframework/transaction/interceptor/TransactionAttributeEditorTests.java +++ b/spring-tx/src/test/java/org/springframework/transaction/interceptor/TransactionAttributeEditorTests.java @@ -17,13 +17,14 @@ package org.springframework.transaction.interceptor; -import static org.junit.Assert.*; - import java.io.IOException; import org.junit.Test; + import org.springframework.transaction.TransactionDefinition; +import static org.junit.Assert.*; + /** * Tests to check conversion from String to TransactionAttribute. * diff --git a/spring-tx/src/test/java/org/springframework/transaction/interceptor/TransactionAttributeSourceAdvisorTests.java b/spring-tx/src/test/java/org/springframework/transaction/interceptor/TransactionAttributeSourceAdvisorTests.java index bfd9071c..a47f6c2d 100644 --- a/spring-tx/src/test/java/org/springframework/transaction/interceptor/TransactionAttributeSourceAdvisorTests.java +++ b/spring-tx/src/test/java/org/springframework/transaction/interceptor/TransactionAttributeSourceAdvisorTests.java @@ -18,10 +18,10 @@ package org.springframework.transaction.interceptor; import java.util.Properties; -import org.springframework.util.SerializationTestUtils; - import junit.framework.TestCase; +import org.springframework.util.SerializationTestUtils; + /** * * @author Rod Johnson diff --git a/spring-tx/src/test/java/org/springframework/transaction/interceptor/TransactionAttributeSourceTests.java b/spring-tx/src/test/java/org/springframework/transaction/interceptor/TransactionAttributeSourceTests.java index 7871f11a..0dce6663 100644 --- a/spring-tx/src/test/java/org/springframework/transaction/interceptor/TransactionAttributeSourceTests.java +++ b/spring-tx/src/test/java/org/springframework/transaction/interceptor/TransactionAttributeSourceTests.java @@ -16,8 +16,6 @@ package org.springframework.transaction.interceptor; -import static org.junit.Assert.*; - import java.io.IOException; import java.util.HashMap; import java.util.Map; @@ -25,8 +23,11 @@ import java.util.Properties; import org.junit.Ignore; import org.junit.Test; + import org.springframework.transaction.TransactionDefinition; +import static org.junit.Assert.*; + /** * Unit tests for the various {@link TransactionAttributeSource} implementations. * diff --git a/spring-tx/src/test/java/org/springframework/transaction/interceptor/TransactionInterceptorTests.java b/spring-tx/src/test/java/org/springframework/transaction/interceptor/TransactionInterceptorTests.java index 9b41bc39..c976f910 100644 --- a/spring-tx/src/test/java/org/springframework/transaction/interceptor/TransactionInterceptorTests.java +++ b/spring-tx/src/test/java/org/springframework/transaction/interceptor/TransactionInterceptorTests.java @@ -19,13 +19,25 @@ package org.springframework.transaction.interceptor; import java.io.Serializable; import java.util.Properties; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; + import org.springframework.aop.framework.ProxyFactory; +import org.springframework.beans.factory.BeanFactory; +import org.springframework.beans.factory.NoSuchBeanDefinitionException; import org.springframework.transaction.PlatformTransactionManager; import org.springframework.transaction.TransactionDefinition; import org.springframework.transaction.TransactionException; import org.springframework.transaction.TransactionStatus; import org.springframework.util.SerializationTestUtils; +import static org.junit.Assert.*; +import static org.mockito.BDDMockito.*; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; + /** * Mock object based tests for TransactionInterceptor. * @@ -34,6 +46,9 @@ import org.springframework.util.SerializationTestUtils; */ public class TransactionInterceptorTests extends AbstractTransactionAspectTests { + @Rule + public final ExpectedException thrown = ExpectedException.none(); + @Override protected Object advised(Object target, PlatformTransactionManager ptm, TransactionAttributeSource[] tas) throws Exception { TransactionInterceptor ti = new TransactionInterceptor(); @@ -63,11 +78,12 @@ public class TransactionInterceptorTests extends AbstractTransactionAspectTests return pf.getProxy(); } -/** + /** * A TransactionInterceptor should be serializable if its * PlatformTransactionManager is. */ - public void testSerializableWithAttributeProperties() throws Exception { + @Test + public void serializableWithAttributeProperties() throws Exception { TransactionInterceptor ti = new TransactionInterceptor(); Properties props = new Properties(); props.setProperty("methodName", "PROPAGATION_REQUIRED"); @@ -82,7 +98,8 @@ public class TransactionInterceptorTests extends AbstractTransactionAspectTests assertNotNull(ti.getTransactionAttributeSource()); } - public void testSerializableWithCompositeSource() throws Exception { + @Test + public void serializableWithCompositeSource() throws Exception { NameMatchTransactionAttributeSource tas1 = new NameMatchTransactionAttributeSource(); Properties props = new Properties(); props.setProperty("methodName", "PROPAGATION_REQUIRED"); @@ -106,6 +123,181 @@ public class TransactionInterceptorTests extends AbstractTransactionAspectTests assertTrue(ctas.getTransactionAttributeSources()[1] instanceof NameMatchTransactionAttributeSource); } + @Test + public void determineTransactionManagerWithNoBeanFactory() { + PlatformTransactionManager transactionManager = mock(PlatformTransactionManager.class); + TransactionInterceptor ti = transactionInterceptorWithTransactionManager(transactionManager, null); + + assertSame(transactionManager, ti.determineTransactionManager(new DefaultTransactionAttribute())); + } + + @Test + public void determineTransactionManagerWithNoBeanFactoryAndNoTransactionAttribute() { + PlatformTransactionManager transactionManager = mock(PlatformTransactionManager.class); + TransactionInterceptor ti = transactionInterceptorWithTransactionManager(transactionManager, null); + + assertSame(transactionManager, ti.determineTransactionManager(null)); + } + + @Test + public void determineTransactionManagerWithNoTransactionAttribute() { + BeanFactory beanFactory = mock(BeanFactory.class); + TransactionInterceptor ti = simpleTransactionInterceptor(beanFactory); + + assertNull(ti.determineTransactionManager(null)); + } + + @Test + public void determineTransactionManagerWithQualifierUnknown() { + BeanFactory beanFactory = mock(BeanFactory.class); + TransactionInterceptor ti = simpleTransactionInterceptor(beanFactory); + DefaultTransactionAttribute attribute = new DefaultTransactionAttribute(); + attribute.setQualifier("fooTransactionManager"); + + thrown.expect(NoSuchBeanDefinitionException.class); + thrown.expectMessage("'fooTransactionManager'"); + ti.determineTransactionManager(attribute); + } + + @Test + public void determineTransactionManagerWithQualifierAndDefault() { + BeanFactory beanFactory = mock(BeanFactory.class); + PlatformTransactionManager transactionManager = mock(PlatformTransactionManager.class); + TransactionInterceptor ti = transactionInterceptorWithTransactionManager(transactionManager, beanFactory); + PlatformTransactionManager fooTransactionManager = + associateTransactionManager(beanFactory, "fooTransactionManager"); + + DefaultTransactionAttribute attribute = new DefaultTransactionAttribute(); + attribute.setQualifier("fooTransactionManager"); + + assertSame(fooTransactionManager, ti.determineTransactionManager(attribute)); + } + + @Test + public void determineTransactionManagerWithQualifierAndDefaultName() { + BeanFactory beanFactory = mock(BeanFactory.class); + associateTransactionManager(beanFactory, "defaultTransactionManager"); + TransactionInterceptor ti = transactionInterceptorWithTransactionManagerName( + "defaultTransactionManager", beanFactory); + + PlatformTransactionManager fooTransactionManager = + associateTransactionManager(beanFactory, "fooTransactionManager"); + DefaultTransactionAttribute attribute = new DefaultTransactionAttribute(); + attribute.setQualifier("fooTransactionManager"); + + assertSame(fooTransactionManager, ti.determineTransactionManager(attribute)); + } + + @Test + public void determineTransactionManagerWithEmptyQualifierAndDefaultName() { + BeanFactory beanFactory = mock(BeanFactory.class); + PlatformTransactionManager defaultTransactionManager + = associateTransactionManager(beanFactory, "defaultTransactionManager"); + TransactionInterceptor ti = transactionInterceptorWithTransactionManagerName( + "defaultTransactionManager", beanFactory); + + DefaultTransactionAttribute attribute = new DefaultTransactionAttribute(); + attribute.setQualifier(""); + + assertSame(defaultTransactionManager, ti.determineTransactionManager(attribute)); + } + + @Test + public void determineTransactionManagerWithQualifierSeveralTimes() { + BeanFactory beanFactory = mock(BeanFactory.class); + TransactionInterceptor ti = simpleTransactionInterceptor(beanFactory); + + PlatformTransactionManager txManager = associateTransactionManager(beanFactory, "fooTransactionManager"); + + DefaultTransactionAttribute attribute = new DefaultTransactionAttribute(); + attribute.setQualifier("fooTransactionManager"); + PlatformTransactionManager actual = ti.determineTransactionManager(attribute); + assertSame(txManager, actual); + + // Call again, should be cached + PlatformTransactionManager actual2 = ti.determineTransactionManager(attribute); + assertSame(txManager, actual2); + verify(beanFactory, times(1)).containsBean("fooTransactionManager"); + verify(beanFactory, times(1)).getBean("fooTransactionManager", PlatformTransactionManager.class); + } + + @Test + public void determineTransactionManagerWithBeanNameSeveralTimes() { + BeanFactory beanFactory = mock(BeanFactory.class); + TransactionInterceptor ti = transactionInterceptorWithTransactionManagerName( + "fooTransactionManager", beanFactory); + + PlatformTransactionManager txManager = associateTransactionManager(beanFactory, "fooTransactionManager"); + + DefaultTransactionAttribute attribute = new DefaultTransactionAttribute(); + PlatformTransactionManager actual = ti.determineTransactionManager(attribute); + assertSame(txManager, actual); + + // Call again, should be cached + PlatformTransactionManager actual2 = ti.determineTransactionManager(attribute); + assertSame(txManager, actual2); + verify(beanFactory, times(1)).getBean("fooTransactionManager", PlatformTransactionManager.class); + } + + @Test + public void determineTransactionManagerDefaultSeveralTimes() { + BeanFactory beanFactory = mock(BeanFactory.class); + TransactionInterceptor ti = simpleTransactionInterceptor(beanFactory); + + PlatformTransactionManager txManager = mock(PlatformTransactionManager.class); + given(beanFactory.getBean(PlatformTransactionManager.class)).willReturn(txManager); + + DefaultTransactionAttribute attribute = new DefaultTransactionAttribute(); + PlatformTransactionManager actual = ti.determineTransactionManager(attribute); + assertSame(txManager, actual); + + // Call again, should be cached + PlatformTransactionManager actual2 = ti.determineTransactionManager(attribute); + assertSame(txManager, actual2); + verify(beanFactory, times(1)).getBean(PlatformTransactionManager.class); + } + + private TransactionInterceptor createTransactionInterceptor(BeanFactory beanFactory, + String transactionManagerName, PlatformTransactionManager transactionManager) { + TransactionInterceptor ti = new TransactionInterceptor(); + if (beanFactory != null) { + ti.setBeanFactory(beanFactory); + } + if (transactionManagerName != null) { + ti.setTransactionManagerBeanName(transactionManagerName); + + } + if (transactionManager != null) { + ti.setTransactionManager(transactionManager); + } + ti.setTransactionAttributeSource(new NameMatchTransactionAttributeSource()); + ti.afterPropertiesSet(); + return ti; + } + + private TransactionInterceptor transactionInterceptorWithTransactionManager( + PlatformTransactionManager transactionManager, BeanFactory beanFactory) { + + return createTransactionInterceptor(beanFactory, null, transactionManager); + } + + private TransactionInterceptor transactionInterceptorWithTransactionManagerName( + String transactionManagerName, BeanFactory beanFactory) { + + return createTransactionInterceptor(beanFactory, transactionManagerName, null); + } + + private TransactionInterceptor simpleTransactionInterceptor(BeanFactory beanFactory) { + return createTransactionInterceptor(beanFactory, null, null); + } + + private PlatformTransactionManager associateTransactionManager(BeanFactory beanFactory, String name) { + PlatformTransactionManager transactionManager = mock(PlatformTransactionManager.class); + given(beanFactory.containsBean(name)).willReturn(true); + given(beanFactory.getBean(name, PlatformTransactionManager.class)).willReturn(transactionManager); + return transactionManager; + } + /** * We won't use this: we just want to know it's serializable. diff --git a/spring-tx/src/test/java/org/springframework/transaction/jta/MockUOWManager.java b/spring-tx/src/test/java/org/springframework/transaction/jta/MockUOWManager.java index aed9bdb2..5daf7629 100644 --- a/spring-tx/src/test/java/org/springframework/transaction/jta/MockUOWManager.java +++ b/spring-tx/src/test/java/org/springframework/transaction/jta/MockUOWManager.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,7 +20,6 @@ import java.util.HashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; - import javax.transaction.Synchronization; import com.ibm.wsspi.uow.UOWAction; @@ -43,9 +42,9 @@ public class MockUOWManager implements UOWManager { private int status = UOW_STATUS_NONE; - private final Map resources = new HashMap(); + private final Map<Object, Object> resources = new HashMap<Object, Object>(); - private final List synchronizations = new LinkedList(); + private final List<Synchronization> synchronizations = new LinkedList<Synchronization>(); @Override diff --git a/spring-tx/src/test/java/org/springframework/transaction/jta/WebSphereUowTransactionManagerTests.java b/spring-tx/src/test/java/org/springframework/transaction/jta/WebSphereUowTransactionManagerTests.java index 802b7fd0..904e88f3 100644 --- a/spring-tx/src/test/java/org/springframework/transaction/jta/WebSphereUowTransactionManagerTests.java +++ b/spring-tx/src/test/java/org/springframework/transaction/jta/WebSphereUowTransactionManagerTests.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. @@ -20,6 +20,9 @@ import javax.transaction.RollbackException; import javax.transaction.Status; import javax.transaction.UserTransaction; +import com.ibm.wsspi.uow.UOWAction; +import com.ibm.wsspi.uow.UOWException; +import com.ibm.wsspi.uow.UOWManager; import junit.framework.TestCase; import org.springframework.dao.OptimisticLockingFailureException; @@ -33,10 +36,6 @@ import org.springframework.transaction.support.DefaultTransactionDefinition; import org.springframework.transaction.support.TransactionCallback; import org.springframework.transaction.support.TransactionSynchronizationManager; -import com.ibm.wsspi.uow.UOWAction; -import com.ibm.wsspi.uow.UOWException; -import com.ibm.wsspi.uow.UOWManager; - import static org.mockito.BDDMockito.*; /** @@ -53,9 +52,9 @@ public class WebSphereUowTransactionManagerTests extends TestCase { ptm.afterPropertiesSet(); DefaultTransactionDefinition definition = new DefaultTransactionDefinition(); - assertEquals("result", ptm.execute(definition, new TransactionCallback() { + assertEquals("result", ptm.execute(definition, new TransactionCallback<String>() { @Override - public Object doInTransaction(TransactionStatus status) { + public String doInTransaction(TransactionStatus status) { return "result"; } })); @@ -80,9 +79,9 @@ public class WebSphereUowTransactionManagerTests extends TestCase { DefaultTransactionDefinition definition = new DefaultTransactionDefinition(); TransactionStatus ts = ptm.getTransaction(definition); ptm.commit(ts); - assertEquals("result", ptm.execute(definition, new TransactionCallback() { + assertEquals("result", ptm.execute(definition, new TransactionCallback<String>() { @Override - public Object doInTransaction(TransactionStatus status) { + public String doInTransaction(TransactionStatus status) { return "result"; } })); @@ -101,9 +100,9 @@ public class WebSphereUowTransactionManagerTests extends TestCase { definition.setPropagationBehavior(TransactionDefinition.PROPAGATION_MANDATORY); try { - ptm.execute(definition, new TransactionCallback() { + ptm.execute(definition, new TransactionCallback<String>() { @Override - public Object doInTransaction(TransactionStatus status) { + public String doInTransaction(TransactionStatus status) { return "result"; } }); @@ -171,9 +170,9 @@ public class WebSphereUowTransactionManagerTests extends TestCase { assertFalse(TransactionSynchronizationManager.isActualTransactionActive()); assertFalse(TransactionSynchronizationManager.isCurrentTransactionReadOnly()); - assertEquals("result", ptm.execute(definition, new TransactionCallback() { + assertEquals("result", ptm.execute(definition, new TransactionCallback<String>() { @Override - public Object doInTransaction(TransactionStatus status) { + public String doInTransaction(TransactionStatus status) { if (synchMode == WebSphereUowTransactionManager.SYNCHRONIZATION_ALWAYS) { assertTrue(TransactionSynchronizationManager.isSynchronizationActive()); assertFalse(TransactionSynchronizationManager.isActualTransactionActive()); @@ -255,9 +254,9 @@ public class WebSphereUowTransactionManagerTests extends TestCase { assertFalse(TransactionSynchronizationManager.isActualTransactionActive()); assertFalse(TransactionSynchronizationManager.isCurrentTransactionReadOnly()); - assertEquals("result", ptm.execute(definition, new TransactionCallback() { + assertEquals("result", ptm.execute(definition, new TransactionCallback<String>() { @Override - public Object doInTransaction(TransactionStatus status) { + public String doInTransaction(TransactionStatus status) { if (synchMode != WebSphereUowTransactionManager.SYNCHRONIZATION_NEVER) { assertTrue(TransactionSynchronizationManager.isSynchronizationActive()); assertTrue(TransactionSynchronizationManager.isActualTransactionActive()); @@ -293,9 +292,9 @@ public class WebSphereUowTransactionManagerTests extends TestCase { assertFalse(TransactionSynchronizationManager.isActualTransactionActive()); assertFalse(TransactionSynchronizationManager.isCurrentTransactionReadOnly()); - assertEquals("result", ptm.execute(definition, new TransactionCallback() { + assertEquals("result", ptm.execute(definition, new TransactionCallback<String>() { @Override - public Object doInTransaction(TransactionStatus status) { + public String doInTransaction(TransactionStatus status) { assertTrue(TransactionSynchronizationManager.isSynchronizationActive()); assertTrue(TransactionSynchronizationManager.isActualTransactionActive()); assertTrue(TransactionSynchronizationManager.isCurrentTransactionReadOnly()); @@ -329,9 +328,9 @@ public class WebSphereUowTransactionManagerTests extends TestCase { assertFalse(TransactionSynchronizationManager.isCurrentTransactionReadOnly()); try { - ptm.execute(definition, new TransactionCallback() { + ptm.execute(definition, new TransactionCallback<String>() { @Override - public Object doInTransaction(TransactionStatus status) { + public String doInTransaction(TransactionStatus status) { assertTrue(TransactionSynchronizationManager.isSynchronizationActive()); assertTrue(TransactionSynchronizationManager.isActualTransactionActive()); assertFalse(TransactionSynchronizationManager.isCurrentTransactionReadOnly()); @@ -364,9 +363,9 @@ public class WebSphereUowTransactionManagerTests extends TestCase { assertFalse(TransactionSynchronizationManager.isCurrentTransactionReadOnly()); try { - ptm.execute(definition, new TransactionCallback() { + ptm.execute(definition, new TransactionCallback<String>() { @Override - public Object doInTransaction(TransactionStatus status) { + public String doInTransaction(TransactionStatus status) { assertTrue(TransactionSynchronizationManager.isSynchronizationActive()); assertTrue(TransactionSynchronizationManager.isActualTransactionActive()); assertFalse(TransactionSynchronizationManager.isCurrentTransactionReadOnly()); @@ -398,9 +397,9 @@ public class WebSphereUowTransactionManagerTests extends TestCase { assertFalse(TransactionSynchronizationManager.isActualTransactionActive()); assertFalse(TransactionSynchronizationManager.isCurrentTransactionReadOnly()); - assertEquals("result", ptm.execute(definition, new TransactionCallback() { + assertEquals("result", ptm.execute(definition, new TransactionCallback<String>() { @Override - public Object doInTransaction(TransactionStatus status) { + public String doInTransaction(TransactionStatus status) { assertTrue(TransactionSynchronizationManager.isSynchronizationActive()); assertTrue(TransactionSynchronizationManager.isActualTransactionActive()); assertFalse(TransactionSynchronizationManager.isCurrentTransactionReadOnly()); @@ -429,9 +428,9 @@ public class WebSphereUowTransactionManagerTests extends TestCase { assertFalse(TransactionSynchronizationManager.isActualTransactionActive()); assertFalse(TransactionSynchronizationManager.isCurrentTransactionReadOnly()); - assertEquals("result", ptm.execute(definition, new TransactionCallback() { + assertEquals("result", ptm.execute(definition, new TransactionCallback<String>() { @Override - public Object doInTransaction(TransactionStatus status) { + public String doInTransaction(TransactionStatus status) { assertTrue(TransactionSynchronizationManager.isSynchronizationActive()); assertTrue(TransactionSynchronizationManager.isActualTransactionActive()); assertFalse(TransactionSynchronizationManager.isCurrentTransactionReadOnly()); @@ -457,9 +456,9 @@ public class WebSphereUowTransactionManagerTests extends TestCase { definition.setPropagationBehavior(TransactionDefinition.PROPAGATION_NEVER); try { - ptm.execute(definition, new TransactionCallback() { + ptm.execute(definition, new TransactionCallback<String>() { @Override - public Object doInTransaction(TransactionStatus status) { + public String doInTransaction(TransactionStatus status) { return "result"; } }); @@ -478,9 +477,9 @@ public class WebSphereUowTransactionManagerTests extends TestCase { definition.setPropagationBehavior(TransactionDefinition.PROPAGATION_NESTED); try { - ptm.execute(definition, new TransactionCallback() { + ptm.execute(definition, new TransactionCallback<String>() { @Override - public Object doInTransaction(TransactionStatus status) { + public String doInTransaction(TransactionStatus status) { return "result"; } }); @@ -515,15 +514,15 @@ public class WebSphereUowTransactionManagerTests extends TestCase { assertFalse(TransactionSynchronizationManager.isActualTransactionActive()); assertFalse(TransactionSynchronizationManager.isCurrentTransactionReadOnly()); - assertEquals("result", ptm.execute(definition, new TransactionCallback() { + assertEquals("result", ptm.execute(definition, new TransactionCallback<String>() { @Override - public Object doInTransaction(TransactionStatus status) { + public String doInTransaction(TransactionStatus status) { assertTrue(TransactionSynchronizationManager.isSynchronizationActive()); assertTrue(TransactionSynchronizationManager.isActualTransactionActive()); assertFalse(TransactionSynchronizationManager.isCurrentTransactionReadOnly()); - assertEquals("result2", ptm.execute(definition2, new TransactionCallback() { + assertEquals("result2", ptm.execute(definition2, new TransactionCallback<String>() { @Override - public Object doInTransaction(TransactionStatus status) { + public String doInTransaction(TransactionStatus status) { assertTrue(TransactionSynchronizationManager.isSynchronizationActive()); assertTrue(TransactionSynchronizationManager.isActualTransactionActive()); assertFalse(TransactionSynchronizationManager.isCurrentTransactionReadOnly()); @@ -564,15 +563,15 @@ public class WebSphereUowTransactionManagerTests extends TestCase { assertFalse(TransactionSynchronizationManager.isActualTransactionActive()); assertFalse(TransactionSynchronizationManager.isCurrentTransactionReadOnly()); - assertEquals("result", ptm.execute(definition, new TransactionCallback() { + assertEquals("result", ptm.execute(definition, new TransactionCallback<String>() { @Override - public Object doInTransaction(TransactionStatus status) { + public String doInTransaction(TransactionStatus status) { assertTrue(TransactionSynchronizationManager.isSynchronizationActive()); assertTrue(TransactionSynchronizationManager.isActualTransactionActive()); assertFalse(TransactionSynchronizationManager.isCurrentTransactionReadOnly()); - assertEquals("result2", ptm.execute(definition2, new TransactionCallback() { + assertEquals("result2", ptm.execute(definition2, new TransactionCallback<String>() { @Override - public Object doInTransaction(TransactionStatus status) { + public String doInTransaction(TransactionStatus status) { assertTrue(TransactionSynchronizationManager.isSynchronizationActive()); assertEquals(propagationBehavior == TransactionDefinition.PROPAGATION_REQUIRES_NEW, TransactionSynchronizationManager.isActualTransactionActive()); @@ -611,15 +610,15 @@ public class WebSphereUowTransactionManagerTests extends TestCase { assertFalse(TransactionSynchronizationManager.isActualTransactionActive()); assertFalse(TransactionSynchronizationManager.isCurrentTransactionReadOnly()); - assertEquals("result", ptm.execute(definition, new TransactionCallback() { + assertEquals("result", ptm.execute(definition, new TransactionCallback<String>() { @Override - public Object doInTransaction(TransactionStatus status) { + public String doInTransaction(TransactionStatus status) { assertTrue(TransactionSynchronizationManager.isSynchronizationActive()); assertTrue(TransactionSynchronizationManager.isActualTransactionActive()); assertFalse(TransactionSynchronizationManager.isCurrentTransactionReadOnly()); - assertEquals("result2", ptm.execute(definition2, new TransactionCallback() { + assertEquals("result2", ptm.execute(definition2, new TransactionCallback<String>() { @Override - public Object doInTransaction(TransactionStatus status) { + public String doInTransaction(TransactionStatus status) { assertTrue(TransactionSynchronizationManager.isSynchronizationActive()); assertFalse(TransactionSynchronizationManager.isActualTransactionActive()); assertTrue(TransactionSynchronizationManager.isCurrentTransactionReadOnly()); |