本文整理汇总了Java中org.junit.runner.Description.getAnnotation方法的典型用法代码示例。如果您正苦于以下问题:Java Description.getAnnotation方法的具体用法?Java Description.getAnnotation怎么用?Java Description.getAnnotation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.junit.runner.Description
的用法示例。
在下文中一共展示了Description.getAnnotation方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: apply
import org.junit.runner.Description; //导入方法依赖的package包/类
@Override
public Statement apply(final Statement base, Description description) {
final RunTestWithRemoteService annotation = description.getAnnotation(RunTestWithRemoteService.class);
if (annotation == null) {
return base;
}
return new Statement() {
@Override
public void evaluate() throws Throwable {
before(annotation.remoteService());
try {
base.evaluate();
} finally {
if (!annotation.onLooperThread()) {
after();
}
}
}
};
}
示例2: apply
import org.junit.runner.Description; //导入方法依赖的package包/类
@Override public Statement apply(final Statement base, final Description description) {
return new Statement() {
@Override public void evaluate() throws Throwable {
Now annotation = description.getAnnotation(Now.class);
if (annotation == null) {
base.evaluate(); // 現在時刻を固定しない
return;
}
try {
now = parse(annotation.value());
lockCurrentTime(new Time.NowProvider() {
@Override public long now() {
return now;
}
});
base.evaluate();
} finally {
unlockCurrentTime();
}
}
};
}
示例3: before
import org.junit.runner.Description; //导入方法依赖的package包/类
@Override
protected void before(Description description) throws Throwable {
this.gfsh = new HeadlessGfsh(getClass().getName(), 30, "gfsh_files");
// do not auto connect if no port initialized
if (port < 0) {
return;
}
// do not auto connect if it's not used with ConnectionConfiguration
ConnectionConfiguration config = description.getAnnotation(ConnectionConfiguration.class);
if (config == null) {
return;
}
connect(port, portType, CliStrings.CONNECT__USERNAME, config.user(),
CliStrings.CONNECT__PASSWORD, config.password());
}
示例4: throwOnIgnoreTest
import org.junit.runner.Description; //导入方法依赖的package包/类
protected Statement throwOnIgnoreTest(Statement statement, Description description) {
if (isTest(description)) {
boolean ignoreTest = false;
String message = "";
ConditionalIgnore testCaseAnnotation = description.getAnnotation(ConditionalIgnore.class);
if (testCaseAnnotation != null) {
ignoreTest = evaluate(testCaseAnnotation, description);
message = testCaseAnnotation.value();
} else if (description.getTestClass().isAnnotationPresent(ConditionalIgnore.class)) {
ConditionalIgnore testClassAnnotation =
description.getTestClass().getAnnotation(ConditionalIgnore.class);
ignoreTest = evaluate(testClassAnnotation, description);
message = testClassAnnotation.value();
}
if (ignoreTest) {
throw new AssumptionViolatedException(format(message, description));
}
}
return statement;
}
示例5: apply
import org.junit.runner.Description; //导入方法依赖的package包/类
public Statement apply(final Statement base, Description description) {
Class<?> testClass = description.getTestClass();
init(description.getMethodName(), testClass.getSimpleName());
suppressCleanupErrors = testClass.getAnnotation(LeaksFileHandles.class) != null
|| description.getAnnotation(LeaksFileHandles.class) != null;
return new TestDirectoryCleaningStatement(base, description.getDisplayName());
}
示例6: apply
import org.junit.runner.Description; //导入方法依赖的package包/类
@Override
public Statement apply(Statement base, Description description) {
setTestName(description);
final RunTestInLooperThread annotation = description.getAnnotation(RunTestInLooperThread.class);
if (annotation == null) {
return base;
}
synchronized (lock) {
ruleBeingUsed = true;
}
return new RunInLooperThreadStatement(annotation, base);
}
示例7: getAnnotationsOnMethod
import org.junit.runner.Description; //导入方法依赖的package包/类
private <T extends Annotation> List<T> getAnnotationsOnMethod(final Description result, final Class<T> clazz) {
final T annotation = result.getAnnotation(clazz);
return Stream.concat(
extractRepeatable(result, clazz).stream(),
Objects.isNull(annotation) ? Stream.empty() : Stream.of(annotation)
).collect(Collectors.toList());
}
示例8: before
import org.junit.runner.Description; //导入方法依赖的package包/类
@Before
protected void before(Description description) throws Throwable {
ConnectionConfiguration config = description.getAnnotation(ConnectionConfiguration.class);
if (config != null) {
connect(CliStrings.CONNECT__USERNAME, config.user(), CliStrings.CONNECT__PASSWORD,
config.password());
} else {
connect();
}
}
示例9: before
import org.junit.runner.Description; //导入方法依赖的package包/类
protected void before(Description description) throws Throwable {
ConnectionConfiguration config = description.getAnnotation(ConnectionConfiguration.class);
Map<String, String[]> env = new HashMap<>();
if (config != null) {
String user = config.user();
String password = config.password();
env.put(JMXConnector.CREDENTIALS, new String[] {user, password});
JMXServiceURL url =
new JMXServiceURL("service:jmx:rmi:///jndi/rmi://:" + jmxServerPort + "/jmxrmi");
jmxConnector = JMXConnectorFactory.connect(url, env);
con = jmxConnector.getMBeanServerConnection();
}
}
示例10: apply
import org.junit.runner.Description; //导入方法依赖的package包/类
@Override
public Statement apply(final Statement statement, final Description description) {
Statement result = statement;
final Repeat repeat = description.getAnnotation(Repeat.class);
if (repeat != null) {
final int times = repeat.times();
result = new RepeatStatement(times, statement);
}
return result;
}
示例11: apply
import org.junit.runner.Description; //导入方法依赖的package包/类
@Override
public Statement apply(Statement base, Description description) {
Statement result = base;
FXTest annotation = description.getAnnotation(FXTest.class);
if (annotation != null) {
ApplicationLaunch.bootstrap();
result = new FXTestStatement(base);
}
return result;
}
示例12: apply
import org.junit.runner.Description; //导入方法依赖的package包/类
@Override
public Statement apply(final Statement base, final Description description) {
final Repeat repeat = description.getAnnotation(Repeat.class);
if (repeat != null) {
final int times = repeat.times();
return new RepeatStatement(times, base);
}
return base;
}
示例13: evaluatePerTest
import org.junit.runner.Description; //导入方法依赖的package包/类
protected void evaluatePerTest(final Statement base, final Description description)
throws Throwable {
if (isTest(description)) {
Retry retry = description.getAnnotation(Retry.class);
int retryCount = getRetryCount(retry);
evaluate(base, description, retryCount);
}
}
示例14: evaluate
import org.junit.runner.Description; //导入方法依赖的package包/类
protected void evaluate(final Statement statement, final Description description)
throws Throwable {
if (isTest(description)) {
Repeat repeat = description.getAnnotation(Repeat.class);
for (int count = 0, repetitions = getRepetitions(repeat); count < repetitions; count++) {
statement.evaluate();
}
}
}
示例15: getIgnoredMessage
import org.junit.runner.Description; //导入方法依赖的package包/类
public String getIgnoredMessage(Description description) {
Ignore ignore = description.getAnnotation(Ignore.class);
return ignore == null || ignore.value().isEmpty() ? "Test ignored (without reason)!" : ignore.value();
}