Skip to content

Commit

Permalink
Use Gradle test fixture support for spring-aop
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrannen committed Jan 2, 2020
1 parent 5581f3b commit 8a371c7
Show file tree
Hide file tree
Showing 59 changed files with 105 additions and 144 deletions.
Expand Up @@ -62,7 +62,8 @@ public class TestSourcesPlugin implements Plugin<Project> {
private static final List<String> excludedProjects = Arrays.asList(
"integration-tests",
"kotlin-coroutines",
// "spring-aop",
"spring-aop",
"spring-aspects",
"spring-beans",
"spring-context",
"spring-context-indexer",
Expand Down
1 change: 1 addition & 0 deletions integration-tests/integration-tests.gradle
Expand Up @@ -7,6 +7,7 @@ dependencies {
testCompile(project(":spring-beans"))
testCompile(project(":spring-context"))
testCompile(project(":spring-core"))
testCompile(testFixtures(project(":spring-aop")))
testCompile(testFixtures(project(":spring-beans")))
testCompile(testFixtures(project(":spring-core")))
testCompile(testFixtures(project(":spring-tx")))
Expand Down
Expand Up @@ -26,14 +26,14 @@

import org.springframework.aop.support.AopUtils;
import org.springframework.aop.support.StaticMethodMatcherPointcutAdvisor;
import org.springframework.aop.testfixture.advice.CountingBeforeAdvice;
import org.springframework.aop.testfixture.advice.MethodCounter;
import org.springframework.aop.testfixture.interceptor.NopInterceptor;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.testfixture.beans.ITestBean;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.lang.Nullable;
import org.springframework.tests.aop.advice.CountingBeforeAdvice;
import org.springframework.tests.aop.advice.MethodCounter;
import org.springframework.tests.aop.interceptor.NopInterceptor;
import org.springframework.transaction.NoTransactionException;
import org.springframework.transaction.interceptor.TransactionInterceptor;
import org.springframework.transaction.testfixture.CallCountingTransactionManager;
Expand Down
Expand Up @@ -85,7 +85,7 @@
<property name="pattern"><value>org.springframework.beans.testfixture.beans.ITestBean.getName</value></property>
</bean>

<bean id="countingAdvice" class="org.springframework.tests.aop.advice.CountingAfterReturningAdvice"/>
<bean id="countingAdvice" class="org.springframework.aop.testfixture.advice.CountingAfterReturningAdvice"/>

<bean id="test" class="org.springframework.beans.testfixture.beans.TestBean">
<property name="age"><value>4</value></property>
Expand Down
1 change: 1 addition & 0 deletions spring-aop/spring-aop.gradle
Expand Up @@ -8,4 +8,5 @@ dependencies {
optional("com.jamonapi:jamon")
testCompile(testFixtures(project(":spring-beans")))
testCompile(testFixtures(project(":spring-core")))
testFixturesImplementation(testFixtures(project(":spring-core")))
}
Expand Up @@ -33,15 +33,15 @@
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.aop.testfixture.advice.CountingBeforeAdvice;
import org.springframework.aop.testfixture.interceptor.NopInterceptor;
import org.springframework.aop.testfixture.interceptor.TimestampIntroductionInterceptor;
import org.springframework.beans.testfixture.beans.IOther;
import org.springframework.beans.testfixture.beans.ITestBean;
import org.springframework.beans.testfixture.beans.TestBean;
import org.springframework.core.annotation.AnnotationAwareOrderComparator;
import org.springframework.core.annotation.Order;
import org.springframework.core.testfixture.TimeStamped;
import org.springframework.tests.aop.advice.CountingBeforeAdvice;
import org.springframework.tests.aop.interceptor.NopInterceptor;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
Expand Down Expand Up @@ -371,30 +371,6 @@ public void testInterceptorWithoutJoinpoint() {
}


@SuppressWarnings("serial")
private static 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;
}
}


@Order(2)
public static class A implements Runnable {

Expand Down
Expand Up @@ -17,16 +17,13 @@
package org.springframework.aop.framework.adapter;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.lang.reflect.Method;
import java.rmi.ConnectException;
import java.rmi.RemoteException;

import org.aopalliance.intercept.MethodInvocation;
import org.junit.jupiter.api.Test;

import org.springframework.aop.ThrowsAdvice;
import org.springframework.tests.aop.advice.MethodCounter;
import org.springframework.aop.testfixture.advice.MyThrowsHandler;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
Expand Down Expand Up @@ -128,23 +125,4 @@ public void afterThrowing(RemoteException ex) throws Throwable {
assertThat(th.getCalls("remoteException")).isEqualTo(1);
}


@SuppressWarnings("serial")
static 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");
}
}

}
Expand Up @@ -25,10 +25,10 @@
import org.springframework.aop.Pointcut;
import org.springframework.aop.interceptor.ExposeInvocationInterceptor;
import org.springframework.aop.target.EmptyTargetSource;
import org.springframework.aop.testfixture.interceptor.NopInterceptor;
import org.springframework.beans.testfixture.beans.TestBean;
import org.springframework.core.testfixture.io.SerializationTestUtils;
import org.springframework.lang.Nullable;
import org.springframework.tests.aop.interceptor.NopInterceptor;

