Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
d6d42515
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 搜索 >>
提交
d6d42515
编写于
7月 08, 2016
作者:
S
Sam Brannen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Utilize default methods in TestExecutionListener
Issue: SPR-14432
上级
a0cad5c4
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
34 addition
and
56 deletion
+34
-56
spring-test/src/main/java/org/springframework/test/context/TestExecutionListener.java
...g/springframework/test/context/TestExecutionListener.java
+30
-5
spring-test/src/main/java/org/springframework/test/context/support/AbstractTestExecutionListener.java
...k/test/context/support/AbstractTestExecutionListener.java
+4
-51
未找到文件。
spring-test/src/main/java/org/springframework/test/context/TestExecutionListener.java
浏览文件 @
d6d42515
...
...
@@ -21,6 +21,10 @@ package org.springframework.test.context;
* test execution events published by the {@link TestContextManager} with which
* the listener is registered.
*
* <p>This interface provides empty {@code default} implementations for all methods.
* Concrete implementations can therefore choose to override only those methods
* suitable for the task at hand.
*
* <p>Concrete implementations must provide a {@code public} no-args constructor,
* so that listeners can be instantiated transparently by tools and configuration
* mechanisms.
...
...
@@ -51,6 +55,7 @@ package org.springframework.test.context;
* @author Sam Brannen
* @author Juergen Hoeller
* @since 2.5
* @see org.springframework.test.context.support.AbstractTestExecutionListener
*/
public
interface
TestExecutionListener
{
...
...
@@ -61,20 +66,28 @@ public interface TestExecutionListener {
* <em>before class</em> lifecycle callbacks.
* <p>If a given testing framework does not support <em>before class</em>
* lifecycle callbacks, this method will not be called for that framework.
* <p>The default implementation is <em>empty</em>. Can be overridden by
* concrete classes as necessary.
* @param testContext the test context for the test; never {@code null}
* @throws Exception allows any exception to propagate
*/
void
beforeTestClass
(
TestContext
testContext
)
throws
Exception
;
default
void
beforeTestClass
(
TestContext
testContext
)
throws
Exception
{
/* no-op */
}
/**
* Prepares the {@link Object test instance} of the supplied
* {@link TestContext test context}, for example by injecting dependencies.
* <p>This method should be called immediately after instantiation of the test
* instance but prior to any framework-specific lifecycle callbacks.
* <p>The default implementation is <em>empty</em>. Can be overridden by
* concrete classes as necessary.
* @param testContext the test context for the test; never {@code null}
* @throws Exception allows any exception to propagate
*/
void
prepareTestInstance
(
TestContext
testContext
)
throws
Exception
;
default
void
prepareTestInstance
(
TestContext
testContext
)
throws
Exception
{
/* no-op */
}
/**
* Pre-processes a test <em>before</em> execution of the
...
...
@@ -83,11 +96,15 @@ public interface TestExecutionListener {
* fixtures.
* <p>This method should be called immediately prior to framework-specific
* <em>before</em> lifecycle callbacks.
* <p>The default implementation is <em>empty</em>. Can be overridden by
* concrete classes as necessary.
* @param testContext the test context in which the test method will be
* executed; never {@code null}
* @throws Exception allows any exception to propagate
*/
void
beforeTestMethod
(
TestContext
testContext
)
throws
Exception
;
default
void
beforeTestMethod
(
TestContext
testContext
)
throws
Exception
{
/* no-op */
}
/**
* Post-processes a test <em>after</em> execution of the
...
...
@@ -96,11 +113,15 @@ public interface TestExecutionListener {
* fixtures.
* <p>This method should be called immediately after framework-specific
* <em>after</em> lifecycle callbacks.
* <p>The default implementation is <em>empty</em>. Can be overridden by
* concrete classes as necessary.
* @param testContext the test context in which the test method was
* executed; never {@code null}
* @throws Exception allows any exception to propagate
*/
void
afterTestMethod
(
TestContext
testContext
)
throws
Exception
;
default
void
afterTestMethod
(
TestContext
testContext
)
throws
Exception
{
/* no-op */
}
/**
* Post-processes a test class <em>after</em> execution of all tests within
...
...
@@ -109,9 +130,13 @@ public interface TestExecutionListener {
* <em>after class</em> lifecycle callbacks.
* <p>If a given testing framework does not support <em>after class</em>
* lifecycle callbacks, this method will not be called for that framework.
* <p>The default implementation is <em>empty</em>. Can be overridden by
* concrete classes as necessary.
* @param testContext the test context for the test; never {@code null}
* @throws Exception allows any exception to propagate
*/
void
afterTestClass
(
TestContext
testContext
)
throws
Exception
;
default
void
afterTestClass
(
TestContext
testContext
)
throws
Exception
{
/* no-op */
}
}
spring-test/src/main/java/org/springframework/test/context/support/AbstractTestExecutionListener.java
浏览文件 @
d6d42515
/*
* Copyright 2002-201
4
the original author or authors.
* Copyright 2002-201
6
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.
...
...
@@ -17,65 +17,18 @@
package
org.springframework.test.context.support
;
import
org.springframework.core.Ordered
;
import
org.springframework.test.context.TestContext
;
import
org.springframework.test.context.TestExecutionListener
;
/**
* Abstract implementation of the {@link TestExecutionListener} interface which
* provides empty method stubs. Subclasses can extend this class and override
* only those methods suitable for the task at hand.
* Abstract {@linkplain Ordered ordered} implementation of the
* {@link TestExecutionListener} API.
*
* @author Sam Brannen
* @author Juergen Hoeller
* @since 2.5
* @see #getOrder()
*/
public
abstract
class
AbstractTestExecutionListener
implements
TestExecutionListener
,
Ordered
{
/**
* The default implementation is <em>empty</em>. Can be overridden by
* subclasses as necessary.
*/
@Override
public
void
beforeTestClass
(
TestContext
testContext
)
throws
Exception
{
/* no-op */
}
/**
* The default implementation is <em>empty</em>. Can be overridden by
* subclasses as necessary.
*/
@Override
public
void
prepareTestInstance
(
TestContext
testContext
)
throws
Exception
{
/* no-op */
}
/**
* The default implementation is <em>empty</em>. Can be overridden by
* subclasses as necessary.
*/
@Override
public
void
beforeTestMethod
(
TestContext
testContext
)
throws
Exception
{
/* no-op */
}
/**
* The default implementation is <em>empty</em>. Can be overridden by
* subclasses as necessary.
*/
@Override
public
void
afterTestMethod
(
TestContext
testContext
)
throws
Exception
{
/* no-op */
}
/**
* The default implementation is <em>empty</em>. Can be overridden by
* subclasses as necessary.
*/
@Override
public
void
afterTestClass
(
TestContext
testContext
)
throws
Exception
{
/* no-op */
}
/**
* The default implementation returns {@link Ordered#LOWEST_PRECEDENCE},
* thereby ensuring that custom listeners are ordered after default
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录