Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
6cb71bbb
S
spring-framework
项目概览
爱吃血肠
/
spring-framework
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
spring-framework
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
6cb71bbb
编写于
12月 15, 2008
作者:
C
Chris Beams
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
moving unit tests from .testsuite -> .beans
上级
8977ad40
变更
18
展开全部
隐藏空白更改
内联
并排
Showing
18 changed file
with
410 addition
and
202 deletion
+410
-202
org.springframework.beans/src/test/java/org/springframework/beans/annotation/AnnotationBeanWiringInfoResolverTests.java
...ans/annotation/AnnotationBeanWiringInfoResolverTests.java
+13
-3
org.springframework.beans/src/test/java/org/springframework/beans/factory/BeanFactoryUtilsTests.java
.../springframework/beans/factory/BeanFactoryUtilsTests.java
+30
-12
org.springframework.beans/src/test/java/org/springframework/beans/factory/DefaultListableBeanFactoryTests.java
...mework/beans/factory/DefaultListableBeanFactoryTests.java
+145
-44
org.springframework.beans/src/test/java/org/springframework/beans/factory/FactoryBeanTests.java
...a/org/springframework/beans/factory/FactoryBeanTests.java
+24
-11
org.springframework.beans/src/test/java/org/springframework/beans/factory/KnowsIfInstantiated.java
...rg/springframework/beans/factory/KnowsIfInstantiated.java
+0
-0
org.springframework.beans/src/test/java/org/springframework/beans/factory/dependentBeans.xml
...java/org/springframework/beans/factory/dependentBeans.xml
+0
-0
org.springframework.beans/src/test/java/org/springframework/beans/factory/factoryBeanReturnsNull.xml
.../springframework/beans/factory/factoryBeanReturnsNull.xml
+0
-0
org.springframework.beans/src/test/java/org/springframework/beans/factory/factoryBeansWithAutowiring.xml
...ingframework/beans/factory/factoryBeansWithAutowiring.xml
+3
-16
org.springframework.beans/src/test/java/org/springframework/beans/factory/leaf.xml
.../src/test/java/org/springframework/beans/factory/leaf.xml
+0
-0
org.springframework.beans/src/test/java/org/springframework/beans/factory/middle.xml
...rc/test/java/org/springframework/beans/factory/middle.xml
+0
-0
org.springframework.beans/src/test/java/org/springframework/beans/factory/root.xml
.../src/test/java/org/springframework/beans/factory/root.xml
+1
-1
org.springframework.beans/src/test/java/org/springframework/beans/factory/xml/ConstructorDependenciesBean.java
...mework/beans/factory/xml/ConstructorDependenciesBean.java
+99
-0
org.springframework.beans/src/test/java/org/springframework/beans/factory/xml/DependenciesBean.java
...g/springframework/beans/factory/xml/DependenciesBean.java
+72
-0
org.springframework.beans/src/test/java/org/springframework/beans/factory/xml/SideEffectBean.java
...org/springframework/beans/factory/xml/SideEffectBean.java
+23
-0
org.springframework.testsuite/src/test/java/org/springframework/beans/factory/PackageLevelVisibleBean.java
...pringframework/beans/factory/PackageLevelVisibleBean.java
+0
-29
org.springframework.testsuite/src/test/java/org/springframework/beans/factory/xml/autowire-with-exclusion.xml
...ngframework/beans/factory/xml/autowire-with-exclusion.xml
+0
-26
org.springframework.testsuite/src/test/java/org/springframework/beans/factory/xml/autowire-with-inclusion.xml
...ngframework/beans/factory/xml/autowire-with-inclusion.xml
+0
-27
org.springframework.testsuite/src/test/java/org/springframework/beans/factory/xml/autowire-with-selective-inclusion.xml
...k/beans/factory/xml/autowire-with-selective-inclusion.xml
+0
-33
未找到文件。
org.springframework.
testsuite/src/test/java/org/springframework/beans/factory
/annotation/AnnotationBeanWiringInfoResolverTests.java
→
org.springframework.
beans/src/test/java/org/springframework/beans
/annotation/AnnotationBeanWiringInfoResolverTests.java
浏览文件 @
6cb71bbb
...
...
@@ -14,17 +14,23 @@
* limitations under the License.
*/
package
org.springframework.beans.
factory.
annotation
;
package
org.springframework.beans.annotation
;
import
junit.framework.TestCase
;
import
static
org
.
junit
.
Assert
.*
;
import
org.junit.Test
;
import
org.springframework.beans.factory.annotation.AnnotationBeanWiringInfoResolver
;
import
org.springframework.beans.factory.annotation.Autowire
;
import
org.springframework.beans.factory.annotation.Configurable
;
import
org.springframework.beans.factory.wiring.BeanWiringInfo
;
/**
* @author Rick Evans
* @author Chris Beams
*/
public
class
AnnotationBeanWiringInfoResolverTests
extends
TestCase
{
public
class
AnnotationBeanWiringInfoResolverTests
{
@Test
public
void
testResolveWiringInfo
()
throws
Exception
{
try
{
new
AnnotationBeanWiringInfoResolver
().
resolveWiringInfo
(
null
);
...
...
@@ -34,18 +40,21 @@ public class AnnotationBeanWiringInfoResolverTests extends TestCase {
}
}
@Test
public
void
testResolveWiringInfoWithAnInstanceOfANonAnnotatedClass
()
{
AnnotationBeanWiringInfoResolver
resolver
=
new
AnnotationBeanWiringInfoResolver
();
BeanWiringInfo
info
=
resolver
.
resolveWiringInfo
(
"java.lang.String is not @Configurable"
);
assertNull
(
"Must be returning null for a non-@Configurable class instance"
,
info
);
}
@Test
public
void
testResolveWiringInfoWithAnInstanceOfAnAnnotatedClass
()
{
AnnotationBeanWiringInfoResolver
resolver
=
new
AnnotationBeanWiringInfoResolver
();
BeanWiringInfo
info
=
resolver
.
resolveWiringInfo
(
new
Soap
());
assertNotNull
(
"Must *not* be returning null for a non-@Configurable class instance"
,
info
);
}
@Test
public
void
testResolveWiringInfoWithAnInstanceOfAnAnnotatedClassWithAutowiringTurnedOffExplicitly
()
{
AnnotationBeanWiringInfoResolver
resolver
=
new
AnnotationBeanWiringInfoResolver
();
BeanWiringInfo
info
=
resolver
.
resolveWiringInfo
(
new
WirelessSoap
());
...
...
@@ -54,6 +63,7 @@ public class AnnotationBeanWiringInfoResolverTests extends TestCase {
assertEquals
(
WirelessSoap
.
class
.
getName
(),
info
.
getBeanName
());
}
@Test
public
void
testResolveWiringInfoWithAnInstanceOfAnAnnotatedClassWithAutowiringTurnedOffExplicitlyAndCustomBeanName
()
{
AnnotationBeanWiringInfoResolver
resolver
=
new
AnnotationBeanWiringInfoResolver
();
BeanWiringInfo
info
=
resolver
.
resolveWiringInfo
(
new
NamedWirelessSoap
());
...
...
org.springframework.
testsuite
/src/test/java/org/springframework/beans/factory/BeanFactoryUtilsTests.java
→
org.springframework.
beans
/src/test/java/org/springframework/beans/factory/BeanFactoryUtilsTests.java
浏览文件 @
6cb71bbb
...
...
@@ -16,12 +16,16 @@
package
org.springframework.beans.factory
;
import
static
org
.
junit
.
Assert
.*;
import
java.util.Arrays
;
import
java.util.List
;
import
java.util.Map
;
import
junit.framework.TestCase
;
import
net.sf.cglib.proxy.NoOp
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.springframework.beans.ITestBean
;
import
org.springframework.beans.IndexedTestBean
;
import
org.springframework.beans.TestBean
;
...
...
@@ -30,20 +34,21 @@ import org.springframework.beans.factory.support.StaticListableBeanFactory;
import
org.springframework.beans.factory.xml.XmlBeanFactory
;
import
org.springframework.core.io.ClassPathResource
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.web.servlet.HandlerAdapter
;
/**
* @author Rod Johnson
* @author Juergen Hoeller
* @author Chris Beams
* @since 04.07.2003
*/
public
class
BeanFactoryUtilsTests
extends
TestCase
{
public
class
BeanFactoryUtilsTests
{
private
ConfigurableListableBeanFactory
listableBeanFactory
;
private
ConfigurableListableBeanFactory
dependentBeansBF
;
protected
void
setUp
()
{
@Before
public
void
setUp
()
{
// Interesting hierarchical factory to test counts.
// Slow to read so we cache it.
XmlBeanFactory
grandParent
=
new
XmlBeanFactory
(
new
ClassPathResource
(
"root.xml"
,
getClass
()));
...
...
@@ -54,6 +59,7 @@ public class BeanFactoryUtilsTests extends TestCase {
this
.
listableBeanFactory
=
child
;
}
@Test
public
void
testHierarchicalCountBeansWithNonHierarchicalFactory
()
{
StaticListableBeanFactory
lbf
=
new
StaticListableBeanFactory
();
lbf
.
addBean
(
"t1"
,
new
TestBean
());
...
...
@@ -64,6 +70,7 @@ public class BeanFactoryUtilsTests extends TestCase {
/**
* Check that override doesn't count as two separate beans.
*/
@Test
public
void
testHierarchicalCountBeansWithOverride
()
throws
Exception
{
// Leaf count
assertTrue
(
this
.
listableBeanFactory
.
getBeanDefinitionCount
()
==
1
);
...
...
@@ -73,14 +80,16 @@ public class BeanFactoryUtilsTests extends TestCase {
BeanFactoryUtils
.
countBeansIncludingAncestors
(
this
.
listableBeanFactory
)
==
7
);
}
@Test
public
void
testHierarchicalNamesWithNoMatch
()
throws
Exception
{
List
names
=
Arrays
.
asList
(
BeanFactoryUtils
.
beanNamesForTypeIncludingAncestors
(
this
.
listableBeanFactory
,
HandlerAdapter
.
class
));
List
<
String
>
names
=
Arrays
.
asList
(
BeanFactoryUtils
.
beanNamesForTypeIncludingAncestors
(
this
.
listableBeanFactory
,
NoOp
.
class
));
assertEquals
(
0
,
names
.
size
());
}
@Test
public
void
testHierarchicalNamesWithMatchOnlyInRoot
()
throws
Exception
{
List
names
=
Arrays
.
asList
(
BeanFactoryUtils
.
beanNamesForTypeIncludingAncestors
(
this
.
listableBeanFactory
,
List
<
String
>
names
=
Arrays
.
asList
(
BeanFactoryUtils
.
beanNamesForTypeIncludingAncestors
(
this
.
listableBeanFactory
,
IndexedTestBean
.
class
));
assertEquals
(
1
,
names
.
size
());
assertTrue
(
names
.
contains
(
"indexedBean"
));
...
...
@@ -88,8 +97,9 @@ public class BeanFactoryUtilsTests extends TestCase {
assertTrue
(
listableBeanFactory
.
getBeanNamesForType
(
IndexedTestBean
.
class
).
length
==
0
);
}
@Test
public
void
testGetBeanNamesForTypeWithOverride
()
throws
Exception
{
List
names
=
Arrays
.
asList
(
BeanFactoryUtils
.
beanNamesForTypeIncludingAncestors
(
this
.
listableBeanFactory
,
List
<
String
>
names
=
Arrays
.
asList
(
BeanFactoryUtils
.
beanNamesForTypeIncludingAncestors
(
this
.
listableBeanFactory
,
ITestBean
.
class
));
// includes 2 TestBeans from FactoryBeans (DummyFactory definitions)
assertEquals
(
4
,
names
.
size
());
...
...
@@ -99,13 +109,15 @@ public class BeanFactoryUtilsTests extends TestCase {
assertTrue
(
names
.
contains
(
"testFactory2"
));
}
@Test
public
void
testNoBeansOfType
()
{
StaticListableBeanFactory
lbf
=
new
StaticListableBeanFactory
();
lbf
.
addBean
(
"foo"
,
new
Object
());
Map
beans
=
BeanFactoryUtils
.
beansOfTypeIncludingAncestors
(
lbf
,
ITestBean
.
class
,
true
,
false
);
Map
<?,
?>
beans
=
BeanFactoryUtils
.
beansOfTypeIncludingAncestors
(
lbf
,
ITestBean
.
class
,
true
,
false
);
assertTrue
(
beans
.
isEmpty
());
}
@Test
public
void
testFindsBeansOfTypeWithStaticFactory
()
{
StaticListableBeanFactory
lbf
=
new
StaticListableBeanFactory
();
TestBean
t1
=
new
TestBean
();
...
...
@@ -118,7 +130,7 @@ public class BeanFactoryUtilsTests extends TestCase {
lbf
.
addBean
(
"t3"
,
t3
);
lbf
.
addBean
(
"t4"
,
t4
);
Map
beans
=
BeanFactoryUtils
.
beansOfTypeIncludingAncestors
(
lbf
,
ITestBean
.
class
,
true
,
false
);
Map
<?,
?>
beans
=
BeanFactoryUtils
.
beansOfTypeIncludingAncestors
(
lbf
,
ITestBean
.
class
,
true
,
false
);
assertEquals
(
2
,
beans
.
size
());
assertEquals
(
t1
,
beans
.
get
(
"t1"
));
assertEquals
(
t2
,
beans
.
get
(
"t2"
));
...
...
@@ -147,6 +159,7 @@ public class BeanFactoryUtilsTests extends TestCase {
assertEquals
(
t4
,
beans
.
get
(
"&t4"
));
}
@Test
public
void
testFindsBeansOfTypeWithDefaultFactory
()
{
Object
test3
=
this
.
listableBeanFactory
.
getBean
(
"test3"
);
Object
test
=
this
.
listableBeanFactory
.
getBean
(
"test"
);
...
...
@@ -161,7 +174,7 @@ public class BeanFactoryUtilsTests extends TestCase {
this
.
listableBeanFactory
.
registerSingleton
(
"t3"
,
t3
);
this
.
listableBeanFactory
.
registerSingleton
(
"t4"
,
t4
);
Map
beans
=
BeanFactoryUtils
.
beansOfTypeIncludingAncestors
(
this
.
listableBeanFactory
,
ITestBean
.
class
,
true
,
Map
<?,
?>
beans
=
BeanFactoryUtils
.
beansOfTypeIncludingAncestors
(
this
.
listableBeanFactory
,
ITestBean
.
class
,
true
,
false
);
assertEquals
(
6
,
beans
.
size
());
assertEquals
(
test3
,
beans
.
get
(
"test3"
));
...
...
@@ -212,11 +225,12 @@ public class BeanFactoryUtilsTests extends TestCase {
assertEquals
(
t4
,
beans
.
get
(
"&t4"
));
}
@Test
public
void
testHierarchicalResolutionWithOverride
()
throws
Exception
{
Object
test3
=
this
.
listableBeanFactory
.
getBean
(
"test3"
);
Object
test
=
this
.
listableBeanFactory
.
getBean
(
"test"
);
Map
beans
=
BeanFactoryUtils
.
beansOfTypeIncludingAncestors
(
this
.
listableBeanFactory
,
ITestBean
.
class
,
true
,
Map
<?,
?>
beans
=
BeanFactoryUtils
.
beansOfTypeIncludingAncestors
(
this
.
listableBeanFactory
,
ITestBean
.
class
,
true
,
false
);
assertEquals
(
2
,
beans
.
size
());
assertEquals
(
test3
,
beans
.
get
(
"test3"
));
...
...
@@ -250,21 +264,25 @@ public class BeanFactoryUtilsTests extends TestCase {
assertEquals
(
this
.
listableBeanFactory
.
getBean
(
"&testFactory2"
),
beans
.
get
(
"&testFactory2"
));
}
@Test
public
void
testADependencies
()
{
String
[]
deps
=
this
.
dependentBeansBF
.
getDependentBeans
(
"a"
);
assertTrue
(
ObjectUtils
.
isEmpty
(
deps
));
}
@Test
public
void
testBDependencies
()
{
String
[]
deps
=
this
.
dependentBeansBF
.
getDependentBeans
(
"b"
);
assertTrue
(
Arrays
.
equals
(
new
String
[]
{
"c"
},
deps
));
}
@Test
public
void
testCDependencies
()
{
String
[]
deps
=
this
.
dependentBeansBF
.
getDependentBeans
(
"c"
);
assertTrue
(
Arrays
.
equals
(
new
String
[]
{
"int"
,
"long"
},
deps
));
}
@Test
public
void
testIntDependencies
()
{
String
[]
deps
=
this
.
dependentBeansBF
.
getDependentBeans
(
"int"
);
assertTrue
(
Arrays
.
equals
(
new
String
[]
{
"buffer"
},
deps
));
...
...
org.springframework.
testsuite
/src/test/java/org/springframework/beans/factory/DefaultListableBeanFactoryTests.java
→
org.springframework.
beans
/src/test/java/org/springframework/beans/factory/DefaultListableBeanFactoryTests.java
浏览文件 @
6cb71bbb
此差异已折叠。
点击以展开。
org.springframework.
testsuite
/src/test/java/org/springframework/beans/factory/FactoryBeanTests.java
→
org.springframework.
beans
/src/test/java/org/springframework/beans/factory/FactoryBeanTests.java
浏览文件 @
6cb71bbb
...
...
@@ -16,28 +16,36 @@
package
org.springframework.beans.factory
;
import
junit.framework.TestCase
;
import
static
org
.
junit
.
Assert
.*
;
import
org.junit.Test
;
import
org.springframework.beans.factory.config.BeanFactoryPostProcessor
;
import
org.springframework.beans.factory.xml.XmlBeanFactory
;
import
org.springframework.context.support.ClassPathXmlApplicationContext
;
import
org.springframework.core.io.ClassPathResource
;
import
org.springframework.util.Assert
;
/**
* @author Rob Harrop
* @author Juergen Hoeller
* @author Chris Beams
*/
public
class
FactoryBeanTests
extends
TestCase
{
public
class
FactoryBeanTests
{
@Test
public
void
testFactoryBeanReturnsNull
()
throws
Exception
{
XmlBeanFactory
factory
=
new
XmlBeanFactory
(
new
ClassPathResource
(
"factoryBeanReturnsNull.xml"
,
getClass
()));
Object
result
=
factory
.
getBean
(
"factoryBean"
);
assertNull
(
result
);
}
@Test
public
void
testFactoryBeansWithAutowiring
()
throws
Exception
{
ClassPathXmlApplicationContext
factory
=
new
ClassPathXmlApplicationContext
(
"factoryBeansWithAutowiring.xml"
,
getClass
());
XmlBeanFactory
factory
=
new
XmlBeanFactory
(
new
ClassPathResource
(
"factoryBeansWithAutowiring.xml"
,
getClass
()));
BeanFactoryPostProcessor
ppc
=
(
BeanFactoryPostProcessor
)
factory
.
getBean
(
"propertyPlaceholderConfigurer"
);
ppc
.
postProcessBeanFactory
(
factory
);
Alpha
alpha
=
(
Alpha
)
factory
.
getBean
(
"alpha"
);
Beta
beta
=
(
Beta
)
factory
.
getBean
(
"beta"
);
Gamma
gamma
=
(
Gamma
)
factory
.
getBean
(
"gamma"
);
...
...
@@ -48,9 +56,14 @@ public class FactoryBeanTests extends TestCase {
assertEquals
(
"yourName"
,
beta
.
getName
());
}
@Test
public
void
testFactoryBeansWithIntermediateFactoryBeanAutowiringFailure
()
throws
Exception
{
ClassPathXmlApplicationContext
factory
=
new
ClassPathXmlApplicationContext
(
"factoryBeansWithAutowiring.xml"
,
getClass
());
XmlBeanFactory
factory
=
new
XmlBeanFactory
(
new
ClassPathResource
(
"factoryBeansWithAutowiring.xml"
,
getClass
()));
BeanFactoryPostProcessor
ppc
=
(
BeanFactoryPostProcessor
)
factory
.
getBean
(
"propertyPlaceholderConfigurer"
);
ppc
.
postProcessBeanFactory
(
factory
);
Beta
beta
=
(
Beta
)
factory
.
getBean
(
"beta"
);
Alpha
alpha
=
(
Alpha
)
factory
.
getBean
(
"alpha"
);
Gamma
gamma
=
(
Gamma
)
factory
.
getBean
(
"gamma"
);
...
...
@@ -59,13 +72,13 @@ public class FactoryBeanTests extends TestCase {
}
public
static
class
NullReturningFactoryBean
implements
FactoryBean
{
public
static
class
NullReturningFactoryBean
implements
FactoryBean
<
Object
>
{
public
Object
getObject
()
{
return
null
;
}
public
Class
getObjectType
()
{
public
Class
<?>
getObjectType
()
{
return
null
;
}
...
...
@@ -125,7 +138,7 @@ public class FactoryBeanTests extends TestCase {
}
public
static
class
BetaFactoryBean
implements
FactoryBean
{
public
static
class
BetaFactoryBean
implements
FactoryBean
<
Object
>
{
private
Beta
beta
;
...
...
@@ -137,7 +150,7 @@ public class FactoryBeanTests extends TestCase {
return
this
.
beta
;
}
public
Class
getObjectType
()
{
public
Class
<?>
getObjectType
()
{
return
null
;
}
...
...
org.springframework.
testsuite
/src/test/java/org/springframework/beans/factory/KnowsIfInstantiated.java
→
org.springframework.
beans
/src/test/java/org/springframework/beans/factory/KnowsIfInstantiated.java
浏览文件 @
6cb71bbb
文件已移动
org.springframework.
testsuite
/src/test/java/org/springframework/beans/factory/dependentBeans.xml
→
org.springframework.
beans
/src/test/java/org/springframework/beans/factory/dependentBeans.xml
浏览文件 @
6cb71bbb
文件已移动
org.springframework.
testsuite
/src/test/java/org/springframework/beans/factory/factoryBeanReturnsNull.xml
→
org.springframework.
beans
/src/test/java/org/springframework/beans/factory/factoryBeanReturnsNull.xml
浏览文件 @
6cb71bbb
文件已移动
org.springframework.
testsuite
/src/test/java/org/springframework/beans/factory/factoryBeansWithAutowiring.xml
→
org.springframework.
beans
/src/test/java/org/springframework/beans/factory/factoryBeansWithAutowiring.xml
浏览文件 @
6cb71bbb
...
...
@@ -3,24 +3,11 @@
<beans
default-lazy-init=
"true"
>
<bean
id=
"abstractBeta"
class=
"org.springframework.aop.framework.ProxyFactoryBean"
abstract=
"true"
/>
<bean
name=
"beta"
parent=
"abstractBeta"
>
<property
name=
"target"
>
<bean
class=
"org.springframework.beans.factory.FactoryBeanTests$Beta"
autowire=
"byType"
>
<bean
name=
"beta"
class=
"org.springframework.beans.factory.FactoryBeanTests$Beta"
autowire=
"byType"
>
<property
name=
"name"
value=
"${myName}"
/>
</bean>
</property>
<property
name=
"proxyTargetClass"
value=
"true"
/>
</bean>
<bean
id=
"alpha"
class=
"org.springframework.aop.framework.ProxyFactoryBean"
>
<property
name=
"target"
>
<bean
class=
"org.springframework.beans.factory.FactoryBeanTests$Alpha"
autowire=
"byType"
/>
</property>
<property
name=
"proxyTargetClass"
value=
"true"
/>
</bean>
<bean
id=
"alpha"
class=
"org.springframework.beans.factory.FactoryBeanTests$Alpha"
autowire=
"byType"
/>
<bean
id=
"gamma"
class=
"org.springframework.beans.factory.FactoryBeanTests$Gamma"
/>
...
...
@@ -30,7 +17,7 @@
<bean
id=
"gammaFactory"
factory-bean=
"betaFactory"
factory-method=
"getGamma"
/>
<bean
class=
"org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"
>
<bean
id=
"propertyPlaceholderConfigurer"
class=
"org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"
>
<property
name=
"properties"
>
<props>
<prop
key=
"myName"
>
yourName
</prop>
...
...
org.springframework.
testsuite
/src/test/java/org/springframework/beans/factory/leaf.xml
→
org.springframework.
beans
/src/test/java/org/springframework/beans/factory/leaf.xml
浏览文件 @
6cb71bbb
文件已移动
org.springframework.
testsuite
/src/test/java/org/springframework/beans/factory/middle.xml
→
org.springframework.
beans
/src/test/java/org/springframework/beans/factory/middle.xml
浏览文件 @
6cb71bbb
文件已移动
org.springframework.
testsuite
/src/test/java/org/springframework/beans/factory/root.xml
→
org.springframework.
beans
/src/test/java/org/springframework/beans/factory/root.xml
浏览文件 @
6cb71bbb
...
...
@@ -6,7 +6,7 @@
<!--
Just included for the count: not to mean anything in particular
-->
<bean
id=
"something"
class=
"org.springframework.
aop.support.DefaultPointcutAdvisor
"
/>
<bean
id=
"something"
class=
"org.springframework.
beans.GenericIntegerBean
"
/>
<bean
id=
"indexedBean"
class=
"org.springframework.beans.IndexedTestBean"
/>
...
...
org.springframework.beans/src/test/java/org/springframework/beans/factory/xml/ConstructorDependenciesBean.java
0 → 100644
浏览文件 @
6cb71bbb
/*
* 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.xml
;
import
java.io.Serializable
;
import
org.springframework.beans.IndexedTestBean
;
import
org.springframework.beans.TestBean
;
/**
* Simple bean used to check constructor dependency checking.
*
* @author Juergen Hoeller
* @since 09.11.2003
*/
public
class
ConstructorDependenciesBean
implements
Serializable
{
private
int
age
;
private
String
name
;
private
TestBean
spouse1
;
private
TestBean
spouse2
;
private
IndexedTestBean
other
;
public
ConstructorDependenciesBean
(
int
age
)
{
this
.
age
=
age
;
}
public
ConstructorDependenciesBean
(
String
name
)
{
this
.
name
=
name
;
}
public
ConstructorDependenciesBean
(
TestBean
spouse1
)
{
this
.
spouse1
=
spouse1
;
}
public
ConstructorDependenciesBean
(
TestBean
spouse1
,
TestBean
spouse2
)
{
this
.
spouse1
=
spouse1
;
this
.
spouse2
=
spouse2
;
}
public
ConstructorDependenciesBean
(
TestBean
spouse1
,
TestBean
spouse2
,
int
age
)
{
this
.
spouse1
=
spouse1
;
this
.
spouse2
=
spouse2
;
this
.
age
=
age
;
}
public
ConstructorDependenciesBean
(
TestBean
spouse1
,
TestBean
spouse2
,
IndexedTestBean
other
)
{
this
.
spouse1
=
spouse1
;
this
.
spouse2
=
spouse2
;
this
.
other
=
other
;
}
public
int
getAge
()
{
return
age
;
}
public
String
getName
()
{
return
name
;
}
public
TestBean
getSpouse1
()
{
return
spouse1
;
}
public
TestBean
getSpouse2
()
{
return
spouse2
;
}
public
IndexedTestBean
getOther
()
{
return
other
;
}
public
void
setAge
(
int
age
)
{
this
.
age
=
age
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
}
org.springframework.
testsuite/src/test/java/org/springframework/beans/factory/CountingFactory
.java
→
org.springframework.
beans/src/test/java/org/springframework/beans/factory/xml/DependenciesBean
.java
浏览文件 @
6cb71bbb
/*
* Copyright 2002-200
6
the original author or authors.
*
* Copyright 2002-200
5
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.
...
...
@@ -14,51 +14,59 @@
* limitations under the License.
*/
package
org.springframework.beans.factory
;
package
org.springframework.beans.factory
.xml
;
import
org.springframework.beans.TestBean
;
import
org.springframework.beans.factory.BeanFactory
;
import
org.springframework.beans.factory.BeanFactoryAware
;
/**
* @author Juergen Hoeller
* Simple bean used to test dependency checking.
*
* @author Rod Johnson
* @since 04.09.2003
*/
public
class
CountingFactory
implements
FactoryBean
{
public
class
DependenciesBean
implements
BeanFactoryAware
{
private
int
age
;
private
static
int
factoryBeanInstanceCount
=
0
;
private
String
name
;
private
TestBean
spouse
;
private
BeanFactory
beanFactory
;
/**
* Clear static state.
*/
public
static
void
reset
()
{
factoryBeanInstanceCount
=
0
;
}
public
static
int
getFactoryBeanInstanceCount
(
)
{
return
factoryBeanInstanceCount
;
public
void
setAge
(
int
age
)
{
this
.
age
=
age
;
}
public
int
getAge
()
{
return
age
;
}
public
CountingFactory
(
)
{
factoryBeanInstanceCount
++
;
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
void
setTestBean
(
TestBean
tb
)
{
if
(
tb
.
getSpouse
()
==
null
)
{
throw
new
IllegalStateException
(
"TestBean needs to have spouse"
);
}
public
String
getName
()
{
return
name
;
}
public
void
setSpouse
(
TestBean
spouse
)
{
this
.
spouse
=
spouse
;
}
public
Object
getObject
()
{
return
"myString"
;
public
TestBean
getSpouse
()
{
return
spouse
;
}
public
Class
getObjectType
(
)
{
return
String
.
class
;
public
void
setBeanFactory
(
BeanFactory
beanFactory
)
{
this
.
beanFactory
=
beanFactory
;
}
public
boolean
isSingleton
()
{
return
true
;
public
BeanFactory
getBeanFactory
()
{
return
beanFactory
;
}
}
org.springframework.beans/src/test/java/org/springframework/beans/factory/xml/SideEffectBean.java
0 → 100644
浏览文件 @
6cb71bbb
package
org.springframework.beans.factory.xml
;
/**
* 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
;
}
}
\ No newline at end of file
org.springframework.testsuite/src/test/java/org/springframework/beans/factory/PackageLevelVisibleBean.java
已删除
100644 → 0
浏览文件 @
8977ad40
/*
* 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
;
/**
* Used in the tests for the FieldRetrievingFactoryBean class
* (c.f. FieldRetrievingFactoryBeanTests)
*
* @author Rick Evans
*/
class
PackageLevelVisibleBean
{
public
static
final
String
CONSTANT
=
"Wuby"
;
}
org.springframework.testsuite/src/test/java/org/springframework/beans/factory/xml/autowire-with-exclusion.xml
已删除
100644 → 0
浏览文件 @
8977ad40
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd">
<beans>
<bean
id=
"rob"
class=
"org.springframework.beans.TestBean"
autowire=
"byType"
/>
<bean
id=
"sally"
class=
"org.springframework.beans.TestBean"
/>
<bean
id=
"props1"
class=
"org.springframework.beans.factory.config.PropertiesFactoryBean"
>
<property
name=
"properties"
>
<value>
name=props1
</value>
</property>
</bean>
<bean
id=
"props2"
class=
"org.springframework.beans.factory.config.PropertiesFactoryBean"
autowire-candidate=
"false"
>
<property
name=
"properties"
>
<value>
name=props2
</value>
</property>
</bean>
<bean
class=
"org.springframework.beans.factory.CountingFactory"
>
<property
name=
"testBean"
ref=
"rob"
/>
</bean>
</beans>
org.springframework.testsuite/src/test/java/org/springframework/beans/factory/xml/autowire-with-inclusion.xml
已删除
100644 → 0
浏览文件 @
8977ad40
<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns=
"http://www.springframework.org/schema/beans"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"
default-autowire-candidates=
""
>
<bean
id=
"rob"
class=
"org.springframework.beans.TestBean"
autowire=
"byType"
/>
<bean
id=
"sally"
class=
"org.springframework.beans.TestBean"
autowire-candidate=
"true"
/>
<bean
id=
"props1"
class=
"org.springframework.beans.factory.config.PropertiesFactoryBean"
autowire-candidate=
"true"
>
<property
name=
"properties"
>
<value>
name=props1
</value>
</property>
</bean>
<bean
id=
"props2"
class=
"org.springframework.beans.factory.config.PropertiesFactoryBean"
>
<property
name=
"properties"
>
<value>
name=props2
</value>
</property>
</bean>
<bean
class=
"org.springframework.beans.factory.CountingFactory"
>
<property
name=
"testBean"
ref=
"rob"
/>
</bean>
</beans>
org.springframework.testsuite/src/test/java/org/springframework/beans/factory/xml/autowire-with-selective-inclusion.xml
已删除
100644 → 0
浏览文件 @
8977ad40
<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns=
"http://www.springframework.org/schema/beans"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"
default-autowire-candidates=
"props*,*ly"
>
<bean
id=
"rob"
class=
"org.springframework.beans.TestBean"
autowire=
"byType"
/>
<bean
id=
"sally"
class=
"org.springframework.beans.TestBean"
/>
<bean
id=
"props1"
class=
"org.springframework.beans.factory.config.PropertiesFactoryBean"
>
<property
name=
"properties"
>
<value>
name=props1
</value>
</property>
</bean>
<bean
id=
"props2"
class=
"org.springframework.beans.factory.config.PropertiesFactoryBean"
autowire-candidate=
"false"
>
<property
name=
"properties"
>
<value>
name=props2
</value>
</property>
</bean>
<bean
id=
"someProps"
class=
"org.springframework.beans.factory.config.PropertiesFactoryBean"
>
<property
name=
"properties"
>
<value>
name=someProps
</value>
</property>
</bean>
<bean
class=
"org.springframework.beans.factory.CountingFactory"
>
<property
name=
"testBean"
ref=
"rob"
/>
</bean>
</beans>
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录