Browse Source

polishing .beans tests

git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@506 50f2f4bb-b051-0410-bef5-90022cba6387
pull/1/head
Chris Beams 17 years ago
parent
commit
657e7b76ae
  1. 0
      org.springframework.beans/src/test/java/org/springframework/beans/factory/access/SingletonBeanFactoryLocatorTests-beans1.xml
  2. 0
      org.springframework.beans/src/test/java/org/springframework/beans/factory/access/SingletonBeanFactoryLocatorTests-beans2.xml
  3. 4
      org.springframework.beans/src/test/java/org/springframework/beans/factory/access/SingletonBeanFactoryLocatorTests-ref1.xml
  4. 68
      org.springframework.beans/src/test/java/org/springframework/beans/factory/access/SingletonBeanFactoryLocatorTests.java
  5. 75
      org.springframework.beans/src/test/java/org/springframework/beans/factory/access/TestBean.java

0
org.springframework.beans/src/test/java/org/springframework/beans/factory/access/beans1.xml → org.springframework.beans/src/test/java/org/springframework/beans/factory/access/SingletonBeanFactoryLocatorTests-beans1.xml

0
org.springframework.beans/src/test/java/org/springframework/beans/factory/access/beans2.xml → org.springframework.beans/src/test/java/org/springframework/beans/factory/access/SingletonBeanFactoryLocatorTests-beans2.xml

4
org.springframework.beans/src/test/java/org/springframework/beans/factory/access/ref1.xml → org.springframework.beans/src/test/java/org/springframework/beans/factory/access/SingletonBeanFactoryLocatorTests-ref1.xml

@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@
<!-- this definition could be inside one beanRefFactory.xml file -->
<bean id="a.qualified.name.of.some.sort"
class="org.springframework.beans.factory.xml.XmlBeanFactory">
<constructor-arg value="org/springframework/beans/factory/access/beans1.xml"/>
<constructor-arg value="org/springframework/beans/factory/access/SingletonBeanFactoryLocatorTests-beans1.xml"/>
</bean>
<!-- while the following two could be inside another, also on the classpath,
@ -19,7 +19,7 @@ @@ -19,7 +19,7 @@
<bean id="another.qualified.name"
class="org.springframework.beans.factory.xml.XmlBeanFactory">
<constructor-arg value="org/springframework/beans/factory/access/beans1.xml"/>
<constructor-arg value="org/springframework/beans/factory/access/SingletonBeanFactoryLocatorTests-beans1.xml"/>
<constructor-arg ref="a.qualified.name.of.some.sort"/> <!-- parent bean factory -->
</bean>

68
org.springframework.beans/src/test/java/org/springframework/beans/factory/access/SingletonBeanFactoryLocatorTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2007 the original author or authors.
* 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.
@ -18,6 +18,8 @@ package org.springframework.beans.factory.access; @@ -18,6 +18,8 @@ package org.springframework.beans.factory.access;
import static org.junit.Assert.assertTrue;
import java.util.List;
import org.junit.Test;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.util.ClassUtils;
@ -26,12 +28,14 @@ import org.springframework.util.ClassUtils; @@ -26,12 +28,14 @@ import org.springframework.util.ClassUtils;
* @author Colin Sampaleanu
* @author Chris Beams
*/
public class SingletonBeanFactoryLocatorTests {
public final class SingletonBeanFactoryLocatorTests {
private static final Class<?> CLASS = SingletonBeanFactoryLocatorTests.class;
private static final String REF1_XML = CLASS.getSimpleName() + "-ref1.xml";
@Test
public void testBasicFunctionality() {
SingletonBeanFactoryLocator facLoc = new SingletonBeanFactoryLocator(
"classpath*:" + ClassUtils.addResourcePathToPackagePath(getClass(), "ref1.xml"));
"classpath*:" + ClassUtils.addResourcePathToPackagePath(CLASS, REF1_XML));
basicFunctionalityTest(facLoc);
}
@ -73,16 +77,16 @@ public class SingletonBeanFactoryLocatorTests { @@ -73,16 +77,16 @@ public class SingletonBeanFactoryLocatorTests {
public void testGetInstance() {
// Try with and without 'classpath*:' prefix, and with 'classpath:' prefix.
BeanFactoryLocator facLoc = SingletonBeanFactoryLocator.getInstance(
ClassUtils.addResourcePathToPackagePath(getClass(), "ref1.xml"));
ClassUtils.addResourcePathToPackagePath(CLASS, REF1_XML));
getInstanceTest1(facLoc);
facLoc = SingletonBeanFactoryLocator.getInstance(
"classpath*:/" + ClassUtils.addResourcePathToPackagePath(getClass(), "ref1.xml"));
"classpath*:/" + ClassUtils.addResourcePathToPackagePath(CLASS, REF1_XML));
getInstanceTest2(facLoc);
// This will actually get another locator instance, as the key is the resource name.
facLoc = SingletonBeanFactoryLocator.getInstance(
"classpath:" + ClassUtils.addResourcePathToPackagePath(getClass(), "ref1.xml"));
"classpath:" + ClassUtils.addResourcePathToPackagePath(CLASS, REF1_XML));
getInstanceTest3(facLoc);
}
@ -180,3 +184,55 @@ public class SingletonBeanFactoryLocatorTests { @@ -180,3 +184,55 @@ public class SingletonBeanFactoryLocatorTests {
}
}
class TestBean {
private String name;
private List<?> list;
private Object objRef;
/**
* @return Returns the name.
*/
public String getName() {
return name;
}
/**
* @param name The name to set.
*/
public void setName(String name) {
this.name = name;
}
/**
* @return Returns the list.
*/
public List<?> getList() {
return list;
}
/**
* @param list The list to set.
*/
public void setList(List<?> list) {
this.list = list;
}
/**
* @return Returns the object.
*/
public Object getObjRef() {
return objRef;
}
/**
* @param object The object to set.
*/
public void setObjRef(Object object) {
this.objRef = object;
}
}

75
org.springframework.beans/src/test/java/org/springframework/beans/factory/access/TestBean.java

@ -1,75 +0,0 @@ @@ -1,75 +0,0 @@
/*
* 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.access;
import java.util.List;
/**
* Scrap bean for use in tests.
*
* @author Colin Sampaleanu
*/
public class TestBean {
private String name;
private List list;
private Object objRef;
/**
* @return Returns the name.
*/
public String getName() {
return name;
}
/**
* @param name The name to set.
*/
public void setName(String name) {
this.name = name;
}
/**
* @return Returns the list.
*/
public List getList() {
return list;
}
/**
* @param list The list to set.
*/
public void setList(List list) {
this.list = list;
}
/**
* @return Returns the object.
*/
public Object getObjRef() {
return objRef;
}
/**
* @param object The object to set.
*/
public void setObjRef(Object object) {
this.objRef = object;
}
}
Loading…
Cancel
Save