当前位置: 首页>>代码示例>>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;未经允许,请勿转载。