1 16 17 package org.springframework.beans.factory.xml; 18 19 import org.springframework.aop.interceptor.DebugInterceptor; 20 import org.springframework.beans.ITestBean; 21 import org.springframework.test.AbstractDependencyInjectionSpringContextTests; 22 23 28 public class LookupMethodWrappedByCglibProxyTests extends AbstractDependencyInjectionSpringContextTests { 29 30 protected String [] getConfigLocations() { 31 return new String [] {"/org/springframework/beans/factory/xml/overloadOverrides.xml"}; 32 } 33 34 protected void onSetUp() { 35 resetInterceptor(); 36 } 37 38 public void testAutoProxiedLookup() { 39 OverloadLookup olup = (OverloadLookup) applicationContext.getBean("autoProxiedOverload"); 40 ITestBean jenny = olup.newTestBean(); 41 assertEquals("Jenny", jenny.getName()); 42 assertEquals("foo", olup.testMethod()); 43 assertInterceptorCount(2); 44 } 45 46 public void testRegularlyProxiedLookup() { 47 OverloadLookup olup = (OverloadLookup) applicationContext.getBean("regularlyProxiedOverload"); 48 ITestBean jenny = olup.newTestBean(); 49 assertEquals("Jenny", jenny.getName()); 50 assertEquals("foo", olup.testMethod()); 51 assertInterceptorCount(2); 52 } 53 54 private void assertInterceptorCount(int count) { 55 DebugInterceptor interceptor = getInterceptor(); 56 assertEquals("Interceptor count is incorrect", count, interceptor.getCount()); 57 } 58 59 private void resetInterceptor() { 60 DebugInterceptor interceptor = getInterceptor(); 61 interceptor.resetCount(); 62 } 63 64 private DebugInterceptor getInterceptor() { 65 return (DebugInterceptor) applicationContext.getBean("interceptor"); 66 } 67 68 69 public static abstract class OverloadLookup { 70 71 public abstract ITestBean newTestBean(); 72 73 public String testMethod() { 74 return "foo"; 75 } 76 } 77 78 } 79 | Popular Tags |