use of org.junit.AssumptionViolatedException in project xtext-core by eclipse.
the class AbstractScenarioRunner method methodBlock.
@Override
protected Statement methodBlock(final FrameworkMethod method) {
IInjectorProvider injectorProvider = getOrCreateInjectorProvider();
final IRegistryConfigurator registryConfigurator = (IRegistryConfigurator) injectorProvider;
registryConfigurator.setupRegistry();
final Statement methodBlock = superMethodBlock(method);
return new Statement() {
@Override
public void evaluate() throws Throwable {
try {
try {
methodBlock.evaluate();
throw new AssumptionViolatedException("Method " + method.getName() + " did parse any input");
} finally {
registryConfigurator.restoreRegistry();
}
} catch (TestDataCarrier testData) {
process(testData.getData());
}
}
};
}
use of org.junit.AssumptionViolatedException in project xtext-core by eclipse.
the class AbstractParallelScenarioRunner method prepareMethodBlock.
protected Statement prepareMethodBlock(final FrameworkMethod method, final RunNotifier notifier) {
final Statement methodBlock = superMethodBlock(method);
return new Statement() {
@Override
public void evaluate() throws Throwable {
try {
methodBlock.evaluate();
Description description = describeChild(method);
try {
notifier.fireTestStarted(description);
notifier.fireTestAssumptionFailed(new Failure(description, new AssumptionViolatedException("Method " + method.getName() + " did parse any input")));
} finally {
notifier.fireTestFinished(description);
}
} catch (TestDataCarrier testData) {
AbstractParallelScenarioRunner.this.testData.put(method, testData.getData());
}
}
};
}
use of org.junit.AssumptionViolatedException in project sonarqube by SonarSource.
the class CoreTestDb method init.
private CoreTestDb init(@Nullable String schemaPath, boolean databaseToUpper) {
Consumer<Settings> noExtraSettingsLoaded = settings -> {
};
Function<Settings, Database> databaseCreator = settings -> {
String dialect = settings.getString("sonar.jdbc.dialect");
// test relying on CoreTestDb can only run on H2
if (dialect != null && !"h2".equals(dialect)) {
throw new AssumptionViolatedException("This test is intended to be run on H2 only");
}
String name = "h2Tests-" + (schemaPath == null ? "empty" : DigestUtils.md5Hex(schemaPath));
if (!databaseToUpper) {
name = name + ";DATABASE_TO_UPPER=FALSE";
}
name = name + ";NON_KEYWORDS=VALUE";
return new CoreH2Database(name);
};
Consumer<Database> databaseInitializer = database -> {
if (schemaPath == null) {
return;
}
((CoreH2Database) database).executeScript(schemaPath);
};
BiConsumer<Database, Boolean> noPostStartAction = (db, created) -> {
};
init(noExtraSettingsLoaded, databaseCreator, databaseInitializer, noPostStartAction);
return this;
}
use of org.junit.AssumptionViolatedException in project sonarqube by SonarSource.
the class TestDbImpl method init.
private void init(@Nullable String schemaPath, MyBatisConfExtension[] confExtensions) {
Consumer<Settings> loadOrchestratorSettings = OrchestratorSettingsUtils::loadOrchestratorSettings;
Function<Settings, Database> databaseCreator = settings -> {
String dialect = settings.getString("sonar.jdbc.dialect");
if (dialect != null && !"h2".equals(dialect)) {
return new DefaultDatabase(new LogbackHelper(), settings);
}
return SQDatabase.newH2Database("h2Tests" + DigestUtils.md5Hex(StringUtils.defaultString(schemaPath)), schemaPath == null);
};
Consumer<Database> schemaPathExecutor = database -> {
if (schemaPath == null) {
return;
}
// scripts are assumed to be using H2 specific syntax, ignore the test if not on H2
if (!database.getDialect().getId().equals("h2")) {
database.stop();
throw new AssumptionViolatedException("This test is intended to be run on H2 only");
}
((SQDatabase) database).executeScript(schemaPath);
};
BiConsumer<Database, Boolean> createMyBatis = (db, created) -> myBatis = newMyBatis(db, confExtensions);
init(loadOrchestratorSettings, databaseCreator, schemaPathExecutor, createMyBatis);
}
use of org.junit.AssumptionViolatedException in project xtext-eclipse by eclipse.
the class AbstractParallelScenarioRunner method prepareMethodBlock.
protected Statement prepareMethodBlock(final FrameworkMethod method, final RunNotifier notifier) {
final Statement methodBlock = superMethodBlock(method);
return new Statement() {
@Override
public void evaluate() throws Throwable {
try {
methodBlock.evaluate();
Description description = describeChild(method);
try {
notifier.fireTestStarted(description);
notifier.fireTestAssumptionFailed(new Failure(description, new AssumptionViolatedException("Method " + method.getName() + " did parse any input")));
} finally {
notifier.fireTestFinished(description);
}
} catch (TestDataCarrier testData) {
AbstractParallelScenarioRunner.this.testData.put(method, testData.getData());
}
}
};
}
Aggregations