import static org.assertj.core.api.Assertions.assertThat;

Expand Down
Expand Up @@ -20,9 +20,9 @@

import org.springframework.aop.Pointcut;
import org.springframework.aop.framework.ProxyFactory;
import org.springframework.aop.testfixture.interceptor.NopInterceptor;
import org.springframework.beans.testfixture.beans.ITestBean;
import org.springframework.beans.testfixture.beans.TestBean;
import org.springframework.tests.aop.interceptor.NopInterceptor;

import static org.assertj.core.api.Assertions.assertThat;

Expand Down
Expand Up @@ -24,6 +24,7 @@
import org.springframework.aop.IntroductionAdvisor;
import org.springframework.aop.IntroductionInterceptor;
import org.springframework.aop.framework.ProxyFactory;
import org.springframework.aop.testfixture.interceptor.SerializableNopInterceptor;
import org.springframework.beans.testfixture.beans.INestedTestBean;
import org.springframework.beans.testfixture.beans.ITestBean;
import org.springframework.beans.testfixture.beans.NestedTestBean;
Expand All @@ -32,7 +33,6 @@
import org.springframework.beans.testfixture.beans.TestBean;
import org.springframework.core.testfixture.TimeStamped;
import org.springframework.core.testfixture.io.SerializationTestUtils;
import org.springframework.tests.aop.interceptor.SerializableNopInterceptor;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
Expand Down
Expand Up @@ -21,11 +21,11 @@

import org.springframework.aop.framework.Advised;
import org.springframework.aop.framework.ProxyFactory;
import org.springframework.aop.testfixture.interceptor.NopInterceptor;
import org.springframework.aop.testfixture.interceptor.SerializableNopInterceptor;
import org.springframework.beans.testfixture.beans.Person;
import org.springframework.beans.testfixture.beans.SerializablePerson;
import org.springframework.core.testfixture.io.SerializationTestUtils;
import org.springframework.tests.aop.interceptor.NopInterceptor;
import org.springframework.tests.aop.interceptor.SerializableNopInterceptor;

import static org.assertj.core.api.Assertions.assertThat;

Expand Down
Expand Up @@ -19,15 +19,15 @@
import org.junit.jupiter.api.Test;

import org.springframework.aop.framework.Advised;
import org.springframework.aop.testfixture.interceptor.NopInterceptor;
import org.springframework.aop.testfixture.interceptor.SerializableNopInterceptor;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.beans.testfixture.beans.ITestBean;
import org.springframework.beans.testfixture.beans.Person;
import org.springframework.beans.testfixture.beans.TestBean;
import org.springframework.core.io.Resource;
import org.springframework.core.testfixture.io.SerializationTestUtils;
import org.springframework.tests.aop.interceptor.NopInterceptor;
import org.springframework.tests.aop.interceptor.SerializableNopInterceptor;

import static org.assertj.core.api.Assertions.assertThat;
import static org.springframework.core.testfixture.io.ResourceTestUtils.qualifiedResource;
Expand Down
Expand Up @@ -23,13 +23,13 @@
import org.springframework.aop.framework.Advised;
import org.springframework.aop.framework.ProxyFactory;
import org.springframework.aop.support.DefaultPointcutAdvisor;
import org.springframework.aop.testfixture.interceptor.SerializableNopInterceptor;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.beans.testfixture.beans.Person;
import org.springframework.beans.testfixture.beans.SerializablePerson;
import org.springframework.beans.testfixture.beans.SideEffectBean;
import org.springframework.core.testfixture.io.SerializationTestUtils;
import org.springframework.tests.aop.interceptor.SerializableNopInterceptor;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
Expand Down
Expand Up @@ -6,7 +6,7 @@
-->
<beans>

<bean id="nopInterceptor" class="org.springframework.tests.aop.interceptor.NopInterceptor"/>
<bean id="nopInterceptor" class="org.springframework.aop.testfixture.interceptor.NopInterceptor"/>

<bean id="exposeInvocation" class="org.springframework.beans.factory.config.FieldRetrievingFactoryBean">
<property name="targetClass">
Expand All @@ -15,7 +15,7 @@
<property name="targetField"><value>INSTANCE</value></property>
</bean>

