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:
Phillip Webb
2013-01-03 00:43:48 -08:00
committed by Chris Beams
parent 2a30fa07ea
commit 42b5d6dd7e
813 changed files with 2241 additions and 27860 deletions

View File

@@ -11,19 +11,19 @@
<bean id="advice" class="org.springframework.aop.interceptor.DebugInterceptor"/>
<bean id="testBean" class="test.beans.TestBean"/>
<bean id="testBean" class="org.springframework.tests.sample.beans.TestBean"/>
<bean id="singletonScoped" class="test.beans.TestBean">
<bean id="singletonScoped" class="org.springframework.tests.sample.beans.TestBean">
<aop:scoped-proxy/>
<property name="name" value="Rob Harrop"/>
</bean>
<bean id="requestScoped" class="test.beans.TestBean" scope="request">
<bean id="requestScoped" class="org.springframework.tests.sample.beans.TestBean" scope="request">
<aop:scoped-proxy/>
<property name="name" value="Rob Harrop"/>
</bean>
<bean id="sessionScoped" name="sessionScopedAlias" class="test.beans.TestBean" scope="session">
<bean id="sessionScoped" name="sessionScopedAlias" class="org.springframework.tests.sample.beans.TestBean" scope="session">
<aop:scoped-proxy proxy-target-class="false"/>
<property name="name" value="Rob Harrop"/>
</bean>

View File

@@ -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,22 @@
package org.springframework.aop.config;
import static java.lang.String.format;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.*;
import org.junit.Before;
import org.junit.Test;
import test.beans.ITestBean;
import test.beans.TestBean;
import test.util.SerializationTestUtils;
import org.springframework.aop.framework.Advised;
import org.springframework.aop.support.AopUtils;
import org.springframework.context.ApplicationContext;
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.mock.web.MockHttpSession;
import org.springframework.tests.sample.beans.ITestBean;
import org.springframework.tests.sample.beans.TestBean;
import org.springframework.util.ClassUtils;
import org.springframework.util.SerializationTestUtils;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.context.support.XmlWebApplicationContext;

View File

@@ -22,20 +22,20 @@
<property name="order"><value>9</value></property>
<property name="requireTransactionContext"><value>false</value></property>
</bean>
<bean id="orderedAfterTransaction" class="org.springframework.aop.framework.autoproxy.OrderedTxCheckAdvisor">
<property name="order"><value>11</value></property>
<property name="requireTransactionContext"><value>true</value></property>
</bean>
<bean id="orderedAfterTransaction2" class="org.springframework.aop.framework.autoproxy.OrderedTxCheckAdvisor">
<!-- Don't set order value: should remain Integer.MAX_VALUE, so it's non-ordered -->
<property name="requireTransactionContext"><value>true</value></property>
</bean>
<!-- Often we can leave the definition of such infrastructural beans to child factories -->
<bean id="txManager" class="org.springframework.aop.framework.autoproxy.CallCountingTransactionManager"/>
<bean id="txManager" class="org.springframework.tests.transaction.CallCountingTransactionManager"/>
<bean id="tas" class="org.springframework.transaction.interceptor.NameMatchTransactionAttributeSource">
<property name="properties">
<props>
@@ -71,37 +71,37 @@
</list>
</property>
</bean>
<!-- These two beans would otherwise be eligible for autoproxying -->
<bean id="singletonDependency" class="test.beans.TestBean" scope="singleton"/>
<bean id="prototypeDependency" class="test.beans.TestBean" scope="prototype"/>
<bean id="singletonDependency" class="org.springframework.tests.sample.beans.TestBean" scope="singleton"/>
<bean id="prototypeDependency" class="org.springframework.tests.sample.beans.TestBean" scope="prototype"/>
<!-- ====== End test for prototype definitions to try to provoke circular references ========================= -->
<bean class="org.springframework.aop.support.RegexpMethodPointcutAdvisor">
<property name="advice"><ref bean="countingAdvice"/></property>
<property name="pattern"><value>test.beans.ITestBean.getName</value></property>
<property name="pattern"><value>org.springframework.tests.sample.beans.ITestBean.getName</value></property>
</bean>
<bean id="countingAdvice" class="test.advice.CountingAfterReturningAdvice"/>
<bean id="countingAdvice" class="org.springframework.tests.aop.advice.CountingAfterReturningAdvice"/>
<bean id="test" class="test.beans.TestBean">
<bean id="test" class="org.springframework.tests.sample.beans.TestBean">
<property name="age"><value>4</value></property>
</bean>
<bean id="noSetters" class="org.springframework.aop.framework.autoproxy.NoSetters"/>
<bean id="rollback" class="org.springframework.aop.framework.autoproxy.Rollback"/>
<!-- The following beans test whether auto-proxying falls over for a null value -->
<bean id="tb" class="test.beans.TestBean"/>
<bean id="tb" class="org.springframework.tests.sample.beans.TestBean"/>
<bean id="nullValueReturned" class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
<property name="targetObject" ref="tb"/>
<property name="targetMethod" value="getSpouse"/>
</bean>
</beans>
</beans>

