當前位置: 首頁>>代碼示例>>Java>>正文


Java Description.getAnnotation方法代碼示例

本文整理匯總了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();
                }
            }
        }
    };
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:21,代碼來源:RunWithRemoteService.java

示例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();
      }
    }
  };
}
 
開發者ID:YukiMatsumura,項目名稱:denbun,代碼行數:24,代碼來源:TimeRule.java

示例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());
}
 
開發者ID:ampool,項目名稱:monarch,代碼行數:18,代碼來源:MashShellConnectionRule.java

示例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;
}
 
開發者ID:ampool,項目名稱:monarch,代碼行數:26,代碼來源:ConditionalIgnoreRule.java

示例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());
}
 
開發者ID:lxxlxx888,項目名稱:Reer,代碼行數:10,代碼來源:AbstractTestDirectoryProvider.java

示例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);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:13,代碼來源:RunInLooperThread.java

示例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());
}
 
開發者ID:allure-framework,項目名稱:allure-java,代碼行數:8,代碼來源:AllureJunit4.java

示例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();
  }
}
 
開發者ID:ampool,項目名稱:monarch,代碼行數:11,代碼來源:GfshShellConnectionRule.java

示例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();
  }
}
 
開發者ID:ampool,項目名稱:monarch,代碼行數:15,代碼來源:MBeanServerConnectionRule.java

示例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;
}
 
開發者ID:silentbalanceyh,項目名稱:vertx-zero,代碼行數:11,代碼來源:RepeatRule.java

示例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;
}
 
開發者ID:BestSolution-at,項目名稱:FX-Test,代碼行數:11,代碼來源:FXTestRule.java

示例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;
}
 
開發者ID:yyunikov,項目名稱:yunikov-commons,代碼行數:11,代碼來源:RepeatRule.java

示例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);
  }
}
 
開發者ID:ampool,項目名稱:monarch,代碼行數:9,代碼來源:RetryRule.java

示例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();
    }
  }
}
 
開發者ID:ampool,項目名稱:monarch,代碼行數:11,代碼來源:RepeatRule.java

示例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();
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:5,代碼來源:AllureMarathonRunListener.java


注:本文中的org.junit.runner.Description.getAnnotation方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。