Remove duplicate test classes
Prior to this commit many test utility classes and sample beans were duplicated across projects. This was previously necessary due to the fact that dependent test sources were not shared during a gradle build. Since the introduction of the 'test-source-set-dependencies' gradle plugin this is no longer the case. This commit attempts to remove as much duplicate code as possible, co-locating test utilities and beans in the most suitable project. For example, test beans are now located in the 'spring-beans' project. Some of the duplicated code had started to drift apart when modifications made in one project where not ported to others. All changes have now been consolidated and when necessary existing tests have been refactored to account for the differences. Conflicts: spring-beans/src/test/java/org/springframework/beans/factory/ConcurrentBeanFactoryTests.java spring-beans/src/test/java/org/springframework/beans/factory/support/BeanFactoryGenericsTests.java spring-beans/src/test/java/org/springframework/beans/support/PagedListHolderTests.java
This commit is contained in:
committed by
Chris Beams
parent
2a30fa07ea
commit
42b5d6dd7e
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -33,10 +33,10 @@ import org.springframework.aop.Pointcut;
|
||||
import org.springframework.aop.framework.ProxyFactory;
|
||||
import org.springframework.aop.support.DefaultPointcutAdvisor;
|
||||
|
||||
import test.beans.IOther;
|
||||
import test.beans.ITestBean;
|
||||
import test.beans.TestBean;
|
||||
import test.beans.subpkg.DeepBean;
|
||||
import org.springframework.tests.sample.beans.IOther;
|
||||
import org.springframework.tests.sample.beans.ITestBean;
|
||||
import org.springframework.tests.sample.beans.TestBean;
|
||||
import org.springframework.tests.sample.beans.subpkg.DeepBean;
|
||||
|
||||
/**
|
||||
* @author Rob Harrop
|
||||
@@ -66,7 +66,7 @@ public final class AspectJExpressionPointcutTests {
|
||||
|
||||
@Test
|
||||
public void testMatchExplicit() {
|
||||
String expression = "execution(int test.beans.TestBean.getAge())";
|
||||
String expression = "execution(int org.springframework.tests.sample.beans.TestBean.getAge())";
|
||||
|
||||
Pointcut pointcut = getPointcut(expression);
|
||||
ClassFilter classFilter = pointcut.getClassFilter();
|
||||
@@ -128,8 +128,8 @@ public final class AspectJExpressionPointcutTests {
|
||||
* @throws SecurityException
|
||||
*/
|
||||
private void testThisOrTarget(String which) throws SecurityException, NoSuchMethodException {
|
||||
String matchesTestBean = which + "(test.beans.TestBean)";
|
||||
String matchesIOther = which + "(test.beans.IOther)";
|
||||
String matchesTestBean = which + "(org.springframework.tests.sample.beans.TestBean)";
|
||||
String matchesIOther = which + "(org.springframework.tests.sample.beans.IOther)";
|
||||
AspectJExpressionPointcut testBeanPc = new AspectJExpressionPointcut();
|
||||
testBeanPc.setExpression(matchesTestBean);
|
||||
|
||||
@@ -156,7 +156,7 @@ public final class AspectJExpressionPointcutTests {
|
||||
}
|
||||
|
||||
private void testWithinPackage(boolean matchSubpackages) throws SecurityException, NoSuchMethodException {
|
||||
String withinBeansPackage = "within(test.beans.";
|
||||
String withinBeansPackage = "within(org.springframework.tests.sample.beans.";
|
||||
// Subpackages are matched by **
|
||||
if (matchSubpackages) {
|
||||
withinBeansPackage += ".";
|
||||
@@ -214,7 +214,7 @@ public final class AspectJExpressionPointcutTests {
|
||||
|
||||
@Test
|
||||
public void testMatchWithArgs() throws Exception {
|
||||
String expression = "execution(void test.beans.TestBean.setSomeNumber(Number)) && args(Double)";
|
||||
String expression = "execution(void org.springframework.tests.sample.beans.TestBean.setSomeNumber(Number)) && args(Double)";
|
||||
|
||||
Pointcut pointcut = getPointcut(expression);
|
||||
ClassFilter classFilter = pointcut.getClassFilter();
|
||||
@@ -235,7 +235,7 @@ public final class AspectJExpressionPointcutTests {
|
||||
|
||||
@Test
|
||||
public void testSimpleAdvice() {
|
||||
String expression = "execution(int test.beans.TestBean.getAge())";
|
||||
String expression = "execution(int org.springframework.tests.sample.beans.TestBean.getAge())";
|
||||
|
||||
CallCountingInterceptor interceptor = new CallCountingInterceptor();
|
||||
|
||||
@@ -254,7 +254,7 @@ public final class AspectJExpressionPointcutTests {
|
||||
|
||||
@Test
|
||||
public void testDynamicMatchingProxy() {
|
||||
String expression = "execution(void test.beans.TestBean.setSomeNumber(Number)) && args(Double)";
|
||||
String expression = "execution(void org.springframework.tests.sample.beans.TestBean.setSomeNumber(Number)) && args(Double)";
|
||||
|
||||
CallCountingInterceptor interceptor = new CallCountingInterceptor();
|
||||
|
||||
@@ -273,7 +273,7 @@ public final class AspectJExpressionPointcutTests {
|
||||
|
||||
@Test
|
||||
public void testInvalidExpression() {
|
||||
String expression = "execution(void test.beans.TestBean.setSomeNumber(Number) && args(Double)";
|
||||
String expression = "execution(void org.springframework.tests.sample.beans.TestBean.setSomeNumber(Number) && args(Double)";
|
||||
|
||||
try {
|
||||
getPointcut(expression).getClassFilter(); // call to getClassFilter forces resolution
|
||||
@@ -315,7 +315,7 @@ public final class AspectJExpressionPointcutTests {
|
||||
|
||||
@Test
|
||||
public void testWithUnsupportedPointcutPrimitive() throws Exception {
|
||||
String expression = "call(int test.beans.TestBean.getAge())";
|
||||
String expression = "call(int org.springframework.tests.sample.beans.TestBean.getAge())";
|
||||
|
||||
try {
|
||||
getPointcut(expression).getClassFilter(); // call to getClassFilter forces resolution...
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -20,7 +20,7 @@ import static org.junit.Assert.*;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import test.beans.TestBean;
|
||||
import org.springframework.tests.sample.beans.TestBean;
|
||||
|
||||
/**
|
||||
* Tests for matching of bean() pointcut designator.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -28,8 +28,8 @@ import org.aspectj.lang.reflect.SourceLocation;
|
||||
import org.aspectj.runtime.reflect.Factory;
|
||||
import static org.junit.Assert.*;
|
||||
import org.junit.Test;
|
||||
import test.beans.ITestBean;
|
||||
import test.beans.TestBean;
|
||||
import org.springframework.tests.sample.beans.ITestBean;
|
||||
import org.springframework.tests.sample.beans.TestBean;
|
||||
|
||||
import org.springframework.aop.MethodBeforeAdvice;
|
||||
import org.springframework.aop.framework.AopContext;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -29,7 +29,7 @@ import org.junit.Test;
|
||||
|
||||
import test.annotation.EmptySpringAnnotation;
|
||||
import test.annotation.transaction.Tx;
|
||||
import test.beans.TestBean;
|
||||
import org.springframework.tests.sample.beans.TestBean;
|
||||
|
||||
|
||||
/**
|
||||
@@ -70,7 +70,7 @@ public final class TigerAspectJExpressionPointcutTests {
|
||||
|
||||
@Test
|
||||
public void testMatchGenericArgument() {
|
||||
String expression = "execution(* set*(java.util.List<test.beans.TestBean>) )";
|
||||
String expression = "execution(* set*(java.util.List<org.springframework.tests.sample.beans.TestBean>) )";
|
||||
AspectJExpressionPointcut ajexp = new AspectJExpressionPointcut();
|
||||
ajexp.setExpression(expression);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -22,11 +22,11 @@ import org.junit.Test;
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
|
||||
|
||||
import test.beans.CountingTestBean;
|
||||
import test.beans.IOther;
|
||||
import test.beans.ITestBean;
|
||||
import test.beans.TestBean;
|
||||
import test.beans.subpkg.DeepBean;
|
||||
import org.springframework.tests.sample.beans.CountingTestBean;
|
||||
import org.springframework.tests.sample.beans.IOther;
|
||||
import org.springframework.tests.sample.beans.ITestBean;
|
||||
import org.springframework.tests.sample.beans.TestBean;
|
||||
import org.springframework.tests.sample.beans.subpkg.DeepBean;
|
||||
|
||||
/**
|
||||
* Unit tests for the {@link TypePatternClassFilter} class.
|
||||
@@ -45,7 +45,7 @@ public final class TypePatternClassFilterTests {
|
||||
|
||||
@Test
|
||||
public void testValidPatternMatching() {
|
||||
TypePatternClassFilter tpcf = new TypePatternClassFilter("test.beans.*");
|
||||
TypePatternClassFilter tpcf = new TypePatternClassFilter("org.springframework.tests.sample.beans.*");
|
||||
assertTrue("Must match: in package", tpcf.matches(TestBean.class));
|
||||
assertTrue("Must match: in package", tpcf.matches(ITestBean.class));
|
||||
assertTrue("Must match: in package", tpcf.matches(IOther.class));
|
||||
@@ -56,7 +56,7 @@ public final class TypePatternClassFilterTests {
|
||||
|
||||
@Test
|
||||
public void testSubclassMatching() {
|
||||
TypePatternClassFilter tpcf = new TypePatternClassFilter("test.beans.ITestBean+");
|
||||
TypePatternClassFilter tpcf = new TypePatternClassFilter("org.springframework.tests.sample.beans.ITestBean+");
|
||||
assertTrue("Must match: in package", tpcf.matches(TestBean.class));
|
||||
assertTrue("Must match: in package", tpcf.matches(ITestBean.class));
|
||||
assertTrue("Must match: in package", tpcf.matches(CountingTestBean.class));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -58,8 +58,8 @@ import test.aop.DefaultLockable;
|
||||
import test.aop.Lockable;
|
||||
import test.aop.PerTargetAspect;
|
||||
import test.aop.TwoAdviceAspect;
|
||||
import test.beans.ITestBean;
|
||||
import test.beans.TestBean;
|
||||
import org.springframework.tests.sample.beans.ITestBean;
|
||||
import org.springframework.tests.sample.beans.TestBean;
|
||||
|
||||
/**
|
||||
* Abstract tests for AspectJAdvisorFactory.
|
||||
@@ -650,7 +650,7 @@ public abstract class AbstractAspectJAdvisorFactoryTests {
|
||||
}
|
||||
|
||||
|
||||
@Aspect("pertypewithin(test.beans.IOther+)")
|
||||
@Aspect("pertypewithin(org.springframework.tests.sample.beans.IOther+)")
|
||||
public static class PerTypeWithinAspect {
|
||||
|
||||
public int count;
|
||||
@@ -979,7 +979,7 @@ abstract class AbstractMakeModifiable {
|
||||
@Aspect
|
||||
class MakeITestBeanModifiable extends AbstractMakeModifiable {
|
||||
|
||||
@DeclareParents(value = "test.beans.ITestBean+",
|
||||
@DeclareParents(value = "org.springframework.tests.sample.beans.ITestBean+",
|
||||
defaultImpl=ModifiableImpl.class)
|
||||
public static MutableModifable mixin;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -29,8 +29,8 @@ import org.aspectj.lang.annotation.Pointcut;
|
||||
import org.junit.Test;
|
||||
import org.springframework.aop.aspectj.AspectJAdviceParameterNameDiscoverer;
|
||||
|
||||
import test.beans.ITestBean;
|
||||
import test.beans.TestBean;
|
||||
import org.springframework.tests.sample.beans.ITestBean;
|
||||
import org.springframework.tests.sample.beans.TestBean;
|
||||
|
||||
/**
|
||||
* @author Adrian Colyer
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -25,7 +25,7 @@ import org.springframework.aop.aspectj.AspectJExpressionPointcutTests;
|
||||
import org.springframework.aop.framework.AopConfigException;
|
||||
|
||||
import test.aop.PerTargetAspect;
|
||||
import test.beans.TestBean;
|
||||
import org.springframework.tests.sample.beans.TestBean;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,14 +16,16 @@
|
||||
|
||||
package org.springframework.aop.aspectj.annotation;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
import org.aspectj.lang.annotation.Around;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
import static org.junit.Assert.*;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.springframework.util.SerializationTestUtils;
|
||||
|
||||
import test.aop.PerThisAspect;
|
||||
import test.util.SerializationTestUtils;
|
||||
|
||||
/**
|
||||
* @author Rob Harrop
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2008 the original author or authors.
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.aop.aspectj.autoproxy;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -30,8 +30,7 @@ import org.springframework.beans.factory.support.DefaultListableBeanFactory;
|
||||
import org.springframework.beans.factory.xml.ParserContext;
|
||||
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
|
||||
import org.springframework.beans.factory.xml.XmlReaderContext;
|
||||
|
||||
import test.parsing.CollectingReaderEventListener;
|
||||
import org.springframework.tests.beans.CollectingReaderEventListener;
|
||||
|
||||
/**
|
||||
* @author Rob Harrop
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
<bean id="getAgeCounter" class="org.springframework.aop.framework.CountingBeforeAdvice"/>
|
||||
|
||||
<bean id="testBean" class="test.beans.TestBean"/>
|
||||
<bean id="testBean" class="org.springframework.tests.sample.beans.TestBean"/>
|
||||
|
||||
<bean id="countingAdvice" class="org.springframework.aop.config.CountingAspectJAdvice"/>
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,8 +16,10 @@
|
||||
|
||||
package org.springframework.aop.config;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static test.util.TestResourceUtils.qualifiedResource;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.springframework.tests.TestResourceUtils.qualifiedResource;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
@@ -32,8 +34,7 @@ import org.springframework.beans.factory.parsing.CompositeComponentDefinition;
|
||||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
|
||||
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
|
||||
import org.springframework.core.io.Resource;
|
||||
|
||||
import test.parsing.CollectingReaderEventListener;
|
||||
import org.springframework.tests.beans.CollectingReaderEventListener;
|
||||
|
||||
/**
|
||||
* @author Rob Harrop
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
<bean id="getAgeCounter" class="org.springframework.aop.framework.CountingBeforeAdvice"/>
|
||||
|
||||
<bean id="testBean" class="test.beans.TestBean"/>
|
||||
<bean id="testBean" class="org.springframework.tests.sample.beans.TestBean"/>
|
||||
|
||||
<bean id="countingAdvice" class="org.springframework.aop.config.CountingAspectJAdvice"/>
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
<bean id="getAgeCounter" class="org.springframework.aop.framework.CountingBeforeAdvice"/>
|
||||
|
||||
<bean id="testBean" class="test.beans.TestBean"/>
|
||||
<bean id="testBean" class="org.springframework.tests.sample.beans.TestBean"/>
|
||||
|
||||
<bean id="countingAdvice" class="org.springframework.aop.config.CountingAspectJAdvice"/>
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -18,7 +18,7 @@ package org.springframework.aop.config;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
import static test.util.TestResourceUtils.qualifiedResource;
|
||||
import static org.springframework.tests.TestResourceUtils.qualifiedResource;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.BeanDefinitionStoreException;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -17,7 +17,7 @@
|
||||
package org.springframework.aop.config;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static test.util.TestResourceUtils.qualifiedResource;
|
||||
import static org.springframework.tests.TestResourceUtils.qualifiedResource;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -27,8 +27,8 @@ import java.util.List;
|
||||
import org.junit.Test;
|
||||
import org.springframework.aop.SpringProxy;
|
||||
|
||||
import test.beans.ITestBean;
|
||||
import test.beans.TestBean;
|
||||
import org.springframework.tests.sample.beans.ITestBean;
|
||||
import org.springframework.tests.sample.beans.TestBean;
|
||||
|
||||
/**
|
||||
* @author Rod Johnson
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -20,8 +20,8 @@ import org.junit.Test;
|
||||
import org.springframework.aop.support.DelegatingIntroductionInterceptor;
|
||||
import org.springframework.util.StopWatch;
|
||||
|
||||
import test.beans.ITestBean;
|
||||
import test.beans.TestBean;
|
||||
import org.springframework.tests.sample.beans.ITestBean;
|
||||
import org.springframework.tests.sample.beans.TestBean;
|
||||
|
||||
/**
|
||||
* Benchmarks for introductions.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -26,7 +26,7 @@ import org.aopalliance.intercept.MethodInterceptor;
|
||||
import org.aopalliance.intercept.MethodInvocation;
|
||||
import org.junit.Test;
|
||||
|
||||
import test.beans.TestBean;
|
||||
import org.springframework.tests.sample.beans.TestBean;
|
||||
|
||||
/**
|
||||
* @author Rod Johnson
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -17,7 +17,7 @@
|
||||
package org.springframework.aop.framework;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static test.util.TestResourceUtils.qualifiedResource;
|
||||
import static org.springframework.tests.TestResourceUtils.qualifiedResource;
|
||||
|
||||
import org.aopalliance.intercept.MethodInterceptor;
|
||||
import org.aopalliance.intercept.MethodInvocation;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,28 +16,33 @@
|
||||
|
||||
package org.springframework.aop.framework;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.instanceOf;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import javax.accessibility.Accessible;
|
||||
import javax.swing.*;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.RootPaneContainer;
|
||||
|
||||
import org.aopalliance.intercept.MethodInterceptor;
|
||||
import org.aopalliance.intercept.MethodInvocation;
|
||||
import static org.hamcrest.CoreMatchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import test.aop.CountingBeforeAdvice;
|
||||
import test.aop.NopInterceptor;
|
||||
import test.beans.IOther;
|
||||
import test.beans.ITestBean;
|
||||
import test.beans.TestBean;
|
||||
import test.util.TimeStamped;
|
||||
|
||||
import org.springframework.aop.Advisor;
|
||||
import org.springframework.aop.interceptor.DebugInterceptor;
|
||||
import org.springframework.aop.support.AopUtils;
|
||||
import org.springframework.aop.support.DefaultIntroductionAdvisor;
|
||||
import org.springframework.aop.support.DefaultPointcutAdvisor;
|
||||
import org.springframework.aop.support.DelegatingIntroductionInterceptor;
|
||||
import org.springframework.tests.TimeStamped;
|
||||
import org.springframework.tests.aop.advice.CountingBeforeAdvice;
|
||||
import org.springframework.tests.aop.interceptor.NopInterceptor;
|
||||
import org.springframework.tests.sample.beans.IOther;
|
||||
import org.springframework.tests.sample.beans.ITestBean;
|
||||
import org.springframework.tests.sample.beans.TestBean;
|
||||
|
||||
/**
|
||||
* Also tests AdvisedSupport and ProxyCreatorSupport superclasses.
|
||||
@@ -190,7 +195,7 @@ public final class ProxyFactoryTests {
|
||||
TestBeanSubclass raw = new TestBeanSubclass();
|
||||
ProxyFactory factory = new ProxyFactory(raw);
|
||||
//System.out.println("Proxied interfaces are " + StringUtils.arrayToDelimitedString(factory.getProxiedInterfaces(), ","));
|
||||
assertEquals("Found correct number of interfaces", 3, factory.getProxiedInterfaces().length);
|
||||
assertEquals("Found correct number of interfaces", 5, factory.getProxiedInterfaces().length);
|
||||
ITestBean tb = (ITestBean) factory.getProxy();
|
||||
assertThat("Picked up secondary interface", tb, instanceOf(IOther.class));
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,21 +16,23 @@
|
||||
|
||||
package org.springframework.aop.framework.adapter;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.rmi.RemoteException;
|
||||
|
||||
import javax.transaction.TransactionRolledbackException;
|
||||
|
||||
import org.aopalliance.intercept.MethodInvocation;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
import org.junit.Test;
|
||||
import test.aop.MethodCounter;
|
||||
|
||||
import org.springframework.aop.ThrowsAdvice;
|
||||
import org.springframework.tests.aop.advice.MethodCounter;
|
||||
|
||||
|
||||
/**
|
||||
* @author Rod Johnson
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,19 +16,17 @@
|
||||
|
||||
package org.springframework.aop.interceptor;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.aop.framework.Advised;
|
||||
import org.springframework.aop.framework.ProxyFactory;
|
||||
|
||||
import test.beans.DerivedTestBean;
|
||||
import test.beans.ITestBean;
|
||||
import test.beans.TestBean;
|
||||
import test.util.SerializationTestUtils;
|
||||
import org.springframework.tests.sample.beans.DerivedTestBean;
|
||||
import org.springframework.tests.sample.beans.ITestBean;
|
||||
import org.springframework.tests.sample.beans.TestBean;
|
||||
import org.springframework.util.SerializationTestUtils;
|
||||
|
||||
/**
|
||||
* @author Juergen Hoeller
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -22,8 +22,8 @@ import org.junit.Test;
|
||||
import org.springframework.aop.framework.ProxyFactory;
|
||||
import org.springframework.beans.factory.NamedBean;
|
||||
|
||||
import test.beans.ITestBean;
|
||||
import test.beans.TestBean;
|
||||
import org.springframework.tests.sample.beans.ITestBean;
|
||||
import org.springframework.tests.sample.beans.TestBean;
|
||||
|
||||
/**
|
||||
* @author Rod Johnson
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
Tests for throws advice.
|
||||
-->
|
||||
<beans>
|
||||
|
||||
<bean id="nopInterceptor" class="test.aop.NopInterceptor"/>
|
||||
|
||||
<bean id="nopInterceptor" class="org.springframework.tests.aop.interceptor.NopInterceptor"/>
|
||||
|
||||
<bean id="exposeInvocation" class="org.springframework.beans.factory.config.FieldRetrievingFactoryBean">
|
||||
<property name="targetClass">
|
||||
@@ -14,8 +14,8 @@
|
||||
</property>
|
||||
<property name="targetField"><value>INSTANCE</value></property>
|
||||
</bean>
|
||||
|
||||
<bean id="countingBeforeAdvice" class="test.aop.CountingBeforeAdvice"/>
|
||||
|
||||
<bean id="countingBeforeAdvice" class="org.springframework.tests.aop.advice.CountingBeforeAdvice"/>
|
||||
|
||||
<bean id="proxy" class="org.springframework.aop.framework.ProxyFactoryBean">
|
||||
<property name="target">
|
||||
@@ -25,5 +25,5 @@
|
||||
<value>exposeInvocation,countingBeforeAdvice,nopInterceptor</value>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
</beans>
|
||||
|
||||
</beans>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -18,16 +18,15 @@ package org.springframework.aop.interceptor;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static test.util.TestResourceUtils.qualifiedResource;
|
||||
import static org.springframework.tests.TestResourceUtils.qualifiedResource;
|
||||
|
||||
import org.aopalliance.intercept.MethodInvocation;
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
|
||||
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
|
||||
import org.springframework.core.io.Resource;
|
||||
|
||||
import test.beans.ITestBean;
|
||||
import test.beans.TestBean;
|
||||
import org.springframework.tests.sample.beans.ITestBean;
|
||||
import org.springframework.tests.sample.beans.TestBean;
|
||||
|
||||
/**
|
||||
* Non-XML tests are in AbstractAopProxyTests
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -17,7 +17,7 @@
|
||||
package org.springframework.aop.scope;
|
||||
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static test.util.TestResourceUtils.qualifiedResource;
|
||||
import static org.springframework.tests.TestResourceUtils.qualifiedResource;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2008 the original author or authors.
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,15 +16,16 @@
|
||||
|
||||
package org.springframework.aop.support;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import test.beans.TestBean;
|
||||
import test.util.SerializationTestUtils;
|
||||
import org.springframework.tests.sample.beans.TestBean;
|
||||
import org.springframework.util.SerializationTestUtils;
|
||||
|
||||
/**
|
||||
* @author Rod Johnson
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,7 +16,9 @@
|
||||
|
||||
package org.springframework.aop.support;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
@@ -26,10 +28,10 @@ import org.springframework.aop.MethodMatcher;
|
||||
import org.springframework.aop.Pointcut;
|
||||
import org.springframework.aop.interceptor.ExposeInvocationInterceptor;
|
||||
import org.springframework.aop.target.EmptyTargetSource;
|
||||
import org.springframework.tests.aop.interceptor.NopInterceptor;
|
||||
import org.springframework.tests.sample.beans.TestBean;
|
||||
import org.springframework.util.SerializationTestUtils;
|
||||
|
||||
import test.aop.NopInterceptor;
|
||||
import test.beans.TestBean;
|
||||
import test.util.SerializationTestUtils;
|
||||
|
||||
/**
|
||||
* @author Rod Johnson
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -22,8 +22,8 @@ import org.junit.Test;
|
||||
import org.springframework.aop.ClassFilter;
|
||||
import org.springframework.core.NestedRuntimeException;
|
||||
|
||||
import test.beans.ITestBean;
|
||||
import test.beans.TestBean;
|
||||
import org.springframework.tests.sample.beans.ITestBean;
|
||||
import org.springframework.tests.sample.beans.TestBean;
|
||||
|
||||
/**
|
||||
* @author Rod Johnson
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2009 the original author or authors.
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -18,7 +18,7 @@ package org.springframework.aop.support;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.springframework.aop.framework.ProxyFactory;
|
||||
import test.beans.TestBean;
|
||||
import org.springframework.tests.sample.beans.TestBean;
|
||||
import org.springframework.util.ClassUtils;
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -26,7 +26,7 @@ import org.springframework.aop.MethodMatcher;
|
||||
import org.springframework.aop.Pointcut;
|
||||
import org.springframework.core.NestedRuntimeException;
|
||||
|
||||
import test.beans.TestBean;
|
||||
import org.springframework.tests.sample.beans.TestBean;
|
||||
|
||||
/**
|
||||
* @author Rod Johnson
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,15 +16,16 @@
|
||||
|
||||
package org.springframework.aop.support;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.aop.Pointcut;
|
||||
import org.springframework.aop.framework.ProxyFactory;
|
||||
import org.springframework.tests.aop.interceptor.NopInterceptor;
|
||||
import org.springframework.tests.sample.beans.ITestBean;
|
||||
import org.springframework.tests.sample.beans.TestBean;
|
||||
|
||||
import test.aop.NopInterceptor;
|
||||
import test.beans.ITestBean;
|
||||
import test.beans.TestBean;
|
||||
|
||||
/**
|
||||
* @author Rod Johnson
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,7 +16,9 @@
|
||||
|
||||
package org.springframework.aop.support;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
@@ -27,16 +29,15 @@ import org.junit.Test;
|
||||
import org.springframework.aop.IntroductionAdvisor;
|
||||
import org.springframework.aop.IntroductionInterceptor;
|
||||
import org.springframework.aop.framework.ProxyFactory;
|
||||
|
||||
import test.aop.SerializableNopInterceptor;
|
||||
import test.beans.INestedTestBean;
|
||||
import test.beans.ITestBean;
|
||||
import test.beans.NestedTestBean;
|
||||
import test.beans.Person;
|
||||
import test.beans.SerializablePerson;
|
||||
import test.beans.TestBean;
|
||||
import test.util.SerializationTestUtils;
|
||||
import test.util.TimeStamped;
|
||||
import org.springframework.tests.TimeStamped;
|
||||
import org.springframework.tests.aop.interceptor.SerializableNopInterceptor;
|
||||
import org.springframework.tests.sample.beans.INestedTestBean;
|
||||
import org.springframework.tests.sample.beans.ITestBean;
|
||||
import org.springframework.tests.sample.beans.NestedTestBean;
|
||||
import org.springframework.tests.sample.beans.Person;
|
||||
import org.springframework.tests.sample.beans.SerializablePerson;
|
||||
import org.springframework.tests.sample.beans.TestBean;
|
||||
import org.springframework.util.SerializationTestUtils;
|
||||
|
||||
/**
|
||||
* @author Rod Johnson
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,17 +16,18 @@
|
||||
|
||||
package org.springframework.aop.support;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.aop.MethodMatcher;
|
||||
|
||||
import test.beans.IOther;
|
||||
import test.beans.ITestBean;
|
||||
import test.beans.TestBean;
|
||||
import test.util.SerializationTestUtils;
|
||||
import org.springframework.tests.sample.beans.IOther;
|
||||
import org.springframework.tests.sample.beans.ITestBean;
|
||||
import org.springframework.tests.sample.beans.TestBean;
|
||||
import org.springframework.util.SerializationTestUtils;
|
||||
|
||||
/**
|
||||
* @author Juergen Hoeller
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,18 +16,20 @@
|
||||
|
||||
package org.springframework.aop.support;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.aop.framework.Advised;
|
||||
import org.springframework.aop.framework.ProxyFactory;
|
||||
import org.springframework.tests.aop.interceptor.NopInterceptor;
|
||||
import org.springframework.tests.aop.interceptor.SerializableNopInterceptor;
|
||||
import org.springframework.tests.sample.beans.Person;
|
||||
import org.springframework.tests.sample.beans.SerializablePerson;
|
||||
import org.springframework.util.SerializationTestUtils;
|
||||
|
||||
import test.aop.NopInterceptor;
|
||||
import test.aop.SerializableNopInterceptor;
|
||||
import test.beans.Person;
|
||||
import test.beans.SerializablePerson;
|
||||
import test.util.SerializationTestUtils;
|
||||
|
||||
/**
|
||||
* @author Rod Johnson
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -24,7 +24,7 @@ import org.junit.Test;
|
||||
import org.springframework.aop.ClassFilter;
|
||||
import org.springframework.aop.Pointcut;
|
||||
|
||||
import test.beans.TestBean;
|
||||
import org.springframework.tests.sample.beans.TestBean;
|
||||
|
||||
/**
|
||||
* @author Rod Johnson
|
||||
|
||||
@@ -4,12 +4,12 @@
|
||||
<beans>
|
||||
|
||||
<!-- Simple target -->
|
||||
<bean id="test" class="test.beans.TestBean">
|
||||
<bean id="test" class="org.springframework.tests.sample.beans.TestBean">
|
||||
<property name="name"><value>custom</value></property>
|
||||
<property name="age"><value>666</value></property>
|
||||
</bean>
|
||||
|
||||
<bean id="nopInterceptor" class="test.aop.SerializableNopInterceptor"/>
|
||||
<bean id="nopInterceptor" class="org.springframework.tests.aop.interceptor.SerializableNopInterceptor"/>
|
||||
|
||||
<bean id="settersAdvisor" class="org.springframework.aop.support.RegexpMethodPointcutAdvisor">
|
||||
<property name="advice"><ref local="nopInterceptor"/></property>
|
||||
@@ -21,19 +21,19 @@
|
||||
</bean>
|
||||
|
||||
<bean id="settersAdvised" class="org.springframework.aop.framework.ProxyFactoryBean">
|
||||
<property name="proxyInterfaces"><value>test.beans.ITestBean</value></property>
|
||||
<property name="proxyInterfaces"><value>org.springframework.tests.sample.beans.ITestBean</value></property>
|
||||
<property name="target"><ref local="test"/></property>
|
||||
<property name="interceptorNames"><value>settersAdvisor</value></property>
|
||||
<property name="interceptorNames"><value>settersAdvisor</value></property>
|
||||
</bean>
|
||||
|
||||
<bean id="serializableSettersAdvised" class="org.springframework.aop.framework.ProxyFactoryBean">
|
||||
<property name="proxyInterfaces"><value>test.beans.Person</value></property>
|
||||
<property name="proxyInterfaces"><value>org.springframework.tests.sample.beans.Person</value></property>
|
||||
<property name="target">
|
||||
<bean class="test.beans.SerializablePerson">
|
||||
<bean class="org.springframework.tests.sample.beans.SerializablePerson">
|
||||
<property name="name"><value>serializableSettersAdvised</value></property>
|
||||
</bean>
|
||||
</property>
|
||||
<property name="interceptorNames"><value>settersAdvisor</value></property>
|
||||
<property name="interceptorNames"><value>settersAdvisor</value></property>
|
||||
</bean>
|
||||
|
||||
<!-- Illustrates use of multiple patterns -->
|
||||
@@ -48,11 +48,11 @@
|
||||
</bean>
|
||||
|
||||
<bean id="settersAndAbsquatulateAdvised" class="org.springframework.aop.framework.ProxyFactoryBean">
|
||||
<property name="proxyInterfaces"><value>test.beans.ITestBean</value></property>
|
||||
<property name="proxyInterfaces"><value>org.springframework.tests.sample.beans.ITestBean</value></property>
|
||||
<!-- Force CGLIB so we can cast to TestBean -->
|
||||
<property name="proxyTargetClass"><value>true</value></property>
|
||||
<property name="target"><ref local="test"/></property>
|
||||
<property name="interceptorNames"><value>settersAndAbsquatulateAdvisor</value></property>
|
||||
<property name="target"><ref local="test"/></property>
|
||||
<property name="interceptorNames"><value>settersAndAbsquatulateAdvisor</value></property>
|
||||
</bean>
|
||||
|
||||
</beans>
|
||||
</beans>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -17,20 +17,20 @@
|
||||
package org.springframework.aop.support;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static test.util.TestResourceUtils.qualifiedResource;
|
||||
import static org.springframework.tests.TestResourceUtils.qualifiedResource;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.aop.framework.Advised;
|
||||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
|
||||
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.tests.aop.interceptor.NopInterceptor;
|
||||
import org.springframework.tests.aop.interceptor.SerializableNopInterceptor;
|
||||
import org.springframework.tests.sample.beans.ITestBean;
|
||||
import org.springframework.tests.sample.beans.Person;
|
||||
import org.springframework.tests.sample.beans.TestBean;
|
||||
import org.springframework.util.SerializationTestUtils;
|
||||
|
||||
import test.aop.NopInterceptor;
|
||||
import test.aop.SerializableNopInterceptor;
|
||||
import test.beans.ITestBean;
|
||||
import test.beans.Person;
|
||||
import test.beans.TestBean;
|
||||
import test.util.SerializationTestUtils;
|
||||
|
||||
/**
|
||||
* @author Rod Johnson
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
<beans>
|
||||
|
||||
<bean id="testBeanTarget" class="test.beans.TestBean" scope="prototype"/>
|
||||
<bean id="testBeanTarget" class="org.springframework.tests.sample.beans.TestBean" scope="prototype"/>
|
||||
|
||||
<bean id="targetSource" class="org.springframework.aop.target.CommonsPoolTargetSource">
|
||||
<property name="targetBeanName" value="testBeanTarget"/>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -17,15 +17,14 @@
|
||||
package org.springframework.aop.target;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static test.util.TestResourceUtils.qualifiedResource;
|
||||
import static org.springframework.tests.TestResourceUtils.qualifiedResource;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.aop.support.AopUtils;
|
||||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
|
||||
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
|
||||
import org.springframework.core.io.Resource;
|
||||
|
||||
import test.beans.ITestBean;
|
||||
import org.springframework.tests.sample.beans.ITestBean;
|
||||
|
||||
/**
|
||||
* @author Rob Harrop
|
||||
|
||||
@@ -4,15 +4,15 @@
|
||||
<beans>
|
||||
|
||||
<!-- Simple target -->
|
||||
<bean id="target1" class="test.beans.SideEffectBean">
|
||||
<bean id="target1" class="org.springframework.tests.sample.beans.SideEffectBean">
|
||||
<property name="count"><value>10</value></property>
|
||||
</bean>
|
||||
|
||||
<bean id="target2" class="test.beans.SideEffectBean" scope="singleton">
|
||||
<bean id="target2" class="org.springframework.tests.sample.beans.SideEffectBean" scope="singleton">
|
||||
<property name="count"><value>20</value></property>
|
||||
</bean>
|
||||
|
||||
<!--
|
||||
|
||||
<!--
|
||||
Hot swappable target source. Note the use of Type 3 IoC.
|
||||
-->
|
||||
<bean id="swapper" class="org.springframework.aop.target.HotSwappableTargetSource">
|
||||
@@ -23,5 +23,4 @@
|
||||
<property name="targetSource"><ref local="swapper"/></property>
|
||||
</bean>
|
||||
|
||||
</beans>
|
||||
|
||||
</beans>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -19,7 +19,7 @@ package org.springframework.aop.target;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
import static test.util.TestResourceUtils.qualifiedResource;
|
||||
import static org.springframework.tests.TestResourceUtils.qualifiedResource;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
@@ -30,12 +30,12 @@ import org.springframework.aop.support.DefaultPointcutAdvisor;
|
||||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
|
||||
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.tests.aop.interceptor.SerializableNopInterceptor;
|
||||
import org.springframework.tests.sample.beans.Person;
|
||||
import org.springframework.tests.sample.beans.SerializablePerson;
|
||||
import org.springframework.tests.sample.beans.SideEffectBean;
|
||||
import org.springframework.util.SerializationTestUtils;
|
||||
|
||||
import test.aop.SerializableNopInterceptor;
|
||||
import test.beans.Person;
|
||||
import test.beans.SerializablePerson;
|
||||
import test.beans.SideEffectBean;
|
||||
import test.util.SerializationTestUtils;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
<beans>
|
||||
|
||||
<bean id="target" class="test.beans.TestBean" lazy-init="true">
|
||||
<bean id="target" class="org.springframework.tests.sample.beans.TestBean" lazy-init="true">
|
||||
<property name="age"><value>10</value></property>
|
||||
</bean>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
<beans>
|
||||
|
||||
<bean id="target" class="test.beans.TestBean" lazy-init="true">
|
||||
<bean id="target" class="org.springframework.tests.sample.beans.TestBean" lazy-init="true">
|
||||
<property name="age"><value>10</value></property>
|
||||
</bean>
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -19,7 +19,7 @@ package org.springframework.aop.target;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static test.util.TestResourceUtils.qualifiedResource;
|
||||
import static org.springframework.tests.TestResourceUtils.qualifiedResource;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@@ -27,8 +27,7 @@ import org.junit.Test;
|
||||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
|
||||
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
|
||||
import org.springframework.core.io.Resource;
|
||||
|
||||
import test.beans.ITestBean;
|
||||
import org.springframework.tests.sample.beans.ITestBean;
|
||||
|
||||
/**
|
||||
* @author Juergen Hoeller
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,17 +16,17 @@
|
||||
|
||||
package org.springframework.aop.target;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.aop.TargetSource;
|
||||
import org.springframework.beans.MutablePropertyValues;
|
||||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
|
||||
import org.springframework.beans.factory.support.RootBeanDefinition;
|
||||
|
||||
import test.beans.SerializablePerson;
|
||||
import test.beans.TestBean;
|
||||
import test.util.SerializationTestUtils;
|
||||
import org.springframework.tests.sample.beans.SerializablePerson;
|
||||
import org.springframework.tests.sample.beans.TestBean;
|
||||
import org.springframework.util.SerializationTestUtils;
|
||||
|
||||
/**
|
||||
* Unit tests relating to the abstract {@link AbstractPrototypeBasedTargetSource}
|
||||
|
||||
@@ -4,22 +4,22 @@
|
||||
<beans>
|
||||
|
||||
<!-- Simple target -->
|
||||
<bean id="test" class="test.beans.SideEffectBean">
|
||||
<property name="count"><value>10</value></property>
|
||||
</bean>
|
||||
|
||||
<bean id="prototypeTest" class="test.beans.SideEffectBean" scope="prototype">
|
||||
<bean id="test" class="org.springframework.tests.sample.beans.SideEffectBean">
|
||||
<property name="count"><value>10</value></property>
|
||||
</bean>
|
||||
|
||||
<bean id="prototypeTargetSource" class="org.springframework.aop.target.PrototypeTargetSource">
|
||||
<bean id="prototypeTest" class="org.springframework.tests.sample.beans.SideEffectBean" scope="prototype">
|
||||
<property name="count"><value>10</value></property>
|
||||
</bean>
|
||||
|
||||
<bean id="prototypeTargetSource" class="org.springframework.aop.target.PrototypeTargetSource">
|
||||
<property name="targetBeanName"><value>prototypeTest</value></property>
|
||||
</bean>
|
||||
|
||||
<bean id="debugInterceptor" class="test.aop.NopInterceptor" />
|
||||
|
||||
|
||||
<bean id="debugInterceptor" class="org.springframework.tests.aop.interceptor.NopInterceptor" />
|
||||
|
||||
<bean id="singleton" class="org.springframework.aop.framework.ProxyFactoryBean">
|
||||
<property name="interceptorNames"><value>debugInterceptor,test</value></property>
|
||||
<property name="interceptorNames"><value>debugInterceptor,test</value></property>
|
||||
</bean>
|
||||
|
||||
<!--
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -17,7 +17,7 @@
|
||||
package org.springframework.aop.target;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static test.util.TestResourceUtils.qualifiedResource;
|
||||
import static org.springframework.tests.TestResourceUtils.qualifiedResource;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -26,8 +26,7 @@ import org.springframework.beans.factory.support.BeanDefinitionRegistry;
|
||||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
|
||||
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
|
||||
import org.springframework.core.io.Resource;
|
||||
|
||||
import test.beans.SideEffectBean;
|
||||
import org.springframework.tests.sample.beans.SideEffectBean;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,17 +2,17 @@
|
||||
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd">
|
||||
|
||||
<beans>
|
||||
|
||||
<bean id="prototypeTest" class="test.beans.SideEffectBean" scope="prototype">
|
||||
|
||||
<bean id="prototypeTest" class="org.springframework.tests.sample.beans.SideEffectBean" scope="prototype">
|
||||
<property name="count"><value>10</value></property>
|
||||
</bean>
|
||||
|
||||
<bean id="threadLocalTs" class="org.springframework.aop.target.ThreadLocalTargetSource">
|
||||
|
||||
<bean id="threadLocalTs" class="org.springframework.aop.target.ThreadLocalTargetSource">
|
||||
<property name="targetBeanName"><value>prototypeTest</value></property>
|
||||
</bean>
|
||||
|
||||
<bean id="debugInterceptor" class="test.aop.NopInterceptor" />
|
||||
|
||||
|
||||
<bean id="debugInterceptor" class="org.springframework.tests.aop.interceptor.NopInterceptor" />
|
||||
|
||||
<!--
|
||||
We want to invoke the getStatsMixin method on our ThreadLocal invoker
|
||||
-->
|
||||
@@ -20,7 +20,7 @@
|
||||
<property name="targetObject"><ref local="threadLocalTs" /></property>
|
||||
<property name="targetMethod"><value>getStatsMixin</value></property>
|
||||
</bean>
|
||||
|
||||
|
||||
<!--
|
||||
This will create a bean for each thread ("apartment")
|
||||
-->
|
||||
@@ -33,23 +33,22 @@
|
||||
</bean>
|
||||
|
||||
<!-- ================ Definitions for second ThreadLocalTargetSource ====== -->
|
||||
|
||||
<bean id="test" class="test.beans.TestBean" scope="prototype">
|
||||
|
||||
<bean id="test" class="org.springframework.tests.sample.beans.TestBean" scope="prototype">
|
||||
<property name="name"><value>Rod</value></property>
|
||||
<property name="spouse"><ref local="wife"/></property>
|
||||
</bean>
|
||||
|
||||
<bean id="wife" class="test.beans.TestBean">
|
||||
|
||||
<bean id="wife" class="org.springframework.tests.sample.beans.TestBean">
|
||||
<property name="name"><value>Kerry</value></property>
|
||||
</bean>
|
||||
|
||||
<bean id="threadLocalTs2" class="org.springframework.aop.target.ThreadLocalTargetSource">
|
||||
|
||||
<bean id="threadLocalTs2" class="org.springframework.aop.target.ThreadLocalTargetSource">
|
||||
<property name="targetBeanName"><value>test</value></property>
|
||||
</bean>
|
||||
|
||||
|
||||
<bean id="threadLocal2" class="org.springframework.aop.framework.ProxyFactoryBean">
|
||||
<property name="targetSource"><ref local="threadLocalTs2"/></property>
|
||||
</bean>
|
||||
|
||||
</beans>
|
||||
|
||||
</beans>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -19,16 +19,15 @@ package org.springframework.aop.target;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.fail;
|
||||
import static test.util.TestResourceUtils.qualifiedResource;
|
||||
import static org.springframework.tests.TestResourceUtils.qualifiedResource;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
|
||||
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
|
||||
import org.springframework.core.io.Resource;
|
||||
|
||||
import test.beans.ITestBean;
|
||||
import test.beans.SideEffectBean;
|
||||
import org.springframework.tests.sample.beans.ITestBean;
|
||||
import org.springframework.tests.sample.beans.SideEffectBean;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.tests.aop.advice;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.springframework.aop.AfterReturningAdvice;
|
||||
|
||||
/**
|
||||
* Simple before advice example that we can use for counting checks.
|
||||
*
|
||||
* @author Rod Johnson
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class CountingAfterReturningAdvice extends MethodCounter implements AfterReturningAdvice {
|
||||
|
||||
@Override
|
||||
public void afterReturning(Object o, Method m, Object[] args, Object target) throws Throwable {
|
||||
count(m);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.tests.aop.advice;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.springframework.aop.MethodBeforeAdvice;
|
||||
|
||||
/**
|
||||
* Simple before advice example that we can use for counting checks.
|
||||
*
|
||||
* @author Rod Johnson
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class CountingBeforeAdvice extends MethodCounter implements MethodBeforeAdvice {
|
||||
|
||||
@Override
|
||||
public void before(Method m, Object[] args, Object target) throws Throwable {
|
||||
count(m);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.tests.aop.advice;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* Abstract superclass for counting advices etc.
|
||||
*
|
||||
* @author Rod Johnson
|
||||
* @author Chris Beams
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class MethodCounter implements Serializable {
|
||||
|
||||
/** Method name --> count, does not understand overloading */
|
||||
private HashMap<String, Integer> map = new HashMap<String, Integer>();
|
||||
|
||||
private int allCount;
|
||||
|
||||
protected void count(Method m) {
|
||||
count(m.getName());
|
||||
}
|
||||
|
||||
protected void count(String methodName) {
|
||||
Integer i = map.get(methodName);
|
||||
i = (i != null) ? new Integer(i.intValue() + 1) : new Integer(1);
|
||||
map.put(methodName, i);
|
||||
++allCount;
|
||||
}
|
||||
|
||||
public int getCalls(String methodName) {
|
||||
Integer i = map.get(methodName);
|
||||
return (i != null ? i.intValue() : 0);
|
||||
}
|
||||
|
||||
public int getCalls() {
|
||||
return allCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* A bit simplistic: just wants the same class.
|
||||
* Doesn't worry about counts.
|
||||
* @see java.lang.Object#equals(java.lang.Object)
|
||||
*/
|
||||
public boolean equals(Object other) {
|
||||
return (other != null && other.getClass() == this.getClass());
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return getClass().hashCode();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package org.springframework.tests.aop.advice;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.rmi.RemoteException;
|
||||
|
||||
import org.springframework.aop.ThrowsAdvice;
|
||||
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class MyThrowsHandler extends MethodCounter implements ThrowsAdvice {
|
||||
// Full method signature
|
||||
public void afterThrowing(Method m, Object[] args, Object target, IOException ex) {
|
||||
count("ioException");
|
||||
}
|
||||
public void afterThrowing(RemoteException ex) throws Throwable {
|
||||
count("remoteException");
|
||||
}
|
||||
|
||||
/** Not valid, wrong number of arguments */
|
||||
public void afterThrowing(Method m, Exception ex) throws Throwable {
|
||||
throw new UnsupportedOperationException("Shouldn't be called");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.tests.aop.advice;
|
||||
|
||||
import org.springframework.aop.support.DelegatingIntroductionInterceptor;
|
||||
import org.springframework.aop.support.DefaultIntroductionAdvisor;
|
||||
import org.springframework.tests.aop.interceptor.TimestampIntroductionInterceptor;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Rod Johnson
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class TimestampIntroductionAdvisor extends DefaultIntroductionAdvisor {
|
||||
|
||||
/**
|
||||
* @param dii
|
||||
*/
|
||||
public TimestampIntroductionAdvisor() {
|
||||
super(new DelegatingIntroductionInterceptor(new TimestampIntroductionInterceptor()));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.tests.aop.interceptor;
|
||||
|
||||
import org.aopalliance.intercept.MethodInterceptor;
|
||||
import org.aopalliance.intercept.MethodInvocation;
|
||||
|
||||
/**
|
||||
* Trivial interceptor that can be introduced in a chain to display it.
|
||||
*
|
||||
* @author Rod Johnson
|
||||
*/
|
||||
public class NopInterceptor implements MethodInterceptor {
|
||||
|
||||
private int count;
|
||||
|
||||
/**
|
||||
* @see org.aopalliance.intercept.MethodInterceptor#invoke(MethodInvocation)
|
||||
*/
|
||||
@Override
|
||||
public Object invoke(MethodInvocation invocation) throws Throwable {
|
||||
increment();
|
||||
return invocation.proceed();
|
||||
}
|
||||
|
||||
public int getCount() {
|
||||
return this.count;
|
||||
}
|
||||
|
||||
protected void increment() {
|
||||
++count;
|
||||
}
|
||||
|
||||
public boolean equals(Object other) {
|
||||
if (!(other instanceof NopInterceptor)) {
|
||||
return false;
|
||||
}
|
||||
if (this == other) {
|
||||
return true;
|
||||
}
|
||||
return this.count == ((NopInterceptor) other).count;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.tests.aop.interceptor;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
|
||||
/**
|
||||
* Subclass of NopInterceptor that is serializable and
|
||||
* can be used to test proxy serialization.
|
||||
*
|
||||
* @author Rod Johnson
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class SerializableNopInterceptor extends NopInterceptor implements Serializable {
|
||||
|
||||
/**
|
||||
* We must override this field and the related methods as
|
||||
* otherwise count won't be serialized from the non-serializable
|
||||
* NopInterceptor superclass.
|
||||
*/
|
||||
private int count;
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return this.count;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void increment() {
|
||||
++count;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.tests.aop.interceptor;
|
||||
|
||||
import org.springframework.aop.support.DelegatingIntroductionInterceptor;
|
||||
import org.springframework.tests.TimeStamped;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class TimestampIntroductionInterceptor extends DelegatingIntroductionInterceptor
|
||||
implements TimeStamped {
|
||||
|
||||
private long ts;
|
||||
|
||||
public TimestampIntroductionInterceptor() {
|
||||
}
|
||||
|
||||
public TimestampIntroductionInterceptor(long ts) {
|
||||
this.ts = ts;
|
||||
}
|
||||
|
||||
public void setTime(long ts) {
|
||||
this.ts = ts;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getTimeStamp() {
|
||||
return ts;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.tests.sample.beans;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Rod Johnson
|
||||
*/
|
||||
public interface Person {
|
||||
|
||||
String getName();
|
||||
|
||||
void setName(String name);
|
||||
|
||||
int getAge();
|
||||
|
||||
void setAge(int i);
|
||||
|
||||
/**
|
||||
* Test for non-property method matching. If the parameter is a Throwable, it will be
|
||||
* thrown rather than returned.
|
||||
*/
|
||||
Object echo(Object o) throws Throwable;
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.tests.sample.beans;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
/**
|
||||
* Serializable implementation of the Person interface.
|
||||
*
|
||||
* @author Rod Johnson
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class SerializablePerson implements Person, Serializable {
|
||||
|
||||
private String name;
|
||||
private int age;
|
||||
|
||||
@Override
|
||||
public int getAge() {
|
||||
return age;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAge(int age) {
|
||||
this.age = age;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object echo(Object o) throws Throwable {
|
||||
if (o instanceof Throwable) {
|
||||
throw (Throwable) o;
|
||||
}
|
||||
return o;
|
||||
}
|
||||
|
||||
public boolean equals(Object other) {
|
||||
if (!(other instanceof SerializablePerson)) {
|
||||
return false;
|
||||
}
|
||||
SerializablePerson p = (SerializablePerson) other;
|
||||
return p.age == age && ObjectUtils.nullSafeEquals(name, p.name);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.tests.sample.beans.subpkg;
|
||||
|
||||
import org.springframework.aop.aspectj.AspectJExpressionPointcutTests;
|
||||
|
||||
/**
|
||||
* Used for testing pointcut matching.
|
||||
*
|
||||
* @see AspectJExpressionPointcutTests#testWithinRootAndSubpackages()
|
||||
*
|
||||
* @author Chris Beams
|
||||
*/
|
||||
public class DeepBean {
|
||||
public void aMethod(String foo) {
|
||||
// no-op
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user