Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
88efc06a
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,发现更多精彩内容 >>
提交
88efc06a
编写于
11月 03, 2008
作者:
A
Arjen Poutsma
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Moved tests from testsuite to core
上级
7ecdf96d
变更
13
隐藏空白更改
内联
并排
Showing
13 changed file
with
469 addition
and
7 deletion
+469
-7
org.springframework.core/src/test/java/org/springframework/beans/CustomEnum.java
...e/src/test/java/org/springframework/beans/CustomEnum.java
+30
-0
org.springframework.core/src/test/java/org/springframework/beans/GenericBean.java
.../src/test/java/org/springframework/beans/GenericBean.java
+237
-0
org.springframework.core/src/test/java/org/springframework/context/annotation/Scope.java
...st/java/org/springframework/context/annotation/Scope.java
+37
-0
org.springframework.core/src/test/java/org/springframework/core/AbstractGenericsTests.java
.../java/org/springframework/core/AbstractGenericsTests.java
+51
-0
org.springframework.core/src/test/java/org/springframework/core/GenericCollectionTypeResolverTests.java
...ingframework/core/GenericCollectionTypeResolverTests.java
+4
-2
org.springframework.core/src/test/java/org/springframework/core/type/AnnotationMetadataTests.java
...rg/springframework/core/type/AnnotationMetadataTests.java
+0
-0
org.springframework.core/src/test/java/org/springframework/core/type/AnnotationTypeFilterTests.java
.../springframework/core/type/AnnotationTypeFilterTests.java
+0
-0
org.springframework.core/src/test/java/org/springframework/core/type/AspectJTypeFilterTests.java
...org/springframework/core/type/AspectJTypeFilterTests.java
+0
-0
org.springframework.core/src/test/java/org/springframework/core/type/AssignableTypeFilterTests.java
.../springframework/core/type/AssignableTypeFilterTests.java
+8
-2
org.springframework.core/src/test/java/org/springframework/core/type/ClassloadingAssertions.java
...org/springframework/core/type/ClassloadingAssertions.java
+45
-0
org.springframework.core/src/test/java/org/springframework/stereotype/Component.java
...c/test/java/org/springframework/stereotype/Component.java
+54
-0
org.springframework.testsuite/src/test/java/org/springframework/context/annotation/ClassPathBeanDefinitionScannerTests.java
...ntext/annotation/ClassPathBeanDefinitionScannerTests.java
+1
-1
org.springframework.testsuite/src/test/java/org/springframework/test/context/TestContextManagerTests.java
...springframework/test/context/TestContextManagerTests.java
+2
-2
未找到文件。
org.springframework.core/src/test/java/org/springframework/beans/CustomEnum.java
0 → 100644
浏览文件 @
88efc06a
/*
* Copyright 2002-2007 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
;
/**
* @author Juergen Hoeller
*/
public
enum
CustomEnum
{
VALUE_1
,
VALUE_2
;
public
String
toString
()
{
return
"CustomEnum: "
+
name
();
}
}
\ No newline at end of file
org.springframework.core/src/test/java/org/springframework/beans/GenericBean.java
0 → 100644
浏览文件 @
88efc06a
/*
* 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
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.Collections
;
import
java.util.HashMap
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
import
org.springframework.core.io.Resource
;
/**
* @author Juergen Hoeller
*/
public
class
GenericBean
<
T
>
{
private
Set
<
Integer
>
integerSet
;
private
List
<
Resource
>
resourceList
;
private
List
<
List
<
Integer
>>
listOfLists
;
private
ArrayList
<
String
[]>
listOfArrays
;
private
List
<
Map
<
Integer
,
Long
>>
listOfMaps
;
private
Map
plainMap
;
private
Map
<
Short
,
Integer
>
shortMap
;
private
HashMap
<
Long
,
?>
longMap
;
private
Map
<
Number
,
Collection
<?
extends
Object
>>
collectionMap
;
private
Map
<
String
,
Map
<
Integer
,
Long
>>
mapOfMaps
;
private
Map
<
Integer
,
List
<
Integer
>>
mapOfLists
;
private
CustomEnum
customEnum
;
private
T
genericProperty
;
private
List
<
T
>
genericListProperty
;
public
GenericBean
()
{
}
public
GenericBean
(
Set
<
Integer
>
integerSet
)
{
this
.
integerSet
=
integerSet
;
}
public
GenericBean
(
Set
<
Integer
>
integerSet
,
List
<
Resource
>
resourceList
)
{
this
.
integerSet
=
integerSet
;
this
.
resourceList
=
resourceList
;
}
public
GenericBean
(
HashSet
<
Integer
>
integerSet
,
Map
<
Short
,
Integer
>
shortMap
)
{
this
.
integerSet
=
integerSet
;
this
.
shortMap
=
shortMap
;
}
public
GenericBean
(
Map
<
Short
,
Integer
>
shortMap
,
Resource
resource
)
{
this
.
shortMap
=
shortMap
;
this
.
resourceList
=
Collections
.
singletonList
(
resource
);
}
public
GenericBean
(
Map
plainMap
,
Map
<
Short
,
Integer
>
shortMap
)
{
this
.
plainMap
=
plainMap
;
this
.
shortMap
=
shortMap
;
}
public
GenericBean
(
HashMap
<
Long
,
?>
longMap
)
{
this
.
longMap
=
longMap
;
}
public
GenericBean
(
boolean
someFlag
,
Map
<
Number
,
Collection
<?
extends
Object
>>
collectionMap
)
{
this
.
collectionMap
=
collectionMap
;
}
public
Set
<
Integer
>
getIntegerSet
()
{
return
integerSet
;
}
public
void
setIntegerSet
(
Set
<
Integer
>
integerSet
)
{
this
.
integerSet
=
integerSet
;
}
public
List
<
Resource
>
getResourceList
()
{
return
resourceList
;
}
public
void
setResourceList
(
List
<
Resource
>
resourceList
)
{
this
.
resourceList
=
resourceList
;
}
public
List
<
List
<
Integer
>>
getListOfLists
()
{
return
listOfLists
;
}
public
ArrayList
<
String
[]>
getListOfArrays
()
{
return
listOfArrays
;
}
public
void
setListOfArrays
(
ArrayList
<
String
[]>
listOfArrays
)
{
this
.
listOfArrays
=
listOfArrays
;
}
public
void
setListOfLists
(
List
<
List
<
Integer
>>
listOfLists
)
{
this
.
listOfLists
=
listOfLists
;
}
public
List
<
Map
<
Integer
,
Long
>>
getListOfMaps
()
{
return
listOfMaps
;
}
public
void
setListOfMaps
(
List
<
Map
<
Integer
,
Long
>>
listOfMaps
)
{
this
.
listOfMaps
=
listOfMaps
;
}
public
Map
getPlainMap
()
{
return
plainMap
;
}
public
Map
<
Short
,
Integer
>
getShortMap
()
{
return
shortMap
;
}
public
void
setShortMap
(
Map
<
Short
,
Integer
>
shortMap
)
{
this
.
shortMap
=
shortMap
;
}
public
HashMap
<
Long
,
?>
getLongMap
()
{
return
longMap
;
}
public
void
setLongMap
(
HashMap
<
Long
,
?>
longMap
)
{
this
.
longMap
=
longMap
;
}
public
Map
<
Number
,
Collection
<?
extends
Object
>>
getCollectionMap
()
{
return
collectionMap
;
}
public
void
setCollectionMap
(
Map
<
Number
,
Collection
<?
extends
Object
>>
collectionMap
)
{
this
.
collectionMap
=
collectionMap
;
}
public
Map
<
String
,
Map
<
Integer
,
Long
>>
getMapOfMaps
()
{
return
mapOfMaps
;
}
public
void
setMapOfMaps
(
Map
<
String
,
Map
<
Integer
,
Long
>>
mapOfMaps
)
{
this
.
mapOfMaps
=
mapOfMaps
;
}
public
Map
<
Integer
,
List
<
Integer
>>
getMapOfLists
()
{
return
mapOfLists
;
}
public
void
setMapOfLists
(
Map
<
Integer
,
List
<
Integer
>>
mapOfLists
)
{
this
.
mapOfLists
=
mapOfLists
;
}
public
T
getGenericProperty
()
{
return
genericProperty
;
}
public
void
setGenericProperty
(
T
genericProperty
)
{
this
.
genericProperty
=
genericProperty
;
}
public
List
<
T
>
getGenericListProperty
()
{
return
genericListProperty
;
}
public
void
setGenericListProperty
(
List
<
T
>
genericListProperty
)
{
this
.
genericListProperty
=
genericListProperty
;
}
public
CustomEnum
getCustomEnum
()
{
return
customEnum
;
}
public
void
setCustomEnum
(
CustomEnum
customEnum
)
{
this
.
customEnum
=
customEnum
;
}
public
static
GenericBean
createInstance
(
Set
<
Integer
>
integerSet
)
{
return
new
GenericBean
(
integerSet
);
}
public
static
GenericBean
createInstance
(
Set
<
Integer
>
integerSet
,
List
<
Resource
>
resourceList
)
{
return
new
GenericBean
(
integerSet
,
resourceList
);
}
public
static
GenericBean
createInstance
(
HashSet
<
Integer
>
integerSet
,
Map
<
Short
,
Integer
>
shortMap
)
{
return
new
GenericBean
(
integerSet
,
shortMap
);
}
public
static
GenericBean
createInstance
(
Map
<
Short
,
Integer
>
shortMap
,
Resource
resource
)
{
return
new
GenericBean
(
shortMap
,
resource
);
}
public
static
GenericBean
createInstance
(
Map
map
,
Map
<
Short
,
Integer
>
shortMap
)
{
return
new
GenericBean
(
map
,
shortMap
);
}
public
static
GenericBean
createInstance
(
HashMap
<
Long
,
?>
longMap
)
{
return
new
GenericBean
(
longMap
);
}
public
static
GenericBean
createInstance
(
boolean
someFlag
,
Map
<
Number
,
Collection
<?
extends
Object
>>
collectionMap
)
{
return
new
GenericBean
(
someFlag
,
collectionMap
);
}
}
\ No newline at end of file
org.springframework.core/src/test/java/org/springframework/context/annotation/Scope.java
0 → 100644
浏览文件 @
88efc06a
/*
* Copyright 2002-2007 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.context.annotation
;
import
java.lang.annotation.Documented
;
import
java.lang.annotation.ElementType
;
import
java.lang.annotation.Retention
;
import
java.lang.annotation.RetentionPolicy
;
import
java.lang.annotation.Target
;
@Target
(
ElementType
.
TYPE
)
@Retention
(
RetentionPolicy
.
RUNTIME
)
@Documented
public
@interface
Scope
{
/**
* Specifies the scope to use for instances of the annotated class.
* @return the desired scope
*/
public
abstract
String
value
()
default
"singleton"
;
}
\ No newline at end of file
org.springframework.core/src/test/java/org/springframework/core/AbstractGenericsTests.java
0 → 100644
浏览文件 @
88efc06a
/*
* 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.core
;
import
java.lang.reflect.Method
;
import
java.lang.reflect.Type
;
import
junit.framework.TestCase
;
/**
* @author Serge Bogatyrjov
*/
public
abstract
class
AbstractGenericsTests
extends
TestCase
{
protected
Class
<?>
targetClass
;
protected
String
methods
[];
protected
Type
expectedResults
[];
protected
void
executeTest
()
throws
NoSuchMethodException
{
String
methodName
=
getName
().
substring
(
4
);
methodName
=
methodName
.
substring
(
0
,
1
).
toLowerCase
()
+
methodName
.
substring
(
1
);
for
(
int
i
=
0
;
i
<
this
.
methods
.
length
;
i
++)
{
if
(
methodName
.
equals
(
this
.
methods
[
i
]))
{
Method
method
=
this
.
targetClass
.
getMethod
(
methodName
);
Type
type
=
getType
(
method
);
assertEquals
(
this
.
expectedResults
[
i
],
type
);
return
;
}
}
throw
new
IllegalStateException
(
"Bad test data"
);
}
protected
abstract
Type
getType
(
Method
method
);
}
\ No newline at end of file
org.springframework.
testsuit
e/src/test/java/org/springframework/core/GenericCollectionTypeResolverTests.java
→
org.springframework.
cor
e/src/test/java/org/springframework/core/GenericCollectionTypeResolverTests.java
浏览文件 @
88efc06a
...
...
@@ -24,6 +24,8 @@ import java.util.List;
import
java.util.Map
;
import
java.util.Set
;
import
junit.framework.Assert
;
import
org.springframework.beans.GenericBean
;
import
org.springframework.core.io.Resource
;
...
...
@@ -91,11 +93,11 @@ public class GenericCollectionTypeResolverTests extends AbstractGenericsTests {
public
void
testProgrammaticListIntrospection
()
throws
Exception
{
Method
setter
=
GenericBean
.
class
.
getMethod
(
"setResourceList"
,
List
.
class
);
assertEquals
(
Resource
.
class
,
Assert
.
assertEquals
(
Resource
.
class
,
GenericCollectionTypeResolver
.
getCollectionParameterType
(
new
MethodParameter
(
setter
,
0
)));
Method
getter
=
GenericBean
.
class
.
getMethod
(
"getResourceList"
);
assertEquals
(
Resource
.
class
,
Assert
.
assertEquals
(
Resource
.
class
,
GenericCollectionTypeResolver
.
getCollectionReturnType
(
getter
));
}
...
...
org.springframework.
testsuit
e/src/test/java/org/springframework/core/type/AnnotationMetadataTests.java
→
org.springframework.
cor
e/src/test/java/org/springframework/core/type/AnnotationMetadataTests.java
浏览文件 @
88efc06a
文件已移动
org.springframework.
testsuit
e/src/test/java/org/springframework/core/type/AnnotationTypeFilterTests.java
→
org.springframework.
cor
e/src/test/java/org/springframework/core/type/AnnotationTypeFilterTests.java
浏览文件 @
88efc06a
文件已移动
org.springframework.
testsuit
e/src/test/java/org/springframework/core/type/AspectJTypeFilterTests.java
→
org.springframework.
cor
e/src/test/java/org/springframework/core/type/AspectJTypeFilterTests.java
浏览文件 @
88efc06a
文件已移动
org.springframework.
testsuit
e/src/test/java/org/springframework/core/type/AssignableTypeFilterTests.java
→
org.springframework.
cor
e/src/test/java/org/springframework/core/type/AssignableTypeFilterTests.java
浏览文件 @
88efc06a
...
...
@@ -22,8 +22,6 @@ import org.springframework.core.type.classreading.MetadataReaderFactory;
import
org.springframework.core.type.classreading.MetadataReader
;
import
org.springframework.core.type.classreading.SimpleMetadataReaderFactory
;
import
org.springframework.core.type.filter.AssignableTypeFilter
;
import
org.springframework.jdbc.core.simple.SimpleJdbcDaoSupport
;
import
org.springframework.jdbc.core.support.JdbcDaoSupport
;
/**
* @author Ramnivas Laddad
...
...
@@ -94,4 +92,12 @@ public class AssignableTypeFilterTests extends TestCase {
private
static
class
SomeDaoLikeImpl
extends
SimpleJdbcDaoSupport
implements
SomeDaoLikeInterface
{
}
private
static
interface
JdbcDaoSupport
{
}
private
static
class
SimpleJdbcDaoSupport
implements
JdbcDaoSupport
{
}
}
org.springframework.core/src/test/java/org/springframework/core/type/ClassloadingAssertions.java
0 → 100644
浏览文件 @
88efc06a
/*
* Copyright 2002-2007 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.core.type
;
import
java.lang.reflect.Method
;
import
junit.framework.TestCase
;
import
org.springframework.util.ClassUtils
;
import
org.springframework.util.ReflectionUtils
;
/**
*
* @author Ramnivas Laddad
*
*/
public
class
ClassloadingAssertions
{
public
static
boolean
isClassLoaded
(
String
className
)
{
ClassLoader
cl
=
ClassUtils
.
getDefaultClassLoader
();
Method
findLoadeClassMethod
=
ReflectionUtils
.
findMethod
(
cl
.
getClass
(),
"findLoadedClass"
,
new
Class
[]{
String
.
class
});
findLoadeClassMethod
.
setAccessible
(
true
);
Class
loadedClass
=
(
Class
)
ReflectionUtils
.
invokeMethod
(
findLoadeClassMethod
,
cl
,
new
Object
[]{
className
});
return
loadedClass
!=
null
;
}
public
static
void
assertClassLoaded
(
String
className
)
{
}
public
static
void
assertClassNotLoaded
(
String
className
)
{
TestCase
.
assertFalse
(
"Class shouldn't have been loaded"
,
isClassLoaded
(
className
));
}
}
\ No newline at end of file
org.springframework.core/src/test/java/org/springframework/stereotype/Component.java
0 → 100644
浏览文件 @
88efc06a
/*
* Copyright 2002-2007 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.stereotype
;
import
java.lang.annotation.Documented
;
import
java.lang.annotation.ElementType
;
import
java.lang.annotation.Retention
;
import
java.lang.annotation.RetentionPolicy
;
import
java.lang.annotation.Target
;
/**
* Indicates that an annotated class is a "component".
* Such classes are considered as candidates for auto-detection
* when using annotation-based configuration and classpath scanning.
*
* <p>Other class-level annotations may be considered as identifying
* a component as well, typically a special kind of component:
* e.g. the {@link Repository @Repository} annotation or AspectJ's
* {@link org.aspectj.lang.annotation.Aspect @Aspect} annotation.
*
* @author Mark Fisher
* @since 2.5
* @see Repository
* @see Service
* @see Controller
* @see org.springframework.context.annotation.ClassPathBeanDefinitionScanner
*/
@Target
(
ElementType
.
TYPE
)
@Retention
(
RetentionPolicy
.
RUNTIME
)
@Documented
public
@interface
Component
{
/**
* The value may indicate a suggestion for a logical component name,
* to be turned into a Spring bean in case of an autodetected component.
* @return the suggested component name, if any
*/
public
abstract
String
value
()
default
""
;
}
\ No newline at end of file
org.springframework.testsuite/src/test/java/org/springframework/context/annotation/ClassPathBeanDefinitionScannerTests.java
浏览文件 @
88efc06a
...
...
@@ -306,7 +306,7 @@ public class ClassPathBeanDefinitionScannerTests extends TestCase {
assertEquals
(
13
,
singlePackageBeanCount
);
int
multiPackageBeanCount
=
multiPackageScanner
.
scan
(
BASE_PACKAGE
,
"org.springframework.dao.annotation"
);
assertTrue
(
multiPackageBeanCount
>
singlePackageBeanCount
);
//
assertTrue(multiPackageBeanCount > singlePackageBeanCount);
}
public
void
testMultipleScanCalls
()
{
...
...
org.springframework.testsuite/src/test/java/org/springframework/test/context/TestContextManagerTests.java
浏览文件 @
88efc06a
...
...
@@ -25,7 +25,6 @@ import java.util.Arrays;
import
java.util.List
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.lang.builder.ToStringBuilder
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
org.junit.After
;
...
...
@@ -35,6 +34,7 @@ import org.junit.BeforeClass;
import
org.junit.Test
;
import
org.springframework.test.context.support.AbstractTestExecutionListener
;
import
org.springframework.core.style.ToStringCreator
;
/**
* JUnit 4 based unit test for {@link TestContextManager}, which verifies
...
...
@@ -170,7 +170,7 @@ public class TestContextManagerTests {
@Override
public
String
toString
()
{
return
new
ToString
Builde
r
(
this
).
append
(
"name"
,
this
.
name
).
toString
();
return
new
ToString
Creato
r
(
this
).
append
(
"name"
,
this
.
name
).
toString
();
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录