refactoring .testsuite .aop.aspectj tests in preparation for migration to .context
This commit is contained in:
parent
eabec18151
commit
6f91ffac62
|
@ -45,7 +45,8 @@ public final class AfterAdviceBindingTests {
|
|||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("after-advice-tests.xml", getClass());
|
||||
ClassPathXmlApplicationContext ctx =
|
||||
new ClassPathXmlApplicationContext(getClass().getSimpleName() + ".xml", getClass());
|
||||
AdviceBindingTestAspect afterAdviceAspect = (AdviceBindingTestAspect) ctx.getBean("testAspect");
|
||||
|
||||
testBeanProxy = (ITestBean) ctx.getBean("testBean");
|
||||
|
|
|
@ -26,7 +26,6 @@ import org.springframework.aop.framework.Advised;
|
|||
import org.springframework.aop.support.AopUtils;
|
||||
import org.springframework.beans.ITestBean;
|
||||
import org.springframework.beans.TestBean;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
|
||||
/**
|
||||
|
@ -52,13 +51,10 @@ public final class AfterReturningAdviceBindingTests {
|
|||
this.afterAdviceAspect = anAspect;
|
||||
}
|
||||
|
||||
protected String getConfigPath() {
|
||||
return "afterReturning-advice-tests.xml";
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
ApplicationContext ctx = new ClassPathXmlApplicationContext(getConfigPath(), getClass());
|
||||
ClassPathXmlApplicationContext ctx =
|
||||
new ClassPathXmlApplicationContext(getClass().getSimpleName() + ".xml", getClass());
|
||||
|
||||
afterAdviceAspect = (AfterReturningAdviceBindingTestAspect) ctx.getBean("testAspect");
|
||||
|
||||
|
|
|
@ -41,7 +41,8 @@ public final class AfterThrowingAdviceBindingTests {
|
|||
|
||||
@Before
|
||||
public void setUp() {
|
||||
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("afterThrowing-advice-tests.xml", getClass());
|
||||
ClassPathXmlApplicationContext ctx =
|
||||
new ClassPathXmlApplicationContext(getClass().getSimpleName() + ".xml", getClass());
|
||||
|
||||
testBean = (ITestBean) ctx.getBean("testBean");
|
||||
afterThrowingAdviceAspect = (AfterThrowingAdviceBindingTestAspect) ctx.getBean("testAspect");
|
||||
|
|
|
@ -46,13 +46,9 @@ public class AroundAdviceBindingTests {
|
|||
|
||||
protected ApplicationContext ctx;
|
||||
|
||||
protected String getConfigPath() {
|
||||
return "around-advice-tests.xml";
|
||||
}
|
||||
|
||||
@Before
|
||||
public void onSetUp() throws Exception {
|
||||
ctx = new ClassPathXmlApplicationContext(getConfigPath(), getClass());
|
||||
ctx = new ClassPathXmlApplicationContext(getClass().getSimpleName() + ".xml", getClass());
|
||||
|
||||
AroundAdviceBindingTestAspect aroundAdviceAspect = ((AroundAdviceBindingTestAspect) ctx.getBean("testAspect"));
|
||||
|
||||
|
|
|
@ -27,10 +27,6 @@ import org.springframework.aop.support.AopUtils;
|
|||
*/
|
||||
public final class AroundAdviceCircularTests extends AroundAdviceBindingTests {
|
||||
|
||||
protected String getConfigPath() {
|
||||
return "around-advice-circular-tests.xml";
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBothBeansAreProxies() {
|
||||
Object tb = ctx.getBean("testBean");
|
||||
|
|
|
@ -48,7 +48,8 @@ public final class AspectAndAdvicePrecedenceTests {
|
|||
|
||||
@Before
|
||||
public void setUp() {
|
||||
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("advice-precedence-tests.xml", getClass());
|
||||
ClassPathXmlApplicationContext ctx =
|
||||
new ClassPathXmlApplicationContext(getClass().getSimpleName() + ".xml", getClass());
|
||||
highPrecedenceAspect = (PrecedenceTestAspect) ctx.getBean("highPrecedenceAspect");
|
||||
lowPrecedenceAspect = (PrecedenceTestAspect) ctx.getBean("lowPrecedenceAspect");
|
||||
highPrecedenceSpringAdvice = (SimpleSpringBeforeAdvice) ctx.getBean("highPrecedenceSpringAdvice");
|
||||
|
|
|
@ -38,7 +38,8 @@ public final class AspectJExpressionPointcutAdvisorTests {
|
|||
|
||||
@Before
|
||||
public void setUp() {
|
||||
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("aspectj.xml", getClass());
|
||||
ClassPathXmlApplicationContext ctx =
|
||||
new ClassPathXmlApplicationContext(getClass().getSimpleName() + ".xml", getClass());
|
||||
testBean = (ITestBean) ctx.getBean("testBean");
|
||||
interceptor = (CallCountingInterceptor) ctx.getBean("interceptor");
|
||||
}
|
||||
|
|
|
@ -47,7 +47,8 @@ public final class BeanNamePointcutAtAspectTests {
|
|||
|
||||
@org.junit.Before
|
||||
public void setUp() {
|
||||
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("bean-name-pointcut-atAspect-tests.xml", getClass());
|
||||
ClassPathXmlApplicationContext ctx =
|
||||
new ClassPathXmlApplicationContext(getClass().getSimpleName() + ".xml", getClass());
|
||||
counterAspect = (CounterAspect) ctx.getBean("counterAspect");
|
||||
testBean1 = (ITestBean) ctx.getBean("testBean1");
|
||||
testBean2 = (ITestBean) ctx.getBean("testBean2");
|
||||
|
|
|
@ -54,7 +54,7 @@ public final class BeanNamePointcutTests {
|
|||
|
||||
@Before
|
||||
public void setUp() {
|
||||
ctx = new ClassPathXmlApplicationContext("bean-name-pointcut-tests.xml", getClass());
|
||||
ctx = new ClassPathXmlApplicationContext(getClass().getSimpleName() + ".xml", getClass());
|
||||
testBean1 = (ITestBean) ctx.getBean("testBean1");
|
||||
testBean2 = (ITestBean) ctx.getBean("testBean2");
|
||||
testBeanContainingNestedBean = (ITestBean) ctx.getBean("testBeanContainingNestedBean");
|
||||
|
|
|
@ -50,7 +50,8 @@ public final class BeforeAdviceBindingTests {
|
|||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
ApplicationContext ctx = new ClassPathXmlApplicationContext(getConfigPath(), getClass());
|
||||
ClassPathXmlApplicationContext ctx =
|
||||
new ClassPathXmlApplicationContext(getClass().getSimpleName() + ".xml", getClass());
|
||||
|
||||
testBeanProxy = (ITestBean) ctx.getBean("testBean");
|
||||
assertTrue(AopUtils.isAopProxy(testBeanProxy));
|
||||
|
|
|
@ -39,7 +39,8 @@ public final class DeclarationOrderIndependenceTests {
|
|||
|
||||
@Before
|
||||
public void setUp() {
|
||||
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("topsy-turvy-aspect.xml", getClass());
|
||||
ClassPathXmlApplicationContext ctx =
|
||||
new ClassPathXmlApplicationContext(getClass().getSimpleName() + ".xml", getClass());
|
||||
aspect = (TopsyTurvyAspect) ctx.getBean("topsyTurvyAspect");
|
||||
target = (TopsyTurvyTarget) ctx.getBean("topsyTurvyTarget");
|
||||
}
|
||||
|
|
|
@ -35,7 +35,8 @@ public class DeclareParentsDelegateRefTests {
|
|||
|
||||
@Before
|
||||
public void setUp() {
|
||||
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("declare-parents-delegate-ref-tests.xml", getClass());
|
||||
ClassPathXmlApplicationContext ctx =
|
||||
new ClassPathXmlApplicationContext(getClass().getSimpleName() + ".xml", getClass());
|
||||
noMethodsBean = (NoMethodsBean) ctx.getBean("noMethodsBean");
|
||||
counter = (Counter) ctx.getBean("counter");
|
||||
counter.reset();
|
||||
|
|
|
@ -40,13 +40,9 @@ public final class DeclareParentsTests {
|
|||
|
||||
private ApplicationContext ctx;
|
||||
|
||||
protected String getConfigPath() {
|
||||
return "declare-parents-tests.xml";
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
ctx = new ClassPathXmlApplicationContext(getConfigPath(), getClass());
|
||||
ctx = new ClassPathXmlApplicationContext(getClass().getSimpleName() + ".xml", getClass());
|
||||
|
||||
testBeanProxy = (ITestBean) ctx.getBean("testBean");
|
||||
assertTrue(AopUtils.isAopProxy(testBeanProxy));
|
||||
|
|
|
@ -34,7 +34,7 @@ public final class ImplicitJPArgumentMatchingAtAspectJTests {
|
|||
@Test
|
||||
public void testAspect() {
|
||||
// nothing to really test; it is enough if we don't get error while creating app context
|
||||
new ClassPathXmlApplicationContext("implicit-jp-argument-matching-atAspectJ-tests.xml", getClass());
|
||||
new ClassPathXmlApplicationContext(getClass().getSimpleName() + ".xml", getClass());
|
||||
}
|
||||
|
||||
@Aspect
|
||||
|
|
|
@ -31,7 +31,7 @@ public final class ImplicitJPArgumentMatchingTests {
|
|||
@Test
|
||||
public void testAspect() {
|
||||
// nothing to really test; it is enough if we don't get error while creating app context
|
||||
new ClassPathXmlApplicationContext("implicit-jp-argument-matching-tests.xml", getClass());
|
||||
new ClassPathXmlApplicationContext(getClass().getSimpleName() + ".xml", getClass());
|
||||
}
|
||||
|
||||
static class CounterAspect {
|
||||
|
|
|
@ -33,7 +33,7 @@ public final class OverloadedAdviceTests {
|
|||
@Test
|
||||
public void testExceptionOnConfigParsingWithMismatchedAdviceMethod() {
|
||||
try {
|
||||
new ClassPathXmlApplicationContext("overloaded-advice-tests.xml", getClass());
|
||||
new ClassPathXmlApplicationContext(getClass().getSimpleName() + ".xml", getClass());
|
||||
}
|
||||
catch (BeanCreationException ex) {
|
||||
Throwable cause = ex.getRootCause();
|
||||
|
@ -46,7 +46,7 @@ public final class OverloadedAdviceTests {
|
|||
@Test
|
||||
public void testExceptionOnConfigParsingWithAmbiguousAdviceMethod() {
|
||||
try {
|
||||
new ClassPathXmlApplicationContext("ambiguous-advice-tests.xml", getClass());
|
||||
new ClassPathXmlApplicationContext(getClass().getSimpleName() + "-ambiguous.xml", getClass());
|
||||
}
|
||||
catch (BeanCreationException ex) {
|
||||
Throwable cause = ex.getRootCause();
|
||||
|
|
|
@ -43,7 +43,7 @@ public final class ProceedTests {
|
|||
|
||||
@Before
|
||||
public void setUp() {
|
||||
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("proceedTests.xml", getClass());
|
||||
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("proceedTests_.xml", getClass());
|
||||
testBean = (SimpleBean) ctx.getBean("testBean");
|
||||
firstTestAspect = (ProceedTestingAspect) ctx.getBean("firstTestAspect");
|
||||
secondTestAspect = (ProceedTestingAspect) ctx.getBean("secondTestAspect");
|
||||
|
|
|
@ -39,26 +39,26 @@ public final class PropertyDependentAspectTests {
|
|||
|
||||
@Test
|
||||
public void testPropertyDependentAspectWithPropertyDeclaredBeforeAdvice() throws Exception {
|
||||
checkXmlAspect("org/springframework/aop/aspectj/property-dependent-aspect-property-before-aspect-test.xml");
|
||||
checkXmlAspect(getClass().getSimpleName() + "-before.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPropertyDependentAspectWithPropertyDeclaredAfterAdvice() throws Exception {
|
||||
checkXmlAspect("org/springframework/aop/aspectj/property-dependent-aspect-property-after-aspect-test.xml");
|
||||
checkXmlAspect(getClass().getSimpleName() + "-after.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPropertyDependentAtAspectJAspectWithPropertyDeclaredBeforeAdvice() throws Exception {
|
||||
checkAtAspectJAspect("org/springframework/aop/aspectj/property-dependent-atAspectJ-aspect-property-before-aspect-test.xml");
|
||||
checkAtAspectJAspect(getClass().getSimpleName() + "-atAspectJ-before.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPropertyDependentAtAspectJAspectWithPropertyDeclaredAfterAdvice() throws Exception {
|
||||
checkAtAspectJAspect("org/springframework/aop/aspectj/property-dependent-atAspectJ-aspect-property-after-aspect-test.xml");
|
||||
checkAtAspectJAspect(getClass().getSimpleName() + "-atAspectJ-after.xml");
|
||||
}
|
||||
|
||||
private void checkXmlAspect(String appContextFile) {
|
||||
ApplicationContext context = new ClassPathXmlApplicationContext(appContextFile);
|
||||
ApplicationContext context = new ClassPathXmlApplicationContext(appContextFile, getClass());
|
||||
ICounter counter = (ICounter) context.getBean("counter");
|
||||
assertTrue("Proxy didn't get created", counter instanceof Advised);
|
||||
|
||||
|
@ -69,7 +69,7 @@ public final class PropertyDependentAspectTests {
|
|||
}
|
||||
|
||||
private void checkAtAspectJAspect(String appContextFile) {
|
||||
ApplicationContext context = new ClassPathXmlApplicationContext(appContextFile);
|
||||
ApplicationContext context = new ClassPathXmlApplicationContext(appContextFile, getClass());
|
||||
ICounter counter = (ICounter) context.getBean("counter");
|
||||
assertTrue("Proxy didn't get created", counter instanceof Advised);
|
||||
|
||||
|
|
|
@ -33,7 +33,8 @@ public final class SharedPointcutWithArgsMismatchTests {
|
|||
|
||||
@Before
|
||||
public void setUp() {
|
||||
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("args-mismatch.xml", getClass());
|
||||
ClassPathXmlApplicationContext ctx =
|
||||
new ClassPathXmlApplicationContext(getClass().getSimpleName() + ".xml", getClass());
|
||||
toBeAdvised = (ToBeAdvised) ctx.getBean("toBeAdvised");
|
||||
}
|
||||
|
||||
|
|
|
@ -40,7 +40,8 @@ public final class SubtypeSensitiveMatchingTests {
|
|||
|
||||
@Before
|
||||
public void setUp() {
|
||||
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("subtype-sensitive-matching.xml", getClass());
|
||||
ClassPathXmlApplicationContext ctx =
|
||||
new ClassPathXmlApplicationContext(getClass().getSimpleName() + ".xml", getClass());
|
||||
nonSerializableBean = (NonSerializableFoo) ctx.getBean("testClassA");
|
||||
serializableBean = (SerializableFoo) ctx.getBean("testClassB");
|
||||
bar = (Bar) ctx.getBean("testClassC");
|
||||
|
|
|
@ -42,7 +42,7 @@ public final class TargetPointcutSelectionTests {
|
|||
|
||||
@Before
|
||||
public void setUp() {
|
||||
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("targetPointcutSelectionTests.xml", getClass());
|
||||
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("targetPointcutSelectionTests_.xml", getClass());
|
||||
testImpl1 = (TestInterface) ctx.getBean("testImpl1");
|
||||
testImpl2 = (TestInterface) ctx.getBean("testImpl2");
|
||||
testAspectForTestImpl1 = (TestAspect) ctx.getBean("testAspectForTestImpl1");
|
||||
|
|
|
@ -39,7 +39,8 @@ public final class ThisAndTargetSelectionOnlyPointcutsAtAspectJTests {
|
|||
|
||||
@org.junit.Before
|
||||
public void setUp() {
|
||||
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("this-and-target-selectionOnly-pointcuts-atAspectJ-tests.xml", getClass());
|
||||
ClassPathXmlApplicationContext ctx =
|
||||
new ClassPathXmlApplicationContext(getClass().getSimpleName() + ".xml", getClass());
|
||||
testBean = (TestInterface) ctx.getBean("testBean");
|
||||
testAnnotatedClassBean = (TestInterface) ctx.getBean("testAnnotatedClassBean");
|
||||
testAnnotatedMethodBean = (TestInterface) ctx.getBean("testAnnotatedMethodBean");
|
||||
|
|
|
@ -40,7 +40,8 @@ public final class ThisAndTargetSelectionOnlyPointcutsTests {
|
|||
|
||||
@Before
|
||||
public void setUp() {
|
||||
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("this-and-target-selectionOnly-pointcuts-tests.xml", getClass());
|
||||
ClassPathXmlApplicationContext ctx =
|
||||
new ClassPathXmlApplicationContext(getClass().getSimpleName() + ".xml", getClass());
|
||||
|
||||
testBean = (TestInterface) ctx.getBean("testBean");
|
||||
|
||||
|
|
Loading…
Reference in New Issue