类org.junit.rules.RuleChain源码实例Demo

下面列出了怎么用org.junit.rules.RuleChain的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: flutter-intellij   文件: FlutterGuiTestRule.java
@NotNull
@Override
public Statement apply(final Statement base, final Description description) {
  RuleChain chain = RuleChain.emptyRuleChain()
    .around(new AspectsAgentLogger())
    .around(new LogStartAndStop())
    .around(myRobotTestRule)
    .around(myOuterTimeout) // Rules should be inside this timeout when possible
    .around(new IdeControl(myRobotTestRule::getRobot))
    .around(new BlockReloading())
    .around(new BazelUndeclaredOutputs())
    .around(myLeakCheck)
    .around(new FlutterGuiTestRule.IdeHandling())
    .around(new ScreenshotOnFailure())
    .around(myInnerTimeout);

  // Perf logging currently writes data to the Bazel-specific TEST_UNDECLARED_OUTPUTS_DIR. Skipp logging if running outside of Bazel.
  if (TestUtils.runningFromBazel()) {
    chain = chain.around(new GuiPerfLogger(description));
  }

  return chain.apply(base, description);
}
 
源代码2 项目: camunda-bpm-platform   文件: JerseySpecifics.java
public TestRule createTestRule() {
  final TemporaryFolder tempFolder = new TemporaryFolder();

  return RuleChain
    .outerRule(tempFolder)
    .around(new ExternalResource() {

      TomcatServerBootstrap bootstrap = new JerseyTomcatServerBootstrap(webXmlResource);

      protected void before() throws Throwable {
        bootstrap.setWorkingDir(tempFolder.getRoot().getAbsolutePath());
        bootstrap.start();
      }

      protected void after() {
        bootstrap.stop();
      }
    });
}
 
源代码3 项目: camunda-bpm-platform   文件: WinkSpecifics.java
public TestRule createTestRule() {
  final TemporaryFolder tempFolder = new TemporaryFolder();

  return RuleChain
    .outerRule(tempFolder)
    .around(new ExternalResource() {

      WinkTomcatServerBootstrap bootstrap = new WinkTomcatServerBootstrap(webXmlResource);

      protected void before() throws Throwable {
        bootstrap.setWorkingDir(tempFolder.getRoot().getAbsolutePath());
        bootstrap.start();
      }

      protected void after() {
        bootstrap.stop();
      }
    });
}
 
源代码4 项目: camunda-bpm-platform   文件: JerseySpecifics.java
public TestRule createTestRule() {
  final TemporaryFolder tempFolder = new TemporaryFolder();

  return RuleChain
    .outerRule(tempFolder)
    .around(new ExternalResource() {

      TomcatServerBootstrap bootstrap = new JerseyTomcatServerBootstrap(webXmlResource);

      protected void before() throws Throwable {
        bootstrap.setWorkingDir(tempFolder.getRoot().getAbsolutePath());
        bootstrap.start();
      }

      protected void after() {
        bootstrap.stop();
      }
    });
}
 
源代码5 项目: camunda-bpm-platform   文件: CXFSpecifics.java
public TestRule createTestRule() {
  final TemporaryFolder tempFolder = new TemporaryFolder();

  return RuleChain
    .outerRule(tempFolder)
    .around(new ExternalResource() {

      TomcatServerBootstrap bootstrap = new CXFTomcatServerBootstrap(webXmlResource);

      protected void before() throws Throwable {
        bootstrap.setWorkingDir(tempFolder.getRoot().getAbsolutePath());
        bootstrap.start();
      }

      protected void after() {
        bootstrap.stop();
      }
    });
}
 
源代码6 项目: camunda-bpm-platform   文件: ResteasySpecifics.java
public TestRule createTestRule() {
  final TemporaryFolder tempFolder = new TemporaryFolder();

  return RuleChain
    .outerRule(tempFolder)
    .around(new ExternalResource() {

      ResteasyTomcatServerBootstrap bootstrap = new ResteasyTomcatServerBootstrap(webXmlResource);

      protected void before() throws Throwable {
        bootstrap.setWorkingDir(tempFolder.getRoot().getAbsolutePath());
        bootstrap.start();
      }

      protected void after() {
        bootstrap.stop();
      }
    });
}
 
/**
 * Sets up both users and the RuleChain.
 * 
 * @return RuleChain
 */
private static RuleChain setupRuleChain()
{
    BRITISH_USER = new AlfrescoPerson(APP_CONTEXT_INIT, "[email protected]");
    FRENCH_USER = new AlfrescoPerson(APP_CONTEXT_INIT, "[email protected]");
    AUSTRALIAN_USER = new AlfrescoPerson(APP_CONTEXT_INIT, "[email protected]");
    EXTERNAL_USER = new AlfrescoPerson(APP_CONTEXT_INIT, "[email protected]");

    return RuleChain.outerRule(APP_CONTEXT_INIT).around(AUSTRALIAN_USER).around(BRITISH_USER).around(FRENCH_USER).around(EXTERNAL_USER);
}
 
