polishing .aop tests

This commit is contained in:
Chris Beams 2008-12-20 19:29:15 +00:00
parent ac9f9c1348
commit 7abde41d5b
10 changed files with 26 additions and 22 deletions

View File

@ -28,8 +28,9 @@ import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.springframework.beans.TestBean; import org.springframework.beans.TestBean;
import example.annotations.EmptySpringAnnotation; import test.annotation.EmptySpringAnnotation;
import example.annotations.transaction.Tx; import test.annotation.transaction.Tx;
/** /**
* Java5-specific AspectJExpressionPointcutTests. * Java5-specific AspectJExpressionPointcutTests.
@ -117,26 +118,26 @@ public class TigerAspectJExpressionPointcutTests {
@Test @Test
public void testMatchAnnotationOnClassWithAtWithin() throws SecurityException, NoSuchMethodException { public void testMatchAnnotationOnClassWithAtWithin() throws SecurityException, NoSuchMethodException {
String expression = "@within(example.annotations.transaction.Tx)"; String expression = "@within(test.annotation.transaction.Tx)";
testMatchAnnotationOnClass(expression); testMatchAnnotationOnClass(expression);
} }
@Test @Test
public void testMatchAnnotationOnClassWithoutBinding() throws SecurityException, NoSuchMethodException { public void testMatchAnnotationOnClassWithoutBinding() throws SecurityException, NoSuchMethodException {
String expression = "within(@example.annotations.transaction.Tx *)"; String expression = "within(@test.annotation.transaction.Tx *)";
testMatchAnnotationOnClass(expression); testMatchAnnotationOnClass(expression);
} }
@Test @Test
public void testMatchAnnotationOnClassWithSubpackageWildcard() throws SecurityException, NoSuchMethodException { public void testMatchAnnotationOnClassWithSubpackageWildcard() throws SecurityException, NoSuchMethodException {
String expression = "within(@(example.annotations..*) *)"; String expression = "within(@(test.annotation..*) *)";
AspectJExpressionPointcut springAnnotatedPc = testMatchAnnotationOnClass(expression); AspectJExpressionPointcut springAnnotatedPc = testMatchAnnotationOnClass(expression);
assertFalse(springAnnotatedPc.matches(TestBean.class.getMethod("setName", String.class), assertFalse(springAnnotatedPc.matches(TestBean.class.getMethod("setName", String.class),
TestBean.class)); TestBean.class));
assertTrue(springAnnotatedPc.matches(SpringAnnotated.class.getMethod("foo", (Class[]) null), assertTrue(springAnnotatedPc.matches(SpringAnnotated.class.getMethod("foo", (Class[]) null),
SpringAnnotated.class)); SpringAnnotated.class));
expression = "within(@(example.annotations.transaction..*) *)"; expression = "within(@(test.annotation.transaction..*) *)";
AspectJExpressionPointcut springTxAnnotatedPc = testMatchAnnotationOnClass(expression); AspectJExpressionPointcut springTxAnnotatedPc = testMatchAnnotationOnClass(expression);
assertFalse(springTxAnnotatedPc.matches(SpringAnnotated.class.getMethod("foo", (Class[]) null), assertFalse(springTxAnnotatedPc.matches(SpringAnnotated.class.getMethod("foo", (Class[]) null),
SpringAnnotated.class)); SpringAnnotated.class));
@ -144,7 +145,7 @@ public class TigerAspectJExpressionPointcutTests {
@Test @Test
public void testMatchAnnotationOnClassWithExactPackageWildcard() throws SecurityException, NoSuchMethodException { public void testMatchAnnotationOnClassWithExactPackageWildcard() throws SecurityException, NoSuchMethodException {
String expression = "within(@(example.annotations.transaction.*) *)"; String expression = "within(@(test.annotation.transaction.*) *)";
testMatchAnnotationOnClass(expression); testMatchAnnotationOnClass(expression);
} }
@ -162,7 +163,7 @@ public class TigerAspectJExpressionPointcutTests {
@Test @Test
public void testAnnotationOnMethodWithFQN() throws SecurityException, NoSuchMethodException { public void testAnnotationOnMethodWithFQN() throws SecurityException, NoSuchMethodException {
String expression = "@annotation(example.annotations.transaction.Tx)"; String expression = "@annotation(test.annotation.transaction.Tx)";
AspectJExpressionPointcut ajexp = new AspectJExpressionPointcut(); AspectJExpressionPointcut ajexp = new AspectJExpressionPointcut();
ajexp.setExpression(expression); ajexp.setExpression(expression);
@ -176,7 +177,7 @@ public class TigerAspectJExpressionPointcutTests {
@Test @Test
public void testAnnotationOnMethodWithWildcard() throws SecurityException, NoSuchMethodException { public void testAnnotationOnMethodWithWildcard() throws SecurityException, NoSuchMethodException {
String expression = "execution(@(example.annotations..*) * *(..))"; String expression = "execution(@(test.annotation..*) * *(..))";
AspectJExpressionPointcut anySpringMethodAnnotation = new AspectJExpressionPointcut(); AspectJExpressionPointcut anySpringMethodAnnotation = new AspectJExpressionPointcut();
anySpringMethodAnnotation.setExpression(expression); anySpringMethodAnnotation.setExpression(expression);
@ -190,7 +191,7 @@ public class TigerAspectJExpressionPointcutTests {
@Test @Test
public void testAnnotationOnMethodArgumentsWithFQN() throws SecurityException, NoSuchMethodException { public void testAnnotationOnMethodArgumentsWithFQN() throws SecurityException, NoSuchMethodException {
String expression = "@args(*, example.annotations.EmptySpringAnnotation))"; String expression = "@args(*, test.annotation.EmptySpringAnnotation))";
AspectJExpressionPointcut takesSpringAnnotatedArgument2 = new AspectJExpressionPointcut(); AspectJExpressionPointcut takesSpringAnnotatedArgument2 = new AspectJExpressionPointcut();
takesSpringAnnotatedArgument2.setExpression(expression); takesSpringAnnotatedArgument2.setExpression(expression);
@ -219,7 +220,7 @@ public class TigerAspectJExpressionPointcutTests {
@Test @Test
public void testAnnotationOnMethodArgumentsWithWildcards() throws SecurityException, NoSuchMethodException { public void testAnnotationOnMethodArgumentsWithWildcards() throws SecurityException, NoSuchMethodException {
String expression = "execution(* *(*, @(example..*) *))"; String expression = "execution(* *(*, @(test..*) *))";
AspectJExpressionPointcut takesSpringAnnotatedArgument2 = new AspectJExpressionPointcut(); AspectJExpressionPointcut takesSpringAnnotatedArgument2 = new AspectJExpressionPointcut();
takesSpringAnnotatedArgument2.setExpression(expression); takesSpringAnnotatedArgument2.setExpression(expression);

View File

@ -31,7 +31,8 @@ import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.ClassPathResource;
import org.springframework.util.SerializationTestUtils; import org.springframework.util.SerializationTestUtils;
import common.beans.core.SideEffectBean; import test.beans.SideEffectBean;
/** /**
* @author Rod Johnson * @author Rod Johnson

View File

@ -24,7 +24,8 @@ import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.xml.XmlBeanFactory; import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.ClassPathResource;
import common.beans.core.SideEffectBean; import test.beans.SideEffectBean;
/** /**
* @author Rod Johnson * @author Rod Johnson

View File

@ -24,7 +24,8 @@ import org.springframework.beans.ITestBean;
import org.springframework.beans.factory.xml.XmlBeanFactory; import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.ClassPathResource;
import common.beans.core.SideEffectBean; import test.beans.SideEffectBean;
/** /**
* @author Rod Johnson * @author Rod Johnson

View File

@ -4,11 +4,11 @@
<beans> <beans>
<!-- Simple target --> <!-- Simple target -->
<bean id="target1" class="common.beans.core.SideEffectBean"> <bean id="target1" class="test.beans.SideEffectBean">
<property name="count"><value>10</value></property> <property name="count"><value>10</value></property>
</bean> </bean>
<bean id="target2" class="common.beans.core.SideEffectBean" scope="singleton"> <bean id="target2" class="test.beans.SideEffectBean" scope="singleton">
<property name="count"><value>20</value></property> <property name="count"><value>20</value></property>
</bean> </bean>

View File

@ -4,11 +4,11 @@
<beans> <beans>
<!-- Simple target --> <!-- Simple target -->
<bean id="test" class="common.beans.core.SideEffectBean"> <bean id="test" class="test.beans.SideEffectBean">
<property name="count"><value>10</value></property> <property name="count"><value>10</value></property>
</bean> </bean>
<bean id="prototypeTest" class="common.beans.core.SideEffectBean" scope="prototype"> <bean id="prototypeTest" class="test.beans.SideEffectBean" scope="prototype">
<property name="count"><value>10</value></property> <property name="count"><value>10</value></property>
</bean> </bean>

View File

@ -3,7 +3,7 @@
<beans> <beans>
<bean id="prototypeTest" class="common.beans.core.SideEffectBean" scope="prototype"> <bean id="prototypeTest" class="test.beans.SideEffectBean" scope="prototype">
<property name="count"><value>10</value></property> <property name="count"><value>10</value></property>
</bean> </bean>

View File

@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package example.annotations; package test.annotation;
import java.lang.annotation.ElementType; import java.lang.annotation.ElementType;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;

View File

@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package example.annotations.transaction; package test.annotation.transaction;
import java.lang.annotation.Documented; import java.lang.annotation.Documented;
import java.lang.annotation.ElementType; import java.lang.annotation.ElementType;

View File

@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package common.beans.core; package test.beans;
/** /**
* Bean that changes state on a business invocation, so that * Bean that changes state on a business invocation, so that