From 2d37eb722b85da0809382f68905e473e8146afc6 Mon Sep 17 00:00:00 2001 From: Chris Beams Date: Fri, 19 Dec 2008 15:45:06 +0000 Subject: [PATCH] + moving .aop.aspectj.* unit tests from .testsuite -> .context + @SuppressWarnings and generic parameters to production .aop sources --- .../autoproxy/TargetSourceCreator.java | 2 +- ...ctBeanFactoryBasedTargetSourceCreator.java | 4 +- .../aop/support/StaticMethodMatcher.java | 2 +- .../StaticMethodMatcherPointcutAdvisor.java | 1 + ...ProxyCreatorTests-common-interceptors.xml} | 0 ... AdvisorAutoProxyCreatorTests-context.xml} | 0 ...ProxyCreatorTests-custom-targetsource.xml} | 0 ...dvisorAutoProxyCreatorTests-optimized.xml} | 0 ...oProxyCreatorTests-quick-targetsource.xml} | 0 .../AdvisorAutoProxyCreatorTests.java | 251 ++++++++++++++---- .../autoproxy/AutoProxyCreatorTests.java | 4 +- ...NameAutoProxyCreatorInitTests-context.xml} | 0 .../BeanNameAutoProxyCreatorInitTests.java | 4 +- ...BeanNameAutoProxyCreatorTests-context.xml} | 0 .../BeanNameAutoProxyCreatorTests.java | 30 ++- .../framework/autoproxy/CountingTestBean.java | 37 --- .../framework/autoproxy/CreatesTestBean.java | 49 ---- .../autoproxy/NeverMatchAdvisor.java | 53 ---- .../aop/framework/autoproxy/NoSetters.java | 33 --- .../aop/framework/autoproxy/NullChecker.java | 40 --- .../autoproxy/OrderedTxCheckAdvisor.java | 88 ------ .../aop/framework/autoproxy/Rollback.java | 57 ---- ...SelectivePrototypeTargetSourceCreator.java | 39 --- ...opedList.xml => ScopedProxyTests-list.xml} | 0 ...scopedMap.xml => ScopedProxyTests-map.xml} | 0 ...ride.xml => ScopedProxyTests-override.xml} | 0 ...Bean.xml => ScopedProxyTests-testbean.xml} | 0 .../aop/scope/ScopedProxyTests.java | 18 +- ... CommonsPoolTargetSourceTests-context.xml} | 0 .../target/CommonsPoolTargetSourceTests.java | 2 +- 30 files changed, 245 insertions(+), 469 deletions(-) rename org.springframework.testsuite/src/test/java/org/springframework/aop/framework/autoproxy/{advisorAutoProxyCreatorWithCommonInterceptors.xml => AdvisorAutoProxyCreatorTests-common-interceptors.xml} (100%) rename org.springframework.testsuite/src/test/java/org/springframework/aop/framework/autoproxy/{advisorAutoProxyCreator.xml => AdvisorAutoProxyCreatorTests-context.xml} (100%) rename org.springframework.testsuite/src/test/java/org/springframework/aop/framework/autoproxy/{customTargetSource.xml => AdvisorAutoProxyCreatorTests-custom-targetsource.xml} (100%) rename org.springframework.testsuite/src/test/java/org/springframework/aop/framework/autoproxy/{optimizedAutoProxyCreator.xml => AdvisorAutoProxyCreatorTests-optimized.xml} (100%) rename org.springframework.testsuite/src/test/java/org/springframework/aop/framework/autoproxy/{quickTargetSource.xml => AdvisorAutoProxyCreatorTests-quick-targetsource.xml} (100%) rename org.springframework.testsuite/src/test/java/org/springframework/aop/framework/autoproxy/{beanNameAutoProxyCreatorInitTests.xml => BeanNameAutoProxyCreatorInitTests-context.xml} (100%) rename org.springframework.testsuite/src/test/java/org/springframework/aop/framework/autoproxy/{beanNameAutoProxyCreatorTests.xml => BeanNameAutoProxyCreatorTests-context.xml} (100%) delete mode 100644 org.springframework.testsuite/src/test/java/org/springframework/aop/framework/autoproxy/CountingTestBean.java delete mode 100644 org.springframework.testsuite/src/test/java/org/springframework/aop/framework/autoproxy/CreatesTestBean.java delete mode 100644 org.springframework.testsuite/src/test/java/org/springframework/aop/framework/autoproxy/NeverMatchAdvisor.java delete mode 100644 org.springframework.testsuite/src/test/java/org/springframework/aop/framework/autoproxy/NoSetters.java delete mode 100644 org.springframework.testsuite/src/test/java/org/springframework/aop/framework/autoproxy/NullChecker.java delete mode 100644 org.springframework.testsuite/src/test/java/org/springframework/aop/framework/autoproxy/OrderedTxCheckAdvisor.java delete mode 100644 org.springframework.testsuite/src/test/java/org/springframework/aop/framework/autoproxy/Rollback.java delete mode 100644 org.springframework.testsuite/src/test/java/org/springframework/aop/framework/autoproxy/SelectivePrototypeTargetSourceCreator.java rename org.springframework.testsuite/src/test/java/org/springframework/aop/scope/{scopedList.xml => ScopedProxyTests-list.xml} (100%) rename org.springframework.testsuite/src/test/java/org/springframework/aop/scope/{scopedMap.xml => ScopedProxyTests-map.xml} (100%) rename org.springframework.testsuite/src/test/java/org/springframework/aop/scope/{scopedOverride.xml => ScopedProxyTests-override.xml} (100%) rename org.springframework.testsuite/src/test/java/org/springframework/aop/scope/{scopedTestBean.xml => ScopedProxyTests-testbean.xml} (100%) rename org.springframework.testsuite/src/test/java/org/springframework/aop/target/{commonsPoolTests.xml => CommonsPoolTargetSourceTests-context.xml} (100%) diff --git a/org.springframework.aop/src/main/java/org/springframework/aop/framework/autoproxy/TargetSourceCreator.java b/org.springframework.aop/src/main/java/org/springframework/aop/framework/autoproxy/TargetSourceCreator.java index 43182c68fc5..6219a5015c3 100644 --- a/org.springframework.aop/src/main/java/org/springframework/aop/framework/autoproxy/TargetSourceCreator.java +++ b/org.springframework.aop/src/main/java/org/springframework/aop/framework/autoproxy/TargetSourceCreator.java @@ -38,6 +38,6 @@ public interface TargetSourceCreator { * @return a special TargetSource or null if this TargetSourceCreator isn't * interested in the particular bean */ - TargetSource getTargetSource(Class beanClass, String beanName); + TargetSource getTargetSource(Class beanClass, String beanName); } diff --git a/org.springframework.aop/src/main/java/org/springframework/aop/framework/autoproxy/target/AbstractBeanFactoryBasedTargetSourceCreator.java b/org.springframework.aop/src/main/java/org/springframework/aop/framework/autoproxy/target/AbstractBeanFactoryBasedTargetSourceCreator.java index 022c6fa1441..a7bf4b490cc 100644 --- a/org.springframework.aop/src/main/java/org/springframework/aop/framework/autoproxy/target/AbstractBeanFactoryBasedTargetSourceCreator.java +++ b/org.springframework.aop/src/main/java/org/springframework/aop/framework/autoproxy/target/AbstractBeanFactoryBasedTargetSourceCreator.java @@ -86,7 +86,7 @@ public abstract class AbstractBeanFactoryBasedTargetSourceCreator // Implementation of the TargetSourceCreator interface //--------------------------------------------------------------------- - public final TargetSource getTargetSource(Class beanClass, String beanName) { + public final TargetSource getTargetSource(Class beanClass, String beanName) { AbstractBeanFactoryBasedTargetSource targetSource = createBeanFactoryBasedTargetSource(beanClass, beanName); if (targetSource == null) { @@ -194,6 +194,6 @@ public abstract class AbstractBeanFactoryBasedTargetSourceCreator * @return the AbstractPrototypeBasedTargetSource, or null if we don't match this */ protected abstract AbstractBeanFactoryBasedTargetSource createBeanFactoryBasedTargetSource( - Class beanClass, String beanName); + Class beanClass, String beanName); } diff --git a/org.springframework.aop/src/main/java/org/springframework/aop/support/StaticMethodMatcher.java b/org.springframework.aop/src/main/java/org/springframework/aop/support/StaticMethodMatcher.java index 108f999dbb5..8023ff88373 100644 --- a/org.springframework.aop/src/main/java/org/springframework/aop/support/StaticMethodMatcher.java +++ b/org.springframework.aop/src/main/java/org/springframework/aop/support/StaticMethodMatcher.java @@ -30,7 +30,7 @@ public abstract class StaticMethodMatcher implements MethodMatcher { return false; } - public final boolean matches(Method method, Class targetClass, Object[] args) { + public final boolean matches(Method method, Class targetClass, Object[] args) { // should never be invoked because isRuntime() returns false throw new UnsupportedOperationException("Illegal MethodMatcher usage"); } diff --git a/org.springframework.aop/src/main/java/org/springframework/aop/support/StaticMethodMatcherPointcutAdvisor.java b/org.springframework.aop/src/main/java/org/springframework/aop/support/StaticMethodMatcherPointcutAdvisor.java index 7844dce8b3b..921129c89b0 100644 --- a/org.springframework.aop/src/main/java/org/springframework/aop/support/StaticMethodMatcherPointcutAdvisor.java +++ b/org.springframework.aop/src/main/java/org/springframework/aop/support/StaticMethodMatcherPointcutAdvisor.java @@ -32,6 +32,7 @@ import org.springframework.util.Assert; * @author Rod Johnson * @author Juergen Hoeller */ +@SuppressWarnings("serial") public abstract class StaticMethodMatcherPointcutAdvisor extends StaticMethodMatcherPointcut implements PointcutAdvisor, Ordered, Serializable { diff --git a/org.springframework.testsuite/src/test/java/org/springframework/aop/framework/autoproxy/advisorAutoProxyCreatorWithCommonInterceptors.xml b/org.springframework.testsuite/src/test/java/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorTests-common-interceptors.xml similarity index 100% rename from org.springframework.testsuite/src/test/java/org/springframework/aop/framework/autoproxy/advisorAutoProxyCreatorWithCommonInterceptors.xml rename to org.springframework.testsuite/src/test/java/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorTests-common-interceptors.xml diff --git a/org.springframework.testsuite/src/test/java/org/springframework/aop/framework/autoproxy/advisorAutoProxyCreator.xml b/org.springframework.testsuite/src/test/java/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorTests-context.xml similarity index 100% rename from org.springframework.testsuite/src/test/java/org/springframework/aop/framework/autoproxy/advisorAutoProxyCreator.xml rename to org.springframework.testsuite/src/test/java/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorTests-context.xml diff --git a/org.springframework.testsuite/src/test/java/org/springframework/aop/framework/autoproxy/customTargetSource.xml b/org.springframework.testsuite/src/test/java/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorTests-custom-targetsource.xml similarity index 100% rename from org.springframework.testsuite/src/test/java/org/springframework/aop/framework/autoproxy/customTargetSource.xml rename to org.springframework.testsuite/src/test/java/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorTests-custom-targetsource.xml diff --git a/org.springframework.testsuite/src/test/java/org/springframework/aop/framework/autoproxy/optimizedAutoProxyCreator.xml b/org.springframework.testsuite/src/test/java/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorTests-optimized.xml similarity index 100% rename from org.springframework.testsuite/src/test/java/org/springframework/aop/framework/autoproxy/optimizedAutoProxyCreator.xml rename to org.springframework.testsuite/src/test/java/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorTests-optimized.xml diff --git a/org.springframework.testsuite/src/test/java/org/springframework/aop/framework/autoproxy/quickTargetSource.xml b/org.springframework.testsuite/src/test/java/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorTests-quick-targetsource.xml similarity index 100% rename from org.springframework.testsuite/src/test/java/org/springframework/aop/framework/autoproxy/quickTargetSource.xml rename to org.springframework.testsuite/src/test/java/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorTests-quick-targetsource.xml diff --git a/org.springframework.testsuite/src/test/java/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorTests.java b/org.springframework.testsuite/src/test/java/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorTests.java index baaae86e950..d94ce297e29 100644 --- a/org.springframework.testsuite/src/test/java/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorTests.java +++ b/org.springframework.testsuite/src/test/java/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorTests.java @@ -16,25 +16,33 @@ package org.springframework.aop.framework.autoproxy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.*; import java.io.IOException; +import java.lang.reflect.Method; +import java.util.List; import javax.servlet.ServletException; import org.junit.Test; +import org.springframework.aop.MethodBeforeAdvice; import org.springframework.aop.framework.Advised; +import org.springframework.aop.framework.autoproxy.target.AbstractBeanFactoryBasedTargetSourceCreator; import org.springframework.aop.support.AopUtils; +import org.springframework.aop.support.StaticMethodMatcherPointcutAdvisor; +import org.springframework.aop.target.AbstractBeanFactoryBasedTargetSource; import org.springframework.aop.target.CommonsPoolTargetSource; import org.springframework.aop.target.LazyInitTargetSource; import org.springframework.aop.target.PrototypeTargetSource; import org.springframework.aop.target.ThreadLocalTargetSource; import org.springframework.beans.ITestBean; +import org.springframework.beans.TestBean; import org.springframework.beans.factory.BeanFactory; +import org.springframework.beans.factory.InitializingBean; import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.transaction.CallCountingTransactionManager; +import org.springframework.transaction.NoTransactionException; +import org.springframework.transaction.interceptor.TransactionInterceptor; import test.advice.CountingBeforeAdvice; import test.advice.MethodCounter; @@ -45,19 +53,28 @@ import test.mixin.Lockable; * Tests for auto proxy creation by advisor recognition. * * @author Rod Johnson + * @author Dave Syer * @author Chris Beams */ -public class AdvisorAutoProxyCreatorTests { +public final class AdvisorAutoProxyCreatorTests { + + private static final Class CLASS = AdvisorAutoProxyCreatorTests.class; + private static final String CLASSNAME = CLASS.getSimpleName(); + + private static final String DEFAULT_CONTEXT = CLASSNAME + "-context.xml"; + private static final String COMMON_INTERCEPTORS_CONTEXT = CLASSNAME + "-common-interceptors.xml"; + private static final String CUSTOM_TARGETSOURCE_CONTEXT = CLASSNAME + "-custom-targetsource.xml"; + private static final String QUICK_TARGETSOURCE_CONTEXT = CLASSNAME + "-quick-targetsource.xml"; + private static final String OPTIMIZED_CONTEXT = CLASSNAME + "-optimized.xml"; private static final String ADVISOR_APC_BEAN_NAME = "aapc"; - private static final String TXMANAGER_BEAN_NAME = "txManager"; /** * Return a bean factory with attributes and EnterpriseServices configured. */ protected BeanFactory getBeanFactory() throws IOException { - return new ClassPathXmlApplicationContext("/org/springframework/aop/framework/autoproxy/advisorAutoProxyCreator.xml"); + return new ClassPathXmlApplicationContext(DEFAULT_CONTEXT, CLASS); } @Test @@ -101,7 +118,7 @@ public class AdvisorAutoProxyCreatorTests { */ @Test public void testCommonInterceptorAndAdvisor() throws Exception { - BeanFactory bf = new ClassPathXmlApplicationContext("/org/springframework/aop/framework/autoproxy/advisorAutoProxyCreatorWithCommonInterceptors.xml"); + BeanFactory bf = new ClassPathXmlApplicationContext(COMMON_INTERCEPTORS_CONTEXT, CLASS); ITestBean test1 = (ITestBean) bf.getBean("test1"); assertTrue(AopUtils.isAopProxy(test1)); @@ -131,7 +148,7 @@ public class AdvisorAutoProxyCreatorTests { */ @Test public void testCustomTargetSourceNoMatch() throws Exception { - BeanFactory bf = new ClassPathXmlApplicationContext("/org/springframework/aop/framework/autoproxy/customTargetSource.xml"); + BeanFactory bf = new ClassPathXmlApplicationContext(CUSTOM_TARGETSOURCE_CONTEXT, CLASS); ITestBean test = (ITestBean) bf.getBean("test"); assertFalse(AopUtils.isAopProxy(test)); assertEquals("Rod", test.getName()); @@ -141,7 +158,7 @@ public class AdvisorAutoProxyCreatorTests { @Test public void testCustomPrototypeTargetSource() throws Exception { CountingTestBean.count = 0; - BeanFactory bf = new ClassPathXmlApplicationContext("/org/springframework/aop/framework/autoproxy/customTargetSource.xml"); + BeanFactory bf = new ClassPathXmlApplicationContext(CUSTOM_TARGETSOURCE_CONTEXT, CLASS); ITestBean test = (ITestBean) bf.getBean("prototypeTest"); assertTrue(AopUtils.isAopProxy(test)); Advised advised = (Advised) test; @@ -156,7 +173,7 @@ public class AdvisorAutoProxyCreatorTests { @Test public void testLazyInitTargetSource() throws Exception { CountingTestBean.count = 0; - BeanFactory bf = new ClassPathXmlApplicationContext("/org/springframework/aop/framework/autoproxy/customTargetSource.xml"); + BeanFactory bf = new ClassPathXmlApplicationContext(CUSTOM_TARGETSOURCE_CONTEXT, CLASS); ITestBean test = (ITestBean) bf.getBean("lazyInitTest"); assertTrue(AopUtils.isAopProxy(test)); Advised advised = (Advised) test; @@ -171,7 +188,7 @@ public class AdvisorAutoProxyCreatorTests { @Test public void testQuickTargetSourceCreator() throws Exception { ClassPathXmlApplicationContext bf = - new ClassPathXmlApplicationContext("/org/springframework/aop/framework/autoproxy/quickTargetSource.xml"); + new ClassPathXmlApplicationContext(QUICK_TARGETSOURCE_CONTEXT, CLASS); ITestBean test = (ITestBean) bf.getBean("test"); assertFalse(AopUtils.isAopProxy(test)); assertEquals("Rod", test.getName()); @@ -213,17 +230,6 @@ public class AdvisorAutoProxyCreatorTests { bf.close(); } - /* - @Test - public void testIntroductionIsProxied() throws Exception { - BeanFactory bf = getBeanFactory(); - Object modifiable = bf.getBean("modifiable1"); - // We can tell it's a CGLIB proxy by looking at the class name - System.out.println(modifiable.getClass().getName()); - assertFalse(modifiable.getClass().getName().equals(ModifiableTestBean.class.getName())); - } - */ - @Test public void testTransactionAttributeOnMethod() throws Exception { BeanFactory bf = getBeanFactory(); @@ -310,7 +316,7 @@ public class AdvisorAutoProxyCreatorTests { @Test public void testWithOptimizedProxy() throws Exception { - BeanFactory beanFactory = new ClassPathXmlApplicationContext("org/springframework/aop/framework/autoproxy/optimizedAutoProxyCreator.xml"); + BeanFactory beanFactory = new ClassPathXmlApplicationContext(OPTIMIZED_CONTEXT, CLASS); ITestBean testBean = (ITestBean) beanFactory.getBean("optimizedTestBean"); assertTrue(AopUtils.isAopProxy(testBean)); @@ -323,42 +329,171 @@ public class AdvisorAutoProxyCreatorTests { assertEquals("Incorrect number of calls to proxy", 2, beforeAdvice.getCalls()); } - - /** - * Tests an introduction pointcut. This is a prototype, so that it can add - * a Modifiable mixin. Tests that the autoproxy infrastructure can create - * advised objects with independent interceptor instances. - * The Modifiable behaviour of each instance of TestBean should be distinct. - */ - /* - @Test - public void testIntroductionViaPrototype() throws Exception { - BeanFactory bf = getBeanFactory(); +} - Object o = bf.getBean("modifiable1"); - ITestBean modifiable1 = (ITestBean) bf.getBean("modifiable1"); - ITestBean modifiable2 = (ITestBean) bf.getBean("modifiable2"); - - Advised pc = (Advised) modifiable1; - System.err.println(pc.toProxyConfigString()); - - // For convenience only - Modifiable mod1 = (Modifiable) modifiable1; - Modifiable mod2 = (Modifiable) modifiable2; - - assertFalse(mod1.isModified()); - assertFalse(mod2.isModified()); - - int newAge = 33; - modifiable1.setAge(newAge); - assertTrue(mod1.isModified()); - // Changes to one shouldn't have affected the other - assertFalse("Instances of prototype introduction pointcut don't seem distinct", mod2.isModified()); - mod1.acceptChanges(); - assertFalse(mod1.isModified()); - assertEquals(modifiable1.getAge(), newAge); - assertFalse(mod1.isModified()); + +class CountingTestBean extends TestBean { + + public static int count = 0; + + public CountingTestBean() { + count++; + } + +} + + +@SuppressWarnings("serial") +class NeverMatchAdvisor extends StaticMethodMatcherPointcutAdvisor { + + public NeverMatchAdvisor() { + super(new NopInterceptor()); + } + + /** + * This method is solely to allow us to create a mixture of dependencies in + * the bean definitions. The dependencies don't have any meaning, and don't + * do anything. + */ + public void setDependencies(List l) { + + } + + /** + * @see org.springframework.aop.MethodMatcher#matches(java.lang.reflect.Method, java.lang.Class) + */ + public boolean matches(Method m, Class targetClass) { + return false; + } + +} + + +class NoSetters { + + public void A() { + + } + + public int getB() { + return -1; + } + +} + + +@SuppressWarnings("serial") +class OrderedTxCheckAdvisor extends StaticMethodMatcherPointcutAdvisor implements InitializingBean { + + /** + * Should we insist on the presence of a transaction attribute or refuse to accept one? + */ + private boolean requireTransactionContext = false; + + + public void setRequireTransactionContext(boolean requireTransactionContext) { + this.requireTransactionContext = requireTransactionContext; + } + + public boolean isRequireTransactionContext() { + return requireTransactionContext; + } + + + public CountingBeforeAdvice getCountingBeforeAdvice() { + return (CountingBeforeAdvice) getAdvice(); + } + + public void afterPropertiesSet() throws Exception { + setAdvice(new TxCountingBeforeAdvice()); + } + + public boolean matches(Method method, Class targetClass) { + return method.getName().startsWith("setAge"); + } + + + private class TxCountingBeforeAdvice extends CountingBeforeAdvice { + + public void before(Method method, Object[] args, Object target) throws Throwable { + // do transaction checks + if (requireTransactionContext) { + TransactionInterceptor.currentTransactionStatus(); + } + else { + try { + TransactionInterceptor.currentTransactionStatus(); + throw new RuntimeException("Shouldn't have a transaction"); + } + catch (NoTransactionException ex) { + // this is Ok + } + } + super.before(method, args, target); + } + } + +} + + +class Rollback { + + /** + * Inherits transaction attribute. + * Illustrates programmatic rollback. + * @param rollbackOnly + */ + public void rollbackOnly(boolean rollbackOnly) { + if (rollbackOnly) { + setRollbackOnly(); + } + } + + /** + * Extracted in a protected method to facilitate testing + */ + protected void setRollbackOnly() { + TransactionInterceptor.currentTransactionStatus().setRollbackOnly(); + } + + /** + * @org.springframework.transaction.interceptor.RuleBasedTransaction ( timeout=-1 ) + * @org.springframework.transaction.interceptor.RollbackRule ( "java.lang.Exception" ) + * @org.springframework.transaction.interceptor.NoRollbackRule ( "ServletException" ) + */ + public void echoException(Exception ex) throws Exception { + if (ex != null) + throw ex; + } + +} + + +class SelectivePrototypeTargetSourceCreator extends AbstractBeanFactoryBasedTargetSourceCreator { + + protected AbstractBeanFactoryBasedTargetSource createBeanFactoryBasedTargetSource( + Class beanClass, String beanName) { + if (!beanName.startsWith("prototype")) { + return null; + } + return new PrototypeTargetSource(); + } + +} + + +class NullChecker implements MethodBeforeAdvice { + + public void before(Method method, Object[] args, Object target) throws Throwable { + check(args); + } + + private void check(Object[] args) { + for (int i = 0; i < args.length; i++) { + if (args[i] == null) { + throw new IllegalArgumentException("Null argument at position " + i); + } + } } - */ } diff --git a/org.springframework.testsuite/src/test/java/org/springframework/aop/framework/autoproxy/AutoProxyCreatorTests.java b/org.springframework.testsuite/src/test/java/org/springframework/aop/framework/autoproxy/AutoProxyCreatorTests.java index e90eadde0b8..dfba7b7dea5 100644 --- a/org.springframework.testsuite/src/test/java/org/springframework/aop/framework/autoproxy/AutoProxyCreatorTests.java +++ b/org.springframework.testsuite/src/test/java/org/springframework/aop/framework/autoproxy/AutoProxyCreatorTests.java @@ -39,11 +39,11 @@ import org.springframework.context.support.StaticApplicationContext; import org.springframework.context.support.StaticMessageSource; /** + * @since 09.12.2003 * @author Juergen Hoeller * @author Chris Beams - * @since 09.12.2003 */ -public class AutoProxyCreatorTests { +public final class AutoProxyCreatorTests { @Test public void testBeanNameAutoProxyCreator() { diff --git a/org.springframework.testsuite/src/test/java/org/springframework/aop/framework/autoproxy/beanNameAutoProxyCreatorInitTests.xml b/org.springframework.testsuite/src/test/java/org/springframework/aop/framework/autoproxy/BeanNameAutoProxyCreatorInitTests-context.xml similarity index 100% rename from org.springframework.testsuite/src/test/java/org/springframework/aop/framework/autoproxy/beanNameAutoProxyCreatorInitTests.xml rename to org.springframework.testsuite/src/test/java/org/springframework/aop/framework/autoproxy/BeanNameAutoProxyCreatorInitTests-context.xml diff --git a/org.springframework.testsuite/src/test/java/org/springframework/aop/framework/autoproxy/BeanNameAutoProxyCreatorInitTests.java b/org.springframework.testsuite/src/test/java/org/springframework/aop/framework/autoproxy/BeanNameAutoProxyCreatorInitTests.java index 4e13cc2022b..bc20df80281 100644 --- a/org.springframework.testsuite/src/test/java/org/springframework/aop/framework/autoproxy/BeanNameAutoProxyCreatorInitTests.java +++ b/org.springframework.testsuite/src/test/java/org/springframework/aop/framework/autoproxy/BeanNameAutoProxyCreatorInitTests.java @@ -27,12 +27,12 @@ import org.springframework.context.support.ClassPathXmlApplicationContext; * @author Dave Syer * @author Chris Beams */ -public class BeanNameAutoProxyCreatorInitTests { +public final class BeanNameAutoProxyCreatorInitTests { @Test(expected=IllegalArgumentException.class) public void testIgnoreAdvisorThatIsCurrentlyCreation() { ClassPathXmlApplicationContext ctx = - new ClassPathXmlApplicationContext("beanNameAutoProxyCreatorInitTests.xml", getClass()); + new ClassPathXmlApplicationContext(getClass().getSimpleName() + "-context.xml", getClass()); TestBean bean = (TestBean) ctx.getBean("bean"); bean.setName("foo"); assertEquals("foo", bean.getName()); diff --git a/org.springframework.testsuite/src/test/java/org/springframework/aop/framework/autoproxy/beanNameAutoProxyCreatorTests.xml b/org.springframework.testsuite/src/test/java/org/springframework/aop/framework/autoproxy/BeanNameAutoProxyCreatorTests-context.xml similarity index 100% rename from org.springframework.testsuite/src/test/java/org/springframework/aop/framework/autoproxy/beanNameAutoProxyCreatorTests.xml rename to org.springframework.testsuite/src/test/java/org/springframework/aop/framework/autoproxy/BeanNameAutoProxyCreatorTests-context.xml diff --git a/org.springframework.testsuite/src/test/java/org/springframework/aop/framework/autoproxy/BeanNameAutoProxyCreatorTests.java b/org.springframework.testsuite/src/test/java/org/springframework/aop/framework/autoproxy/BeanNameAutoProxyCreatorTests.java index 94b3c7d8417..93a4b20b322 100644 --- a/org.springframework.testsuite/src/test/java/org/springframework/aop/framework/autoproxy/BeanNameAutoProxyCreatorTests.java +++ b/org.springframework.testsuite/src/test/java/org/springframework/aop/framework/autoproxy/BeanNameAutoProxyCreatorTests.java @@ -27,6 +27,7 @@ import org.springframework.aop.support.AopUtils; import org.springframework.beans.ITestBean; import org.springframework.beans.TestBean; import org.springframework.beans.factory.BeanFactory; +import org.springframework.beans.factory.FactoryBean; import org.springframework.context.support.ClassPathXmlApplicationContext; import test.advice.CountingBeforeAdvice; @@ -48,7 +49,8 @@ public class BeanNameAutoProxyCreatorTests { public void setUp() throws IOException { // Note that we need an ApplicationContext, not just a BeanFactory, // for post-processing and hence auto-proxying to work. - this.beanFactory = new ClassPathXmlApplicationContext("beanNameAutoProxyCreatorTests.xml", getClass()); + beanFactory = + new ClassPathXmlApplicationContext(getClass().getSimpleName() + "-context.xml", getClass()); } @Test @@ -196,3 +198,29 @@ public class BeanNameAutoProxyCreatorTests { } } + + +class CreatesTestBean implements FactoryBean { + + /** + * @see org.springframework.beans.factory.FactoryBean#getObject() + */ + public Object getObject() throws Exception { + return new TestBean(); + } + + /** + * @see org.springframework.beans.factory.FactoryBean#getObjectType() + */ + public Class getObjectType() { + return TestBean.class; + } + + /** + * @see org.springframework.beans.factory.FactoryBean#isSingleton() + */ + public boolean isSingleton() { + return true; + } + +} \ No newline at end of file diff --git a/org.springframework.testsuite/src/test/java/org/springframework/aop/framework/autoproxy/CountingTestBean.java b/org.springframework.testsuite/src/test/java/org/springframework/aop/framework/autoproxy/CountingTestBean.java deleted file mode 100644 index bd377aed847..00000000000 --- a/org.springframework.testsuite/src/test/java/org/springframework/aop/framework/autoproxy/CountingTestBean.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * $Id: CountingTestBean.java,v 1.2 2005/03/25 09:28:17 jhoeller Exp $ - */ - -/* - * Copyright 2002-2005 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.aop.framework.autoproxy; - -import org.springframework.beans.TestBean; - -/** - * @author Juergen Hoeller - * @since 15.03.2005 - */ -public class CountingTestBean extends TestBean { - - public static int count = 0; - - public CountingTestBean() { - count++; - } - -} diff --git a/org.springframework.testsuite/src/test/java/org/springframework/aop/framework/autoproxy/CreatesTestBean.java b/org.springframework.testsuite/src/test/java/org/springframework/aop/framework/autoproxy/CreatesTestBean.java deleted file mode 100644 index f95da4b0620..00000000000 --- a/org.springframework.testsuite/src/test/java/org/springframework/aop/framework/autoproxy/CreatesTestBean.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright 2002-2005 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.aop.framework.autoproxy; - -import org.springframework.beans.TestBean; -import org.springframework.beans.factory.FactoryBean; - -/** - * - * @author Rod Johnson - */ -public class CreatesTestBean implements FactoryBean { - - /** - * @see org.springframework.beans.factory.FactoryBean#getObject() - */ - public Object getObject() throws Exception { - return new TestBean(); - } - - /** - * @see org.springframework.beans.factory.FactoryBean#getObjectType() - */ - public Class getObjectType() { - return TestBean.class; - } - - /** - * @see org.springframework.beans.factory.FactoryBean#isSingleton() - */ - public boolean isSingleton() { - return true; - } - -} diff --git a/org.springframework.testsuite/src/test/java/org/springframework/aop/framework/autoproxy/NeverMatchAdvisor.java b/org.springframework.testsuite/src/test/java/org/springframework/aop/framework/autoproxy/NeverMatchAdvisor.java deleted file mode 100644 index 1ffd4760415..00000000000 --- a/org.springframework.testsuite/src/test/java/org/springframework/aop/framework/autoproxy/NeverMatchAdvisor.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright 2002-2005 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.aop.framework.autoproxy; - -import java.lang.reflect.Method; -import java.util.List; - -import org.springframework.aop.support.StaticMethodMatcherPointcutAdvisor; - -import test.interceptor.NopInterceptor; - -/** - * - * @author Rod Johnson - */ -public class NeverMatchAdvisor extends StaticMethodMatcherPointcutAdvisor { - - public NeverMatchAdvisor() { - super(new NopInterceptor()); - } - - /** - * This method is solely to allow us to create a mixture of dependencies in - * the bean definitions. The dependencies don't have any meaning, and don't - * do anything. - */ - public void setDependencies(List l) { - - } - - /** - * @see org.springframework.aop.MethodMatcher#matches(java.lang.reflect.Method, java.lang.Class) - */ - public boolean matches(Method m, Class targetClass) { - //System.err.println("NeverMAtch test"); - return false; - } - -} diff --git a/org.springframework.testsuite/src/test/java/org/springframework/aop/framework/autoproxy/NoSetters.java b/org.springframework.testsuite/src/test/java/org/springframework/aop/framework/autoproxy/NoSetters.java deleted file mode 100644 index 5ecd63cc928..00000000000 --- a/org.springframework.testsuite/src/test/java/org/springframework/aop/framework/autoproxy/NoSetters.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 2002-2005 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.aop.framework.autoproxy; - -/** - * - * @author Rod Johnson - */ -public class NoSetters { - - public void A() { - - } - - public int getB() { - return -1; - } - -} diff --git a/org.springframework.testsuite/src/test/java/org/springframework/aop/framework/autoproxy/NullChecker.java b/org.springframework.testsuite/src/test/java/org/springframework/aop/framework/autoproxy/NullChecker.java deleted file mode 100644 index 343bf82b224..00000000000 --- a/org.springframework.testsuite/src/test/java/org/springframework/aop/framework/autoproxy/NullChecker.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2002-2006 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.aop.framework.autoproxy; - -import java.lang.reflect.Method; - -import org.springframework.aop.MethodBeforeAdvice; - -/** - * @author Dave Syer - */ -public class NullChecker implements MethodBeforeAdvice { - - public void before(Method method, Object[] args, Object target) throws Throwable { - check(args); - } - - private void check(Object[] args) { - for (int i = 0; i < args.length; i++) { - if (args[i] == null) { - throw new IllegalArgumentException("Null argument at position " + i); - } - } - } - -} diff --git a/org.springframework.testsuite/src/test/java/org/springframework/aop/framework/autoproxy/OrderedTxCheckAdvisor.java b/org.springframework.testsuite/src/test/java/org/springframework/aop/framework/autoproxy/OrderedTxCheckAdvisor.java deleted file mode 100644 index 41984f8b144..00000000000 --- a/org.springframework.testsuite/src/test/java/org/springframework/aop/framework/autoproxy/OrderedTxCheckAdvisor.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright 2002-2006 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.aop.framework.autoproxy; - -import java.lang.reflect.Method; - -import org.springframework.aop.support.StaticMethodMatcherPointcutAdvisor; -import org.springframework.beans.factory.InitializingBean; -import org.springframework.transaction.NoTransactionException; -import org.springframework.transaction.interceptor.TransactionInterceptor; - -import test.advice.CountingBeforeAdvice; - -/** - * Before advisor that allow us to manipulate ordering to check - * that superclass sorting works correctly. - * - *

It doesn't actually do anything except count - * method invocations and check for presence of transaction context. - *
Matches setters. - * - * @author Rod Johnson - */ -public class OrderedTxCheckAdvisor extends StaticMethodMatcherPointcutAdvisor implements InitializingBean { - - /** - * Should we insist on the presence of a transaction attribute or refuse to accept one? - */ - private boolean requireTransactionContext = false; - - - public void setRequireTransactionContext(boolean requireTransactionContext) { - this.requireTransactionContext = requireTransactionContext; - } - - public boolean isRequireTransactionContext() { - return requireTransactionContext; - } - - - public CountingBeforeAdvice getCountingBeforeAdvice() { - return (CountingBeforeAdvice) getAdvice(); - } - - public void afterPropertiesSet() throws Exception { - setAdvice(new TxCountingBeforeAdvice()); - } - - public boolean matches(Method method, Class targetClass) { - return method.getName().startsWith("setAge"); - } - - - private class TxCountingBeforeAdvice extends CountingBeforeAdvice { - - public void before(Method method, Object[] args, Object target) throws Throwable { - // do transaction checks - if (requireTransactionContext) { - TransactionInterceptor.currentTransactionStatus(); - } - else { - try { - TransactionInterceptor.currentTransactionStatus(); - throw new RuntimeException("Shouldn't have a transaction"); - } - catch (NoTransactionException ex) { - // this is Ok - } - } - super.before(method, args, target); - } - } - -} diff --git a/org.springframework.testsuite/src/test/java/org/springframework/aop/framework/autoproxy/Rollback.java b/org.springframework.testsuite/src/test/java/org/springframework/aop/framework/autoproxy/Rollback.java deleted file mode 100644 index 3b9caa59d80..00000000000 --- a/org.springframework.testsuite/src/test/java/org/springframework/aop/framework/autoproxy/Rollback.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright 2002-2005 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.aop.framework.autoproxy; - -import org.springframework.transaction.interceptor.TransactionInterceptor; - - - -/** - * @org.springframework.enterpriseservices.Pooling (size=10) - * @org.springframework.transaction.interceptor.DefaultTransaction ( timeout=-1 ) - */ -public class Rollback { - - /** - * Inherits transaction attribute. - * Illustrates programmatic rollback. - * @param rollbackOnly - */ - public void rollbackOnly(boolean rollbackOnly) { - if (rollbackOnly) { - setRollbackOnly(); - } - } - - /** - * Extracted in a protected method to facilitate testing - */ - protected void setRollbackOnly() { - TransactionInterceptor.currentTransactionStatus().setRollbackOnly(); - } - - /** - * @org.springframework.transaction.interceptor.RuleBasedTransaction ( timeout=-1 ) - * @org.springframework.transaction.interceptor.RollbackRule ( "java.lang.Exception" ) - * @org.springframework.transaction.interceptor.NoRollbackRule ( "ServletException" ) - */ - public void echoException(Exception ex) throws Exception { - if (ex != null) - throw ex; - } - -} diff --git a/org.springframework.testsuite/src/test/java/org/springframework/aop/framework/autoproxy/SelectivePrototypeTargetSourceCreator.java b/org.springframework.testsuite/src/test/java/org/springframework/aop/framework/autoproxy/SelectivePrototypeTargetSourceCreator.java deleted file mode 100644 index cf8b2ddc63e..00000000000 --- a/org.springframework.testsuite/src/test/java/org/springframework/aop/framework/autoproxy/SelectivePrototypeTargetSourceCreator.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2002-2005 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.aop.framework.autoproxy; - -import org.springframework.aop.framework.autoproxy.target.AbstractBeanFactoryBasedTargetSourceCreator; -import org.springframework.aop.target.AbstractBeanFactoryBasedTargetSource; -import org.springframework.aop.target.PrototypeTargetSource; - -/** - * Overrides generic PrototypeTargetSourceCreator to create a prototype only for beans - * with names beginning with "prototype". - * - * @author Rod Johnson - */ -public class SelectivePrototypeTargetSourceCreator extends AbstractBeanFactoryBasedTargetSourceCreator { - - protected AbstractBeanFactoryBasedTargetSource createBeanFactoryBasedTargetSource( - Class beanClass, String beanName) { - if (!beanName.startsWith("prototype")) { - return null; - } - return new PrototypeTargetSource(); - } - -} diff --git a/org.springframework.testsuite/src/test/java/org/springframework/aop/scope/scopedList.xml b/org.springframework.testsuite/src/test/java/org/springframework/aop/scope/ScopedProxyTests-list.xml similarity index 100% rename from org.springframework.testsuite/src/test/java/org/springframework/aop/scope/scopedList.xml rename to org.springframework.testsuite/src/test/java/org/springframework/aop/scope/ScopedProxyTests-list.xml diff --git a/org.springframework.testsuite/src/test/java/org/springframework/aop/scope/scopedMap.xml b/org.springframework.testsuite/src/test/java/org/springframework/aop/scope/ScopedProxyTests-map.xml similarity index 100% rename from org.springframework.testsuite/src/test/java/org/springframework/aop/scope/scopedMap.xml rename to org.springframework.testsuite/src/test/java/org/springframework/aop/scope/ScopedProxyTests-map.xml diff --git a/org.springframework.testsuite/src/test/java/org/springframework/aop/scope/scopedOverride.xml b/org.springframework.testsuite/src/test/java/org/springframework/aop/scope/ScopedProxyTests-override.xml similarity index 100% rename from org.springframework.testsuite/src/test/java/org/springframework/aop/scope/scopedOverride.xml rename to org.springframework.testsuite/src/test/java/org/springframework/aop/scope/ScopedProxyTests-override.xml diff --git a/org.springframework.testsuite/src/test/java/org/springframework/aop/scope/scopedTestBean.xml b/org.springframework.testsuite/src/test/java/org/springframework/aop/scope/ScopedProxyTests-testbean.xml similarity index 100% rename from org.springframework.testsuite/src/test/java/org/springframework/aop/scope/scopedTestBean.xml rename to org.springframework.testsuite/src/test/java/org/springframework/aop/scope/ScopedProxyTests-testbean.xml 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 d9c3cbfef40..291dc7f81ab 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 @@ -38,18 +38,26 @@ import org.springframework.core.io.ClassPathResource; * @author Chris Beams */ public class ScopedProxyTests { + + private static final Class CLASS = ScopedProxyTests.class; + private static final String CLASSNAME = CLASS.getSimpleName(); + + private static final ClassPathResource LIST_CONTEXT = new ClassPathResource(CLASSNAME + "-list.xml", CLASS); + private static final ClassPathResource MAP_CONTEXT = new ClassPathResource(CLASSNAME + "-map.xml", CLASS); + private static final ClassPathResource OVERRIDE_CONTEXT = new ClassPathResource(CLASSNAME + "-override.xml", CLASS); + private static final ClassPathResource TESTBEAN_CONTEXT = new ClassPathResource(CLASSNAME + "-testbean.xml", CLASS); /* SPR-2108 */ @Test public void testProxyAssignable() throws Exception { - XmlBeanFactory bf = new XmlBeanFactory(new ClassPathResource("scopedMap.xml", getClass())); + XmlBeanFactory bf = new XmlBeanFactory(MAP_CONTEXT); Object baseMap = bf.getBean("singletonMap"); assertTrue(baseMap instanceof Map); } @Test public void testSimpleProxy() throws Exception { - XmlBeanFactory bf = new XmlBeanFactory(new ClassPathResource("scopedMap.xml", getClass())); + XmlBeanFactory bf = new XmlBeanFactory(MAP_CONTEXT); Object simpleMap = bf.getBean("simpleMap"); assertTrue(simpleMap instanceof Map); assertTrue(simpleMap instanceof HashMap); @@ -58,7 +66,7 @@ public class ScopedProxyTests { @Test public void testScopedOverride() throws Exception { GenericApplicationContext ctx = new GenericApplicationContext(); - new XmlBeanDefinitionReader(ctx).loadBeanDefinitions(new ClassPathResource("scopedOverride.xml", getClass())); + new XmlBeanDefinitionReader(ctx).loadBeanDefinitions(OVERRIDE_CONTEXT); SimpleMapScope scope = new SimpleMapScope(); ctx.getBeanFactory().registerScope("request", scope); ctx.refresh(); @@ -73,7 +81,7 @@ public class ScopedProxyTests { @Test public void testJdkScopedProxy() throws Exception { - XmlBeanFactory bf = new XmlBeanFactory(new ClassPathResource("scopedTestBean.xml", getClass())); + XmlBeanFactory bf = new XmlBeanFactory(TESTBEAN_CONTEXT); SimpleMapScope scope = new SimpleMapScope(); bf.registerScope("request", scope); @@ -90,7 +98,7 @@ public class ScopedProxyTests { @Test public void testCglibScopedProxy() { - XmlBeanFactory bf = new XmlBeanFactory(new ClassPathResource("scopedList.xml", getClass())); + XmlBeanFactory bf = new XmlBeanFactory(LIST_CONTEXT); SimpleMapScope scope = new SimpleMapScope(); bf.registerScope("request", scope); diff --git a/org.springframework.testsuite/src/test/java/org/springframework/aop/target/commonsPoolTests.xml b/org.springframework.testsuite/src/test/java/org/springframework/aop/target/CommonsPoolTargetSourceTests-context.xml similarity index 100% rename from org.springframework.testsuite/src/test/java/org/springframework/aop/target/commonsPoolTests.xml rename to org.springframework.testsuite/src/test/java/org/springframework/aop/target/CommonsPoolTargetSourceTests-context.xml diff --git a/org.springframework.testsuite/src/test/java/org/springframework/aop/target/CommonsPoolTargetSourceTests.java b/org.springframework.testsuite/src/test/java/org/springframework/aop/target/CommonsPoolTargetSourceTests.java index 3ec62982419..84b701e107e 100644 --- a/org.springframework.testsuite/src/test/java/org/springframework/aop/target/CommonsPoolTargetSourceTests.java +++ b/org.springframework.testsuite/src/test/java/org/springframework/aop/target/CommonsPoolTargetSourceTests.java @@ -54,7 +54,7 @@ public class CommonsPoolTargetSourceTests { @Before public void setUp() throws Exception { - this.beanFactory = new XmlBeanFactory(new ClassPathResource("org/springframework/aop/target/commonsPoolTests.xml")); + this.beanFactory = new XmlBeanFactory(new ClassPathResource(getClass().getSimpleName() + "-context.xml", getClass())); } /**