diff --git a/org.springframework.aop/src/test/java/org/springframework/aop/aspectj/TypePatternClassFilterTests.java b/org.springframework.aop/src/test/java/org/springframework/aop/aspectj/TypePatternClassFilterTests.java index a9202dfee2d..c3708d6b86c 100644 --- a/org.springframework.aop/src/test/java/org/springframework/aop/aspectj/TypePatternClassFilterTests.java +++ b/org.springframework.aop/src/test/java/org/springframework/aop/aspectj/TypePatternClassFilterTests.java @@ -19,13 +19,14 @@ package org.springframework.aop.aspectj; import static org.junit.Assert.*; import org.junit.Test; -import org.springframework.aop.framework.autoproxy.CountingTestBean; import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.support.DefaultListableBeanFactory; +import test.beans.CountingTestBean; import test.beans.IOther; import test.beans.ITestBean; import test.beans.TestBean; +import test.beans.subpkg.DeepBean; /** * Unit tests for the {@link TypePatternClassFilter} class. @@ -48,7 +49,7 @@ public final class TypePatternClassFilterTests { assertTrue("Must match: in package", tpcf.matches(TestBean.class)); assertTrue("Must match: in package", tpcf.matches(ITestBean.class)); assertTrue("Must match: in package", tpcf.matches(IOther.class)); - assertFalse("Must be excluded: in wrong package", tpcf.matches(CountingTestBean.class)); + assertFalse("Must be excluded: in wrong package", tpcf.matches(DeepBean.class)); assertFalse("Must be excluded: in wrong package", tpcf.matches(BeanFactory.class)); assertFalse("Must be excluded: in wrong package", tpcf.matches(DefaultListableBeanFactory.class)); } diff --git a/org.springframework.aop/src/test/java/org/springframework/aop/config/AopNamespaceHandlerEventTests.java b/org.springframework.aop/src/test/java/org/springframework/aop/config/AopNamespaceHandlerEventTests.java index 3c2d2b4abcb..de36eb98b63 100644 --- a/org.springframework.aop/src/test/java/org/springframework/aop/config/AopNamespaceHandlerEventTests.java +++ b/org.springframework.aop/src/test/java/org/springframework/aop/config/AopNamespaceHandlerEventTests.java @@ -17,6 +17,7 @@ package org.springframework.aop.config; import static org.junit.Assert.*; +import static test.util.TestResourceUtils.qualifiedResource; import java.util.HashSet; import java.util.Set; @@ -30,7 +31,7 @@ import org.springframework.beans.factory.parsing.ComponentDefinition; import org.springframework.beans.factory.parsing.CompositeComponentDefinition; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; -import org.springframework.core.io.ClassPathResource; +import org.springframework.core.io.Resource; import test.parsing.CollectingReaderEventListener; @@ -42,12 +43,11 @@ import test.parsing.CollectingReaderEventListener; public final class AopNamespaceHandlerEventTests { private static final Class> CLASS = AopNamespaceHandlerEventTests.class; - private static final String CLASSNAME = CLASS.getSimpleName(); - private static final String CONTEXT = CLASSNAME + "-context.xml"; - private static final String POINTCUT_EVENTS_CONTEXT = CLASSNAME + "-pointcutEvents.xml"; - private static final String POINTCUT_REF_CONTEXT = CLASSNAME + "-pointcutRefEvents.xml"; - private static final String DIRECT_POINTCUT_EVENTS_CONTEXT = CLASSNAME + "-directPointcutEvents.xml"; + private static final Resource CONTEXT = qualifiedResource(CLASS, "context.xml"); + private static final Resource POINTCUT_EVENTS_CONTEXT = qualifiedResource(CLASS, "pointcutEvents.xml"); + private static final Resource POINTCUT_REF_CONTEXT = qualifiedResource(CLASS, "pointcutRefEvents.xml"); + private static final Resource DIRECT_POINTCUT_EVENTS_CONTEXT = qualifiedResource(CLASS, "directPointcutEvents.xml"); private CollectingReaderEventListener eventListener = new CollectingReaderEventListener(); @@ -65,7 +65,7 @@ public final class AopNamespaceHandlerEventTests { @Test public void testPointcutEvents() throws Exception { - loadBeansFrom(POINTCUT_EVENTS_CONTEXT); + this.reader.loadBeanDefinitions(POINTCUT_EVENTS_CONTEXT); ComponentDefinition[] componentDefinitions = this.eventListener.getComponentDefinitions(); assertEquals("Incorrect number of events fired", 1, componentDefinitions.length); assertTrue("No holder with nested components", componentDefinitions[0] instanceof CompositeComponentDefinition); @@ -89,7 +89,7 @@ public final class AopNamespaceHandlerEventTests { @Test public void testAdvisorEventsWithPointcutRef() throws Exception { - loadBeansFrom(POINTCUT_REF_CONTEXT); + this.reader.loadBeanDefinitions(POINTCUT_REF_CONTEXT); ComponentDefinition[] componentDefinitions = this.eventListener.getComponentDefinitions(); assertEquals("Incorrect number of events fired", 2, componentDefinitions.length); @@ -118,7 +118,7 @@ public final class AopNamespaceHandlerEventTests { @Test public void testAdvisorEventsWithDirectPointcut() throws Exception { - loadBeansFrom(DIRECT_POINTCUT_EVENTS_CONTEXT); + this.reader.loadBeanDefinitions(DIRECT_POINTCUT_EVENTS_CONTEXT); ComponentDefinition[] componentDefinitions = this.eventListener.getComponentDefinitions(); assertEquals("Incorrect number of events fired", 2, componentDefinitions.length); @@ -147,7 +147,7 @@ public final class AopNamespaceHandlerEventTests { @Test public void testAspectEvent() throws Exception { - loadBeansFrom(CONTEXT); + this.reader.loadBeanDefinitions(CONTEXT); ComponentDefinition[] componentDefinitions = this.eventListener.getComponentDefinitions(); assertEquals("Incorrect number of events fired", 5, componentDefinitions.length); @@ -192,8 +192,4 @@ public final class AopNamespaceHandlerEventTests { assertEquals("Incorrect number of BeanDefinitions", 1, pcd.getBeanDefinitions().length); } - private void loadBeansFrom(String path) { - this.reader.loadBeanDefinitions(new ClassPathResource(path, getClass())); - } - } diff --git a/org.springframework.aop/src/test/java/org/springframework/aop/config/AopNamespaceHandlerPointcutErrorTests.java b/org.springframework.aop/src/test/java/org/springframework/aop/config/AopNamespaceHandlerPointcutErrorTests.java index fc2a3bda717..860e3dd0ba8 100644 --- a/org.springframework.aop/src/test/java/org/springframework/aop/config/AopNamespaceHandlerPointcutErrorTests.java +++ b/org.springframework.aop/src/test/java/org/springframework/aop/config/AopNamespaceHandlerPointcutErrorTests.java @@ -17,12 +17,12 @@ package org.springframework.aop.config; import static org.junit.Assert.*; +import static test.util.TestResourceUtils.qualifiedResource; import org.junit.Test; import org.springframework.beans.factory.BeanDefinitionStoreException; import org.springframework.beans.factory.parsing.BeanDefinitionParsingException; import org.springframework.beans.factory.xml.XmlBeanFactory; -import org.springframework.core.io.ClassPathResource; /** * @author Mark Fisher @@ -30,19 +30,10 @@ import org.springframework.core.io.ClassPathResource; */ public final class AopNamespaceHandlerPointcutErrorTests { - private static final Class> CLASS = AopNamespaceHandlerPointcutErrorTests.class; - private static final String CLASSNAME = CLASS.getSimpleName(); - - private static final ClassPathResource DUPLICATION_CONTEXT = - new ClassPathResource(CLASSNAME + "-pointcutDuplication.xml", CLASS); - - private static final ClassPathResource MISSING_CONTEXT = - new ClassPathResource(CLASSNAME + "-pointcutMissing.xml", CLASS); - @Test public void testDuplicatePointcutConfig() { try { - new XmlBeanFactory(DUPLICATION_CONTEXT); + new XmlBeanFactory(qualifiedResource(getClass(), "pointcutDuplication.xml")); fail("parsing should have caused a BeanDefinitionStoreException"); } catch (BeanDefinitionStoreException ex) { @@ -53,7 +44,7 @@ public final class AopNamespaceHandlerPointcutErrorTests { @Test public void testMissingPointcutConfig() { try { - new XmlBeanFactory(MISSING_CONTEXT); + new XmlBeanFactory(qualifiedResource(getClass(), "pointcutMissing.xml")); fail("parsing should have caused a BeanDefinitionStoreException"); } catch (BeanDefinitionStoreException ex) { diff --git a/org.springframework.aop/src/test/java/org/springframework/aop/config/TopLevelAopTagTests.java b/org.springframework.aop/src/test/java/org/springframework/aop/config/TopLevelAopTagTests.java index 2a69f55967a..353df218fa4 100644 --- a/org.springframework.aop/src/test/java/org/springframework/aop/config/TopLevelAopTagTests.java +++ b/org.springframework.aop/src/test/java/org/springframework/aop/config/TopLevelAopTagTests.java @@ -17,11 +17,12 @@ package org.springframework.aop.config; import static org.junit.Assert.assertTrue; +import static test.util.TestResourceUtils.qualifiedResource; import org.junit.Test; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; -import org.springframework.core.io.ClassPathResource; +import org.springframework.core.io.Resource; /** * Tests that the <aop:config/> element can be used as a top level element. @@ -31,9 +32,7 @@ import org.springframework.core.io.ClassPathResource; */ public final class TopLevelAopTagTests { - private static final Class> CLASS = TopLevelAopTagTests.class; - private static final ClassPathResource CONTEXT = - new ClassPathResource(CLASS.getSimpleName() + "-context.xml", CLASS); + private static final Resource CONTEXT = qualifiedResource(TopLevelAopTagTests.class, "context.xml"); @Test public void testParse() throws Exception { diff --git a/org.springframework.aop/src/test/java/org/springframework/aop/framework/PrototypeTargetTests.java b/org.springframework.aop/src/test/java/org/springframework/aop/framework/PrototypeTargetTests.java index 166332a0af3..fd4eae3a7fb 100644 --- a/org.springframework.aop/src/test/java/org/springframework/aop/framework/PrototypeTargetTests.java +++ b/org.springframework.aop/src/test/java/org/springframework/aop/framework/PrototypeTargetTests.java @@ -16,14 +16,14 @@ package org.springframework.aop.framework; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static test.util.TestResourceUtils.qualifiedResource; import org.aopalliance.intercept.MethodInterceptor; import org.aopalliance.intercept.MethodInvocation; import org.junit.Test; - import org.springframework.beans.factory.xml.XmlBeanFactory; -import org.springframework.core.io.ClassPathResource; +import org.springframework.core.io.Resource; /** * @author Juergen Hoeller @@ -32,9 +32,7 @@ import org.springframework.core.io.ClassPathResource; */ public final class PrototypeTargetTests { - private static final Class> CLASS = PrototypeTargetTests.class; - private static final String CLASSNAME = CLASS.getSimpleName(); - private static final ClassPathResource CONTEXT = new ClassPathResource(CLASSNAME + "-context.xml", CLASS); + private static final Resource CONTEXT = qualifiedResource(PrototypeTargetTests.class, "context.xml"); @Test public void testPrototypeProxyWithPrototypeTarget() { diff --git a/org.springframework.aop/src/test/java/org/springframework/aop/interceptor/ExposeInvocationInterceptorTests.java b/org.springframework.aop/src/test/java/org/springframework/aop/interceptor/ExposeInvocationInterceptorTests.java index e624c4152a3..bfa9ea4d053 100644 --- a/org.springframework.aop/src/test/java/org/springframework/aop/interceptor/ExposeInvocationInterceptorTests.java +++ b/org.springframework.aop/src/test/java/org/springframework/aop/interceptor/ExposeInvocationInterceptorTests.java @@ -16,13 +16,13 @@ package org.springframework.aop.interceptor; -import static org.junit.Assert.assertEquals; -import junit.framework.TestCase; +import static org.junit.Assert.*; +import static test.util.TestResourceUtils.qualifiedResource; import org.aopalliance.intercept.MethodInvocation; import org.junit.Test; import org.springframework.beans.factory.xml.XmlBeanFactory; -import org.springframework.core.io.ClassPathResource; +import org.springframework.core.io.Resource; import test.beans.ITestBean; import test.beans.TestBean; @@ -33,11 +33,10 @@ import test.beans.TestBean; * @author Rod Johnson * @author Chris Beams */ -public class ExposeInvocationInterceptorTests { +public final class ExposeInvocationInterceptorTests { - private static final Class> CLASS = ExposeInvocationInterceptorTests.class; - private static final ClassPathResource CONTEXT = - new ClassPathResource(CLASS.getSimpleName() + "-context.xml", CLASS); + private static final Resource CONTEXT = + qualifiedResource(ExposeInvocationInterceptorTests.class, "context.xml"); @Test public void testXmlConfig() { @@ -72,8 +71,8 @@ abstract class ExposedInvocationTestBean extends TestBean { class InvocationCheckExposedInvocationTestBean extends ExposedInvocationTestBean { protected void assertions(MethodInvocation invocation) { - TestCase.assertTrue(invocation.getThis() == this); - TestCase.assertTrue("Invocation should be on ITestBean: " + invocation.getMethod(), + assertTrue(invocation.getThis() == this); + assertTrue("Invocation should be on ITestBean: " + invocation.getMethod(), ITestBean.class.isAssignableFrom(invocation.getMethod().getDeclaringClass())); } } diff --git a/org.springframework.aop/src/test/java/org/springframework/aop/scope/ScopedProxyAutowireTests.java b/org.springframework.aop/src/test/java/org/springframework/aop/scope/ScopedProxyAutowireTests.java index 710786dbde3..3706293c2c3 100644 --- a/org.springframework.aop/src/test/java/org/springframework/aop/scope/ScopedProxyAutowireTests.java +++ b/org.springframework.aop/src/test/java/org/springframework/aop/scope/ScopedProxyAutowireTests.java @@ -17,10 +17,11 @@ package org.springframework.aop.scope; import static org.junit.Assert.assertSame; +import static test.util.TestResourceUtils.qualifiedResource; import org.junit.Test; import org.springframework.beans.factory.xml.XmlBeanFactory; -import org.springframework.core.io.ClassPathResource; +import org.springframework.core.io.Resource; /** * @author Mark Fisher @@ -29,12 +30,9 @@ import org.springframework.core.io.ClassPathResource; public final class ScopedProxyAutowireTests { private static final Class> CLASS = ScopedProxyAutowireTests.class; - private static final String CLASSNAME = CLASS.getSimpleName(); - private static final ClassPathResource SCOPED_AUTOWIRE_TRUE_CONTEXT = - new ClassPathResource(CLASSNAME + "-scopedAutowireTrue.xml", CLASS); - private static final ClassPathResource SCOPED_AUTOWIRE_FALSE_CONTEXT = - new ClassPathResource(CLASSNAME + "-scopedAutowireFalse.xml", CLASS); + private static final Resource SCOPED_AUTOWIRE_TRUE_CONTEXT = qualifiedResource(CLASS, "scopedAutowireTrue.xml"); + private static final Resource SCOPED_AUTOWIRE_FALSE_CONTEXT = qualifiedResource(CLASS, "scopedAutowireFalse.xml"); @Test public void testScopedProxyInheritsAutowireCandidateFalse() { diff --git a/org.springframework.aop/src/test/java/org/springframework/aop/support/NameMatchMethodPointcutTests.java b/org.springframework.aop/src/test/java/org/springframework/aop/support/NameMatchMethodPointcutTests.java index 1d6a3531564..996d72f02fa 100644 --- a/org.springframework.aop/src/test/java/org/springframework/aop/support/NameMatchMethodPointcutTests.java +++ b/org.springframework.aop/src/test/java/org/springframework/aop/support/NameMatchMethodPointcutTests.java @@ -43,7 +43,6 @@ public final class NameMatchMethodPointcutTests { /** * Create an empty pointcut, populating instance variables. - * @see junit.framework.TestCase#setUp() */ @Before public void setUp() { diff --git a/org.springframework.aop/src/test/java/org/springframework/aop/support/RegexpMethodPointcutAdvisorIntegrationTests.java b/org.springframework.aop/src/test/java/org/springframework/aop/support/RegexpMethodPointcutAdvisorIntegrationTests.java index 3b90868cad7..8218e4d5db3 100644 --- a/org.springframework.aop/src/test/java/org/springframework/aop/support/RegexpMethodPointcutAdvisorIntegrationTests.java +++ b/org.springframework.aop/src/test/java/org/springframework/aop/support/RegexpMethodPointcutAdvisorIntegrationTests.java @@ -17,12 +17,13 @@ package org.springframework.aop.support; import static org.junit.Assert.assertEquals; +import static test.util.TestResourceUtils.qualifiedResource; import org.junit.Test; import org.springframework.aop.framework.Advised; import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.xml.XmlBeanFactory; -import org.springframework.core.io.ClassPathResource; +import org.springframework.core.io.Resource; import test.aop.NopInterceptor; import test.aop.SerializableNopInterceptor; @@ -37,11 +38,8 @@ import test.util.SerializationTestUtils; */ public final class RegexpMethodPointcutAdvisorIntegrationTests { - private static final Class> CLASS = RegexpMethodPointcutAdvisorIntegrationTests.class; - private static final String CLASSNAME = CLASS.getSimpleName(); - - private static final ClassPathResource CONTEXT = - new ClassPathResource(CLASSNAME + "-context.xml", CLASS); + private static final Resource CONTEXT = + qualifiedResource(RegexpMethodPointcutAdvisorIntegrationTests.class, "context.xml"); @Test public void testSinglePattern() throws Throwable { diff --git a/org.springframework.aop/src/test/java/org/springframework/aop/target/CommonsPoolTargetSourceProxyTests.java b/org.springframework.aop/src/test/java/org/springframework/aop/target/CommonsPoolTargetSourceProxyTests.java index ebef892a94f..69907b0f2f1 100644 --- a/org.springframework.aop/src/test/java/org/springframework/aop/target/CommonsPoolTargetSourceProxyTests.java +++ b/org.springframework.aop/src/test/java/org/springframework/aop/target/CommonsPoolTargetSourceProxyTests.java @@ -17,12 +17,13 @@ package org.springframework.aop.target; import static org.junit.Assert.assertTrue; +import static test.util.TestResourceUtils.qualifiedResource; import org.junit.Test; import org.springframework.aop.support.AopUtils; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; -import org.springframework.core.io.ClassPathResource; +import org.springframework.core.io.Resource; import test.beans.ITestBean; @@ -32,12 +33,15 @@ import test.beans.ITestBean; * @since 2.0 */ public final class CommonsPoolTargetSourceProxyTests { + + private static final Resource CONTEXT = + qualifiedResource(CommonsPoolTargetSourceProxyTests.class, "context.xml"); @Test public void testProxy() throws Exception { DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory(); XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(beanFactory); - reader.loadBeanDefinitions(new ClassPathResource("CommonsPoolTargetSourceProxyTests-context.xml", getClass())); + reader.loadBeanDefinitions(CONTEXT); beanFactory.preInstantiateSingletons(); ITestBean bean = (ITestBean)beanFactory.getBean("testBean"); assertTrue(AopUtils.isAopProxy(bean)); diff --git a/org.springframework.aop/src/test/java/org/springframework/aop/target/HotSwappableTargetSourceTests.java b/org.springframework.aop/src/test/java/org/springframework/aop/target/HotSwappableTargetSourceTests.java index 59cecf140d6..284c3ae5619 100644 --- a/org.springframework.aop/src/test/java/org/springframework/aop/target/HotSwappableTargetSourceTests.java +++ b/org.springframework.aop/src/test/java/org/springframework/aop/target/HotSwappableTargetSourceTests.java @@ -17,6 +17,7 @@ package org.springframework.aop.target; import static org.junit.Assert.*; +import static test.util.TestResourceUtils.qualifiedResource; import org.junit.After; import org.junit.Before; @@ -25,7 +26,7 @@ import org.springframework.aop.framework.Advised; import org.springframework.aop.framework.ProxyFactory; import org.springframework.aop.support.DefaultPointcutAdvisor; import org.springframework.beans.factory.xml.XmlBeanFactory; -import org.springframework.core.io.ClassPathResource; +import org.springframework.core.io.Resource; import test.aop.SerializableNopInterceptor; import test.beans.Person; @@ -39,6 +40,8 @@ import test.util.SerializationTestUtils; * @author Chris Beams */ public final class HotSwappableTargetSourceTests { + + private static final Resource CONTEXT = qualifiedResource(HotSwappableTargetSourceTests.class, "context.xml"); /** Initial count value set in bean factory XML */ private static final int INITIAL_COUNT = 10; @@ -47,8 +50,7 @@ public final class HotSwappableTargetSourceTests { @Before public void setUp() throws Exception { - this.beanFactory = new XmlBeanFactory( - new ClassPathResource("HotSwappableTargetSourceTests-context.xml", getClass())); + this.beanFactory = new XmlBeanFactory(CONTEXT); } /** diff --git a/org.springframework.aop/src/test/java/org/springframework/aop/target/LazyInitTargetSourceTests.java b/org.springframework.aop/src/test/java/org/springframework/aop/target/LazyInitTargetSourceTests.java index 13e28df7df4..b26fbb1e911 100644 --- a/org.springframework.aop/src/test/java/org/springframework/aop/target/LazyInitTargetSourceTests.java +++ b/org.springframework.aop/src/test/java/org/springframework/aop/target/LazyInitTargetSourceTests.java @@ -17,12 +17,13 @@ package org.springframework.aop.target; import static org.junit.Assert.*; +import static test.util.TestResourceUtils.qualifiedResource; import java.util.Set; import org.junit.Test; import org.springframework.beans.factory.xml.XmlBeanFactory; -import org.springframework.core.io.ClassPathResource; +import org.springframework.core.io.Resource; import test.beans.ITestBean; @@ -35,14 +36,10 @@ import test.beans.ITestBean; public final class LazyInitTargetSourceTests { private static final Class> CLASS = LazyInitTargetSourceTests.class; - private static final String CLASSNAME = CLASS.getSimpleName(); - private static final ClassPathResource SINGLETON_CONTEXT = - new ClassPathResource(CLASSNAME + "-singleton.xml", CLASS); - private static final ClassPathResource CUSTOM_TARGET_CONTEXT = - new ClassPathResource(CLASSNAME + "-customTarget.xml", CLASS); - private static final ClassPathResource FACTORY_BEAN_CONTEXT = - new ClassPathResource(CLASSNAME + "-factoryBean.xml", CLASS); + private static final Resource SINGLETON_CONTEXT = qualifiedResource(CLASS, "singleton.xml"); + private static final Resource CUSTOM_TARGET_CONTEXT = qualifiedResource(CLASS, "customTarget.xml"); + private static final Resource FACTORY_BEAN_CONTEXT = qualifiedResource(CLASS, "factoryBean.xml"); @Test public void testLazyInitSingletonTargetSource() { diff --git a/org.springframework.aop/src/test/java/org/springframework/aop/target/PrototypeTargetSourceTests.java b/org.springframework.aop/src/test/java/org/springframework/aop/target/PrototypeTargetSourceTests.java index 275fa6e2ac6..c5f0fa9d385 100644 --- a/org.springframework.aop/src/test/java/org/springframework/aop/target/PrototypeTargetSourceTests.java +++ b/org.springframework.aop/src/test/java/org/springframework/aop/target/PrototypeTargetSourceTests.java @@ -17,12 +17,13 @@ package org.springframework.aop.target; import static org.junit.Assert.assertEquals; +import static test.util.TestResourceUtils.qualifiedResource; import org.junit.Before; import org.junit.Test; import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.xml.XmlBeanFactory; -import org.springframework.core.io.ClassPathResource; +import org.springframework.core.io.Resource; import test.beans.SideEffectBean; @@ -33,8 +34,7 @@ import test.beans.SideEffectBean; */ public final class PrototypeTargetSourceTests { - private static final ClassPathResource CONTEXT = - new ClassPathResource("PrototypeTargetSourceTests-context.xml", PrototypeTargetSourceTests.class); + private static final Resource CONTEXT = qualifiedResource(PrototypeTargetSourceTests.class, "context.xml"); /** Initial count value set in bean factory XML */ private static final int INITIAL_COUNT = 10; diff --git a/org.springframework.aop/src/test/java/org/springframework/aop/target/ThreadLocalTargetSourceTests.java b/org.springframework.aop/src/test/java/org/springframework/aop/target/ThreadLocalTargetSourceTests.java index 7332562f2ba..bd79620b700 100644 --- a/org.springframework.aop/src/test/java/org/springframework/aop/target/ThreadLocalTargetSourceTests.java +++ b/org.springframework.aop/src/test/java/org/springframework/aop/target/ThreadLocalTargetSourceTests.java @@ -17,11 +17,12 @@ package org.springframework.aop.target; import static org.junit.Assert.*; +import static test.util.TestResourceUtils.qualifiedResource; import org.junit.Before; import org.junit.Test; import org.springframework.beans.factory.xml.XmlBeanFactory; -import org.springframework.core.io.ClassPathResource; +import org.springframework.core.io.Resource; import test.beans.ITestBean; import test.beans.SideEffectBean; @@ -33,8 +34,7 @@ import test.beans.SideEffectBean; */ public class ThreadLocalTargetSourceTests { - private static final ClassPathResource CONTEXT = - new ClassPathResource("ThreadLocalTargetSourceTests-context.xml", ThreadLocalTargetSourceTests.class); + private static final Resource CONTEXT = qualifiedResource(ThreadLocalTargetSourceTests.class, "context.xml"); /** Initial count value set in bean factory XML */ private static final int INITIAL_COUNT = 10; diff --git a/org.springframework.aop/src/test/java/org/springframework/aop/framework/autoproxy/CountingTestBean.java b/org.springframework.aop/src/test/java/test/beans/CountingTestBean.java similarity index 91% rename from org.springframework.aop/src/test/java/org/springframework/aop/framework/autoproxy/CountingTestBean.java rename to org.springframework.aop/src/test/java/test/beans/CountingTestBean.java index 9bc22615ab9..50657647656 100644 --- a/org.springframework.aop/src/test/java/org/springframework/aop/framework/autoproxy/CountingTestBean.java +++ b/org.springframework.aop/src/test/java/test/beans/CountingTestBean.java @@ -18,9 +18,8 @@ * limitations under the License. */ -package org.springframework.aop.framework.autoproxy; +package test.beans; -import test.beans.TestBean; /** * @author Juergen Hoeller diff --git a/org.springframework.aop/src/test/java/test/util/SerializationTestUtils.java b/org.springframework.aop/src/test/java/test/util/SerializationTestUtils.java index cdee0289809..cd7df05058f 100644 --- a/org.springframework.aop/src/test/java/test/util/SerializationTestUtils.java +++ b/org.springframework.aop/src/test/java/test/util/SerializationTestUtils.java @@ -1,6 +1,17 @@ /* - * The Spring Framework is published under the terms - * of the Apache Software License. + * Copyright 2002-2008 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package test.util; diff --git a/org.springframework.aop/src/test/java/test/util/TestResourceUtils.java b/org.springframework.aop/src/test/java/test/util/TestResourceUtils.java new file mode 100644 index 00000000000..bae2b829acd --- /dev/null +++ b/org.springframework.aop/src/test/java/test/util/TestResourceUtils.java @@ -0,0 +1,46 @@ +/* + * Copyright 2002-2008 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package test.util; + +import static java.lang.String.format; + +import org.springframework.core.io.ClassPathResource; + +/** + * Convenience utilities for common operations with test resources. + * + * @author Chris Beams + */ +public class TestResourceUtils { + + /** + * Loads a {@link ClassPathResource} qualified by the simple name of clazz, + * and relative to the package for clazz. + * + *
Example: given a clazz 'com.foo.BarTests' and a resourceSuffix of 'context.xml', + * this method will return a ClassPathResource representing com/foo/BarTests-context.xml + * + *
Intended for use loading context configuration XML files within JUnit tests. + * + * @param clazz + * @param resourceSuffix + */ + public static ClassPathResource qualifiedResource(Class> clazz, String resourceSuffix) { + return new ClassPathResource(format("%s-%s", clazz.getSimpleName(), resourceSuffix), clazz); + } + +} diff --git a/org.springframework.aop/src/test/java/test/util/TimeStamped.java b/org.springframework.aop/src/test/java/test/util/TimeStamped.java index 958d8b21f9a..052b56ff738 100644 --- a/org.springframework.aop/src/test/java/test/util/TimeStamped.java +++ b/org.springframework.aop/src/test/java/test/util/TimeStamped.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2005 the original author or authors. + * Copyright 2002-2008 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.