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-04 10:02:29 +01:00
committed by Chris Beams
parent 2a30fa07ea
commit 42b5d6dd7e
813 changed files with 2241 additions and 27860 deletions
@@ -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.
@@ -37,8 +37,7 @@ public class ComponentBeanDefinitionParserTest {
@BeforeClass
public static void setUpBeforeClass() throws Exception {
bf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(
new ClassPathResource("com/foo/component-config.xml"));
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(new ClassPathResource("com/foo/component-config.xml"));
}
@AfterClass
@@ -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,10 +29,10 @@ import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceEditor;
import org.springframework.tests.sample.beans.DerivedTestBean;
import org.springframework.tests.sample.beans.ITestBean;
import org.springframework.tests.sample.beans.TestBean;
import test.beans.DerivedTestBean;
import test.beans.ITestBean;
import test.beans.TestBean;
/**
* Unit tests for {@link BeanUtils}.
@@ -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,8 +17,8 @@
package org.springframework.beans;
import org.junit.Test;
import test.beans.CustomEnum;
import test.beans.GenericBean;
import org.springframework.tests.sample.beans.CustomEnum;
import org.springframework.tests.sample.beans.GenericBean;
import static org.junit.Assert.*;
@@ -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.
@@ -30,15 +30,15 @@ import java.util.Set;
import static org.junit.Assert.*;
import org.junit.Test;
import test.beans.GenericBean;
import test.beans.GenericIntegerBean;
import test.beans.GenericSetOfIntegerBean;
import test.beans.TestBean;
import org.springframework.beans.propertyeditors.CustomNumberEditor;
import org.springframework.beans.propertyeditors.StringTrimmerEditor;
import org.springframework.core.io.Resource;
import org.springframework.core.io.UrlResource;
import org.springframework.tests.sample.beans.GenericBean;
import org.springframework.tests.sample.beans.GenericIntegerBean;
import org.springframework.tests.sample.beans.GenericSetOfIntegerBean;
import org.springframework.tests.sample.beans.TestBean;
/**
* @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.
@@ -51,6 +51,11 @@ import org.springframework.beans.propertyeditors.StringTrimmerEditor;
import org.springframework.beans.support.DerivedFromProtectedBaseBean;
import org.springframework.tests.Assume;
import org.springframework.tests.TestGroup;
import org.springframework.tests.sample.beans.BooleanTestBean;
import org.springframework.tests.sample.beans.ITestBean;
import org.springframework.tests.sample.beans.IndexedTestBean;
import org.springframework.tests.sample.beans.NumberTestBean;
import org.springframework.tests.sample.beans.TestBean;
import org.springframework.core.convert.ConversionFailedException;
import org.springframework.core.convert.TypeDescriptor;
import org.springframework.core.convert.support.DefaultConversionService;
@@ -58,11 +63,6 @@ import org.springframework.core.convert.support.GenericConversionService;
import org.springframework.util.StopWatch;
import org.springframework.util.StringUtils;
import test.beans.BooleanTestBean;
import test.beans.ITestBean;
import test.beans.IndexedTestBean;
import test.beans.NumberTestBean;
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.
@@ -22,9 +22,9 @@ import java.beans.PropertyDescriptor;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import test.beans.TestBean;
import org.springframework.core.OverridingClassLoader;
import org.springframework.tests.sample.beans.TestBean;
import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.*;
@@ -44,7 +44,7 @@ public final class CachedIntrospectionResultsTests {
assertTrue(CachedIntrospectionResults.classCache.containsKey(TestBean.class));
ClassLoader child = new OverridingClassLoader(getClass().getClassLoader());
Class<?> tbClass = child.loadClass("test.beans.TestBean");
Class<?> tbClass = child.loadClass("org.springframework.tests.sample.beans.TestBean");
assertFalse(CachedIntrospectionResults.classCache.containsKey(tbClass));
CachedIntrospectionResults.acceptClassLoader(child);
bw = new BeanWrapperImpl(tbClass);
@@ -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,9 +27,9 @@ import java.lang.reflect.Method;
import org.junit.Test;
import org.springframework.core.JdkVersion;
import org.springframework.tests.sample.beans.TestBean;
import org.springframework.util.ClassUtils;
import test.beans.TestBean;
import static org.hamcrest.Matchers.greaterThan;
import static org.hamcrest.Matchers.lessThan;
@@ -3,7 +3,7 @@
<beans>
<bean id="test3" class="test.beans.TestBean" scope="prototype">
<bean id="test3" class="org.springframework.tests.sample.beans.TestBean" scope="prototype">
<property name="name"><value>custom</value></property>
<property name="age"><value>25</value></property>
</bean>
@@ -4,17 +4,16 @@
<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>
<!--
Check that invoker is automatically added to wrap target.
Non pointcut bean name should be wrapped in invoker.
-->
<bean id="numberTestBean" class="test.beans.NumberTestBean"/>
<bean id="numberTestBean" class="org.springframework.tests.sample.beans.NumberTestBean"/>
</beans>
</beans>
@@ -6,19 +6,19 @@
<!--
Just included for the count: not to mean anything in particular
-->
<bean id="something" class="test.beans.GenericIntegerBean"/>
<bean id="something" class="org.springframework.tests.sample.beans.GenericIntegerBean"/>
<bean id="indexedBean" class="test.beans.IndexedTestBean"/>
<bean id="indexedBean" class="org.springframework.tests.sample.beans.IndexedTestBean"/>
<!-- Overridden by next factory -->
<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>25</value></property>
</bean>
<bean id="testFactory1" class="test.beans.DummyFactory"/>
<bean id="testFactory1" class="org.springframework.tests.sample.beans.factory.DummyFactory"/>
<bean id="testFactory2" class="test.beans.DummyFactory">
<bean id="testFactory2" class="org.springframework.tests.sample.beans.factory.DummyFactory">
<property name="singleton"><value>false</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.
@@ -18,7 +18,7 @@ package org.springframework.beans.factory;
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 java.util.Arrays;
import java.util.List;
@@ -33,12 +33,12 @@ import org.springframework.beans.factory.support.StaticListableBeanFactory;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.cglib.proxy.NoOp;
import org.springframework.core.io.Resource;
import org.springframework.tests.sample.beans.ITestBean;
import org.springframework.tests.sample.beans.IndexedTestBean;
import org.springframework.tests.sample.beans.TestBean;
import org.springframework.tests.sample.beans.factory.DummyFactory;
import org.springframework.util.ObjectUtils;
import test.beans.DummyFactory;
import test.beans.ITestBean;
import test.beans.IndexedTestBean;
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.
@@ -18,7 +18,6 @@ package org.springframework.beans.factory;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import static test.util.TestResourceUtils.qualifiedResource;
import java.text.DateFormat;
import java.text.ParseException;
@@ -39,6 +38,10 @@ import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.springframework.core.io.Resource;
import org.springframework.tests.Assume;
import org.springframework.tests.TestGroup;
import static org.springframework.tests.TestResourceUtils.qualifiedResource;
/**
* @author Guillaume Poirier
@@ -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,6 +16,17 @@
package org.springframework.beans.factory;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.io.Closeable;
import java.lang.reflect.Field;
import java.net.MalformedURLException;
@@ -32,19 +43,13 @@ import java.util.Locale;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
import javax.security.auth.Subject;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.junit.Ignore;
import org.junit.Test;
import test.beans.DerivedTestBean;
import test.beans.DummyFactory;
import test.beans.ITestBean;
import test.beans.LifecycleBean;
import test.beans.NestedTestBean;
import test.beans.TestBean;
import org.springframework.beans.BeansException;
import org.springframework.beans.MutablePropertyValues;
import org.springframework.beans.NotWritablePropertyException;
@@ -70,21 +75,25 @@ import org.springframework.beans.factory.support.ManagedList;
import org.springframework.beans.factory.support.PropertiesBeanDefinitionReader;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.beans.factory.xml.ConstructorDependenciesBean;
import org.springframework.beans.factory.xml.DependenciesBean;
import org.springframework.beans.propertyeditors.CustomNumberEditor;
import org.springframework.tests.Assume;
import org.springframework.tests.TestGroup;
import org.springframework.core.MethodParameter;
import org.springframework.core.convert.converter.Converter;
import org.springframework.core.convert.support.DefaultConversionService;
import org.springframework.core.convert.support.GenericConversionService;
import org.springframework.core.io.Resource;
import org.springframework.core.io.UrlResource;
import org.springframework.tests.Assume;
import org.springframework.tests.TestGroup;
import org.springframework.tests.sample.beans.DependenciesBean;
import org.springframework.tests.sample.beans.DerivedTestBean;
import org.springframework.tests.sample.beans.ITestBean;
import org.springframework.tests.sample.beans.LifecycleBean;
import org.springframework.tests.sample.beans.NestedTestBean;
import org.springframework.tests.sample.beans.SideEffectBean;
import org.springframework.tests.sample.beans.TestBean;
import org.springframework.tests.sample.beans.factory.DummyFactory;
import org.springframework.util.StopWatch;
import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.*;
/**
* Tests properties population and autowire behavior.
*
@@ -2600,29 +2609,6 @@ public class DefaultListableBeanFactoryTests {
}
}
/**
* Bean that changes state on a business invocation, so that
* we can check whether it's been invoked
* @author Rod Johnson
*/
private static class SideEffectBean {
private int count;
public void setCount(int count) {
this.count = count;
}
public int getCount() {
return this.count;
}
public void doWork() {
++count;
}
}
private static class KnowsIfInstantiated {
private static boolean instantiated;
@@ -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.beans.factory;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
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.config.BeanFactoryPostProcessor;
@@ -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.
@@ -23,9 +23,9 @@ import java.util.Arrays;
import org.junit.Test;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.support.DefaultSingletonBeanRegistry;
import org.springframework.tests.sample.beans.DerivedTestBean;
import org.springframework.tests.sample.beans.TestBean;
import test.beans.DerivedTestBean;
import test.beans.TestBean;
/**
* @author Juergen Hoeller
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- $Id: beans1.xml,v 1.3 2006/08/20 19:08:40 jhoeller Exp $ -->
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd">
<beans>
<bean id="beans1.bean1" class="org.springframework.beans.factory.access.TestBean">
<property name="name"><value>beans1.bean1</value></property>
</bean>
<bean id="beans1.bean2" class="org.springframework.beans.factory.access.TestBean">
<property name="name"><value>bean2</value></property>
<property name="objRef"><ref bean="beans1.bean2"/></property>
</bean>
</beans>
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- $Id: beans2.xml,v 1.3 2006/08/20 19:08:40 jhoeller Exp $ -->
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd">
<beans>
<bean id="beans2.bean1" class="org.springframework.beans.factory.access.TestBean">
<property name="name"><value>beans2.bean1</value></property>
</bean>
<bean id="beans2.bean2" class="org.springframework.beans.factory.access.TestBean">
<property name="name"><value>beans2.bean2</value></property>
<property name="objRef"><ref bean="beans1.bean1"/></property>
</bean>
</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.
@@ -43,12 +43,12 @@ import org.springframework.beans.factory.support.AutowireCandidateQualifier;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.support.GenericBeanDefinition;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.tests.sample.beans.ITestBean;
import org.springframework.tests.sample.beans.IndexedTestBean;
import org.springframework.tests.sample.beans.NestedTestBean;
import org.springframework.tests.sample.beans.TestBean;
import org.springframework.util.SerializationTestUtils;
import test.beans.ITestBean;
import test.beans.IndexedTestBean;
import test.beans.NestedTestBean;
import test.beans.TestBean;
/**
* Unit tests for {@link AutowiredAnnotationBeanPostProcessor}.
@@ -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.beans.factory.annotation;
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.beans.factory.config.BeanDefinitionHolder;
@@ -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,10 +24,6 @@ import javax.inject.Named;
import javax.inject.Provider;
import org.junit.Test;
import test.beans.ITestBean;
import test.beans.IndexedTestBean;
import test.beans.NestedTestBean;
import test.beans.TestBean;
import org.springframework.beans.factory.BeanCreationException;
import org.springframework.beans.factory.BeanFactory;
@@ -38,6 +34,10 @@ import org.springframework.beans.factory.support.AutowireCandidateQualifier;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.support.GenericBeanDefinition;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.tests.sample.beans.ITestBean;
import org.springframework.tests.sample.beans.IndexedTestBean;
import org.springframework.tests.sample.beans.NestedTestBean;
import org.springframework.tests.sample.beans.TestBean;
import org.springframework.util.SerializationTestUtils;
import static org.junit.Assert.*;
@@ -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,7 +27,6 @@ import java.util.Map;
import static org.junit.Assert.*;
import org.junit.Test;
import test.beans.TestBean;
import org.springframework.beans.FatalBeanException;
import org.springframework.beans.MutablePropertyValues;
@@ -36,6 +35,7 @@ import org.springframework.beans.PropertyEditorRegistry;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.springframework.tests.sample.beans.TestBean;
/**
* Unit tests for {@link CustomEditorConfigurer}.
@@ -3,7 +3,7 @@
<beans>
<bean id="testBean" class="test.beans.TestBean">
<bean id="testBean" class="org.springframework.tests.sample.beans.TestBean">
<property name="someIntegerArray">
<list>
<bean name="java.sql.Connection.TRANSACTION_SERIALIZABLE" class="org.springframework.beans.factory.config.FieldRetrievingFactoryBean"/>
@@ -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.beans.factory.config;
import static org.junit.Assert.assertEquals;
import static test.util.TestResourceUtils.qualifiedResource;
import static org.springframework.tests.TestResourceUtils.qualifiedResource;
import java.sql.Connection;
@@ -25,8 +25,8 @@ 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 org.springframework.tests.sample.beans.TestBean;
import test.beans.TestBean;
/**
* Unit tests for {@link FieldRetrievingFactoryBean}.
@@ -119,7 +119,7 @@ public final class FieldRetrievingFactoryBeanTests {
@Test
public void testWithConstantOnClassWithPackageLevelVisibility() throws Exception {
FieldRetrievingFactoryBean fr = new FieldRetrievingFactoryBean();
fr.setBeanName("test.beans.PackageLevelVisibleBean.CONSTANT");
fr.setBeanName("org.springframework.tests.sample.beans.PackageLevelVisibleBean.CONSTANT");
fr.afterPropertiesSet();
assertEquals("Wuby", fr.getObject());
}
@@ -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,7 +22,7 @@ import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.mock;
import static test.util.TestResourceUtils.qualifiedResource;
import static org.springframework.tests.TestResourceUtils.qualifiedResource;
import java.util.Date;
@@ -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.beans.factory.config;
import static org.junit.Assert.*;
import static test.util.TestResourceUtils.qualifiedResource;
import static org.springframework.tests.TestResourceUtils.qualifiedResource;
import java.util.Properties;
@@ -3,19 +3,19 @@
<beans>
<bean id="tb" class="test.beans.TestBean" scope="prototype">
<bean id="tb" class="org.springframework.tests.sample.beans.TestBean" scope="prototype">
<property name="age"><value>10</value></property>
<property name="spouse">
<bean class="test.beans.TestBean">
<bean class="org.springframework.tests.sample.beans.TestBean">
<property name="age"><value>11</value></property>
</bean>
</property>
</bean>
<bean id="otb" class="test.beans.TestBean">
<bean id="otb" class="org.springframework.tests.sample.beans.TestBean">
<property name="age"><value>98</value></property>
<property name="spouse">
<bean class="test.beans.TestBean">
<bean class="org.springframework.tests.sample.beans.TestBean">
<property name="age"><value>99</value></property>
</bean>
</property>
@@ -23,7 +23,7 @@
<bean id="propertyPath1" class="org.springframework.beans.factory.config.PropertyPathFactoryBean">
<property name="targetObject">
<bean class="test.beans.TestBean">
<bean class="org.springframework.tests.sample.beans.TestBean">
<property name="age"><value>12</value></property>
</bean>
</property>
@@ -46,10 +46,10 @@
<bean id="propertyPath3" class="org.springframework.beans.factory.config.PropertyPathFactoryBean">
<property name="targetBeanName"><value>tb</value></property>
<property name="propertyPath"><value>spouse</value></property>
<property name="resultType"><value>test.beans.TestBean</value></property>
<property name="resultType"><value>org.springframework.tests.sample.beans.TestBean</value></property>
</bean>
<bean id="tbWithInner" class="test.beans.TestBean">
<bean id="tbWithInner" class="org.springframework.tests.sample.beans.TestBean">
<property name="age" value="10"/>
<property name="spouse">
<bean name="otb.spouse" class="org.springframework.beans.factory.config.PropertyPathFactoryBean"/>
@@ -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,15 +20,15 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
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;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.core.io.Resource;
import org.springframework.tests.sample.beans.ITestBean;
import org.springframework.tests.sample.beans.TestBean;
import test.beans.ITestBean;
import test.beans.TestBean;
/**
* Unit tests for {@link PropertyPathFactoryBean}.
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2011 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.
@@ -36,8 +36,8 @@ import org.springframework.beans.factory.support.AbstractBeanDefinition;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.tests.sample.beans.TestBean;
import test.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.
@@ -22,7 +22,7 @@ import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.springframework.beans.factory.support.BeanDefinitionBuilder.genericBeanDefinition;
import static test.util.TestResourceUtils.qualifiedResource;
import static org.springframework.tests.TestResourceUtils.qualifiedResource;
import java.util.Collections;
import java.util.HashMap;
@@ -48,9 +48,9 @@ import org.springframework.beans.factory.support.ManagedMap;
import org.springframework.beans.factory.support.ManagedSet;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.core.io.Resource;
import org.springframework.tests.sample.beans.IndexedTestBean;
import org.springframework.tests.sample.beans.TestBean;
import test.beans.IndexedTestBean;
import test.beans.TestBean;
/**
* Unit tests for various {@link PropertyResourceConfigurer} implementations including:
@@ -5,6 +5,6 @@
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.0.xsd">
<bean id="usesScope" class="test.beans.TestBean" scope="myScope"/>
<bean id="usesScope" class="org.springframework.tests.sample.beans.TestBean" scope="myScope"/>
</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,7 +17,7 @@
package org.springframework.beans.factory.config;
import static org.junit.Assert.*;
import static test.util.TestResourceUtils.qualifiedResource;
import static org.springframework.tests.TestResourceUtils.qualifiedResource;
import java.util.LinkedList;
import java.util.List;
@@ -28,8 +28,8 @@ import org.springframework.beans.factory.ObjectFactory;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.core.io.Resource;
import org.springframework.tests.sample.beans.TestBean;
import test.beans.TestBean;
/**
* Simple test to illustrate and verify scope usage.
@@ -6,7 +6,7 @@
<bean id="invalidClass" class="some.class.that.does.not.Exist"/>
<bean id="invalidMapDefinition" class="test.beans.TestBean">
<bean id="invalidMapDefinition" class="org.springframework.tests.sample.beans.TestBean">
<property name="someMap">
<map>
<entry/>
@@ -14,9 +14,9 @@
</property>
</bean>
<bean id="nestedBeanErrors" class="test.beans.TestBean">
<bean id="nestedBeanErrors" class="org.springframework.tests.sample.beans.TestBean">
<property name="spouse">
<bean class="test.beans.TestBean">
<bean class="org.springframework.tests.sample.beans.TestBean">
<property name="someMap">
<map>
<entry/>
@@ -26,5 +26,5 @@
</property>
</bean>
<bean id="validBean" class="test.beans.TestBean"/>
<bean id="validBean" class="org.springframework.tests.sample.beans.TestBean"/>
</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,7 +17,7 @@
package org.springframework.beans.factory.parsing;
import static org.junit.Assert.*;
import static test.util.TestResourceUtils.qualifiedResource;
import static org.springframework.tests.TestResourceUtils.qualifiedResource;
import java.util.ArrayList;
import java.util.List;
@@ -27,8 +27,8 @@ 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 org.springframework.tests.sample.beans.TestBean;
import test.beans.TestBean;
/**
* @author Rob Harrop
@@ -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.
@@ -21,8 +21,8 @@ import java.util.Arrays;
import junit.framework.TestCase;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.tests.sample.beans.TestBean;
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.
@@ -20,8 +20,8 @@ import junit.framework.TestCase;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.BeanDefinitionHolder;
import org.springframework.tests.sample.beans.TestBean;
import test.beans.TestBean;
/**
* @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.
@@ -45,10 +45,13 @@ import org.springframework.beans.propertyeditors.CustomNumberEditor;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.UrlResource;
import test.beans.GenericBean;
import test.beans.GenericIntegerBean;
import test.beans.GenericSetOfIntegerBean;
import test.beans.TestBean;
import org.springframework.tests.Assume;
import org.springframework.tests.TestGroup;
import org.springframework.tests.sample.beans.GenericBean;
import org.springframework.tests.sample.beans.GenericIntegerBean;
import org.springframework.tests.sample.beans.GenericSetOfIntegerBean;
import org.springframework.tests.sample.beans.TestBean;
/**
* @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.
@@ -20,8 +20,8 @@ import junit.framework.TestCase;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.RuntimeBeanReference;
import org.springframework.tests.sample.beans.TestBean;
import test.beans.TestBean;
/**
* @author Rob Harrop
@@ -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,8 +18,8 @@ package org.springframework.beans.factory.support;
import junit.framework.TestCase;
import org.springframework.core.io.ClassPathResource;
import org.springframework.tests.sample.beans.TestBean;
import test.beans.TestBean;
/**
* @author Rob Harrop
@@ -3,7 +3,7 @@
<beans>
<bean id="listOfArrays" class="test.beans.GenericBean">
<bean id="listOfArrays" class="org.springframework.tests.sample.beans.GenericBean">
<property name="listOfArrays">
<list>
<list>
@@ -43,7 +43,7 @@
autowire="constructor">
</bean>
<bean id="integerBean" class="test.beans.GenericIntegerBean">
<bean id="integerBean" class="org.springframework.tests.sample.beans.GenericIntegerBean">
<property name="genericProperty" value="10"/>
<property name="genericListProperty">
<list>
@@ -53,7 +53,7 @@
</property>
</bean>
<bean id="setOfIntegerBean" class="test.beans.GenericSetOfIntegerBean">
<bean id="setOfIntegerBean" class="org.springframework.tests.sample.beans.GenericSetOfIntegerBean">
<property name="genericProperty" value="10"/>
<property name="genericListProperty">
<list>
@@ -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,8 +24,8 @@ import junit.framework.TestCase;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.tests.sample.beans.TestBean;
import test.beans.TestBean;
/**
* @author Rick Evans
@@ -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,13 +27,13 @@ import org.springframework.beans.factory.BeanCreationException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanIsNotAFactoryException;
import org.springframework.beans.factory.BeanNotOfRequiredTypeException;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.tests.sample.beans.LifecycleBean;
import org.springframework.tests.sample.beans.MustBeInitialized;
import org.springframework.tests.sample.beans.TestBean;
import org.springframework.tests.sample.beans.factory.DummyFactory;
import test.beans.DummyFactory;
import test.beans.LifecycleBean;
import test.beans.TestBean;
/**
* Subclasses must implement setUp() to initialize bean factory
@@ -336,32 +336,3 @@ public abstract class AbstractBeanFactoryTests extends TestCase {
}
}
/**
* Simple test of BeanFactory initialization
* @author Rod Johnson
* @since 12.03.2003
*/
class MustBeInitialized implements InitializingBean {
private boolean inited;
/**
* @see InitializingBean#afterPropertiesSet()
*/
@Override
public void afterPropertiesSet() throws Exception {
this.inited = true;
}
/**
* Dummy business method that will fail unless the factory
* managed the bean's lifecycle correctly
*/
public void businessMethod() {
if (!this.inited)
throw new RuntimeException("Factory didn't call afterPropertiesSet() on MustBeInitialized object");
}
}
@@ -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,8 +19,8 @@ package org.springframework.beans.factory.xml;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.beans.factory.ListableBeanFactory;
import org.springframework.tests.sample.beans.TestBean;
import test.beans.TestBean;
/**
* @author Rod Johnson
@@ -51,13 +51,13 @@ public abstract class AbstractListableBeanFactoryTests extends AbstractBeanFacto
public void assertTestBeanCount(int count) {
String[] defNames = getListableBeanFactory().getBeanNamesForType(TestBean.class, true, false);
assertTrue("We should have " + count + " beans for class org.springframework.beans.TestBean, not " +
assertTrue("We should have " + count + " beans for class org.springframework.tests.sample.beans.TestBean, not " +
defNames.length, defNames.length == count);
int countIncludingFactoryBeans = count + 2;
String[] names = getListableBeanFactory().getBeanNamesForType(TestBean.class, true, true);
assertTrue("We should have " + countIncludingFactoryBeans +
" beans for class org.springframework.beans.TestBean, not " + names.length,
" beans for class org.springframework.tests.sample.beans.TestBean, not " + names.length,
names.length == countIncludingFactoryBeans);
}
@@ -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.
@@ -23,8 +23,8 @@ import org.springframework.beans.factory.config.RuntimeBeanReference;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.core.io.ClassPathResource;
import org.springframework.tests.sample.beans.TestBean;
import test.beans.TestBean;
/**
* @author Rob Harrop
@@ -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 junit.framework.TestCase;
import org.springframework.beans.factory.support.BeanDefinitionReader;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.core.io.ClassPathResource;
import org.springframework.tests.sample.beans.TestBean;
import test.beans.TestBean;
/**
* Unit and integration tests for the collection merging support.
@@ -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,8 +25,8 @@ import java.util.Map;
import org.junit.Test;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.core.io.ClassPathResource;
import org.springframework.tests.sample.beans.TestBean;
import test.beans.TestBean;
/**
* @author Rob Harrop
@@ -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,8 +18,9 @@ package org.springframework.beans.factory.xml;
import java.io.Serializable;
import test.beans.IndexedTestBean;
import test.beans.TestBean;
import org.springframework.tests.sample.beans.IndexedTestBean;
import org.springframework.tests.sample.beans.TestBean;
/**
* Simple bean used to check constructor dependency checking.
@@ -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,8 +17,8 @@
package org.springframework.beans.factory.xml;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.tests.sample.beans.TestBean;
import test.beans.TestBean;
/**
* @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.
@@ -17,8 +17,8 @@
package org.springframework.beans.factory.xml;
import test.beans.DummyFactory;
import test.beans.TestBean;
import org.springframework.tests.sample.beans.TestBean;
import org.springframework.tests.sample.beans.factory.DummyFactory;
/**
* @author Juergen Hoeller
@@ -4,12 +4,12 @@
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd">
<bean id="testBean" class="test.beans.TestBean">
<bean id="testBean" class="org.springframework.tests.sample.beans.TestBean">
<property name="name" value="topLevel"/>
</bean>
<beans>
<bean id="testBean" class="test.beans.TestBean">
<bean id="testBean" class="org.springframework.tests.sample.beans.TestBean">
<property name="name" value="nested"/>
</bean>
</beans>
@@ -4,12 +4,12 @@
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd">
<bean id="testBean" class="test.beans.TestBean">
<bean id="testBean" class="org.springframework.tests.sample.beans.TestBean">
<property name="name" value="original"/>
</bean>
<!-- STS should raise an error for this duplicate id -->
<bean id="testBean" class="test.beans.TestBean">
<bean id="testBean" class="org.springframework.tests.sample.beans.TestBean">
<property name="name" value="duplicate"/>
</bean>
</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.
@@ -23,8 +23,8 @@ import static org.junit.Assert.fail;
import org.junit.Test;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.core.io.ClassPathResource;
import org.springframework.tests.sample.beans.TestBean;
import test.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.
@@ -30,6 +30,7 @@ import org.springframework.beans.factory.parsing.ImportDefinition;
import org.springframework.beans.factory.parsing.PassThroughSourceExtractor;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.core.io.ClassPathResource;
import org.springframework.tests.beans.CollectingReaderEventListener;
/**
* @author Rob Harrop
@@ -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.
@@ -23,12 +23,12 @@ import java.util.Properties;
import static org.junit.Assert.*;
import org.junit.Test;
import test.beans.TestBean;
import org.springframework.beans.factory.BeanCreationException;
import org.springframework.beans.factory.BeanDefinitionStoreException;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.core.io.ClassPathResource;
import org.springframework.tests.sample.beans.TestBean;
/**
* @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.
@@ -19,7 +19,8 @@ package org.springframework.beans.factory.xml;
import java.util.Collections;
import java.util.List;
import test.beans.TestBean;
import org.springframework.tests.sample.beans.TestBean;
/**
* Test class for Spring's ability to create objects using static
@@ -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,7 @@
package org.springframework.beans.factory.xml;
import test.beans.TestBean;
import org.springframework.tests.sample.beans.TestBean;
/**
* Test class for Spring's ability to create objects using
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2010 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,8 +25,8 @@ import org.junit.Test;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.core.io.ClassPathResource;
import org.springframework.tests.sample.beans.TestBean;
import test.beans.TestBean;
/**
* Tests for propagating enclosing beans element defaults to nested beans elements.
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2007 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.xml.sax.SAXParseException;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.core.io.ClassPathResource;
import org.springframework.tests.sample.beans.TestBean;
import test.beans.TestBean;
/**
* @author Rob Harrop
@@ -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,9 +22,9 @@ import org.junit.Test;
import org.springframework.beans.factory.BeanDefinitionStoreException;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.core.io.ClassPathResource;
import org.springframework.tests.sample.beans.DummyBean;
import org.springframework.tests.sample.beans.TestBean;
import test.beans.DummyBean;
import test.beans.TestBean;
/**
* @author Costin Leau
@@ -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,9 +22,9 @@ import org.junit.Test;
import org.springframework.beans.factory.BeanDefinitionStoreException;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.core.io.ClassPathResource;
import org.springframework.tests.sample.beans.ITestBean;
import org.springframework.tests.sample.beans.TestBean;
import test.beans.ITestBean;
import test.beans.TestBean;
/**
* @author Rob Harrop
@@ -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,7 @@
package org.springframework.beans.factory.xml;
import test.beans.TestBean;
import org.springframework.tests.sample.beans.TestBean;
/**
* Test class for Spring's ability to create
@@ -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,8 +25,6 @@ import java.util.TreeMap;
import java.util.Arrays;
import junit.framework.TestCase;
import test.beans.CustomEnum;
import test.beans.TestBean;
import org.springframework.beans.factory.config.FieldRetrievingFactoryBean;
import org.springframework.beans.factory.config.PropertiesFactoryBean;
@@ -34,6 +32,9 @@ import org.springframework.beans.factory.parsing.ComponentDefinition;
import org.springframework.beans.factory.support.AbstractBeanDefinition;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.core.io.ClassPathResource;
import org.springframework.tests.beans.CollectingReaderEventListener;
import org.springframework.tests.sample.beans.CustomEnum;
import org.springframework.tests.sample.beans.TestBean;
/**
* @author Rob Harrop
@@ -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.
@@ -23,7 +23,6 @@ import static org.junit.Assert.fail;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.IdentityHashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
@@ -34,7 +33,6 @@ import java.util.Properties;
import java.util.Set;
import java.util.TreeMap;
import java.util.TreeSet;
import java.util.concurrent.CopyOnWriteArraySet;
import org.junit.Test;
import org.springframework.beans.factory.BeanCreationException;
@@ -44,8 +42,9 @@ import org.springframework.beans.factory.config.MapFactoryBean;
import org.springframework.beans.factory.config.SetFactoryBean;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.core.io.ClassPathResource;
import org.springframework.tests.sample.beans.HasMap;
import org.springframework.tests.sample.beans.TestBean;
import test.beans.TestBean;
/**
* Tests for collections in XML bean definitions.
@@ -452,94 +451,3 @@ public class XmlBeanCollectionTests {
}
}
}
/**
* Bean exposing a map. Used for bean factory tests.
*
* @author Rod Johnson
* @since 05.06.2003
*/
class HasMap {
private Map map;
private IdentityHashMap identityMap;
private Set set;
private CopyOnWriteArraySet concurrentSet;
private Properties props;
private Object[] objectArray;
private Class[] classArray;
private Integer[] intArray;
public Map getMap() {
return map;
}
public void setMap(Map map) {
this.map = map;
}
public IdentityHashMap getIdentityMap() {
return identityMap;
}
public void setIdentityMap(IdentityHashMap identityMap) {
this.identityMap = identityMap;
}
public Set getSet() {
return set;
}
public void setSet(Set set) {
this.set = set;
}
public CopyOnWriteArraySet getConcurrentSet() {
return concurrentSet;
}
public void setConcurrentSet(CopyOnWriteArraySet concurrentSet) {
this.concurrentSet = concurrentSet;
}
public Properties getProps() {
return props;
}
public void setProps(Properties props) {
this.props = props;
}
public Object[] getObjectArray() {
return objectArray;
}
public void setObjectArray(Object[] objectArray) {
this.objectArray = objectArray;
}
public Class[] getClassArray() {
return classArray;
}
public void setClassArray(Class[] classArray) {
this.classArray = classArray;
}
public Integer[] getIntegerArray() {
return intArray;
}
public void setIntegerArray(Integer[] is) {
intArray = is;
}
}
@@ -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.springframework.beans.factory.support.SimpleBeanDefinitionRegistry;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.InputStreamResource;
import org.springframework.core.io.Resource;
import org.springframework.tests.sample.beans.TestBean;
import test.beans.TestBean;
/**
* @author Rick Evans
@@ -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,11 +28,11 @@ import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.core.io.ClassPathResource;
import org.springframework.tests.sample.beans.ITestBean;
import org.springframework.tests.sample.beans.LifecycleBean;
import org.springframework.tests.sample.beans.TestBean;
import org.springframework.tests.sample.beans.factory.DummyFactory;
import test.beans.DummyFactory;
import test.beans.ITestBean;
import test.beans.LifecycleBean;
import test.beans.TestBean;
/**
* @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.
@@ -44,12 +44,12 @@ import org.springframework.beans.BeanWrapperImpl;
import org.springframework.beans.BeansException;
import org.springframework.beans.MutablePropertyValues;
import org.springframework.beans.PropertyValue;
import org.springframework.tests.sample.beans.BooleanTestBean;
import org.springframework.tests.sample.beans.ITestBean;
import org.springframework.tests.sample.beans.IndexedTestBean;
import org.springframework.tests.sample.beans.NumberTestBean;
import org.springframework.tests.sample.beans.TestBean;
import test.beans.BooleanTestBean;
import test.beans.ITestBean;
import test.beans.IndexedTestBean;
import test.beans.NumberTestBean;
import test.beans.TestBean;
/**
* Unit tests for the various PropertyEditors in Spring.
@@ -592,9 +592,9 @@ public class CustomEditorTests {
@Test
public void testClassEditorWithArray() {
PropertyEditor classEditor = new ClassEditor();
classEditor.setAsText("test.beans.TestBean[]");
classEditor.setAsText("org.springframework.tests.sample.beans.TestBean[]");
assertEquals(TestBean[].class, classEditor.getValue());
assertEquals("test.beans.TestBean[]", classEditor.getAsText());
assertEquals("org.springframework.tests.sample.beans.TestBean[]", classEditor.getAsText());
}
/*
@@ -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.beans.support;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.util.ArrayList;
import java.util.List;
import junit.framework.TestCase;
import test.beans.TestBean;
import org.springframework.tests.Assume;
import org.springframework.tests.TestGroup;
import org.springframework.tests.sample.beans.TestBean;
/**
* @author Juergen Hoeller
@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.beans.factory.xml;
package org.springframework.tests.beans;
import java.util.ArrayList;
import java.util.Collection;
@@ -14,7 +14,7 @@
* limitations under the License.
*/
package test.beans;
package org.springframework.tests.sample.beans;
/**
* @author Juergen Hoeller
@@ -14,7 +14,7 @@
* limitations under the License.
*/
package test.beans;
package org.springframework.tests.sample.beans;
import org.springframework.core.enums.ShortCodedLabeledEnum;
@@ -0,0 +1,32 @@
/*
* Copyright 2002-2005 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 Juergen Hoeller
* @since 15.03.2005
*/
public class CountingTestBean extends TestBean {
public static int count = 0;
public CountingTestBean() {
count++;
}
}
@@ -14,7 +14,7 @@
* limitations under the License.
*/
package test.beans;
package org.springframework.tests.sample.beans;
/**
* @author Juergen Hoeller
@@ -14,13 +14,11 @@
* limitations under the License.
*/
package org.springframework.beans.factory.xml;
package org.springframework.tests.sample.beans;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
import test.beans.TestBean;
/**
* Simple bean used to test dependency checking.
*
@@ -14,7 +14,7 @@
* limitations under the License.
*/
package test.beans;
package org.springframework.tests.sample.beans;
import java.io.Serializable;
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.beans;
package org.springframework.tests.sample.beans;
/**
* @author Costin Leau
@@ -14,7 +14,7 @@
* limitations under the License.
*/
package test.beans;
package org.springframework.tests.sample.beans;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
@@ -24,6 +24,7 @@ import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
import org.springframework.tests.sample.beans.TestBean;
/**
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2010 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.
@@ -14,7 +14,7 @@
* limitations under the License.
*/
package test.beans;
package org.springframework.tests.sample.beans;
import java.util.ArrayList;
import java.util.Collection;
@@ -37,6 +37,8 @@ public class GenericBean<T> {
private Set<? extends Number> numberSet;
private Set<ITestBean> testBeanSet;
private List<Resource> resourceList;
private List<TestBean> testBeanList;
@@ -69,6 +71,7 @@ public class GenericBean<T> {
private List<T> genericListProperty;
public GenericBean() {
}
@@ -121,6 +124,14 @@ public class GenericBean<T> {
this.numberSet = numberSet;
}
public Set<ITestBean> getTestBeanSet() {
return testBeanSet;
}
public void setTestBeanSet(Set<ITestBean> testBeanSet) {
this.testBeanSet = testBeanSet;
}
public List<Resource> getResourceList() {
return resourceList;
}
@@ -284,4 +295,4 @@ public class GenericBean<T> {
return new GenericBean(someFlag, collectionMap);
}
}
}
@@ -14,7 +14,7 @@
* limitations under the License.
*/
package test.beans;
package org.springframework.tests.sample.beans;
/**
@@ -14,7 +14,7 @@
* limitations under the License.
*/
package test.beans;
package org.springframework.tests.sample.beans;
import java.util.Set;
@@ -0,0 +1,116 @@
/*
* 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.util.IdentityHashMap;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
import java.util.concurrent.CopyOnWriteArraySet;
/**
* Bean exposing a map. Used for bean factory tests.
*
* @author Rod Johnson
* @since 05.06.2003
*/
public class HasMap {
private Map<?, ?> map;
private Set<?> set;
private Properties props;
private Object[] objectArray;
private Class<?>[] classArray;
private Integer[] intArray;
private IdentityHashMap identityMap;
private CopyOnWriteArraySet concurrentSet;
private HasMap() {
}
public Map<?, ?> getMap() {
return map;
}
public void setMap(Map<?, ?> map) {
this.map = map;
}
public Set<?> getSet() {
return set;
}
public void setSet(Set<?> set) {
this.set = set;
}
public Properties getProps() {
return props;
}
public void setProps(Properties props) {
this.props = props;
}
public Object[] getObjectArray() {
return objectArray;
}
public void setObjectArray(Object[] objectArray) {
this.objectArray = objectArray;
}
public Class<?>[] getClassArray() {
return classArray;
}
public void setClassArray(Class<?>[] classArray) {
this.classArray = classArray;
}
public Integer[] getIntegerArray() {
return intArray;
}
public void setIntegerArray(Integer[] is) {
intArray = is;
}
public IdentityHashMap getIdentityMap() {
return identityMap;
}
public void setIdentityMap(IdentityHashMap identityMap) {
this.identityMap = identityMap;
}
public CopyOnWriteArraySet getConcurrentSet() {
return concurrentSet;
}
public void setConcurrentSet(CopyOnWriteArraySet concurrentSet) {
this.concurrentSet = concurrentSet;
}
}
@@ -14,7 +14,7 @@
* limitations under the License.
*/
package test.beans;
package org.springframework.tests.sample.beans;
public interface INestedTestBean {
@@ -15,7 +15,7 @@
* limitations under the License.
*/
package test.beans;
package org.springframework.tests.sample.beans;
public interface IOther {
@@ -14,12 +14,12 @@
* limitations under the License.
*/
package test.beans;
package org.springframework.tests.sample.beans;
import java.io.IOException;
/**
* Interface used for {@link test.beans.TestBean}.
* Interface used for {@link org.springframework.tests.sample.beans.TestBean}.
*
* <p>Two methods are the same as on Person, but if this
* extends person it breaks quite a few tests..
@@ -47,6 +47,22 @@ public interface ITestBean {
void setStringArray(String[] stringArray);
Integer[][] getNestedIntegerArray();
Integer[] getSomeIntegerArray();
void setSomeIntegerArray(Integer[] someIntegerArray);
void setNestedIntegerArray(Integer[][] nestedIntegerArray);
int[] getSomeIntArray();
void setSomeIntArray(int[] someIntArray);
int[][] getNestedIntArray();
void setNestedIntArray(int[][] someNestedArray);
/**
* Throws a given (non-null) exception.
*/
@@ -68,4 +84,4 @@ public interface ITestBean {
void unreliableFileOperation() throws IOException;
}
}
@@ -14,7 +14,7 @@
* limitations under the License.
*/
package test.beans;
package org.springframework.tests.sample.beans;
import java.util.ArrayList;
import java.util.Collection;
@@ -14,7 +14,7 @@
* limitations under the License.
*/
package test.beans;
package org.springframework.tests.sample.beans;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
@@ -0,0 +1,47 @@
/*
* 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 org.springframework.beans.factory.InitializingBean;
/**
* Simple test of BeanFactory initialization
* @author Rod Johnson
* @since 12.03.2003
*/
public class MustBeInitialized implements InitializingBean {
private boolean inited;
/**
* @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet()
*/
@Override
public void afterPropertiesSet() throws Exception {
this.inited = true;
}
/**
* Dummy business method that will fail unless the factory
* managed the bean's lifecycle correctly
*/
public void businessMethod() {
if (!this.inited)
throw new RuntimeException("Factory didn't call afterPropertiesSet() on MustBeInitialized object");
}
}
@@ -14,7 +14,7 @@
* limitations under the License.
*/
package test.beans;
package org.springframework.tests.sample.beans;
/**
* Simple nested test bean used for testing bean factories, AOP framework etc.
@@ -14,7 +14,7 @@
* limitations under the License.
*/
package test.beans;
package org.springframework.tests.sample.beans;
import java.math.BigDecimal;
import java.math.BigInteger;
@@ -14,7 +14,7 @@
* limitations under the License.
*/
package test.beans;
package org.springframework.tests.sample.beans;
/**
* @see org.springframework.beans.factory.config.FieldRetrievingFactoryBeanTests
@@ -0,0 +1,54 @@
/*
* Copyright 2002-2006 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 Rob Harrop
* @since 2.0
*/
public class Pet {
private String name;
public Pet(String name) {
this.name = name;
}
public String getName() {
return name;
}
public String toString() {
return getName();
}
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
final Pet pet = (Pet) o;
if (name != null ? !name.equals(pet.name) : pet.name != null) return false;
return true;
}
public int hashCode() {
return (name != null ? name.hashCode() : 0);
}
}
@@ -0,0 +1,40 @@
/*
* 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;
/**
* Bean that changes state on a business invocation, so that
* we can check whether it's been invoked
* @author Rod Johnson
*/
public class SideEffectBean {
private int count;
public void setCount(int count) {
this.count = count;
}
public int getCount() {
return this.count;
}
public void doWork() {
++count;
}
}
@@ -14,7 +14,7 @@
* limitations under the License.
*/
package test.beans;
package org.springframework.tests.sample.beans;
import java.io.IOException;
import java.util.ArrayList;
@@ -40,7 +40,7 @@ import org.springframework.util.ObjectUtils;
* @author Juergen Hoeller
* @since 15 April 2001
*/
public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOther, Comparable {
public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOther, Comparable<Object> {
private String beanName;
@@ -58,7 +58,7 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt
private boolean jedi;
private ITestBean[] spouses;
protected ITestBean[] spouses;
private String touchy;
@@ -66,17 +66,23 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt
private Integer[] someIntegerArray;
private Integer[][] nestedIntegerArray;
private int[] someIntArray;
private int[][] nestedIntArray;
private Date date = new Date();
private Float myFloat = new Float(0.0);
private Collection friends = new LinkedList();
private Collection<? super Object> friends = new LinkedList<>();
private Set someSet = new HashSet();
private Set<?> someSet = new HashSet<>();
private Map someMap = new HashMap();
private Map<?, ?> someMap = new HashMap<>();
private List someList = new ArrayList();
private List<?> someList = new ArrayList<>();
private Properties someProperties = new Properties();
@@ -94,9 +100,9 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt
private Boolean someBoolean;
private List otherColours;
private List<?> otherColours;
private List pets;
private List<?> pets;
public TestBean() {
@@ -120,15 +126,15 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt
this.someProperties = someProperties;
}
public TestBean(List someList) {
public TestBean(List<?> someList) {
this.someList = someList;
}
public TestBean(Set someSet) {
public TestBean(Set<?> someSet) {
this.someSet = someSet;
}
public TestBean(Map someMap) {
public TestBean(Map<?, ?> someMap) {
this.someMap = someMap;
}
@@ -203,13 +209,13 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt
}
@Override
public void setSpouse(ITestBean spouse) {
this.spouses = new ITestBean[] {spouse};
public ITestBean getSpouse() {
return (spouses != null ? spouses[0] : null);
}
@Override
public ITestBean getSpouse() {
return (spouses != null ? spouses[0] : null);
public void setSpouse(ITestBean spouse) {
this.spouses = new ITestBean[] {spouse};
}
@Override
@@ -257,6 +263,36 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt
this.someIntegerArray = someIntegerArray;
}
@Override
public Integer[][] getNestedIntegerArray() {
return nestedIntegerArray;
}
@Override
public void setNestedIntegerArray(Integer[][] nestedIntegerArray) {
this.nestedIntegerArray = nestedIntegerArray;
}
@Override
public int[] getSomeIntArray() {
return someIntArray;
}
@Override
public void setSomeIntArray(int[] someIntArray) {
this.someIntArray = someIntArray;
}
@Override
public int[][] getNestedIntArray() {
return nestedIntArray;
}
@Override
public void setNestedIntArray(int[][] nestedIntArray) {
this.nestedIntArray = nestedIntArray;
}
public Date getDate() {
return date;
}
@@ -273,35 +309,35 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt
this.myFloat = myFloat;
}
public Collection getFriends() {
public Collection<? super Object> getFriends() {
return friends;
}
public void setFriends(Collection friends) {
public void setFriends(Collection<? super Object> friends) {
this.friends = friends;
}
public Set getSomeSet() {
public Set<?> getSomeSet() {
return someSet;
}
public void setSomeSet(Set someSet) {
public void setSomeSet(Set<?> someSet) {
this.someSet = someSet;
}
public Map getSomeMap() {
public Map<?, ?> getSomeMap() {
return someMap;
}
public void setSomeMap(Map someMap) {
public void setSomeMap(Map<?, ?> someMap) {
this.someMap = someMap;
}
public List getSomeList() {
public List<?> getSomeList() {
return someList;
}
public void setSomeList(List someList) {
public void setSomeList(List<?> someList) {
this.someList = someList;
}
@@ -364,25 +400,25 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt
this.nestedIndexedBean = nestedIndexedBean;
}
public List getOtherColours() {
public List<?> getOtherColours() {
return otherColours;
}
public void setOtherColours(List otherColours) {
public void setOtherColours(List<?> otherColours) {
this.otherColours = otherColours;
}
public List getPets() {
public List<?> getPets() {
return pets;
}
public void setPets(List pets) {
public void setPets(List<?> pets) {
this.pets = pets;
}
/**
* @see ITestBean#exceptional(Throwable)
* @see org.springframework.tests.sample.beans.ITestBean#exceptional(Throwable)
*/
@Override
public void exceptional(Throwable t) throws Throwable {
@@ -396,7 +432,7 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt
throw new IOException();
}
/**
* @see ITestBean#returnsThis()
* @see org.springframework.tests.sample.beans.ITestBean#returnsThis()
*/
@Override
public Object returnsThis() {
@@ -404,7 +440,7 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt
}
/**
* @see IOther#absquatulate()
* @see org.springframework.tests.sample.beans.IOther#absquatulate()
*/
@Override
public void absquatulate() {
@@ -454,4 +490,4 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt
return this.name;
}
}
}
@@ -0,0 +1,187 @@
/*
* 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.factory;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
import org.springframework.tests.sample.beans.TestBean;
/**
* Simple factory to allow testing of FactoryBean support in AbstractBeanFactory.
* Depending on whether its singleton property is set, it will return a singleton
* or a prototype instance.
*
* <p>Implements InitializingBean interface, so we can check that
* factories get this lifecycle callback if they want.
*
* @author Rod Johnson
* @author Chris Beams
* @since 10.03.2003
*/
public class DummyFactory
implements FactoryBean<Object>, BeanNameAware, BeanFactoryAware, InitializingBean, DisposableBean {
public static final String SINGLETON_NAME = "Factory singleton";
private static boolean prototypeCreated;
/**
* Clear static state.
*/
public static void reset() {
prototypeCreated = false;
}
/**
* Default is for factories to return a singleton instance.
*/
private boolean singleton = true;
private String beanName;
private AutowireCapableBeanFactory beanFactory;
private boolean postProcessed;
private boolean initialized;
private TestBean testBean;
private TestBean otherTestBean;
public DummyFactory() {
this.testBean = new TestBean();
this.testBean.setName(SINGLETON_NAME);
this.testBean.setAge(25);
}
/**
* Return if the bean managed by this factory is a singleton.
* @see FactoryBean#isSingleton()
*/
@Override
public boolean isSingleton() {
return this.singleton;
}
/**
* Set if the bean managed by this factory is a singleton.
*/
public void setSingleton(boolean singleton) {
this.singleton = singleton;
}
@Override
public void setBeanName(String beanName) {
this.beanName = beanName;
}
public String getBeanName() {
return beanName;
}
@Override
public void setBeanFactory(BeanFactory beanFactory) {
this.beanFactory = (AutowireCapableBeanFactory) beanFactory;
this.beanFactory.applyBeanPostProcessorsBeforeInitialization(this.testBean, this.beanName);
}
public BeanFactory getBeanFactory() {
return beanFactory;
}
public void setPostProcessed(boolean postProcessed) {
this.postProcessed = postProcessed;
}
public boolean isPostProcessed() {
return postProcessed;
}
public void setOtherTestBean(TestBean otherTestBean) {
this.otherTestBean = otherTestBean;
this.testBean.setSpouse(otherTestBean);
}
public TestBean getOtherTestBean() {
return otherTestBean;
}
@Override
public void afterPropertiesSet() {
if (initialized) {
throw new RuntimeException("Cannot call afterPropertiesSet twice on the one bean");
}
this.initialized = true;
}
/**
* Was this initialized by invocation of the
* afterPropertiesSet() method from the InitializingBean interface?
*/
public boolean wasInitialized() {
return initialized;
}
public static boolean wasPrototypeCreated() {
return prototypeCreated;
}
/**
* Return the managed object, supporting both singleton
* and prototype mode.
* @see FactoryBean#getObject()
*/
@Override
public Object getObject() throws BeansException {
if (isSingleton()) {
return this.testBean;
}
else {
TestBean prototype = new TestBean("prototype created at " + System.currentTimeMillis(), 11);
if (this.beanFactory != null) {
this.beanFactory.applyBeanPostProcessorsBeforeInitialization(prototype, this.beanName);
}
prototypeCreated = true;
return prototype;
}
}
@Override
public Class<?> getObjectType() {
return TestBean.class;
}
@Override
public void destroy() {
if (this.testBean != null) {
this.testBean.setName(null);
}
}
}
@@ -0,0 +1,4 @@
/**
* General purpose sample beans that can be used with tests.
*/
package org.springframework.tests.sample.beans;
@@ -1,65 +0,0 @@
/*
* Copyright 2002-2009 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.util;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.NotSerializableException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.OutputStream;
/**
* Utilities for testing serializability of objects.
* Exposes static methods for use in other test cases.
*
* @author Rod Johnson
*/
public class SerializationTestUtils {
public static void testSerialization(Object o) throws IOException {
OutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(o);
}
public static boolean isSerializable(Object o) throws IOException {
try {
testSerialization(o);
return true;
}
catch (NotSerializableException ex) {
return false;
}
}
public static Object serializeAndDeserialize(Object o) throws IOException, ClassNotFoundException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(o);
oos.flush();
baos.flush();
byte[] bytes = baos.toByteArray();
ByteArrayInputStream is = new ByteArrayInputStream(bytes);
ObjectInputStream ois = new ObjectInputStream(is);
Object o2 = ois.readObject();
return o2;
}
}
@@ -1,46 +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 test.util;
import static java.lang.String.format;
import org.springframework.core.io.ClassPathResource;
/**
* Convenience utilities for common operations with test resources.
*
* @author Chris Beams
*/
public class TestResourceUtils {
/**
* Loads a {@link ClassPathResource} qualified by the simple name of clazz,
* and relative to the package for clazz.
*
* <p>Example: given a clazz 'com.foo.BarTests' and a resourceSuffix of 'context.xml',
* this method will return a ClassPathResource representing com/foo/BarTests-context.xml
*
* <p>Intended for use loading context configuration XML files within JUnit tests.
*
* @param clazz
* @param resourceSuffix
*/
public static ClassPathResource qualifiedResource(Class<?> clazz, String resourceSuffix) {
return new ClassPathResource(format("%s-%s", clazz.getSimpleName(), resourceSuffix), clazz);
}
}