本文整理汇总了Java中org.junit.AssumptionViolatedException类的典型用法代码示例。如果您正苦于以下问题:Java AssumptionViolatedException类的具体用法?Java AssumptionViolatedException怎么用?Java AssumptionViolatedException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AssumptionViolatedException类属于org.junit包,在下文中一共展示了AssumptionViolatedException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: evaluate
import org.junit.AssumptionViolatedException; //导入依赖的package包/类
@Override
public void evaluate() throws Throwable {
ProducedValues marker = method.getAnnotation(ProducedValues.class);
ProducerAssignments assignments = ProducerAssignments.allUnassigned(testClass, method.getMethod());
int iterations = marker == null ? 1 : marker.iterations();
for (int i = 0; i < iterations; i++) {
try {
new AssignmentsStatement(testClass.getJavaClass(), method, assignments, i).evaluate();
success++;
} catch (AssumptionViolatedException e) {
failedAssumptions.add(e);
}
}
if (success == 0) {
fail("Never found parameters that satisfied method assumptions. Violated assumptions: "
+ failedAssumptions);
}
}
示例2: before
import org.junit.AssumptionViolatedException; //导入依赖的package包/类
@Override
protected void before() throws Throwable {
if (runtimeMode == RuntimeMode.REQUIRE_RUNNING_INSTANCE) {
if (!CassandraSocket.isConnectable(getHost(), getPort())) {
throw new AssumptionViolatedException(
String.format("Cassandra is not reachable at %s:%s.", getHost(), getPort()));
}
}
if (runtimeMode == RuntimeMode.EMBEDDED_IF_NOT_RUNNING) {
if (CassandraSocket.isConnectable(getHost(), getPort())) {
return;
}
}
EmbeddedCassandraServerHelper.startEmbeddedCassandra("embedded-cassandra.yaml");
super.before();
}
示例3: whenDockerClientCantBeCreatedAnAssumptionExceptionIsThrown
import org.junit.AssumptionViolatedException; //导入依赖的package包/类
@Test
public void whenDockerClientCantBeCreatedAnAssumptionExceptionIsThrown() throws NoSuchMethodException, NoSuchFieldException, IllegalAccessException, InvocationTargetException {
destroyDockerClientFactoryInstance();
GenericContainerRule genericContainerRule = new GenericContainerRule(() -> new GenericContainer()).assumeDockerIsPresent();
boolean assumptionExceptionOccurred = false;
try {
genericContainerRule.apply(null,null).evaluate();
} catch (AssumptionViolatedException ave) {
assumptionExceptionOccurred = true;
} catch (Throwable throwable) {
throwable.printStackTrace();
} finally {
unDestroyDockerClientFactoryInstance();
}
assertThat(assumptionExceptionOccurred).isTrue().as("AssumptionException was thrown");
}
示例4: throwOnIgnoreTest
import org.junit.AssumptionViolatedException; //导入依赖的package包/类
protected Statement throwOnIgnoreTest(Statement statement, Description description) {
if (isTest(description)) {
boolean ignoreTest = false;
String message = "";
IgnoreUntil testCaseAnnotation = description.getAnnotation(IgnoreUntil.class);
if (testCaseAnnotation != null) {
ignoreTest = evaluate(testCaseAnnotation, description);
message = testCaseAnnotation.value();
} else if (description.getTestClass().isAnnotationPresent(IgnoreUntil.class)) {
IgnoreUntil testClassAnnotation =
description.getTestClass().getAnnotation(IgnoreUntil.class);
ignoreTest = evaluate(testClassAnnotation, description);
message = testClassAnnotation.value();
}
if (ignoreTest) {
throw new AssumptionViolatedException(format(message, description));
}
}
return statement;
}
示例5: throwOnIgnoreTest
import org.junit.AssumptionViolatedException; //导入依赖的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;
}
示例6: prepareMethodBlock
import org.junit.AssumptionViolatedException; //导入依赖的package包/类
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());
}
}
};
}
示例7: process
import org.junit.AssumptionViolatedException; //导入依赖的package包/类
protected void process(String data) throws Exception {
IInjectorProvider delegate = getOrCreateInjectorProvider().getDelegate();
if (delegate instanceof IRegistryConfigurator) {
IRegistryConfigurator registryConfigurator = (IRegistryConfigurator) delegate;
registryConfigurator.setupRegistry();
try {
ScenarioProcessor processor = delegate.getInjector().getInstance(processorClass);
String preProcessed = processor.preProcess(data);
if (preProcessed == null) {
throw new AssumptionViolatedException("Input is filtered by the pre processing step: " + data);
}
doProcess(preProcessed, processor);
} finally {
registryConfigurator.restoreRegistry();
}
}
}
示例8: createSender
import org.junit.AssumptionViolatedException; //导入依赖的package包/类
@Override protected Sender createSender() throws Exception {
RabbitMQSender result = RabbitMQSender.newBuilder()
.queue("zipkin-jmh")
.addresses("localhost:5672").build();
CheckResult check = result.check();
if (!check.ok()) {
throw new AssumptionViolatedException(check.error().getMessage(), check.error());
}
channel = result.get().createChannel();
channel.queueDelete(result.queue());
channel.queueDeclare(result.queue(), false, true, true, null);
Thread.sleep(500L);
new Thread(() -> {
try {
channel.basicConsume(result.queue(), true, new DefaultConsumer(channel));
} catch (IOException e) {
e.printStackTrace();
}
}).start();
return result;
}
示例9: useTimeoutEventDescriptionForMessage
import org.junit.AssumptionViolatedException; //导入依赖的package包/类
@Test
public void useTimeoutEventDescriptionForMessage() throws Exception {
String theMessage = "last result";
Mockito.doReturn(theMessage).when(event).getLastResult();
expectedException.expect(RuntimeException.class);
expectedException.expectCause(allOf(
Matchers.<Throwable>instanceOf(AssumptionViolatedException.class),
applying(messageFunction(),
allOf(
containsString(failureMessage),
containsString(theMessage),
containsString(matcherDescription)
))
));
try {
timeoutExceptionFunction.apply(event);
} catch (AssumptionViolatedException e) {
throw new RuntimeException(e);
}
}
示例10: apply
import org.junit.AssumptionViolatedException; //导入依赖的package包/类
@Override
public Statement apply(final Statement base, Description description) {
return new Statement() {
@Override
public void evaluate() throws Throwable {
try {
base.evaluate();
} catch (IOException e) {
if (isOffline()) {
throw new AssumptionViolatedException("offline", e);
}
else {
throw e;
}
}
}
};
}
示例11: compute
import org.junit.AssumptionViolatedException; //导入依赖的package包/类
@Override protected ElasticsearchHttpStorage compute() {
try {
container = new GenericContainer(image)
.withExposedPorts(9200)
.withEnv("ES_JAVA_OPTS", "-Dmapper.allow_dots_in_name=true -Xms512m -Xmx512m")
.waitingFor(new HttpWaitStrategy().forPath("/"));
container.start();
if (Boolean.valueOf(System.getenv("ES_DEBUG"))) {
container.followOutput(new Slf4jLogConsumer(LoggerFactory.getLogger(image)));
}
System.out.println("Starting docker image " + image);
} catch (RuntimeException e) {
// Ignore
}
ElasticsearchHttpStorage result = computeStorageBuilder().build();
CheckResult check = result.check();
if (check.ok()) {
return result;
} else {
throw new AssumptionViolatedException(check.error().getMessage(), check.error());
}
}
示例12: testDeclareAndCallUF
import org.junit.AssumptionViolatedException; //导入依赖的package包/类
@Test
public void testDeclareAndCallUF() {
List<String> names = ImmutableList.of("Func", "|Func|", "(Func)");
for (String name : names) {
Formula f;
try {
f =
fmgr.declareAndCallUF(
name, FormulaType.IntegerType, ImmutableList.of(imgr.makeNumber(1)));
} catch (RuntimeException e) {
if (name.equals("|Func|")) {
throw new AssumptionViolatedException("unsupported UF name", e);
} else {
throw e;
}
}
FunctionDeclaration<?> declaration = getDeclaration(f);
Truth.assertThat(declaration.getName()).isEqualTo(name);
Formula f2 = mgr.makeApplication(declaration, imgr.makeNumber(1));
Truth.assertThat(f2).isEqualTo(f);
}
}
示例13: getBaseConfiguration
import org.junit.AssumptionViolatedException; //导入依赖的package包/类
@Override
public Map<String, Object> getBaseConfiguration(String graphName, Class<?> test, String testMethodName, LoadGraphWith.GraphData loadGraphWith) {
if (IGNORED_TESTS.containsKey(test) && IGNORED_TESTS.get(test).contains(testMethodName))
throw new AssumptionViolatedException("We allow mixed ids");
if (testMethodName.contains("graphson-v2-embedded"))
throw new AssumptionViolatedException("graphson-v2-embedded support not implemented");
HashMap<String, Object> configs = new HashMap<String, Object>();
configs.put(Graph.GRAPH, OrientGraph.class.getName());
configs.put("name", graphName);
if (testMethodName.equals("shouldPersistDataOnClose"))
configs.put(OrientGraph.CONFIG_URL, "memory:test-" + graphName + "-" + test.getSimpleName() + "-" + testMethodName);
Random random = new Random();
if (random.nextBoolean())
configs.put(OrientGraph.CONFIG_POOL_SIZE, random.nextInt(10) + 1);
return configs;
}
示例14: getEventBus
import org.junit.AssumptionViolatedException; //导入依赖的package包/类
/**
* Get the event bus that's being used in the app.
*
* @return The event bus.
* @throws AssumptionViolatedException If the default event bus can't be constructed because of
* the Android framework not being loaded. This will stop the calling tests from being reported
* as failures.
*/
@NonNull
private static EventBus getEventBus() {
try {
return EventBus.getDefault();
} catch (RuntimeException e) {
/* The event bus uses the Looper from the Android framework, so
* initializing it would throw a runtime exception if the
* framework is not loaded. Nor can RoboGuice be used to inject
* a mocked instance to get around this issue, since customizing
* RoboGuice injections requires a Context.
*
* Robolectric can't be used to solve this issue, because it
* doesn't support parameterized testing. The only solution that
* could work at the moment would be to make this an
* instrumented test suite.
*
* TODO: Mock the event bus when RoboGuice is replaced with
* another dependency injection framework, or when there is a
* Robolectric test runner available that support parameterized
* tests.
*/
throw new AssumptionViolatedException(
"Event bus requires Android framework", e, nullValue());
}
}
示例15: apply
import org.junit.AssumptionViolatedException; //导入依赖的package包/类
/**
* Implementation based on {@link TestWatcher}.
*/
@Override
public Statement apply(final Statement base, final Description description) {
return new Statement() {
@Override
public void evaluate() throws Throwable {
List<Throwable> errors = new ArrayList<Throwable>();
startingQuietly(description, errors);
try {
base.evaluate();
succeededQuietly(description, errors);
} catch (AssumptionViolatedException e) {
errors.add(e);
skippedQuietly(e, description, errors);
} catch (Throwable t) {
errors.add(t);
failedQuietly(t, description, errors);
} finally {
finishedQuietly(description, errors);
}
MultipleFailureException.assertEmpty(errors);
}
};
}