Search in sources :

Example 6 with AssumptionViolatedException

use of org.junit.AssumptionViolatedException in project spring-security by spring-projects.

the class CryptoAssumptions method assumeAes256.

private static void assumeAes256(CipherAlgorithm cipherAlgorithm) {
    boolean aes256Available = false;
    try {
        Cipher.getInstance(cipherAlgorithm.toString());
        aes256Available = Cipher.getMaxAllowedKeyLength("AES") >= 256;
    } catch (NoSuchAlgorithmException e) {
        throw new AssumptionViolatedException(cipherAlgorithm + " not available, skipping test", e);
    } catch (NoSuchPaddingException e) {
        throw new AssumptionViolatedException(cipherAlgorithm + " padding not available, skipping test", e);
    }
    Assume.assumeTrue("AES key length of 256 not allowed, skipping test", aes256Available);
}
Also used : AssumptionViolatedException(org.junit.AssumptionViolatedException) NoSuchPaddingException(javax.crypto.NoSuchPaddingException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException)

Example 7 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)

Example 8 with AssumptionViolatedException

use of org.junit.AssumptionViolatedException in project mongo-java-driver by mongodb.

the class CrudTest method getOperationMongoOperations.

private BsonDocument getOperationMongoOperations(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) + "MongoOperation";
    try {
        Method method = getClass().getDeclaredMethod(methodName, BsonDocument.class);
        return convertMongoOperationToResult(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();
        }
        throw new UnsupportedOperationException("Invalid handler for operation " + methodName);
    } catch (IllegalAccessException e) {
        throw new UnsupportedOperationException("Invalid handler access for operation " + methodName);
    }
}
Also used : BsonDocument(org.bson.BsonDocument) AssumptionViolatedException(org.junit.AssumptionViolatedException) Method(java.lang.reflect.Method) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 9 with AssumptionViolatedException

use of org.junit.AssumptionViolatedException in project geode by apache.

the class IgnoreUntilRule method throwOnIgnoreTest.

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

Example 10 with AssumptionViolatedException

use of org.junit.AssumptionViolatedException in project jackrabbit-oak by apache.

the class DocumentMongoFixture method createNodeStore.

@Override
public NodeStore createNodeStore() {
    try {
        String suffix = String.format("-%d-%d", System.currentTimeMillis(), sequence.incrementAndGet());
        DocumentMK.Builder builder = new DocumentMK.Builder();
        if (blobStore != null) {
            builder.setBlobStore(blobStore);
        }
        builder.setPersistentCache("target/persistentCache,time");
        builder.setMongoDB(getDb(suffix));
        DocumentNodeStore ns = builder.getNodeStore();
        suffixes.put(ns, suffix);
        return ns;
    } catch (Exception e) {
        throw new AssumptionViolatedException("Mongo instance is not available", e);
    }
}
Also used : AssumptionViolatedException(org.junit.AssumptionViolatedException) DocumentMK(org.apache.jackrabbit.oak.plugins.document.DocumentMK) DocumentNodeStore(org.apache.jackrabbit.oak.plugins.document.DocumentNodeStore) AssumptionViolatedException(org.junit.AssumptionViolatedException) UnknownHostException(java.net.UnknownHostException)

Aggregations

AssumptionViolatedException (org.junit.AssumptionViolatedException)12 IOException (java.io.IOException)3 GenericContainer (org.testcontainers.containers.GenericContainer)3 HttpWaitStrategy (org.testcontainers.containers.wait.HttpWaitStrategy)3 Component (zipkin.Component)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 Method (java.lang.reflect.Method)2 DocumentMK (org.apache.jackrabbit.oak.plugins.document.DocumentMK)2 DocumentNodeStore (org.apache.jackrabbit.oak.plugins.document.DocumentNodeStore)2 BsonDocument (org.bson.BsonDocument)2 DB (com.mongodb.DB)1 MongoException (com.mongodb.MongoException)1 BufferedInputStream (java.io.BufferedInputStream)1 BufferedReader (java.io.BufferedReader)1 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 InputStream (java.io.InputStream)1 InputStreamReader (java.io.InputStreamReader)1 UnknownHostException (java.net.UnknownHostException)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1