From f4a7700216f1078e89a1badecf30dd903c7ebad1 Mon Sep 17 00:00:00 2001 From: Chris Beams Date: Fri, 12 Dec 2008 03:36:10 +0000 Subject: [PATCH] moving unit tests from .testsuite -> .aop --- .../config/AopNamespaceHandlerEventTests.java | 17 ++++++++++++----- .../AopNamespaceHandlerPointcutErrorTests.java | 7 +++++-- .../aop/config/TopLevelAopTagTests.java | 7 +++++-- ...ndlerAdvisorWithDirectPointcutEventTests.xml | 0 ...eHandlerAdvisorWithPointcutRefEventTests.xml | 0 .../aopNamespaceHandlerAspectEventTests.xml | 0 ...NamespaceHandlerPointcutDuplicationTests.xml | 0 .../aopNamespaceHandlerPointcutEventTests.xml | 0 .../aopNamespaceHandlerPointcutMissingTests.xml | 0 .../springframework/aop/config/topLevelAop.xml | 0 .../aop/config/AopNamespaceAdviceTypeTests.java | 8 +++++--- .../AopNamespaceHandlerArgNamesTests.java | 7 +++++-- ...opNamespaceHandlerProxyTargetClassTests.java | 4 ++++ .../AopNamespaceHandlerReturningTests.java | 7 +++++-- .../config/AopNamespaceHandlerScopeTests.java | 9 +++++++-- .../aop/config/AopNamespaceHandlerTests.java | 11 +++++++++-- .../AopNamespaceHandlerThrowingTests.java | 7 +++++-- .../config/MethodLocatingFactoryBeanTests.java | 15 +++++++++++++-- .../aop/config/PrototypeProxyTests.java | 6 +++--- 19 files changed, 78 insertions(+), 27 deletions(-) rename {org.springframework.testsuite => org.springframework.aop}/src/test/java/org/springframework/aop/config/AopNamespaceHandlerEventTests.java (96%) rename {org.springframework.testsuite => org.springframework.aop}/src/test/java/org/springframework/aop/config/AopNamespaceHandlerPointcutErrorTests.java (92%) rename {org.springframework.testsuite => org.springframework.aop}/src/test/java/org/springframework/aop/config/TopLevelAopTagTests.java (91%) rename {org.springframework.testsuite => org.springframework.aop}/src/test/java/org/springframework/aop/config/aopNamespaceHandlerAdvisorWithDirectPointcutEventTests.xml (100%) rename {org.springframework.testsuite => org.springframework.aop}/src/test/java/org/springframework/aop/config/aopNamespaceHandlerAdvisorWithPointcutRefEventTests.xml (100%) rename {org.springframework.testsuite => org.springframework.aop}/src/test/java/org/springframework/aop/config/aopNamespaceHandlerAspectEventTests.xml (100%) rename {org.springframework.testsuite => org.springframework.aop}/src/test/java/org/springframework/aop/config/aopNamespaceHandlerPointcutDuplicationTests.xml (100%) rename {org.springframework.testsuite => org.springframework.aop}/src/test/java/org/springframework/aop/config/aopNamespaceHandlerPointcutEventTests.xml (100%) rename {org.springframework.testsuite => org.springframework.aop}/src/test/java/org/springframework/aop/config/aopNamespaceHandlerPointcutMissingTests.xml (100%) rename {org.springframework.testsuite => org.springframework.aop}/src/test/java/org/springframework/aop/config/topLevelAop.xml (100%) diff --git a/org.springframework.testsuite/src/test/java/org/springframework/aop/config/AopNamespaceHandlerEventTests.java b/org.springframework.aop/src/test/java/org/springframework/aop/config/AopNamespaceHandlerEventTests.java similarity index 96% rename from org.springframework.testsuite/src/test/java/org/springframework/aop/config/AopNamespaceHandlerEventTests.java rename to org.springframework.aop/src/test/java/org/springframework/aop/config/AopNamespaceHandlerEventTests.java index 7e49b8e845f..0b389ed8571 100644 --- a/org.springframework.testsuite/src/test/java/org/springframework/aop/config/AopNamespaceHandlerEventTests.java +++ b/org.springframework.aop/src/test/java/org/springframework/aop/config/AopNamespaceHandlerEventTests.java @@ -16,11 +16,13 @@ package org.springframework.aop.config; +import static org.junit.Assert.*; + import java.util.HashSet; import java.util.Set; -import junit.framework.TestCase; - +import org.junit.Before; +import org.junit.Test; import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.config.BeanReference; import org.springframework.beans.factory.parsing.BeanComponentDefinition; @@ -35,7 +37,7 @@ import org.springframework.core.io.ClassPathResource; * @author Rob Harrop * @author Juergen Hoeller */ -public class AopNamespaceHandlerEventTests extends TestCase { +public class AopNamespaceHandlerEventTests { private CollectingReaderEventListener eventListener = new CollectingReaderEventListener(); @@ -44,11 +46,13 @@ public class AopNamespaceHandlerEventTests extends TestCase { private DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory(); - protected void setUp() throws Exception { + @Before + public void setUp() throws Exception { this.reader = new XmlBeanDefinitionReader(this.beanFactory); this.reader.setEventListener(this.eventListener); } + @Test public void testPointcutEvents() throws Exception { loadBeansFrom("aopNamespaceHandlerPointcutEventTests.xml"); ComponentDefinition[] componentDefinitions = this.eventListener.getComponentDefinitions(); @@ -72,6 +76,7 @@ public class AopNamespaceHandlerEventTests extends TestCase { assertEquals("Incorrect number of BeanDefinitions", 1, pcd.getBeanDefinitions().length); } + @Test public void testAdvisorEventsWithPointcutRef() throws Exception { loadBeansFrom("aopNamespaceHandlerAdvisorWithPointcutRefEventTests.xml"); ComponentDefinition[] componentDefinitions = this.eventListener.getComponentDefinitions(); @@ -100,6 +105,7 @@ public class AopNamespaceHandlerEventTests extends TestCase { assertEquals("countingAdvice", adviceDef.getBeanName()); } + @Test public void testAdvisorEventsWithDirectPointcut() throws Exception { loadBeansFrom("aopNamespaceHandlerAdvisorWithDirectPointcutEventTests.xml"); ComponentDefinition[] componentDefinitions = this.eventListener.getComponentDefinitions(); @@ -128,6 +134,7 @@ public class AopNamespaceHandlerEventTests extends TestCase { assertEquals("countingAdvice", adviceDef.getBeanName()); } + @Test public void testAspectEvent() throws Exception { loadBeansFrom("aopNamespaceHandlerAspectEventTests.xml"); ComponentDefinition[] componentDefinitions = this.eventListener.getComponentDefinitions(); @@ -154,7 +161,7 @@ public class AopNamespaceHandlerEventTests extends TestCase { BeanReference[] beanReferences = acd.getBeanReferences(); assertEquals(6, beanReferences.length); - Set expectedReferences = new HashSet(); + Set expectedReferences = new HashSet(); expectedReferences.add("pc"); expectedReferences.add("countingAdvice"); for (int i = 0; i < beanReferences.length; i++) { diff --git a/org.springframework.testsuite/src/test/java/org/springframework/aop/config/AopNamespaceHandlerPointcutErrorTests.java b/org.springframework.aop/src/test/java/org/springframework/aop/config/AopNamespaceHandlerPointcutErrorTests.java similarity index 92% rename from org.springframework.testsuite/src/test/java/org/springframework/aop/config/AopNamespaceHandlerPointcutErrorTests.java rename to org.springframework.aop/src/test/java/org/springframework/aop/config/AopNamespaceHandlerPointcutErrorTests.java index c5dfcab6b07..ae01a9c8ca1 100644 --- a/org.springframework.testsuite/src/test/java/org/springframework/aop/config/AopNamespaceHandlerPointcutErrorTests.java +++ b/org.springframework.aop/src/test/java/org/springframework/aop/config/AopNamespaceHandlerPointcutErrorTests.java @@ -16,8 +16,9 @@ package org.springframework.aop.config; -import junit.framework.TestCase; +import static org.junit.Assert.*; +import org.junit.Test; import org.springframework.beans.factory.BeanDefinitionStoreException; import org.springframework.beans.factory.parsing.BeanDefinitionParsingException; import org.springframework.beans.factory.xml.XmlBeanFactory; @@ -26,8 +27,9 @@ import org.springframework.core.io.ClassPathResource; /** * @author Mark Fisher */ -public class AopNamespaceHandlerPointcutErrorTests extends TestCase { +public class AopNamespaceHandlerPointcutErrorTests { + @Test public void testDuplicatePointcutConfig() { try { new XmlBeanFactory(new ClassPathResource( @@ -39,6 +41,7 @@ public class AopNamespaceHandlerPointcutErrorTests extends TestCase { } } + @Test public void testMissingPointcutConfig() { try { new XmlBeanFactory(new ClassPathResource( diff --git a/org.springframework.testsuite/src/test/java/org/springframework/aop/config/TopLevelAopTagTests.java b/org.springframework.aop/src/test/java/org/springframework/aop/config/TopLevelAopTagTests.java similarity index 91% rename from org.springframework.testsuite/src/test/java/org/springframework/aop/config/TopLevelAopTagTests.java rename to org.springframework.aop/src/test/java/org/springframework/aop/config/TopLevelAopTagTests.java index f9d6f66e565..82715eff24d 100644 --- a/org.springframework.testsuite/src/test/java/org/springframework/aop/config/TopLevelAopTagTests.java +++ b/org.springframework.aop/src/test/java/org/springframework/aop/config/TopLevelAopTagTests.java @@ -16,7 +16,9 @@ package org.springframework.aop.config; -import junit.framework.TestCase; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; import org.springframework.core.io.ClassPathResource; @@ -26,8 +28,9 @@ import org.springframework.core.io.ClassPathResource; * * @author Rob Harrop */ -public final class TopLevelAopTagTests extends TestCase { +public final class TopLevelAopTagTests { + @Test public void testParse() throws Exception { DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory(); XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(beanFactory); diff --git a/org.springframework.testsuite/src/test/java/org/springframework/aop/config/aopNamespaceHandlerAdvisorWithDirectPointcutEventTests.xml b/org.springframework.aop/src/test/java/org/springframework/aop/config/aopNamespaceHandlerAdvisorWithDirectPointcutEventTests.xml similarity index 100% rename from org.springframework.testsuite/src/test/java/org/springframework/aop/config/aopNamespaceHandlerAdvisorWithDirectPointcutEventTests.xml rename to org.springframework.aop/src/test/java/org/springframework/aop/config/aopNamespaceHandlerAdvisorWithDirectPointcutEventTests.xml diff --git a/org.springframework.testsuite/src/test/java/org/springframework/aop/config/aopNamespaceHandlerAdvisorWithPointcutRefEventTests.xml b/org.springframework.aop/src/test/java/org/springframework/aop/config/aopNamespaceHandlerAdvisorWithPointcutRefEventTests.xml similarity index 100% rename from org.springframework.testsuite/src/test/java/org/springframework/aop/config/aopNamespaceHandlerAdvisorWithPointcutRefEventTests.xml rename to org.springframework.aop/src/test/java/org/springframework/aop/config/aopNamespaceHandlerAdvisorWithPointcutRefEventTests.xml diff --git a/org.springframework.testsuite/src/test/java/org/springframework/aop/config/aopNamespaceHandlerAspectEventTests.xml b/org.springframework.aop/src/test/java/org/springframework/aop/config/aopNamespaceHandlerAspectEventTests.xml similarity index 100% rename from org.springframework.testsuite/src/test/java/org/springframework/aop/config/aopNamespaceHandlerAspectEventTests.xml rename to org.springframework.aop/src/test/java/org/springframework/aop/config/aopNamespaceHandlerAspectEventTests.xml diff --git a/org.springframework.testsuite/src/test/java/org/springframework/aop/config/aopNamespaceHandlerPointcutDuplicationTests.xml b/org.springframework.aop/src/test/java/org/springframework/aop/config/aopNamespaceHandlerPointcutDuplicationTests.xml similarity index 100% rename from org.springframework.testsuite/src/test/java/org/springframework/aop/config/aopNamespaceHandlerPointcutDuplicationTests.xml rename to org.springframework.aop/src/test/java/org/springframework/aop/config/aopNamespaceHandlerPointcutDuplicationTests.xml diff --git a/org.springframework.testsuite/src/test/java/org/springframework/aop/config/aopNamespaceHandlerPointcutEventTests.xml b/org.springframework.aop/src/test/java/org/springframework/aop/config/aopNamespaceHandlerPointcutEventTests.xml similarity index 100% rename from org.springframework.testsuite/src/test/java/org/springframework/aop/config/aopNamespaceHandlerPointcutEventTests.xml rename to org.springframework.aop/src/test/java/org/springframework/aop/config/aopNamespaceHandlerPointcutEventTests.xml diff --git a/org.springframework.testsuite/src/test/java/org/springframework/aop/config/aopNamespaceHandlerPointcutMissingTests.xml b/org.springframework.aop/src/test/java/org/springframework/aop/config/aopNamespaceHandlerPointcutMissingTests.xml similarity index 100% rename from org.springframework.testsuite/src/test/java/org/springframework/aop/config/aopNamespaceHandlerPointcutMissingTests.xml rename to org.springframework.aop/src/test/java/org/springframework/aop/config/aopNamespaceHandlerPointcutMissingTests.xml diff --git a/org.springframework.testsuite/src/test/java/org/springframework/aop/config/topLevelAop.xml b/org.springframework.aop/src/test/java/org/springframework/aop/config/topLevelAop.xml similarity index 100% rename from org.springframework.testsuite/src/test/java/org/springframework/aop/config/topLevelAop.xml rename to org.springframework.aop/src/test/java/org/springframework/aop/config/topLevelAop.xml diff --git a/org.springframework.testsuite/src/test/java/org/springframework/aop/config/AopNamespaceAdviceTypeTests.java b/org.springframework.testsuite/src/test/java/org/springframework/aop/config/AopNamespaceAdviceTypeTests.java index a62a6dec0e4..f71f2dbb81b 100644 --- a/org.springframework.testsuite/src/test/java/org/springframework/aop/config/AopNamespaceAdviceTypeTests.java +++ b/org.springframework.testsuite/src/test/java/org/springframework/aop/config/AopNamespaceAdviceTypeTests.java @@ -16,10 +16,10 @@ package org.springframework.aop.config; -import junit.framework.TestCase; +import static org.junit.Assert.*; +import org.junit.Test; import org.springframework.beans.ITestBean; -import org.springframework.beans.factory.BeanCreationException; import org.springframework.beans.factory.BeanDefinitionStoreException; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; @@ -28,7 +28,7 @@ import org.xml.sax.SAXParseException; /** * @author Adrian Colyer */ -public class AopNamespaceAdviceTypeTests extends TestCase { +public class AopNamespaceAdviceTypeTests { private ApplicationContext context; @@ -40,10 +40,12 @@ public class AopNamespaceAdviceTypeTests extends TestCase { return "org/springframework/aop/config/aopNamespaceHandlerAdviceTypeErrorTests.xml"; } + @Test public void testParsingOfAdviceTypes() { this.context = new ClassPathXmlApplicationContext(getOKConfigLocation()); } + @Test public void testParsingOfAdviceTypesWithError() { try { this.context = new ClassPathXmlApplicationContext(getErrorConfigLocation()); diff --git a/org.springframework.testsuite/src/test/java/org/springframework/aop/config/AopNamespaceHandlerArgNamesTests.java b/org.springframework.testsuite/src/test/java/org/springframework/aop/config/AopNamespaceHandlerArgNamesTests.java index 6f58ae39319..f59748bca34 100644 --- a/org.springframework.testsuite/src/test/java/org/springframework/aop/config/AopNamespaceHandlerArgNamesTests.java +++ b/org.springframework.testsuite/src/test/java/org/springframework/aop/config/AopNamespaceHandlerArgNamesTests.java @@ -16,8 +16,9 @@ package org.springframework.aop.config; -import junit.framework.TestCase; +import static org.junit.Assert.*; +import org.junit.Test; import org.springframework.beans.ITestBean; import org.springframework.beans.factory.BeanCreationException; import org.springframework.context.ApplicationContext; @@ -26,7 +27,7 @@ import org.springframework.context.support.ClassPathXmlApplicationContext; /** * @author Adrian Colyer */ -public class AopNamespaceHandlerArgNamesTests extends TestCase { +public class AopNamespaceHandlerArgNamesTests { private ApplicationContext context; @@ -38,10 +39,12 @@ public class AopNamespaceHandlerArgNamesTests extends TestCase { return "org/springframework/aop/config/aopNamespaceHandlerArgNamesErrorTests.xml"; } + @Test public void testArgNamesOK() { this.context = new ClassPathXmlApplicationContext(getOKConfigLocation()); } + @Test public void testArgNamesError() { try { this.context = new ClassPathXmlApplicationContext(getErrorConfigLocation()); diff --git a/org.springframework.testsuite/src/test/java/org/springframework/aop/config/AopNamespaceHandlerProxyTargetClassTests.java b/org.springframework.testsuite/src/test/java/org/springframework/aop/config/AopNamespaceHandlerProxyTargetClassTests.java index 73e9f377be5..abaeb20d1db 100644 --- a/org.springframework.testsuite/src/test/java/org/springframework/aop/config/AopNamespaceHandlerProxyTargetClassTests.java +++ b/org.springframework.testsuite/src/test/java/org/springframework/aop/config/AopNamespaceHandlerProxyTargetClassTests.java @@ -16,6 +16,9 @@ package org.springframework.aop.config; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; import org.springframework.aop.support.AopUtils; import org.springframework.beans.ITestBean; @@ -24,6 +27,7 @@ import org.springframework.beans.ITestBean; */ public class AopNamespaceHandlerProxyTargetClassTests extends AopNamespaceHandlerTests { + @Test public void testIsClassProxy() { ITestBean bean = getTestBean(); assertTrue("Should be a CGLIB proxy", AopUtils.isCglibProxy(bean)); diff --git a/org.springframework.testsuite/src/test/java/org/springframework/aop/config/AopNamespaceHandlerReturningTests.java b/org.springframework.testsuite/src/test/java/org/springframework/aop/config/AopNamespaceHandlerReturningTests.java index 9852cdfef4e..e3d05a601a9 100644 --- a/org.springframework.testsuite/src/test/java/org/springframework/aop/config/AopNamespaceHandlerReturningTests.java +++ b/org.springframework.testsuite/src/test/java/org/springframework/aop/config/AopNamespaceHandlerReturningTests.java @@ -16,8 +16,9 @@ package org.springframework.aop.config; -import junit.framework.TestCase; +import static org.junit.Assert.*; +import org.junit.Test; import org.springframework.beans.ITestBean; import org.springframework.beans.factory.BeanDefinitionStoreException; import org.springframework.context.ApplicationContext; @@ -27,7 +28,7 @@ import org.xml.sax.SAXParseException; /** * @author Adrian Colyer */ -public class AopNamespaceHandlerReturningTests extends TestCase { +public class AopNamespaceHandlerReturningTests { private ApplicationContext context; @@ -39,10 +40,12 @@ public class AopNamespaceHandlerReturningTests extends TestCase { return "org/springframework/aop/config/aopNamespaceHandlerReturningErrorTests.xml"; } + @Test public void testReturningOnReturningAdvice() { this.context = new ClassPathXmlApplicationContext(getOKConfigLocation()); } + @Test public void testParseReturningOnOtherAdviceType() { try { this.context = new ClassPathXmlApplicationContext(getErrorConfigLocation()); diff --git a/org.springframework.testsuite/src/test/java/org/springframework/aop/config/AopNamespaceHandlerScopeTests.java b/org.springframework.testsuite/src/test/java/org/springframework/aop/config/AopNamespaceHandlerScopeTests.java index e8bce909650..1d1cc6bb8b3 100644 --- a/org.springframework.testsuite/src/test/java/org/springframework/aop/config/AopNamespaceHandlerScopeTests.java +++ b/org.springframework.testsuite/src/test/java/org/springframework/aop/config/AopNamespaceHandlerScopeTests.java @@ -16,8 +16,10 @@ package org.springframework.aop.config; -import junit.framework.TestCase; +import static org.junit.Assert.*; +import org.junit.Before; +import org.junit.Test; import org.springframework.aop.framework.Advised; import org.springframework.aop.support.AopUtils; import org.springframework.beans.ITestBean; @@ -33,10 +35,11 @@ import org.springframework.web.context.support.XmlWebApplicationContext; * @author Rob Harrop * @author Juergen Hoeller */ -public class AopNamespaceHandlerScopeTests extends TestCase { +public class AopNamespaceHandlerScopeTests { private ApplicationContext context; + @Before public void setUp() { XmlWebApplicationContext wac = new XmlWebApplicationContext(); wac.setConfigLocations(new String[] {"classpath:org/springframework/aop/config/aopNamespaceHandlerScopeTests.xml"}); @@ -44,6 +47,7 @@ public class AopNamespaceHandlerScopeTests extends TestCase { this.context = wac; } + @Test public void testRequestScoping() throws Exception { MockHttpServletRequest oldRequest = new MockHttpServletRequest(); MockHttpServletRequest newRequest = new MockHttpServletRequest(); @@ -71,6 +75,7 @@ public class AopNamespaceHandlerScopeTests extends TestCase { assertTrue("Should have advisors", ((Advised) scoped).getAdvisors().length > 0); } + @Test public void testSessionScoping() throws Exception { MockHttpSession oldSession = new MockHttpSession(); MockHttpSession newSession = new MockHttpSession(); diff --git a/org.springframework.testsuite/src/test/java/org/springframework/aop/config/AopNamespaceHandlerTests.java b/org.springframework.testsuite/src/test/java/org/springframework/aop/config/AopNamespaceHandlerTests.java index 70e57beed78..bc2d07e58c9 100644 --- a/org.springframework.testsuite/src/test/java/org/springframework/aop/config/AopNamespaceHandlerTests.java +++ b/org.springframework.testsuite/src/test/java/org/springframework/aop/config/AopNamespaceHandlerTests.java @@ -16,7 +16,10 @@ package org.springframework.aop.config; -import junit.framework.TestCase; +import static org.junit.Assert.*; + +import org.junit.Before; +import org.junit.Test; import org.springframework.aop.Advisor; import org.springframework.aop.framework.Advised; import org.springframework.aop.framework.CountingBeforeAdvice; @@ -28,10 +31,11 @@ import org.springframework.context.support.ClassPathXmlApplicationContext; /** * @author Rob Harrop */ -public class AopNamespaceHandlerTests extends TestCase { +public class AopNamespaceHandlerTests { private ApplicationContext context; + @Before public void setUp() { this.context = new ClassPathXmlApplicationContext(getConfigLocation()); } @@ -40,6 +44,7 @@ public class AopNamespaceHandlerTests extends TestCase { return "org/springframework/aop/config/aopNamespaceHandlerTests.xml"; } + @Test public void testIsProxy() throws Exception { ITestBean bean = getTestBean(); @@ -52,6 +57,7 @@ public class AopNamespaceHandlerTests extends TestCase { assertTrue("Advisors should not be empty", advisors.length > 0); } + @Test public void testAdviceInvokedCorrectly() throws Exception { CountingBeforeAdvice getAgeCounter = (CountingBeforeAdvice) this.context.getBean("getAgeCounter"); CountingBeforeAdvice getNameCounter = (CountingBeforeAdvice) this.context.getBean("getNameCounter"); @@ -72,6 +78,7 @@ public class AopNamespaceHandlerTests extends TestCase { assertEquals("Incorrect getName count on getAge counter", 0, getAgeCounter.getCalls("getName")); } + @Test public void testAspectApplied() throws Exception { ITestBean testBean = getTestBean(); diff --git a/org.springframework.testsuite/src/test/java/org/springframework/aop/config/AopNamespaceHandlerThrowingTests.java b/org.springframework.testsuite/src/test/java/org/springframework/aop/config/AopNamespaceHandlerThrowingTests.java index 597e069ee90..2786c8ab710 100644 --- a/org.springframework.testsuite/src/test/java/org/springframework/aop/config/AopNamespaceHandlerThrowingTests.java +++ b/org.springframework.testsuite/src/test/java/org/springframework/aop/config/AopNamespaceHandlerThrowingTests.java @@ -16,8 +16,9 @@ package org.springframework.aop.config; -import junit.framework.TestCase; +import static org.junit.Assert.*; +import org.junit.Test; import org.springframework.beans.ITestBean; import org.springframework.beans.factory.BeanDefinitionStoreException; import org.springframework.context.ApplicationContext; @@ -27,7 +28,7 @@ import org.xml.sax.SAXParseException; /** * @author Adrian Colyer */ -public class AopNamespaceHandlerThrowingTests extends TestCase { +public class AopNamespaceHandlerThrowingTests { private ApplicationContext context; @@ -39,10 +40,12 @@ public class AopNamespaceHandlerThrowingTests extends TestCase { return "org/springframework/aop/config/aopNamespaceHandlerThrowingErrorTests.xml"; } + @Test public void testThrowingOnThrowingAdvice() { this.context = new ClassPathXmlApplicationContext(getOKConfigLocation()); } + @Test public void testParseThrowingOnOtherAdviceType() { try { this.context = new ClassPathXmlApplicationContext(getErrorConfigLocation()); diff --git a/org.springframework.testsuite/src/test/java/org/springframework/aop/config/MethodLocatingFactoryBeanTests.java b/org.springframework.testsuite/src/test/java/org/springframework/aop/config/MethodLocatingFactoryBeanTests.java index 55699b56fae..620a300931f 100644 --- a/org.springframework.testsuite/src/test/java/org/springframework/aop/config/MethodLocatingFactoryBeanTests.java +++ b/org.springframework.testsuite/src/test/java/org/springframework/aop/config/MethodLocatingFactoryBeanTests.java @@ -16,10 +16,12 @@ package org.springframework.aop.config; +import static org.junit.Assert.*; + import java.lang.reflect.Method; -import junit.framework.TestCase; import org.easymock.MockControl; +import org.junit.Test; import org.springframework.beans.factory.BeanFactory; import org.springframework.mock.easymock.AbstractScalarMockTemplate; @@ -28,21 +30,24 @@ import org.springframework.test.AssertThrows; /** * @author Rick Evans */ -public final class MethodLocatingFactoryBeanTests extends TestCase { +public final class MethodLocatingFactoryBeanTests { private static final String BEAN_NAME = "string"; + @Test public void testIsSingleton() throws Exception { MethodLocatingFactoryBean factory = new MethodLocatingFactoryBean(); assertTrue(factory.isSingleton()); } + @Test public void testGetObjectType() throws Exception { MethodLocatingFactoryBean factory = new MethodLocatingFactoryBean(); assertEquals(Method.class, factory.getObjectType()); } + @Test public void testWithNullTargetBeanName() throws Exception { new BeanFactoryScalarMockTemplate() { public void doTestInternal(final BeanFactory beanFactory) throws Exception { @@ -57,6 +62,7 @@ public final class MethodLocatingFactoryBeanTests extends TestCase { }.test(); } + @Test public void testWithEmptyTargetBeanName() throws Exception { new BeanFactoryScalarMockTemplate() { public void doTestInternal(final BeanFactory beanFactory) throws Exception { @@ -72,6 +78,7 @@ public final class MethodLocatingFactoryBeanTests extends TestCase { }.test(); } + @Test public void testWithNullTargetMethodName() throws Exception { new BeanFactoryScalarMockTemplate() { public void doTestInternal(final BeanFactory beanFactory) throws Exception { @@ -86,6 +93,7 @@ public final class MethodLocatingFactoryBeanTests extends TestCase { }.test(); } + @Test public void testWithEmptyTargetMethodName() throws Exception { new BeanFactoryScalarMockTemplate() { public void doTestInternal(final BeanFactory beanFactory) throws Exception { @@ -101,6 +109,7 @@ public final class MethodLocatingFactoryBeanTests extends TestCase { }.test(); } + @Test public void testWhenTargetBeanClassCannotBeResolved() throws Exception { new BeanFactoryScalarMockTemplate() { protected void setupBeanFactoryExpectations(MockControl mockControl, BeanFactory beanFactory) throws Exception { @@ -120,6 +129,7 @@ public final class MethodLocatingFactoryBeanTests extends TestCase { }.test(); } + @Test public void testSunnyDayPath() throws Exception { new BeanFactoryScalarMockTemplate() { protected void setupBeanFactoryExpectations(MockControl mockControl, BeanFactory beanFactory) throws Exception { @@ -140,6 +150,7 @@ public final class MethodLocatingFactoryBeanTests extends TestCase { }.test(); } + @Test public void testWhereMethodCannotBeResolved() throws Exception { new BeanFactoryScalarMockTemplate() { protected void setupBeanFactoryExpectations(MockControl mockControl, BeanFactory beanFactory) throws Exception { diff --git a/org.springframework.testsuite/src/test/java/org/springframework/aop/config/PrototypeProxyTests.java b/org.springframework.testsuite/src/test/java/org/springframework/aop/config/PrototypeProxyTests.java index 1c64d884c7c..e72d4249442 100644 --- a/org.springframework.testsuite/src/test/java/org/springframework/aop/config/PrototypeProxyTests.java +++ b/org.springframework.testsuite/src/test/java/org/springframework/aop/config/PrototypeProxyTests.java @@ -16,15 +16,15 @@ package org.springframework.aop.config; -import junit.framework.TestCase; - +import org.junit.Test; import org.springframework.context.support.ClassPathXmlApplicationContext; /** * @author Juergen Hoeller */ -public class PrototypeProxyTests extends TestCase { +public class PrototypeProxyTests { + @Test public void testInjectionBeforeWrappingCheckDoesNotKickInForPrototypeProxy() { new ClassPathXmlApplicationContext("prototypeProxy.xml", getClass()); }