diff --git a/org.springframework.testsuite/src/test/java/org/springframework/transaction/CallCountingTransactionManager.java b/org.springframework.transaction/src/test/java/org/springframework/transaction/CallCountingTransactionManager.java similarity index 100% rename from org.springframework.testsuite/src/test/java/org/springframework/transaction/CallCountingTransactionManager.java rename to org.springframework.transaction/src/test/java/org/springframework/transaction/CallCountingTransactionManager.java diff --git a/org.springframework.testsuite/src/test/java/org/springframework/transaction/JndiJtaTransactionManagerTests.java b/org.springframework.transaction/src/test/java/org/springframework/transaction/JndiJtaTransactionManagerTests.java similarity index 100% rename from org.springframework.testsuite/src/test/java/org/springframework/transaction/JndiJtaTransactionManagerTests.java rename to org.springframework.transaction/src/test/java/org/springframework/transaction/JndiJtaTransactionManagerTests.java diff --git a/org.springframework.testsuite/src/test/java/org/springframework/transaction/JtaTransactionManagerTests.java b/org.springframework.transaction/src/test/java/org/springframework/transaction/JtaTransactionManagerTests.java similarity index 100% rename from org.springframework.testsuite/src/test/java/org/springframework/transaction/JtaTransactionManagerTests.java rename to org.springframework.transaction/src/test/java/org/springframework/transaction/JtaTransactionManagerTests.java diff --git a/org.springframework.testsuite/src/test/java/org/springframework/transaction/MockCallbackPreferringTransactionManager.java b/org.springframework.transaction/src/test/java/org/springframework/transaction/MockCallbackPreferringTransactionManager.java similarity index 100% rename from org.springframework.testsuite/src/test/java/org/springframework/transaction/MockCallbackPreferringTransactionManager.java rename to org.springframework.transaction/src/test/java/org/springframework/transaction/MockCallbackPreferringTransactionManager.java diff --git a/org.springframework.testsuite/src/test/java/org/springframework/transaction/MockJtaTransaction.java b/org.springframework.transaction/src/test/java/org/springframework/transaction/MockJtaTransaction.java similarity index 100% rename from org.springframework.testsuite/src/test/java/org/springframework/transaction/MockJtaTransaction.java rename to org.springframework.transaction/src/test/java/org/springframework/transaction/MockJtaTransaction.java diff --git a/org.springframework.testsuite/src/test/java/org/springframework/transaction/TestTransactionManager.java b/org.springframework.transaction/src/test/java/org/springframework/transaction/TestTransactionManager.java similarity index 100% rename from org.springframework.testsuite/src/test/java/org/springframework/transaction/TestTransactionManager.java rename to org.springframework.transaction/src/test/java/org/springframework/transaction/TestTransactionManager.java diff --git a/org.springframework.testsuite/src/test/java/org/springframework/transaction/TransactionSupportTests.java b/org.springframework.transaction/src/test/java/org/springframework/transaction/TransactionSupportTests.java similarity index 100% rename from org.springframework.testsuite/src/test/java/org/springframework/transaction/TransactionSupportTests.java rename to org.springframework.transaction/src/test/java/org/springframework/transaction/TransactionSupportTests.java diff --git a/org.springframework.testsuite/src/test/java/org/springframework/transaction/TxNamespaceHandlerEventTests.java b/org.springframework.transaction/src/test/java/org/springframework/transaction/TxNamespaceHandlerEventTests.java similarity index 100% rename from org.springframework.testsuite/src/test/java/org/springframework/transaction/TxNamespaceHandlerEventTests.java rename to org.springframework.transaction/src/test/java/org/springframework/transaction/TxNamespaceHandlerEventTests.java diff --git a/org.springframework.testsuite/src/test/java/org/springframework/transaction/TxNamespaceHandlerTests.java b/org.springframework.transaction/src/test/java/org/springframework/transaction/TxNamespaceHandlerTests.java similarity index 100% rename from org.springframework.testsuite/src/test/java/org/springframework/transaction/TxNamespaceHandlerTests.java rename to org.springframework.transaction/src/test/java/org/springframework/transaction/TxNamespaceHandlerTests.java diff --git a/org.springframework.testsuite/src/test/java/org/springframework/transaction/annotation/AnnotationTransactionAttributeSourceTests.java b/org.springframework.transaction/src/test/java/org/springframework/transaction/annotation/AnnotationTransactionAttributeSourceTests.java similarity index 100% rename from org.springframework.testsuite/src/test/java/org/springframework/transaction/annotation/AnnotationTransactionAttributeSourceTests.java rename to org.springframework.transaction/src/test/java/org/springframework/transaction/annotation/AnnotationTransactionAttributeSourceTests.java diff --git a/org.springframework.testsuite/src/test/java/org/springframework/transaction/annotation/AnnotationTransactionInterceptorTests.java b/org.springframework.transaction/src/test/java/org/springframework/transaction/annotation/AnnotationTransactionInterceptorTests.java similarity index 100% rename from org.springframework.testsuite/src/test/java/org/springframework/transaction/annotation/AnnotationTransactionInterceptorTests.java rename to org.springframework.transaction/src/test/java/org/springframework/transaction/annotation/AnnotationTransactionInterceptorTests.java diff --git a/org.springframework.testsuite/src/test/java/org/springframework/transaction/annotation/AnnotationTransactionNamespaceHandlerTests.java b/org.springframework.transaction/src/test/java/org/springframework/transaction/annotation/AnnotationTransactionNamespaceHandlerTests.java similarity index 100% rename from org.springframework.testsuite/src/test/java/org/springframework/transaction/annotation/AnnotationTransactionNamespaceHandlerTests.java rename to org.springframework.transaction/src/test/java/org/springframework/transaction/annotation/AnnotationTransactionNamespaceHandlerTests.java diff --git a/org.springframework.testsuite/src/test/java/org/springframework/transaction/annotation/annotationTransactionNamespaceHandlerTests.xml b/org.springframework.transaction/src/test/java/org/springframework/transaction/annotation/annotationTransactionNamespaceHandlerTests.xml similarity index 100% rename from org.springframework.testsuite/src/test/java/org/springframework/transaction/annotation/annotationTransactionNamespaceHandlerTests.xml rename to org.springframework.transaction/src/test/java/org/springframework/transaction/annotation/annotationTransactionNamespaceHandlerTests.xml diff --git a/org.springframework.testsuite/src/test/java/org/springframework/transaction/config/AnnotationDrivenTests.java b/org.springframework.transaction/src/test/java/org/springframework/transaction/config/AnnotationDrivenTests.java similarity index 100% rename from org.springframework.testsuite/src/test/java/org/springframework/transaction/config/AnnotationDrivenTests.java rename to org.springframework.transaction/src/test/java/org/springframework/transaction/config/AnnotationDrivenTests.java diff --git a/org.springframework.testsuite/src/test/java/org/springframework/transaction/config/TransactionalService.java b/org.springframework.transaction/src/test/java/org/springframework/transaction/config/TransactionalService.java similarity index 100% rename from org.springframework.testsuite/src/test/java/org/springframework/transaction/config/TransactionalService.java rename to org.springframework.transaction/src/test/java/org/springframework/transaction/config/TransactionalService.java diff --git a/org.springframework.testsuite/src/test/java/org/springframework/transaction/config/annotationDrivenProxyTargetClassTests.xml b/org.springframework.transaction/src/test/java/org/springframework/transaction/config/annotationDrivenProxyTargetClassTests.xml similarity index 100% rename from org.springframework.testsuite/src/test/java/org/springframework/transaction/config/annotationDrivenProxyTargetClassTests.xml rename to org.springframework.transaction/src/test/java/org/springframework/transaction/config/annotationDrivenProxyTargetClassTests.xml diff --git a/org.springframework.testsuite/src/test/java/org/springframework/transaction/interceptor/AbstractTransactionAspectTests.java b/org.springframework.transaction/src/test/java/org/springframework/transaction/interceptor/AbstractTransactionAspectTests.java similarity index 100% rename from org.springframework.testsuite/src/test/java/org/springframework/transaction/interceptor/AbstractTransactionAspectTests.java rename to org.springframework.transaction/src/test/java/org/springframework/transaction/interceptor/AbstractTransactionAspectTests.java diff --git a/org.springframework.testsuite/src/test/java/org/springframework/transaction/interceptor/BeanFactoryTransactionTests.java b/org.springframework.transaction/src/test/java/org/springframework/transaction/interceptor/BeanFactoryTransactionTests.java similarity index 100% rename from org.springframework.testsuite/src/test/java/org/springframework/transaction/interceptor/BeanFactoryTransactionTests.java rename to org.springframework.transaction/src/test/java/org/springframework/transaction/interceptor/BeanFactoryTransactionTests.java diff --git a/org.springframework.testsuite/src/test/java/org/springframework/transaction/interceptor/ImplementsNoInterfaces.java b/org.springframework.transaction/src/test/java/org/springframework/transaction/interceptor/ImplementsNoInterfaces.java similarity index 100% rename from org.springframework.testsuite/src/test/java/org/springframework/transaction/interceptor/ImplementsNoInterfaces.java rename to org.springframework.transaction/src/test/java/org/springframework/transaction/interceptor/ImplementsNoInterfaces.java diff --git a/org.springframework.testsuite/src/test/java/org/springframework/transaction/interceptor/MapTransactionAttributeSource.java b/org.springframework.transaction/src/test/java/org/springframework/transaction/interceptor/MapTransactionAttributeSource.java similarity index 100% rename from org.springframework.testsuite/src/test/java/org/springframework/transaction/interceptor/MapTransactionAttributeSource.java rename to org.springframework.transaction/src/test/java/org/springframework/transaction/interceptor/MapTransactionAttributeSource.java diff --git a/org.springframework.transaction/src/test/java/org/springframework/transaction/interceptor/MyRuntimeException.java b/org.springframework.transaction/src/test/java/org/springframework/transaction/interceptor/MyRuntimeException.java new file mode 100644 index 00000000000..674edb6befd --- /dev/null +++ b/org.springframework.transaction/src/test/java/org/springframework/transaction/interceptor/MyRuntimeException.java @@ -0,0 +1,31 @@ +/* + * Copyright 2002-2008 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.transaction.interceptor; + +import org.springframework.core.NestedRuntimeException; + +/** + * An example {@link RuntimeException} for use in testing rollback rules. + * + * @author Chris Beams + */ +@SuppressWarnings("serial") +class MyRuntimeException extends NestedRuntimeException { + public MyRuntimeException(String msg) { + super(msg); + } +} \ No newline at end of file diff --git a/org.springframework.testsuite/src/test/java/org/springframework/transaction/interceptor/PlatformTransactionManagerFacade.java b/org.springframework.transaction/src/test/java/org/springframework/transaction/interceptor/PlatformTransactionManagerFacade.java similarity index 100% rename from org.springframework.testsuite/src/test/java/org/springframework/transaction/interceptor/PlatformTransactionManagerFacade.java rename to org.springframework.transaction/src/test/java/org/springframework/transaction/interceptor/PlatformTransactionManagerFacade.java diff --git a/org.springframework.testsuite/src/test/java/org/springframework/transaction/interceptor/RollbackRuleTests.java b/org.springframework.transaction/src/test/java/org/springframework/transaction/interceptor/RollbackRuleTests.java similarity index 73% rename from org.springframework.testsuite/src/test/java/org/springframework/transaction/interceptor/RollbackRuleTests.java rename to org.springframework.transaction/src/test/java/org/springframework/transaction/interceptor/RollbackRuleTests.java index 789ff37a158..c9125fc6cd8 100644 --- a/org.springframework.testsuite/src/test/java/org/springframework/transaction/interceptor/RollbackRuleTests.java +++ b/org.springframework.transaction/src/test/java/org/springframework/transaction/interceptor/RollbackRuleTests.java @@ -16,24 +16,27 @@ package org.springframework.transaction.interceptor; -import javax.servlet.ServletException; +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 org.springframework.mail.MailSendException; /** * Unit tests for the {@link RollbackRuleAttribute} class. * * @author Rod Johnson * @author Rick Evans + * @author Chris Beams * @since 09.04.2003 */ public class RollbackRuleTests extends TestCase { public void testFoundImmediatelyWithString() { - RollbackRuleAttribute rr = new RollbackRuleAttribute("java.lang.Exception"); + RollbackRuleAttribute rr = new RollbackRuleAttribute(java.lang.Exception.class.getName()); assertTrue(rr.getDepth(new Exception()) == 0); } @@ -43,20 +46,20 @@ public class RollbackRuleTests extends TestCase { } public void testNotFound() { - RollbackRuleAttribute rr = new RollbackRuleAttribute("javax.servlet.ServletException"); - assertTrue(rr.getDepth(new MailSendException("")) == -1); + RollbackRuleAttribute rr = new RollbackRuleAttribute(java.io.IOException.class.getName()); + assertTrue(rr.getDepth(new MyRuntimeException("")) == -1); } public void testAncestry() { - RollbackRuleAttribute rr = new RollbackRuleAttribute("java.lang.Exception"); - // Exception -> Runtime -> NestedRuntime -> MailException -> MailSendException - assertTrue(rr.getDepth(new MailSendException("")) == 4); + RollbackRuleAttribute rr = new RollbackRuleAttribute(java.lang.Exception.class.getName()); + // Exception -> Runtime -> NestedRuntime -> MyRuntimeException + assertThat(rr.getDepth(new MyRuntimeException("")), equalTo(3)); } public void testAlwaysTrueForThrowable() { - RollbackRuleAttribute rr = new RollbackRuleAttribute("java.lang.Throwable"); - assertTrue(rr.getDepth(new MailSendException("")) > 0); - assertTrue(rr.getDepth(new ServletException()) > 0); + RollbackRuleAttribute rr = new RollbackRuleAttribute(java.lang.Throwable.class.getName()); + assertTrue(rr.getDepth(new MyRuntimeException("")) > 0); + assertTrue(rr.getDepth(new IOException()) > 0); assertTrue(rr.getDepth(new FatalBeanException(null,null)) > 0); assertTrue(rr.getDepth(new RuntimeException()) > 0); } diff --git a/org.springframework.testsuite/src/test/java/org/springframework/transaction/interceptor/RuleBasedTransactionAttributeTests.java b/org.springframework.transaction/src/test/java/org/springframework/transaction/interceptor/RuleBasedTransactionAttributeTests.java similarity index 69% rename from org.springframework.testsuite/src/test/java/org/springframework/transaction/interceptor/RuleBasedTransactionAttributeTests.java rename to org.springframework.transaction/src/test/java/org/springframework/transaction/interceptor/RuleBasedTransactionAttributeTests.java index b147c23a912..5ba1746d25b 100644 --- a/org.springframework.testsuite/src/test/java/org/springframework/transaction/interceptor/RuleBasedTransactionAttributeTests.java +++ b/org.springframework.transaction/src/test/java/org/springframework/transaction/interceptor/RuleBasedTransactionAttributeTests.java @@ -16,72 +16,77 @@ package org.springframework.transaction.interceptor; +import static org.junit.Assert.*; + +import java.io.IOException; import java.rmi.RemoteException; import java.util.Collections; import java.util.LinkedList; import java.util.List; -import javax.servlet.ServletException; - -import junit.framework.TestCase; - -import org.springframework.mail.MailSendException; +import org.junit.Test; import org.springframework.transaction.TransactionDefinition; /** * @author Rod Johnson * @author Juergen Hoeller * @author Rick Evans + * @author Chris Beams * @since 09.04.2003 */ -public class RuleBasedTransactionAttributeTests extends TestCase { +public class RuleBasedTransactionAttributeTests { + @Test public void testDefaultRule() { RuleBasedTransactionAttribute rta = new RuleBasedTransactionAttribute(); assertTrue(rta.rollbackOn(new RuntimeException())); - assertTrue(rta.rollbackOn(new MailSendException(""))); + assertTrue(rta.rollbackOn(new MyRuntimeException(""))); assertFalse(rta.rollbackOn(new Exception())); - assertFalse(rta.rollbackOn(new ServletException())); + assertFalse(rta.rollbackOn(new IOException())); } /** * Test one checked exception that should roll back. */ + @Test public void testRuleForRollbackOnChecked() { - List list = new LinkedList(); - list.add(new RollbackRuleAttribute("javax.servlet.ServletException")); + List list = new LinkedList(); + list.add(new RollbackRuleAttribute(IOException.class.getName())); RuleBasedTransactionAttribute rta = new RuleBasedTransactionAttribute(TransactionDefinition.PROPAGATION_REQUIRED, list); assertTrue(rta.rollbackOn(new RuntimeException())); - assertTrue(rta.rollbackOn(new MailSendException(""))); + assertTrue(rta.rollbackOn(new MyRuntimeException(""))); assertFalse(rta.rollbackOn(new Exception())); // Check that default behaviour is overridden - assertTrue(rta.rollbackOn(new ServletException())); + assertTrue(rta.rollbackOn(new IOException())); } + @Test public void testRuleForCommitOnUnchecked() { - List list = new LinkedList(); - list.add(new NoRollbackRuleAttribute("org.springframework.mail.MailSendException")); - list.add(new RollbackRuleAttribute("javax.servlet.ServletException")); + List list = new LinkedList(); + list.add(new NoRollbackRuleAttribute(MyRuntimeException.class.getName())); + list.add(new RollbackRuleAttribute(IOException.class.getName())); RuleBasedTransactionAttribute rta = new RuleBasedTransactionAttribute(TransactionDefinition.PROPAGATION_REQUIRED, list); assertTrue(rta.rollbackOn(new RuntimeException())); // Check default behaviour is overridden - assertFalse(rta.rollbackOn(new MailSendException(""))); + assertFalse(rta.rollbackOn(new MyRuntimeException(""))); assertFalse(rta.rollbackOn(new Exception())); // Check that default behaviour is overridden - assertTrue(rta.rollbackOn(new ServletException())); + assertTrue(rta.rollbackOn(new IOException())); } + @Test public void testRuleForSelectiveRollbackOnCheckedWithString() { - List l = new LinkedList(); - l.add(new RollbackRuleAttribute("java.rmi.RemoteException")); + List l = new LinkedList(); + l.add(new RollbackRuleAttribute(java.rmi.RemoteException.class.getName())); RuleBasedTransactionAttribute rta = new RuleBasedTransactionAttribute(TransactionDefinition.PROPAGATION_REQUIRED, l); doTestRuleForSelectiveRollbackOnChecked(rta); } + @Test public void testRuleForSelectiveRollbackOnCheckedWithClass() { - List l = Collections.singletonList(new RollbackRuleAttribute(RemoteException.class)); + List l = Collections.singletonList(new RollbackRuleAttribute(RemoteException.class)); RuleBasedTransactionAttribute rta = new RuleBasedTransactionAttribute(TransactionDefinition.PROPAGATION_REQUIRED, l); doTestRuleForSelectiveRollbackOnChecked(rta); } @@ -95,37 +100,40 @@ public class RuleBasedTransactionAttributeTests extends TestCase { } /** - * Check that a rule can cause commit on a ServletException + * Check that a rule can cause commit on a IOException * when Exception prompts a rollback. */ + @Test public void testRuleForCommitOnSubclassOfChecked() { - List list = new LinkedList(); + List list = new LinkedList(); // Note that it's important to ensure that we have this as // a FQN: otherwise it will match everything! list.add(new RollbackRuleAttribute("java.lang.Exception")); - list.add(new NoRollbackRuleAttribute("ServletException")); + list.add(new NoRollbackRuleAttribute("IOException")); RuleBasedTransactionAttribute rta = new RuleBasedTransactionAttribute(TransactionDefinition.PROPAGATION_REQUIRED, list); assertTrue(rta.rollbackOn(new RuntimeException())); assertTrue(rta.rollbackOn(new Exception())); // Check that default behaviour is overridden - assertFalse(rta.rollbackOn(new ServletException())); + assertFalse(rta.rollbackOn(new IOException())); } + @Test public void testRollbackNever() { - List list = new LinkedList(); + List list = new LinkedList(); list.add(new NoRollbackRuleAttribute("Throwable")); RuleBasedTransactionAttribute rta = new RuleBasedTransactionAttribute(TransactionDefinition.PROPAGATION_REQUIRED, list); assertFalse(rta.rollbackOn(new Throwable())); assertFalse(rta.rollbackOn(new RuntimeException())); - assertFalse(rta.rollbackOn(new MailSendException(""))); + assertFalse(rta.rollbackOn(new MyRuntimeException(""))); assertFalse(rta.rollbackOn(new Exception())); - assertFalse(rta.rollbackOn(new ServletException())); + assertFalse(rta.rollbackOn(new IOException())); } + @Test public void testToStringMatchesEditor() { - List list = new LinkedList(); + List list = new LinkedList(); list.add(new NoRollbackRuleAttribute("Throwable")); RuleBasedTransactionAttribute rta = new RuleBasedTransactionAttribute(TransactionDefinition.PROPAGATION_REQUIRED, list); @@ -135,16 +143,17 @@ public class RuleBasedTransactionAttributeTests extends TestCase { assertFalse(rta.rollbackOn(new Throwable())); assertFalse(rta.rollbackOn(new RuntimeException())); - assertFalse(rta.rollbackOn(new MailSendException(""))); + assertFalse(rta.rollbackOn(new MyRuntimeException(""))); assertFalse(rta.rollbackOn(new Exception())); - assertFalse(rta.rollbackOn(new ServletException())); + assertFalse(rta.rollbackOn(new IOException())); } /** * See this forum post. */ + @Test public void testConflictingRulesToDetermineExactContract() { - List list = new LinkedList(); + List list = new LinkedList(); list.add(new NoRollbackRuleAttribute(MyBusinessWarningException.class)); list.add(new RollbackRuleAttribute(MyBusinessException.class)); RuleBasedTransactionAttribute rta = new RuleBasedTransactionAttribute(TransactionDefinition.PROPAGATION_REQUIRED, list); @@ -154,9 +163,11 @@ public class RuleBasedTransactionAttributeTests extends TestCase { } - public static class MyBusinessException extends Exception {} + @SuppressWarnings("serial") + private static class MyBusinessException extends Exception {} - public static final class MyBusinessWarningException extends MyBusinessException {} + @SuppressWarnings("serial") + private static final class MyBusinessWarningException extends MyBusinessException {} } diff --git a/org.springframework.testsuite/src/test/java/org/springframework/transaction/interceptor/TransactionAttributeEditorTests.java b/org.springframework.transaction/src/test/java/org/springframework/transaction/interceptor/TransactionAttributeEditorTests.java similarity index 86% rename from org.springframework.testsuite/src/test/java/org/springframework/transaction/interceptor/TransactionAttributeEditorTests.java rename to org.springframework.transaction/src/test/java/org/springframework/transaction/interceptor/TransactionAttributeEditorTests.java index 993bcf80fab..a0eef8be2ce 100644 --- a/org.springframework.testsuite/src/test/java/org/springframework/transaction/interceptor/TransactionAttributeEditorTests.java +++ b/org.springframework.transaction/src/test/java/org/springframework/transaction/interceptor/TransactionAttributeEditorTests.java @@ -16,11 +16,12 @@ package org.springframework.transaction.interceptor; -import javax.servlet.ServletException; -import junit.framework.TestCase; +import static org.junit.Assert.*; -import org.springframework.mail.MailSendException; +import java.io.IOException; + +import org.junit.Test; import org.springframework.transaction.TransactionDefinition; /** @@ -28,10 +29,12 @@ import org.springframework.transaction.TransactionDefinition; * * @author Rod Johnson * @author Juergen Hoeller + * @author Chris Beams * @since 26.04.2003 */ -public class TransactionAttributeEditorTests extends TestCase { +public class TransactionAttributeEditorTests { + @Test public void testNull() { TransactionAttributeEditor pe = new TransactionAttributeEditor(); pe.setAsText(null); @@ -39,6 +42,7 @@ public class TransactionAttributeEditorTests extends TestCase { assertTrue(ta == null); } + @Test public void testEmptyString() { TransactionAttributeEditor pe = new TransactionAttributeEditor(); pe.setAsText(""); @@ -46,6 +50,7 @@ public class TransactionAttributeEditorTests extends TestCase { assertTrue(ta == null); } + @Test public void testValidPropagationCodeOnly() { TransactionAttributeEditor pe = new TransactionAttributeEditor(); pe.setAsText("PROPAGATION_REQUIRED"); @@ -56,17 +61,14 @@ public class TransactionAttributeEditorTests extends TestCase { assertTrue(!ta.isReadOnly()); } + @Test(expected=IllegalArgumentException.class) public void testInvalidPropagationCodeOnly() { TransactionAttributeEditor pe = new TransactionAttributeEditor(); - try { - pe.setAsText("XXPROPAGATION_REQUIRED"); - fail("Should have failed with bogus propagation code"); - } - catch (IllegalArgumentException ex) { - // Ok - } + // should have failed with bogus propagation code + pe.setAsText("XXPROPAGATION_REQUIRED"); } + @Test public void testValidPropagationCodeAndIsolationCode() { TransactionAttributeEditor pe = new TransactionAttributeEditor(); pe.setAsText("PROPAGATION_REQUIRED, ISOLATION_READ_UNCOMMITTED"); @@ -76,20 +78,17 @@ public class TransactionAttributeEditorTests extends TestCase { assertTrue(ta.getIsolationLevel() == TransactionDefinition.ISOLATION_READ_UNCOMMITTED); } + @Test(expected=IllegalArgumentException.class) public void testValidPropagationAndIsolationCodesAndInvalidRollbackRule() { TransactionAttributeEditor pe = new TransactionAttributeEditor(); - try { - pe.setAsText("PROPAGATION_REQUIRED,ISOLATION_READ_UNCOMMITTED,XXX"); - fail("Should have failed with bogus rollback rule"); - } - catch (IllegalArgumentException ex) { - // Ok - } - } + // should fail with bogus rollback rule + pe.setAsText("PROPAGATION_REQUIRED,ISOLATION_READ_UNCOMMITTED,XXX"); + } + @Test public void testValidPropagationCodeAndIsolationCodeAndRollbackRules1() { TransactionAttributeEditor pe = new TransactionAttributeEditor(); - pe.setAsText("PROPAGATION_MANDATORY,ISOLATION_REPEATABLE_READ,timeout_10,-ServletException,+MailSendException"); + pe.setAsText("PROPAGATION_MANDATORY,ISOLATION_REPEATABLE_READ,timeout_10,-IOException,+MyRuntimeException"); TransactionAttribute ta = (TransactionAttribute) pe.getValue(); assertNotNull(ta); assertEquals(ta.getPropagationBehavior(), TransactionDefinition.PROPAGATION_MANDATORY); @@ -99,13 +98,14 @@ public class TransactionAttributeEditorTests extends TestCase { assertTrue(ta.rollbackOn(new RuntimeException())); assertFalse(ta.rollbackOn(new Exception())); // Check for our bizarre customized rollback rules - assertTrue(ta.rollbackOn(new ServletException())); - assertTrue(!ta.rollbackOn(new MailSendException(""))); + assertTrue(ta.rollbackOn(new IOException())); + assertTrue(!ta.rollbackOn(new MyRuntimeException(""))); } + @Test public void testValidPropagationCodeAndIsolationCodeAndRollbackRules2() { TransactionAttributeEditor pe = new TransactionAttributeEditor(); - pe.setAsText("+ServletException,readOnly,ISOLATION_READ_COMMITTED,-MailSendException,PROPAGATION_SUPPORTS"); + pe.setAsText("+IOException,readOnly,ISOLATION_READ_COMMITTED,-MyRuntimeException,PROPAGATION_SUPPORTS"); TransactionAttribute ta = (TransactionAttribute) pe.getValue(); assertNotNull(ta); assertEquals(ta.getPropagationBehavior(), TransactionDefinition.PROPAGATION_SUPPORTS); @@ -115,10 +115,11 @@ public class TransactionAttributeEditorTests extends TestCase { assertTrue(ta.rollbackOn(new RuntimeException())); assertFalse(ta.rollbackOn(new Exception())); // Check for our bizarre customized rollback rules - assertFalse(ta.rollbackOn(new ServletException())); - assertTrue(ta.rollbackOn(new MailSendException(""))); + assertFalse(ta.rollbackOn(new IOException())); + assertTrue(ta.rollbackOn(new MyRuntimeException(""))); } + @Test public void testDefaultTransactionAttributeToString() { DefaultTransactionAttribute source = new DefaultTransactionAttribute(); source.setPropagationBehavior(TransactionDefinition.PROPAGATION_SUPPORTS); @@ -143,6 +144,7 @@ public class TransactionAttributeEditorTests extends TestCase { assertEquals(ta, source); } + @Test public void testRuleBasedTransactionAttributeToString() { RuleBasedTransactionAttribute source = new RuleBasedTransactionAttribute(); source.setPropagationBehavior(TransactionDefinition.PROPAGATION_SUPPORTS); @@ -169,5 +171,5 @@ public class TransactionAttributeEditorTests extends TestCase { source.getRollbackRules().add(new NoRollbackRuleAttribute("IllegalStateException")); assertEquals(ta, source); } - + } diff --git a/org.springframework.testsuite/src/test/java/org/springframework/transaction/interceptor/TransactionAttributeSourceAdvisorTests.java b/org.springframework.transaction/src/test/java/org/springframework/transaction/interceptor/TransactionAttributeSourceAdvisorTests.java similarity index 100% rename from org.springframework.testsuite/src/test/java/org/springframework/transaction/interceptor/TransactionAttributeSourceAdvisorTests.java rename to org.springframework.transaction/src/test/java/org/springframework/transaction/interceptor/TransactionAttributeSourceAdvisorTests.java diff --git a/org.springframework.testsuite/src/test/java/org/springframework/transaction/interceptor/TransactionAttributeSourceEditorTests.java b/org.springframework.transaction/src/test/java/org/springframework/transaction/interceptor/TransactionAttributeSourceEditorTests.java similarity index 100% rename from org.springframework.testsuite/src/test/java/org/springframework/transaction/interceptor/TransactionAttributeSourceEditorTests.java rename to org.springframework.transaction/src/test/java/org/springframework/transaction/interceptor/TransactionAttributeSourceEditorTests.java diff --git a/org.springframework.testsuite/src/test/java/org/springframework/transaction/interceptor/TransactionAttributeSourceTests.java b/org.springframework.transaction/src/test/java/org/springframework/transaction/interceptor/TransactionAttributeSourceTests.java similarity index 91% rename from org.springframework.testsuite/src/test/java/org/springframework/transaction/interceptor/TransactionAttributeSourceTests.java rename to org.springframework.transaction/src/test/java/org/springframework/transaction/interceptor/TransactionAttributeSourceTests.java index b7977e07cc6..b5a7b2c741c 100644 --- a/org.springframework.testsuite/src/test/java/org/springframework/transaction/interceptor/TransactionAttributeSourceTests.java +++ b/org.springframework.transaction/src/test/java/org/springframework/transaction/interceptor/TransactionAttributeSourceTests.java @@ -16,17 +16,13 @@ package org.springframework.transaction.interceptor; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.*; +import java.io.IOException; import java.util.HashMap; import java.util.Map; import java.util.Properties; -import javax.servlet.ServletException; - import org.junit.Ignore; import org.junit.Test; import org.springframework.transaction.TransactionDefinition; @@ -37,6 +33,7 @@ import org.springframework.transaction.TransactionDefinition; * @author Colin Sampaleanu * @author Juergen Hoeller * @author Rick Evans + * @author Chris Beams * @since 15.10.2003 * @see org.springframework.transaction.interceptor.TransactionProxyFactoryBean */ @@ -52,17 +49,18 @@ public final class TransactionAttributeSourceTests { tas.setTransactionAttribute(new DefaultTransactionAttribute(TransactionDefinition.PROPAGATION_SUPPORTS)); ta = tas.getTransactionAttribute( - ServletException.class.getMethod("getMessage", (Class[]) null), ServletException.class); + IOException.class.getMethod("getMessage", (Class[]) null), IOException.class); assertNotNull(ta); assertTrue(TransactionDefinition.PROPAGATION_SUPPORTS == ta.getPropagationBehavior()); } - @Ignore + @SuppressWarnings("unchecked") + @Ignore // no longer works now that setMethodMap has been parameterized @Test public void testMethodMapTransactionAttributeSource() throws NoSuchMethodException { MethodMapTransactionAttributeSource tas = new MethodMapTransactionAttributeSource(); Map methodMap = new HashMap(); - methodMap.put(Object.class.getName() + ".hashCode", "PROPAGATION_REQUIRED"); + methodMap.put(Object.class.getName() + ".hashCode", TransactionDefinition.PROPAGATION_REQUIRED); methodMap.put(Object.class.getName() + ".toString", new DefaultTransactionAttribute(TransactionDefinition.PROPAGATION_SUPPORTS)); tas.setMethodMap(methodMap); @@ -76,7 +74,8 @@ public final class TransactionAttributeSourceTests { assertEquals(TransactionDefinition.PROPAGATION_SUPPORTS, ta.getPropagationBehavior()); } - @Ignore + @SuppressWarnings("unchecked") + @Ignore // no longer works now that setMethodMap has been parameterized @Test public void testMethodMapTransactionAttributeSourceWithLazyInit() throws NoSuchMethodException { MethodMapTransactionAttributeSource tas = new MethodMapTransactionAttributeSource(); @@ -94,7 +93,8 @@ public final class TransactionAttributeSourceTests { assertEquals(TransactionDefinition.PROPAGATION_SUPPORTS, ta.getPropagationBehavior()); } - @Ignore + @SuppressWarnings("unchecked") + @Ignore // no longer works now that setMethodMap has been parameterized @Test public void testNameMatchTransactionAttributeSource() throws NoSuchMethodException { NameMatchTransactionAttributeSource tas = new NameMatchTransactionAttributeSource(); diff --git a/org.springframework.testsuite/src/test/java/org/springframework/transaction/interceptor/TransactionInterceptorTests.java b/org.springframework.transaction/src/test/java/org/springframework/transaction/interceptor/TransactionInterceptorTests.java similarity index 100% rename from org.springframework.testsuite/src/test/java/org/springframework/transaction/interceptor/TransactionInterceptorTests.java rename to org.springframework.transaction/src/test/java/org/springframework/transaction/interceptor/TransactionInterceptorTests.java diff --git a/org.springframework.testsuite/src/test/java/org/springframework/transaction/interceptor/noTransactionAttributeSource.xml b/org.springframework.transaction/src/test/java/org/springframework/transaction/interceptor/noTransactionAttributeSource.xml similarity index 100% rename from org.springframework.testsuite/src/test/java/org/springframework/transaction/interceptor/noTransactionAttributeSource.xml rename to org.springframework.transaction/src/test/java/org/springframework/transaction/interceptor/noTransactionAttributeSource.xml diff --git a/org.springframework.testsuite/src/test/java/org/springframework/transaction/interceptor/transactionalBeanFactory.xml b/org.springframework.transaction/src/test/java/org/springframework/transaction/interceptor/transactionalBeanFactory.xml similarity index 100% rename from org.springframework.testsuite/src/test/java/org/springframework/transaction/interceptor/transactionalBeanFactory.xml rename to org.springframework.transaction/src/test/java/org/springframework/transaction/interceptor/transactionalBeanFactory.xml diff --git a/org.springframework.testsuite/src/test/java/org/springframework/transaction/jta/MockUOWManager.java b/org.springframework.transaction/src/test/java/org/springframework/transaction/jta/MockUOWManager.java similarity index 100% rename from org.springframework.testsuite/src/test/java/org/springframework/transaction/jta/MockUOWManager.java rename to org.springframework.transaction/src/test/java/org/springframework/transaction/jta/MockUOWManager.java diff --git a/org.springframework.testsuite/src/test/java/org/springframework/transaction/jta/WebSphereUowTransactionManagerTests.java b/org.springframework.transaction/src/test/java/org/springframework/transaction/jta/WebSphereUowTransactionManagerTests.java similarity index 100% rename from org.springframework.testsuite/src/test/java/org/springframework/transaction/jta/WebSphereUowTransactionManagerTests.java rename to org.springframework.transaction/src/test/java/org/springframework/transaction/jta/WebSphereUowTransactionManagerTests.java diff --git a/org.springframework.testsuite/src/test/java/org/springframework/transaction/support/JtaTransactionManagerSerializationTests.java b/org.springframework.transaction/src/test/java/org/springframework/transaction/support/JtaTransactionManagerSerializationTests.java similarity index 100% rename from org.springframework.testsuite/src/test/java/org/springframework/transaction/support/JtaTransactionManagerSerializationTests.java rename to org.springframework.transaction/src/test/java/org/springframework/transaction/support/JtaTransactionManagerSerializationTests.java diff --git a/org.springframework.testsuite/src/test/java/org/springframework/transaction/txNamespaceHandlerTests.xml b/org.springframework.transaction/src/test/java/org/springframework/transaction/txNamespaceHandlerTests.xml similarity index 100% rename from org.springframework.testsuite/src/test/java/org/springframework/transaction/txNamespaceHandlerTests.xml rename to org.springframework.transaction/src/test/java/org/springframework/transaction/txNamespaceHandlerTests.xml diff --git a/org.springframework.web.portlet/.classpath b/org.springframework.web.portlet/.classpath index a0ee00d8f01..6ad70b93a7c 100644 --- a/org.springframework.web.portlet/.classpath +++ b/org.springframework.web.portlet/.classpath @@ -10,7 +10,6 @@ - @@ -18,5 +17,10 @@ + + + + + diff --git a/org.springframework.web.portlet/ivy.xml b/org.springframework.web.portlet/ivy.xml index 2ab8cda7a90..08cc3ab4186 100644 --- a/org.springframework.web.portlet/ivy.xml +++ b/org.springframework.web.portlet/ivy.xml @@ -20,8 +20,11 @@ + - + + + diff --git a/org.springframework.web.portlet/src/main/java/org/springframework/mock/web/DelegatingServletInputStream.java b/org.springframework.web.portlet/src/main/java/org/springframework/mock/web/DelegatingServletInputStream.java deleted file mode 100644 index 6b9ec44af2e..00000000000 --- a/org.springframework.web.portlet/src/main/java/org/springframework/mock/web/DelegatingServletInputStream.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright 2002-2007 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.mock.web; - -import java.io.IOException; -import java.io.InputStream; - -import javax.servlet.ServletInputStream; - -import org.springframework.util.Assert; - -/** - * Delegating implementation of {@link javax.servlet.ServletInputStream}. - * - *

Used by {@link org.springframework.mock.web.MockHttpServletRequest}; typically not directly - * used for testing application controllers. - * - * @author Juergen Hoeller - * @since 1.0.2 - * @see org.springframework.mock.web.MockHttpServletRequest - */ -public class DelegatingServletInputStream extends ServletInputStream { - - private final InputStream sourceStream; - - - /** - * Create a DelegatingServletInputStream for the given source stream. - * @param sourceStream the source stream (never null) - */ - public DelegatingServletInputStream(InputStream sourceStream) { - Assert.notNull(sourceStream, "Source InputStream must not be null"); - this.sourceStream = sourceStream; - } - - /** - * Return the underlying source stream (never null). - */ - public final InputStream getSourceStream() { - return this.sourceStream; - } - - - public int read() throws IOException { - return this.sourceStream.read(); - } - - public void close() throws IOException { - super.close(); - this.sourceStream.close(); - } - -} \ No newline at end of file