View File

@@ -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.framework.autoproxy;
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 java.lang.reflect.Method;
@@ -30,16 +32,13 @@ import org.springframework.aop.support.StaticMethodMatcherPointcutAdvisor;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.tests.aop.advice.CountingBeforeAdvice;
import org.springframework.tests.aop.advice.MethodCounter;
import org.springframework.tests.aop.interceptor.NopInterceptor;
import org.springframework.tests.sample.beans.ITestBean;
import org.springframework.tests.transaction.CallCountingTransactionManager;
import org.springframework.transaction.NoTransactionException;
import org.springframework.transaction.TransactionDefinition;
import org.springframework.transaction.interceptor.TransactionInterceptor;
import org.springframework.transaction.support.AbstractPlatformTransactionManager;
import org.springframework.transaction.support.DefaultTransactionStatus;
import test.advice.CountingBeforeAdvice;
import test.advice.MethodCounter;
import test.beans.ITestBean;
import test.interceptor.NopInterceptor;
/**
* Integration tests for auto proxy creation by advisor recognition working in
@@ -316,43 +315,3 @@ class Rollback {
}
}
@SuppressWarnings("serial")
class CallCountingTransactionManager extends AbstractPlatformTransactionManager {
public TransactionDefinition lastDefinition;
public int begun;
public int commits;
public int rollbacks;
public int inflight;
@Override
protected Object doGetTransaction() {
return new Object();
}
@Override
protected void doBegin(Object transaction, TransactionDefinition definition) {
this.lastDefinition = definition;
++begun;
++inflight;
}
@Override
protected void doCommit(DefaultTransactionStatus status) {
++commits;
--inflight;
}
@Override
protected void doRollback(DefaultTransactionStatus status) {
++rollbacks;
--inflight;
}
public void clear() {
begun = commits = rollbacks = inflight = 0;
}
}

View File

@@ -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,11 +16,18 @@
package org.springframework.scheduling.annotation;
import static org.easymock.EasyMock.createMock;
import static org.easymock.EasyMock.replay;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.Matchers.greaterThan;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.util.concurrent.atomic.AtomicInteger;
import org.junit.Before;
import org.junit.Test;
import org.springframework.aop.support.AopUtils;
import org.springframework.beans.factory.BeanCreationException;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
@@ -31,16 +38,11 @@ import org.springframework.dao.support.PersistenceExceptionTranslator;
import org.springframework.stereotype.Repository;
import org.springframework.tests.Assume;
import org.springframework.tests.TestGroup;
import org.springframework.transaction.CallCountingTransactionManager;
import org.springframework.tests.transaction.CallCountingTransactionManager;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.transaction.annotation.Transactional;
import static org.easymock.EasyMock.*;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*;
/**
* Integration tests cornering bug SPR-8651, which revealed that @Scheduled methods may
* not work well with beans that have already been proxied for other reasons such

View File

@@ -1,65 +0,0 @@
/*
* 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.transaction;
import org.springframework.transaction.support.AbstractPlatformTransactionManager;
import org.springframework.transaction.support.DefaultTransactionStatus;
/**
* @author Rod Johnson
* @author Juergen Hoeller
*/
@SuppressWarnings("serial")
public class CallCountingTransactionManager extends AbstractPlatformTransactionManager {
public TransactionDefinition lastDefinition;
public int begun;
public int commits;
public int rollbacks;
public int inflight;
@Override
protected Object doGetTransaction() {
return new Object();
}
@Override
protected void doBegin(Object transaction, TransactionDefinition definition) {
this.lastDefinition = definition;
++begun;
++inflight;
}
@Override
protected void doCommit(DefaultTransactionStatus status) {
++commits;
--inflight;
}
@Override
protected void doRollback(DefaultTransactionStatus status) {
++rollbacks;
--inflight;
}
public void clear() {
begun = commits = rollbacks = inflight = 0;
}
}

View File

@@ -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.
@@ -46,7 +46,7 @@ import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder;
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.CallCountingTransactionManager;
import org.springframework.tests.transaction.CallCountingTransactionManager;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.interceptor.BeanFactoryTransactionAttributeSourceAdvisor;