Remove trailing whitespace in source files
find . -type f -name "*.java" -or -name "*.aj" | \
xargs perl -p -i -e "s/[ \t]*$//g" {} \;
Issue: SPR-10127
This commit is contained in:
committed by
Chris Beams
parent
44a474a014
commit
1762157ad1
@@ -38,9 +38,9 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
public final class AfterAdviceBindingTests {
|
||||
|
||||
private AdviceBindingCollaborator mockCollaborator;
|
||||
|
||||
|
||||
private ITestBean testBeanProxy;
|
||||
|
||||
|
||||
private TestBean testBeanTarget;
|
||||
|
||||
@Before
|
||||
@@ -48,13 +48,13 @@ public final class AfterAdviceBindingTests {
|
||||
ClassPathXmlApplicationContext ctx =
|
||||
new ClassPathXmlApplicationContext(getClass().getSimpleName() + ".xml", getClass());
|
||||
AdviceBindingTestAspect afterAdviceAspect = (AdviceBindingTestAspect) ctx.getBean("testAspect");
|
||||
|
||||
|
||||
testBeanProxy = (ITestBean) ctx.getBean("testBean");
|
||||
assertTrue(AopUtils.isAopProxy(testBeanProxy));
|
||||
|
||||
|
||||
// we need the real target too, not just the proxy...
|
||||
testBeanTarget = (TestBean) ((Advised) testBeanProxy).getTargetSource().getTarget();
|
||||
|
||||
|
||||
mockCollaborator = createNiceMock(AdviceBindingCollaborator.class);
|
||||
afterAdviceAspect.setCollaborator(mockCollaborator);
|
||||
}
|
||||
@@ -66,7 +66,7 @@ public final class AfterAdviceBindingTests {
|
||||
testBeanProxy.setAge(5);
|
||||
verify(mockCollaborator);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testOneObjectArgBindingProxyWithThis() {
|
||||
mockCollaborator.oneObjectArg(this.testBeanProxy);
|
||||
@@ -74,7 +74,7 @@ public final class AfterAdviceBindingTests {
|
||||
testBeanProxy.getAge();
|
||||
verify(mockCollaborator);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testOneObjectArgBindingTarget() {
|
||||
mockCollaborator.oneObjectArg(this.testBeanTarget);
|
||||
@@ -82,7 +82,7 @@ public final class AfterAdviceBindingTests {
|
||||
testBeanProxy.getDoctor();
|
||||
verify(mockCollaborator);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testOneIntAndOneObjectArgs() {
|
||||
mockCollaborator.oneIntAndOneObject(5,this.testBeanProxy);
|
||||
@@ -90,7 +90,7 @@ public final class AfterAdviceBindingTests {
|
||||
testBeanProxy.setAge(5);
|
||||
verify(mockCollaborator);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testNeedsJoinPoint() {
|
||||
mockCollaborator.needsJoinPoint("getAge");
|
||||
@@ -98,7 +98,7 @@ public final class AfterAdviceBindingTests {
|
||||
testBeanProxy.getAge();
|
||||
verify(mockCollaborator);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testNeedsJoinPointStaticPart() {
|
||||
mockCollaborator.needsJoinPointStaticPart("getAge");
|
||||
@@ -106,5 +106,5 @@ public final class AfterAdviceBindingTests {
|
||||
testBeanProxy.getAge();
|
||||
verify(mockCollaborator);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ public final class AfterReturningAdviceBindingTests {
|
||||
private TestBean testBeanTarget;
|
||||
|
||||
private AfterReturningAdviceBindingCollaborator mockCollaborator;
|
||||
|
||||
|
||||
|
||||
public void setAfterReturningAdviceAspect(AfterReturningAdviceBindingTestAspect anAspect) {
|
||||
this.afterAdviceAspect = anAspect;
|
||||
@@ -55,15 +55,15 @@ public final class AfterReturningAdviceBindingTests {
|
||||
public void setUp() throws Exception {
|
||||
ClassPathXmlApplicationContext ctx =
|
||||
new ClassPathXmlApplicationContext(getClass().getSimpleName() + ".xml", getClass());
|
||||
|
||||
|
||||
afterAdviceAspect = (AfterReturningAdviceBindingTestAspect) ctx.getBean("testAspect");
|
||||
|
||||
|
||||
mockCollaborator = createNiceMock(AfterReturningAdviceBindingCollaborator.class);
|
||||
afterAdviceAspect.setCollaborator(mockCollaborator);
|
||||
|
||||
|
||||
testBeanProxy = (ITestBean) ctx.getBean("testBean");
|
||||
assertTrue(AopUtils.isAopProxy(testBeanProxy));
|
||||
|
||||
|
||||
// we need the real target too, not just the proxy...
|
||||
this.testBeanTarget = (TestBean) ((Advised)testBeanProxy).getTargetSource().getTarget();
|
||||
}
|
||||
@@ -76,7 +76,7 @@ public final class AfterReturningAdviceBindingTests {
|
||||
testBeanProxy.setAge(5);
|
||||
verify(mockCollaborator);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testOneObjectArg() {
|
||||
mockCollaborator.oneObjectArg(this.testBeanProxy);
|
||||
@@ -84,7 +84,7 @@ public final class AfterReturningAdviceBindingTests {
|
||||
testBeanProxy.getAge();
|
||||
verify(mockCollaborator);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testOneIntAndOneObjectArgs() {
|
||||
mockCollaborator.oneIntAndOneObject(5,this.testBeanProxy);
|
||||
@@ -92,7 +92,7 @@ public final class AfterReturningAdviceBindingTests {
|
||||
testBeanProxy.setAge(5);
|
||||
verify(mockCollaborator);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testNeedsJoinPoint() {
|
||||
mockCollaborator.needsJoinPoint("getAge");
|
||||
@@ -100,7 +100,7 @@ public final class AfterReturningAdviceBindingTests {
|
||||
testBeanProxy.getAge();
|
||||
verify(mockCollaborator);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testNeedsJoinPointStaticPart() {
|
||||
mockCollaborator.needsJoinPointStaticPart("getAge");
|
||||
@@ -117,7 +117,7 @@ public final class AfterReturningAdviceBindingTests {
|
||||
testBeanProxy.getName();
|
||||
verify(mockCollaborator);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testReturningObject() {
|
||||
mockCollaborator.oneObjectArg(this.testBeanTarget);
|
||||
@@ -125,7 +125,7 @@ public final class AfterReturningAdviceBindingTests {
|
||||
testBeanProxy.returnsThis();
|
||||
verify(mockCollaborator);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testReturningBean() {
|
||||
mockCollaborator.oneTestBeanArg(this.testBeanTarget);
|
||||
@@ -133,7 +133,7 @@ public final class AfterReturningAdviceBindingTests {
|
||||
testBeanProxy.returnsThis();
|
||||
verify(mockCollaborator);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testReturningBeanArray() {
|
||||
this.testBeanTarget.setSpouse(new TestBean());
|
||||
@@ -149,13 +149,13 @@ public final class AfterReturningAdviceBindingTests {
|
||||
// we need a strict mock for this...
|
||||
mockCollaborator = createMock(AfterReturningAdviceBindingCollaborator.class);
|
||||
afterAdviceAspect.setCollaborator(mockCollaborator);
|
||||
|
||||
|
||||
replay(mockCollaborator);
|
||||
testBeanProxy.setSpouse(this.testBeanProxy);
|
||||
testBeanProxy.getSpouse();
|
||||
verify(mockCollaborator);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testReturningByType() {
|
||||
mockCollaborator.objectMatchNoArgs();
|
||||
@@ -163,7 +163,7 @@ public final class AfterReturningAdviceBindingTests {
|
||||
testBeanProxy.returnsThis();
|
||||
verify(mockCollaborator);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testReturningPrimitive() {
|
||||
mockCollaborator.oneInt(20);
|
||||
@@ -181,15 +181,15 @@ final class AfterReturningAdviceBindingTestAspect extends AdviceBindingTestAspec
|
||||
private AfterReturningAdviceBindingCollaborator getCollaborator() {
|
||||
return (AfterReturningAdviceBindingCollaborator) this.collaborator;
|
||||
}
|
||||
|
||||
|
||||
public void oneString(String name) {
|
||||
getCollaborator().oneString(name);
|
||||
}
|
||||
|
||||
|
||||
public void oneTestBeanArg(TestBean bean) {
|
||||
getCollaborator().oneTestBeanArg(bean);
|
||||
}
|
||||
|
||||
|
||||
public void testBeanArrayArg(ITestBean[] beans) {
|
||||
getCollaborator().testBeanArrayArg(beans);
|
||||
}
|
||||
@@ -197,11 +197,11 @@ final class AfterReturningAdviceBindingTestAspect extends AdviceBindingTestAspec
|
||||
public void objectMatchNoArgs() {
|
||||
getCollaborator().objectMatchNoArgs();
|
||||
}
|
||||
|
||||
|
||||
public void stringMatchNoArgs() {
|
||||
getCollaborator().stringMatchNoArgs();
|
||||
}
|
||||
|
||||
|
||||
public void oneInt(int result) {
|
||||
getCollaborator().oneInt(result);
|
||||
}
|
||||
|
||||
@@ -43,14 +43,14 @@ public final class AfterThrowingAdviceBindingTests {
|
||||
public void setUp() {
|
||||
ClassPathXmlApplicationContext ctx =
|
||||
new ClassPathXmlApplicationContext(getClass().getSimpleName() + ".xml", getClass());
|
||||
|
||||
|
||||
testBean = (ITestBean) ctx.getBean("testBean");
|
||||
afterThrowingAdviceAspect = (AfterThrowingAdviceBindingTestAspect) ctx.getBean("testAspect");
|
||||
|
||||
|
||||
mockCollaborator = createNiceMock(AfterThrowingAdviceBindingCollaborator.class);
|
||||
afterThrowingAdviceAspect.setCollaborator(mockCollaborator);
|
||||
}
|
||||
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
verify(mockCollaborator);
|
||||
@@ -62,7 +62,7 @@ public final class AfterThrowingAdviceBindingTests {
|
||||
replay(mockCollaborator);
|
||||
this.testBean.exceptional(new Throwable());
|
||||
}
|
||||
|
||||
|
||||
@Test(expected=Throwable.class)
|
||||
public void testAfterThrowingWithBinding() throws Throwable {
|
||||
Throwable t = new Throwable();
|
||||
@@ -70,14 +70,14 @@ public final class AfterThrowingAdviceBindingTests {
|
||||
replay(mockCollaborator);
|
||||
this.testBean.exceptional(t);
|
||||
}
|
||||
|
||||
|
||||
@Test(expected=Throwable.class)
|
||||
public void testAfterThrowingWithNamedTypeRestriction() throws Throwable {
|
||||
Throwable t = new Throwable();
|
||||
// need a strict mock for this test...
|
||||
mockCollaborator = createMock(AfterThrowingAdviceBindingCollaborator.class);
|
||||
afterThrowingAdviceAspect.setCollaborator(mockCollaborator);
|
||||
|
||||
|
||||
mockCollaborator.noArgs();
|
||||
mockCollaborator.oneThrowable(t);
|
||||
mockCollaborator.noArgsOnThrowableMatch();
|
||||
@@ -113,7 +113,7 @@ public final class AfterThrowingAdviceBindingTests {
|
||||
|
||||
final class AfterThrowingAdviceBindingTestAspect {
|
||||
|
||||
// collaborator interface that makes it easy to test this aspect is
|
||||
// collaborator interface that makes it easy to test this aspect is
|
||||
// working as expected through mocking.
|
||||
public interface AfterThrowingAdviceBindingCollaborator {
|
||||
void noArgs();
|
||||
@@ -122,29 +122,29 @@ final class AfterThrowingAdviceBindingTestAspect {
|
||||
void noArgsOnThrowableMatch();
|
||||
void noArgsOnRuntimeExceptionMatch();
|
||||
}
|
||||
|
||||
|
||||
protected AfterThrowingAdviceBindingCollaborator collaborator = null;
|
||||
|
||||
|
||||
public void setCollaborator(AfterThrowingAdviceBindingCollaborator aCollaborator) {
|
||||
this.collaborator = aCollaborator;
|
||||
}
|
||||
|
||||
|
||||
public void noArgs() {
|
||||
this.collaborator.noArgs();
|
||||
}
|
||||
|
||||
|
||||
public void oneThrowable(Throwable t) {
|
||||
this.collaborator.oneThrowable(t);
|
||||
}
|
||||
|
||||
|
||||
public void oneRuntimeException(RuntimeException ex) {
|
||||
this.collaborator.oneRuntimeException(ex);
|
||||
}
|
||||
|
||||
|
||||
public void noArgsOnThrowableMatch() {
|
||||
this.collaborator.noArgsOnThrowableMatch();
|
||||
}
|
||||
|
||||
|
||||
public void noArgsOnRuntimeExceptionMatch() {
|
||||
this.collaborator.noArgsOnRuntimeExceptionMatch();
|
||||
}
|
||||
|
||||
@@ -39,27 +39,27 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
public class AroundAdviceBindingTests {
|
||||
|
||||
private AroundAdviceBindingCollaborator mockCollaborator;
|
||||
|
||||
|
||||
private ITestBean testBeanProxy;
|
||||
|
||||
|
||||
private TestBean testBeanTarget;
|
||||
|
||||
|
||||
protected ApplicationContext ctx;
|
||||
|
||||
@Before
|
||||
public void onSetUp() throws Exception {
|
||||
ctx = new ClassPathXmlApplicationContext(getClass().getSimpleName() + ".xml", getClass());
|
||||
|
||||
|
||||
AroundAdviceBindingTestAspect aroundAdviceAspect = ((AroundAdviceBindingTestAspect) ctx.getBean("testAspect"));
|
||||
|
||||
|
||||
ITestBean injectedTestBean = (ITestBean) ctx.getBean("testBean");
|
||||
assertTrue(AopUtils.isAopProxy(injectedTestBean));
|
||||
|
||||
|
||||
this.testBeanProxy = injectedTestBean;
|
||||
// we need the real target too, not just the proxy...
|
||||
|
||||
|
||||
this.testBeanTarget = (TestBean) ((Advised) testBeanProxy).getTargetSource().getTarget();
|
||||
|
||||
|
||||
mockCollaborator = createNiceMock(AroundAdviceBindingCollaborator.class);
|
||||
aroundAdviceAspect.setCollaborator(mockCollaborator);
|
||||
}
|
||||
@@ -71,7 +71,7 @@ public class AroundAdviceBindingTests {
|
||||
testBeanProxy.setAge(5);
|
||||
verify(mockCollaborator);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testOneObjectArgBoundToTarget() {
|
||||
mockCollaborator.oneObjectArg(this.testBeanTarget);
|
||||
@@ -79,7 +79,7 @@ public class AroundAdviceBindingTests {
|
||||
testBeanProxy.getAge();
|
||||
verify(mockCollaborator);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testOneIntAndOneObjectArgs() {
|
||||
mockCollaborator.oneIntAndOneObject(5, this.testBeanProxy);
|
||||
@@ -87,7 +87,7 @@ public class AroundAdviceBindingTests {
|
||||
testBeanProxy.setAge(5);
|
||||
verify(mockCollaborator);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testJustJoinPoint() {
|
||||
mockCollaborator.justJoinPoint("getAge");
|
||||
@@ -95,7 +95,7 @@ public class AroundAdviceBindingTests {
|
||||
testBeanProxy.getAge();
|
||||
verify(mockCollaborator);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -36,15 +36,15 @@ import org.springframework.core.Ordered;
|
||||
public final class AspectAndAdvicePrecedenceTests {
|
||||
|
||||
private PrecedenceTestAspect highPrecedenceAspect;
|
||||
|
||||
|
||||
private PrecedenceTestAspect lowPrecedenceAspect;
|
||||
|
||||
|
||||
private SimpleSpringBeforeAdvice highPrecedenceSpringAdvice;
|
||||
|
||||
|
||||
private SimpleSpringBeforeAdvice lowPrecedenceSpringAdvice;
|
||||
|
||||
|
||||
private ITestBean testBean;
|
||||
|
||||
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
@@ -176,7 +176,7 @@ class PrecedenceTestAspect implements BeanNameAware, Ordered {
|
||||
this.collaborator.aroundAdviceOne(this.name);
|
||||
try {
|
||||
ret = ((Integer)pjp.proceed()).intValue();
|
||||
}
|
||||
}
|
||||
catch(Throwable t) { throw new RuntimeException(t); }
|
||||
this.collaborator.aroundAdviceOne(this.name);
|
||||
return ret;
|
||||
@@ -187,7 +187,7 @@ class PrecedenceTestAspect implements BeanNameAware, Ordered {
|
||||
this.collaborator.aroundAdviceTwo(this.name);
|
||||
try {
|
||||
ret = ((Integer)pjp.proceed()).intValue();
|
||||
}
|
||||
}
|
||||
catch(Throwable t) {throw new RuntimeException(t);}
|
||||
this.collaborator.aroundAdviceTwo(this.name);
|
||||
return ret;
|
||||
@@ -219,7 +219,7 @@ class SimpleSpringBeforeAdvice implements MethodBeforeAdvice, BeanNameAware {
|
||||
|
||||
private PrecedenceTestAspect.Collaborator collaborator;
|
||||
private String name;
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.aop.MethodBeforeAdvice#before(java.lang.reflect.Method, java.lang.Object[], java.lang.Object)
|
||||
*/
|
||||
|
||||
@@ -100,5 +100,5 @@ class CounterAspect {
|
||||
public void increment1ForAnonymousPointcut() {
|
||||
count++;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ public final class BeanNamePointcutTests {
|
||||
private ITestBean interceptThis;
|
||||
private ITestBean dontInterceptThis;
|
||||
private TestInterceptor testInterceptor;
|
||||
|
||||
|
||||
private ClassPathXmlApplicationContext ctx;
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ public final class BeanNamePointcutTests {
|
||||
interceptThis = (ITestBean) ctx.getBean("interceptThis");
|
||||
dontInterceptThis = (ITestBean) ctx.getBean("dontInterceptThis");
|
||||
testInterceptor = (TestInterceptor) ctx.getBean("testInterceptor");
|
||||
|
||||
|
||||
counterAspect.reset();
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ public final class BeanNamePointcutTests {
|
||||
public void testNonMatchingNestedBeanName() {
|
||||
assertFalse("Non-matching bean must *not* be advised (proxied)", this.testBeanContainingNestedBean.getDoctor() instanceof Advised);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testMatchingFactoryBeanObject() {
|
||||
assertTrue("Matching bean must be advised (proxied)", this.testFactoryBean1 instanceof Advised);
|
||||
@@ -125,7 +125,7 @@ public final class BeanNamePointcutTests {
|
||||
public static class TestInterceptor implements MethodBeforeAdvice {
|
||||
|
||||
private int interceptionCount;
|
||||
|
||||
|
||||
public void before(Method method, Object[] args, Object target) throws Throwable {
|
||||
interceptionCount++;
|
||||
}
|
||||
|
||||
@@ -38,28 +38,28 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
public final class BeforeAdviceBindingTests {
|
||||
|
||||
private AdviceBindingCollaborator mockCollaborator;
|
||||
|
||||
|
||||
private ITestBean testBeanProxy;
|
||||
|
||||
|
||||
private TestBean testBeanTarget;
|
||||
|
||||
protected String getConfigPath() {
|
||||
return "before-advice-tests.xml";
|
||||
}
|
||||
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
ClassPathXmlApplicationContext ctx =
|
||||
new ClassPathXmlApplicationContext(getClass().getSimpleName() + ".xml", getClass());
|
||||
|
||||
|
||||
testBeanProxy = (ITestBean) ctx.getBean("testBean");
|
||||
assertTrue(AopUtils.isAopProxy(testBeanProxy));
|
||||
|
||||
|
||||
// we need the real target too, not just the proxy...
|
||||
testBeanTarget = (TestBean) ((Advised) testBeanProxy).getTargetSource().getTarget();
|
||||
|
||||
|
||||
AdviceBindingTestAspect beforeAdviceAspect = (AdviceBindingTestAspect) ctx.getBean("testAspect");
|
||||
|
||||
|
||||
mockCollaborator = createNiceMock(AdviceBindingCollaborator.class);
|
||||
beforeAdviceAspect.setCollaborator(mockCollaborator);
|
||||
}
|
||||
@@ -72,7 +72,7 @@ public final class BeforeAdviceBindingTests {
|
||||
testBeanProxy.setAge(5);
|
||||
verify(mockCollaborator);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testOneObjectArgBoundToProxyUsingThis() {
|
||||
mockCollaborator.oneObjectArg(this.testBeanProxy);
|
||||
@@ -80,7 +80,7 @@ public final class BeforeAdviceBindingTests {
|
||||
testBeanProxy.getAge();
|
||||
verify(mockCollaborator);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testOneIntAndOneObjectArgs() {
|
||||
mockCollaborator.oneIntAndOneObject(5,this.testBeanTarget);
|
||||
@@ -88,7 +88,7 @@ public final class BeforeAdviceBindingTests {
|
||||
testBeanProxy.setAge(5);
|
||||
verify(mockCollaborator);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testNeedsJoinPoint() {
|
||||
mockCollaborator.needsJoinPoint("getAge");
|
||||
@@ -96,7 +96,7 @@ public final class BeforeAdviceBindingTests {
|
||||
testBeanProxy.getAge();
|
||||
verify(mockCollaborator);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testNeedsJoinPointStaticPart() {
|
||||
mockCollaborator.needsJoinPointStaticPart("getAge");
|
||||
@@ -105,7 +105,7 @@ public final class BeforeAdviceBindingTests {
|
||||
verify(mockCollaborator);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ public final class DeclarationOrderIndependenceTests {
|
||||
private TopsyTurvyAspect aspect;
|
||||
|
||||
private TopsyTurvyTarget target;
|
||||
|
||||
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
@@ -49,12 +49,12 @@ public final class DeclarationOrderIndependenceTests {
|
||||
public void testTargetIsSerializable() {
|
||||
assertTrue("target bean is serializable",this.target instanceof Serializable);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testTargetIsBeanNameAware() {
|
||||
assertTrue("target bean is bean name aware",this.target instanceof BeanNameAware);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testBeforeAdviceFiringOk() {
|
||||
AspectCollaborator collab = new AspectCollaborator();
|
||||
@@ -62,7 +62,7 @@ public final class DeclarationOrderIndependenceTests {
|
||||
this.target.doSomething();
|
||||
assertTrue("before advice fired",collab.beforeFired);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testAroundAdviceFiringOk() {
|
||||
AspectCollaborator collab = new AspectCollaborator();
|
||||
@@ -70,30 +70,30 @@ public final class DeclarationOrderIndependenceTests {
|
||||
this.target.getX();
|
||||
assertTrue("around advice fired",collab.aroundFired);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testAfterReturningFiringOk() {
|
||||
AspectCollaborator collab = new AspectCollaborator();
|
||||
this.aspect.setCollaborator(collab);
|
||||
this.target.getX();
|
||||
assertTrue("after returning advice fired",collab.afterReturningFired);
|
||||
assertTrue("after returning advice fired",collab.afterReturningFired);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/** public visibility is required */
|
||||
public static class BeanNameAwareMixin implements BeanNameAware {
|
||||
|
||||
|
||||
private String beanName;
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.beans.factory.BeanNameAware#setBeanName(java.lang.String)
|
||||
*/
|
||||
public void setBeanName(String name) {
|
||||
this.beanName = name;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/** public visibility is required */
|
||||
@SuppressWarnings("serial")
|
||||
public static class SerializableMixin implements Serializable {
|
||||
@@ -103,15 +103,15 @@ public final class DeclarationOrderIndependenceTests {
|
||||
|
||||
|
||||
class TopsyTurvyAspect {
|
||||
|
||||
|
||||
interface Collaborator {
|
||||
void beforeAdviceFired();
|
||||
void afterReturningAdviceFired();
|
||||
void aroundAdviceFired();
|
||||
}
|
||||
|
||||
|
||||
private Collaborator collaborator;
|
||||
|
||||
|
||||
public void setCollaborator(Collaborator collaborator) {
|
||||
this.collaborator = collaborator;
|
||||
}
|
||||
@@ -119,11 +119,11 @@ class TopsyTurvyAspect {
|
||||
public void before() {
|
||||
this.collaborator.beforeAdviceFired();
|
||||
}
|
||||
|
||||
|
||||
public void afterReturning() {
|
||||
this.collaborator.afterReturningAdviceFired();
|
||||
}
|
||||
|
||||
|
||||
public Object around(ProceedingJoinPoint pjp) throws Throwable {
|
||||
Object ret = pjp.proceed();
|
||||
this.collaborator.aroundAdviceFired();
|
||||
@@ -144,21 +144,21 @@ interface TopsyTurvyTarget {
|
||||
class TopsyTurvyTargetImpl implements TopsyTurvyTarget {
|
||||
|
||||
private int x = 5;
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.aop.aspectj.TopsyTurvyTarget#doSomething()
|
||||
*/
|
||||
public void doSomething() {
|
||||
this.x = 10;
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.aop.aspectj.TopsyTurvyTarget#getX()
|
||||
*/
|
||||
public int getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -167,7 +167,7 @@ class AspectCollaborator implements TopsyTurvyAspect.Collaborator {
|
||||
public boolean afterReturningFired = false;
|
||||
public boolean aroundFired = false;
|
||||
public boolean beforeFired = false;
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.aop.aspectj.TopsyTurvyAspect.Collaborator#afterReturningAdviceFired()
|
||||
*/
|
||||
@@ -188,5 +188,5 @@ class AspectCollaborator implements TopsyTurvyAspect.Collaborator {
|
||||
public void beforeAdviceFired() {
|
||||
this.beforeFired = true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ public class DeclareParentsDelegateRefTests {
|
||||
protected NoMethodsBean noMethodsBean;
|
||||
|
||||
protected Counter counter;
|
||||
|
||||
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
@@ -46,7 +46,7 @@ public class DeclareParentsDelegateRefTests {
|
||||
public void testIntroductionWasMade() {
|
||||
assertTrue("Introduction must have been made", noMethodsBean instanceof ICounter);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testIntroductionDelegation() {
|
||||
((ICounter)noMethodsBean).increment();
|
||||
@@ -62,4 +62,4 @@ interface NoMethodsBean {
|
||||
|
||||
class NoMethodsBeanImpl implements NoMethodsBean {
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ import test.mixin.Lockable;
|
||||
public final class DeclareParentsTests {
|
||||
|
||||
private ITestBean testBeanProxy;
|
||||
|
||||
|
||||
private TestBean testBeanTarget;
|
||||
|
||||
private ApplicationContext ctx;
|
||||
@@ -44,14 +44,14 @@ public final class DeclareParentsTests {
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
ctx = new ClassPathXmlApplicationContext(getClass().getSimpleName() + ".xml", getClass());
|
||||
|
||||
|
||||
testBeanProxy = (ITestBean) ctx.getBean("testBean");
|
||||
assertTrue(AopUtils.isAopProxy(testBeanProxy));
|
||||
|
||||
|
||||
// we need the real target too, not just the proxy...
|
||||
testBeanTarget = (TestBean) ((Advised) testBeanProxy).getTargetSource().getTarget();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testIntroductionWasMade() {
|
||||
assertTrue("Introduction must have been made", testBeanProxy instanceof Lockable);
|
||||
|
||||
@@ -25,18 +25,18 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
/**
|
||||
* Tests to check if the first implicit join point argument is correctly processed.
|
||||
* See SPR-3723 for more details.
|
||||
*
|
||||
*
|
||||
* @author Ramnivas Laddad
|
||||
* @author Chris Beams
|
||||
*/
|
||||
public final class ImplicitJPArgumentMatchingAtAspectJTests {
|
||||
|
||||
|
||||
@Test
|
||||
public void testAspect() {
|
||||
// nothing to really test; it is enough if we don't get error while creating app context
|
||||
new ClassPathXmlApplicationContext(getClass().getSimpleName() + ".xml", getClass());
|
||||
}
|
||||
|
||||
|
||||
@Aspect
|
||||
static class CounterAtAspectJAspect {
|
||||
@Around(value="execution(* org.springframework.beans.TestBean.*(..)) and this(bean) and args(argument)",
|
||||
|
||||
@@ -22,18 +22,18 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
/**
|
||||
* Tests to check if the first implicit join point argument is correctly processed.
|
||||
* See SPR-3723 for more details.
|
||||
*
|
||||
*
|
||||
* @author Ramnivas Laddad
|
||||
* @author Chris Beams
|
||||
*/
|
||||
public final class ImplicitJPArgumentMatchingTests {
|
||||
|
||||
|
||||
@Test
|
||||
public void testAspect() {
|
||||
// nothing to really test; it is enough if we don't get error while creating app context
|
||||
new ClassPathXmlApplicationContext(getClass().getSimpleName() + ".xml", getClass());
|
||||
}
|
||||
|
||||
|
||||
static class CounterAspect {
|
||||
public void increment(ProceedingJoinPoint pjp, Object bean, Object argument) throws Throwable {
|
||||
pjp.proceed();
|
||||
|
||||
@@ -64,7 +64,7 @@ class OverloadedAdviceTestAspect {
|
||||
public void myBeforeAdvice(String name) {
|
||||
// no-op
|
||||
}
|
||||
|
||||
|
||||
public void myBeforeAdvice(int age) {
|
||||
// no-op
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ public final class ProceedTests {
|
||||
|
||||
|
||||
interface SimpleBean {
|
||||
|
||||
|
||||
void setName(String name);
|
||||
String getName();
|
||||
void setAge(int age);
|
||||
@@ -100,7 +100,7 @@ class SimpleBeanImpl implements SimpleBean {
|
||||
private float aFloat;
|
||||
private String name;
|
||||
private String sex;
|
||||
|
||||
|
||||
public int getAge() {
|
||||
return age;
|
||||
}
|
||||
@@ -136,30 +136,30 @@ class SimpleBeanImpl implements SimpleBean {
|
||||
|
||||
|
||||
class ProceedTestingAspect implements Ordered {
|
||||
|
||||
|
||||
private String lastBeforeStringValue;
|
||||
private String lastAroundStringValue;
|
||||
private float lastBeforeFloatValue;
|
||||
private int order;
|
||||
|
||||
|
||||
public void setOrder(int order) { this.order = order; }
|
||||
public int getOrder() { return this.order; }
|
||||
|
||||
|
||||
public Object capitalize(ProceedingJoinPoint pjp, String value) throws Throwable {
|
||||
return pjp.proceed(new Object[] {value.toUpperCase()});
|
||||
}
|
||||
|
||||
|
||||
public Object doubleOrQuits(ProceedingJoinPoint pjp) throws Throwable {
|
||||
int value = ((Integer) pjp.getArgs()[0]).intValue();
|
||||
pjp.getArgs()[0] = new Integer(value * 2);
|
||||
return pjp.proceed();
|
||||
}
|
||||
|
||||
|
||||
public Object addOne(ProceedingJoinPoint pjp, Float value) throws Throwable {
|
||||
float fv = value.floatValue();
|
||||
return pjp.proceed(new Object[] {new Float(fv + 1.0F)});
|
||||
}
|
||||
|
||||
|
||||
public void captureStringArgument(JoinPoint tjp, String arg) {
|
||||
if (!tjp.getArgs()[0].equals(arg)) {
|
||||
throw new IllegalStateException(
|
||||
@@ -169,7 +169,7 @@ class ProceedTestingAspect implements Ordered {
|
||||
}
|
||||
this.lastBeforeStringValue = arg;
|
||||
}
|
||||
|
||||
|
||||
public Object captureStringArgumentInAround(ProceedingJoinPoint pjp, String arg) throws Throwable {
|
||||
if (!pjp.getArgs()[0].equals(arg)) {
|
||||
throw new IllegalStateException(
|
||||
@@ -179,7 +179,7 @@ class ProceedTestingAspect implements Ordered {
|
||||
this.lastAroundStringValue = arg;
|
||||
return pjp.proceed();
|
||||
}
|
||||
|
||||
|
||||
public void captureFloatArgument(JoinPoint tjp, float arg) {
|
||||
float tjpArg = ((Float) tjp.getArgs()[0]).floatValue();
|
||||
if (Math.abs(tjpArg - arg) > 0.000001) {
|
||||
@@ -190,15 +190,15 @@ class ProceedTestingAspect implements Ordered {
|
||||
}
|
||||
this.lastBeforeFloatValue = arg;
|
||||
}
|
||||
|
||||
|
||||
public String getLastBeforeStringValue() {
|
||||
return this.lastBeforeStringValue;
|
||||
}
|
||||
|
||||
|
||||
public String getLastAroundStringValue() {
|
||||
return this.lastAroundStringValue;
|
||||
}
|
||||
|
||||
|
||||
public float getLastBeforeFloatValue() {
|
||||
return this.lastBeforeFloatValue;
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ class JoinPointMonitorAspect {
|
||||
* is sufficient to reproduce the bug.
|
||||
*/
|
||||
private ICounter counter;
|
||||
|
||||
|
||||
int beforeExecutions;
|
||||
int aroundExecutions;
|
||||
|
||||
@@ -121,7 +121,7 @@ class JoinPointMonitorAtAspectJAspect {
|
||||
* is sufficient to reproduce the bug.
|
||||
*/
|
||||
private ICounter counter;
|
||||
|
||||
|
||||
int beforeExecutions;
|
||||
int aroundExecutions;
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
|
||||
/**
|
||||
* See SPR-1682.
|
||||
*
|
||||
*
|
||||
* @author Adrian Colyer
|
||||
* @author Chris Beams
|
||||
*/
|
||||
@@ -30,7 +30,7 @@ public final class SharedPointcutWithArgsMismatchTests {
|
||||
|
||||
private ToBeAdvised toBeAdvised;
|
||||
|
||||
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
ClassPathXmlApplicationContext ctx =
|
||||
|
||||
@@ -36,7 +36,7 @@ public final class SubtypeSensitiveMatchingTests {
|
||||
private SerializableFoo serializableBean;
|
||||
|
||||
private Bar bar;
|
||||
|
||||
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
@@ -52,13 +52,13 @@ public final class SubtypeSensitiveMatchingTests {
|
||||
assertTrue("bean with serializable type should be proxied",
|
||||
this.serializableBean instanceof Advised);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testBeansThatDoNotMatchBasedSolelyOnRuntimeTypeAreNotProxied() {
|
||||
assertFalse("bean with non-serializable type should not be proxied",
|
||||
this.nonSerializableBean instanceof Advised);
|
||||
this.nonSerializableBean instanceof Advised);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testBeansThatDoNotMatchBasedOnOtherTestAreProxied() {
|
||||
assertTrue("bean with args check should be proxied",
|
||||
@@ -73,14 +73,14 @@ interface NonSerializableFoo { void foo(); }
|
||||
interface SerializableFoo extends Serializable { void foo(); }
|
||||
|
||||
class SubtypeMatchingTestClassA implements NonSerializableFoo {
|
||||
|
||||
|
||||
public void foo() {}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
class SubtypeMatchingTestClassB implements SerializableFoo {
|
||||
|
||||
|
||||
public void foo() {}
|
||||
|
||||
}
|
||||
@@ -90,5 +90,5 @@ interface Bar { void bar(Object o); }
|
||||
class SubtypeMatchingTestClassC implements Bar {
|
||||
|
||||
public void bar(Object o) {}
|
||||
|
||||
|
||||
}
|
||||
@@ -38,7 +38,7 @@ public final class TargetPointcutSelectionTests {
|
||||
public TestAspect testAspectForTestImpl1;
|
||||
public TestAspect testAspectForAbstractTestImpl;
|
||||
public TestInterceptor testInterceptor;
|
||||
|
||||
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
@@ -49,12 +49,12 @@ public final class TargetPointcutSelectionTests {
|
||||
testAspectForTestImpl1 = (TestAspect) ctx.getBean("testAspectForTestImpl1");
|
||||
testAspectForAbstractTestImpl = (TestAspect) ctx.getBean("testAspectForAbstractTestImpl");
|
||||
testInterceptor = (TestInterceptor) ctx.getBean("testInterceptor");
|
||||
|
||||
|
||||
testAspectForTestImpl1.count = 0;
|
||||
testAspectForAbstractTestImpl.count = 0;
|
||||
testInterceptor.count = 0;
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testTargetSelectionForMatchedType() {
|
||||
testImpl1.interfaceMethod();
|
||||
@@ -76,7 +76,7 @@ public final class TargetPointcutSelectionTests {
|
||||
|
||||
public void interfaceMethod();
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Reproducing bug requires that the class specified in target() pointcut doesn't
|
||||
// include the advised method's implementation (instead a base class should include it)
|
||||
@@ -85,7 +85,7 @@ public final class TargetPointcutSelectionTests {
|
||||
public void interfaceMethod() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static class TestImpl1 extends AbstractTestImpl {
|
||||
}
|
||||
@@ -98,12 +98,12 @@ public final class TargetPointcutSelectionTests {
|
||||
public static class TestAspect {
|
||||
|
||||
public int count;
|
||||
|
||||
|
||||
public void increment() {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static class TestInterceptor extends TestAspect implements MethodInterceptor {
|
||||
|
||||
|
||||
@@ -34,9 +34,9 @@ public final class ThisAndTargetSelectionOnlyPointcutsAtAspectJTests {
|
||||
public TestInterface testBean;
|
||||
public TestInterface testAnnotatedClassBean;
|
||||
public TestInterface testAnnotatedMethodBean;
|
||||
|
||||
|
||||
protected Counter counter;
|
||||
|
||||
|
||||
@org.junit.Before
|
||||
public void setUp() {
|
||||
ClassPathXmlApplicationContext ctx =
|
||||
@@ -89,8 +89,8 @@ public final class ThisAndTargetSelectionOnlyPointcutsAtAspectJTests {
|
||||
testBean.doIt();
|
||||
assertEquals(1, counter.thisAsInterfaceAndTargetAsInterfaceCounter);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void testAtTargetClassAnnotationMatch() {
|
||||
testAnnotatedClassBean.doIt();
|
||||
@@ -102,7 +102,7 @@ public final class ThisAndTargetSelectionOnlyPointcutsAtAspectJTests {
|
||||
testAnnotatedMethodBean.doIt();
|
||||
assertEquals(1, counter.atAnnotationMethodAnnotationCounter);
|
||||
}
|
||||
|
||||
|
||||
public static interface TestInterface {
|
||||
public void doIt();
|
||||
}
|
||||
@@ -111,12 +111,12 @@ public final class ThisAndTargetSelectionOnlyPointcutsAtAspectJTests {
|
||||
public void doIt() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public static @interface TestAnnotation {
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@TestAnnotation
|
||||
public static class AnnotatedClassTestImpl implements TestInterface {
|
||||
public void doIt() {
|
||||
@@ -128,7 +128,7 @@ public final class ThisAndTargetSelectionOnlyPointcutsAtAspectJTests {
|
||||
public void doIt() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Aspect
|
||||
public static class Counter {
|
||||
int thisAsClassCounter;
|
||||
@@ -140,7 +140,7 @@ public final class ThisAndTargetSelectionOnlyPointcutsAtAspectJTests {
|
||||
int thisAsInterfaceAndTargetAsClassCounter;
|
||||
int atTargetClassAnnotationCounter;
|
||||
int atAnnotationMethodAnnotationCounter;
|
||||
|
||||
|
||||
public void reset() {
|
||||
thisAsClassCounter = 0;
|
||||
thisAsInterfaceCounter = 0;
|
||||
@@ -152,7 +152,7 @@ public final class ThisAndTargetSelectionOnlyPointcutsAtAspectJTests {
|
||||
atTargetClassAnnotationCounter = 0;
|
||||
atAnnotationMethodAnnotationCounter = 0;
|
||||
}
|
||||
|
||||
|
||||
@Before("this(org.springframework.aop.aspectj.ThisAndTargetSelectionOnlyPointcutsAtAspectJTests.TestImpl)")
|
||||
public void incrementThisAsClassCounter() {
|
||||
thisAsClassCounter++;
|
||||
@@ -162,7 +162,7 @@ public final class ThisAndTargetSelectionOnlyPointcutsAtAspectJTests {
|
||||
public void incrementThisAsInterfaceCounter() {
|
||||
thisAsInterfaceCounter++;
|
||||
}
|
||||
|
||||
|
||||
@Before("target(org.springframework.aop.aspectj.ThisAndTargetSelectionOnlyPointcutsAtAspectJTests.TestImpl)")
|
||||
public void incrementTargetAsClassCounter() {
|
||||
targetAsClassCounter++;
|
||||
@@ -184,22 +184,22 @@ public final class ThisAndTargetSelectionOnlyPointcutsAtAspectJTests {
|
||||
public void incrementThisAsInterfaceAndTargetAsInterfaceCounter() {
|
||||
thisAsInterfaceAndTargetAsInterfaceCounter++;
|
||||
}
|
||||
|
||||
|
||||
@Before("this(org.springframework.aop.aspectj.ThisAndTargetSelectionOnlyPointcutsAtAspectJTests.TestInterface) " +
|
||||
"&& target(org.springframework.aop.aspectj.ThisAndTargetSelectionOnlyPointcutsAtAspectJTests.TestImpl)")
|
||||
public void incrementThisAsInterfaceAndTargetAsClassCounter() {
|
||||
thisAsInterfaceAndTargetAsClassCounter++;
|
||||
}
|
||||
|
||||
|
||||
@Before("@target(org.springframework.aop.aspectj.ThisAndTargetSelectionOnlyPointcutsAtAspectJTests.TestAnnotation)")
|
||||
public void incrementAtTargetClassAnnotationCounter() {
|
||||
atTargetClassAnnotationCounter++;
|
||||
}
|
||||
|
||||
|
||||
@Before("@annotation(org.springframework.aop.aspectj.ThisAndTargetSelectionOnlyPointcutsAtAspectJTests.TestAnnotation)")
|
||||
public void incrementAtAnnotationMethodAnnotationCounter() {
|
||||
atAnnotationMethodAnnotationCounter++;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,9 +27,9 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
* @author Chris Beams
|
||||
*/
|
||||
public final class ThisAndTargetSelectionOnlyPointcutsTests {
|
||||
|
||||
|
||||
private TestInterface testBean;
|
||||
|
||||
|
||||
private Counter thisAsClassCounter;
|
||||
private Counter thisAsInterfaceCounter;
|
||||
private Counter targetAsClassCounter;
|
||||
@@ -37,28 +37,28 @@ public final class ThisAndTargetSelectionOnlyPointcutsTests {
|
||||
private Counter thisAsClassAndTargetAsClassCounter;
|
||||
private Counter thisAsInterfaceAndTargetAsInterfaceCounter;
|
||||
private Counter thisAsInterfaceAndTargetAsClassCounter;
|
||||
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
ClassPathXmlApplicationContext ctx =
|
||||
new ClassPathXmlApplicationContext(getClass().getSimpleName() + ".xml", getClass());
|
||||
|
||||
testBean = (TestInterface) ctx.getBean("testBean");
|
||||
|
||||
|
||||
thisAsClassCounter = (Counter) ctx.getBean("thisAsClassCounter");
|
||||
thisAsInterfaceCounter = (Counter) ctx.getBean("thisAsInterfaceCounter");
|
||||
targetAsClassCounter = (Counter) ctx.getBean("targetAsClassCounter");
|
||||
targetAsInterfaceCounter = (Counter) ctx.getBean("targetAsInterfaceCounter");
|
||||
|
||||
|
||||
thisAsClassAndTargetAsClassCounter = (Counter) ctx.getBean("thisAsClassAndTargetAsClassCounter");
|
||||
thisAsInterfaceAndTargetAsInterfaceCounter = (Counter) ctx.getBean("thisAsInterfaceAndTargetAsInterfaceCounter");
|
||||
thisAsInterfaceAndTargetAsClassCounter = (Counter) ctx.getBean("thisAsInterfaceAndTargetAsClassCounter");
|
||||
|
||||
|
||||
thisAsClassCounter.reset();
|
||||
thisAsInterfaceCounter.reset();
|
||||
targetAsClassCounter.reset();
|
||||
targetAsInterfaceCounter.reset();
|
||||
|
||||
|
||||
thisAsClassAndTargetAsClassCounter.reset();
|
||||
thisAsInterfaceAndTargetAsInterfaceCounter.reset();
|
||||
thisAsInterfaceAndTargetAsClassCounter.reset();
|
||||
@@ -105,7 +105,7 @@ public final class ThisAndTargetSelectionOnlyPointcutsTests {
|
||||
testBean.doIt();
|
||||
assertEquals(1, thisAsInterfaceAndTargetAsInterfaceCounter.getCount());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ import org.aspectj.lang.JoinPoint;
|
||||
* intention of reducing the surface area of java files within this
|
||||
* package. This allows developers to think about tests first, and deal
|
||||
* with these second class testing artifacts on an as-needed basis.
|
||||
*
|
||||
*
|
||||
* Types here should be defined as package-private top level classes in
|
||||
* order to avoid needing to fully qualify, e.g.: _TestTypes$Foo.
|
||||
*
|
||||
@@ -49,24 +49,24 @@ class AdviceBindingTestAspect {
|
||||
public void setCollaborator(AdviceBindingCollaborator aCollaborator) {
|
||||
this.collaborator = aCollaborator;
|
||||
}
|
||||
|
||||
|
||||
// "advice" methods
|
||||
public void oneIntArg(int age) {
|
||||
this.collaborator.oneIntArg(age);
|
||||
}
|
||||
|
||||
|
||||
public void oneObjectArg(Object bean) {
|
||||
this.collaborator.oneObjectArg(bean);
|
||||
}
|
||||
|
||||
|
||||
public void oneIntAndOneObject(int x, Object o) {
|
||||
this.collaborator.oneIntAndOneObject(x,o);
|
||||
}
|
||||
|
||||
|
||||
public void needsJoinPoint(JoinPoint tjp) {
|
||||
this.collaborator.needsJoinPoint(tjp.getSignature().getName());
|
||||
}
|
||||
|
||||
|
||||
public void needsJoinPointStaticPart(JoinPoint.StaticPart tjpsp) {
|
||||
this.collaborator.needsJoinPointStaticPart(tjpsp.getSignature().getName());
|
||||
}
|
||||
@@ -108,7 +108,7 @@ interface ICounter {
|
||||
|
||||
/**
|
||||
* A simple counter for use in simple tests (for example, how many times an advice was executed)
|
||||
*
|
||||
*
|
||||
* @author Ramnivas Laddad
|
||||
*/
|
||||
final class Counter implements ICounter {
|
||||
@@ -121,7 +121,7 @@ final class Counter implements ICounter {
|
||||
public void increment() {
|
||||
count++;
|
||||
}
|
||||
|
||||
|
||||
public void decrement() {
|
||||
count--;
|
||||
}
|
||||
@@ -133,7 +133,7 @@ final class Counter implements ICounter {
|
||||
public void setCount(int counter) {
|
||||
this.count = counter;
|
||||
}
|
||||
|
||||
|
||||
public void reset() {
|
||||
this.count = 0;
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ public final class AnnotationBindingTests {
|
||||
public void setUp() {
|
||||
ClassPathXmlApplicationContext ctx =
|
||||
new ClassPathXmlApplicationContext(getClass().getSimpleName() + "-context.xml", getClass());
|
||||
|
||||
|
||||
testBean = (AnnotatedTestBean) ctx.getBean("testBean");
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ public final class AnnotationPointcutTests {
|
||||
public void setUp() {
|
||||
ClassPathXmlApplicationContext ctx =
|
||||
new ClassPathXmlApplicationContext(getClass().getSimpleName() + "-context.xml", getClass());
|
||||
|
||||
|
||||
testBean = (AnnotatedTestBean) ctx.getBean("testBean");
|
||||
}
|
||||
|
||||
|
||||
@@ -36,10 +36,10 @@ public final class AspectImplementingInterfaceTests {
|
||||
public void testProxyCreation() {
|
||||
ClassPathXmlApplicationContext ctx =
|
||||
new ClassPathXmlApplicationContext(getClass().getSimpleName() + "-context.xml", getClass());
|
||||
|
||||
|
||||
ITestBean testBean = (ITestBean) ctx.getBean("testBean");
|
||||
AnInterface interfaceExtendingAspect = (AnInterface) ctx.getBean("interfaceExtendingAspect");
|
||||
|
||||
|
||||
assertTrue(testBean instanceof Advised);
|
||||
assertFalse(interfaceExtendingAspect instanceof Advised);
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ public final class AspectJAutoProxyCreatorAndLazyInitTargetSourceTests {
|
||||
public void testAdrian() {
|
||||
ClassPathXmlApplicationContext ctx =
|
||||
new ClassPathXmlApplicationContext(getClass().getSimpleName() + "-context.xml", getClass());
|
||||
|
||||
|
||||
ITestBean adrian = (ITestBean) ctx.getBean("adrian");
|
||||
assertEquals(0, LazyTestBean.instantiations);
|
||||
assertNotNull(adrian);
|
||||
|
||||
@@ -180,7 +180,7 @@ public final class AspectJAutoProxyCreatorTests {
|
||||
public void testAspectsAndAdvisorAreAppliedEvenIfComingFromParentFactory() {
|
||||
ClassPathXmlApplicationContext ac = newContext("aspectsPlusAdvisor.xml");
|
||||
GenericApplicationContext childAc = new GenericApplicationContext(ac);
|
||||
// Create a child factory with a bean that should be woven
|
||||
// Create a child factory with a bean that should be woven
|
||||
RootBeanDefinition bd = new RootBeanDefinition(TestBean.class);
|
||||
bd.getPropertyValues().addPropertyValue(new PropertyValue("name", "Adrian"))
|
||||
.addPropertyValue(new PropertyValue("age", new Integer(34)));
|
||||
@@ -297,7 +297,7 @@ public final class AspectJAutoProxyCreatorTests {
|
||||
adrian1.getAge();
|
||||
AdviceUsingThisJoinPoint aspectInstance = (AdviceUsingThisJoinPoint) bf.getBean("aspect");
|
||||
//(AdviceUsingThisJoinPoint) Aspects.aspectOf(AdviceUsingThisJoinPoint.class);
|
||||
//assertEquals("method-execution(int TestBean.getAge())",aspectInstance.getLastMethodEntered());
|
||||
//assertEquals("method-execution(int TestBean.getAge())",aspectInstance.getLastMethodEntered());
|
||||
assertTrue(aspectInstance.getLastMethodEntered().indexOf("TestBean.getAge())") != 0);
|
||||
}
|
||||
|
||||
|
||||
@@ -76,8 +76,8 @@ class AtAspectJAnnotationBindingTestAspect {
|
||||
Object result = pjp.proceed();
|
||||
return (result instanceof String ? annValue + " " + result : result);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
class ResourceArrayFactoryBean implements FactoryBean<Object> {
|
||||
|
||||
@@ -30,7 +30,7 @@ import org.aspectj.lang.ProceedingJoinPoint;
|
||||
* intention of reducing the surface area of java files within this
|
||||
* package. This allows developers to think about tests first, and deal
|
||||
* with these second class testing artifacts on an as-needed basis.
|
||||
*
|
||||
*
|
||||
* Types here should be defined as package-private top level classes in
|
||||
* order to avoid needing to fully qualify, e.g.: _TestTypes$Foo.
|
||||
*
|
||||
|
||||
@@ -38,14 +38,14 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
import org.springframework.util.StopWatch;
|
||||
|
||||
/**
|
||||
* Integration tests for AspectJ auto proxying. Includes mixing with Spring AOP
|
||||
* Integration tests for AspectJ auto proxying. Includes mixing with Spring AOP
|
||||
* Advisors to demonstrate that existing autoproxying contract is honoured.
|
||||
*
|
||||
* @author Rod Johnson
|
||||
* @author Chris Beams
|
||||
*/
|
||||
public final class BenchmarkTests {
|
||||
|
||||
|
||||
private static final Class<?> CLASS = BenchmarkTests.class;
|
||||
|
||||
private static final String ASPECTJ_CONTEXT = CLASS.getSimpleName() + "-aspectj.xml";
|
||||
@@ -56,27 +56,27 @@ public final class BenchmarkTests {
|
||||
public void testRepeatedAroundAdviceInvocationsWithAspectJ() {
|
||||
testRepeatedAroundAdviceInvocations(ASPECTJ_CONTEXT, getCount(), "AspectJ");
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testRepeatedAroundAdviceInvocationsWithSpringAop() {
|
||||
testRepeatedAroundAdviceInvocations(SPRING_AOP_CONTEXT, getCount(), "Spring AOP");
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testRepeatedBeforeAdviceInvocationsWithAspectJ() {
|
||||
testBeforeAdviceWithoutJoinPoint(ASPECTJ_CONTEXT, getCount(), "AspectJ");
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testRepeatedBeforeAdviceInvocationsWithSpringAop() {
|
||||
testBeforeAdviceWithoutJoinPoint(SPRING_AOP_CONTEXT, getCount(), "Spring AOP");
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testRepeatedAfterReturningAdviceInvocationsWithAspectJ() {
|
||||
testAfterReturningAdviceWithoutJoinPoint(ASPECTJ_CONTEXT, getCount(), "AspectJ");
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testRepeatedAfterReturningAdviceInvocationsWithSpringAop() {
|
||||
testAfterReturningAdviceWithoutJoinPoint(SPRING_AOP_CONTEXT, getCount(), "Spring AOP");
|
||||
@@ -86,12 +86,12 @@ public final class BenchmarkTests {
|
||||
public void testRepeatedMixWithAspectJ() {
|
||||
testMix(ASPECTJ_CONTEXT, getCount(), "AspectJ");
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testRepeatedMixWithSpringAop() {
|
||||
testMix(SPRING_AOP_CONTEXT, getCount(), "Spring AOP");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Change the return number to a higher number to make this test useful.
|
||||
*/
|
||||
@@ -105,85 +105,85 @@ public final class BenchmarkTests {
|
||||
StopWatch sw = new StopWatch();
|
||||
sw.start(howmany + " repeated around advice invocations with " + technology);
|
||||
ITestBean adrian = (ITestBean) bf.getBean("adrian");
|
||||
|
||||
|
||||
assertTrue(AopUtils.isAopProxy(adrian));
|
||||
assertEquals(68, adrian.getAge());
|
||||
|
||||
|
||||
for (int i = 0; i < howmany; i++) {
|
||||
adrian.getAge();
|
||||
}
|
||||
|
||||
|
||||
sw.stop();
|
||||
System.out.println(sw.prettyPrint());
|
||||
return sw.getLastTaskTimeMillis();
|
||||
}
|
||||
|
||||
|
||||
private long testBeforeAdviceWithoutJoinPoint(String file, int howmany, String technology) {
|
||||
ClassPathXmlApplicationContext bf = new ClassPathXmlApplicationContext(file, CLASS);
|
||||
|
||||
StopWatch sw = new StopWatch();
|
||||
sw.start(howmany + " repeated before advice invocations with " + technology);
|
||||
ITestBean adrian = (ITestBean) bf.getBean("adrian");
|
||||
|
||||
|
||||
assertTrue(AopUtils.isAopProxy(adrian));
|
||||
Advised a = (Advised) adrian;
|
||||
assertTrue(a.getAdvisors().length >= 3);
|
||||
assertEquals("adrian", adrian.getName());
|
||||
|
||||
|
||||
for (int i = 0; i < howmany; i++) {
|
||||
adrian.getName();
|
||||
}
|
||||
|
||||
|
||||
sw.stop();
|
||||
System.out.println(sw.prettyPrint());
|
||||
return sw.getLastTaskTimeMillis();
|
||||
}
|
||||
|
||||
|
||||
private long testAfterReturningAdviceWithoutJoinPoint(String file, int howmany, String technology) {
|
||||
ClassPathXmlApplicationContext bf = new ClassPathXmlApplicationContext(file, CLASS);
|
||||
|
||||
StopWatch sw = new StopWatch();
|
||||
sw.start(howmany + " repeated after returning advice invocations with " + technology);
|
||||
ITestBean adrian = (ITestBean) bf.getBean("adrian");
|
||||
|
||||
|
||||
assertTrue(AopUtils.isAopProxy(adrian));
|
||||
Advised a = (Advised) adrian;
|
||||
assertTrue(a.getAdvisors().length >= 3);
|
||||
// Hits joinpoint
|
||||
adrian.setAge(25);
|
||||
|
||||
|
||||
for (int i = 0; i < howmany; i++) {
|
||||
adrian.setAge(i);
|
||||
}
|
||||
|
||||
|
||||
sw.stop();
|
||||
System.out.println(sw.prettyPrint());
|
||||
return sw.getLastTaskTimeMillis();
|
||||
}
|
||||
|
||||
|
||||
private long testMix(String file, int howmany, String technology) {
|
||||
ClassPathXmlApplicationContext bf = new ClassPathXmlApplicationContext(file, CLASS);
|
||||
|
||||
StopWatch sw = new StopWatch();
|
||||
sw.start(howmany + " repeated mixed invocations with " + technology);
|
||||
ITestBean adrian = (ITestBean) bf.getBean("adrian");
|
||||
|
||||
|
||||
assertTrue(AopUtils.isAopProxy(adrian));
|
||||
Advised a = (Advised) adrian;
|
||||
assertTrue(a.getAdvisors().length >= 3);
|
||||
|
||||
|
||||
for (int i = 0; i < howmany; i++) {
|
||||
// Hit all 3 joinpoints
|
||||
adrian.getAge();
|
||||
adrian.getName();
|
||||
adrian.setAge(i);
|
||||
|
||||
|
||||
// Invoke three non-advised methods
|
||||
adrian.getDoctor();
|
||||
adrian.getLawyer();
|
||||
adrian.getSpouse();
|
||||
}
|
||||
|
||||
|
||||
sw.stop();
|
||||
System.out.println(sw.prettyPrint());
|
||||
return sw.getLastTaskTimeMillis();
|
||||
@@ -193,19 +193,19 @@ public final class BenchmarkTests {
|
||||
|
||||
|
||||
class MultiplyReturnValueInterceptor implements MethodInterceptor {
|
||||
|
||||
|
||||
private int multiple = 2;
|
||||
|
||||
|
||||
public int invocations;
|
||||
|
||||
|
||||
public void setMultiple(int multiple) {
|
||||
this.multiple = multiple;
|
||||
}
|
||||
|
||||
|
||||
public int getMultiple() {
|
||||
return this.multiple;
|
||||
}
|
||||
|
||||
|
||||
public Object invoke(MethodInvocation mi) throws Throwable {
|
||||
++invocations;
|
||||
int result = (Integer) mi.proceed();
|
||||
@@ -216,13 +216,13 @@ class MultiplyReturnValueInterceptor implements MethodInterceptor {
|
||||
|
||||
|
||||
class TraceAfterReturningAdvice implements AfterReturningAdvice {
|
||||
|
||||
|
||||
public int afterTakesInt;
|
||||
|
||||
|
||||
public void afterReturning(Object returnValue, Method method, Object[] args, Object target) throws Throwable {
|
||||
++afterTakesInt;
|
||||
}
|
||||
|
||||
|
||||
public static Advisor advisor() {
|
||||
return new DefaultPointcutAdvisor(
|
||||
new StaticMethodMatcherPointcut() {
|
||||
@@ -239,16 +239,16 @@ class TraceAfterReturningAdvice implements AfterReturningAdvice {
|
||||
|
||||
@Aspect
|
||||
class TraceAspect {
|
||||
|
||||
|
||||
public int beforeStringReturn;
|
||||
|
||||
|
||||
public int afterTakesInt;
|
||||
|
||||
|
||||
@Before("execution(String *.*(..))")
|
||||
public void traceWithoutJoinPoint() {
|
||||
++beforeStringReturn;
|
||||
}
|
||||
|
||||
|
||||
@AfterReturning("execution(void *.*(int))")
|
||||
public void traceWithoutJoinPoint2() {
|
||||
++afterTakesInt;
|
||||
@@ -258,13 +258,13 @@ class TraceAspect {
|
||||
|
||||
|
||||
class TraceBeforeAdvice implements MethodBeforeAdvice {
|
||||
|
||||
|
||||
public int beforeStringReturn;
|
||||
|
||||
|
||||
public void before(Method method, Object[] args, Object target) throws Throwable {
|
||||
++beforeStringReturn;
|
||||
}
|
||||
|
||||
|
||||
public static Advisor advisor() {
|
||||
return new DefaultPointcutAdvisor(
|
||||
new StaticMethodMatcherPointcut() {
|
||||
|
||||
@@ -34,14 +34,14 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
public final class SPR3064Tests {
|
||||
|
||||
private Service service;
|
||||
|
||||
|
||||
@Test
|
||||
public void testServiceIsAdvised() {
|
||||
ClassPathXmlApplicationContext ctx =
|
||||
new ClassPathXmlApplicationContext(getClass().getSimpleName() + ".xml", getClass());
|
||||
|
||||
|
||||
service = (Service) ctx.getBean("service");
|
||||
|
||||
|
||||
try {
|
||||
this.service.serveMe();
|
||||
fail("service operation has not been advised by transaction interceptor");
|
||||
@@ -50,7 +50,7 @@ public final class SPR3064Tests {
|
||||
assertEquals("advice invoked",ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ public final class SPR3064Tests {
|
||||
|
||||
@Aspect
|
||||
class TransactionInterceptor {
|
||||
|
||||
|
||||
@Around(value="execution(* *..Service.*(..)) && @annotation(transaction)")
|
||||
public Object around(ProceedingJoinPoint pjp, Transaction transaction) throws Throwable {
|
||||
throw new RuntimeException("advice invoked");
|
||||
@@ -73,7 +73,7 @@ class TransactionInterceptor {
|
||||
|
||||
|
||||
interface Service {
|
||||
|
||||
|
||||
void serveMe();
|
||||
|
||||
}
|
||||
|
||||
@@ -51,10 +51,10 @@ public final class AfterReturningGenericTypeMatchingTests {
|
||||
public void setUp() {
|
||||
ClassPathXmlApplicationContext ctx =
|
||||
new ClassPathXmlApplicationContext(getClass().getSimpleName() + "-context.xml", getClass());
|
||||
|
||||
|
||||
counterAspect = (CounterAspect) ctx.getBean("counterAspect");
|
||||
counterAspect.reset();
|
||||
|
||||
|
||||
testBean = (GenericReturnTypeVariationClass) ctx.getBean("testBean");
|
||||
}
|
||||
|
||||
|
||||
@@ -50,10 +50,10 @@ public class GenericBridgeMethodMatchingTests {
|
||||
public void setUp() {
|
||||
ClassPathXmlApplicationContext ctx =
|
||||
new ClassPathXmlApplicationContext(getClass().getSimpleName() + "-context.xml", getClass());
|
||||
|
||||
|
||||
counterAspect = (GenericCounterAspect) ctx.getBean("counterAspect");
|
||||
counterAspect.count = 0;
|
||||
|
||||
|
||||
testBean = (DerivedInterface<String>) ctx.getBean("testBean");
|
||||
}
|
||||
|
||||
|
||||
@@ -45,14 +45,14 @@ public final class GenericParameterMatchingTests {
|
||||
public void setUp() {
|
||||
ClassPathXmlApplicationContext ctx =
|
||||
new ClassPathXmlApplicationContext(getClass().getSimpleName() + "-context.xml", getClass());
|
||||
|
||||
|
||||
counterAspect = (CounterAspect) ctx.getBean("counterAspect");
|
||||
counterAspect.reset();
|
||||
|
||||
|
||||
testBean = (GenericInterface<String>) ctx.getBean("testBean");
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void testGenericInterfaceGenericArgExecution() {
|
||||
testBean.save("");
|
||||
@@ -64,7 +64,7 @@ public final class GenericParameterMatchingTests {
|
||||
testBean.saveAll(null);
|
||||
assertEquals(1, counterAspect.genericInterfaceGenericCollectionArgExecutionCount);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testGenericInterfaceSubtypeGenericCollectionArgExecution() {
|
||||
testBean.saveAll(null);
|
||||
@@ -96,21 +96,21 @@ public final class GenericParameterMatchingTests {
|
||||
int genericInterfaceGenericArgExecutionCount;
|
||||
int genericInterfaceGenericCollectionArgExecutionCount;
|
||||
int genericInterfaceSubtypeGenericCollectionArgExecutionCount;
|
||||
|
||||
|
||||
public void reset() {
|
||||
genericInterfaceGenericArgExecutionCount = 0;
|
||||
genericInterfaceGenericCollectionArgExecutionCount = 0;
|
||||
genericInterfaceSubtypeGenericCollectionArgExecutionCount = 0;
|
||||
}
|
||||
|
||||
|
||||
@Pointcut("execution(* org.springframework.aop.aspectj.generic.GenericParameterMatchingTests.GenericInterface.save(..))")
|
||||
public void genericInterfaceGenericArgExecution() {}
|
||||
|
||||
public void genericInterfaceGenericArgExecution() {}
|
||||
|
||||
@Pointcut("execution(* org.springframework.aop.aspectj.generic.GenericParameterMatchingTests.GenericInterface.saveAll(..))")
|
||||
public void GenericInterfaceGenericCollectionArgExecution() {}
|
||||
public void GenericInterfaceGenericCollectionArgExecution() {}
|
||||
|
||||
@Pointcut("execution(* org.springframework.aop.aspectj.generic.GenericParameterMatchingTests.GenericInterface+.saveAll(..))")
|
||||
public void genericInterfaceSubtypeGenericCollectionArgExecution() {}
|
||||
public void genericInterfaceSubtypeGenericCollectionArgExecution() {}
|
||||
|
||||
@Before("genericInterfaceGenericArgExecution()")
|
||||
public void incrementGenericInterfaceGenericArgExecution() {
|
||||
|
||||
@@ -33,7 +33,7 @@ public final class AopNamespaceHandlerAdviceTypeTests {
|
||||
public void testParsingOfAdviceTypes() {
|
||||
new ClassPathXmlApplicationContext(getClass().getSimpleName() + "-ok.xml", getClass());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testParsingOfAdviceTypesWithError() {
|
||||
try {
|
||||
|
||||
@@ -32,7 +32,7 @@ public final class AopNamespaceHandlerArgNamesTests {
|
||||
public void testArgNamesOK() {
|
||||
new ClassPathXmlApplicationContext(getClass().getSimpleName() + "-ok.xml", getClass());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testArgNamesError() {
|
||||
try {
|
||||
|
||||
@@ -33,7 +33,7 @@ public final class AopNamespaceHandlerReturningTests {
|
||||
public void testReturningOnReturningAdvice() {
|
||||
new ClassPathXmlApplicationContext(getClass().getSimpleName() + "-ok.xml", getClass());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testParseReturningOnOtherAdviceType() {
|
||||
try {
|
||||
|
||||
@@ -33,7 +33,7 @@ import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Unit tests for aop namespace.
|
||||
*
|
||||
*
|
||||
* @author Rob Harrop
|
||||
* @author Chris Beams
|
||||
*/
|
||||
@@ -41,7 +41,7 @@ public class AopNamespaceHandlerTests {
|
||||
|
||||
private ApplicationContext context;
|
||||
|
||||
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
this.context =
|
||||
@@ -149,7 +149,7 @@ class CountingAspectJAdvice {
|
||||
this.aroundCount++;
|
||||
pjp.proceed();
|
||||
}
|
||||
|
||||
|
||||
public void myAfterReturningAdvice(int age) {
|
||||
this.afterCount++;
|
||||
}
|
||||
@@ -157,11 +157,11 @@ class CountingAspectJAdvice {
|
||||
public void myAfterThrowingAdvice(RuntimeException ex) {
|
||||
this.afterCount++;
|
||||
}
|
||||
|
||||
|
||||
public void mySetAgeAdvice(int newAge, ITestBean bean) {
|
||||
// no-op
|
||||
}
|
||||
|
||||
|
||||
public int getBeforeCount() {
|
||||
return this.beforeCount;
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ public final class AopNamespaceHandlerThrowingTests {
|
||||
public void testThrowingOnThrowingAdvice() {
|
||||
new ClassPathXmlApplicationContext(getClass().getSimpleName() + "-ok.xml", getClass());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testParseThrowingOnOtherAdviceType() {
|
||||
try {
|
||||
|
||||
@@ -35,15 +35,15 @@ public final class MethodLocatingFactoryBeanTests {
|
||||
private static final String BEAN_NAME = "string";
|
||||
private MethodLocatingFactoryBean factory;
|
||||
private BeanFactory beanFactory;
|
||||
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
factory = new MethodLocatingFactoryBean();
|
||||
|
||||
|
||||
// methods must set up expectations and call replay() manually for this mock
|
||||
beanFactory = createMock(BeanFactory.class);
|
||||
}
|
||||
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
verify(beanFactory);
|
||||
@@ -64,7 +64,7 @@ public final class MethodLocatingFactoryBeanTests {
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
public void testWithNullTargetBeanName() {
|
||||
replay(beanFactory);
|
||||
|
||||
|
||||
factory.setMethodName("toString()");
|
||||
factory.setBeanFactory(beanFactory);
|
||||
}
|
||||
@@ -72,7 +72,7 @@ public final class MethodLocatingFactoryBeanTests {
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
public void testWithEmptyTargetBeanName() {
|
||||
replay(beanFactory);
|
||||
|
||||
|
||||
factory.setTargetBeanName("");
|
||||
factory.setMethodName("toString()");
|
||||
factory.setBeanFactory(beanFactory);
|
||||
@@ -81,7 +81,7 @@ public final class MethodLocatingFactoryBeanTests {
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
public void testWithNullTargetMethodName() {
|
||||
replay(beanFactory);
|
||||
|
||||
|
||||
factory.setTargetBeanName(BEAN_NAME);
|
||||
factory.setBeanFactory(beanFactory);
|
||||
}
|
||||
@@ -89,7 +89,7 @@ public final class MethodLocatingFactoryBeanTests {
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
public void testWithEmptyTargetMethodName() {
|
||||
replay(beanFactory);
|
||||
|
||||
|
||||
factory.setTargetBeanName(BEAN_NAME);
|
||||
factory.setMethodName("");
|
||||
factory.setBeanFactory(beanFactory);
|
||||
@@ -99,7 +99,7 @@ public final class MethodLocatingFactoryBeanTests {
|
||||
public void testWhenTargetBeanClassCannotBeResolved() {
|
||||
expect(beanFactory.getType(BEAN_NAME)).andReturn(null);
|
||||
replay(beanFactory);
|
||||
|
||||
|
||||
factory.setTargetBeanName(BEAN_NAME);
|
||||
factory.setMethodName("toString()");
|
||||
factory.setBeanFactory(beanFactory);
|
||||
@@ -109,7 +109,7 @@ public final class MethodLocatingFactoryBeanTests {
|
||||
public void testSunnyDayPath() throws Exception {
|
||||
expect((Class) beanFactory.getType(BEAN_NAME)).andReturn(String.class);
|
||||
replay(beanFactory);
|
||||
|
||||
|
||||
factory.setTargetBeanName(BEAN_NAME);
|
||||
factory.setMethodName("toString()");
|
||||
factory.setBeanFactory(beanFactory);
|
||||
@@ -124,7 +124,7 @@ public final class MethodLocatingFactoryBeanTests {
|
||||
public void testWhereMethodCannotBeResolved() {
|
||||
expect((Class) beanFactory.getType(BEAN_NAME)).andReturn(String.class);
|
||||
replay(beanFactory);
|
||||
|
||||
|
||||
factory.setTargetBeanName(BEAN_NAME);
|
||||
factory.setMethodName("loadOfOld()");
|
||||
factory.setBeanFactory(beanFactory);
|
||||
|
||||
@@ -797,7 +797,7 @@ public abstract class AbstractAopProxyTests {
|
||||
}
|
||||
|
||||
/**
|
||||
* Note that an introduction can't throw an unexpected checked exception,
|
||||
* Note that an introduction can't throw an unexpected checked exception,
|
||||
* as it's constained by the interface.
|
||||
*/
|
||||
@Test
|
||||
@@ -1268,8 +1268,8 @@ public abstract class AbstractAopProxyTests {
|
||||
return target;
|
||||
}
|
||||
|
||||
public void releaseTarget(Object target) throws Exception {
|
||||
}
|
||||
public void releaseTarget(Object target) throws Exception {
|
||||
}
|
||||
});
|
||||
|
||||
// Just test anything: it will fail if context wasn't found
|
||||
@@ -1422,7 +1422,7 @@ public abstract class AbstractAopProxyTests {
|
||||
}
|
||||
assertEquals(6, cca.getCalls());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testBeforeAdviceThrowsException() {
|
||||
final RuntimeException rex = new RuntimeException();
|
||||
@@ -1909,31 +1909,31 @@ public abstract class AbstractAopProxyTests {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public static class CountingMultiAdvice extends MethodCounter implements MethodBeforeAdvice,
|
||||
AfterReturningAdvice, ThrowsAdvice {
|
||||
|
||||
|
||||
public void before(Method m, Object[] args, Object target) throws Throwable {
|
||||
count(m);
|
||||
}
|
||||
|
||||
|
||||
public void afterReturning(Object o, Method m, Object[] args, Object target)
|
||||
throws Throwable {
|
||||
count(m);
|
||||
}
|
||||
|
||||
|
||||
public void afterThrowing(IOException ex) throws Throwable {
|
||||
count(IOException.class.getName());
|
||||
}
|
||||
|
||||
|
||||
public void afterThrowing(UncheckedException ex) throws Throwable {
|
||||
count(UncheckedException.class.getName());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public static class CountingThrowsAdvice extends MethodCounter implements ThrowsAdvice {
|
||||
|
||||
@@ -1946,36 +1946,36 @@ public abstract class AbstractAopProxyTests {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
static class UncheckedException extends RuntimeException {
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
static class SpecializedUncheckedException extends UncheckedException {
|
||||
|
||||
public SpecializedUncheckedException(String string, SQLException exception) {
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static class MockTargetSource implements TargetSource {
|
||||
|
||||
|
||||
private Object target;
|
||||
|
||||
|
||||
public int gets;
|
||||
|
||||
|
||||
public int releases;
|
||||
|
||||
|
||||
public void reset() {
|
||||
this.target = null;
|
||||
gets = releases = 0;
|
||||
}
|
||||
|
||||
|
||||
public void setTarget(Object target) {
|
||||
this.target = target;
|
||||
}
|
||||
@@ -2003,7 +2003,7 @@ public abstract class AbstractAopProxyTests {
|
||||
throw new RuntimeException("Released wrong target");
|
||||
++releases;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check that gets and releases match
|
||||
*
|
||||
@@ -2021,8 +2021,8 @@ public abstract class AbstractAopProxyTests {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static abstract class ExposedInvocationTestBean extends TestBean {
|
||||
|
||||
public String getName() {
|
||||
@@ -2036,18 +2036,18 @@ public abstract class AbstractAopProxyTests {
|
||||
assertions(invocation);
|
||||
super.absquatulate();
|
||||
}
|
||||
|
||||
|
||||
protected abstract void assertions(MethodInvocation invocation);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static class InvocationCheckExposedInvocationTestBean extends ExposedInvocationTestBean {
|
||||
protected void assertions(MethodInvocation invocation) {
|
||||
TestCase.assertTrue(invocation.getThis() == this);
|
||||
TestCase.assertTrue("Invocation should be on ITestBean: " + invocation.getMethod(),
|
||||
TestCase.assertTrue("Invocation should be on ITestBean: " + invocation.getMethod(),
|
||||
ITestBean.class.isAssignableFrom(invocation.getMethod().getDeclaringClass()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -227,7 +227,7 @@ public final class CglibProxyTests extends AbstractAopProxyTests implements Seri
|
||||
|
||||
return (ITestBean) pf.getProxy();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testMultipleProxiesForIntroductionAdvisor() {
|
||||
TestBean target = new TestBean();
|
||||
@@ -243,7 +243,7 @@ public final class CglibProxyTests extends AbstractAopProxyTests implements Seri
|
||||
private ITestBean getIntroductionAdvisorProxy(TestBean target) {
|
||||
ProxyFactory pf = new ProxyFactory(new Class[]{ITestBean.class});
|
||||
pf.setProxyTargetClass(true);
|
||||
|
||||
|
||||
pf.addAdvisor(new LockMixinAdvisor());
|
||||
pf.setTarget(target);
|
||||
pf.setFrozen(true);
|
||||
@@ -462,15 +462,15 @@ class CglibTestBean {
|
||||
class NoArgCtorTestBean {
|
||||
|
||||
private boolean called = false;
|
||||
|
||||
|
||||
public NoArgCtorTestBean(String x, int y) {
|
||||
called = true;
|
||||
}
|
||||
|
||||
|
||||
public boolean wasCalled() {
|
||||
return called;
|
||||
}
|
||||
|
||||
|
||||
public void reset() {
|
||||
called = false;
|
||||
}
|
||||
|
||||
@@ -48,16 +48,16 @@ public final class JdkDynamicProxyTests extends AbstractAopProxyTests implements
|
||||
assertTrue("Should be a JDK proxy: " + proxy.getClass(), AopUtils.isJdkDynamicProxy(proxy));
|
||||
return proxy;
|
||||
}
|
||||
|
||||
|
||||
protected AopProxy createAopProxy(AdvisedSupport as) {
|
||||
return new JdkDynamicAopProxy(as);
|
||||
}
|
||||
|
||||
|
||||
public void testNullConfig() {
|
||||
try {
|
||||
new JdkDynamicAopProxy(null);
|
||||
fail("Shouldn't allow null interceptors");
|
||||
}
|
||||
}
|
||||
catch (IllegalArgumentException ex) {
|
||||
// Ok
|
||||
}
|
||||
@@ -91,16 +91,16 @@ public final class JdkDynamicProxyTests extends AbstractAopProxyTests implements
|
||||
assertTrue("correct return value", tb.getAge() == age);
|
||||
verify(mi);
|
||||
}
|
||||
|
||||
|
||||
public void testTargetCanGetInvocationWithPrivateClass() throws Throwable {
|
||||
final ExposedInvocationTestBean expectedTarget = new ExposedInvocationTestBean() {
|
||||
protected void assertions(MethodInvocation invocation) {
|
||||
assertTrue(invocation.getThis() == this);
|
||||
assertTrue("Invocation should be on ITestBean: " + invocation.getMethod(),
|
||||
assertTrue("Invocation should be on ITestBean: " + invocation.getMethod(),
|
||||
invocation.getMethod().getDeclaringClass() == ITestBean.class);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
AdvisedSupport pc = new AdvisedSupport(new Class[] { ITestBean.class, IOther.class });
|
||||
pc.addAdvice(ExposeInvocationInterceptor.INSTANCE);
|
||||
TrapTargetInterceptor tii = new TrapTargetInterceptor() {
|
||||
@@ -118,7 +118,7 @@ public final class JdkDynamicProxyTests extends AbstractAopProxyTests implements
|
||||
tb.getName();
|
||||
// Not safe to trap invocation
|
||||
//assertTrue(tii.invocation == target.invocation);
|
||||
|
||||
|
||||
//assertTrue(target.invocation.getProxy() == tb);
|
||||
|
||||
// ((IOther) tb).absquatulate();
|
||||
|
||||
@@ -71,10 +71,10 @@ import test.beans.SideEffectBean;
|
||||
* @author Chris Beams
|
||||
*/
|
||||
public final class ProxyFactoryBeanTests {
|
||||
|
||||
|
||||
private static final Class<?> CLASS = ProxyFactoryBeanTests.class;
|
||||
private static final String CLASSNAME = CLASS.getSimpleName();
|
||||
|
||||
|
||||
private static final String CONTEXT = CLASSNAME + "-context.xml";
|
||||
private static final String SERIALIZATION_CONTEXT = CLASSNAME + "-serialization.xml";
|
||||
private static final String AUTOWIRING_CONTEXT = CLASSNAME + "-autowiring.xml";
|
||||
@@ -86,7 +86,7 @@ public final class ProxyFactoryBeanTests {
|
||||
private static final String PROTOTYPE_CONTEXT = CLASSNAME + "-prototype.xml";
|
||||
private static final String THROWS_ADVICE_CONTEXT = CLASSNAME + "-throws-advice.xml";
|
||||
private static final String INNER_BEAN_TARGET_CONTEXT = CLASSNAME + "-inner-bean-target.xml";
|
||||
|
||||
|
||||
private BeanFactory factory;
|
||||
|
||||
@Before
|
||||
@@ -243,7 +243,7 @@ public final class ProxyFactoryBeanTests {
|
||||
* be a prototype
|
||||
*/
|
||||
private Object testPrototypeInstancesAreIndependent(String beanName) {
|
||||
// Initial count value set in bean factory XML
|
||||
// Initial count value set in bean factory XML
|
||||
int INITIAL_COUNT = 10;
|
||||
|
||||
BeanFactory bf = new XmlBeanFactory(new ClassPathResource(PROTOTYPE_CONTEXT, CLASS));
|
||||
@@ -301,7 +301,7 @@ public final class ProxyFactoryBeanTests {
|
||||
assertTrue("Has correct object type", ITestBean.class.isAssignableFrom(factory.getType("test1")));
|
||||
|
||||
ITestBean tb = (ITestBean) factory.getBean("test1");
|
||||
// no exception
|
||||
// no exception
|
||||
tb.hashCode();
|
||||
|
||||
final Exception ex = new UnsupportedOperationException("invoke");
|
||||
@@ -313,12 +313,12 @@ public final class ProxyFactoryBeanTests {
|
||||
});
|
||||
assertEquals("Have correct advisor count", 2, config.getAdvisors().length);
|
||||
|
||||
tb = (ITestBean) factory.getBean("test1");
|
||||
tb = (ITestBean) factory.getBean("test1");
|
||||
try {
|
||||
// Will fail now
|
||||
tb.toString();
|
||||
fail("Evil interceptor added programmatically should fail all method calls");
|
||||
}
|
||||
}
|
||||
catch (Exception thrown) {
|
||||
assertTrue(thrown == ex);
|
||||
}
|
||||
@@ -570,7 +570,7 @@ public final class ProxyFactoryBeanTests {
|
||||
|
||||
// Remove offending interceptor...
|
||||
assertTrue(((Advised) p).removeAdvice(nop));
|
||||
assertTrue("Serializable again because offending interceptor was removed", SerializationTestUtils.isSerializable(p));
|
||||
assertTrue("Serializable again because offending interceptor was removed", SerializationTestUtils.isSerializable(p));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -728,7 +728,7 @@ public final class ProxyFactoryBeanTests {
|
||||
|
||||
|
||||
/**
|
||||
* Use as a global interceptor. Checks that
|
||||
* Use as a global interceptor. Checks that
|
||||
* global interceptors can add aspect interfaces.
|
||||
* NB: Add only via global interceptors in XML file.
|
||||
*/
|
||||
|
||||
@@ -8,7 +8,7 @@ package org.springframework.aop.framework;
|
||||
* intention of reducing the surface area of java files within this
|
||||
* package. This allows developers to think about tests first, and deal
|
||||
* with these second class testing artifacts on an as-needed basis.
|
||||
*
|
||||
*
|
||||
* Types here should be defined as package-private top level classes in
|
||||
* order to avoid needing to fully qualify, e.g.: _TestTypes$Foo.
|
||||
*
|
||||
@@ -26,7 +26,7 @@ interface IEcho {
|
||||
|
||||
class Echo implements IEcho {
|
||||
private int a;
|
||||
|
||||
|
||||
public int echoException(int i, Throwable t) throws Throwable {
|
||||
if (t != null)
|
||||
throw t;
|
||||
|
||||
@@ -40,7 +40,7 @@ import test.mixin.Lockable;
|
||||
|
||||
/**
|
||||
* Tests for auto proxy creation by advisor recognition.
|
||||
*
|
||||
*
|
||||
* @see org.springframework.aop.framework.autoproxy.AdvisorAutoProxyCreatorIntegrationTests;
|
||||
*
|
||||
* @author Rod Johnson
|
||||
@@ -51,7 +51,7 @@ 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";
|
||||
@@ -85,7 +85,7 @@ public final class AdvisorAutoProxyCreatorTests {
|
||||
|
||||
ITestBean test2 = (ITestBean) bf.getBean("test2");
|
||||
Lockable lockable2 = (Lockable) test2;
|
||||
|
||||
|
||||
// Locking should be independent; nop is shared
|
||||
assertFalse(lockable1.locked());
|
||||
assertFalse(lockable2.locked());
|
||||
@@ -151,7 +151,7 @@ public final class AdvisorAutoProxyCreatorTests {
|
||||
assertEquals("Rod", test.getName());
|
||||
// Check that references survived pooling
|
||||
assertEquals("Kerry", test.getSpouse().getName());
|
||||
|
||||
|
||||
// Now test the pooled one
|
||||
test = (ITestBean) bf.getBean(":test");
|
||||
assertTrue(AopUtils.isAopProxy(test));
|
||||
@@ -160,7 +160,7 @@ public final class AdvisorAutoProxyCreatorTests {
|
||||
assertEquals("Rod", test.getName());
|
||||
// Check that references survived pooling
|
||||
assertEquals("Kerry", test.getSpouse().getName());
|
||||
|
||||
|
||||
// Now test the ThreadLocal one
|
||||
test = (ITestBean) bf.getBean("%test");
|
||||
assertTrue(AopUtils.isAopProxy(test));
|
||||
@@ -169,7 +169,7 @@ public final class AdvisorAutoProxyCreatorTests {
|
||||
assertEquals("Rod", test.getName());
|
||||
// Check that references survived pooling
|
||||
assertEquals("Kerry", test.getSpouse().getName());
|
||||
|
||||
|
||||
// Now test the Prototype TargetSource
|
||||
test = (ITestBean) bf.getBean("!test");
|
||||
assertTrue(AopUtils.isAopProxy(test));
|
||||
@@ -186,7 +186,7 @@ public final class AdvisorAutoProxyCreatorTests {
|
||||
assertEquals("Kerry", test2.getSpouse().getName());
|
||||
bf.close();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testWithOptimizedProxy() throws Exception {
|
||||
BeanFactory beanFactory = new ClassPathXmlApplicationContext(OPTIMIZED_CONTEXT, CLASS);
|
||||
|
||||
@@ -85,7 +85,7 @@ public class BeanNameAutoProxyCreatorTests {
|
||||
assertEquals(age, tb.getAge());
|
||||
assertTrue("Introduction was made", tb instanceof TimeStamped);
|
||||
assertEquals(0, ((TimeStamped) tb).getTimeStamp());
|
||||
assertEquals(3, nop.getCount());
|
||||
assertEquals(3, nop.getCount());
|
||||
assertEquals("introductionUsingJdk", tb.getName());
|
||||
|
||||
ITestBean tb2 = (ITestBean) beanFactory.getBean("second-introductionUsingJdk");
|
||||
@@ -124,10 +124,10 @@ public class BeanNameAutoProxyCreatorTests {
|
||||
assertEquals(age, tb.getAge());
|
||||
assertTrue("Introduction was made", tb instanceof TimeStamped);
|
||||
assertEquals(0, ((TimeStamped) tb).getTimeStamp());
|
||||
assertEquals(3, nop.getCount());
|
||||
|
||||
assertEquals(3, nop.getCount());
|
||||
|
||||
ITestBean tb2 = (ITestBean) beanFactory.getBean("second-introductionUsingJdk");
|
||||
|
||||
|
||||
// Check two per-instance mixins were distinct
|
||||
Lockable lockable1 = (Lockable) tb;
|
||||
Lockable lockable2 = (Lockable) tb2;
|
||||
@@ -194,7 +194,7 @@ public class BeanNameAutoProxyCreatorTests {
|
||||
tb.setAge(age);
|
||||
assertEquals(age, tb.getAge());
|
||||
assertEquals(2, nop.getCount());
|
||||
assertEquals(2, cba.getCalls());
|
||||
assertEquals(2, cba.getCalls());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -39,10 +39,10 @@ import org.springframework.util.SerializationTestUtils;
|
||||
* @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);
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
/*
|
||||
* 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.
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
/*
|
||||
* 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.
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
|
||||
/*
|
||||
* 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.
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
/*
|
||||
* 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.
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
/*
|
||||
* 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.
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
/*
|
||||
* 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.
|
||||
|
||||
@@ -33,7 +33,7 @@ import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
|
||||
*/
|
||||
public class DummyFactory
|
||||
implements FactoryBean, BeanNameAware, BeanFactoryAware, InitializingBean, DisposableBean {
|
||||
|
||||
|
||||
public static final String SINGLETON_NAME = "Factory singleton";
|
||||
|
||||
private static boolean prototypeCreated;
|
||||
@@ -125,7 +125,7 @@ public class DummyFactory
|
||||
}
|
||||
this.initialized = true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Was this initialized by invocation of the
|
||||
* afterPropertiesSet() method from the InitializingBean interface?
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
/*
|
||||
* 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.
|
||||
@@ -27,17 +27,17 @@ import java.util.Set;
|
||||
* @since 05.06.2003
|
||||
*/
|
||||
public class HasMap {
|
||||
|
||||
|
||||
private Map map;
|
||||
|
||||
private Set set;
|
||||
|
||||
private Properties props;
|
||||
|
||||
|
||||
private Object[] objectArray;
|
||||
|
||||
|
||||
private Class[] classArray;
|
||||
|
||||
|
||||
private Integer[] intArray;
|
||||
|
||||
private HasMap() {
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
/*
|
||||
* 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.
|
||||
@@ -23,15 +23,15 @@ package org.springframework.beans.factory;
|
||||
*/
|
||||
public class MustBeInitialized implements InitializingBean {
|
||||
|
||||
private boolean inited;
|
||||
|
||||
private boolean inited;
|
||||
|
||||
/**
|
||||
* @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet()
|
||||
*/
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
this.inited = true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Dummy business method that will fail unless the factory
|
||||
* managed the bean's lifecycle correctly
|
||||
|
||||
@@ -32,7 +32,7 @@ public class SingletonBeanFactoryLocatorTests {
|
||||
public void testBasicFunctionality() {
|
||||
SingletonBeanFactoryLocator facLoc = new SingletonBeanFactoryLocator(
|
||||
"classpath*:" + ClassUtils.addResourcePathToPackagePath(getClass(), "ref1.xml"));
|
||||
|
||||
|
||||
basicFunctionalityTest(facLoc);
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ public class SingletonBeanFactoryLocatorTests {
|
||||
BeanFactoryLocator facLoc = SingletonBeanFactoryLocator.getInstance(
|
||||
ClassUtils.addResourcePathToPackagePath(getClass(), "ref1.xml"));
|
||||
getInstanceTest1(facLoc);
|
||||
|
||||
|
||||
facLoc = SingletonBeanFactoryLocator.getInstance(
|
||||
"classpath*:/" + ClassUtils.addResourcePathToPackagePath(getClass(), "ref1.xml"));
|
||||
getInstanceTest2(facLoc);
|
||||
@@ -84,7 +84,7 @@ public class SingletonBeanFactoryLocatorTests {
|
||||
facLoc = SingletonBeanFactoryLocator.getInstance(
|
||||
"classpath:" + ClassUtils.addResourcePathToPackagePath(getClass(), "ref1.xml"));
|
||||
getInstanceTest3(facLoc);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -103,12 +103,12 @@ public class SingletonBeanFactoryLocatorTests {
|
||||
fac = bfr3.getFactory();
|
||||
tb = (TestBean) fac.getBean("beans1.bean1");
|
||||
assertTrue(tb.getName().equals("was beans1.bean1"));
|
||||
|
||||
|
||||
BeanFactoryReference bfr4 = facLoc.useBeanFactory("a.qualified.name.which.is.an.alias");
|
||||
fac = bfr4.getFactory();
|
||||
tb = (TestBean) fac.getBean("beans1.bean1");
|
||||
assertTrue(tb.getName().equals("was beans1.bean1"));
|
||||
|
||||
|
||||
bfr.release();
|
||||
bfr3.release();
|
||||
bfr2.release();
|
||||
@@ -146,7 +146,7 @@ public class SingletonBeanFactoryLocatorTests {
|
||||
bfr4.release();
|
||||
bfr3.release();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Worker method so subclass can use it too
|
||||
*/
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
/*
|
||||
* 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.
|
||||
@@ -20,7 +20,7 @@ import java.util.List;
|
||||
|
||||
/**
|
||||
* Scrap bean for use in tests.
|
||||
*
|
||||
*
|
||||
* @author Colin Sampaleanu
|
||||
*/
|
||||
public class TestBean {
|
||||
|
||||
@@ -43,7 +43,7 @@ import org.springframework.context.support.GenericApplicationContext;
|
||||
* @since 3.0
|
||||
*/
|
||||
public class InjectAnnotationAutowireContextTests {
|
||||
|
||||
|
||||
private static final String JUERGEN = "juergen";
|
||||
|
||||
private static final String MARK = "mark";
|
||||
@@ -56,7 +56,7 @@ public class InjectAnnotationAutowireContextTests {
|
||||
cavs.addGenericArgumentValue(JUERGEN);
|
||||
RootBeanDefinition person = new RootBeanDefinition(Person.class, cavs, null);
|
||||
context.registerBeanDefinition(JUERGEN, person);
|
||||
context.registerBeanDefinition("autowired",
|
||||
context.registerBeanDefinition("autowired",
|
||||
new RootBeanDefinition(QualifiedFieldTestBean.class));
|
||||
AnnotationConfigUtils.registerAnnotationConfigProcessors(context);
|
||||
try {
|
||||
@@ -76,7 +76,7 @@ public class InjectAnnotationAutowireContextTests {
|
||||
cavs.addGenericArgumentValue(JUERGEN);
|
||||
RootBeanDefinition person = new RootBeanDefinition(Person.class, cavs, null);
|
||||
context.registerBeanDefinition(JUERGEN, person);
|
||||
context.registerBeanDefinition("autowired",
|
||||
context.registerBeanDefinition("autowired",
|
||||
new RootBeanDefinition(QualifiedMethodParameterTestBean.class));
|
||||
AnnotationConfigUtils.registerAnnotationConfigProcessors(context);
|
||||
try {
|
||||
@@ -96,7 +96,7 @@ public class InjectAnnotationAutowireContextTests {
|
||||
cavs.addGenericArgumentValue(JUERGEN);
|
||||
RootBeanDefinition person = new RootBeanDefinition(Person.class, cavs, null);
|
||||
context.registerBeanDefinition(JUERGEN, person);
|
||||
context.registerBeanDefinition("autowired",
|
||||
context.registerBeanDefinition("autowired",
|
||||
new RootBeanDefinition(QualifiedConstructorArgumentTestBean.class));
|
||||
AnnotationConfigUtils.registerAnnotationConfigProcessors(context);
|
||||
try {
|
||||
@@ -132,11 +132,11 @@ public class InjectAnnotationAutowireContextTests {
|
||||
RootBeanDefinition person = new RootBeanDefinition(Person.class, cavs, null);
|
||||
person.addQualifier(new AutowireCandidateQualifier(TestQualifier.class));
|
||||
context.registerBeanDefinition(JUERGEN, person);
|
||||
context.registerBeanDefinition("autowired",
|
||||
context.registerBeanDefinition("autowired",
|
||||
new RootBeanDefinition(QualifiedMethodParameterTestBean.class));
|
||||
AnnotationConfigUtils.registerAnnotationConfigProcessors(context);
|
||||
context.refresh();
|
||||
QualifiedMethodParameterTestBean bean =
|
||||
QualifiedMethodParameterTestBean bean =
|
||||
(QualifiedMethodParameterTestBean) context.getBean("autowired");
|
||||
assertEquals(JUERGEN, bean.getPerson().getName());
|
||||
}
|
||||
@@ -186,11 +186,11 @@ public class InjectAnnotationAutowireContextTests {
|
||||
RootBeanDefinition person = new RootBeanDefinition(Person.class, cavs, null);
|
||||
person.addQualifier(new AutowireCandidateQualifier(TestQualifier.class));
|
||||
context.registerBeanDefinition(JUERGEN, person);
|
||||
context.registerBeanDefinition("autowired",
|
||||
context.registerBeanDefinition("autowired",
|
||||
new RootBeanDefinition(QualifiedConstructorArgumentTestBean.class));
|
||||
AnnotationConfigUtils.registerAnnotationConfigProcessors(context);
|
||||
context.refresh();
|
||||
QualifiedConstructorArgumentTestBean bean =
|
||||
QualifiedConstructorArgumentTestBean bean =
|
||||
(QualifiedConstructorArgumentTestBean) context.getBean("autowired");
|
||||
assertEquals(JUERGEN, bean.getPerson().getName());
|
||||
}
|
||||
@@ -206,7 +206,7 @@ public class InjectAnnotationAutowireContextTests {
|
||||
RootBeanDefinition person2 = new RootBeanDefinition(Person.class, cavs2, null);
|
||||
context.registerBeanDefinition(JUERGEN, person1);
|
||||
context.registerBeanDefinition(MARK, person2);
|
||||
context.registerBeanDefinition("autowired",
|
||||
context.registerBeanDefinition("autowired",
|
||||
new RootBeanDefinition(QualifiedFieldTestBean.class));
|
||||
AnnotationConfigUtils.registerAnnotationConfigProcessors(context);
|
||||
try {
|
||||
@@ -230,7 +230,7 @@ public class InjectAnnotationAutowireContextTests {
|
||||
RootBeanDefinition person2 = new RootBeanDefinition(Person.class, cavs2, null);
|
||||
context.registerBeanDefinition(JUERGEN, person1);
|
||||
context.registerBeanDefinition(MARK, person2);
|
||||
context.registerBeanDefinition("autowired",
|
||||
context.registerBeanDefinition("autowired",
|
||||
new RootBeanDefinition(QualifiedMethodParameterTestBean.class));
|
||||
AnnotationConfigUtils.registerAnnotationConfigProcessors(context);
|
||||
try {
|
||||
@@ -254,7 +254,7 @@ public class InjectAnnotationAutowireContextTests {
|
||||
RootBeanDefinition person2 = new RootBeanDefinition(Person.class, cavs2, null);
|
||||
context.registerBeanDefinition(JUERGEN, person1);
|
||||
context.registerBeanDefinition(MARK, person2);
|
||||
context.registerBeanDefinition("autowired",
|
||||
context.registerBeanDefinition("autowired",
|
||||
new RootBeanDefinition(QualifiedConstructorArgumentTestBean.class));
|
||||
AnnotationConfigUtils.registerAnnotationConfigProcessors(context);
|
||||
try {
|
||||
@@ -279,7 +279,7 @@ public class InjectAnnotationAutowireContextTests {
|
||||
RootBeanDefinition person2 = new RootBeanDefinition(Person.class, cavs2, null);
|
||||
context.registerBeanDefinition(JUERGEN, person1);
|
||||
context.registerBeanDefinition(MARK, person2);
|
||||
context.registerBeanDefinition("autowired",
|
||||
context.registerBeanDefinition("autowired",
|
||||
new RootBeanDefinition(QualifiedFieldTestBean.class));
|
||||
AnnotationConfigUtils.registerAnnotationConfigProcessors(context);
|
||||
context.refresh();
|
||||
@@ -299,11 +299,11 @@ public class InjectAnnotationAutowireContextTests {
|
||||
RootBeanDefinition person2 = new RootBeanDefinition(Person.class, cavs2, null);
|
||||
context.registerBeanDefinition(JUERGEN, person1);
|
||||
context.registerBeanDefinition(MARK, person2);
|
||||
context.registerBeanDefinition("autowired",
|
||||
context.registerBeanDefinition("autowired",
|
||||
new RootBeanDefinition(QualifiedMethodParameterTestBean.class));
|
||||
AnnotationConfigUtils.registerAnnotationConfigProcessors(context);
|
||||
context.refresh();
|
||||
QualifiedMethodParameterTestBean bean =
|
||||
QualifiedMethodParameterTestBean bean =
|
||||
(QualifiedMethodParameterTestBean) context.getBean("autowired");
|
||||
assertEquals(JUERGEN, bean.getPerson().getName());
|
||||
}
|
||||
@@ -320,11 +320,11 @@ public class InjectAnnotationAutowireContextTests {
|
||||
RootBeanDefinition person2 = new RootBeanDefinition(Person.class, cavs2, null);
|
||||
context.registerBeanDefinition(JUERGEN, person1);
|
||||
context.registerBeanDefinition(MARK, person2);
|
||||
context.registerBeanDefinition("autowired",
|
||||
context.registerBeanDefinition("autowired",
|
||||
new RootBeanDefinition(QualifiedConstructorArgumentTestBean.class));
|
||||
AnnotationConfigUtils.registerAnnotationConfigProcessors(context);
|
||||
context.refresh();
|
||||
QualifiedConstructorArgumentTestBean bean =
|
||||
QualifiedConstructorArgumentTestBean bean =
|
||||
(QualifiedConstructorArgumentTestBean) context.getBean("autowired");
|
||||
assertEquals(JUERGEN, bean.getPerson().getName());
|
||||
}
|
||||
@@ -342,11 +342,11 @@ public class InjectAnnotationAutowireContextTests {
|
||||
RootBeanDefinition person2 = new RootBeanDefinition(Person.class, cavs2, null);
|
||||
context.registerBeanDefinition(JUERGEN, person1);
|
||||
context.registerBeanDefinition(MARK, person2);
|
||||
context.registerBeanDefinition("autowired",
|
||||
context.registerBeanDefinition("autowired",
|
||||
new RootBeanDefinition(QualifiedFieldWithDefaultValueTestBean.class));
|
||||
AnnotationConfigUtils.registerAnnotationConfigProcessors(context);
|
||||
context.refresh();
|
||||
QualifiedFieldWithDefaultValueTestBean bean =
|
||||
QualifiedFieldWithDefaultValueTestBean bean =
|
||||
(QualifiedFieldWithDefaultValueTestBean) context.getBean("autowired");
|
||||
assertEquals(JUERGEN, bean.getPerson().getName());
|
||||
}
|
||||
@@ -364,7 +364,7 @@ public class InjectAnnotationAutowireContextTests {
|
||||
RootBeanDefinition person2 = new RootBeanDefinition(Person.class, cavs2, null);
|
||||
context.registerBeanDefinition(JUERGEN, person1);
|
||||
context.registerBeanDefinition(MARK, person2);
|
||||
context.registerBeanDefinition("autowired",
|
||||
context.registerBeanDefinition("autowired",
|
||||
new RootBeanDefinition(QualifiedFieldWithDefaultValueTestBean.class));
|
||||
AnnotationConfigUtils.registerAnnotationConfigProcessors(context);
|
||||
try {
|
||||
@@ -390,11 +390,11 @@ public class InjectAnnotationAutowireContextTests {
|
||||
RootBeanDefinition person2 = new RootBeanDefinition(Person.class, cavs2, null);
|
||||
context.registerBeanDefinition(JUERGEN, person1);
|
||||
context.registerBeanDefinition(MARK, person2);
|
||||
context.registerBeanDefinition("autowired",
|
||||
context.registerBeanDefinition("autowired",
|
||||
new RootBeanDefinition(QualifiedFieldWithDefaultValueTestBean.class));
|
||||
AnnotationConfigUtils.registerAnnotationConfigProcessors(context);
|
||||
context.refresh();
|
||||
QualifiedFieldWithDefaultValueTestBean bean =
|
||||
QualifiedFieldWithDefaultValueTestBean bean =
|
||||
(QualifiedFieldWithDefaultValueTestBean) context.getBean("autowired");
|
||||
assertEquals(JUERGEN, bean.getPerson().getName());
|
||||
}
|
||||
@@ -416,11 +416,11 @@ public class InjectAnnotationAutowireContextTests {
|
||||
person2.addQualifier(qualifier2);
|
||||
context.registerBeanDefinition(JUERGEN, person1);
|
||||
context.registerBeanDefinition(MARK, person2);
|
||||
context.registerBeanDefinition("autowired",
|
||||
context.registerBeanDefinition("autowired",
|
||||
new RootBeanDefinition(QualifiedFieldWithMultipleAttributesTestBean.class));
|
||||
AnnotationConfigUtils.registerAnnotationConfigProcessors(context);
|
||||
context.refresh();
|
||||
QualifiedFieldWithMultipleAttributesTestBean bean =
|
||||
QualifiedFieldWithMultipleAttributesTestBean bean =
|
||||
(QualifiedFieldWithMultipleAttributesTestBean) context.getBean("autowired");
|
||||
assertEquals(MARK, bean.getPerson().getName());
|
||||
}
|
||||
@@ -443,7 +443,7 @@ public class InjectAnnotationAutowireContextTests {
|
||||
person2.addQualifier(qualifier2);
|
||||
context.registerBeanDefinition(JUERGEN, person1);
|
||||
context.registerBeanDefinition(MARK, person2);
|
||||
context.registerBeanDefinition("autowired",
|
||||
context.registerBeanDefinition("autowired",
|
||||
new RootBeanDefinition(QualifiedFieldWithMultipleAttributesTestBean.class));
|
||||
AnnotationConfigUtils.registerAnnotationConfigProcessors(context);
|
||||
try {
|
||||
@@ -474,11 +474,11 @@ public class InjectAnnotationAutowireContextTests {
|
||||
person2.addQualifier(qualifier2);
|
||||
context.registerBeanDefinition(JUERGEN, person1);
|
||||
context.registerBeanDefinition(MARK, person2);
|
||||
context.registerBeanDefinition("autowired",
|
||||
context.registerBeanDefinition("autowired",
|
||||
new RootBeanDefinition(QualifiedFieldWithMultipleAttributesTestBean.class));
|
||||
AnnotationConfigUtils.registerAnnotationConfigProcessors(context);
|
||||
context.refresh();
|
||||
QualifiedFieldWithMultipleAttributesTestBean bean =
|
||||
QualifiedFieldWithMultipleAttributesTestBean bean =
|
||||
(QualifiedFieldWithMultipleAttributesTestBean) context.getBean("autowired");
|
||||
assertEquals(MARK, bean.getPerson().getName());
|
||||
}
|
||||
@@ -501,7 +501,7 @@ public class InjectAnnotationAutowireContextTests {
|
||||
person2.addQualifier(qualifier2);
|
||||
context.registerBeanDefinition(JUERGEN, person1);
|
||||
context.registerBeanDefinition(MARK, person2);
|
||||
context.registerBeanDefinition("autowired",
|
||||
context.registerBeanDefinition("autowired",
|
||||
new RootBeanDefinition(QualifiedFieldWithMultipleAttributesTestBean.class));
|
||||
AnnotationConfigUtils.registerAnnotationConfigProcessors(context);
|
||||
try {
|
||||
@@ -527,7 +527,7 @@ public class InjectAnnotationAutowireContextTests {
|
||||
person2.addQualifier(new AutowireCandidateQualifier(Qualifier.class, "juergen"));
|
||||
context.registerBeanDefinition("juergen1", person1);
|
||||
context.registerBeanDefinition("juergen2", person2);
|
||||
context.registerBeanDefinition("autowired",
|
||||
context.registerBeanDefinition("autowired",
|
||||
new RootBeanDefinition(QualifiedConstructorArgumentWithBaseQualifierNonDefaultValueTestBean.class));
|
||||
AnnotationConfigUtils.registerAnnotationConfigProcessors(context);
|
||||
try {
|
||||
@@ -546,7 +546,7 @@ public class InjectAnnotationAutowireContextTests {
|
||||
@Inject
|
||||
@TestQualifier
|
||||
private Person person;
|
||||
|
||||
|
||||
public Person getPerson() {
|
||||
return this.person;
|
||||
}
|
||||
@@ -556,7 +556,7 @@ public class InjectAnnotationAutowireContextTests {
|
||||
private static class QualifiedMethodParameterTestBean {
|
||||
|
||||
private Person person;
|
||||
|
||||
|
||||
@Inject
|
||||
public void setPerson(@TestQualifier Person person) {
|
||||
this.person = person;
|
||||
@@ -566,17 +566,17 @@ public class InjectAnnotationAutowireContextTests {
|
||||
return this.person;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private static class QualifiedConstructorArgumentTestBean {
|
||||
|
||||
private Person person;
|
||||
|
||||
|
||||
@Inject
|
||||
public QualifiedConstructorArgumentTestBean(@TestQualifier Person person) {
|
||||
this.person = person;
|
||||
}
|
||||
|
||||
|
||||
public Person getPerson() {
|
||||
return this.person;
|
||||
}
|
||||
@@ -589,7 +589,7 @@ public class InjectAnnotationAutowireContextTests {
|
||||
@Inject
|
||||
@TestQualifierWithDefaultValue
|
||||
private Person person;
|
||||
|
||||
|
||||
public Person getPerson() {
|
||||
return this.person;
|
||||
}
|
||||
@@ -601,7 +601,7 @@ public class InjectAnnotationAutowireContextTests {
|
||||
@Inject
|
||||
@TestQualifierWithMultipleAttributes(number=123)
|
||||
private Person person;
|
||||
|
||||
|
||||
public Person getPerson() {
|
||||
return this.person;
|
||||
}
|
||||
@@ -612,7 +612,7 @@ public class InjectAnnotationAutowireContextTests {
|
||||
|
||||
@Inject
|
||||
private Person person;
|
||||
|
||||
|
||||
public Person getPerson() {
|
||||
return this.person;
|
||||
}
|
||||
@@ -628,7 +628,7 @@ public class InjectAnnotationAutowireContextTests {
|
||||
@Named("juergen") Person person) {
|
||||
this.person = person;
|
||||
}
|
||||
|
||||
|
||||
public Person getPerson() {
|
||||
return this.person;
|
||||
}
|
||||
|
||||
@@ -38,13 +38,13 @@ import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Integration tests for handling {@link Qualifier} annotations.
|
||||
*
|
||||
*
|
||||
* @author Mark Fisher
|
||||
* @author Juergen Hoeller
|
||||
* @author Chris Beams
|
||||
*/
|
||||
public class QualifierAnnotationAutowireContextTests {
|
||||
|
||||
|
||||
private static final String JUERGEN = "juergen";
|
||||
|
||||
private static final String MARK = "mark";
|
||||
@@ -57,7 +57,7 @@ public class QualifierAnnotationAutowireContextTests {
|
||||
cavs.addGenericArgumentValue(JUERGEN);
|
||||
RootBeanDefinition person = new RootBeanDefinition(Person.class, cavs, null);
|
||||
context.registerBeanDefinition(JUERGEN, person);
|
||||
context.registerBeanDefinition("autowired",
|
||||
context.registerBeanDefinition("autowired",
|
||||
new RootBeanDefinition(QualifiedFieldTestBean.class));
|
||||
AnnotationConfigUtils.registerAnnotationConfigProcessors(context);
|
||||
try {
|
||||
@@ -77,7 +77,7 @@ public class QualifierAnnotationAutowireContextTests {
|
||||
cavs.addGenericArgumentValue(JUERGEN);
|
||||
RootBeanDefinition person = new RootBeanDefinition(Person.class, cavs, null);
|
||||
context.registerBeanDefinition(JUERGEN, person);
|
||||
context.registerBeanDefinition("autowired",
|
||||
context.registerBeanDefinition("autowired",
|
||||
new RootBeanDefinition(QualifiedMethodParameterTestBean.class));
|
||||
AnnotationConfigUtils.registerAnnotationConfigProcessors(context);
|
||||
try {
|
||||
@@ -97,7 +97,7 @@ public class QualifierAnnotationAutowireContextTests {
|
||||
cavs.addGenericArgumentValue(JUERGEN);
|
||||
RootBeanDefinition person = new RootBeanDefinition(Person.class, cavs, null);
|
||||
context.registerBeanDefinition(JUERGEN, person);
|
||||
context.registerBeanDefinition("autowired",
|
||||
context.registerBeanDefinition("autowired",
|
||||
new RootBeanDefinition(QualifiedConstructorArgumentTestBean.class));
|
||||
AnnotationConfigUtils.registerAnnotationConfigProcessors(context);
|
||||
try {
|
||||
@@ -133,11 +133,11 @@ public class QualifierAnnotationAutowireContextTests {
|
||||
RootBeanDefinition person = new RootBeanDefinition(Person.class, cavs, null);
|
||||
person.addQualifier(new AutowireCandidateQualifier(TestQualifier.class));
|
||||
context.registerBeanDefinition(JUERGEN, person);
|
||||
context.registerBeanDefinition("autowired",
|
||||
context.registerBeanDefinition("autowired",
|
||||
new RootBeanDefinition(QualifiedMethodParameterTestBean.class));
|
||||
AnnotationConfigUtils.registerAnnotationConfigProcessors(context);
|
||||
context.refresh();
|
||||
QualifiedMethodParameterTestBean bean =
|
||||
QualifiedMethodParameterTestBean bean =
|
||||
(QualifiedMethodParameterTestBean) context.getBean("autowired");
|
||||
assertEquals(JUERGEN, bean.getPerson().getName());
|
||||
}
|
||||
@@ -187,11 +187,11 @@ public class QualifierAnnotationAutowireContextTests {
|
||||
RootBeanDefinition person = new RootBeanDefinition(Person.class, cavs, null);
|
||||
person.addQualifier(new AutowireCandidateQualifier(TestQualifier.class));
|
||||
context.registerBeanDefinition(JUERGEN, person);
|
||||
context.registerBeanDefinition("autowired",
|
||||
context.registerBeanDefinition("autowired",
|
||||
new RootBeanDefinition(QualifiedConstructorArgumentTestBean.class));
|
||||
AnnotationConfigUtils.registerAnnotationConfigProcessors(context);
|
||||
context.refresh();
|
||||
QualifiedConstructorArgumentTestBean bean =
|
||||
QualifiedConstructorArgumentTestBean bean =
|
||||
(QualifiedConstructorArgumentTestBean) context.getBean("autowired");
|
||||
assertEquals(JUERGEN, bean.getPerson().getName());
|
||||
}
|
||||
@@ -207,7 +207,7 @@ public class QualifierAnnotationAutowireContextTests {
|
||||
RootBeanDefinition person2 = new RootBeanDefinition(Person.class, cavs2, null);
|
||||
context.registerBeanDefinition(JUERGEN, person1);
|
||||
context.registerBeanDefinition(MARK, person2);
|
||||
context.registerBeanDefinition("autowired",
|
||||
context.registerBeanDefinition("autowired",
|
||||
new RootBeanDefinition(QualifiedFieldTestBean.class));
|
||||
AnnotationConfigUtils.registerAnnotationConfigProcessors(context);
|
||||
try {
|
||||
@@ -231,7 +231,7 @@ public class QualifierAnnotationAutowireContextTests {
|
||||
RootBeanDefinition person2 = new RootBeanDefinition(Person.class, cavs2, null);
|
||||
context.registerBeanDefinition(JUERGEN, person1);
|
||||
context.registerBeanDefinition(MARK, person2);
|
||||
context.registerBeanDefinition("autowired",
|
||||
context.registerBeanDefinition("autowired",
|
||||
new RootBeanDefinition(QualifiedMethodParameterTestBean.class));
|
||||
AnnotationConfigUtils.registerAnnotationConfigProcessors(context);
|
||||
try {
|
||||
@@ -255,7 +255,7 @@ public class QualifierAnnotationAutowireContextTests {
|
||||
RootBeanDefinition person2 = new RootBeanDefinition(Person.class, cavs2, null);
|
||||
context.registerBeanDefinition(JUERGEN, person1);
|
||||
context.registerBeanDefinition(MARK, person2);
|
||||
context.registerBeanDefinition("autowired",
|
||||
context.registerBeanDefinition("autowired",
|
||||
new RootBeanDefinition(QualifiedConstructorArgumentTestBean.class));
|
||||
AnnotationConfigUtils.registerAnnotationConfigProcessors(context);
|
||||
try {
|
||||
@@ -320,11 +320,11 @@ public class QualifierAnnotationAutowireContextTests {
|
||||
RootBeanDefinition person2 = new RootBeanDefinition(Person.class, cavs2, null);
|
||||
context.registerBeanDefinition(JUERGEN, person1);
|
||||
context.registerBeanDefinition(MARK, person2);
|
||||
context.registerBeanDefinition("autowired",
|
||||
context.registerBeanDefinition("autowired",
|
||||
new RootBeanDefinition(QualifiedMethodParameterTestBean.class));
|
||||
AnnotationConfigUtils.registerAnnotationConfigProcessors(context);
|
||||
context.refresh();
|
||||
QualifiedMethodParameterTestBean bean =
|
||||
QualifiedMethodParameterTestBean bean =
|
||||
(QualifiedMethodParameterTestBean) context.getBean("autowired");
|
||||
assertEquals(JUERGEN, bean.getPerson().getName());
|
||||
}
|
||||
@@ -341,11 +341,11 @@ public class QualifierAnnotationAutowireContextTests {
|
||||
RootBeanDefinition person2 = new RootBeanDefinition(Person.class, cavs2, null);
|
||||
context.registerBeanDefinition(JUERGEN, person1);
|
||||
context.registerBeanDefinition(MARK, person2);
|
||||
context.registerBeanDefinition("autowired",
|
||||
context.registerBeanDefinition("autowired",
|
||||
new RootBeanDefinition(QualifiedConstructorArgumentTestBean.class));
|
||||
AnnotationConfigUtils.registerAnnotationConfigProcessors(context);
|
||||
context.refresh();
|
||||
QualifiedConstructorArgumentTestBean bean =
|
||||
QualifiedConstructorArgumentTestBean bean =
|
||||
(QualifiedConstructorArgumentTestBean) context.getBean("autowired");
|
||||
assertEquals(JUERGEN, bean.getPerson().getName());
|
||||
}
|
||||
@@ -363,11 +363,11 @@ public class QualifierAnnotationAutowireContextTests {
|
||||
RootBeanDefinition person2 = new RootBeanDefinition(Person.class, cavs2, null);
|
||||
context.registerBeanDefinition(JUERGEN, person1);
|
||||
context.registerBeanDefinition(MARK, person2);
|
||||
context.registerBeanDefinition("autowired",
|
||||
context.registerBeanDefinition("autowired",
|
||||
new RootBeanDefinition(QualifiedFieldWithDefaultValueTestBean.class));
|
||||
AnnotationConfigUtils.registerAnnotationConfigProcessors(context);
|
||||
context.refresh();
|
||||
QualifiedFieldWithDefaultValueTestBean bean =
|
||||
QualifiedFieldWithDefaultValueTestBean bean =
|
||||
(QualifiedFieldWithDefaultValueTestBean) context.getBean("autowired");
|
||||
assertEquals(JUERGEN, bean.getPerson().getName());
|
||||
}
|
||||
@@ -385,7 +385,7 @@ public class QualifierAnnotationAutowireContextTests {
|
||||
RootBeanDefinition person2 = new RootBeanDefinition(Person.class, cavs2, null);
|
||||
context.registerBeanDefinition(JUERGEN, person1);
|
||||
context.registerBeanDefinition(MARK, person2);
|
||||
context.registerBeanDefinition("autowired",
|
||||
context.registerBeanDefinition("autowired",
|
||||
new RootBeanDefinition(QualifiedFieldWithDefaultValueTestBean.class));
|
||||
AnnotationConfigUtils.registerAnnotationConfigProcessors(context);
|
||||
try {
|
||||
@@ -411,11 +411,11 @@ public class QualifierAnnotationAutowireContextTests {
|
||||
RootBeanDefinition person2 = new RootBeanDefinition(Person.class, cavs2, null);
|
||||
context.registerBeanDefinition(JUERGEN, person1);
|
||||
context.registerBeanDefinition(MARK, person2);
|
||||
context.registerBeanDefinition("autowired",
|
||||
context.registerBeanDefinition("autowired",
|
||||
new RootBeanDefinition(QualifiedFieldWithDefaultValueTestBean.class));
|
||||
AnnotationConfigUtils.registerAnnotationConfigProcessors(context);
|
||||
context.refresh();
|
||||
QualifiedFieldWithDefaultValueTestBean bean =
|
||||
QualifiedFieldWithDefaultValueTestBean bean =
|
||||
(QualifiedFieldWithDefaultValueTestBean) context.getBean("autowired");
|
||||
assertEquals(JUERGEN, bean.getPerson().getName());
|
||||
}
|
||||
@@ -437,11 +437,11 @@ public class QualifierAnnotationAutowireContextTests {
|
||||
person2.addQualifier(qualifier2);
|
||||
context.registerBeanDefinition(JUERGEN, person1);
|
||||
context.registerBeanDefinition(MARK, person2);
|
||||
context.registerBeanDefinition("autowired",
|
||||
context.registerBeanDefinition("autowired",
|
||||
new RootBeanDefinition(QualifiedFieldWithMultipleAttributesTestBean.class));
|
||||
AnnotationConfigUtils.registerAnnotationConfigProcessors(context);
|
||||
context.refresh();
|
||||
QualifiedFieldWithMultipleAttributesTestBean bean =
|
||||
QualifiedFieldWithMultipleAttributesTestBean bean =
|
||||
(QualifiedFieldWithMultipleAttributesTestBean) context.getBean("autowired");
|
||||
assertEquals(MARK, bean.getPerson().getName());
|
||||
}
|
||||
@@ -464,7 +464,7 @@ public class QualifierAnnotationAutowireContextTests {
|
||||
person2.addQualifier(qualifier2);
|
||||
context.registerBeanDefinition(JUERGEN, person1);
|
||||
context.registerBeanDefinition(MARK, person2);
|
||||
context.registerBeanDefinition("autowired",
|
||||
context.registerBeanDefinition("autowired",
|
||||
new RootBeanDefinition(QualifiedFieldWithMultipleAttributesTestBean.class));
|
||||
AnnotationConfigUtils.registerAnnotationConfigProcessors(context);
|
||||
try {
|
||||
@@ -495,11 +495,11 @@ public class QualifierAnnotationAutowireContextTests {
|
||||
person2.addQualifier(qualifier2);
|
||||
context.registerBeanDefinition(JUERGEN, person1);
|
||||
context.registerBeanDefinition(MARK, person2);
|
||||
context.registerBeanDefinition("autowired",
|
||||
context.registerBeanDefinition("autowired",
|
||||
new RootBeanDefinition(QualifiedFieldWithMultipleAttributesTestBean.class));
|
||||
AnnotationConfigUtils.registerAnnotationConfigProcessors(context);
|
||||
context.refresh();
|
||||
QualifiedFieldWithMultipleAttributesTestBean bean =
|
||||
QualifiedFieldWithMultipleAttributesTestBean bean =
|
||||
(QualifiedFieldWithMultipleAttributesTestBean) context.getBean("autowired");
|
||||
assertEquals(MARK, bean.getPerson().getName());
|
||||
}
|
||||
@@ -522,7 +522,7 @@ public class QualifierAnnotationAutowireContextTests {
|
||||
person2.addQualifier(qualifier2);
|
||||
context.registerBeanDefinition(JUERGEN, person1);
|
||||
context.registerBeanDefinition(MARK, person2);
|
||||
context.registerBeanDefinition("autowired",
|
||||
context.registerBeanDefinition("autowired",
|
||||
new RootBeanDefinition(QualifiedFieldWithMultipleAttributesTestBean.class));
|
||||
AnnotationConfigUtils.registerAnnotationConfigProcessors(context);
|
||||
try {
|
||||
@@ -547,11 +547,11 @@ public class QualifierAnnotationAutowireContextTests {
|
||||
person2.addQualifier(new AutowireCandidateQualifier(Qualifier.class));
|
||||
context.registerBeanDefinition(JUERGEN, person1);
|
||||
context.registerBeanDefinition(MARK, person2);
|
||||
context.registerBeanDefinition("autowired",
|
||||
context.registerBeanDefinition("autowired",
|
||||
new RootBeanDefinition(QualifiedFieldWithBaseQualifierDefaultValueTestBean.class));
|
||||
AnnotationConfigUtils.registerAnnotationConfigProcessors(context);
|
||||
context.refresh();
|
||||
QualifiedFieldWithBaseQualifierDefaultValueTestBean bean =
|
||||
QualifiedFieldWithBaseQualifierDefaultValueTestBean bean =
|
||||
(QualifiedFieldWithBaseQualifierDefaultValueTestBean) context.getBean("autowired");
|
||||
assertEquals(MARK, bean.getPerson().getName());
|
||||
}
|
||||
@@ -569,11 +569,11 @@ public class QualifierAnnotationAutowireContextTests {
|
||||
person2.addQualifier(new AutowireCandidateQualifier(Qualifier.class, "not really juergen"));
|
||||
context.registerBeanDefinition("juergen1", person1);
|
||||
context.registerBeanDefinition("juergen2", person2);
|
||||
context.registerBeanDefinition("autowired",
|
||||
context.registerBeanDefinition("autowired",
|
||||
new RootBeanDefinition(QualifiedConstructorArgumentWithBaseQualifierNonDefaultValueTestBean.class));
|
||||
AnnotationConfigUtils.registerAnnotationConfigProcessors(context);
|
||||
context.refresh();
|
||||
QualifiedConstructorArgumentWithBaseQualifierNonDefaultValueTestBean bean =
|
||||
QualifiedConstructorArgumentWithBaseQualifierNonDefaultValueTestBean bean =
|
||||
(QualifiedConstructorArgumentWithBaseQualifierNonDefaultValueTestBean) context.getBean("autowired");
|
||||
assertEquals("the real juergen", bean.getPerson().getName());
|
||||
}
|
||||
@@ -591,7 +591,7 @@ public class QualifierAnnotationAutowireContextTests {
|
||||
person2.addQualifier(new AutowireCandidateQualifier(Qualifier.class, "juergen"));
|
||||
context.registerBeanDefinition("juergen1", person1);
|
||||
context.registerBeanDefinition("juergen2", person2);
|
||||
context.registerBeanDefinition("autowired",
|
||||
context.registerBeanDefinition("autowired",
|
||||
new RootBeanDefinition(QualifiedConstructorArgumentWithBaseQualifierNonDefaultValueTestBean.class));
|
||||
AnnotationConfigUtils.registerAnnotationConfigProcessors(context);
|
||||
try {
|
||||
@@ -610,7 +610,7 @@ public class QualifierAnnotationAutowireContextTests {
|
||||
@Autowired
|
||||
@TestQualifier
|
||||
private Person person;
|
||||
|
||||
|
||||
public Person getPerson() {
|
||||
return this.person;
|
||||
}
|
||||
@@ -638,7 +638,7 @@ public class QualifierAnnotationAutowireContextTests {
|
||||
private static class QualifiedMethodParameterTestBean {
|
||||
|
||||
private Person person;
|
||||
|
||||
|
||||
@Autowired
|
||||
public void setPerson(@TestQualifier Person person) {
|
||||
this.person = person;
|
||||
@@ -648,17 +648,17 @@ public class QualifierAnnotationAutowireContextTests {
|
||||
return this.person;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private static class QualifiedConstructorArgumentTestBean {
|
||||
|
||||
private Person person;
|
||||
|
||||
|
||||
@Autowired
|
||||
public QualifiedConstructorArgumentTestBean(@TestQualifier Person person) {
|
||||
this.person = person;
|
||||
}
|
||||
|
||||
|
||||
public Person getPerson() {
|
||||
return this.person;
|
||||
}
|
||||
@@ -671,7 +671,7 @@ public class QualifierAnnotationAutowireContextTests {
|
||||
@Autowired
|
||||
@TestQualifierWithDefaultValue
|
||||
private Person person;
|
||||
|
||||
|
||||
public Person getPerson() {
|
||||
return this.person;
|
||||
}
|
||||
@@ -683,7 +683,7 @@ public class QualifierAnnotationAutowireContextTests {
|
||||
@Autowired
|
||||
@TestQualifierWithMultipleAttributes(number=123)
|
||||
private Person person;
|
||||
|
||||
|
||||
public Person getPerson() {
|
||||
return this.person;
|
||||
}
|
||||
@@ -695,7 +695,7 @@ public class QualifierAnnotationAutowireContextTests {
|
||||
@Autowired
|
||||
@Qualifier
|
||||
private Person person;
|
||||
|
||||
|
||||
public Person getPerson() {
|
||||
return this.person;
|
||||
}
|
||||
@@ -711,7 +711,7 @@ public class QualifierAnnotationAutowireContextTests {
|
||||
@Qualifier("juergen") Person person) {
|
||||
this.person = person;
|
||||
}
|
||||
|
||||
|
||||
public Person getPerson() {
|
||||
return this.person;
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
/*
|
||||
* 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.
|
||||
@@ -22,7 +22,7 @@ import org.springframework.beans.factory.BeanFactoryAware;
|
||||
|
||||
/**
|
||||
* Simple bean used to test dependency checking.
|
||||
*
|
||||
*
|
||||
* Note: would be defined within {@link XmlBeanFactoryTestTypes}, but must be a public type
|
||||
* in order to satisfy test dependencies.
|
||||
*
|
||||
@@ -31,11 +31,11 @@ import org.springframework.beans.factory.BeanFactoryAware;
|
||||
* @since 04.09.2003
|
||||
*/
|
||||
public final class DependenciesBean implements BeanFactoryAware {
|
||||
|
||||
|
||||
private int age;
|
||||
|
||||
|
||||
private String name;
|
||||
|
||||
|
||||
private TestBean spouse;
|
||||
|
||||
private BeanFactory beanFactory;
|
||||
|
||||
@@ -33,10 +33,10 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
* @author Chris Beams
|
||||
*/
|
||||
public final class LookupMethodWrappedByCglibProxyTests {
|
||||
|
||||
|
||||
private static final Class<?> CLASS = LookupMethodWrappedByCglibProxyTests.class;
|
||||
private static final String CLASSNAME = CLASS.getSimpleName();
|
||||
|
||||
|
||||
private static final String CONTEXT = CLASSNAME + "-context.xml";
|
||||
|
||||
private ApplicationContext applicationContext;
|
||||
|
||||
@@ -120,7 +120,7 @@ public final class QualifierAnnotationTests {
|
||||
context.refresh();
|
||||
QualifiedByAliasTestBean testBean = (QualifiedByAliasTestBean) context.getBean("testBean");
|
||||
Person person = testBean.getStooge();
|
||||
assertEquals("LarryBean", person.getName());
|
||||
assertEquals("LarryBean", person.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -63,18 +63,18 @@ import org.springframework.core.io.Resource;
|
||||
|
||||
/**
|
||||
* Unit tests for custom XML namespace handler implementations.
|
||||
*
|
||||
*
|
||||
* @author Rob Harrop
|
||||
* @author Rick Evans
|
||||
* @author Chris Beams
|
||||
* @author Juergen Hoeller
|
||||
*/
|
||||
public class CustomNamespaceHandlerTests {
|
||||
|
||||
|
||||
private static final Class<?> CLASS = CustomNamespaceHandlerTests.class;
|
||||
private static final String CLASSNAME = CLASS.getSimpleName();
|
||||
private static final String FQ_PATH = "org/springframework/beans/factory/xml/support";
|
||||
|
||||
|
||||
private static final String NS_PROPS = format("%s/%s.properties", FQ_PATH, CLASSNAME);
|
||||
private static final String NS_XML = format("%s/%s-context.xml", FQ_PATH, CLASSNAME);
|
||||
private static final String TEST_XSD = format("%s/%s.xsd", FQ_PATH, CLASSNAME);
|
||||
@@ -211,7 +211,7 @@ public class CustomNamespaceHandlerTests {
|
||||
|
||||
/**
|
||||
* Custom namespace handler implementation.
|
||||
*
|
||||
*
|
||||
* @author Rob Harrop
|
||||
*/
|
||||
final class TestNamespaceHandler extends NamespaceHandlerSupport {
|
||||
|
||||
@@ -18,7 +18,7 @@ package org.springframework.cache.config;
|
||||
|
||||
/**
|
||||
* Basic service interface.
|
||||
*
|
||||
*
|
||||
* @author Costin Leau
|
||||
*/
|
||||
public interface CacheableService<T> {
|
||||
@@ -59,11 +59,11 @@ public interface CacheableService<T> {
|
||||
|
||||
// multi annotations
|
||||
T multiCache(Object arg1);
|
||||
|
||||
|
||||
T multiEvict(Object arg1);
|
||||
|
||||
T multiCacheAndEvict(Object arg1);
|
||||
|
||||
|
||||
T multiConditionalCacheAndEvict(Object arg1);
|
||||
|
||||
T multiUpdate(Object arg1);
|
||||
|
||||
@@ -25,7 +25,7 @@ import org.springframework.cache.annotation.Caching;
|
||||
|
||||
/**
|
||||
* Simple cacheable service
|
||||
*
|
||||
*
|
||||
* @author Costin Leau
|
||||
*/
|
||||
public class DefaultCacheableService implements CacheableService<Long> {
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
/*
|
||||
* 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.
|
||||
@@ -19,7 +19,7 @@ package org.springframework.context;
|
||||
import java.util.Locale;
|
||||
|
||||
public class ACATester implements ApplicationContextAware {
|
||||
|
||||
|
||||
private ApplicationContext ac;
|
||||
|
||||
public void setApplicationContext(ApplicationContext ctx) throws ApplicationContextException {
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
/*
|
||||
* 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.
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
/*
|
||||
* 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.
|
||||
@@ -22,12 +22,12 @@ import org.springframework.beans.factory.LifecycleBean;
|
||||
|
||||
/**
|
||||
* Simple bean to test ApplicationContext lifecycle methods for beans
|
||||
*
|
||||
*
|
||||
* @author Colin Sampaleanu
|
||||
* @since 03.07.2004
|
||||
*/
|
||||
public class LifecycleContextBean extends LifecycleBean implements ApplicationContextAware {
|
||||
|
||||
|
||||
protected ApplicationContext owningContext;
|
||||
|
||||
public void setBeanFactory(BeanFactory beanFactory) {
|
||||
@@ -35,18 +35,18 @@ public class LifecycleContextBean extends LifecycleBean implements ApplicationCo
|
||||
if (this.owningContext != null)
|
||||
throw new RuntimeException("Factory called setBeanFactory after setApplicationContext");
|
||||
}
|
||||
|
||||
|
||||
public void afterPropertiesSet() {
|
||||
super.afterPropertiesSet();
|
||||
if (this.owningContext == null)
|
||||
throw new RuntimeException("Factory didn't call setAppliationContext before afterPropertiesSet on lifecycle bean");
|
||||
}
|
||||
|
||||
|
||||
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
||||
if (this.owningFactory == null)
|
||||
throw new RuntimeException("Factory called setApplicationContext before setBeanFactory");
|
||||
|
||||
|
||||
this.owningContext = applicationContext;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
/*
|
||||
* 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.
|
||||
@@ -24,12 +24,12 @@ import org.springframework.context.ConfigurableApplicationContext;
|
||||
|
||||
/**
|
||||
* Unit test for {@link ContextBeanFactoryReference}
|
||||
*
|
||||
*
|
||||
* @author Colin Sampaleanu
|
||||
* @author Chris Beams
|
||||
*/
|
||||
public class ContextBeanFactoryReferenceTests {
|
||||
|
||||
|
||||
@Test
|
||||
public void testAllOperations() {
|
||||
ConfigurableApplicationContext ctx = createMock(ConfigurableApplicationContext.class);
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
/*
|
||||
* 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.
|
||||
@@ -35,15 +35,15 @@ import org.springframework.mock.jndi.SimpleNamingContextBuilder;
|
||||
public final class ContextJndiBeanFactoryLocatorTests extends TestCase {
|
||||
|
||||
private static final String BEAN_FACTORY_PATH_ENVIRONMENT_KEY = "java:comp/env/ejb/BeanFactoryPath";
|
||||
|
||||
|
||||
private static final Class<?> CLASS = ContextJndiBeanFactoryLocatorTests.class;
|
||||
private static final String CLASSNAME = CLASS.getSimpleName();
|
||||
|
||||
|
||||
private static final String FQ_PATH = "/org/springframework/context/access/";
|
||||
|
||||
|
||||
private static final String COLLECTIONS_CONTEXT = FQ_PATH + CLASSNAME + "-collections.xml";
|
||||
private static final String PARENT_CONTEXT = FQ_PATH + CLASSNAME + "-parent.xml";
|
||||
|
||||
|
||||
|
||||
public void testBeanFactoryPathRequiredFromJndiEnvironment() throws Exception {
|
||||
// Set up initial context but don't bind anything
|
||||
|
||||
@@ -34,10 +34,10 @@ import org.springframework.util.ClassUtils;
|
||||
* @author Chris Beams
|
||||
*/
|
||||
public class ContextSingletonBeanFactoryLocatorTests extends SingletonBeanFactoryLocatorTests {
|
||||
|
||||
|
||||
private static final Class<?> CLASS = ContextSingletonBeanFactoryLocatorTests.class;
|
||||
private static final String CONTEXT = CLASS.getSimpleName() + "-context.xml";
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void testBaseBeanFactoryDefs() {
|
||||
@@ -51,7 +51,7 @@ public class ContextSingletonBeanFactoryLocatorTests extends SingletonBeanFactor
|
||||
public void testBasicFunctionality() {
|
||||
ContextSingletonBeanFactoryLocator facLoc = new ContextSingletonBeanFactoryLocator(
|
||||
"classpath*:" + ClassUtils.addResourcePathToPackagePath(CLASS, CONTEXT));
|
||||
|
||||
|
||||
basicFunctionalityTest(facLoc);
|
||||
|
||||
BeanFactoryReference bfr = facLoc.useBeanFactory("a.qualified.name.of.some.sort");
|
||||
@@ -77,7 +77,7 @@ public class ContextSingletonBeanFactoryLocatorTests extends SingletonBeanFactor
|
||||
BeanFactoryLocator facLoc = ContextSingletonBeanFactoryLocator.getInstance(
|
||||
ClassUtils.addResourcePathToPackagePath(CLASS, CONTEXT));
|
||||
getInstanceTest1(facLoc);
|
||||
|
||||
|
||||
facLoc = ContextSingletonBeanFactoryLocator.getInstance(
|
||||
"classpath*:" + ClassUtils.addResourcePathToPackagePath(CLASS, CONTEXT));
|
||||
getInstanceTest2(facLoc);
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
/*
|
||||
* 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.
|
||||
|
||||
@@ -29,7 +29,7 @@ import test.beans.TestBean;
|
||||
/**
|
||||
* TCK-style unit tests for handling circular use of the {@link Import} annotation. Explore
|
||||
* subclass hierarchy for specific concrete implementations.
|
||||
*
|
||||
*
|
||||
* @author Chris Beams
|
||||
*/
|
||||
public abstract class AbstractCircularImportDetectionTests {
|
||||
@@ -37,7 +37,7 @@ public abstract class AbstractCircularImportDetectionTests {
|
||||
protected abstract ConfigurationClassParser newParser();
|
||||
|
||||
protected abstract String loadAsConfigurationSource(Class<?> clazz) throws Exception;
|
||||
|
||||
|
||||
@Test
|
||||
public void simpleCircularImportIsDetected() throws Exception {
|
||||
boolean threw = false;
|
||||
|
||||
@@ -43,7 +43,7 @@ public class AnnotationConfigApplicationContextTests {
|
||||
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(Config.class);
|
||||
context.getBean((Class<?>)null);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void scanAndRefresh() {
|
||||
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
|
||||
|
||||
@@ -24,11 +24,11 @@ import org.springframework.core.type.classreading.CachingMetadataReaderFactory;
|
||||
/**
|
||||
* Unit test proving that ASM-based {@link ConfigurationClassParser} correctly detects circular use of
|
||||
* the {@link Import @Import} annotation.
|
||||
*
|
||||
*
|
||||
* <p>While this test is the only subclass of {@link AbstractCircularImportDetectionTests}, the
|
||||
* hierarchy remains in place in case a JDT-based ConfigurationParser implementation needs to be
|
||||
* developed.
|
||||
*
|
||||
*
|
||||
* @author Chris Beams
|
||||
*/
|
||||
public class AsmCircularImportDetectionTests extends AbstractCircularImportDetectionTests {
|
||||
|
||||
@@ -57,7 +57,7 @@ public class ClassPathFactoryBeanDefinitionScannerTests extends TestCase {
|
||||
TestBean tb2 = (TestBean)context.getBean("publicInstance"); //2
|
||||
assertEquals("publicInstance", tb2.getName());
|
||||
assertSame(tb2, tb);
|
||||
|
||||
|
||||
tb = (TestBean)context.getBean("protectedInstance"); //3
|
||||
assertEquals("protectedInstance", tb.getName());
|
||||
assertSame(tb, context.getBean("protectedInstance"));
|
||||
@@ -72,7 +72,7 @@ public class ClassPathFactoryBeanDefinitionScannerTests extends TestCase {
|
||||
tb2 = context.getBean("privateInstance", TestBean.class); //4
|
||||
assertEquals(2, tb2.getAge());
|
||||
assertNotSame(tb2, tb);
|
||||
|
||||
|
||||
Object bean = context.getBean("requestScopedInstance"); //5
|
||||
assertTrue(AopUtils.isCglibProxy(bean));
|
||||
assertTrue(bean instanceof ScopedObject);
|
||||
|
||||
@@ -124,7 +124,7 @@ public class ComponentScanParserTests {
|
||||
|
||||
@Target({ElementType.TYPE, ElementType.FIELD})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public static @interface CustomAnnotation {
|
||||
public static @interface CustomAnnotation {
|
||||
}
|
||||
|
||||
|
||||
@@ -141,7 +141,7 @@ public class ComponentScanParserTests {
|
||||
|
||||
|
||||
@CustomAnnotation
|
||||
public static class CustomAnnotationDependencyBean {
|
||||
public static class CustomAnnotationDependencyBean {
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -68,5 +68,5 @@ public class ComponentScanParserWithUserDefinedStrategiesTests {
|
||||
// expected
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -31,7 +31,7 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
* @author Juergen Hoeller
|
||||
*/
|
||||
public class SimpleConfigTests {
|
||||
|
||||
|
||||
@Test
|
||||
public void testFooService() throws Exception {
|
||||
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(getConfigLocations(), getClass());
|
||||
|
||||
@@ -38,10 +38,10 @@ public class SimpleScanTests {
|
||||
@Test
|
||||
public void testFooService() throws Exception {
|
||||
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(getConfigLocations(), getClass());
|
||||
|
||||
|
||||
FooService fooService = (FooService) ctx.getBean("fooServiceImpl");
|
||||
ServiceInvocationCounter serviceInvocationCounter = (ServiceInvocationCounter) ctx.getBean("serviceInvocationCounter");
|
||||
|
||||
|
||||
assertEquals(0, serviceInvocationCounter.getCount());
|
||||
|
||||
assertTrue(fooService.isInitCalled());
|
||||
@@ -50,7 +50,7 @@ public class SimpleScanTests {
|
||||
String value = fooService.foo(1);
|
||||
assertEquals("bar", value);
|
||||
assertEquals(2, serviceInvocationCounter.getCount());
|
||||
|
||||
|
||||
fooService.foo(1);
|
||||
assertEquals(3, serviceInvocationCounter.getCount());
|
||||
}
|
||||
|
||||
@@ -37,13 +37,13 @@ import org.springframework.core.io.ClassPathResource;
|
||||
/**
|
||||
* System tests covering use of {@link Autowired} and {@link Value} within
|
||||
* {@link Configuration} classes.
|
||||
*
|
||||
*
|
||||
* @author Chris Beams
|
||||
* @author Juergen Hoeller
|
||||
*/
|
||||
public class AutowiredConfigurationTests {
|
||||
|
||||
@Test
|
||||
@Test
|
||||
public void testAutowiredConfigurationDependencies() {
|
||||
ClassPathXmlApplicationContext factory = new ClassPathXmlApplicationContext(
|
||||
AutowiredConfigurationTests.class.getSimpleName() + ".xml", AutowiredConfigurationTests.class);
|
||||
|
||||
@@ -34,7 +34,7 @@ import org.springframework.context.annotation.DependsOn;
|
||||
* Unit tests proving that the various attributes available via the {@link Bean}
|
||||
* annotation are correctly reflected in the {@link BeanDefinition} created when
|
||||
* processing the {@link Configuration} class.
|
||||
*
|
||||
*
|
||||
* <p>Also includes tests proving that using {@link Lazy} and {@link Primary}
|
||||
* annotations in conjunction with Bean propagate their respective metadata
|
||||
* correctly into the resulting BeanDefinition
|
||||
|
||||
@@ -36,9 +36,9 @@ import static org.hamcrest.CoreMatchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Tests proving that @Qualifier annotations work when used
|
||||
* Tests proving that @Qualifier annotations work when used
|
||||
* with @Configuration classes on @Bean methods.
|
||||
*
|
||||
*
|
||||
* @author Chris Beams
|
||||
* @author Juergen Hoeller
|
||||
*/
|
||||
@@ -69,7 +69,7 @@ public class BeanMethodQualificationTests {
|
||||
public TestBean testBean1() {
|
||||
return new TestBean("interesting");
|
||||
}
|
||||
|
||||
|
||||
@Bean @Qualifier("boring")
|
||||
public TestBean testBean2() {
|
||||
return new TestBean("boring");
|
||||
|
||||
@@ -38,7 +38,7 @@ import test.beans.TestBean;
|
||||
* {@link Bean} methods may return aspects, or Configuration classes may themselves be annotated with Aspect.
|
||||
* In the latter case, advice methods are declared inline within the Configuration class. This makes for a
|
||||
* particularly convenient syntax requiring no extra artifact for the aspect.
|
||||
*
|
||||
*
|
||||
* <p>Currently it is assumed that the user is bootstrapping Configuration class processing via XML (using
|
||||
* annotation-config or component-scan), and thus will also use {@code <aop:aspectj-autoproxy/>} to enable
|
||||
* processing of the Aspect annotation.
|
||||
|
||||
@@ -78,81 +78,81 @@ public class ImportResourceTests {
|
||||
return new TestBean("java.declared");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Ignore // TODO: SPR-6310
|
||||
@Test
|
||||
public void testImportXmlByConvention() {
|
||||
ApplicationContext ctx = new AnnotationConfigApplicationContext(ImportXmlByConventionConfig.class);
|
||||
assertTrue("context does not contain xml-declared bean", ctx.containsBean("xmlDeclaredBean"));
|
||||
}
|
||||
|
||||
|
||||
@Configuration
|
||||
//@ImportXml
|
||||
static class ImportXmlByConventionConfig {
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testImportXmlIsInheritedFromSuperclassDeclarations() {
|
||||
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(FirstLevelSubConfig.class);
|
||||
assertTrue(ctx.containsBean("xmlDeclaredBean"));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testImportXmlIsMergedFromSuperclassDeclarations() {
|
||||
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(SecondLevelSubConfig.class);
|
||||
assertTrue("failed to pick up second-level-declared XML bean", ctx.containsBean("secondLevelXmlDeclaredBean"));
|
||||
assertTrue("failed to pick up parent-declared XML bean", ctx.containsBean("xmlDeclaredBean"));
|
||||
}
|
||||
|
||||
|
||||
@Configuration
|
||||
@ImportResource("classpath:org/springframework/context/annotation/configuration/ImportXmlConfig-context.xml")
|
||||
static class BaseConfig {
|
||||
}
|
||||
|
||||
|
||||
@Configuration
|
||||
static class FirstLevelSubConfig extends BaseConfig {
|
||||
}
|
||||
|
||||
|
||||
@Configuration
|
||||
@ImportResource("classpath:org/springframework/context/annotation/configuration/SecondLevelSubConfig-context.xml")
|
||||
static class SecondLevelSubConfig extends BaseConfig {
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testImportXmlWithNamespaceConfig() {
|
||||
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(ImportXmlWithAopNamespaceConfig.class);
|
||||
Object bean = ctx.getBean("proxiedXmlBean");
|
||||
assertTrue(AopUtils.isAopProxy(bean));
|
||||
}
|
||||
|
||||
|
||||
@Configuration
|
||||
@ImportResource("classpath:org/springframework/context/annotation/configuration/ImportXmlWithAopNamespace-context.xml")
|
||||
static class ImportXmlWithAopNamespaceConfig {
|
||||
}
|
||||
|
||||
|
||||
@Aspect
|
||||
static class AnAspect {
|
||||
@Before("execution(* test.beans.TestBean.*(..))")
|
||||
public void advice() { }
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testImportXmlWithAutowiredConfig() {
|
||||
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(ImportXmlAutowiredConfig.class);
|
||||
String name = ctx.getBean("xmlBeanName", String.class);
|
||||
assertThat(name, equalTo("xml.declared"));
|
||||
}
|
||||
|
||||
|
||||
@Configuration
|
||||
@ImportResource(value="classpath:org/springframework/context/annotation/configuration/ImportXmlConfig-context.xml")
|
||||
static class ImportXmlAutowiredConfig {
|
||||
@Autowired TestBean xmlDeclaredBean;
|
||||
|
||||
|
||||
public @Bean String xmlBeanName() {
|
||||
return xmlDeclaredBean.getName();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testImportNonXmlResource() {
|
||||
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(ImportNonXmlResourceConfig.class);
|
||||
@@ -164,7 +164,7 @@ public class ImportResourceTests {
|
||||
reader=PropertiesBeanDefinitionReader.class)
|
||||
static class ImportNonXmlResourceConfig {
|
||||
}
|
||||
|
||||
|
||||
@Ignore // TODO: SPR-6327
|
||||
@Test
|
||||
public void testImportDifferentResourceTypes() {
|
||||
@@ -172,7 +172,7 @@ public class ImportResourceTests {
|
||||
assertTrue(ctx.containsBean("propertiesDeclaredBean"));
|
||||
assertTrue(ctx.containsBean("xmlDeclaredBean"));
|
||||
}
|
||||
|
||||
|
||||
@Configuration
|
||||
@ImportResource(value="classpath:org/springframework/context/annotation/configuration/ImportXmlConfig-context.xml",
|
||||
reader=XmlBeanDefinitionReader.class)
|
||||
|
||||
@@ -34,7 +34,7 @@ import org.springframework.context.annotation.Import;
|
||||
|
||||
/**
|
||||
* System tests for {@link Import} annotation support.
|
||||
*
|
||||
*
|
||||
* @author Chris Beams
|
||||
*/
|
||||
public class ImportTests {
|
||||
@@ -125,7 +125,7 @@ public class ImportTests {
|
||||
@Configuration
|
||||
@Import(DataSourceConfig.class)
|
||||
static class AppConfig {
|
||||
|
||||
|
||||
@Bean
|
||||
public ITestBean transferService() {
|
||||
return new TestBean(accountRepository());
|
||||
|
||||
@@ -39,7 +39,7 @@ import test.beans.TestBean;
|
||||
*/
|
||||
public class ImportedConfigurationClassEnhancementTests {
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void autowiredConfigClassIsEnhancedWhenImported() {
|
||||
autowiredConfigClassIsEnhanced(ConfigThatDoesImport.class);
|
||||
@@ -49,25 +49,25 @@ public class ImportedConfigurationClassEnhancementTests {
|
||||
public void autowiredConfigClassIsEnhancedWhenRegisteredViaConstructor() {
|
||||
autowiredConfigClassIsEnhanced(ConfigThatDoesNotImport.class, ConfigToBeAutowired.class);
|
||||
}
|
||||
|
||||
|
||||
private void autowiredConfigClassIsEnhanced(Class<?>... configClasses) {
|
||||
ApplicationContext ctx = new AnnotationConfigApplicationContext(configClasses);
|
||||
Config config = ctx.getBean(Config.class);
|
||||
assertTrue("autowired config class has not been enhanced",
|
||||
ClassUtils.isCglibProxy(config.autowiredConfig));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void autowiredConfigClassBeanMethodsRespectScopingWhenImported() {
|
||||
autowiredConfigClassBeanMethodsRespectScoping(ConfigThatDoesImport.class);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void autowiredConfigClassBeanMethodsRespectScopingWhenRegisteredViaConstructor() {
|
||||
autowiredConfigClassBeanMethodsRespectScoping(ConfigThatDoesNotImport.class, ConfigToBeAutowired.class);
|
||||
}
|
||||
|
||||
|
||||
private void autowiredConfigClassBeanMethodsRespectScoping(Class<?>... configClasses) {
|
||||
ApplicationContext ctx = new AnnotationConfigApplicationContext(configClasses);
|
||||
Config config = ctx.getBean(Config.class);
|
||||
|
||||
@@ -196,7 +196,7 @@ public class ScopingTests {
|
||||
// 6 @Beans + 1 Configuration + 2 scoped proxy + 1 importRegistry
|
||||
assertEquals(10, ctx.getBeanDefinitionCount());
|
||||
}
|
||||
|
||||
|
||||
// /**
|
||||
// * SJC-254 caught a regression in handling scoped proxies starting in 1.0 m4.
|
||||
// * The ScopedProxyFactoryBean object was having its scope set to that of its delegate
|
||||
@@ -207,10 +207,10 @@ public class ScopingTests {
|
||||
// JavaConfigWebApplicationContext ctx = new JavaConfigWebApplicationContext();
|
||||
// ctx.setConfigLocations(new String[] { ScopeTestConfiguration.class.getName() });
|
||||
// ctx.refresh();
|
||||
//
|
||||
//
|
||||
// // should be fine
|
||||
// ctx.getBean(Bar.class);
|
||||
//
|
||||
//
|
||||
// boolean threw = false;
|
||||
// try {
|
||||
// ctx.getBean(Foo.class);
|
||||
@@ -221,7 +221,7 @@ public class ScopingTests {
|
||||
// }
|
||||
// assertTrue(threw);
|
||||
// }
|
||||
|
||||
|
||||
@Configuration
|
||||
static class ScopeTestConfiguration {
|
||||
|
||||
@@ -236,30 +236,30 @@ public class ScopingTests {
|
||||
return new Bar(foo());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static class Foo {
|
||||
public Foo() {
|
||||
//System.out.println("created foo: " + this.getClass().getName());
|
||||
}
|
||||
|
||||
|
||||
public void doSomething() {
|
||||
//System.out.println("interesting: " + this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static class Bar {
|
||||
|
||||
|
||||
private final Foo foo;
|
||||
|
||||
|
||||
public Bar(Foo foo) {
|
||||
this.foo = foo;
|
||||
//System.out.println("created bar: " + this);
|
||||
}
|
||||
|
||||
|
||||
public Foo getFoo() {
|
||||
return foo;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void genericTestScope(String beanName) throws Exception {
|
||||
|
||||
@@ -53,5 +53,5 @@ class WithNestedAnnotation {
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Component
|
||||
public static @interface MyComponent {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,13 +20,13 @@ package org.springframework.context.conversionservice;
|
||||
* @author Keith Donald
|
||||
*/
|
||||
public class Bar {
|
||||
|
||||
|
||||
private String value;
|
||||
|
||||
|
||||
public Bar(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
* @author Keith Donald
|
||||
*/
|
||||
public class ConversionServiceContextConfigTests {
|
||||
|
||||
|
||||
@Test
|
||||
public void testConfigOk() {
|
||||
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("org/springframework/context/conversionservice/conversionService.xml");
|
||||
|
||||
@@ -39,7 +39,7 @@ import org.springframework.context.support.StaticApplicationContext;
|
||||
* @author Rick Evans
|
||||
*/
|
||||
public class EventPublicationInterceptorTests {
|
||||
|
||||
|
||||
private ApplicationEventPublisher publisher;
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ public class EventPublicationInterceptorTests {
|
||||
publisher = createMock(ApplicationEventPublisher.class);
|
||||
replay(publisher);
|
||||
}
|
||||
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
verify(publisher);
|
||||
|
||||
@@ -55,7 +55,7 @@ public class LifecycleEventTests extends TestCase {
|
||||
assertFalse(lifecycleBean.isRunning());
|
||||
context.start();
|
||||
assertTrue(lifecycleBean.isRunning());
|
||||
assertEquals(0, listener.getStoppedCount());
|
||||
assertEquals(0, listener.getStoppedCount());
|
||||
context.stop();
|
||||
assertFalse(lifecycleBean.isRunning());
|
||||
assertEquals(1, listener.getStoppedCount());
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
/*
|
||||
* 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.
|
||||
@@ -22,24 +22,24 @@ package org.springframework.context.support;
|
||||
public class Assembler implements TestIF {
|
||||
|
||||
private Service service;
|
||||
private Logic l;
|
||||
private Logic l;
|
||||
private String name;
|
||||
|
||||
public void setService(Service service) {
|
||||
this.service = service;
|
||||
}
|
||||
|
||||
|
||||
public void setLogic(Logic l) {
|
||||
this.l = l;
|
||||
}
|
||||
|
||||
|
||||
public void setBeanName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public void test() {
|
||||
}
|
||||
|
||||
|
||||
public void output() {
|
||||
System.out.println("Bean " + name);
|
||||
l.output();
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
/*
|
||||
* 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.
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
/*
|
||||
* 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.
|
||||
@@ -35,7 +35,7 @@ import org.springframework.context.support.StaticApplicationContext;
|
||||
* any registered {@link BeanFactoryPostProcessor} implementations. Specifically
|
||||
* {@link StaticApplicationContext} is used for the tests, but what's represented
|
||||
* here is any {@link AbstractApplicationContext} implementation.
|
||||
*
|
||||
*
|
||||
* @author Colin Sampaleanu
|
||||
* @author Juergen Hoeller
|
||||
* @author Chris Beams
|
||||
@@ -54,7 +54,7 @@ public class BeanFactoryPostProcessorTests {
|
||||
ac.refresh();
|
||||
assertTrue(bfpp.wasCalled);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testDefinedBeanFactoryPostProcessor() {
|
||||
StaticApplicationContext ac = new StaticApplicationContext();
|
||||
@@ -93,7 +93,7 @@ public class BeanFactoryPostProcessorTests {
|
||||
assertFalse(bfpp.wasCalled);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static class TestBeanFactoryPostProcessor implements BeanFactoryPostProcessor {
|
||||
|
||||
public String initValue;
|
||||
@@ -103,10 +103,10 @@ public class BeanFactoryPostProcessorTests {
|
||||
}
|
||||
|
||||
public boolean wasCalled = false;
|
||||
|
||||
|
||||
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) {
|
||||
wasCalled = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ public final class ClassPathXmlApplicationContextTests {
|
||||
private static final String TEST_PROPERTIES = "test.properties";
|
||||
private static final String FQ_TEST_PROPERTIES = "classpath:org/springframework/beans/factory/xml/" + TEST_PROPERTIES;
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void testSingleConfigLocation() {
|
||||
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(FQ_SIMPLE_CONTEXT);
|
||||
|
||||
@@ -48,7 +48,7 @@ public class ConversionServiceFactoryBeanTests {
|
||||
ConversionService service = factory.getObject();
|
||||
assertTrue(service.canConvert(String.class, Integer.class));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void createDefaultConversionServiceWithSupplements() {
|
||||
ConversionServiceFactoryBean factory = new ConversionServiceFactoryBean();
|
||||
@@ -81,7 +81,7 @@ public class ConversionServiceFactoryBeanTests {
|
||||
assertTrue(service.canConvert(String.class, Integer.class));
|
||||
assertTrue(service.canConvert(String.class, Foo.class));
|
||||
assertTrue(service.canConvert(String.class, Bar.class));
|
||||
assertTrue(service.canConvert(String.class, Baz.class));
|
||||
assertTrue(service.canConvert(String.class, Baz.class));
|
||||
}
|
||||
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
@@ -119,10 +119,10 @@ public class ConversionServiceFactoryBeanTests {
|
||||
|
||||
public static class Foo {
|
||||
}
|
||||
|
||||
|
||||
public static class Bar {
|
||||
}
|
||||
|
||||
|
||||
public static class Baz {
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user