本文整理匯總了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();
}