Browse Source

moving unit tests from .testsuite -> .aop

conversation
Chris Beams 16 years ago
parent
commit
e8cacade02
  1. 21
      org.springframework.aop/src/test/java/org/springframework/aop/aspectj/annotation/AspectJPointcutAdvisorTests.java
  2. 14
      org.springframework.aop/src/test/java/org/springframework/aop/aspectj/autoproxy/AspectJNamespaceHandlerTests.java

21
org.springframework.aop/src/test/java/org/springframework/aop/aspectj/annotation/AspectJPointcutAdvisorTests.java

@ -16,8 +16,9 @@ @@ -16,8 +16,9 @@
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.aspectj.AspectJExpressionPointcut;
import org.springframework.aop.aspectj.AspectJExpressionPointcutTests;
@ -26,11 +27,13 @@ import org.springframework.beans.TestBean; @@ -26,11 +27,13 @@ import org.springframework.beans.TestBean;
/**
* @author Rod Johnson
* @author Chris Beams
*/
public class AspectJPointcutAdvisorTests extends TestCase {
public class AspectJPointcutAdvisorTests {
private AspectJAdvisorFactory af = new ReflectiveAspectJAdvisorFactory();
@Test
public void testSingleton() throws SecurityException, NoSuchMethodException {
AspectJExpressionPointcut ajexp = new AspectJExpressionPointcut();
ajexp.setExpression(AspectJExpressionPointcutTests.MATCH_ALL_METHODS);
@ -42,6 +45,7 @@ public class AspectJPointcutAdvisorTests extends TestCase { @@ -42,6 +45,7 @@ public class AspectJPointcutAdvisorTests extends TestCase {
assertFalse(ajpa.isPerInstance());
}
@Test
public void testPerTarget() throws SecurityException, NoSuchMethodException {
AspectJExpressionPointcut ajexp = new AspectJExpressionPointcut();
ajexp.setExpression(AspectJExpressionPointcutTests.MATCH_ALL_METHODS);
@ -62,23 +66,18 @@ public class AspectJPointcutAdvisorTests extends TestCase { @@ -62,23 +66,18 @@ public class AspectJPointcutAdvisorTests extends TestCase {
TestBean.class));
}
@Test(expected=AopConfigException.class)
public void testPerCflowTarget() {
testIllegalInstantiationModel(AbstractAspectJAdvisorFactoryTests.PerCflowAspect.class);
}
@Test(expected=AopConfigException.class)
public void testPerCflowBelowTarget() {
testIllegalInstantiationModel(AbstractAspectJAdvisorFactoryTests.PerCflowBelowAspect.class);
}
private void testIllegalInstantiationModel(Class c) {
try {
new AspectMetadata(c,"someBean");
fail();
}
catch (AopConfigException ex) {
// OK
}
private void testIllegalInstantiationModel(Class<?> c) throws AopConfigException {
new AspectMetadata(c,"someBean");
}
}

14
org.springframework.aop/src/test/java/org/springframework/aop/aspectj/autoproxy/AspectJNamespaceHandlerTests.java

@ -16,8 +16,10 @@ @@ -16,8 +16,10 @@
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.AopNamespaceUtils;
import org.springframework.beans.factory.config.BeanDefinition;
@ -32,8 +34,9 @@ import org.springframework.beans.factory.xml.XmlReaderContext; @@ -32,8 +34,9 @@ import org.springframework.beans.factory.xml.XmlReaderContext;
/**
* @author Rob Harrop
* @author Chris Beams
*/
public class AspectJNamespaceHandlerTests extends TestCase {
public class AspectJNamespaceHandlerTests {
private ParserContext parserContext;
@ -42,7 +45,8 @@ public class AspectJNamespaceHandlerTests extends TestCase { @@ -42,7 +45,8 @@ public class AspectJNamespaceHandlerTests extends TestCase {
private BeanDefinitionRegistry registry = new DefaultListableBeanFactory();
protected void setUp() throws Exception {
@Before
public void setUp() throws Exception {
SourceExtractor sourceExtractor = new PassThroughSourceExtractor();
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(this.registry);
XmlReaderContext readerContext =
@ -50,6 +54,7 @@ public class AspectJNamespaceHandlerTests extends TestCase { @@ -50,6 +54,7 @@ public class AspectJNamespaceHandlerTests extends TestCase {
this.parserContext = new ParserContext(readerContext, null);
}
@Test
public void testRegisterAutoProxyCreator() throws Exception {
AopNamespaceUtils.registerAutoProxyCreatorIfNecessary(this.parserContext, null);
assertEquals("Incorrect number of definitions registered", 1, registry.getBeanDefinitionCount());
@ -58,6 +63,7 @@ public class AspectJNamespaceHandlerTests extends TestCase { @@ -58,6 +63,7 @@ public class AspectJNamespaceHandlerTests extends TestCase {
assertEquals("Incorrect number of definitions registered", 1, registry.getBeanDefinitionCount());
}
@Test
public void testRegisterAspectJAutoProxyCreator() throws Exception {
AopNamespaceUtils.registerAspectJAutoProxyCreatorIfNecessary(this.parserContext, null);
assertEquals("Incorrect number of definitions registered", 1, registry.getBeanDefinitionCount());
@ -70,6 +76,7 @@ public class AspectJNamespaceHandlerTests extends TestCase { @@ -70,6 +76,7 @@ public class AspectJNamespaceHandlerTests extends TestCase {
AspectJAwareAdvisorAutoProxyCreator.class.getName(), definition.getBeanClassName());
}
@Test
public void testRegisterAspectJAutoProxyCreatorWithExistingAutoProxyCreator() throws Exception {
AopNamespaceUtils.registerAutoProxyCreatorIfNecessary(this.parserContext, null);
assertEquals(1, registry.getBeanDefinitionCount());
@ -82,6 +89,7 @@ public class AspectJNamespaceHandlerTests extends TestCase { @@ -82,6 +89,7 @@ public class AspectJNamespaceHandlerTests extends TestCase {
AspectJAwareAdvisorAutoProxyCreator.class.getName(), definition.getBeanClassName());
}
@Test
public void testRegisterAutoProxyCreatorWhenAspectJAutoProxyCreatorAlreadyExists() throws Exception {
AopNamespaceUtils.registerAspectJAutoProxyCreatorIfNecessary(this.parserContext, null);
assertEquals(1, registry.getBeanDefinitionCount());

Loading…
Cancel
Save