Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
97d15254
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,体验更适合开发者的 AI 搜索 >>
提交
97d15254
编写于
6月 09, 2013
作者:
S
Sam Brannen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Reformatted GenericTypeResolverTests
上级
b305f000
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
56 addition
and
33 deletion
+56
-33
spring-core/src/test/java/org/springframework/core/GenericTypeResolverTests.java
...va/org/springframework/core/GenericTypeResolverTests.java
+56
-33
未找到文件。
spring-core/src/test/java/org/springframework/core/GenericTypeResolverTests.java
浏览文件 @
97d15254
/*
* Copyright 2002-201
2
the original author or authors.
* Copyright 2002-201
3
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.
...
...
@@ -65,10 +65,13 @@ public class GenericTypeResolverTests {
@Test
public
void
methodReturnTypes
()
{
assertEquals
(
Integer
.
class
,
resolveReturnTypeArgument
(
findMethod
(
MyTypeWithMethods
.
class
,
"integer"
),
MyInterfaceType
.
class
));
assertEquals
(
String
.
class
,
resolveReturnTypeArgument
(
findMethod
(
MyTypeWithMethods
.
class
,
"string"
),
MyInterfaceType
.
class
));
assertEquals
(
Integer
.
class
,
resolveReturnTypeArgument
(
findMethod
(
MyTypeWithMethods
.
class
,
"integer"
),
MyInterfaceType
.
class
));
assertEquals
(
String
.
class
,
resolveReturnTypeArgument
(
findMethod
(
MyTypeWithMethods
.
class
,
"string"
),
MyInterfaceType
.
class
));
assertEquals
(
null
,
resolveReturnTypeArgument
(
findMethod
(
MyTypeWithMethods
.
class
,
"raw"
),
MyInterfaceType
.
class
));
assertEquals
(
null
,
resolveReturnTypeArgument
(
findMethod
(
MyTypeWithMethods
.
class
,
"object"
),
MyInterfaceType
.
class
));
assertEquals
(
null
,
resolveReturnTypeArgument
(
findMethod
(
MyTypeWithMethods
.
class
,
"object"
),
MyInterfaceType
.
class
));
}
/**
...
...
@@ -135,20 +138,22 @@ public class GenericTypeResolverTests {
*/
@Test
public
void
testResolveType
()
{
Method
intMessageMethod
=
findMethod
(
MyTypeWithMethods
.
class
,
"readIntegerInputMessage"
,
MyInterfaceType
.
class
);
MethodParameter
intMessageMethodParam
=
new
MethodParameter
(
intMessageMethod
,
0
);
assertEquals
(
MyInterfaceType
.
class
,
resolveType
(
intMessageMethodParam
.
getGenericParameterType
(),
new
HashMap
<
TypeVariable
,
Type
>()));
Method
intArrMessageMethod
=
findMethod
(
MyTypeWithMethods
.
class
,
"readIntegerArrayInputMessage"
,
MyInterfaceType
[].
class
);
MethodParameter
intArrMessageMethodParam
=
new
MethodParameter
(
intArrMessageMethod
,
0
);
assertEquals
(
MyInterfaceType
[].
class
,
resolveType
(
intArrMessageMethodParam
.
getGenericParameterType
(),
new
HashMap
<
TypeVariable
,
Type
>()));
Method
genericArrMessageMethod
=
findMethod
(
MySimpleTypeWithMethods
.
class
,
"readGenericArrayInputMessage"
,
Object
[].
class
);
MethodParameter
genericArrMessageMethodParam
=
new
MethodParameter
(
genericArrMessageMethod
,
0
);
Map
<
TypeVariable
,
Type
>
varMap
=
getTypeVariableMap
(
MySimpleTypeWithMethods
.
class
);
assertEquals
(
Integer
[].
class
,
resolveType
(
genericArrMessageMethodParam
.
getGenericParameterType
(),
varMap
));
Method
intMessageMethod
=
findMethod
(
MyTypeWithMethods
.
class
,
"readIntegerInputMessage"
,
MyInterfaceType
.
class
);
MethodParameter
intMessageMethodParam
=
new
MethodParameter
(
intMessageMethod
,
0
);
assertEquals
(
MyInterfaceType
.
class
,
resolveType
(
intMessageMethodParam
.
getGenericParameterType
(),
new
HashMap
<
TypeVariable
,
Type
>()));
Method
intArrMessageMethod
=
findMethod
(
MyTypeWithMethods
.
class
,
"readIntegerArrayInputMessage"
,
MyInterfaceType
[].
class
);
MethodParameter
intArrMessageMethodParam
=
new
MethodParameter
(
intArrMessageMethod
,
0
);
assertEquals
(
MyInterfaceType
[].
class
,
resolveType
(
intArrMessageMethodParam
.
getGenericParameterType
(),
new
HashMap
<
TypeVariable
,
Type
>()));
Method
genericArrMessageMethod
=
findMethod
(
MySimpleTypeWithMethods
.
class
,
"readGenericArrayInputMessage"
,
Object
[].
class
);
MethodParameter
genericArrMessageMethodParam
=
new
MethodParameter
(
genericArrMessageMethod
,
0
);
Map
<
TypeVariable
,
Type
>
varMap
=
getTypeVariableMap
(
MySimpleTypeWithMethods
.
class
);
assertEquals
(
Integer
[].
class
,
resolveType
(
genericArrMessageMethodParam
.
getGenericParameterType
(),
varMap
));
}
...
...
@@ -171,26 +176,44 @@ public class GenericTypeResolverTests {
}
public
static
class
MyTypeWithMethods
<
T
>
{
public
MyInterfaceType
<
Integer
>
integer
()
{
return
null
;
}
public
MySimpleInterfaceType
string
()
{
return
null
;
}
public
Object
object
()
{
return
null
;
}
public
MyInterfaceType
<
Integer
>
integer
()
{
return
null
;
}
public
MySimpleInterfaceType
string
()
{
return
null
;
}
public
Object
object
()
{
return
null
;
}
@SuppressWarnings
(
"rawtypes"
)
public
MyInterfaceType
raw
()
{
return
null
;
}
public
String
notParameterized
()
{
return
null
;
}
public
String
notParameterizedWithArguments
(
Integer
x
,
Boolean
b
)
{
return
null
;
}
public
MyInterfaceType
raw
()
{
return
null
;
}
public
String
notParameterized
()
{
return
null
;
}
public
String
notParameterizedWithArguments
(
Integer
x
,
Boolean
b
)
{
return
null
;
}
/**
* Simulates a factory method that wraps the supplied object in a proxy
*
of the
same type.
* Simulates a factory method that wraps the supplied object in a proxy
of the
* same type.
*/
public
static
<
T
>
T
createProxy
(
T
object
)
{
return
null
;
}
/**
* Similar to {@link #createProxy(Object)} but adds an additional argument
*
before the argument of type {@code T}. Note that they may potentially
*
be of the same
time when invoked!
* Similar to {@link #createProxy(Object)} but adds an additional argument
before
*
the argument of type {@code T}. Note that they may potentially be of the same
* time when invoked!
*/
public
static
<
T
>
T
createNamedProxy
(
String
name
,
T
object
)
{
return
null
;
...
...
@@ -204,8 +227,8 @@ public class GenericTypeResolverTests {
}
/**
* Similar to {@link #createMock(Class)} but adds an additional method
*
argument
before the parameterized argument.
* Similar to {@link #createMock(Class)} but adds an additional method
argument
* before the parameterized argument.
*/
public
static
<
T
>
T
createNamedMock
(
String
name
,
Class
<
T
>
toMock
)
{
return
null
;
...
...
@@ -220,8 +243,8 @@ public class GenericTypeResolverTests {
}
/**
* Extract some value of the type supported by the interface (i.e., by
*
a concrete,
non-generic implementation of the interface).
* Extract some value of the type supported by the interface (i.e., by
a concrete,
* non-generic implementation of the interface).
*/
public
static
<
T
>
T
extractValueFrom
(
MyInterfaceType
<
T
>
myInterfaceType
)
{
return
null
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录