Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
2ae8ce6f
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,发现更多精彩内容 >>
提交
2ae8ce6f
编写于
12月 11, 2008
作者:
C
Chris Beams
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
upgraded integration test to JUnit 4
上级
08f1be7f
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
23 addition
and
5 deletion
+23
-5
org.springframework.testsuite/src/test/java/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests.java
...k/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests.java
+23
-5
未找到文件。
org.springframework.testsuite/src/test/java/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests.java
浏览文件 @
2ae8ce6f
...
...
@@ -13,13 +13,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.springframework.aop.aspectj.autoproxy
;
import
junit.framework.TestCase
;
import
static
org
.
junit
.
Assert
.*;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
org.junit.Test
;
import
org.springframework.aop.aspectj.annotation.AbstractAspectJAdvisorFactoryTests
;
import
org.springframework.aop.aspectj.annotation.AnnotationAwareAspectJAutoProxyCreator
;
import
org.springframework.aop.aspectj.annotation.AspectMetadata
;
...
...
@@ -41,16 +41,18 @@ import org.springframework.context.support.GenericApplicationContext;
import
org.springframework.util.StopWatch
;
/**
*
T
ests for AspectJ auto-proxying. Includes mixing with Spring AOP Advisors
*
Integration t
ests for AspectJ auto-proxying. Includes mixing with Spring AOP Advisors
* to demonstrate that existing autoproxying contract is honoured.
*
* @author Rod Johnson
* @author Juergen Hoeller
* @author Chris Beams
*/
public
class
AspectJAutoProxyCreatorTests
extends
TestCase
{
public
class
AspectJAutoProxyCreatorTests
{
private
static
final
Log
factoryLog
=
LogFactory
.
getLog
(
DefaultListableBeanFactory
.
class
);
@Test
public
void
testAspectsAreApplied
()
{
ClassPathXmlApplicationContext
bf
=
new
ClassPathXmlApplicationContext
(
"/org/springframework/aop/aspectj/autoproxy/aspects.xml"
);
...
...
@@ -61,6 +63,7 @@ public class AspectJAutoProxyCreatorTests extends TestCase {
assertEquals
(
68
,
((
ITestBean
)
factoryBean
.
getTargetObject
()).
getAge
());
}
@Test
public
void
testMultipleAspectsWithParameterApplied
()
{
ClassPathXmlApplicationContext
bf
=
new
ClassPathXmlApplicationContext
(
"/org/springframework/aop/aspectj/autoproxy/aspects.xml"
);
...
...
@@ -69,6 +72,7 @@ public class AspectJAutoProxyCreatorTests extends TestCase {
assertEquals
(
20
,
tb
.
getAge
());
}
@Test
public
void
testAspectsAreAppliedInDefinedOrder
()
{
ClassPathXmlApplicationContext
bf
=
new
ClassPathXmlApplicationContext
(
"/org/springframework/aop/aspectj/autoproxy/aspectsWithOrdering.xml"
);
...
...
@@ -76,6 +80,7 @@ public class AspectJAutoProxyCreatorTests extends TestCase {
assertEquals
(
71
,
tb
.
getAge
());
}
@Test
public
void
testAspectsAndAdvisorAreApplied
()
{
ClassPathXmlApplicationContext
ac
=
new
ClassPathXmlApplicationContext
(
"/org/springframework/aop/aspectj/autoproxy/aspectsPlusAdvisor.xml"
);
...
...
@@ -83,6 +88,7 @@ public class AspectJAutoProxyCreatorTests extends TestCase {
testAspectsAndAdvisorAreApplied
(
ac
,
shouldBeWeaved
);
}
@Test
public
void
testAspectsAndAdvisorAppliedToPrototypeIsFastEnough
()
{
if
(
factoryLog
.
isTraceEnabled
()
||
factoryLog
.
isDebugEnabled
())
{
// Skip this test: Trace logging blows the time limit.
...
...
@@ -103,6 +109,7 @@ public class AspectJAutoProxyCreatorTests extends TestCase {
assertTrue
(
"Prototype creation took too long: "
+
sw
.
getTotalTimeMillis
(),
sw
.
getTotalTimeMillis
()
<
4000
);
}
@Test
public
void
testAspectsAndAdvisorNotAppliedToPrototypeIsFastEnough
()
{
if
(
factoryLog
.
isTraceEnabled
()
||
factoryLog
.
isDebugEnabled
())
{
// Skip this test: Trace logging blows the time limit.
...
...
@@ -123,6 +130,7 @@ public class AspectJAutoProxyCreatorTests extends TestCase {
assertTrue
(
"Prototype creation took too long: "
+
sw
.
getTotalTimeMillis
(),
sw
.
getTotalTimeMillis
()
<
3000
);
}
@Test
public
void
testAspectsAndAdvisorNotAppliedToManySingletonsIsFastEnough
()
{
if
(
factoryLog
.
isTraceEnabled
()
||
factoryLog
.
isDebugEnabled
())
{
// Skip this test: Trace logging blows the time limit.
...
...
@@ -142,6 +150,7 @@ public class AspectJAutoProxyCreatorTests extends TestCase {
assertTrue
(
"Singleton creation took too long: "
+
sw
.
getTotalTimeMillis
(),
sw
.
getTotalTimeMillis
()
<
4000
);
}
@Test
public
void
testAspectsAndAdvisorAreAppliedEvenIfComingFromParentFactory
()
{
ClassPathXmlApplicationContext
ac
=
new
ClassPathXmlApplicationContext
(
"/org/springframework/aop/aspectj/autoproxy/aspectsPlusAdvisor.xml"
);
...
...
@@ -178,6 +187,7 @@ public class AspectJAutoProxyCreatorTests extends TestCase {
assertEquals
(
"Must be able to hold state in aspect"
,
1
,
mrv
.
invocations
);
}
@Test
public
void
testPerThisAspect
()
{
ClassPathXmlApplicationContext
bf
=
new
ClassPathXmlApplicationContext
(
"/org/springframework/aop/aspectj/autoproxy/perthis.xml"
);
...
...
@@ -198,6 +208,7 @@ public class AspectJAutoProxyCreatorTests extends TestCase {
assertEquals
(
2
,
adrian1
.
getAge
());
}
@Test
public
void
testPerTargetAspect
()
throws
SecurityException
,
NoSuchMethodException
{
ClassPathXmlApplicationContext
bf
=
new
ClassPathXmlApplicationContext
(
"/org/springframework/aop/aspectj/autoproxy/pertarget.xml"
);
...
...
@@ -234,10 +245,12 @@ public class AspectJAutoProxyCreatorTests extends TestCase {
assertEquals
(
3
,
adrian1
.
getAge
());
}
@Test
public
void
testTwoAdviceAspectSingleton
()
{
doTestTwoAdviceAspectWith
(
"twoAdviceAspect.xml"
);
}
@Test
public
void
testTwoAdviceAspectPrototype
()
{
doTestTwoAdviceAspectWith
(
"twoAdviceAspectPrototype.xml"
);
}
...
...
@@ -254,6 +267,7 @@ public class AspectJAutoProxyCreatorTests extends TestCase {
testPrototype
(
adrian2
,
aspectSingleton
?
2
:
0
);
}
@Test
public
void
testAdviceUsingJoinPoint
()
{
ClassPathXmlApplicationContext
bf
=
new
ClassPathXmlApplicationContext
(
"/org/springframework/aop/aspectj/autoproxy/usesJoinPointAspect.xml"
);
...
...
@@ -266,6 +280,7 @@ public class AspectJAutoProxyCreatorTests extends TestCase {
assertTrue
(
aspectInstance
.
getLastMethodEntered
().
indexOf
(
"TestBean.getAge())"
)
!=
0
);
}
@Test
public
void
testIncludeMechanism
()
{
ClassPathXmlApplicationContext
bf
=
new
ClassPathXmlApplicationContext
(
"/org/springframework/aop/aspectj/autoproxy/usesInclude.xml"
);
...
...
@@ -287,6 +302,7 @@ public class AspectJAutoProxyCreatorTests extends TestCase {
assertEquals
(
start
++,
adrian1
.
getAge
());
}
@Test
public
void
testForceProxyTargetClass
()
{
ClassPathXmlApplicationContext
bf
=
new
ClassPathXmlApplicationContext
(
"/org/springframework/aop/aspectj/autoproxy/aspectsWithCGLIB.xml"
);
...
...
@@ -295,6 +311,7 @@ public class AspectJAutoProxyCreatorTests extends TestCase {
assertTrue
(
"should be proxying classes"
,
pc
.
isProxyTargetClass
());
}
@Test
public
void
testWithAbstractFactoryBeanAreApplied
()
{
ClassPathXmlApplicationContext
bf
=
new
ClassPathXmlApplicationContext
(
"/org/springframework/aop/aspectj/autoproxy/aspectsWithAbstractBean.xml"
);
...
...
@@ -304,6 +321,7 @@ public class AspectJAutoProxyCreatorTests extends TestCase {
assertEquals
(
68
,
adrian
.
getAge
());
}
@Test
public
void
testRetryAspect
()
throws
Exception
{
ClassPathXmlApplicationContext
bf
=
new
ClassPathXmlApplicationContext
(
"/org/springframework/aop/aspectj/autoproxy/retryAspect.xml"
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录