@Override
public Statement apply(Statement base, Description description) {
    return RuleChain.outerRule(verifyMetadataServer)
        .around(trustAnchorServer)
        .around(metadataAggregatorServer)
        .around(super::apply).apply(base, description);
}
 
源代码9 项目: nomulus   文件: JpaTestRules.java
JpaIntegrationWithCoverageRule(JpaIntegrationTestRule integrationTestRule) {
  TestCaseWatcher watcher = new TestCaseWatcher();
  this.ruleChain =
      RuleChain.outerRule(watcher)
          .around(integrationTestRule)
          .around(new JpaEntityCoverage(watcher::getTestClass));
}
 
源代码10 项目: terracotta-platform   文件: DynamicConfigIT.java
public DynamicConfigIT(Duration testTimeout, Path parentTmpDir) {
  ClusterDefinition clusterDef = getClass().getAnnotation(ClusterDefinition.class);
  this.timeout = testTimeout.toMillis();
  this.rules = RuleChain.emptyRuleChain()
      .around(tmpDir = new TmpDir(parentTmpDir, false))
      .around(angela = new AngelaRule(createConfigurationContext(clusterDef.stripes(), clusterDef.nodesPerStripe()), clusterDef.autoStart(), clusterDef.autoActivate()) {
        @Override
        public void startNode(int stripeId, int nodeId) {
          // let the subclasses control the node startup
          DynamicConfigIT.this.startNode(stripeId, nodeId);
        }
      })
      .around(Timeout.millis(testTimeout.toMillis()))
      .around(new ExtendedTestRule() {
        @Override
        protected void before(Description description) throws Throwable {
          // upload tc logging config, but ONLY IF EXISTS !
          URL tcLoggingConfig = this.getClass().getResource("/tc-logback.xml");
          if (tcLoggingConfig != null) {
            List<TerracottaServer> servers = angela.tsa().getTsaConfigurationContext().getTopology().getServers();
            for (TerracottaServer s : servers) {
              try {
                RemoteFolder folder = angela.tsa().browse(s, "");
                folder.upload("logback-test.xml", tcLoggingConfig);
              } catch (IOException exp) {
                LOGGER.warn("unable to upload logback configuration", exp);
              }
            }
          }
          // wait for server startup if auto-activated
          if (clusterDef.autoStart() && clusterDef.autoActivate()) {
            for (int stripeId = 1; stripeId <= clusterDef.stripes(); stripeId++) {
              waitForActive(stripeId);
              waitForPassives(stripeId);
            }
          }
        }
      });
}
 
/**
 * Creates a test rule.
 *
 * @return a test rule.
 */
@Rule
public TestRule rule() {
    return RuleChain
            .outerRule(new LogbackAccessEventQueuingAppenderRule())
            .around(new LogbackAccessEventQueuingListenerRule());
}
 
/**
 * Creates a test rule.
 *
 * @return a test rule.
 */
@Rule
public TestRule rule() {
    return RuleChain
            .outerRule(new LogbackAccessEventQueuingAppenderRule())
            .around(new LogbackAccessEventQueuingListenerRule());
}
 
/**
 * Creates a test rule.
 *
 * @return a test rule.
 */
@Rule
public TestRule rule() {
    return RuleChain
            .outerRule(new LogbackAccessEventQueuingAppenderRule())
            .around(new LogbackAccessEventQueuingListenerRule());
}
 
/**
 * Creates a test rule.
 *
 * @return a test rule.
 */
@Rule
public TestRule rule() {
    return RuleChain
            .outerRule(new LogbackAccessEventQueuingAppenderRule())
            .around(new LogbackAccessEventQueuingListenerRule());
}
 
/**
 * Creates a test rule.
 *
 * @return a test rule.
 */
@Rule
public TestRule rule() {
    return RuleChain
            .outerRule(new LogbackAccessEventQueuingAppenderRule())
            .around(new LogbackAccessEventQueuingListenerRule())
            .around(outputCapture);
}
 
/**
 * Creates a test rule.
 *
 * @return a test rule.
 */
@Rule
public TestRule rule() {
    return RuleChain
            .outerRule(new LogbackAccessEventQueuingAppenderRule())
            .around(new LogbackAccessEventQueuingListenerRule());
}
 
/**
 * Creates a test rule.
 *
 * @return a test rule.
 */
