SmartLifecycle beans will get auto-started on demand even if marked as lazy-init (SPR-6515)

This commit is contained in:
Juergen Hoeller 2009-12-08 13:27:15 +00:00
parent 93b17042a2
commit 736c7212db
1 changed files with 8 additions and 7 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2006 the original author or authors.
* Copyright 2002-2009 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.
@ -16,12 +16,11 @@
package org.springframework.aop.framework.autoproxy;
import static org.junit.Assert.*;
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;
@ -114,18 +113,20 @@ public final class AutoProxyCreatorTests {
ITestBean singletonToBeProxied = (ITestBean) sac.getBean("singletonToBeProxied");
assertTrue(Proxy.isProxyClass(singletonToBeProxied.getClass()));
// 2 invocations coming from FactoryBean inspection during lifecycle startup
TestInterceptor ti = (TestInterceptor) sac.getBean("testInterceptor");
assertEquals(0, ti.nrOfInvocations);
assertEquals(2, ti.nrOfInvocations);
singletonToBeProxied.getName();
assertEquals(1, ti.nrOfInvocations);
assertEquals(3, ti.nrOfInvocations);
FactoryBean<?> factory = (FactoryBean<?>) sac.getBean("&singletonFactoryToBeProxied");
assertTrue(Proxy.isProxyClass(factory.getClass()));
TestBean tb = (TestBean) sac.getBean("singletonFactoryToBeProxied");
assertFalse(AopUtils.isAopProxy(tb));
assertEquals(3, ti.nrOfInvocations);
assertEquals(5, ti.nrOfInvocations);
tb.getAge();
assertEquals(3, ti.nrOfInvocations);
assertEquals(5, ti.nrOfInvocations);
}
@Test