polishing .aop tests

This commit is contained in:
Chris Beams 2008-12-20 23:28:22 +00:00
parent 5dd4e5220a
commit 9211357e94
51 changed files with 152 additions and 261 deletions

View File

@ -32,11 +32,11 @@ import org.springframework.aop.MethodMatcher;
import org.springframework.aop.Pointcut;
import org.springframework.aop.framework.ProxyFactory;
import org.springframework.aop.support.DefaultPointcutAdvisor;
import org.springframework.beans.IOther;
import org.springframework.beans.ITestBean;
import org.springframework.beans.TestBean;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import test.beans.IOther;
import test.beans.ITestBean;
import test.beans.TestBean;
import test.beans.subpkg.DeepBean;
/**
* @author Rob Harrop
@ -66,7 +66,7 @@ public final class AspectJExpressionPointcutTests {
@Test
public void testMatchExplicit() {
String expression = "execution(int org.springframework.beans.TestBean.getAge())";
String expression = "execution(int test.beans.TestBean.getAge())";
Pointcut pointcut = getPointcut(expression);
ClassFilter classFilter = pointcut.getClassFilter();
@ -127,8 +127,8 @@ public final class AspectJExpressionPointcutTests {
* @throws SecurityException
*/
private void testThisOrTarget(String which) throws SecurityException, NoSuchMethodException {
String matchesTestBean = which + "(org.springframework.beans.TestBean)";
String matchesIOther = which + "(org.springframework.beans.IOther)";
String matchesTestBean = which + "(test.beans.TestBean)";
String matchesIOther = which + "(test.beans.IOther)";
AspectJExpressionPointcut testBeanPc = new AspectJExpressionPointcut();
testBeanPc.setExpression(matchesTestBean);
@ -155,7 +155,7 @@ public final class AspectJExpressionPointcutTests {
}
private void testWithinPackage(boolean matchSubpackages) throws SecurityException, NoSuchMethodException {
String withinBeansPackage = "within(org.springframework.beans.";
String withinBeansPackage = "within(test.beans.";
// Subpackages are matched by **
if (matchSubpackages) {
withinBeansPackage += ".";
@ -166,10 +166,9 @@ public final class AspectJExpressionPointcutTests {
assertTrue(withinBeansPc.matches(TestBean.class));
assertTrue(withinBeansPc.matches(getAge, TestBean.class));
assertEquals(matchSubpackages, withinBeansPc.matches(BeanFactory.class));
assertEquals(matchSubpackages, withinBeansPc.matches(DeepBean.class));
assertEquals(matchSubpackages, withinBeansPc.matches(
DefaultListableBeanFactory.class.getMethod("getBeanDefinitionCount", (Class<?>[])null),
DefaultListableBeanFactory.class));
DeepBean.class.getMethod("aMethod", String.class), DeepBean.class));
assertFalse(withinBeansPc.matches(String.class));
assertFalse(withinBeansPc.matches(OtherIOther.class.getMethod("absquatulate", (Class<?>[])null),
OtherIOther.class));
@ -214,7 +213,7 @@ public final class AspectJExpressionPointcutTests {
@Test
public void testMatchWithArgs() throws Exception {
String expression = "execution(void org.springframework.beans.TestBean.setSomeNumber(Number)) && args(Double)";
String expression = "execution(void test.beans.TestBean.setSomeNumber(Number)) && args(Double)";
Pointcut pointcut = getPointcut(expression);
ClassFilter classFilter = pointcut.getClassFilter();
@ -235,7 +234,7 @@ public final class AspectJExpressionPointcutTests {
@Test
public void testSimpleAdvice() {
String expression = "execution(int org.springframework.beans.TestBean.getAge())";
String expression = "execution(int test.beans.TestBean.getAge())";
CallCountingInterceptor interceptor = new CallCountingInterceptor();
@ -254,7 +253,7 @@ public final class AspectJExpressionPointcutTests {
@Test
public void testDynamicMatchingProxy() {
String expression = "execution(void org.springframework.beans.TestBean.setSomeNumber(Number)) && args(Double)";
String expression = "execution(void test.beans.TestBean.setSomeNumber(Number)) && args(Double)";
CallCountingInterceptor interceptor = new CallCountingInterceptor();
@ -273,7 +272,7 @@ public final class AspectJExpressionPointcutTests {
@Test
public void testInvalidExpression() {
String expression = "execution(void org.springframework.beans.TestBean.setSomeNumber(Number) && args(Double)";
String expression = "execution(void test.beans.TestBean.setSomeNumber(Number) && args(Double)";
try {
getPointcut(expression).getClassFilter(); // call to getClassFilter forces resolution
@ -315,7 +314,7 @@ public final class AspectJExpressionPointcutTests {
@Test
public void testWithUnsupportedPointcutPrimitive() throws Exception {
String expression = "call(int org.springframework.beans.TestBean.getAge())";
String expression = "call(int test.beans.TestBean.getAge())";
try {
getPointcut(expression).getClassFilter(); // call to getClassFilter forces resolution...

View File

@ -19,7 +19,8 @@ package org.springframework.aop.aspectj;
import static org.junit.Assert.*;
import org.junit.Test;
import org.springframework.beans.TestBean;
import test.beans.TestBean;
/**
* Tests for matching of bean() pointcut designator.

View File

@ -33,8 +33,9 @@ import org.springframework.aop.framework.AopContext;
import org.springframework.aop.framework.ProxyFactory;
import org.springframework.aop.interceptor.ExposeInvocationInterceptor;
import org.springframework.aop.support.AopUtils;
import org.springframework.beans.ITestBean;
import org.springframework.beans.TestBean;
import test.beans.ITestBean;
import test.beans.TestBean;
/**
* @author Rod Johnson

View File

@ -26,10 +26,10 @@ import java.util.Map;
import org.junit.Before;
import org.junit.Test;
import org.springframework.beans.TestBean;
import test.annotation.EmptySpringAnnotation;
import test.annotation.transaction.Tx;
import test.beans.TestBean;
/**
@ -70,7 +70,7 @@ public final class TigerAspectJExpressionPointcutTests {
@Test
public void testMatchGenericArgument() {
String expression = "execution(* set*(java.util.List<org.springframework.beans.TestBean>) )";
String expression = "execution(* set*(java.util.List<test.beans.TestBean>) )";
AspectJExpressionPointcut ajexp = new AspectJExpressionPointcut();
ajexp.setExpression(expression);

View File

@ -20,12 +20,13 @@ import static org.junit.Assert.*;
import org.junit.Test;
import org.springframework.aop.framework.autoproxy.CountingTestBean;
import org.springframework.beans.IOther;
import org.springframework.beans.ITestBean;
import org.springframework.beans.TestBean;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import test.beans.IOther;
import test.beans.ITestBean;
import test.beans.TestBean;
/**
* Unit tests for the {@link TypePatternClassFilter} class.
*
@ -43,7 +44,7 @@ public final class TypePatternClassFilterTests {
@Test
public void testValidPatternMatching() {
TypePatternClassFilter tpcf = new TypePatternClassFilter("org.springframework.beans.*");
TypePatternClassFilter tpcf = new TypePatternClassFilter("test.beans.*");
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));
@ -54,7 +55,7 @@ public final class TypePatternClassFilterTests {
@Test
public void testSubclassMatching() {
TypePatternClassFilter tpcf = new TypePatternClassFilter("org.springframework.beans.ITestBean+");
TypePatternClassFilter tpcf = new TypePatternClassFilter("test.beans.ITestBean+");
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(CountingTestBean.class));

View File

@ -45,8 +45,6 @@ import org.springframework.aop.framework.AopConfigException;
import org.springframework.aop.framework.ProxyFactory;
import org.springframework.aop.interceptor.ExposeInvocationInterceptor;
import org.springframework.aop.support.AopUtils;
import org.springframework.beans.ITestBean;
import org.springframework.beans.TestBean;
import org.springframework.core.OrderComparator;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
@ -54,6 +52,8 @@ import org.springframework.util.ObjectUtils;
import test.aspect.PerTargetAspect;
import test.aspect.TwoAdviceAspect;
import test.beans.ITestBean;
import test.beans.TestBean;
import test.mixin.DefaultLockable;
import test.mixin.Lockable;
@ -638,7 +638,7 @@ public abstract class AbstractAspectJAdvisorFactoryTests {
}
@Aspect("pertypewithin(org.springframework.beans.IOther+)")
@Aspect("pertypewithin(test.beans.IOther+)")
public static class PerTypeWithinAspect {
public int count;
@ -847,7 +847,7 @@ public abstract class AbstractAspectJAdvisorFactoryTests {
@Aspect
@DeclarePrecedence("org.springframework..*")
@DeclarePrecedence("test..*")
public static class DeclarePrecedenceShouldSucceed {
@Pointcut("execution(int *.getAge())")
@ -960,7 +960,7 @@ abstract class AbstractMakeModifiable {
@Aspect
class MakeITestBeanModifiable extends AbstractMakeModifiable {
@DeclareParents(value = "org.springframework.beans.ITestBean+",
@DeclareParents(value = "test.beans.ITestBean+",
defaultImpl=ModifiableImpl.class)
public static MutableModifable mixin;

View File

@ -28,8 +28,9 @@ import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.junit.Test;
import org.springframework.aop.aspectj.AspectJAdviceParameterNameDiscoverer;
import org.springframework.beans.ITestBean;
import org.springframework.beans.TestBean;
import test.beans.ITestBean;
import test.beans.TestBean;
/**
* @author Adrian Colyer

View File

@ -23,9 +23,9 @@ import org.springframework.aop.Pointcut;
import org.springframework.aop.aspectj.AspectJExpressionPointcut;
import org.springframework.aop.aspectj.AspectJExpressionPointcutTests;
import org.springframework.aop.framework.AopConfigException;
import org.springframework.beans.TestBean;
import test.aspect.PerTargetAspect;
import test.beans.TestBean;
/**

View File

@ -20,7 +20,7 @@
<bean id="getAgeCounter" class="org.springframework.aop.framework.CountingBeforeAdvice"/>
<bean id="testBean" class="org.springframework.beans.TestBean"/>
<bean id="testBean" class="test.beans.TestBean"/>
<bean id="countingAdvice" class="org.springframework.aop.config.CountingAspectJAdvice"/>

View File

@ -14,7 +14,7 @@
<bean id="getAgeCounter" class="org.springframework.aop.framework.CountingBeforeAdvice"/>
<bean id="testBean" class="org.springframework.beans.TestBean"/>
<bean id="testBean" class="test.beans.TestBean"/>
<bean id="countingAdvice" class="org.springframework.aop.config.CountingAspectJAdvice"/>

View File

@ -14,7 +14,7 @@
<bean id="getAgeCounter" class="org.springframework.aop.framework.CountingBeforeAdvice"/>
<bean id="testBean" class="org.springframework.beans.TestBean"/>
<bean id="testBean" class="test.beans.TestBean"/>
<bean id="countingAdvice" class="org.springframework.aop.config.CountingAspectJAdvice"/>

View File

@ -26,8 +26,9 @@ import java.util.List;
import org.junit.Test;
import org.springframework.aop.SpringProxy;
import org.springframework.beans.ITestBean;
import org.springframework.beans.TestBean;
import test.beans.ITestBean;
import test.beans.TestBean;
/**
* @author Rod Johnson

View File

@ -18,10 +18,11 @@ package org.springframework.aop.framework;
import org.junit.Test;
import org.springframework.aop.support.DelegatingIntroductionInterceptor;
import org.springframework.beans.ITestBean;
import org.springframework.beans.TestBean;
import org.springframework.util.StopWatch;
import test.beans.ITestBean;
import test.beans.TestBean;
/**
* Benchmarks for introductions.
*

View File

@ -25,7 +25,8 @@ import java.util.List;
import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
import org.junit.Test;
import org.springframework.beans.TestBean;
import test.beans.TestBean;
/**
* @author Rod Johnson

View File

@ -32,11 +32,11 @@ import org.springframework.aop.support.AopUtils;
import org.springframework.aop.support.DefaultIntroductionAdvisor;
import org.springframework.aop.support.DefaultPointcutAdvisor;
import org.springframework.aop.support.DelegatingIntroductionInterceptor;
import org.springframework.beans.IOther;
import org.springframework.beans.ITestBean;
import org.springframework.beans.TestBean;
import test.advice.MethodCounter;
import test.beans.IOther;
import test.beans.ITestBean;
import test.beans.TestBean;
import test.interceptor.NopInterceptor;
import test.util.TimeStamped;

View File

@ -20,7 +20,7 @@
package org.springframework.aop.framework.autoproxy;
import org.springframework.beans.TestBean;
import test.beans.TestBean;
/**
* @author Juergen Hoeller

View File

@ -24,10 +24,10 @@ import org.junit.Test;
import org.springframework.aop.framework.Advised;
import org.springframework.aop.framework.ProxyFactory;
import org.springframework.beans.DerivedTestBean;
import org.springframework.beans.ITestBean;
import org.springframework.beans.TestBean;
import test.beans.DerivedTestBean;
import test.beans.ITestBean;
import test.beans.TestBean;
import test.util.SerializationTestUtils;
/**

View File

@ -20,10 +20,11 @@ import static org.junit.Assert.*;
import org.junit.Test;
import org.springframework.aop.framework.ProxyFactory;
import org.springframework.beans.ITestBean;
import org.springframework.beans.TestBean;
import org.springframework.beans.factory.NamedBean;
import test.beans.ITestBean;
import test.beans.TestBean;
/**
* @author Rod Johnson
* @author Chris Beams

View File

@ -21,11 +21,12 @@ import junit.framework.TestCase;
import org.aopalliance.intercept.MethodInvocation;
import org.junit.Test;
import org.springframework.beans.ITestBean;
import org.springframework.beans.TestBean;
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.core.io.ClassPathResource;
import test.beans.ITestBean;
import test.beans.TestBean;
/**
* Non-XML tests are in AbstractAopProxyTests
*

View File

@ -22,8 +22,8 @@ import java.io.IOException;
import org.junit.Before;
import org.junit.Test;
import org.springframework.beans.TestBean;
import test.beans.TestBean;
import test.util.SerializationTestUtils;
/**

View File

@ -26,8 +26,8 @@ import org.springframework.aop.MethodMatcher;
import org.springframework.aop.Pointcut;
import org.springframework.aop.interceptor.ExposeInvocationInterceptor;
import org.springframework.aop.target.EmptyTargetSource;
import org.springframework.beans.TestBean;
import test.beans.TestBean;
import test.interceptor.NopInterceptor;
import test.util.SerializationTestUtils;

View File

@ -20,10 +20,11 @@ import static org.junit.Assert.*;
import org.junit.Test;
import org.springframework.aop.ClassFilter;
import org.springframework.beans.ITestBean;
import org.springframework.beans.TestBean;
import org.springframework.core.NestedRuntimeException;
import test.beans.ITestBean;
import test.beans.TestBean;
/**
* @author Rod Johnson
* @author Chris Beams

View File

@ -24,9 +24,10 @@ import org.junit.Test;
import org.springframework.aop.ClassFilter;
import org.springframework.aop.MethodMatcher;
import org.springframework.aop.Pointcut;
import org.springframework.beans.TestBean;
import org.springframework.core.NestedRuntimeException;
import test.beans.TestBean;
/**
* @author Rod Johnson
* @author Chris Beams

View File

@ -21,9 +21,9 @@ import static org.junit.Assert.*;
import org.junit.Test;
import org.springframework.aop.Pointcut;
import org.springframework.aop.framework.ProxyFactory;
import org.springframework.beans.ITestBean;
import org.springframework.beans.TestBean;
import test.beans.ITestBean;
import test.beans.TestBean;
import test.interceptor.NopInterceptor;
/**

View File

@ -26,13 +26,13 @@ import org.junit.Test;
import org.springframework.aop.IntroductionAdvisor;
import org.springframework.aop.IntroductionInterceptor;
import org.springframework.aop.framework.ProxyFactory;
import org.springframework.beans.INestedTestBean;
import org.springframework.beans.ITestBean;
import org.springframework.beans.NestedTestBean;
import org.springframework.beans.Person;
import org.springframework.beans.SerializablePerson;
import org.springframework.beans.TestBean;
import test.beans.INestedTestBean;
import test.beans.ITestBean;
import test.beans.NestedTestBean;
import test.beans.Person;
import test.beans.SerializablePerson;
import test.beans.TestBean;
import test.interceptor.SerializableNopInterceptor;
import test.util.SerializationTestUtils;
import test.util.TimeStamped;

View File

@ -22,10 +22,10 @@ import java.lang.reflect.Method;
import org.junit.Test;
import org.springframework.aop.MethodMatcher;
import org.springframework.beans.IOther;
import org.springframework.beans.ITestBean;
import org.springframework.beans.TestBean;
import test.beans.IOther;
import test.beans.ITestBean;
import test.beans.TestBean;
import test.util.SerializationTestUtils;
/**

View File

@ -22,9 +22,9 @@ import org.junit.Before;
import org.junit.Test;
import org.springframework.aop.framework.Advised;
import org.springframework.aop.framework.ProxyFactory;
import org.springframework.beans.Person;
import org.springframework.beans.SerializablePerson;
import test.beans.Person;
import test.beans.SerializablePerson;
import test.interceptor.NopInterceptor;
import test.interceptor.SerializableNopInterceptor;
import test.util.SerializationTestUtils;

View File

@ -23,7 +23,8 @@ import java.lang.reflect.Method;
import org.junit.Test;
import org.springframework.aop.ClassFilter;
import org.springframework.aop.Pointcut;
import org.springframework.beans.TestBean;
import test.beans.TestBean;
/**
* @author Rod Johnson

View File

@ -4,7 +4,7 @@
<beans>
<!-- Simple target -->
<bean id="test" class="org.springframework.beans.TestBean">
<bean id="test" class="test.beans.TestBean">
<property name="name"><value>custom</value></property>
<property name="age"><value>666</value></property>
</bean>
@ -21,15 +21,15 @@
</bean>
<bean id="settersAdvised" class="org.springframework.aop.framework.ProxyFactoryBean">
<property name="proxyInterfaces"><value>org.springframework.beans.ITestBean</value></property>
<property name="proxyInterfaces"><value>test.beans.ITestBean</value></property>
<property name="target"><ref local="test"/></property>
<property name="interceptorNames"><value>settersAdvisor</value></property>
</bean>
<bean id="serializableSettersAdvised" class="org.springframework.aop.framework.ProxyFactoryBean">
<property name="proxyInterfaces"><value>org.springframework.beans.Person</value></property>
<property name="proxyInterfaces"><value>test.beans.Person</value></property>
<property name="target">
<bean class="org.springframework.beans.SerializablePerson">
<bean class="test.beans.SerializablePerson">
<property name="name"><value>serializableSettersAdvised</value></property>
</bean>
</property>
@ -48,7 +48,7 @@
</bean>
<bean id="settersAndAbsquatulateAdvised" class="org.springframework.aop.framework.ProxyFactoryBean">
<property name="proxyInterfaces"><value>org.springframework.beans.ITestBean</value></property>
<property name="proxyInterfaces"><value>test.beans.ITestBean</value></property>
<!-- Force CGLIB so we can cast to TestBean -->
<property name="proxyTargetClass"><value>true</value></property>
<property name="target"><ref local="test"/></property>

View File

@ -20,13 +20,13 @@ import static org.junit.Assert.assertEquals;
import org.junit.Test;
import org.springframework.aop.framework.Advised;
import org.springframework.beans.ITestBean;
import org.springframework.beans.Person;
import org.springframework.beans.TestBean;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.core.io.ClassPathResource;
import test.beans.ITestBean;
import test.beans.Person;
import test.beans.TestBean;
import test.interceptor.NopInterceptor;
import test.interceptor.SerializableNopInterceptor;
import test.util.SerializationTestUtils;

View File

@ -3,7 +3,7 @@
<beans>
<bean id="testBeanTarget" class="org.springframework.beans.TestBean" scope="prototype"/>
<bean id="testBeanTarget" class="test.beans.TestBean" scope="prototype"/>
<bean id="targetSource" class="org.springframework.aop.target.CommonsPoolTargetSource">
<property name="targetBeanName" value="testBeanTarget"/>

View File

@ -20,11 +20,12 @@ import static org.junit.Assert.assertTrue;
import org.junit.Test;
import org.springframework.aop.support.AopUtils;
import org.springframework.beans.ITestBean;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.core.io.ClassPathResource;
import test.beans.ITestBean;
/**
* @author Rob Harrop
* @author Chris Beams

View File

@ -24,11 +24,11 @@ import org.junit.Test;
import org.springframework.aop.framework.Advised;
import org.springframework.aop.framework.ProxyFactory;
import org.springframework.aop.support.DefaultPointcutAdvisor;
import org.springframework.beans.Person;
import org.springframework.beans.SerializablePerson;
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.core.io.ClassPathResource;
import test.beans.Person;
import test.beans.SerializablePerson;
import test.beans.SideEffectBean;
import test.interceptor.SerializableNopInterceptor;
import test.util.SerializationTestUtils;

View File

@ -3,7 +3,7 @@
<beans>
<bean id="target" class="org.springframework.beans.TestBean" lazy-init="true">
<bean id="target" class="test.beans.TestBean" lazy-init="true">
<property name="age"><value>10</value></property>
</bean>

View File

@ -3,7 +3,7 @@
<beans>
<bean id="target" class="org.springframework.beans.TestBean" lazy-init="true">
<bean id="target" class="test.beans.TestBean" lazy-init="true">
<property name="age"><value>10</value></property>
</bean>

View File

@ -21,10 +21,11 @@ import static org.junit.Assert.*;
import java.util.Set;
import org.junit.Test;
import org.springframework.beans.ITestBean;
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.core.io.ClassPathResource;
import test.beans.ITestBean;
/**
* @author Juergen Hoeller
* @author Rob Harrop

View File

@ -21,11 +21,11 @@ import static org.junit.Assert.*;
import org.junit.Test;
import org.springframework.aop.TargetSource;
import org.springframework.beans.MutablePropertyValues;
import org.springframework.beans.SerializablePerson;
import org.springframework.beans.TestBean;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.support.RootBeanDefinition;
import test.beans.SerializablePerson;
import test.beans.TestBean;
import test.util.SerializationTestUtils;
/**

View File

@ -34,12 +34,12 @@
<!-- ================ Definitions for second ThreadLocalTargetSource ====== -->
<bean id="test" class="org.springframework.beans.TestBean" scope="prototype">
<bean id="test" class="test.beans.TestBean" scope="prototype">
<property name="name"><value>Rod</value></property>
<property name="spouse"><ref local="wife"/></property>
</bean>
<bean id="wife" class="org.springframework.beans.TestBean">
<bean id="wife" class="test.beans.TestBean">
<property name="name"><value>Kerry</value></property>
</bean>

View File

@ -20,10 +20,10 @@ import static org.junit.Assert.*;
import org.junit.Before;
import org.junit.Test;
import org.springframework.beans.ITestBean;
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.core.io.ClassPathResource;
import test.beans.ITestBean;
import test.beans.SideEffectBean;

View File

@ -1,145 +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.beans;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.SortedMap;
import java.util.SortedSet;
import java.util.TreeSet;
/**
* @author Juergen Hoeller
* @since 11.11.2003
*/
public class IndexedTestBean {
private TestBean[] array;
private Collection<TestBean> collection;
private List<TestBean> list;
private Set<TestBean> set;
private SortedSet<TestBean> sortedSet;
private Map<String, ? super Object> map;
private SortedMap<?, ?> sortedMap;
public IndexedTestBean() {
this(true);
}
public IndexedTestBean(boolean populate) {
if (populate) {
populate();
}
}
public void populate() {
TestBean tb0 = new TestBean("name0", 0);
TestBean tb1 = new TestBean("name1", 0);
TestBean tb2 = new TestBean("name2", 0);
TestBean tb3 = new TestBean("name3", 0);
TestBean tb4 = new TestBean("name4", 0);
TestBean tb5 = new TestBean("name5", 0);
TestBean tb6 = new TestBean("name6", 0);
TestBean tb7 = new TestBean("name7", 0);
TestBean tbX = new TestBean("nameX", 0);
TestBean tbY = new TestBean("nameY", 0);
this.array = new TestBean[] {tb0, tb1};
this.list = new ArrayList<TestBean>();
this.list.add(tb2);
this.list.add(tb3);
this.set = new TreeSet<TestBean>();
this.set.add(tb6);
this.set.add(tb7);
this.map = new HashMap<String, Object>();
this.map.put("key1", tb4);
this.map.put("key2", tb5);
this.map.put("key.3", tb5);
List<TestBean> list = new ArrayList<TestBean>();
list.add(tbX);
list.add(tbY);
this.map.put("key4", list);
}
public TestBean[] getArray() {
return array;
}
public void setArray(TestBean[] array) {
this.array = array;
}
public Collection<TestBean> getCollection() {
return collection;
}
public void setCollection(Collection<TestBean> collection) {
this.collection = collection;
}
public List<TestBean> getList() {
return list;
}
public void setList(List<TestBean> list) {
this.list = list;
}
public Set<TestBean> getSet() {
return set;
}
public void setSet(Set<TestBean> set) {
this.set = set;
}
public SortedSet<TestBean> getSortedSet() {
return sortedSet;
}
public void setSortedSet(SortedSet<TestBean> sortedSet) {
this.sortedSet = sortedSet;
}
public Map<String, ? super Object> getMap() {
return map;
}
public void setMap(Map<String, ? super Object> map) {
this.map = map;
}
public SortedMap<?, ?> getSortedMap() {
return sortedMap;
}
public void setSortedMap(SortedMap<?, ?> sortedMap) {
this.sortedMap = sortedMap;
}
}

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.beans;
package test.beans;
import org.springframework.core.enums.ShortCodedLabeledEnum;

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.beans;
package test.beans;
import java.io.Serializable;
@ -25,6 +25,7 @@ import org.springframework.beans.factory.DisposableBean;
* @author Juergen Hoeller
* @since 21.08.2003
*/
@SuppressWarnings("serial")
public class DerivedTestBean extends TestBean implements Serializable, BeanNameAware, DisposableBean {
private String beanName;

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.beans;
package test.beans;
public interface INestedTestBean {

View File

@ -15,7 +15,7 @@
* limitations under the License.
*/
package org.springframework.beans;
package test.beans;
public interface IOther {

View File

@ -14,12 +14,12 @@
* limitations under the License.
*/
package org.springframework.beans;
package test.beans;
import java.io.IOException;
/**
* Interface used for {@link org.springframework.beans.TestBean}.
* Interface used for {@link test.beans.TestBean}.
*
* <p>Two methods are the same as on Person, but if this
* extends person it breaks quite a few tests..
@ -58,8 +58,6 @@ public interface ITestBean {
INestedTestBean getLawyer();
IndexedTestBean getNestedIndexedBean();
/**
* Increment the age by one.
* @return the previous age

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.beans;
package test.beans;
/**
* Simple nested test bean used for testing bean factories, AOP framework etc.

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.beans;
package test.beans;
/**
*

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.beans;
package test.beans;
import java.io.Serializable;
@ -25,6 +25,7 @@ import org.springframework.util.ObjectUtils;
*
* @author Rod Johnson
*/
@SuppressWarnings("serial")
public class SerializablePerson implements Person, Serializable {
private String name;

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.beans;
package test.beans;
import java.io.IOException;
import java.util.ArrayList;
@ -79,8 +79,6 @@ public class TestBean implements ITestBean, IOther, Comparable<Object> {
private INestedTestBean lawyer = new NestedTestBean();
private IndexedTestBean nestedIndexedBean;
private boolean destroyed;
private Number someNumber;
@ -329,14 +327,6 @@ public class TestBean implements ITestBean, IOther, Comparable<Object> {
this.someBoolean = someBoolean;
}
public IndexedTestBean getNestedIndexedBean() {
return nestedIndexedBean;
}
public void setNestedIndexedBean(IndexedTestBean nestedIndexedBean) {
this.nestedIndexedBean = nestedIndexedBean;
}
public List<?> getOtherColours() {
return otherColours;
}

View File

@ -0,0 +1,32 @@
/*
* 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.beans.subpkg;
import org.springframework.aop.aspectj.AspectJExpressionPointcutTests;
/**
* Used for testing pointcut matching.
*
* @see AspectJExpressionPointcutTests#testWithinRootAndSubpackages()
*
* @author Chris Beams
*/
public class DeepBean {
public void aMethod(String foo) {
// no-op
}
}

View File

@ -18,7 +18,8 @@ import java.io.OutputStream;
import java.io.Serializable;
import org.junit.Test;
import org.springframework.beans.TestBean;
import test.beans.TestBean;
/**
* Utilities for testing serializability of objects.