Search in sources :

Example 16 with AssumptionViolatedException

use of org.junit.AssumptionViolatedException in project netty by netty.

the class OpenSslEngineTest method testWrapWithDifferentSizes.

private void testWrapWithDifferentSizes(SSLEngineTestParam param, String protocol, String cipher) throws Exception {
    assumeTrue(OpenSsl.SUPPORTED_PROTOCOLS_SET.contains(protocol));
    if (!OpenSsl.isCipherSuiteAvailable(cipher)) {
        return;
    }
    SSLEngine clientEngine = null;
    SSLEngine serverEngine = null;
    try {
        clientEngine = wrapEngine(clientSslCtx.newEngine(UnpooledByteBufAllocator.DEFAULT));
        serverEngine = wrapEngine(serverSslCtx.newEngine(UnpooledByteBufAllocator.DEFAULT));
        clientEngine.setEnabledCipherSuites(new String[] { cipher });
        clientEngine.setEnabledProtocols(new String[] { protocol });
        serverEngine.setEnabledCipherSuites(new String[] { cipher });
        serverEngine.setEnabledProtocols(new String[] { protocol });
        try {
            handshake(param.type(), param.delegate(), clientEngine, serverEngine);
        } catch (SSLException e) {
            if (e.getMessage().contains("unsupported protocol") || e.getMessage().contains("no protocols available")) {
                throw new AssumptionViolatedException(protocol + " not supported with cipher " + cipher, e);
            }
            throw e;
        }
        int srcLen = 64;
        do {
            testWrapDstBigEnough(param.type(), clientEngine, srcLen);
            srcLen += 64;
        } while (srcLen < MAX_PLAINTEXT_LENGTH);
        testWrapDstBigEnough(param.type(), clientEngine, MAX_PLAINTEXT_LENGTH);
    } finally {
        cleanupClientSslEngine(clientEngine);
        cleanupServerSslEngine(serverEngine);
    }
}
Also used : AssumptionViolatedException(org.junit.AssumptionViolatedException) SSLEngine(javax.net.ssl.SSLEngine) SSLException(javax.net.ssl.SSLException)

Example 17 with AssumptionViolatedException

use of org.junit.AssumptionViolatedException in project netty by netty.

the class JdkSslEngineTest method testTlsExtensionNoCompatibleProtocolsNoHandshakeFailure.

@MethodSource("newJdkParams")
@ParameterizedTest
public void testTlsExtensionNoCompatibleProtocolsNoHandshakeFailure(JdkSSLEngineTestParam param) throws Exception {
    try {
        param.providerType.activate(this);
        ApplicationProtocolConfig clientApn = acceptingNegotiator(param.providerType.protocol(), PREFERRED_APPLICATION_LEVEL_PROTOCOL);
        ApplicationProtocolConfig serverApn = acceptingNegotiator(param.providerType.protocol(), APPLICATION_LEVEL_PROTOCOL_NOT_COMPATIBLE);
        setupHandlers(param, serverApn, clientApn);
        runTest(null);
    } catch (SkipTestException e) {
        // java version incompatibility don't fail the test, but instead just skip the test
        throw new AssumptionViolatedException("Not expected", e);
    }
}
Also used : AssumptionViolatedException(org.junit.AssumptionViolatedException) MethodSource(org.junit.jupiter.params.provider.MethodSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 18 with AssumptionViolatedException

use of org.junit.AssumptionViolatedException in project netty by netty.

the class JdkSslEngineTest method testTlsExtensionNoCompatibleProtocolsServerHandshakeFailure.

@MethodSource("newJdkParams")
@ParameterizedTest
public void testTlsExtensionNoCompatibleProtocolsServerHandshakeFailure(JdkSSLEngineTestParam param) throws Exception {
    try {
        param.providerType.activate(this);
        ApplicationProtocolConfig clientApn = acceptingNegotiator(param.providerType.protocol(), PREFERRED_APPLICATION_LEVEL_PROTOCOL);
        ApplicationProtocolConfig serverApn = failingNegotiator(param.providerType.protocol(), APPLICATION_LEVEL_PROTOCOL_NOT_COMPATIBLE);
        setupHandlers(param, serverApn, clientApn);
        assertTrue(serverLatch.await(2, TimeUnit.SECONDS));
        assertTrue(serverException instanceof SSLHandshakeException);
    } catch (SkipTestException e) {
        // java version incompatibility don't fail the test, but instead just skip the test
        throw new AssumptionViolatedException("Not expected", e);
    }
}
Also used : AssumptionViolatedException(org.junit.AssumptionViolatedException) SSLHandshakeException(javax.net.ssl.SSLHandshakeException) MethodSource(org.junit.jupiter.params.provider.MethodSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 19 with AssumptionViolatedException

use of org.junit.AssumptionViolatedException in project netty by netty.

the class JdkSslEngineTest method testTlsExtension.

@MethodSource("newJdkParams")
@ParameterizedTest
public void testTlsExtension(JdkSSLEngineTestParam param) throws Exception {
    try {
        param.providerType.activate(this);
        ApplicationProtocolConfig apn = failingNegotiator(param.providerType.protocol(), PREFERRED_APPLICATION_LEVEL_PROTOCOL);
        setupHandlers(param, apn);
        runTest();
    } catch (SkipTestException e) {
        // java version incompatibility don't fail the test, but instead just skip the test
        throw new AssumptionViolatedException("Not expected", e);
    }
}
Also used : AssumptionViolatedException(org.junit.AssumptionViolatedException) MethodSource(org.junit.jupiter.params.provider.MethodSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 20 with AssumptionViolatedException

use of org.junit.AssumptionViolatedException in project randomizedtesting by randomizedtesting.

the class RandomizedRunner method reportAsIgnored.

void reportAsIgnored(RunNotifier notifier, GroupEvaluator ge, TestCandidate c) {
    if (c.method.getAnnotation(Ignore.class) != null) {
        notifier.fireTestIgnored(c.description);
        return;
    }
    String ignoreReason = ge.getIgnoreReason(c.method, suiteClass);
    if (ignoreReason != null) {
        notifier.fireTestStarted(c.description);
        notifier.fireTestAssumptionFailed(new Failure(c.description, new AssumptionViolatedException(ignoreReason)));
        notifier.fireTestFinished(c.description);
    }
}
Also used : Ignore(org.junit.Ignore) AssumptionViolatedException(org.junit.AssumptionViolatedException) Failure(org.junit.runner.notification.Failure)

Aggregations

AssumptionViolatedException (org.junit.AssumptionViolatedException)79 Test (org.junit.Test)26 IOException (java.io.IOException)16 Statement (org.junit.runners.model.Statement)9 ByteArrayOutputStream (java.io.ByteArrayOutputStream)6 Method (java.lang.reflect.Method)6 Set (java.util.Set)6 ByteArrayInputStream (java.io.ByteArrayInputStream)5 File (java.io.File)5 CountDownLatch (java.util.concurrent.CountDownLatch)5 ZipEntry (java.util.zip.ZipEntry)5 ZipOutputStream (java.util.zip.ZipOutputStream)5 InputStream (java.io.InputStream)4 HashSet (java.util.HashSet)4 ZipInputStream (java.util.zip.ZipInputStream)4 FilterInputStream (java.io.FilterInputStream)3 UnknownHostException (java.net.UnknownHostException)3 JarInputStream (java.util.jar.JarInputStream)3 Configuration (org.apache.flink.configuration.Configuration)3 IInjectorProvider (org.eclipse.xtext.junit4.IInjectorProvider)3