<bean id="countingBeforeAdvice" class="org.springframework.tests.aop.advice.CountingBeforeAdvice"/>
<bean id="countingBeforeAdvice" class="org.springframework.aop.testfixture.advice.CountingBeforeAdvice"/>

<bean id="proxy" class="org.springframework.aop.framework.ProxyFactoryBean">
<property name="target">
Expand Down
Expand Up @@ -9,7 +9,7 @@
<property name="age"><value>666</value></property>
</bean>

<bean id="nopInterceptor" class="org.springframework.tests.aop.interceptor.SerializableNopInterceptor"/>
<bean id="nopInterceptor" class="org.springframework.aop.testfixture.interceptor.SerializableNopInterceptor"/>

<bean id="settersAdvisor" class="org.springframework.aop.support.RegexpMethodPointcutAdvisor">
<property name="advice"><ref bean="nopInterceptor"/></property>
Expand Down
Expand Up @@ -16,7 +16,7 @@
<property name="targetBeanName"><value>prototypeTest</value></property>
</bean>

<bean id="debugInterceptor" class="org.springframework.tests.aop.interceptor.NopInterceptor" />
<bean id="debugInterceptor" class="org.springframework.aop.testfixture.interceptor.NopInterceptor" />

<bean id="singleton" class="org.springframework.aop.framework.ProxyFactoryBean">
<property name="interceptorNames"><value>debugInterceptor,test</value></property>
Expand Down
Expand Up @@ -11,7 +11,7 @@
<property name="targetBeanName"><value>prototypeTest</value></property>
</bean>

<bean id="debugInterceptor" class="org.springframework.tests.aop.interceptor.NopInterceptor" />
<bean id="debugInterceptor" class="org.springframework.aop.testfixture.interceptor.NopInterceptor" />

<!--
We want to invoke the getStatsMixin method on our ThreadLocal invoker
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2019 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.
Expand All @@ -14,7 +14,7 @@
* limitations under the License.
*/

package org.springframework.tests.aop.advice;
package org.springframework.aop.testfixture.advice;

import java.lang.reflect.Method;

Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2019 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.
Expand All @@ -14,7 +14,7 @@
* limitations under the License.
*/

package org.springframework.tests.aop.advice;
package org.springframework.aop.testfixture.advice;

import java.lang.reflect.Method;

Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2019 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.
Expand All @@ -14,7 +14,7 @@
* limitations under the License.
*/

package org.springframework.tests.aop.advice;
package org.springframework.aop.testfixture.advice;

import java.io.Serializable;
import java.lang.reflect.Method;
Expand Down
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package org.springframework.tests.aop.advice;
package org.springframework.aop.testfixture.advice;

import java.io.IOException;
import java.lang.reflect.Method;
Expand All @@ -24,10 +24,12 @@

@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");
}
Expand All @@ -36,4 +38,5 @@ public void afterThrowing(RemoteException ex) throws Throwable {
public void afterThrowing(Method m, Exception ex) throws Throwable {
throw new UnsupportedOperationException("Shouldn't be called");
}

}
Expand Up @@ -14,11 +14,11 @@
* limitations under the License.
*/

package org.springframework.tests.aop.advice;
package org.springframework.aop.testfixture.advice;

import org.springframework.aop.support.DefaultIntroductionAdvisor;
import org.springframework.aop.support.DelegatingIntroductionInterceptor;
import org.springframework.tests.aop.interceptor.TimestampIntroductionInterceptor;
import org.springframework.aop.testfixture.interceptor.TimestampIntroductionInterceptor;

/**
* @author Rod Johnson
Expand Down
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package org.springframework.tests.aop.interceptor;
package org.springframework.aop.testfixture.interceptor;

import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
Expand Down
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package org.springframework.tests.aop.interceptor;
package org.springframework.aop.testfixture.interceptor;

import java.io.Serializable;

Expand Down
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package org.springframework.tests.aop.interceptor;
package org.springframework.aop.testfixture.interceptor;

import org.springframework.aop.support.DelegatingIntroductionInterceptor;
import org.springframework.core.testfixture.TimeStamped;
Expand Down
1 change: 1 addition & 0 deletions spring-context/spring-context.gradle
Expand Up @@ -26,6 +26,7 @@ dependencies {
optional("org.jetbrains.kotlin:kotlin-reflect")
optional("org.jetbrains.kotlin:kotlin-stdlib")
optional("org.reactivestreams:reactive-streams")
testCompile(testFixtures(project(":spring-aop")))
testCompile(testFixtures(project(":spring-beans")))
testCompile(testFixtures(project(":spring-core")))
testCompile("io.projectreactor:reactor-core")
Expand Down

0 comments on commit 8a371c7

Please sign in to comment.