Search in sources :

Example 1 with AssumptionViolatedException

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);
    }
}
Also used : MongoException(com.mongodb.MongoException) BsonDocument(org.bson.BsonDocument) AssumptionViolatedException(org.junit.AssumptionViolatedException) Method(java.lang.reflect.Method) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 2 with AssumptionViolatedException

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);
    }
}
Also used : AssumptionViolatedException(org.junit.AssumptionViolatedException) HttpWaitStrategy(org.testcontainers.containers.wait.HttpWaitStrategy) ElasticsearchHttpStorage(zipkin.storage.elasticsearch.http.ElasticsearchHttpStorage) GenericContainer(org.testcontainers.containers.GenericContainer) Component(zipkin.Component) AssumptionViolatedException(org.junit.AssumptionViolatedException)

Example 3 with AssumptionViolatedException

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);
    }
}
Also used : AssumptionViolatedException(org.junit.AssumptionViolatedException) HttpWaitStrategy(org.testcontainers.containers.wait.HttpWaitStrategy) GenericContainer(org.testcontainers.containers.GenericContainer) Component(zipkin.Component) AssumptionViolatedException(org.junit.AssumptionViolatedException) IOException(java.io.IOException)

Example 4 with AssumptionViolatedException

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);
    }
}
Also used : AssumptionViolatedException(org.junit.AssumptionViolatedException) HttpWaitStrategy(org.testcontainers.containers.wait.HttpWaitStrategy) GenericContainer(org.testcontainers.containers.GenericContainer) Component(zipkin.Component) AssumptionViolatedException(org.junit.AssumptionViolatedException) IOException(java.io.IOException)

Example 5 with AssumptionViolatedException

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;
}
Also used : ConditionalIgnore(org.apache.geode.test.junit.ConditionalIgnore) AssumptionViolatedException(org.junit.AssumptionViolatedException)

Aggregations

AssumptionViolatedException (org.junit.AssumptionViolatedException)58 Test (org.junit.Test)15 IOException (java.io.IOException)10 Method (java.lang.reflect.Method)6 Set (java.util.Set)6 File (java.io.File)5 CountDownLatch (java.util.concurrent.CountDownLatch)5 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)5 MethodSource (org.junit.jupiter.params.provider.MethodSource)5 Statement (org.junit.runners.model.Statement)5 HashSet (java.util.HashSet)4 WatsonServiceTest (com.ibm.watson.developer_cloud.WatsonServiceTest)3 NotFoundException (com.ibm.watson.developer_cloud.service.exception.NotFoundException)3 ByteBuf (io.netty.buffer.ByteBuf)3 Unpooled (io.netty.buffer.Unpooled)3 io.vertx.core (io.vertx.core)3 Buffer (io.vertx.core.buffer.Buffer)3 AsyncFileImpl (io.vertx.core.file.impl.AsyncFileImpl)3 UnknownHostException (java.net.UnknownHostException)3 Configuration (org.apache.flink.configuration.Configuration)3