Polishing
This commit is contained in:
@@ -40,7 +40,7 @@ import static org.hamcrest.CoreMatchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Additional and overridden tests for the CGLIB proxy.
|
||||
* Additional and overridden tests for CGLIB proxies.
|
||||
*
|
||||
* @author Rod Johnson
|
||||
* @author Juergen Hoeller
|
||||
@@ -51,7 +51,8 @@ import static org.junit.Assert.*;
|
||||
@SuppressWarnings("serial")
|
||||
public final class CglibProxyTests extends AbstractAopProxyTests implements Serializable {
|
||||
|
||||
private static final String DEPENDENCY_CHECK_CONTEXT = CglibProxyTests.class.getSimpleName() + "-with-dependency-checking.xml";
|
||||
private static final String DEPENDENCY_CHECK_CONTEXT =
|
||||
CglibProxyTests.class.getSimpleName() + "-with-dependency-checking.xml";
|
||||
|
||||
|
||||
@Override
|
||||
@@ -317,15 +318,13 @@ public final class CglibProxyTests extends AbstractAopProxyTests implements Seri
|
||||
@Test
|
||||
@SuppressWarnings("resource")
|
||||
public void testWithDependencyChecking() {
|
||||
ApplicationContext ctx =
|
||||
new ClassPathXmlApplicationContext(DEPENDENCY_CHECK_CONTEXT, getClass());
|
||||
ApplicationContext ctx = new ClassPathXmlApplicationContext(DEPENDENCY_CHECK_CONTEXT, getClass());
|
||||
ctx.getBean("testBean");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddAdviceAtRuntime() {
|
||||
TestBean bean = new TestBean();
|
||||
|
||||
CountingBeforeAdvice cba = new CountingBeforeAdvice();
|
||||
|
||||
ProxyFactory pf = new ProxyFactory();
|
||||
@@ -335,17 +334,13 @@ public final class CglibProxyTests extends AbstractAopProxyTests implements Seri
|
||||
pf.setProxyTargetClass(true);
|
||||
|
||||
TestBean proxy = (TestBean) pf.getProxy();
|
||||
|
||||
assertTrue(AopUtils.isCglibProxy(proxy));
|
||||
|
||||
proxy.getAge();
|
||||
|
||||
assertEquals(0, cba.getCalls());
|
||||
|
||||
((Advised) proxy).addAdvice(cba);
|
||||
|
||||
proxy.getAge();
|
||||
|
||||
assertEquals(1, cba.getCalls());
|
||||
}
|
||||
|
||||
@@ -357,7 +352,6 @@ public final class CglibProxyTests extends AbstractAopProxyTests implements Seri
|
||||
proxyFactory.setProxyTargetClass(true);
|
||||
|
||||
MyBean proxy = (MyBean) proxyFactory.getProxy();
|
||||
|
||||
assertEquals(4, proxy.add(1, 3));
|
||||
assertEquals(1, advice.getCalls("add"));
|
||||
}
|
||||
@@ -415,7 +409,6 @@ public final class CglibProxyTests extends AbstractAopProxyTests implements Seri
|
||||
public final void foo() {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -452,7 +445,6 @@ class NoArgCtorTestBean {
|
||||
public void reset() {
|
||||
called = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -461,15 +453,11 @@ class ProtectedMethodTestBean {
|
||||
protected String getString() {
|
||||
return "foo";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
class UnsupportedInterceptor implements MethodInterceptor {
|
||||
|
||||
/**
|
||||
* @see org.aopalliance.intercept.MethodInterceptor#invoke(org.aopalliance.intercept.MethodInvocation)
|
||||
*/
|
||||
@Override
|
||||
public Object invoke(MethodInvocation mi) throws Throwable {
|
||||
throw new UnsupportedOperationException(mi.getMethod().getName());
|
||||
|
||||
Reference in New Issue
Block a user