use of org.junit.AssumptionViolatedException in project mongo-java-driver by mongodb.
the class JsonPoweredCrudTestHelper method getOperationResults.
BsonDocument getOperationResults(final BsonDocument operation) {
String name = operation.getString("name").getValue();
BsonDocument arguments = operation.getDocument("arguments");
String methodName = "get" + name.substring(0, 1).toUpperCase() + name.substring(1) + "Result";
try {
Method method = getClass().getDeclaredMethod(methodName, BsonDocument.class);
return (BsonDocument) method.invoke(this, arguments);
} catch (NoSuchMethodException e) {
throw new UnsupportedOperationException("No handler for operation " + methodName);
} catch (InvocationTargetException e) {
if (e.getTargetException() instanceof AssumptionViolatedException) {
throw (AssumptionViolatedException) e.getTargetException();
}
if (e.getTargetException() instanceof MongoException) {
throw (MongoException) e.getTargetException();
}
throw (RuntimeException) e.getTargetException();
} catch (IllegalAccessException e) {
throw new UnsupportedOperationException("Invalid handler access for operation " + methodName);
}
}
use of org.junit.AssumptionViolatedException in project zipkin by openzipkin.
the class LazyElasticsearchHttpStorage method compute.
@Override
protected ElasticsearchHttpStorage compute() {
try {
container = new GenericContainer(image).withExposedPorts(9200).waitingFor(new HttpWaitStrategy().forPath("/"));
container.start();
System.out.println("Will use TestContainers Elasticsearch instance");
} catch (Exception e) {
// Ignore
}
ElasticsearchHttpStorage result = computeStorageBuilder().build();
Component.CheckResult check = result.check();
if (check.ok) {
return result;
} else {
throw new AssumptionViolatedException(check.exception.getMessage(), check.exception);
}
}
use of org.junit.AssumptionViolatedException in project zipkin by openzipkin.
the class LazyElasticsearchTransportStorage method compute.
@Override
protected ElasticsearchStorage compute() {
try {
container = new GenericContainer(image).withExposedPorts(9200, 9300).waitingFor(new HttpWaitStrategy().forPath("/"));
container.start();
System.out.println("Will use TestContainers Elasticsearch instance");
} catch (Exception e) {
// Ignore
}
ElasticsearchStorage result = computeStorageBuilder().build();
Component.CheckResult check = result.check();
if (check.ok) {
return result;
} else {
throw new AssumptionViolatedException(check.exception.getMessage(), check.exception);
}
}
use of org.junit.AssumptionViolatedException in project zipkin by openzipkin.
the class LazyElasticsearchHttpStorage method compute.
@Override
protected ElasticsearchStorage compute() {
try {
container = new GenericContainer(image).withExposedPorts(9200).waitingFor(new HttpWaitStrategy().forPath("/"));
container.start();
System.out.println("Will use TestContainers Elasticsearch instance");
} catch (Exception e) {
// Ignore
}
ElasticsearchStorage result = computeStorageBuilder().build();
Component.CheckResult check = result.check();
if (check.ok) {
return result;
} else {
throw new AssumptionViolatedException(check.exception.getMessage(), check.exception);
}
}
use of org.junit.AssumptionViolatedException in project geode by apache.
the class ConditionalIgnoreRule method throwOnIgnoreTest.
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;
}
Aggregations