diff --git a/org.springframework.aop/src/main/java/org/springframework/aop/ClassFilter.java b/org.springframework.aop/src/main/java/org/springframework/aop/ClassFilter.java index bc3051fce4c..9cb86c02c0b 100644 --- a/org.springframework.aop/src/main/java/org/springframework/aop/ClassFilter.java +++ b/org.springframework.aop/src/main/java/org/springframework/aop/ClassFilter.java @@ -34,7 +34,7 @@ public interface ClassFilter { * @param clazz the candidate target class * @return whether the advice should apply to the given target class */ - boolean matches(Class clazz); + boolean matches(Class clazz); /** diff --git a/org.springframework.testsuite/src/test/java/org/springframework/aop/scope/DefaultScopedObjectTests.java b/org.springframework.aop/src/test/java/org/springframework/aop/scope/DefaultScopedObjectTests.java similarity index 66% rename from org.springframework.testsuite/src/test/java/org/springframework/aop/scope/DefaultScopedObjectTests.java rename to org.springframework.aop/src/test/java/org/springframework/aop/scope/DefaultScopedObjectTests.java index c05fa15dc97..c33782401ec 100644 --- a/org.springframework.testsuite/src/test/java/org/springframework/aop/scope/DefaultScopedObjectTests.java +++ b/org.springframework.aop/src/test/java/org/springframework/aop/scope/DefaultScopedObjectTests.java @@ -16,54 +16,49 @@ package org.springframework.aop.scope; -import junit.framework.TestCase; -import org.easymock.MockControl; +import static org.easymock.EasyMock.*; + +import org.junit.Test; import org.springframework.beans.factory.config.ConfigurableBeanFactory; -import org.springframework.test.AssertThrows; /** * Unit tests for the {@link DefaultScopedObject} class. * * @author Rick Evans */ -public final class DefaultScopedObjectTests extends TestCase { +public final class DefaultScopedObjectTests { private static final String GOOD_BEAN_NAME = "foo"; + @Test(expected=IllegalArgumentException.class) public void testCtorWithNullBeanFactory() throws Exception { - new AssertThrows(IllegalArgumentException.class) { - public void test() throws Exception { - new DefaultScopedObject(null, GOOD_BEAN_NAME); - } - }.runTest(); + new DefaultScopedObject(null, GOOD_BEAN_NAME); } + @Test(expected=IllegalArgumentException.class) public void testCtorWithNullTargetBeanName() throws Exception { testBadTargetBeanName(null); } + @Test(expected=IllegalArgumentException.class) public void testCtorWithEmptyTargetBeanName() throws Exception { testBadTargetBeanName(""); } + @Test(expected=IllegalArgumentException.class) public void testCtorWithJustWhitespacedTargetBeanName() throws Exception { testBadTargetBeanName(" "); } private static void testBadTargetBeanName(final String badTargetBeanName) { - MockControl mock = MockControl.createControl(ConfigurableBeanFactory.class); - final ConfigurableBeanFactory factory = (ConfigurableBeanFactory) mock.getMock(); - mock.replay(); + ConfigurableBeanFactory factory = createMock(ConfigurableBeanFactory.class); + replay(factory); - new AssertThrows(IllegalArgumentException.class) { - public void test() throws Exception { - new DefaultScopedObject(factory, badTargetBeanName); - } - }.runTest(); + new DefaultScopedObject(factory, badTargetBeanName); - mock.verify(); + verify(factory); } } diff --git a/org.springframework.testsuite/src/test/java/org/springframework/aop/scope/ScopedProxyAutowireTests.java b/org.springframework.aop/src/test/java/org/springframework/aop/scope/ScopedProxyAutowireTests.java similarity index 90% rename from org.springframework.testsuite/src/test/java/org/springframework/aop/scope/ScopedProxyAutowireTests.java rename to org.springframework.aop/src/test/java/org/springframework/aop/scope/ScopedProxyAutowireTests.java index 925ddcc3f7a..ab32bec7fa4 100644 --- a/org.springframework.testsuite/src/test/java/org/springframework/aop/scope/ScopedProxyAutowireTests.java +++ b/org.springframework.aop/src/test/java/org/springframework/aop/scope/ScopedProxyAutowireTests.java @@ -16,16 +16,19 @@ package org.springframework.aop.scope; -import junit.framework.TestCase; +import static org.junit.Assert.assertSame; +import org.junit.Test; import org.springframework.beans.factory.xml.XmlBeanFactory; import org.springframework.core.io.ClassPathResource; /** * @author Mark Fisher + * @author Chris Beams */ -public class ScopedProxyAutowireTests extends TestCase { +public class ScopedProxyAutowireTests { + @Test public void testScopedProxyInheritsAutowireCandidateFalse() { XmlBeanFactory bf = new XmlBeanFactory(new ClassPathResource("scopedAutowireFalse.xml", getClass())); TestBean autowired = (TestBean) bf.getBean("autowired"); @@ -33,6 +36,7 @@ public class ScopedProxyAutowireTests extends TestCase { assertSame(unscoped, autowired.getChild()); } + @Test public void testScopedProxyReplacesAutowireCandidateTrue() { XmlBeanFactory bf = new XmlBeanFactory(new ClassPathResource("scopedAutowireTrue.xml", getClass())); TestBean autowired = (TestBean) bf.getBean("autowired"); @@ -41,7 +45,7 @@ public class ScopedProxyAutowireTests extends TestCase { } - public static class TestBean { + static class TestBean { private TestBean child; diff --git a/org.springframework.testsuite/src/test/java/org/springframework/aop/scope/scopedAutowireFalse.xml b/org.springframework.aop/src/test/java/org/springframework/aop/scope/scopedAutowireFalse.xml similarity index 100% rename from org.springframework.testsuite/src/test/java/org/springframework/aop/scope/scopedAutowireFalse.xml rename to org.springframework.aop/src/test/java/org/springframework/aop/scope/scopedAutowireFalse.xml diff --git a/org.springframework.testsuite/src/test/java/org/springframework/aop/scope/scopedAutowireTrue.xml b/org.springframework.aop/src/test/java/org/springframework/aop/scope/scopedAutowireTrue.xml similarity index 100% rename from org.springframework.testsuite/src/test/java/org/springframework/aop/scope/scopedAutowireTrue.xml rename to org.springframework.aop/src/test/java/org/springframework/aop/scope/scopedAutowireTrue.xml diff --git a/org.springframework.testsuite/src/test/java/org/springframework/aop/support/AbstractRegexpMethodPointcutTests.java b/org.springframework.aop/src/test/java/org/springframework/aop/support/AbstractRegexpMethodPointcutTests.java similarity index 91% rename from org.springframework.testsuite/src/test/java/org/springframework/aop/support/AbstractRegexpMethodPointcutTests.java rename to org.springframework.aop/src/test/java/org/springframework/aop/support/AbstractRegexpMethodPointcutTests.java index 75d4af6d2e4..0dc9bbfda80 100644 --- a/org.springframework.testsuite/src/test/java/org/springframework/aop/support/AbstractRegexpMethodPointcutTests.java +++ b/org.springframework.aop/src/test/java/org/springframework/aop/support/AbstractRegexpMethodPointcutTests.java @@ -16,31 +16,37 @@ package org.springframework.aop.support; -import javax.servlet.ServletException; +import static org.junit.Assert.*; -import junit.framework.TestCase; +import java.io.IOException; +import org.junit.Before; +import org.junit.Test; import org.springframework.beans.TestBean; import org.springframework.util.SerializationTestUtils; /** * @author Rod Johnson * @author Dmitriy Kopylenko + * @author Chris Beams */ -public abstract class AbstractRegexpMethodPointcutTests extends TestCase { +public abstract class AbstractRegexpMethodPointcutTests { private AbstractRegexpMethodPointcut rpc; - protected void setUp() { + @Before + public void setUp() { rpc = getRegexpMethodPointcut(); } protected abstract AbstractRegexpMethodPointcut getRegexpMethodPointcut(); + @Test public void testNoPatternSupplied() throws Exception { noPatternSuppliedTests(rpc); } + @Test public void testSerializationWithNoPatternSupplied() throws Exception { rpc = (AbstractRegexpMethodPointcut) SerializationTestUtils.serializeAndDeserialize(rpc); noPatternSuppliedTests(rpc); @@ -52,6 +58,7 @@ public abstract class AbstractRegexpMethodPointcutTests extends TestCase { assertEquals(0, rpc.getPatterns().length); } + @Test public void testExactMatch() throws Exception { rpc.setPattern("java.lang.Object.hashCode"); exactMatchTests(rpc); @@ -66,36 +73,41 @@ public abstract class AbstractRegexpMethodPointcutTests extends TestCase { assertFalse(rpc.matches(Object.class.getMethod("wait", (Class[]) null), Object.class)); } + @Test public void testSpecificMatch() throws Exception { rpc.setPattern("java.lang.String.hashCode"); assertTrue(rpc.matches(Object.class.getMethod("hashCode", (Class[]) null), String.class)); assertFalse(rpc.matches(Object.class.getMethod("hashCode", (Class[]) null), Object.class)); } + @Test public void testWildcard() throws Exception { rpc.setPattern(".*Object.hashCode"); assertTrue(rpc.matches(Object.class.getMethod("hashCode", (Class[]) null), Object.class)); assertFalse(rpc.matches(Object.class.getMethod("wait", (Class[]) null), Object.class)); } + @Test public void testWildcardForOneClass() throws Exception { rpc.setPattern("java.lang.Object.*"); assertTrue(rpc.matches(Object.class.getMethod("hashCode", (Class[]) null), String.class)); assertTrue(rpc.matches(Object.class.getMethod("wait", (Class[]) null), String.class)); } + @Test public void testMatchesObjectClass() throws Exception { rpc.setPattern("java.lang.Object.*"); - assertTrue(rpc.matches(Exception.class.getMethod("hashCode", (Class[]) null), ServletException.class)); + assertTrue(rpc.matches(Exception.class.getMethod("hashCode", (Class[]) null), IOException.class)); // Doesn't match a method from Throwable assertFalse(rpc.matches(Exception.class.getMethod("getMessage", (Class[]) null), Exception.class)); } + @Test public void testWithExclusion() throws Exception { this.rpc.setPattern(".*get.*"); this.rpc.setExcludedPattern(".*Age.*"); - assertTrue(this.rpc.matches(TestBean.class.getMethod("getName", null), TestBean.class)); - assertFalse(this.rpc.matches(TestBean.class.getMethod("getAge", null), TestBean.class)); + assertTrue(this.rpc.matches(TestBean.class.getMethod("getName"), TestBean.class)); + assertFalse(this.rpc.matches(TestBean.class.getMethod("getAge"), TestBean.class)); } } diff --git a/org.springframework.testsuite/src/test/java/org/springframework/aop/support/AopUtilsTests.java b/org.springframework.aop/src/test/java/org/springframework/aop/support/AopUtilsTests.java similarity index 92% rename from org.springframework.testsuite/src/test/java/org/springframework/aop/support/AopUtilsTests.java rename to org.springframework.aop/src/test/java/org/springframework/aop/support/AopUtilsTests.java index f8130f465d1..6456d925c77 100644 --- a/org.springframework.testsuite/src/test/java/org/springframework/aop/support/AopUtilsTests.java +++ b/org.springframework.aop/src/test/java/org/springframework/aop/support/AopUtilsTests.java @@ -16,10 +16,11 @@ package org.springframework.aop.support; +import static org.junit.Assert.*; + import java.lang.reflect.Method; -import junit.framework.TestCase; - +import org.junit.Test; import org.springframework.aop.ClassFilter; import org.springframework.aop.MethodMatcher; import org.springframework.aop.Pointcut; @@ -31,12 +32,14 @@ import org.springframework.util.SerializationTestUtils; /** * @author Rod Johnson + * @author Chris Beams */ -public class AopUtilsTests extends TestCase { +public class AopUtilsTests { + @Test public void testPointcutCanNeverApply() { class TestPointcut extends StaticMethodMatcherPointcut { - public boolean matches(Method method, Class clazzy) { + public boolean matches(Method method, Class clazzy) { return false; } } @@ -45,14 +48,16 @@ public class AopUtilsTests extends TestCase { assertFalse(AopUtils.canApply(no, Object.class)); } + @Test public void testPointcutAlwaysApplies() { assertTrue(AopUtils.canApply(new DefaultPointcutAdvisor(new NopInterceptor()), Object.class)); assertTrue(AopUtils.canApply(new DefaultPointcutAdvisor(new NopInterceptor()), TestBean.class)); } + @Test public void testPointcutAppliesToOneMethodOnObject() { class TestPointcut extends StaticMethodMatcherPointcut { - public boolean matches(Method method, Class clazz) { + public boolean matches(Method method, Class clazz) { return method.getName().equals("hashCode"); } } @@ -68,6 +73,7 @@ public class AopUtilsTests extends TestCase { * of AOP classes, they return the same instance, not a new instance * that's subverted the singleton construction limitation. */ + @Test public void testCanonicalFrameworkClassesStillCanonicalOnDeserialization() throws Exception { assertSame(MethodMatcher.TRUE, SerializationTestUtils.serializeAndDeserialize(MethodMatcher.TRUE)); assertSame(ClassFilter.TRUE, SerializationTestUtils.serializeAndDeserialize(ClassFilter.TRUE)); diff --git a/org.springframework.testsuite/src/test/java/org/springframework/aop/support/ComposablePointcutTests.java b/org.springframework.aop/src/test/java/org/springframework/aop/support/ComposablePointcutTests.java similarity index 93% rename from org.springframework.testsuite/src/test/java/org/springframework/aop/support/ComposablePointcutTests.java rename to org.springframework.aop/src/test/java/org/springframework/aop/support/ComposablePointcutTests.java index d73d642bcae..ebe1f00090f 100644 --- a/org.springframework.testsuite/src/test/java/org/springframework/aop/support/ComposablePointcutTests.java +++ b/org.springframework.aop/src/test/java/org/springframework/aop/support/ComposablePointcutTests.java @@ -17,10 +17,11 @@ package org.springframework.aop.support; +import static org.junit.Assert.*; + import java.lang.reflect.Method; -import junit.framework.TestCase; - +import org.junit.Test; import org.springframework.aop.ClassFilter; import org.springframework.aop.MethodMatcher; import org.springframework.aop.Pointcut; @@ -29,39 +30,42 @@ import org.springframework.core.NestedRuntimeException; /** * @author Rod Johnson + * @author Chris Beams */ -public class ComposablePointcutTests extends TestCase { +public class ComposablePointcutTests { public static MethodMatcher GETTER_METHOD_MATCHER = new StaticMethodMatcher() { - public boolean matches(Method m, Class targetClass) { + public boolean matches(Method m, Class targetClass) { return m.getName().startsWith("get"); } }; public static MethodMatcher GET_AGE_METHOD_MATCHER = new StaticMethodMatcher() { - public boolean matches(Method m, Class targetClass) { + public boolean matches(Method m, Class targetClass) { return m.getName().equals("getAge"); } }; public static MethodMatcher ABSQUATULATE_METHOD_MATCHER = new StaticMethodMatcher() { - public boolean matches(Method m, Class targetClass) { + public boolean matches(Method m, Class targetClass) { return m.getName().equals("absquatulate"); } }; public static MethodMatcher SETTER_METHOD_MATCHER = new StaticMethodMatcher() { - public boolean matches(Method m, Class targetClass) { + public boolean matches(Method m, Class targetClass) { return m.getName().startsWith("set"); } }; + @Test public void testMatchAll() throws NoSuchMethodException { Pointcut pc = new ComposablePointcut(); assertTrue(pc.getClassFilter().matches(Object.class)); assertTrue(pc.getMethodMatcher().matches(Object.class.getMethod("hashCode", (Class[]) null), Exception.class)); } + @Test public void testFilterByClass() throws NoSuchMethodException { ComposablePointcut pc = new ComposablePointcut(); @@ -81,6 +85,7 @@ public class ComposablePointcutTests extends TestCase { assertTrue(pc.getClassFilter().matches(NestedRuntimeException.class)); } + @Test public void testUnionMethodMatcher() { // Matches the getAge() method in any class ComposablePointcut pc = new ComposablePointcut(ClassFilter.TRUE, GET_AGE_METHOD_MATCHER); @@ -103,6 +108,7 @@ public class ComposablePointcutTests extends TestCase { assertFalse(Pointcuts.matches(pc, PointcutsTests.TEST_BEAN_SET_AGE, TestBean.class, null)); } + @Test public void testIntersectionMethodMatcher() { ComposablePointcut pc = new ComposablePointcut(); assertTrue(pc.getMethodMatcher().matches(PointcutsTests.TEST_BEAN_ABSQUATULATE, TestBean.class)); @@ -119,6 +125,7 @@ public class ComposablePointcutTests extends TestCase { assertFalse(Pointcuts.matches(pc, PointcutsTests.TEST_BEAN_GET_NAME, TestBean.class, null)); } + @Test public void testEqualsAndHashCode() throws Exception { ComposablePointcut pc1 = new ComposablePointcut(); ComposablePointcut pc2 = new ComposablePointcut(); diff --git a/org.springframework.testsuite/src/test/java/org/springframework/aop/support/ControlFlowPointcutTests.java b/org.springframework.aop/src/test/java/org/springframework/aop/support/ControlFlowPointcutTests.java similarity index 96% rename from org.springframework.testsuite/src/test/java/org/springframework/aop/support/ControlFlowPointcutTests.java rename to org.springframework.aop/src/test/java/org/springframework/aop/support/ControlFlowPointcutTests.java index 100cab23725..940c2824ed2 100644 --- a/org.springframework.testsuite/src/test/java/org/springframework/aop/support/ControlFlowPointcutTests.java +++ b/org.springframework.aop/src/test/java/org/springframework/aop/support/ControlFlowPointcutTests.java @@ -16,8 +16,9 @@ package org.springframework.aop.support; -import junit.framework.TestCase; +import static org.junit.Assert.*; +import org.junit.Test; import org.springframework.aop.Pointcut; import org.springframework.aop.framework.ProxyFactory; import org.springframework.aop.interceptor.NopInterceptor; @@ -25,15 +26,12 @@ import org.springframework.beans.ITestBean; import org.springframework.beans.TestBean; /** - * * @author Rod Johnson + * @author Chris Beams */ -public class ControlFlowPointcutTests extends TestCase { - - public ControlFlowPointcutTests(String s) { - super(s); - } +public class ControlFlowPointcutTests { + @Test public void testMatches() { TestBean target = new TestBean(); target.setAge(27); @@ -64,6 +62,7 @@ public class ControlFlowPointcutTests extends TestCase { * to the cflow pointcut, meaning that it's not so prohibitively * expensive. */ + @Test public void testSelectiveApplication() { TestBean target = new TestBean(); target.setAge(27); @@ -90,6 +89,7 @@ public class ControlFlowPointcutTests extends TestCase { assertEquals(1, cflow.getEvaluations()); } + @Test public void testEqualsAndHashCode() throws Exception { assertEquals(new ControlFlowPointcut(One.class), new ControlFlowPointcut(One.class)); assertEquals(new ControlFlowPointcut(One.class, "getAge"), new ControlFlowPointcut(One.class, "getAge")); diff --git a/org.springframework.testsuite/src/test/java/org/springframework/aop/support/JdkRegexpMethodPointcutTests.java b/org.springframework.aop/src/test/java/org/springframework/aop/support/JdkRegexpMethodPointcutTests.java similarity index 100% rename from org.springframework.testsuite/src/test/java/org/springframework/aop/support/JdkRegexpMethodPointcutTests.java rename to org.springframework.aop/src/test/java/org/springframework/aop/support/JdkRegexpMethodPointcutTests.java diff --git a/org.springframework.testsuite/src/test/java/org/springframework/aop/support/PointcutsTests.java b/org.springframework.aop/src/test/java/org/springframework/aop/support/PointcutsTests.java similarity index 96% rename from org.springframework.testsuite/src/test/java/org/springframework/aop/support/PointcutsTests.java rename to org.springframework.aop/src/test/java/org/springframework/aop/support/PointcutsTests.java index 115903240c6..d3cfd9759c4 100644 --- a/org.springframework.testsuite/src/test/java/org/springframework/aop/support/PointcutsTests.java +++ b/org.springframework.aop/src/test/java/org/springframework/aop/support/PointcutsTests.java @@ -16,19 +16,20 @@ package org.springframework.aop.support; +import static org.junit.Assert.*; + import java.lang.reflect.Method; +import org.junit.Test; import org.springframework.aop.ClassFilter; import org.springframework.aop.Pointcut; import org.springframework.beans.TestBean; -import junit.framework.TestCase; - /** - * * @author Rod Johnson + * @author Chris Beams */ -public class PointcutsTests extends TestCase { +public class PointcutsTests { public static Method TEST_BEAN_SET_AGE; public static Method TEST_BEAN_GET_AGE; @@ -53,13 +54,13 @@ public class PointcutsTests extends TestCase { public static Pointcut allTestBeanMethodsPointcut = new StaticMethodMatcherPointcut() { public ClassFilter getClassFilter() { return new ClassFilter() { - public boolean matches(Class clazz) { + public boolean matches(Class clazz) { return clazz.equals(TestBean.class); } }; } - public boolean matches(Method m, Class targetClass) { + public boolean matches(Method m, Class targetClass) { return true; } }; @@ -75,7 +76,7 @@ public class PointcutsTests extends TestCase { return new RootClassFilter(MyTestBean.class); } - public boolean matches(Method m, Class targetClass) { + public boolean matches(Method m, Class targetClass) { return m.getName().startsWith("set"); } }; @@ -86,7 +87,7 @@ public class PointcutsTests extends TestCase { return new RootClassFilter(MyTestBean.class); } - public boolean matches(Method m, Class targetClass) { + public boolean matches(Method m, Class targetClass) { return m.getName().startsWith("get"); } }; @@ -100,7 +101,7 @@ public class PointcutsTests extends TestCase { return new RootClassFilter(MyTestBeanSubclass.class); } - public boolean matches(Method m, Class targetClass) { + public boolean matches(Method m, Class targetClass) { return m.getName().startsWith("get"); } }; @@ -112,10 +113,7 @@ public class PointcutsTests extends TestCase { public static Pointcut allClassGetNamePointcut = new NameMatchMethodPointcut().addMethodName("getName"); - public PointcutsTests(String s) { - super(s); - } - + @Test public void testTrue() { assertTrue(Pointcuts.matches(Pointcut.TRUE, TEST_BEAN_SET_AGE, TestBean.class, new Object[] { new Integer(6)})); assertTrue(Pointcuts.matches(Pointcut.TRUE, TEST_BEAN_GET_AGE, TestBean.class, null)); @@ -125,6 +123,7 @@ public class PointcutsTests extends TestCase { assertTrue(Pointcuts.matches(Pointcut.TRUE, TEST_BEAN_ABSQUATULATE, TestBean.class, null)); } + @Test public void testMatches() { assertTrue(Pointcuts.matches(allClassSetterPointcut, TEST_BEAN_SET_AGE, TestBean.class, new Object[] { new Integer(6)})); assertFalse(Pointcuts.matches(allClassSetterPointcut, TEST_BEAN_GET_AGE, TestBean.class, null)); @@ -137,6 +136,7 @@ public class PointcutsTests extends TestCase { /** * Should match all setters and getters on any class */ + @Test public void testUnionOfSettersAndGetters() { Pointcut union = Pointcuts.union(allClassGetterPointcut, allClassSetterPointcut); assertTrue(Pointcuts.matches(union, TEST_BEAN_SET_AGE, TestBean.class, new Object[] { new Integer(6)})); @@ -144,6 +144,7 @@ public class PointcutsTests extends TestCase { assertFalse(Pointcuts.matches(union, TEST_BEAN_ABSQUATULATE, TestBean.class, null)); } + @Test public void testUnionOfSpecificGetters() { Pointcut union = Pointcuts.union(allClassGetAgePointcut, allClassGetNamePointcut); assertFalse(Pointcuts.matches(union, TEST_BEAN_SET_AGE, TestBean.class, new Object[] { new Integer(6)})); @@ -167,6 +168,7 @@ public class PointcutsTests extends TestCase { * Tests vertical composition. First pointcut matches all setters. * Second one matches all getters in the MyTestBean class. TestBean getters shouldn't pass. */ + @Test public void testUnionOfAllSettersAndSubclassSetters() { assertFalse(Pointcuts.matches(myTestBeanSetterPointcut, TEST_BEAN_SET_AGE, TestBean.class, new Object[] { new Integer(6)})); assertTrue(Pointcuts.matches(myTestBeanSetterPointcut, TEST_BEAN_SET_AGE, MyTestBean.class, new Object[] { new Integer(6)})); @@ -184,6 +186,7 @@ public class PointcutsTests extends TestCase { * Intersection should be MyTestBean getAge() only: * it's the union of allClassGetAge and subclass getters */ + @Test public void testIntersectionOfSpecificGettersAndSubclassGetters() { assertTrue(Pointcuts.matches(allClassGetAgePointcut, TEST_BEAN_GET_AGE, TestBean.class, null)); assertTrue(Pointcuts.matches(allClassGetAgePointcut, TEST_BEAN_GET_AGE, MyTestBean.class, null)); @@ -229,6 +232,7 @@ public class PointcutsTests extends TestCase { /** * The intersection of these two pointcuts leaves nothing. */ + @Test public void testSimpleIntersection() { Pointcut intersection = Pointcuts.intersection(allClassGetterPointcut, allClassSetterPointcut); assertFalse(Pointcuts.matches(intersection, TEST_BEAN_SET_AGE, TestBean.class, new Object[] { new Integer(6)})); diff --git a/org.springframework.testsuite/src/test/java/org/springframework/aop/scope/ScopedProxyTests.java b/org.springframework.testsuite/src/test/java/org/springframework/aop/scope/ScopedProxyTests.java index 54515872534..d9c3cbfef40 100644 --- a/org.springframework.testsuite/src/test/java/org/springframework/aop/scope/ScopedProxyTests.java +++ b/org.springframework.testsuite/src/test/java/org/springframework/aop/scope/ScopedProxyTests.java @@ -16,12 +16,13 @@ package org.springframework.aop.scope; +import static org.junit.Assert.*; + import java.util.ArrayList; import java.util.HashMap; import java.util.Map; -import junit.framework.TestCase; - +import org.junit.Test; import org.springframework.aop.support.AopUtils; import org.springframework.beans.ITestBean; import org.springframework.beans.TestBean; @@ -34,16 +35,19 @@ import org.springframework.core.io.ClassPathResource; /** * @author Rob Harrop * @author Juergen Hoeller + * @author Chris Beams */ -public class ScopedProxyTests extends TestCase { +public class ScopedProxyTests { /* SPR-2108 */ + @Test public void testProxyAssignable() throws Exception { XmlBeanFactory bf = new XmlBeanFactory(new ClassPathResource("scopedMap.xml", getClass())); Object baseMap = bf.getBean("singletonMap"); assertTrue(baseMap instanceof Map); } + @Test public void testSimpleProxy() throws Exception { XmlBeanFactory bf = new XmlBeanFactory(new ClassPathResource("scopedMap.xml", getClass())); Object simpleMap = bf.getBean("simpleMap"); @@ -51,6 +55,7 @@ public class ScopedProxyTests extends TestCase { assertTrue(simpleMap instanceof HashMap); } + @Test public void testScopedOverride() throws Exception { GenericApplicationContext ctx = new GenericApplicationContext(); new XmlBeanDefinitionReader(ctx).loadBeanDefinitions(new ClassPathResource("scopedOverride.xml", getClass())); @@ -66,6 +71,7 @@ public class ScopedProxyTests extends TestCase { assertEquals(TestBean.class, scope.getMap().get("scopedTarget.testBean").getClass()); } + @Test public void testJdkScopedProxy() throws Exception { XmlBeanFactory bf = new XmlBeanFactory(new ClassPathResource("scopedTestBean.xml", getClass())); SimpleMapScope scope = new SimpleMapScope(); @@ -82,6 +88,7 @@ public class ScopedProxyTests extends TestCase { assertEquals(TestBean.class, scope.getMap().get("testBeanTarget").getClass()); } + @Test public void testCglibScopedProxy() { XmlBeanFactory bf = new XmlBeanFactory(new ClassPathResource("scopedList.xml", getClass())); SimpleMapScope scope = new SimpleMapScope(); diff --git a/org.springframework.testsuite/src/test/java/org/springframework/aop/support/ClassFiltersTests.java b/org.springframework.testsuite/src/test/java/org/springframework/aop/support/ClassFiltersTests.java index a6d61f85439..0610b8f6a27 100644 --- a/org.springframework.testsuite/src/test/java/org/springframework/aop/support/ClassFiltersTests.java +++ b/org.springframework.testsuite/src/test/java/org/springframework/aop/support/ClassFiltersTests.java @@ -17,8 +17,9 @@ package org.springframework.aop.support; -import junit.framework.TestCase; +import static org.junit.Assert.*; +import org.junit.Test; import org.springframework.aop.ClassFilter; import org.springframework.beans.ITestBean; import org.springframework.beans.TestBean; @@ -26,8 +27,9 @@ import org.springframework.core.NestedRuntimeException; /** * @author Rod Johnson + * @author Chris Beams */ -public class ClassFiltersTests extends TestCase { +public class ClassFiltersTests { private ClassFilter exceptionFilter = new RootClassFilter(Exception.class); @@ -35,6 +37,7 @@ public class ClassFiltersTests extends TestCase { private ClassFilter hasRootCauseFilter = new RootClassFilter(NestedRuntimeException.class); + @Test public void testUnion() { assertTrue(exceptionFilter.matches(RuntimeException.class)); assertFalse(exceptionFilter.matches(TestBean.class)); @@ -45,6 +48,7 @@ public class ClassFiltersTests extends TestCase { assertTrue(union.matches(TestBean.class)); } + @Test public void testIntersection() { assertTrue(exceptionFilter.matches(RuntimeException.class)); assertTrue(hasRootCauseFilter.matches(NestedRuntimeException.class));