polishing .aop tests
This commit is contained in:
parent
ac9f9c1348
commit
7abde41d5b
|
@ -28,8 +28,9 @@ import org.junit.Before;
|
|||
import org.junit.Test;
|
||||
import org.springframework.beans.TestBean;
|
||||
|
||||
import example.annotations.EmptySpringAnnotation;
|
||||
import example.annotations.transaction.Tx;
|
||||
import test.annotation.EmptySpringAnnotation;
|
||||
import test.annotation.transaction.Tx;
|
||||
|
||||
|
||||
/**
|
||||
* Java5-specific AspectJExpressionPointcutTests.
|
||||
|
@ -117,26 +118,26 @@ public class TigerAspectJExpressionPointcutTests {
|
|||
|
||||
@Test
|
||||
public void testMatchAnnotationOnClassWithAtWithin() throws SecurityException, NoSuchMethodException {
|
||||
String expression = "@within(example.annotations.transaction.Tx)";
|
||||
String expression = "@within(test.annotation.transaction.Tx)";
|
||||
testMatchAnnotationOnClass(expression);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMatchAnnotationOnClassWithoutBinding() throws SecurityException, NoSuchMethodException {
|
||||
String expression = "within(@example.annotations.transaction.Tx *)";
|
||||
String expression = "within(@test.annotation.transaction.Tx *)";
|
||||
testMatchAnnotationOnClass(expression);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMatchAnnotationOnClassWithSubpackageWildcard() throws SecurityException, NoSuchMethodException {
|
||||
String expression = "within(@(example.annotations..*) *)";
|
||||
String expression = "within(@(test.annotation..*) *)";
|
||||
AspectJExpressionPointcut springAnnotatedPc = testMatchAnnotationOnClass(expression);
|
||||
assertFalse(springAnnotatedPc.matches(TestBean.class.getMethod("setName", String.class),
|
||||
TestBean.class));
|
||||
assertTrue(springAnnotatedPc.matches(SpringAnnotated.class.getMethod("foo", (Class[]) null),
|
||||
SpringAnnotated.class));
|
||||
|
||||
expression = "within(@(example.annotations.transaction..*) *)";
|
||||
expression = "within(@(test.annotation.transaction..*) *)";
|
||||
AspectJExpressionPointcut springTxAnnotatedPc = testMatchAnnotationOnClass(expression);
|
||||
assertFalse(springTxAnnotatedPc.matches(SpringAnnotated.class.getMethod("foo", (Class[]) null),
|
||||
SpringAnnotated.class));
|
||||
|
@ -144,7 +145,7 @@ public class TigerAspectJExpressionPointcutTests {
|
|||
|
||||
@Test
|
||||
public void testMatchAnnotationOnClassWithExactPackageWildcard() throws SecurityException, NoSuchMethodException {
|
||||
String expression = "within(@(example.annotations.transaction.*) *)";
|
||||
String expression = "within(@(test.annotation.transaction.*) *)";
|
||||
testMatchAnnotationOnClass(expression);
|
||||
}
|
||||
|
||||
|
@ -162,7 +163,7 @@ public class TigerAspectJExpressionPointcutTests {
|
|||
|
||||
@Test
|
||||
public void testAnnotationOnMethodWithFQN() throws SecurityException, NoSuchMethodException {
|
||||
String expression = "@annotation(example.annotations.transaction.Tx)";
|
||||
String expression = "@annotation(test.annotation.transaction.Tx)";
|
||||
AspectJExpressionPointcut ajexp = new AspectJExpressionPointcut();
|
||||
ajexp.setExpression(expression);
|
||||
|
||||
|
@ -176,7 +177,7 @@ public class TigerAspectJExpressionPointcutTests {
|
|||
|
||||
@Test
|
||||
public void testAnnotationOnMethodWithWildcard() throws SecurityException, NoSuchMethodException {
|
||||
String expression = "execution(@(example.annotations..*) * *(..))";
|
||||
String expression = "execution(@(test.annotation..*) * *(..))";
|
||||
AspectJExpressionPointcut anySpringMethodAnnotation = new AspectJExpressionPointcut();
|
||||
anySpringMethodAnnotation.setExpression(expression);
|
||||
|
||||
|
@ -190,7 +191,7 @@ public class TigerAspectJExpressionPointcutTests {
|
|||
|
||||
@Test
|
||||
public void testAnnotationOnMethodArgumentsWithFQN() throws SecurityException, NoSuchMethodException {
|
||||
String expression = "@args(*, example.annotations.EmptySpringAnnotation))";
|
||||
String expression = "@args(*, test.annotation.EmptySpringAnnotation))";
|
||||
AspectJExpressionPointcut takesSpringAnnotatedArgument2 = new AspectJExpressionPointcut();
|
||||
takesSpringAnnotatedArgument2.setExpression(expression);
|
||||
|
||||
|
@ -219,7 +220,7 @@ public class TigerAspectJExpressionPointcutTests {
|
|||
|
||||
@Test
|
||||
public void testAnnotationOnMethodArgumentsWithWildcards() throws SecurityException, NoSuchMethodException {
|
||||
String expression = "execution(* *(*, @(example..*) *))";
|
||||
String expression = "execution(* *(*, @(test..*) *))";
|
||||
AspectJExpressionPointcut takesSpringAnnotatedArgument2 = new AspectJExpressionPointcut();
|
||||
takesSpringAnnotatedArgument2.setExpression(expression);
|
||||
|
||||
|
|
|
@ -31,7 +31,8 @@ import org.springframework.beans.factory.xml.XmlBeanFactory;
|
|||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.util.SerializationTestUtils;
|
||||
|
||||
import common.beans.core.SideEffectBean;
|
||||
import test.beans.SideEffectBean;
|
||||
|
||||
|
||||
/**
|
||||
* @author Rod Johnson
|
||||
|
|
|
@ -24,7 +24,8 @@ import org.springframework.beans.factory.BeanFactory;
|
|||
import org.springframework.beans.factory.xml.XmlBeanFactory;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
|
||||
import common.beans.core.SideEffectBean;
|
||||
import test.beans.SideEffectBean;
|
||||
|
||||
|
||||
/**
|
||||
* @author Rod Johnson
|
||||
|
|
|
@ -24,7 +24,8 @@ import org.springframework.beans.ITestBean;
|
|||
import org.springframework.beans.factory.xml.XmlBeanFactory;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
|
||||
import common.beans.core.SideEffectBean;
|
||||
import test.beans.SideEffectBean;
|
||||
|
||||
|
||||
/**
|
||||
* @author Rod Johnson
|
||||
|
|
|
@ -4,11 +4,11 @@
|
|||
<beans>
|
||||
|
||||
<!-- Simple target -->
|
||||
<bean id="target1" class="common.beans.core.SideEffectBean">
|
||||
<bean id="target1" class="test.beans.SideEffectBean">
|
||||
<property name="count"><value>10</value></property>
|
||||
</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>
|
||||
</bean>
|
||||
|
||||
|
|
|
@ -4,11 +4,11 @@
|
|||
<beans>
|
||||
|
||||
<!-- Simple target -->
|
||||
<bean id="test" class="common.beans.core.SideEffectBean">
|
||||
<bean id="test" class="test.beans.SideEffectBean">
|
||||
<property name="count"><value>10</value></property>
|
||||
</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>
|
||||
</bean>
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
<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>
|
||||
</bean>
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package example.annotations;
|
||||
package test.annotation;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package example.annotations.transaction;
|
||||
package test.annotation.transaction;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package common.beans.core;
|
||||
package test.beans;
|
||||
|
||||
/**
|
||||
* Bean that changes state on a business invocation, so that
|
Loading…
Reference in New Issue