Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
58db5132
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,发现更多精彩内容 >>
提交
58db5132
编写于
7月 02, 2009
作者:
S
Sam Brannen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Made fragile tests a little less fragile: increased max times.
上级
0f22e22f
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
30 addition
and
34 deletion
+30
-34
org.springframework.context/src/test/java/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests.java
...k/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests.java
+30
-34
未找到文件。
org.springframework.context/src/test/java/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests.java
浏览文件 @
58db5132
...
...
@@ -118,8 +118,11 @@ public final class AspectJAutoProxyCreatorTests {
}
}
sw
.
stop
();
System
.
out
.
println
(
sw
.
getTotalTimeMillis
());
assertTrue
(
"Prototype creation took too long: "
+
sw
.
getTotalTimeMillis
(),
sw
.
getTotalTimeMillis
()
<
4000
);
long
totalTimeMillis
=
sw
.
getTotalTimeMillis
();
// System.out.println(totalTimeMillis);
// How was it decided that 4 seconds is a reasonable maximum time?
int
maxTimeMillis
=
5000
;
// 4000;
assertTrue
(
"Prototype creation took too long: "
+
totalTimeMillis
,
totalTimeMillis
<
maxTimeMillis
);
}
@Test
...
...
@@ -138,8 +141,11 @@ public final class AspectJAutoProxyCreatorTests {
}
}
sw
.
stop
();
System
.
out
.
println
(
sw
.
getTotalTimeMillis
());
assertTrue
(
"Prototype creation took too long: "
+
sw
.
getTotalTimeMillis
(),
sw
.
getTotalTimeMillis
()
<
3000
);
long
totalTimeMillis
=
sw
.
getTotalTimeMillis
();
// System.out.println(totalTimeMillis);
// How was it decided that 3 seconds is a reasonable maximum time?
int
maxTimeMillis
=
3000
;
assertTrue
(
"Prototype creation took too long: "
+
totalTimeMillis
,
totalTimeMillis
<
maxTimeMillis
);
}
@Test
...
...
@@ -149,8 +155,8 @@ public final class AspectJAutoProxyCreatorTests {
return
;
}
GenericApplicationContext
ac
=
new
GenericApplicationContext
();
new
XmlBeanDefinitionReader
(
ac
).
loadBeanDefinitions
(
new
ClassPathResource
(
qName
(
"aspectsPlusAdvisor.xml"
),
getClass
()));
new
XmlBeanDefinitionReader
(
ac
).
loadBeanDefinitions
(
new
ClassPathResource
(
qName
(
"aspectsPlusAdvisor.xml"
),
getClass
()));
for
(
int
i
=
0
;
i
<
10000
;
i
++)
{
ac
.
registerBeanDefinition
(
"singleton"
+
i
,
new
RootBeanDefinition
(
NestedTestBean
.
class
));
}
...
...
@@ -158,8 +164,11 @@ public final class AspectJAutoProxyCreatorTests {
sw
.
start
(
"singleton"
);
ac
.
refresh
();
sw
.
stop
();
System
.
out
.
println
(
sw
.
getTotalTimeMillis
());
assertTrue
(
"Singleton creation took too long: "
+
sw
.
getTotalTimeMillis
(),
sw
.
getTotalTimeMillis
()
<
4000
);
long
totalTimeMillis
=
sw
.
getTotalTimeMillis
();
// System.out.println(totalTimeMillis);
// How was it decided that 4 seconds is a reasonable maximum time?
int
maxTimeMillis
=
5000
;
// 4000;
assertTrue
(
"Singleton creation took too long: "
+
totalTimeMillis
,
totalTimeMillis
<
maxTimeMillis
);
}
@Test
...
...
@@ -168,12 +177,12 @@ public final class AspectJAutoProxyCreatorTests {
GenericApplicationContext
childAc
=
new
GenericApplicationContext
(
ac
);
// Create a child factory with a bean that should be weaved
RootBeanDefinition
bd
=
new
RootBeanDefinition
(
TestBean
.
class
);
bd
.
getPropertyValues
().
addPropertyValue
(
new
PropertyValue
(
"name"
,
"Adrian"
)).
addPropertyValue
(
new
PropertyValue
(
"age"
,
new
Integer
(
34
)));
bd
.
getPropertyValues
().
addPropertyValue
(
new
PropertyValue
(
"name"
,
"Adrian"
)).
addPropertyValue
(
new
PropertyValue
(
"age"
,
new
Integer
(
34
)));
childAc
.
registerBeanDefinition
(
"adrian2"
,
bd
);
// Register the advisor auto proxy creator with subclass
childAc
.
registerBeanDefinition
(
AnnotationAwareAspectJAutoProxyCreator
.
class
.
getName
(),
new
RootBeanDefinition
(
AnnotationAwareAspectJAutoProxyCreator
.
class
));
childAc
.
registerBeanDefinition
(
AnnotationAwareAspectJAutoProxyCreator
.
class
.
getName
(),
new
RootBeanDefinition
(
AnnotationAwareAspectJAutoProxyCreator
.
class
));
childAc
.
refresh
();
ITestBean
beanFromChildContextThatShouldBeWeaved
=
(
ITestBean
)
childAc
.
getBean
(
"adrian2"
);
...
...
@@ -355,7 +364,6 @@ public final class AspectJAutoProxyCreatorTests {
}
@Aspect
(
"pertarget(execution(* *.getSpouse()))"
)
class
PerTargetAspect
implements
Ordered
{
...
...
@@ -392,7 +400,8 @@ class AdviceUsingThisJoinPoint {
}
@Pointcut
(
"execution(* *(..))"
)
public
void
methodExecution
()
{}
public
void
methodExecution
()
{
}
@Before
(
"methodExecution()"
)
public
void
entryTrace
(
JoinPoint
jp
)
{
...
...
@@ -401,7 +410,6 @@ class AdviceUsingThisJoinPoint {
}
@Aspect
class
DummyAspect
{
...
...
@@ -412,7 +420,6 @@ class DummyAspect {
}
@Aspect
class
DummyAspectWithParameter
{
...
...
@@ -423,7 +430,6 @@ class DummyAspectWithParameter {
}
class
DummyFactoryBean
implements
FactoryBean
<
Object
>
{
public
Object
getObject
()
throws
Exception
{
...
...
@@ -440,7 +446,6 @@ class DummyFactoryBean implements FactoryBean<Object> {
}
@Aspect
@Order
(
10
)
class
IncreaseReturnValue
{
...
...
@@ -453,7 +458,6 @@ class IncreaseReturnValue {
}
@Aspect
class
MultiplyReturnValue
{
...
...
@@ -478,7 +482,6 @@ class MultiplyReturnValue {
}
@Aspect
class
RetryAspect
{
...
...
@@ -488,7 +491,6 @@ class RetryAspect {
private
int
rollbackCalls
;
@Pointcut
(
"execution(public * UnreliableBean.*(..))"
)
public
void
execOfPublicMethod
()
{
}
...
...
@@ -507,20 +509,17 @@ class RetryAspect {
try
{
o
=
jp
.
proceed
();
this
.
commitCalls
++;
}
catch
(
RetryableException
e
)
{
}
catch
(
RetryableException
e
)
{
this
.
rollbackCalls
++;
throw
e
;
}
}
catch
(
RetryableException
re
)
{
}
catch
(
RetryableException
re
)
{
retry
=
true
;
}
}
return
o
;
}
public
int
getBeginCalls
()
{
return
this
.
beginCalls
;
}
...
...
@@ -535,7 +534,6 @@ class RetryAspect {
}
@SuppressWarnings
(
"serial"
)
class
RetryableException
extends
NestedRuntimeException
{
...
...
@@ -548,27 +546,25 @@ class RetryableException extends NestedRuntimeException {
}
}
class
UnreliableBean
{
private
int
calls
;
public
int
unreliable
()
{
this
.
calls
++;
if
(
this
.
calls
%
2
!=
0
)
{
throw
new
RetryableException
(
"foo"
);
}
if
(
this
.
calls
%
2
!=
0
)
{
throw
new
RetryableException
(
"foo"
);
}
return
this
.
calls
;
}
}
@SuppressWarnings
(
"serial"
)
class
TestBeanAdvisor
extends
StaticMethodMatcherPointcutAdvisor
{
public
int
count
;
public
TestBeanAdvisor
()
{
setAdvice
(
new
MethodBeforeAdvice
()
{
public
void
before
(
Method
method
,
Object
[]
args
,
Object
target
)
throws
Throwable
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录