moving unit tests from .testsuite -> .beans

fixed broken unit tests getting ClassNotFoundExceptions
This commit is contained in:
Chris Beams 2008-12-15 17:13:48 +00:00
parent 2ec861351c
commit ef414420c8
12 changed files with 281 additions and 36 deletions

View File

@ -16,6 +16,8 @@
package org.springframework.beans.factory.annotation; package org.springframework.beans.factory.annotation;
import static org.junit.Assert.*;
import java.lang.annotation.ElementType; import java.lang.annotation.ElementType;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy; import java.lang.annotation.RetentionPolicy;
@ -23,8 +25,7 @@ import java.lang.annotation.Target;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import junit.framework.TestCase; import org.junit.Test;
import org.springframework.beans.ITestBean; import org.springframework.beans.ITestBean;
import org.springframework.beans.IndexedTestBean; import org.springframework.beans.IndexedTestBean;
import org.springframework.beans.NestedTestBean; import org.springframework.beans.NestedTestBean;
@ -41,9 +42,11 @@ import org.springframework.beans.factory.support.RootBeanDefinition;
* @author Juergen Hoeller * @author Juergen Hoeller
* @author Mark Fisher * @author Mark Fisher
* @author Sam Brannen * @author Sam Brannen
* @author Chris Beams
*/ */
public class AutowiredAnnotationBeanPostProcessorTests extends TestCase { public class AutowiredAnnotationBeanPostProcessorTests {
@Test
public void testIncompleteBeanDefinition() { public void testIncompleteBeanDefinition() {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor(); AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor();
@ -58,6 +61,7 @@ public class AutowiredAnnotationBeanPostProcessorTests extends TestCase {
} }
} }
@Test
public void testResourceInjection() { public void testResourceInjection() {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor(); AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor();
@ -78,6 +82,7 @@ public class AutowiredAnnotationBeanPostProcessorTests extends TestCase {
assertSame(tb, bean.getTestBean2()); assertSame(tb, bean.getTestBean2());
} }
@Test
public void testExtendedResourceInjection() { public void testExtendedResourceInjection() {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
bf.registerResolvableDependency(BeanFactory.class, bf); bf.registerResolvableDependency(BeanFactory.class, bf);
@ -109,6 +114,7 @@ public class AutowiredAnnotationBeanPostProcessorTests extends TestCase {
assertSame(bf, bean.getBeanFactory()); assertSame(bf, bean.getBeanFactory());
} }
@Test
public void testExtendedResourceInjectionWithOverriding() { public void testExtendedResourceInjectionWithOverriding() {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
bf.registerResolvableDependency(BeanFactory.class, bf); bf.registerResolvableDependency(BeanFactory.class, bf);
@ -134,6 +140,7 @@ public class AutowiredAnnotationBeanPostProcessorTests extends TestCase {
bf.destroySingletons(); bf.destroySingletons();
} }
@Test
public void testExtendedResourceInjectionWithAtRequired() { public void testExtendedResourceInjectionWithAtRequired() {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
bf.registerResolvableDependency(BeanFactory.class, bf); bf.registerResolvableDependency(BeanFactory.class, bf);
@ -158,6 +165,7 @@ public class AutowiredAnnotationBeanPostProcessorTests extends TestCase {
assertSame(bf, bean.getBeanFactory()); assertSame(bf, bean.getBeanFactory());
} }
@Test
public void testOptionalResourceInjection() { public void testOptionalResourceInjection() {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor(); AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor();
@ -188,6 +196,7 @@ public class AutowiredAnnotationBeanPostProcessorTests extends TestCase {
bf.destroySingletons(); bf.destroySingletons();
} }
@Test
public void testOptionalCollectionResourceInjection() { public void testOptionalCollectionResourceInjection() {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor(); AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor();
@ -225,6 +234,7 @@ public class AutowiredAnnotationBeanPostProcessorTests extends TestCase {
bf.destroySingletons(); bf.destroySingletons();
} }
@Test
public void testOptionalCollectionResourceInjectionWithSingleElement() { public void testOptionalCollectionResourceInjectionWithSingleElement() {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor(); AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor();
@ -257,6 +267,7 @@ public class AutowiredAnnotationBeanPostProcessorTests extends TestCase {
bf.destroySingletons(); bf.destroySingletons();
} }
@Test
public void testOptionalResourceInjectionWithIncompleteDependencies() { public void testOptionalResourceInjectionWithIncompleteDependencies() {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor(); AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor();
@ -275,6 +286,7 @@ public class AutowiredAnnotationBeanPostProcessorTests extends TestCase {
bf.destroySingletons(); bf.destroySingletons();
} }
@Test
public void testOptionalResourceInjectionWithNoDependencies() { public void testOptionalResourceInjectionWithNoDependencies() {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor(); AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor();
@ -291,6 +303,7 @@ public class AutowiredAnnotationBeanPostProcessorTests extends TestCase {
bf.destroySingletons(); bf.destroySingletons();
} }
@Test
public void testConstructorResourceInjection() { public void testConstructorResourceInjection() {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
bf.registerResolvableDependency(BeanFactory.class, bf); bf.registerResolvableDependency(BeanFactory.class, bf);
@ -322,6 +335,7 @@ public class AutowiredAnnotationBeanPostProcessorTests extends TestCase {
assertSame(bf, bean.getBeanFactory()); assertSame(bf, bean.getBeanFactory());
} }
@Test
public void testConstructorResourceInjectionWithMultipleCandidates() { public void testConstructorResourceInjectionWithMultipleCandidates() {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor(); AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor();
@ -344,6 +358,7 @@ public class AutowiredAnnotationBeanPostProcessorTests extends TestCase {
bf.destroySingletons(); bf.destroySingletons();
} }
@Test
public void testConstructorResourceInjectionWithMultipleCandidatesAsCollection() { public void testConstructorResourceInjectionWithMultipleCandidatesAsCollection() {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor(); AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor();
@ -367,6 +382,7 @@ public class AutowiredAnnotationBeanPostProcessorTests extends TestCase {
bf.destroySingletons(); bf.destroySingletons();
} }
@Test
public void testConstructorResourceInjectionWithMultipleCandidatesAndFallback() { public void testConstructorResourceInjectionWithMultipleCandidatesAndFallback() {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor(); AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor();
@ -382,6 +398,7 @@ public class AutowiredAnnotationBeanPostProcessorTests extends TestCase {
bf.destroySingletons(); bf.destroySingletons();
} }
@Test
public void testConstructorResourceInjectionWithMultipleCandidatesAndDefaultFallback() { public void testConstructorResourceInjectionWithMultipleCandidatesAndDefaultFallback() {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor(); AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor();
@ -395,6 +412,7 @@ public class AutowiredAnnotationBeanPostProcessorTests extends TestCase {
bf.destroySingletons(); bf.destroySingletons();
} }
@Test
public void testConstructorInjectionWithMap() { public void testConstructorInjectionWithMap() {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor(); AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor();
@ -423,6 +441,7 @@ public class AutowiredAnnotationBeanPostProcessorTests extends TestCase {
assertTrue(bean.getTestBeanMap().values().contains(tb2)); assertTrue(bean.getTestBeanMap().values().contains(tb2));
} }
@Test
public void testFieldInjectionWithMap() { public void testFieldInjectionWithMap() {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor(); AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor();
@ -451,6 +470,7 @@ public class AutowiredAnnotationBeanPostProcessorTests extends TestCase {
assertTrue(bean.getTestBeanMap().values().contains(tb2)); assertTrue(bean.getTestBeanMap().values().contains(tb2));
} }
@Test
public void testMethodInjectionWithMap() { public void testMethodInjectionWithMap() {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor(); AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor();
@ -475,6 +495,7 @@ public class AutowiredAnnotationBeanPostProcessorTests extends TestCase {
assertSame(tb, bean.getTestBean()); assertSame(tb, bean.getTestBean());
} }
@Test
public void testMethodInjectionWithMapAndMultipleMatches() { public void testMethodInjectionWithMapAndMultipleMatches() {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor(); AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor();
@ -485,7 +506,7 @@ public class AutowiredAnnotationBeanPostProcessorTests extends TestCase {
bf.registerBeanDefinition("testBean2", new RootBeanDefinition(TestBean.class)); bf.registerBeanDefinition("testBean2", new RootBeanDefinition(TestBean.class));
try { try {
MapMethodInjectionBean bean = (MapMethodInjectionBean) bf.getBean("annotatedBean"); bf.getBean("annotatedBean");
fail("should have failed, more than one bean of type"); fail("should have failed, more than one bean of type");
} }
catch (BeanCreationException e) { catch (BeanCreationException e) {
@ -494,6 +515,7 @@ public class AutowiredAnnotationBeanPostProcessorTests extends TestCase {
bf.destroySingletons(); bf.destroySingletons();
} }
@Test
public void testMethodInjectionWithMapAndMultipleMatchesButOnlyOneAutowireCandidate() { public void testMethodInjectionWithMapAndMultipleMatchesButOnlyOneAutowireCandidate() {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor(); AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor();
@ -514,6 +536,7 @@ public class AutowiredAnnotationBeanPostProcessorTests extends TestCase {
bf.destroySingletons(); bf.destroySingletons();
} }
@Test
public void testMethodInjectionWithMapAndNoMatches() { public void testMethodInjectionWithMapAndNoMatches() {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor(); AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor();
@ -527,6 +550,7 @@ public class AutowiredAnnotationBeanPostProcessorTests extends TestCase {
bf.destroySingletons(); bf.destroySingletons();
} }
@Test
public void testCustomAnnotationRequiredFieldResourceInjection() { public void testCustomAnnotationRequiredFieldResourceInjection() {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor(); AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor();
@ -545,6 +569,7 @@ public class AutowiredAnnotationBeanPostProcessorTests extends TestCase {
bf.destroySingletons(); bf.destroySingletons();
} }
@Test
public void testCustomAnnotationRequiredFieldResourceInjectionFailsWhenNoDependencyFound() { public void testCustomAnnotationRequiredFieldResourceInjectionFailsWhenNoDependencyFound() {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor(); AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor();
@ -566,6 +591,7 @@ public class AutowiredAnnotationBeanPostProcessorTests extends TestCase {
bf.destroySingletons(); bf.destroySingletons();
} }
@Test
public void testCustomAnnotationRequiredFieldResourceInjectionFailsWhenMultipleDependenciesFound() { public void testCustomAnnotationRequiredFieldResourceInjectionFailsWhenMultipleDependenciesFound() {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor(); AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor();
@ -591,6 +617,7 @@ public class AutowiredAnnotationBeanPostProcessorTests extends TestCase {
bf.destroySingletons(); bf.destroySingletons();
} }
@Test
public void testCustomAnnotationRequiredMethodResourceInjection() { public void testCustomAnnotationRequiredMethodResourceInjection() {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor(); AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor();
@ -609,6 +636,7 @@ public class AutowiredAnnotationBeanPostProcessorTests extends TestCase {
bf.destroySingletons(); bf.destroySingletons();
} }
@Test
public void testCustomAnnotationRequiredMethodResourceInjectionFailsWhenNoDependencyFound() { public void testCustomAnnotationRequiredMethodResourceInjectionFailsWhenNoDependencyFound() {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor(); AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor();
@ -630,6 +658,7 @@ public class AutowiredAnnotationBeanPostProcessorTests extends TestCase {
bf.destroySingletons(); bf.destroySingletons();
} }
@Test
public void testCustomAnnotationRequiredMethodResourceInjectionFailsWhenMultipleDependenciesFound() { public void testCustomAnnotationRequiredMethodResourceInjectionFailsWhenMultipleDependenciesFound() {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor(); AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor();
@ -655,6 +684,7 @@ public class AutowiredAnnotationBeanPostProcessorTests extends TestCase {
bf.destroySingletons(); bf.destroySingletons();
} }
@Test
public void testCustomAnnotationOptionalFieldResourceInjection() { public void testCustomAnnotationOptionalFieldResourceInjection() {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor(); AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor();
@ -675,6 +705,7 @@ public class AutowiredAnnotationBeanPostProcessorTests extends TestCase {
bf.destroySingletons(); bf.destroySingletons();
} }
@Test
public void testCustomAnnotationOptionalFieldResourceInjectionWhenNoDependencyFound() { public void testCustomAnnotationOptionalFieldResourceInjectionWhenNoDependencyFound() {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor(); AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor();
@ -693,6 +724,7 @@ public class AutowiredAnnotationBeanPostProcessorTests extends TestCase {
bf.destroySingletons(); bf.destroySingletons();
} }
@Test
public void testCustomAnnotationOptionalFieldResourceInjectionWhenMultipleDependenciesFound() { public void testCustomAnnotationOptionalFieldResourceInjectionWhenMultipleDependenciesFound() {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor(); AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor();
@ -718,6 +750,7 @@ public class AutowiredAnnotationBeanPostProcessorTests extends TestCase {
bf.destroySingletons(); bf.destroySingletons();
} }
@Test
public void testCustomAnnotationOptionalMethodResourceInjection() { public void testCustomAnnotationOptionalMethodResourceInjection() {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor(); AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor();
@ -738,6 +771,7 @@ public class AutowiredAnnotationBeanPostProcessorTests extends TestCase {
bf.destroySingletons(); bf.destroySingletons();
} }
@Test
public void testCustomAnnotationOptionalMethodResourceInjectionWhenNoDependencyFound() { public void testCustomAnnotationOptionalMethodResourceInjectionWhenNoDependencyFound() {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor(); AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor();
@ -756,6 +790,7 @@ public class AutowiredAnnotationBeanPostProcessorTests extends TestCase {
bf.destroySingletons(); bf.destroySingletons();
} }
@Test
public void testCustomAnnotationOptionalMethodResourceInjectionWhenMultipleDependenciesFound() { public void testCustomAnnotationOptionalMethodResourceInjectionWhenMultipleDependenciesFound() {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor(); AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor();
@ -788,6 +823,7 @@ public class AutowiredAnnotationBeanPostProcessorTests extends TestCase {
* href="http://opensource.atlassian.com/projects/spring/browse/SPR-4040" * href="http://opensource.atlassian.com/projects/spring/browse/SPR-4040"
* target="_blank">SPR-4040</a>. * target="_blank">SPR-4040</a>.
*/ */
@Test
public void testBeanAutowiredWithFactoryBean() { public void testBeanAutowiredWithFactoryBean() {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor(); AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor();
@ -1246,21 +1282,21 @@ public class AutowiredAnnotationBeanPostProcessorTests extends TestCase {
private static class FactoryBeanDependentBean { private static class FactoryBeanDependentBean {
@Autowired @Autowired
private FactoryBean factoryBean; private FactoryBean<?> factoryBean;
public final FactoryBean getFactoryBean() { public final FactoryBean<?> getFactoryBean() {
return this.factoryBean; return this.factoryBean;
} }
} }
public static class StringFactoryBean implements FactoryBean { public static class StringFactoryBean implements FactoryBean<String> {
public Object getObject() throws Exception { public String getObject() throws Exception {
return ""; return "";
} }
public Class getObjectType() { public Class<String> getObjectType() {
return String.class; return String.class;
} }

View File

@ -16,8 +16,9 @@
package org.springframework.beans.factory.annotation; package org.springframework.beans.factory.annotation;
import junit.framework.TestCase; import static org.junit.Assert.assertEquals;
import org.junit.Test;
import org.springframework.beans.factory.config.BeanDefinitionHolder; import org.springframework.beans.factory.config.BeanDefinitionHolder;
import org.springframework.beans.factory.config.DependencyDescriptor; import org.springframework.beans.factory.config.DependencyDescriptor;
import org.springframework.beans.factory.support.AutowireCandidateResolver; import org.springframework.beans.factory.support.AutowireCandidateResolver;
@ -28,13 +29,15 @@ import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
/** /**
* @author Mark Fisher * @author Mark Fisher
* @author Juergen Hoeller * @author Juergen Hoeller
* @author Chris Beams
*/ */
public class CustomAutowireConfigurerTests extends TestCase { public class CustomAutowireConfigurerTests {
private static final String CONFIG_LOCATION = private static final String CONFIG_LOCATION =
"classpath:org/springframework/beans/factory/annotation/customAutowireConfigurer.xml"; "classpath:org/springframework/beans/factory/annotation/customAutowireConfigurer.xml";
@Test
public void testCustomResolver() { public void testCustomResolver() {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
BeanDefinitionReader reader = new XmlBeanDefinitionReader(bf); BeanDefinitionReader reader = new XmlBeanDefinitionReader(bf);

View File

@ -0,0 +1,94 @@
/*
* 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.beans.factory;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
/**
* 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 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;
}
}

View File

@ -24,6 +24,7 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
/** /**
* @author Rob Harrop * @author Rob Harrop
* @author Chris Beams
* @since 2.0 * @since 2.0
*/ */
public class RequiredAnnotationBeanPostProcessorTests extends TestCase { public class RequiredAnnotationBeanPostProcessorTests extends TestCase {

View File

@ -16,10 +16,7 @@
package org.springframework.beans.factory.config; package org.springframework.beans.factory.config;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.*;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.util.List; import java.util.List;
@ -37,7 +34,6 @@ import org.springframework.beans.TestBean;
import org.springframework.beans.factory.BeanDefinitionStoreException; import org.springframework.beans.factory.BeanDefinitionStoreException;
import org.springframework.beans.factory.BeanInitializationException; import org.springframework.beans.factory.BeanInitializationException;
import org.springframework.beans.factory.support.ChildBeanDefinition; import org.springframework.beans.factory.support.ChildBeanDefinition;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.support.ManagedList; import org.springframework.beans.factory.support.ManagedList;
import org.springframework.beans.factory.support.ManagedMap; import org.springframework.beans.factory.support.ManagedMap;
import org.springframework.beans.factory.support.ManagedSet; import org.springframework.beans.factory.support.ManagedSet;

View File

@ -16,9 +16,10 @@
package org.springframework.beans.factory.config; package org.springframework.beans.factory.config;
import junit.framework.TestCase; import static org.easymock.EasyMock.*;
import org.easymock.MockControl; import static org.junit.Assert.*;
import org.junit.Test;
import org.springframework.beans.FatalBeanException; import org.springframework.beans.FatalBeanException;
import org.springframework.beans.MutablePropertyValues; import org.springframework.beans.MutablePropertyValues;
import org.springframework.beans.PropertyValue; import org.springframework.beans.PropertyValue;
@ -32,9 +33,11 @@ import org.springframework.test.AssertThrows;
/** /**
* @author Colin Sampaleanu * @author Colin Sampaleanu
* @author Rick Evans * @author Rick Evans
* @author Chris Beams
*/ */
public class ServiceLocatorFactoryBeanTests extends TestCase { public class ServiceLocatorFactoryBeanTests {
@Test
public void testNoArgGetter() { public void testNoArgGetter() {
StaticApplicationContext ctx = new StaticApplicationContext(); StaticApplicationContext ctx = new StaticApplicationContext();
ctx.registerSingleton("testService", TestService.class, new MutablePropertyValues()); ctx.registerSingleton("testService", TestService.class, new MutablePropertyValues());
@ -48,6 +51,7 @@ public class ServiceLocatorFactoryBeanTests extends TestCase {
assertNotNull(testService); assertNotNull(testService);
} }
@Test
public void testErrorOnTooManyOrTooFew() throws Exception { public void testErrorOnTooManyOrTooFew() throws Exception {
StaticApplicationContext ctx = new StaticApplicationContext(); StaticApplicationContext ctx = new StaticApplicationContext();
ctx.registerSingleton("testService", TestService.class, new MutablePropertyValues()); ctx.registerSingleton("testService", TestService.class, new MutablePropertyValues());
@ -84,6 +88,7 @@ public class ServiceLocatorFactoryBeanTests extends TestCase {
}.runTest(); }.runTest();
} }
@Test
public void testErrorOnTooManyOrTooFewWithCustomServiceLocatorException() { public void testErrorOnTooManyOrTooFewWithCustomServiceLocatorException() {
StaticApplicationContext ctx = new StaticApplicationContext(); StaticApplicationContext ctx = new StaticApplicationContext();
ctx.registerSingleton("testService", TestService.class, new MutablePropertyValues()); ctx.registerSingleton("testService", TestService.class, new MutablePropertyValues());
@ -126,6 +131,7 @@ public class ServiceLocatorFactoryBeanTests extends TestCase {
}.runTest(); }.runTest();
} }
@Test
public void testStringArgGetter() throws Exception { public void testStringArgGetter() throws Exception {
StaticApplicationContext ctx = new StaticApplicationContext(); StaticApplicationContext ctx = new StaticApplicationContext();
ctx.registerSingleton("testService", TestService.class, new MutablePropertyValues()); ctx.registerSingleton("testService", TestService.class, new MutablePropertyValues());
@ -136,6 +142,7 @@ public class ServiceLocatorFactoryBeanTests extends TestCase {
// test string-arg getter with null id // test string-arg getter with null id
final TestServiceLocator2 factory = (TestServiceLocator2) ctx.getBean("factory"); final TestServiceLocator2 factory = (TestServiceLocator2) ctx.getBean("factory");
@SuppressWarnings("unused")
TestService testBean = factory.getTestService(null); TestService testBean = factory.getTestService(null);
// now test with explicit id // now test with explicit id
testBean = factory.getTestService("testService"); testBean = factory.getTestService("testService");
@ -147,6 +154,7 @@ public class ServiceLocatorFactoryBeanTests extends TestCase {
}.runTest(); }.runTest();
} }
@Test
public void testCombinedLocatorInterface() { public void testCombinedLocatorInterface() {
StaticApplicationContext ctx = new StaticApplicationContext(); StaticApplicationContext ctx = new StaticApplicationContext();
ctx.registerPrototype("testService", TestService.class, new MutablePropertyValues()); ctx.registerPrototype("testService", TestService.class, new MutablePropertyValues());
@ -171,6 +179,7 @@ public class ServiceLocatorFactoryBeanTests extends TestCase {
assertTrue(factory.toString().indexOf("TestServiceLocator3") != -1); assertTrue(factory.toString().indexOf("TestServiceLocator3") != -1);
} }
@Test
public void testServiceMappings() { public void testServiceMappings() {
StaticApplicationContext ctx = new StaticApplicationContext(); StaticApplicationContext ctx = new StaticApplicationContext();
ctx.registerPrototype("testService1", TestService.class, new MutablePropertyValues()); ctx.registerPrototype("testService1", TestService.class, new MutablePropertyValues());
@ -198,6 +207,7 @@ public class ServiceLocatorFactoryBeanTests extends TestCase {
assertTrue(testBean4 instanceof ExtendedTestService); assertTrue(testBean4 instanceof ExtendedTestService);
} }
@Test
public void testNoServiceLocatorInterfaceSupplied() throws Exception { public void testNoServiceLocatorInterfaceSupplied() throws Exception {
new AssertThrows(IllegalArgumentException.class, "No serviceLocator interface supplied") { new AssertThrows(IllegalArgumentException.class, "No serviceLocator interface supplied") {
public void test() throws Exception { public void test() throws Exception {
@ -206,6 +216,7 @@ public class ServiceLocatorFactoryBeanTests extends TestCase {
}.runTest(); }.runTest();
} }
@Test
public void testWhenServiceLocatorInterfaceIsNotAnInterfaceType() throws Exception { public void testWhenServiceLocatorInterfaceIsNotAnInterfaceType() throws Exception {
new AssertThrows(IllegalArgumentException.class, "Bad (non-interface-type) serviceLocator interface supplied") { new AssertThrows(IllegalArgumentException.class, "Bad (non-interface-type) serviceLocator interface supplied") {
public void test() throws Exception { public void test() throws Exception {
@ -216,6 +227,7 @@ public class ServiceLocatorFactoryBeanTests extends TestCase {
}.runTest(); }.runTest();
} }
@Test
public void testWhenServiceLocatorExceptionClassToExceptionTypeWithOnlyNoArgCtor() throws Exception { public void testWhenServiceLocatorExceptionClassToExceptionTypeWithOnlyNoArgCtor() throws Exception {
new AssertThrows(IllegalArgumentException.class, "Bad (invalid-Exception-type) serviceLocatorException class supplied") { new AssertThrows(IllegalArgumentException.class, "Bad (invalid-Exception-type) serviceLocatorException class supplied") {
public void test() throws Exception { public void test() throws Exception {
@ -225,6 +237,7 @@ public class ServiceLocatorFactoryBeanTests extends TestCase {
}.runTest(); }.runTest();
} }
@Test
public void testWhenServiceLocatorExceptionClassIsNotAnExceptionSubclass() throws Exception { public void testWhenServiceLocatorExceptionClassIsNotAnExceptionSubclass() throws Exception {
new AssertThrows(IllegalArgumentException.class, "Bad (non-Exception-type) serviceLocatorException class supplied") { new AssertThrows(IllegalArgumentException.class, "Bad (non-Exception-type) serviceLocatorException class supplied") {
public void test() throws Exception { public void test() throws Exception {
@ -234,6 +247,7 @@ public class ServiceLocatorFactoryBeanTests extends TestCase {
}.runTest(); }.runTest();
} }
@Test
public void testWhenServiceLocatorMethodCalledWithTooManyParameters() throws Exception { public void testWhenServiceLocatorMethodCalledWithTooManyParameters() throws Exception {
ServiceLocatorFactoryBean factory = new ServiceLocatorFactoryBean(); ServiceLocatorFactoryBean factory = new ServiceLocatorFactoryBean();
factory.setServiceLocatorInterface(ServiceLocatorInterfaceWithExtraNonCompliantMethod.class); factory.setServiceLocatorInterface(ServiceLocatorInterfaceWithExtraNonCompliantMethod.class);
@ -246,19 +260,19 @@ public class ServiceLocatorFactoryBeanTests extends TestCase {
}.runTest(); }.runTest();
} }
@Test
public void testRequiresListableBeanFactoryAndChokesOnAnythingElse() throws Exception { public void testRequiresListableBeanFactoryAndChokesOnAnythingElse() throws Exception {
MockControl mockBeanFactory = MockControl.createControl(BeanFactory.class); final BeanFactory beanFactory = createMock(BeanFactory.class);
final BeanFactory beanFactory = (BeanFactory) mockBeanFactory.getMock(); replay(beanFactory);
mockBeanFactory.replay();
new AssertThrows(FatalBeanException.class) { try {
public void test() throws Exception { ServiceLocatorFactoryBean factory = new ServiceLocatorFactoryBean();
ServiceLocatorFactoryBean factory = new ServiceLocatorFactoryBean(); factory.setBeanFactory(beanFactory);
factory.setBeanFactory(beanFactory); } catch (FatalBeanException ex) {
} // expected
}.runTest(); }
mockBeanFactory.verify(); verify(beanFactory);
} }
@ -315,6 +329,7 @@ public class ServiceLocatorFactoryBeanTests extends TestCase {
} }
@SuppressWarnings("serial")
public static class CustomServiceLocatorException1 extends NestedRuntimeException { public static class CustomServiceLocatorException1 extends NestedRuntimeException {
public CustomServiceLocatorException1(String message, Throwable cause) { public CustomServiceLocatorException1(String message, Throwable cause) {
@ -323,6 +338,7 @@ public class ServiceLocatorFactoryBeanTests extends TestCase {
} }
@SuppressWarnings("serial")
public static class CustomServiceLocatorException2 extends NestedCheckedException { public static class CustomServiceLocatorException2 extends NestedCheckedException {
public CustomServiceLocatorException2(Throwable cause) { public CustomServiceLocatorException2(Throwable cause) {
@ -331,6 +347,7 @@ public class ServiceLocatorFactoryBeanTests extends TestCase {
} }
@SuppressWarnings("serial")
public static class CustomServiceLocatorException3 extends NestedCheckedException { public static class CustomServiceLocatorException3 extends NestedCheckedException {
public CustomServiceLocatorException3(String message) { public CustomServiceLocatorException3(String message) {
@ -339,6 +356,7 @@ public class ServiceLocatorFactoryBeanTests extends TestCase {
} }
@SuppressWarnings("serial")
public static class ExceptionClassWithOnlyZeroArgCtor extends Exception { public static class ExceptionClassWithOnlyZeroArgCtor extends Exception {
} }

View File

@ -16,8 +16,10 @@
package org.springframework.beans.factory.xml; package org.springframework.beans.factory.xml;
import junit.framework.TestCase; import static org.junit.Assert.assertEquals;
import org.junit.Before;
import org.junit.Test;
import org.springframework.aop.interceptor.DebugInterceptor; import org.springframework.aop.interceptor.DebugInterceptor;
import org.springframework.beans.ITestBean; import org.springframework.beans.ITestBean;
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContext;
@ -28,16 +30,19 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
* *
* @author Rod Johnson * @author Rod Johnson
* @author Juergen Hoeller * @author Juergen Hoeller
* @author Chris Beams
*/ */
public class LookupMethodWrappedByCglibProxyTests extends TestCase { public class LookupMethodWrappedByCglibProxyTests {
private ApplicationContext applicationContext; private ApplicationContext applicationContext;
protected void setUp() { @Before
public void setUp() {
this.applicationContext = new ClassPathXmlApplicationContext("overloadOverrides.xml", getClass()); this.applicationContext = new ClassPathXmlApplicationContext("overloadOverrides.xml", getClass());
resetInterceptor(); resetInterceptor();
} }
@Test
public void testAutoProxiedLookup() { public void testAutoProxiedLookup() {
OverloadLookup olup = (OverloadLookup) applicationContext.getBean("autoProxiedOverload"); OverloadLookup olup = (OverloadLookup) applicationContext.getBean("autoProxiedOverload");
ITestBean jenny = olup.newTestBean(); ITestBean jenny = olup.newTestBean();
@ -46,6 +51,7 @@ public class LookupMethodWrappedByCglibProxyTests extends TestCase {
assertInterceptorCount(2); assertInterceptorCount(2);
} }
@Test
public void testRegularlyProxiedLookup() { public void testRegularlyProxiedLookup() {
OverloadLookup olup = (OverloadLookup) applicationContext.getBean("regularlyProxiedOverload"); OverloadLookup olup = (OverloadLookup) applicationContext.getBean("regularlyProxiedOverload");
ITestBean jenny = olup.newTestBean(); ITestBean jenny = olup.newTestBean();

View File

@ -0,0 +1,39 @@
/*
* 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.beans.factory.xml;
import java.util.Map;
import java.util.Set;
/**
* @author Chris Beams
*/
public class MapAndSet {
private Object obj;
public MapAndSet(Map map) {
this.obj = map;
}
public MapAndSet(Set set) {
this.obj = set;
}
public Object getObject() {
return obj;
}
}

View File

@ -0,0 +1,41 @@
/*
* 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.beans.factory.xml;
import java.util.Collection;
/**
* Bean that exposes a simple property that can be set
* to a mix of references and individual values.
*
* @author Rod Johnson
* @since 27.05.2003
*/
public class MixedCollectionBean {
private Collection jumble;
public void setJumble(Collection jumble) {
this.jumble = jumble;
}
public Collection getJumble() {
return jumble;
}
}

View File

@ -16,13 +16,14 @@
package org.springframework.beans.factory.xml; package org.springframework.beans.factory.xml;
import static org.junit.Assert.*;
import java.lang.annotation.ElementType; import java.lang.annotation.ElementType;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy; import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target; import java.lang.annotation.Target;
import junit.framework.TestCase; import org.junit.Test;
import org.springframework.beans.factory.BeanCreationException; import org.springframework.beans.factory.BeanCreationException;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Qualifier;
@ -33,13 +34,15 @@ import org.springframework.context.support.StaticApplicationContext;
/** /**
* @author Mark Fisher * @author Mark Fisher
* @author Juergen Hoeller * @author Juergen Hoeller
* @author Chris Beams
*/ */
public class QualifierAnnotationTests extends TestCase { public class QualifierAnnotationTests {
private static final String CONFIG_LOCATION = private static final String CONFIG_LOCATION =
"classpath:org/springframework/beans/factory/xml/qualifierAnnotationTests.xml"; "classpath:org/springframework/beans/factory/xml/qualifierAnnotationTests.xml";
@Test
public void testNonQualifiedFieldFails() { public void testNonQualifiedFieldFails() {
StaticApplicationContext context = new StaticApplicationContext(); StaticApplicationContext context = new StaticApplicationContext();
BeanDefinitionReader reader = new XmlBeanDefinitionReader(context); BeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
@ -54,6 +57,7 @@ public class QualifierAnnotationTests extends TestCase {
} }
} }
@Test
public void testQualifiedByValue() { public void testQualifiedByValue() {
StaticApplicationContext context = new StaticApplicationContext(); StaticApplicationContext context = new StaticApplicationContext();
BeanDefinitionReader reader = new XmlBeanDefinitionReader(context); BeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
@ -65,6 +69,7 @@ public class QualifierAnnotationTests extends TestCase {
assertEquals("Larry", person.getName()); assertEquals("Larry", person.getName());
} }
@Test
public void testQualifiedByBeanName() { public void testQualifiedByBeanName() {
StaticApplicationContext context = new StaticApplicationContext(); StaticApplicationContext context = new StaticApplicationContext();
BeanDefinitionReader reader = new XmlBeanDefinitionReader(context); BeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
@ -76,6 +81,7 @@ public class QualifierAnnotationTests extends TestCase {
assertEquals("LarryBean", person.getName()); assertEquals("LarryBean", person.getName());
} }
@Test
public void testQualifiedByAlias() { public void testQualifiedByAlias() {
StaticApplicationContext context = new StaticApplicationContext(); StaticApplicationContext context = new StaticApplicationContext();
BeanDefinitionReader reader = new XmlBeanDefinitionReader(context); BeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
@ -87,6 +93,7 @@ public class QualifierAnnotationTests extends TestCase {
assertEquals("LarryBean", person.getName()); assertEquals("LarryBean", person.getName());
} }
@Test
public void testQualifiedByAnnotation() { public void testQualifiedByAnnotation() {
StaticApplicationContext context = new StaticApplicationContext(); StaticApplicationContext context = new StaticApplicationContext();
BeanDefinitionReader reader = new XmlBeanDefinitionReader(context); BeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
@ -98,6 +105,7 @@ public class QualifierAnnotationTests extends TestCase {
assertEquals("LarrySpecial", person.getName()); assertEquals("LarrySpecial", person.getName());
} }
@Test
public void testQualifiedByCustomValue() { public void testQualifiedByCustomValue() {
StaticApplicationContext context = new StaticApplicationContext(); StaticApplicationContext context = new StaticApplicationContext();
BeanDefinitionReader reader = new XmlBeanDefinitionReader(context); BeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
@ -109,6 +117,7 @@ public class QualifierAnnotationTests extends TestCase {
assertEquals("Curly", person.getName()); assertEquals("Curly", person.getName());
} }
@Test
public void testQualifiedByAnnotationValue() { public void testQualifiedByAnnotationValue() {
StaticApplicationContext context = new StaticApplicationContext(); StaticApplicationContext context = new StaticApplicationContext();
BeanDefinitionReader reader = new XmlBeanDefinitionReader(context); BeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
@ -120,6 +129,7 @@ public class QualifierAnnotationTests extends TestCase {
assertEquals("LarrySpecial", person.getName()); assertEquals("LarrySpecial", person.getName());
} }
@Test
public void testQualifiedByAttributesFailsWithoutCustomQualifierRegistered() { public void testQualifiedByAttributesFailsWithoutCustomQualifierRegistered() {
StaticApplicationContext context = new StaticApplicationContext(); StaticApplicationContext context = new StaticApplicationContext();
BeanDefinitionReader reader = new XmlBeanDefinitionReader(context); BeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
@ -134,6 +144,7 @@ public class QualifierAnnotationTests extends TestCase {
} }
} }
@Test
public void testQualifiedByAttributesWithCustomQualifierRegistered() { public void testQualifiedByAttributesWithCustomQualifierRegistered() {
StaticApplicationContext context = new StaticApplicationContext(); StaticApplicationContext context = new StaticApplicationContext();
BeanDefinitionReader reader = new XmlBeanDefinitionReader(context); BeanDefinitionReader reader = new XmlBeanDefinitionReader(context);

View File

@ -352,7 +352,7 @@
</property> </property>
</bean> </bean>
<bean id="setAndMap" class="org.springframework.beans.factory.xml.XmlBeanCollectionTests$MapAndSet"> <bean id="setAndMap" class="org.springframework.beans.factory.xml.MapAndSet">
<constructor-arg> <constructor-arg>
<map> <map>
<description>My Map</description> <description>My Map</description>