moving unit tests from .testsuite -> .aop
This commit is contained in:
parent
78f8494bec
commit
e8cacade02
|
|
@ -16,8 +16,9 @@
|
||||||
|
|
||||||
package org.springframework.aop.aspectj.annotation;
|
package org.springframework.aop.aspectj.annotation;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
import org.springframework.aop.Pointcut;
|
import org.springframework.aop.Pointcut;
|
||||||
import org.springframework.aop.aspectj.AspectJExpressionPointcut;
|
import org.springframework.aop.aspectj.AspectJExpressionPointcut;
|
||||||
import org.springframework.aop.aspectj.AspectJExpressionPointcutTests;
|
import org.springframework.aop.aspectj.AspectJExpressionPointcutTests;
|
||||||
|
|
@ -26,11 +27,13 @@ import org.springframework.beans.TestBean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Rod Johnson
|
* @author Rod Johnson
|
||||||
|
* @author Chris Beams
|
||||||
*/
|
*/
|
||||||
public class AspectJPointcutAdvisorTests extends TestCase {
|
public class AspectJPointcutAdvisorTests {
|
||||||
|
|
||||||
private AspectJAdvisorFactory af = new ReflectiveAspectJAdvisorFactory();
|
private AspectJAdvisorFactory af = new ReflectiveAspectJAdvisorFactory();
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testSingleton() throws SecurityException, NoSuchMethodException {
|
public void testSingleton() throws SecurityException, NoSuchMethodException {
|
||||||
AspectJExpressionPointcut ajexp = new AspectJExpressionPointcut();
|
AspectJExpressionPointcut ajexp = new AspectJExpressionPointcut();
|
||||||
ajexp.setExpression(AspectJExpressionPointcutTests.MATCH_ALL_METHODS);
|
ajexp.setExpression(AspectJExpressionPointcutTests.MATCH_ALL_METHODS);
|
||||||
|
|
@ -42,6 +45,7 @@ public class AspectJPointcutAdvisorTests extends TestCase {
|
||||||
assertFalse(ajpa.isPerInstance());
|
assertFalse(ajpa.isPerInstance());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testPerTarget() throws SecurityException, NoSuchMethodException {
|
public void testPerTarget() throws SecurityException, NoSuchMethodException {
|
||||||
AspectJExpressionPointcut ajexp = new AspectJExpressionPointcut();
|
AspectJExpressionPointcut ajexp = new AspectJExpressionPointcut();
|
||||||
ajexp.setExpression(AspectJExpressionPointcutTests.MATCH_ALL_METHODS);
|
ajexp.setExpression(AspectJExpressionPointcutTests.MATCH_ALL_METHODS);
|
||||||
|
|
@ -62,23 +66,18 @@ public class AspectJPointcutAdvisorTests extends TestCase {
|
||||||
TestBean.class));
|
TestBean.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test(expected=AopConfigException.class)
|
||||||
public void testPerCflowTarget() {
|
public void testPerCflowTarget() {
|
||||||
testIllegalInstantiationModel(AbstractAspectJAdvisorFactoryTests.PerCflowAspect.class);
|
testIllegalInstantiationModel(AbstractAspectJAdvisorFactoryTests.PerCflowAspect.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test(expected=AopConfigException.class)
|
||||||
public void testPerCflowBelowTarget() {
|
public void testPerCflowBelowTarget() {
|
||||||
testIllegalInstantiationModel(AbstractAspectJAdvisorFactoryTests.PerCflowBelowAspect.class);
|
testIllegalInstantiationModel(AbstractAspectJAdvisorFactoryTests.PerCflowBelowAspect.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void testIllegalInstantiationModel(Class c) {
|
private void testIllegalInstantiationModel(Class<?> c) throws AopConfigException {
|
||||||
try {
|
new AspectMetadata(c,"someBean");
|
||||||
new AspectMetadata(c,"someBean");
|
|
||||||
fail();
|
|
||||||
}
|
|
||||||
catch (AopConfigException ex) {
|
|
||||||
// OK
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,8 +16,10 @@
|
||||||
|
|
||||||
package org.springframework.aop.aspectj.autoproxy;
|
package org.springframework.aop.aspectj.autoproxy;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
import org.springframework.aop.config.AopConfigUtils;
|
import org.springframework.aop.config.AopConfigUtils;
|
||||||
import org.springframework.aop.config.AopNamespaceUtils;
|
import org.springframework.aop.config.AopNamespaceUtils;
|
||||||
import org.springframework.beans.factory.config.BeanDefinition;
|
import org.springframework.beans.factory.config.BeanDefinition;
|
||||||
|
|
@ -32,8 +34,9 @@ import org.springframework.beans.factory.xml.XmlReaderContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Rob Harrop
|
* @author Rob Harrop
|
||||||
|
* @author Chris Beams
|
||||||
*/
|
*/
|
||||||
public class AspectJNamespaceHandlerTests extends TestCase {
|
public class AspectJNamespaceHandlerTests {
|
||||||
|
|
||||||
private ParserContext parserContext;
|
private ParserContext parserContext;
|
||||||
|
|
||||||
|
|
@ -42,7 +45,8 @@ public class AspectJNamespaceHandlerTests extends TestCase {
|
||||||
private BeanDefinitionRegistry registry = new DefaultListableBeanFactory();
|
private BeanDefinitionRegistry registry = new DefaultListableBeanFactory();
|
||||||
|
|
||||||
|
|
||||||
protected void setUp() throws Exception {
|
@Before
|
||||||
|
public void setUp() throws Exception {
|
||||||
SourceExtractor sourceExtractor = new PassThroughSourceExtractor();
|
SourceExtractor sourceExtractor = new PassThroughSourceExtractor();
|
||||||
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(this.registry);
|
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(this.registry);
|
||||||
XmlReaderContext readerContext =
|
XmlReaderContext readerContext =
|
||||||
|
|
@ -50,6 +54,7 @@ public class AspectJNamespaceHandlerTests extends TestCase {
|
||||||
this.parserContext = new ParserContext(readerContext, null);
|
this.parserContext = new ParserContext(readerContext, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testRegisterAutoProxyCreator() throws Exception {
|
public void testRegisterAutoProxyCreator() throws Exception {
|
||||||
AopNamespaceUtils.registerAutoProxyCreatorIfNecessary(this.parserContext, null);
|
AopNamespaceUtils.registerAutoProxyCreatorIfNecessary(this.parserContext, null);
|
||||||
assertEquals("Incorrect number of definitions registered", 1, registry.getBeanDefinitionCount());
|
assertEquals("Incorrect number of definitions registered", 1, registry.getBeanDefinitionCount());
|
||||||
|
|
@ -58,6 +63,7 @@ public class AspectJNamespaceHandlerTests extends TestCase {
|
||||||
assertEquals("Incorrect number of definitions registered", 1, registry.getBeanDefinitionCount());
|
assertEquals("Incorrect number of definitions registered", 1, registry.getBeanDefinitionCount());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testRegisterAspectJAutoProxyCreator() throws Exception {
|
public void testRegisterAspectJAutoProxyCreator() throws Exception {
|
||||||
AopNamespaceUtils.registerAspectJAutoProxyCreatorIfNecessary(this.parserContext, null);
|
AopNamespaceUtils.registerAspectJAutoProxyCreatorIfNecessary(this.parserContext, null);
|
||||||
assertEquals("Incorrect number of definitions registered", 1, registry.getBeanDefinitionCount());
|
assertEquals("Incorrect number of definitions registered", 1, registry.getBeanDefinitionCount());
|
||||||
|
|
@ -70,6 +76,7 @@ public class AspectJNamespaceHandlerTests extends TestCase {
|
||||||
AspectJAwareAdvisorAutoProxyCreator.class.getName(), definition.getBeanClassName());
|
AspectJAwareAdvisorAutoProxyCreator.class.getName(), definition.getBeanClassName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testRegisterAspectJAutoProxyCreatorWithExistingAutoProxyCreator() throws Exception {
|
public void testRegisterAspectJAutoProxyCreatorWithExistingAutoProxyCreator() throws Exception {
|
||||||
AopNamespaceUtils.registerAutoProxyCreatorIfNecessary(this.parserContext, null);
|
AopNamespaceUtils.registerAutoProxyCreatorIfNecessary(this.parserContext, null);
|
||||||
assertEquals(1, registry.getBeanDefinitionCount());
|
assertEquals(1, registry.getBeanDefinitionCount());
|
||||||
|
|
@ -82,6 +89,7 @@ public class AspectJNamespaceHandlerTests extends TestCase {
|
||||||
AspectJAwareAdvisorAutoProxyCreator.class.getName(), definition.getBeanClassName());
|
AspectJAwareAdvisorAutoProxyCreator.class.getName(), definition.getBeanClassName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testRegisterAutoProxyCreatorWhenAspectJAutoProxyCreatorAlreadyExists() throws Exception {
|
public void testRegisterAutoProxyCreatorWhenAspectJAutoProxyCreatorAlreadyExists() throws Exception {
|
||||||
AopNamespaceUtils.registerAspectJAutoProxyCreatorIfNecessary(this.parserContext, null);
|
AopNamespaceUtils.registerAspectJAutoProxyCreatorIfNecessary(this.parserContext, null);
|
||||||
assertEquals(1, registry.getBeanDefinitionCount());
|
assertEquals(1, registry.getBeanDefinitionCount());
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue