moving unit tests from .testsuite -> .context
This commit is contained in:
@@ -0,0 +1,82 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2002-2008 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.config;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.ObjectFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Juergen Hoeller
|
||||||
|
*/
|
||||||
|
public class SimpleMapScope implements Scope, Serializable {
|
||||||
|
|
||||||
|
private final Map map = new HashMap();
|
||||||
|
|
||||||
|
private final List callbacks = new LinkedList();
|
||||||
|
|
||||||
|
|
||||||
|
public SimpleMapScope() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public final Map getMap() {
|
||||||
|
return this.map;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Object get(String name, ObjectFactory objectFactory) {
|
||||||
|
synchronized (this.map) {
|
||||||
|
Object scopedObject = this.map.get(name);
|
||||||
|
if (scopedObject == null) {
|
||||||
|
scopedObject = objectFactory.getObject();
|
||||||
|
this.map.put(name, scopedObject);
|
||||||
|
}
|
||||||
|
return scopedObject;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object remove(String name) {
|
||||||
|
synchronized (this.map) {
|
||||||
|
return this.map.remove(name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void registerDestructionCallback(String name, Runnable callback) {
|
||||||
|
this.callbacks.add(callback);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object resolveContextualObject(String key) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void close() {
|
||||||
|
for (Iterator it = this.callbacks.iterator(); it.hasNext();) {
|
||||||
|
Runnable runnable = (Runnable) it.next();
|
||||||
|
runnable.run();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getConversationId() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -16,26 +16,31 @@
|
|||||||
|
|
||||||
package org.springframework.context.annotation;
|
package org.springframework.context.annotation;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
import org.springframework.beans.factory.UnsatisfiedDependencyException;
|
import org.springframework.beans.factory.UnsatisfiedDependencyException;
|
||||||
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
|
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
|
||||||
import org.springframework.context.support.GenericApplicationContext;
|
import org.springframework.context.support.GenericApplicationContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Mark Fisher
|
* @author Mark Fisher
|
||||||
|
* @author Chris Beams
|
||||||
*/
|
*/
|
||||||
public class ComponentScanParserBeanDefinitionDefaultsTests extends TestCase {
|
public class ComponentScanParserBeanDefinitionDefaultsTests {
|
||||||
|
|
||||||
private static final String TEST_BEAN_NAME = "componentScanParserBeanDefinitionDefaultsTests.DefaultsTestBean";
|
private static final String TEST_BEAN_NAME = "componentScanParserBeanDefinitionDefaultsTests.DefaultsTestBean";
|
||||||
|
|
||||||
private static final String LOCATION_PREFIX = "org/springframework/context/annotation/";
|
private static final String LOCATION_PREFIX = "org/springframework/context/annotation/";
|
||||||
|
|
||||||
|
|
||||||
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
DefaultsTestBean.INIT_COUNT = 0;
|
DefaultsTestBean.INIT_COUNT = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testDefaultLazyInit() {
|
public void testDefaultLazyInit() {
|
||||||
GenericApplicationContext context = new GenericApplicationContext();
|
GenericApplicationContext context = new GenericApplicationContext();
|
||||||
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
|
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
|
||||||
@@ -46,6 +51,7 @@ public class ComponentScanParserBeanDefinitionDefaultsTests extends TestCase {
|
|||||||
assertEquals("bean should have been instantiated", 1, DefaultsTestBean.INIT_COUNT);
|
assertEquals("bean should have been instantiated", 1, DefaultsTestBean.INIT_COUNT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testLazyInitTrue() {
|
public void testLazyInitTrue() {
|
||||||
GenericApplicationContext context = new GenericApplicationContext();
|
GenericApplicationContext context = new GenericApplicationContext();
|
||||||
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
|
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
|
||||||
@@ -58,6 +64,7 @@ public class ComponentScanParserBeanDefinitionDefaultsTests extends TestCase {
|
|||||||
assertEquals("bean should have been instantiated", 1, DefaultsTestBean.INIT_COUNT);
|
assertEquals("bean should have been instantiated", 1, DefaultsTestBean.INIT_COUNT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testLazyInitFalse() {
|
public void testLazyInitFalse() {
|
||||||
GenericApplicationContext context = new GenericApplicationContext();
|
GenericApplicationContext context = new GenericApplicationContext();
|
||||||
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
|
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
|
||||||
@@ -68,6 +75,7 @@ public class ComponentScanParserBeanDefinitionDefaultsTests extends TestCase {
|
|||||||
assertEquals("bean should have been instantiated", 1, DefaultsTestBean.INIT_COUNT);
|
assertEquals("bean should have been instantiated", 1, DefaultsTestBean.INIT_COUNT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testDefaultAutowire() {
|
public void testDefaultAutowire() {
|
||||||
GenericApplicationContext context = new GenericApplicationContext();
|
GenericApplicationContext context = new GenericApplicationContext();
|
||||||
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
|
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
|
||||||
@@ -79,6 +87,7 @@ public class ComponentScanParserBeanDefinitionDefaultsTests extends TestCase {
|
|||||||
assertNull("no dependencies should have been autowired", bean.getPropertyDependency2());
|
assertNull("no dependencies should have been autowired", bean.getPropertyDependency2());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testAutowireNo() {
|
public void testAutowireNo() {
|
||||||
GenericApplicationContext context = new GenericApplicationContext();
|
GenericApplicationContext context = new GenericApplicationContext();
|
||||||
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
|
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
|
||||||
@@ -90,6 +99,7 @@ public class ComponentScanParserBeanDefinitionDefaultsTests extends TestCase {
|
|||||||
assertNull("no dependencies should have been autowired", bean.getPropertyDependency2());
|
assertNull("no dependencies should have been autowired", bean.getPropertyDependency2());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testAutowireConstructor() {
|
public void testAutowireConstructor() {
|
||||||
GenericApplicationContext context = new GenericApplicationContext();
|
GenericApplicationContext context = new GenericApplicationContext();
|
||||||
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
|
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
|
||||||
@@ -102,6 +112,7 @@ public class ComponentScanParserBeanDefinitionDefaultsTests extends TestCase {
|
|||||||
assertNull("property dependencies should not have been autowired", bean.getPropertyDependency2());
|
assertNull("property dependencies should not have been autowired", bean.getPropertyDependency2());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testAutowireByType() {
|
public void testAutowireByType() {
|
||||||
GenericApplicationContext context = new GenericApplicationContext();
|
GenericApplicationContext context = new GenericApplicationContext();
|
||||||
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
|
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
|
||||||
@@ -115,6 +126,7 @@ public class ComponentScanParserBeanDefinitionDefaultsTests extends TestCase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testAutowireByName() {
|
public void testAutowireByName() {
|
||||||
GenericApplicationContext context = new GenericApplicationContext();
|
GenericApplicationContext context = new GenericApplicationContext();
|
||||||
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
|
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
|
||||||
@@ -127,6 +139,7 @@ public class ComponentScanParserBeanDefinitionDefaultsTests extends TestCase {
|
|||||||
assertEquals("pd2", bean.getPropertyDependency2().getName());
|
assertEquals("pd2", bean.getPropertyDependency2().getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testDefaultDependencyCheck() {
|
public void testDefaultDependencyCheck() {
|
||||||
GenericApplicationContext context = new GenericApplicationContext();
|
GenericApplicationContext context = new GenericApplicationContext();
|
||||||
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
|
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
|
||||||
@@ -138,6 +151,7 @@ public class ComponentScanParserBeanDefinitionDefaultsTests extends TestCase {
|
|||||||
assertNull("property dependencies should not have been autowired", bean.getPropertyDependency2());
|
assertNull("property dependencies should not have been autowired", bean.getPropertyDependency2());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testDependencyCheckAll() {
|
public void testDependencyCheckAll() {
|
||||||
GenericApplicationContext context = new GenericApplicationContext();
|
GenericApplicationContext context = new GenericApplicationContext();
|
||||||
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
|
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
|
||||||
@@ -151,6 +165,7 @@ public class ComponentScanParserBeanDefinitionDefaultsTests extends TestCase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testDependencyCheckObjectsWithAutowireByName() {
|
public void testDependencyCheckObjectsWithAutowireByName() {
|
||||||
GenericApplicationContext context = new GenericApplicationContext();
|
GenericApplicationContext context = new GenericApplicationContext();
|
||||||
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
|
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
|
||||||
@@ -162,6 +177,7 @@ public class ComponentScanParserBeanDefinitionDefaultsTests extends TestCase {
|
|||||||
assertNotNull("property dependencies should have been autowired", bean.getPropertyDependency2());
|
assertNotNull("property dependencies should have been autowired", bean.getPropertyDependency2());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testDefaultInitAndDestroyMethodsNotDefined() {
|
public void testDefaultInitAndDestroyMethodsNotDefined() {
|
||||||
GenericApplicationContext context = new GenericApplicationContext();
|
GenericApplicationContext context = new GenericApplicationContext();
|
||||||
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
|
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
|
||||||
@@ -173,6 +189,7 @@ public class ComponentScanParserBeanDefinitionDefaultsTests extends TestCase {
|
|||||||
assertFalse("bean should not have been destroyed", bean.isDestroyed());
|
assertFalse("bean should not have been destroyed", bean.isDestroyed());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testDefaultInitAndDestroyMethodsDefined() {
|
public void testDefaultInitAndDestroyMethodsDefined() {
|
||||||
GenericApplicationContext context = new GenericApplicationContext();
|
GenericApplicationContext context = new GenericApplicationContext();
|
||||||
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
|
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
|
||||||
@@ -184,6 +201,7 @@ public class ComponentScanParserBeanDefinitionDefaultsTests extends TestCase {
|
|||||||
assertTrue("bean should have been destroyed", bean.isDestroyed());
|
assertTrue("bean should have been destroyed", bean.isDestroyed());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testDefaultNonExistingInitAndDestroyMethodsDefined() {
|
public void testDefaultNonExistingInitAndDestroyMethodsDefined() {
|
||||||
GenericApplicationContext context = new GenericApplicationContext();
|
GenericApplicationContext context = new GenericApplicationContext();
|
||||||
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
|
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
|
||||||
@@ -16,8 +16,9 @@
|
|||||||
|
|
||||||
package org.springframework.context.annotation;
|
package org.springframework.context.annotation;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
import org.springframework.aop.support.AopUtils;
|
import org.springframework.aop.support.AopUtils;
|
||||||
import org.springframework.beans.FatalBeanException;
|
import org.springframework.beans.FatalBeanException;
|
||||||
import org.springframework.beans.factory.config.SimpleMapScope;
|
import org.springframework.beans.factory.config.SimpleMapScope;
|
||||||
@@ -30,8 +31,9 @@ import example.scannable.ScopedProxyTestBean;
|
|||||||
* @author Mark Fisher
|
* @author Mark Fisher
|
||||||
* @author Juergen Hoeller
|
* @author Juergen Hoeller
|
||||||
*/
|
*/
|
||||||
public class ComponentScanParserScopedProxyTests extends TestCase {
|
public class ComponentScanParserScopedProxyTests {
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testDefaultScopedProxy() {
|
public void testDefaultScopedProxy() {
|
||||||
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
|
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
|
||||||
"org/springframework/context/annotation/scopedProxyDefaultTests.xml");
|
"org/springframework/context/annotation/scopedProxyDefaultTests.xml");
|
||||||
@@ -41,6 +43,7 @@ public class ComponentScanParserScopedProxyTests extends TestCase {
|
|||||||
assertFalse(AopUtils.isAopProxy(bean));
|
assertFalse(AopUtils.isAopProxy(bean));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testNoScopedProxy() {
|
public void testNoScopedProxy() {
|
||||||
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
|
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
|
||||||
"org/springframework/context/annotation/scopedProxyNoTests.xml");
|
"org/springframework/context/annotation/scopedProxyNoTests.xml");
|
||||||
@@ -50,6 +53,7 @@ public class ComponentScanParserScopedProxyTests extends TestCase {
|
|||||||
assertFalse(AopUtils.isAopProxy(bean));
|
assertFalse(AopUtils.isAopProxy(bean));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testInterfacesScopedProxy() {
|
public void testInterfacesScopedProxy() {
|
||||||
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
|
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
|
||||||
"org/springframework/context/annotation/scopedProxyInterfacesTests.xml");
|
"org/springframework/context/annotation/scopedProxyInterfacesTests.xml");
|
||||||
@@ -60,6 +64,7 @@ public class ComponentScanParserScopedProxyTests extends TestCase {
|
|||||||
assertTrue(AopUtils.isJdkDynamicProxy(bean));
|
assertTrue(AopUtils.isJdkDynamicProxy(bean));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testTargetClassScopedProxy() {
|
public void testTargetClassScopedProxy() {
|
||||||
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
|
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
|
||||||
"org/springframework/context/annotation/scopedProxyTargetClassTests.xml");
|
"org/springframework/context/annotation/scopedProxyTargetClassTests.xml");
|
||||||
@@ -69,6 +74,7 @@ public class ComponentScanParserScopedProxyTests extends TestCase {
|
|||||||
assertTrue(AopUtils.isCglibProxy(bean));
|
assertTrue(AopUtils.isCglibProxy(bean));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testInvalidConfigScopedProxy() {
|
public void testInvalidConfigScopedProxy() {
|
||||||
try {
|
try {
|
||||||
new ClassPathXmlApplicationContext(
|
new ClassPathXmlApplicationContext(
|
||||||
@@ -16,13 +16,14 @@
|
|||||||
|
|
||||||
package org.springframework.context.annotation;
|
package org.springframework.context.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;
|
||||||
import java.lang.annotation.Target;
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
import org.junit.Test;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||||
@@ -35,9 +36,11 @@ import example.scannable.AutowiredQualifierFooService;
|
|||||||
/**
|
/**
|
||||||
* @author Mark Fisher
|
* @author Mark Fisher
|
||||||
* @author Juergen Hoeller
|
* @author Juergen Hoeller
|
||||||
|
* @author Chris Beams
|
||||||
*/
|
*/
|
||||||
public class ComponentScanParserTests extends TestCase {
|
public class ComponentScanParserTests {
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testAspectJTypeFilter() {
|
public void testAspectJTypeFilter() {
|
||||||
ApplicationContext context = new ClassPathXmlApplicationContext(
|
ApplicationContext context = new ClassPathXmlApplicationContext(
|
||||||
"org/springframework/context/annotation/aspectjTypeFilterTests.xml");
|
"org/springframework/context/annotation/aspectjTypeFilterTests.xml");
|
||||||
@@ -46,18 +49,21 @@ public class ComponentScanParserTests extends TestCase {
|
|||||||
assertFalse(context.containsBean("scopedProxyTestBean"));
|
assertFalse(context.containsBean("scopedProxyTestBean"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testNonMatchingResourcePattern() {
|
public void testNonMatchingResourcePattern() {
|
||||||
ApplicationContext context = new ClassPathXmlApplicationContext(
|
ApplicationContext context = new ClassPathXmlApplicationContext(
|
||||||
"org/springframework/context/annotation/nonMatchingResourcePatternTests.xml");
|
"org/springframework/context/annotation/nonMatchingResourcePatternTests.xml");
|
||||||
assertFalse(context.containsBean("fooServiceImpl"));
|
assertFalse(context.containsBean("fooServiceImpl"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testMatchingResourcePattern() {
|
public void testMatchingResourcePattern() {
|
||||||
ApplicationContext context = new ClassPathXmlApplicationContext(
|
ApplicationContext context = new ClassPathXmlApplicationContext(
|
||||||
"org/springframework/context/annotation/matchingResourcePatternTests.xml");
|
"org/springframework/context/annotation/matchingResourcePatternTests.xml");
|
||||||
assertTrue(context.containsBean("fooServiceImpl"));
|
assertTrue(context.containsBean("fooServiceImpl"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testComponentScanWithAutowiredQualifier() {
|
public void testComponentScanWithAutowiredQualifier() {
|
||||||
ApplicationContext context = new ClassPathXmlApplicationContext(
|
ApplicationContext context = new ClassPathXmlApplicationContext(
|
||||||
"org/springframework/context/annotation/componentScanWithAutowiredQualifierTests.xml");
|
"org/springframework/context/annotation/componentScanWithAutowiredQualifierTests.xml");
|
||||||
@@ -66,6 +72,7 @@ public class ComponentScanParserTests extends TestCase {
|
|||||||
assertEquals("bar", fooService.foo(123));
|
assertEquals("bar", fooService.foo(123));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testCustomAnnotationUsedForBothComponentScanAndQualifier() {
|
public void testCustomAnnotationUsedForBothComponentScanAndQualifier() {
|
||||||
ApplicationContext context = new ClassPathXmlApplicationContext(
|
ApplicationContext context = new ClassPathXmlApplicationContext(
|
||||||
"org/springframework/context/annotation/customAnnotationUsedForBothComponentScanAndQualifierTests.xml");
|
"org/springframework/context/annotation/customAnnotationUsedForBothComponentScanAndQualifierTests.xml");
|
||||||
@@ -73,6 +80,7 @@ public class ComponentScanParserTests extends TestCase {
|
|||||||
assertNotNull(testBean.getDependency());
|
assertNotNull(testBean.getDependency());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testCustomTypeFilter() {
|
public void testCustomTypeFilter() {
|
||||||
ApplicationContext context = new ClassPathXmlApplicationContext(
|
ApplicationContext context = new ClassPathXmlApplicationContext(
|
||||||
"org/springframework/context/annotation/customTypeFilterTests.xml");
|
"org/springframework/context/annotation/customTypeFilterTests.xml");
|
||||||
@@ -16,23 +16,27 @@
|
|||||||
|
|
||||||
package org.springframework.context.annotation;
|
package org.springframework.context.annotation;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
import org.springframework.beans.BeansException;
|
import org.springframework.beans.BeansException;
|
||||||
import org.springframework.beans.factory.config.BeanDefinition;
|
import org.springframework.beans.factory.config.BeanDefinition;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||||
import org.springframework.test.AbstractDependencyInjectionSpringContextTests;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Mark Fisher
|
* @author Mark Fisher
|
||||||
*/
|
*/
|
||||||
public class ComponentScanParserWithUserDefinedStrategiesTests extends AbstractDependencyInjectionSpringContextTests {
|
public class ComponentScanParserWithUserDefinedStrategiesTests {
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testCustomBeanNameGenerator() {
|
public void testCustomBeanNameGenerator() {
|
||||||
ApplicationContext context = new ClassPathXmlApplicationContext(
|
ApplicationContext context = new ClassPathXmlApplicationContext(
|
||||||
"org/springframework/context/annotation/customNameGeneratorTests.xml");
|
"org/springframework/context/annotation/customNameGeneratorTests.xml");
|
||||||
assertTrue(context.containsBean("testing.fooServiceImpl"));
|
assertTrue(context.containsBean("testing.fooServiceImpl"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testCustomScopeMetadataResolver() {
|
public void testCustomScopeMetadataResolver() {
|
||||||
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
|
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
|
||||||
"org/springframework/context/annotation/customScopeResolverTests.xml");
|
"org/springframework/context/annotation/customScopeResolverTests.xml");
|
||||||
@@ -41,6 +45,7 @@ public class ComponentScanParserWithUserDefinedStrategiesTests extends AbstractD
|
|||||||
assertFalse(bd.isSingleton());
|
assertFalse(bd.isSingleton());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testInvalidConstructorBeanNameGenerator() {
|
public void testInvalidConstructorBeanNameGenerator() {
|
||||||
try {
|
try {
|
||||||
new ClassPathXmlApplicationContext(
|
new ClassPathXmlApplicationContext(
|
||||||
@@ -52,6 +57,7 @@ public class ComponentScanParserWithUserDefinedStrategiesTests extends AbstractD
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testInvalidClassNameScopeMetadataResolver() {
|
public void testInvalidClassNameScopeMetadataResolver() {
|
||||||
try {
|
try {
|
||||||
new ClassPathXmlApplicationContext(
|
new ClassPathXmlApplicationContext(
|
||||||
Reference in New Issue
Block a user