Skip to content

Commit

Permalink
Remove duplicate test classes
Browse files Browse the repository at this point in the history
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
  • Loading branch information
philwebb authored and cbeams committed Jan 4, 2013
1 parent 2a30fa0 commit 42b5d6d
Show file tree
Hide file tree
Showing 813 changed files with 2,233 additions and 27,852 deletions.
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -33,10 +33,10 @@
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
Expand Down Expand Up @@ -66,7 +66,7 @@ public void setUp() throws NoSuchMethodException {

@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();
Expand Down Expand Up @@ -128,8 +128,8 @@ public void absquatulate() {
* @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);

Expand All @@ -156,7 +156,7 @@ public void testWithinRootAndSubpackages() throws SecurityException, NoSuchMetho
}

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 += ".";
Expand Down Expand Up @@ -214,7 +214,7 @@ public void testFriendlyErrorOnNoLocation3ArgMatching() {

@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();
Expand All @@ -235,7 +235,7 @@ public void testMatchWithArgs() throws Exception {

@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();

Expand All @@ -254,7 +254,7 @@ public void testSimpleAdvice() {

@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();

Expand All @@ -273,7 +273,7 @@ public void testDynamicMatchingProxy() {

@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
Expand Down Expand Up @@ -315,7 +315,7 @@ private void assertDoesNotMatchStringClass(ClassFilter classFilter) {

@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...
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -20,7 +20,7 @@

import org.junit.Test;

import test.beans.TestBean;
import org.springframework.tests.sample.beans.TestBean;

/**
* Tests for matching of bean() pointcut designator.
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -28,8 +28,8 @@
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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -29,7 +29,7 @@

import test.annotation.EmptySpringAnnotation;
import test.annotation.transaction.Tx;
import test.beans.TestBean;
import org.springframework.tests.sample.beans.TestBean;


/**
Expand Down Expand Up @@ -70,7 +70,7 @@ public void setPhoneNumbers(List<String> numbers) {

@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);

Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -22,11 +22,11 @@
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.
Expand All @@ -45,7 +45,7 @@ public void testInvalidPattern() {

@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));
Expand All @@ -56,7 +56,7 @@ public void testValidPatternMatching() {

@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));
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -58,8 +58,8 @@
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.
Expand Down Expand Up @@ -650,7 +650,7 @@ public void countSetter() {
}


@Aspect("pertypewithin(test.beans.IOther+)")
@Aspect("pertypewithin(org.springframework.tests.sample.beans.IOther+)")
public static class PerTypeWithinAspect {

public int count;
Expand Down Expand Up @@ -979,7 +979,7 @@ private Method getGetterFromSetter(Method setter) {
@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;

Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -29,8 +29,8 @@
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
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -25,7 +25,7 @@
import org.springframework.aop.framework.AopConfigException;

import test.aop.PerTargetAspect;
import test.beans.TestBean;
import org.springframework.tests.sample.beans.TestBean;


/**
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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;
Expand All @@ -30,8 +30,7 @@
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"/>

Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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;
Expand All @@ -32,8 +34,7 @@
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"/>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"/>

Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -18,7 +18,7 @@

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;
Expand Down
Loading

0 comments on commit 42b5d6d

Please sign in to comment.