From 736c7212dbaf357bb1f45c546b94c7c2669a369e Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Tue, 8 Dec 2009 13:27:15 +0000 Subject: [PATCH] SmartLifecycle beans will get auto-started on demand even if marked as lazy-init (SPR-6515) --- .../autoproxy/AutoProxyCreatorTests.java | 15 ++++++++------- 1 file changed, 8 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 77718a473e5..141c493cd97 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 @@ -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