From c90e2c6f106cf94811bb72fdbefb878e5d067bfb Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Fri, 12 Oct 2012 23:06:15 +0200 Subject: [PATCH] Made AutoProxyCreatorTests less dependent on container's own interrogation of FactoryBeans Issue: SPR-9857 --- .../framework/autoproxy/AutoProxyCreatorTests.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/org.springframework.context/src/test/java/org/springframework/aop/framework/autoproxy/AutoProxyCreatorTests.java b/org.springframework.context/src/test/java/org/springframework/aop/framework/autoproxy/AutoProxyCreatorTests.java index d3d7958af1d..f8b0e7a01ff 100644 --- a/org.springframework.context/src/test/java/org/springframework/aop/framework/autoproxy/AutoProxyCreatorTests.java +++ b/org.springframework.context/src/test/java/org/springframework/aop/framework/autoproxy/AutoProxyCreatorTests.java @@ -20,7 +20,6 @@ import java.lang.reflect.Proxy; import org.aopalliance.intercept.MethodInterceptor; import org.aopalliance.intercept.MethodInvocation; -import static org.junit.Assert.*; import org.junit.Test; import org.springframework.aop.TargetSource; @@ -37,6 +36,8 @@ import org.springframework.context.MessageSource; import org.springframework.context.support.StaticApplicationContext; import org.springframework.context.support.StaticMessageSource; +import static org.junit.Assert.*; + /** * @author Juergen Hoeller * @author Chris Beams @@ -113,20 +114,18 @@ public final class AutoProxyCreatorTests { ITestBean singletonToBeProxied = (ITestBean) sac.getBean("singletonToBeProxied"); assertTrue(Proxy.isProxyClass(singletonToBeProxied.getClass())); - // 4 invocations coming from FactoryBean inspection during lifecycle startup - TestInterceptor ti = (TestInterceptor) sac.getBean("testInterceptor"); - assertEquals(4, ti.nrOfInvocations); + int initialNr = ti.nrOfInvocations; singletonToBeProxied.getName(); - assertEquals(5, ti.nrOfInvocations); + assertEquals(initialNr + 1, ti.nrOfInvocations); FactoryBean factory = (FactoryBean) sac.getBean("&singletonFactoryToBeProxied"); assertTrue(Proxy.isProxyClass(factory.getClass())); TestBean tb = (TestBean) sac.getBean("singletonFactoryToBeProxied"); assertFalse(AopUtils.isAopProxy(tb)); - assertEquals(7, ti.nrOfInvocations); + assertEquals(initialNr + 3, ti.nrOfInvocations); tb.getAge(); - assertEquals(7, ti.nrOfInvocations); + assertEquals(initialNr + 3, ti.nrOfInvocations); } @Test