@Rule
public TestRule rule() {
    return RuleChain
            .outerRule(new LogbackAccessEventQueuingAppenderRule())
            .around(new LogbackAccessEventQueuingListenerRule());
}
 
/**
 * Creates a test rule.
 *
 * @return a test rule.
 */
@Rule
public TestRule rule() {
    return RuleChain
            .outerRule(new LogbackAccessEventQueuingAppenderRule())
            .around(new LogbackAccessEventQueuingListenerRule())
            .around(outputCapture);
}
 
/**
 * Creates a test rule.
 *
 * @return a test rule.
 */
@Rule
public TestRule rule() {
    return RuleChain
            .outerRule(new LogbackAccessEventQueuingAppenderRule())
            .around(new LogbackAccessEventQueuingListenerRule())
            .around(outputCapture);
}
 
/**
 * Creates a test rule.
 *
 * @return a test rule.
 */
@Rule
public TestRule rule() {
    return RuleChain
            .outerRule(new LogbackAccessEventQueuingAppenderRule())
            .around(new LogbackAccessEventQueuingListenerRule());
}
 
/**
 * Creates a test rule.
 *
 * @return a test rule.
 */
@Rule
public TestRule rule() {
    return RuleChain
            .outerRule(new LogbackAccessEventQueuingAppenderRule())
            .around(new LogbackAccessEventQueuingListenerRule());
}
 
/**
 * Creates a test rule.
 *
 * @return a test rule.
 */
@Rule
public TestRule rule() {
    return RuleChain
            .outerRule(new LogbackAccessEventQueuingAppenderRule())
            .around(new LogbackAccessEventQueuingListenerRule());
}
 
/**
 * Creates a test rule.
 *
 * @return a test rule.
 */
@Rule
public TestRule rule() {
    return RuleChain
            .outerRule(new LogbackAccessEventQueuingAppenderRule())
            .around(new LogbackAccessEventQueuingListenerRule());
}
 
private AggregateGuiceModuleTestRule(List<GuiceModuleTestRule> subrule) {
    this.subrule = subrule;
    this.chain = subrule
            .stream()
            .reduce(RuleChain.emptyRuleChain(),
                    RuleChain::around,
                    RuleChain::around);
}
 
源代码25 项目: logging-log4j2   文件: RuleChainFactory.java
/**
 * Creates a {@link RuleChain} where the rules are evaluated in the order you pass in.
 * 
 * @param testRules
 *            test rules to evaluate
 * @return a new rule chain.
 */
public static RuleChain create(final TestRule... testRules) {
    if (testRules == null || testRules.length == 0) {
        return RuleChain.emptyRuleChain();
    }
    RuleChain ruleChain = RuleChain.outerRule(testRules[0]);
    for (int i = 1; i < testRules.length; i++) {
        ruleChain = ruleChain.around(testRules[i]);
    }
    return ruleChain;
}
 
public RandomAccessFileAppenderTest(final String testName, final boolean locationEnabled, final String type) {
    this.init = new LoggerContextRule(testName + type);
    this.logFile = new File("target", testName + ".log");
    this.files = new CleanFiles(this.logFile);
    this.locationEnabled = locationEnabled;
    this.chain = RuleChain.outerRule(files).around(init);
}
 
protected AbstractJdbcAppenderDataSourceTest(final JdbcRule jdbcRule) {
    this.rules = RuleChain.emptyRuleChain()
        .around(new JndiRule("java:/comp/env/jdbc/TestDataSourceAppender", createMockDataSource()))
        .around(jdbcRule)
        .around(new LoggerContextRule(
            "org/apache/logging/log4j/jdbc/appender/log4j2-data-source.xml"));
    this.jdbcRule = jdbcRule;
}
 
protected JdbcAppenderMapMessageDataSourceTest(final JdbcRule jdbcRule) {
    // @formatter:off
    this.rules = RuleChain.emptyRuleChain()
            .around(new JndiRule("java:/comp/env/jdbc/TestDataSourceAppender", createMockDataSource()))
            .around(jdbcRule)
            .around(new LoggerContextRule("org/apache/logging/log4j/jdbc/appender/log4j2-data-source-map-message.xml"));
    // @formatter:on
    this.jdbcRule = jdbcRule;
}
 
源代码29 项目: keywhiz   文件: IntegrationTestRule.java
public static RuleChain rule() {
  String configPath = Resources.getResource("keywhiz-test.yaml").getPath();
  return RuleChain
      .outerRule(new MigrationsRule())
      .around(new DropwizardAppRule<>(KeywhizService.class, configPath));
}
 
源代码30 项目: jenkins-build-monitor-plugin   文件: RuleChains.java
public static RuleChain from(TestRule... rules) {
    return from(Arrays.asList(rules));
}