本文整理汇总了Java中org.junit.rules.RuleChain类的典型用法代码示例。如果您正苦于以下问题:Java RuleChain类的具体用法?Java RuleChain怎么用?Java RuleChain使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RuleChain类属于org.junit.rules包,在下文中一共展示了RuleChain类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: DropwizardAppWithPostgresRule
import org.junit.rules.RuleChain; //导入依赖的package包/类
public DropwizardAppWithPostgresRule(String configPath, ConfigOverride... configOverrides) {
configFilePath = resourceFilePath(configPath);
postgres = new PostgresDockerRule();
List<ConfigOverride> cfgOverrideList = newArrayList(configOverrides);
cfgOverrideList.add(config("database.url", postgres.getConnectionUrl()));
cfgOverrideList.add(config("database.user", postgres.getUsername()));
cfgOverrideList.add(config("database.password", postgres.getPassword()));
app = new DropwizardAppRule<>(
AdminUsersApp.class,
configFilePath,
cfgOverrideList.toArray(new ConfigOverride[cfgOverrideList.size()])
);
createJpaModule(postgres);
rules = RuleChain.outerRule(postgres).around(app);
registerShutdownHook();
}
示例2: ExpectedDeploymentException
import org.junit.rules.RuleChain; //导入依赖的package包/类
private ExpectedDeploymentException() {
chain = RuleChain
.outerRule(log)
.around((base, description) -> new Statement() {
@Override
public void evaluate() throws Throwable {
try {
base.evaluate();
} catch (Throwable exception) {
assertThat(exception, allOf(pecs(exceptions)));
try {
// OpenWebBeans logs the deployment exception details
// TODO: OpenWebBeans only log the root cause of exception thrown in producer methods
//assertThat(log.getMessages(), containsInRelativeOrder(pecs(messages)))
assertThat(log.getMessages(), anyOf(hasItems(messages)));
} catch (AssertionError error) {
// Weld stores the deployment exception details in the exception message
assertThat(exception.getMessage(), allOf(pecs(messages)));
}
}
}
});
}
示例3: executionStatement
import org.junit.rules.RuleChain; //导入依赖的package包/类
private Statement executionStatement(final RunNotifier notifier, final int minPriority, final RuleChain ruleChain) {
return new Statement() {
@Override
public void evaluate() {
RuleChain ongoingRuleChain = withRules(ruleChain, specificationNode.rules());
if (hasOwnTest(minPriority)) {
evaluateStatementAndNotifyFailures(
ongoingRuleChain,
specificationNode.test().get().asStatement(),
notifier);
}
for(ExecutableNode child : children) {
child.execute(notifier, minPriority, ongoingRuleChain);
}
}
};
}
示例4: ExpectedDeploymentException
import org.junit.rules.RuleChain; //导入依赖的package包/类
private ExpectedDeploymentException() {
chain = RuleChain
.outerRule(log)
.around((base, description) -> new Statement() {
@Override
public void evaluate() {
try {
base.evaluate();
} catch (Throwable exception) {
assertThat(exception, allOf(pecs(exceptions)));
try {
// OpenWebBeans logs the deployment exception details
// TODO: OpenWebBeans only log the root cause of exception thrown in producer methods
//assertThat(log.getMessages(), containsInRelativeOrder(pecs(messages)))
assertThat(log.getMessages(), anyOf(hasItems(messages)));
} catch (AssertionError error) {
// Weld stores the deployment exception details in the exception message
assertThat(exception.getMessage(), allOf(pecs(messages)));
}
}
}
});
}
示例5: createTestRule
import org.junit.rules.RuleChain; //导入依赖的package包/类
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();
}
});
}
示例6: createTestRule
import org.junit.rules.RuleChain; //导入依赖的package包/类
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();
}
});
}
示例7: createTestRule
import org.junit.rules.RuleChain; //导入依赖的package包/类
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();
}
});
}
示例8: createTestRule
import org.junit.rules.RuleChain; //导入依赖的package包/类
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();
}
});
}
示例9: setupRuleChain
import org.junit.rules.RuleChain; //导入依赖的package包/类
/**
* 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);
}
示例10: getAllResourcesRule
import org.junit.rules.RuleChain; //导入依赖的package包/类
public static RuleChain getAllResourcesRule(int timeout) {
if (allResourcesRule == null) {
allResourcesRule = RuleChain
.outerRule(new Timeout(timeout))
.around(CLUSTER_RESOURCE);
}
return allResourcesRule;
}
示例11: getAllResourcesRule
import org.junit.rules.RuleChain; //导入依赖的package包/类
public static RuleChain getAllResourcesRule(int timeout) {
if (allResourcesRule == null) {
allResourcesRule = RuleChain
.outerRule(FOLDER)
.around(new Timeout(timeout))
.around(new EmbeddedKafkaRule(FOLDER, "mainKafka", 3, 2181, 9092))
.around(new EmbeddedKafkaRule(FOLDER, "drKafka", 3, 2182, 9096))
.around(SUPER_CLUSTER_RESOURCE)
.around(MAIN_CLUSTER_RESOURCE)
.around(DR_CLUSTER_RESOURCE);
}
return allResourcesRule;
}
示例12: SeleniumRule
import org.junit.rules.RuleChain; //导入依赖的package包/类
/**
* @param parameterObjects objects wich can be injected into {@link SeleniumProvider} implementations.
* See {@link SeleniumProviderFactory}
*/
public SeleniumRule(ParameterObject... parameterObjects) {
ParameterObject[] allParameterObjects =
ArrayUtils.addAll(parameterObjects, new ParameterObject(firefoxConfiguration.getClass(), firefoxConfiguration));
defaultSeleniumProvider = SeleniumProviderFactory.createSeleniumProviderRule(allParameterObjects);
defaultSeleniumProvider.addWebDriverConfigurationParticipant(new FileDetectorConfigurator<>());
defaultSeleniumProvider.addWebDriverConfigurationParticipant(timeoutsConfigurationParticipant);
DefaultFirefoxConfigurationParticipant<D> defaultFirefoxConfigurationParticipant =
new DefaultFirefoxConfigurationParticipant<>();
defaultSeleniumProvider.addWebDriverConfigurationParticipant(defaultFirefoxConfigurationParticipant);
firefoxConfiguration.addFirefoxConfigurationParticipant(defaultFirefoxConfigurationParticipant);
JavascriptError<P, D> javascriptErrorRule =
new JavascriptError<>(defaultSeleniumProvider, false);
firefoxConfiguration.addFirefoxConfigurationParticipant(javascriptErrorRule);
WebDriverLog<P, D> webDriverLog = new WebDriverLog<>(defaultSeleniumProvider);
PageSource pageSource = new PageSource(defaultSeleniumProvider);
screenshotRule = new ScreenshotRule(defaultSeleniumProvider)
.setScreenshotProvider(new DefaultScreenshotProvider());
JavascriptAlert javascriptAlert = new JavascriptAlert(defaultSeleniumProvider);
ruleChain = RuleChain
.outerRule(defaultSeleniumProvider)
.around(webDriverLog)
.around(pageSource)
.around(screenshotRule)
.around(javascriptAlert)
.around(javascriptErrorRule)
.around(resourceHelper);
}
示例13: apply
import org.junit.rules.RuleChain; //导入依赖的package包/类
@Override
public Statement apply(Statement base, Description description) {
return RuleChain
.outerRule(logContext)
.around(ruleChain)
.apply(base,description);
}
示例14: RegisterRule
import org.junit.rules.RuleChain; //导入依赖的package包/类
public RegisterRule() {
this.appRule = new DropwizardAppRule<>(RegisterApplication.class,
ResourceHelpers.resourceFilePath("test-app-config.yaml"));
wipeRule = new WipeDatabaseRule(TestRegister.values());
wholeRule = RuleChain
.outerRule(appRule)
.around(wipeRule);
}
示例15: rules
import org.junit.rules.RuleChain; //导入依赖的package包/类
public TestRule rules() {
if (System.getProperty(ACCTEST_BASEURI_PROPERTY) == null) {
return RuleChain
.outerRule(databaseContext.rules())
.around(appRule);
} else {
return new TestRule() {
@Override
public Statement apply(final Statement base, final Description description) {
return base;
}
};
}
}