use of org.junit.AssumptionViolatedException in project netty by netty.
the class JdkSslEngineTest method testTlsExtensionNoCompatibleProtocolsClientHandshakeFailure.
@MethodSource("newJdkParams")
@ParameterizedTest
public void testTlsExtensionNoCompatibleProtocolsClientHandshakeFailure(JdkSSLEngineTestParam param) throws Exception {
try {
param.providerType.activate(this);
if (param.providerType == ProviderType.NPN_JETTY) {
ApplicationProtocolConfig clientApn = failingNegotiator(param.providerType.protocol(), PREFERRED_APPLICATION_LEVEL_PROTOCOL);
ApplicationProtocolConfig serverApn = acceptingNegotiator(param.providerType.protocol(), APPLICATION_LEVEL_PROTOCOL_NOT_COMPATIBLE);
setupHandlers(param, serverApn, clientApn);
assertTrue(clientLatch.await(2, TimeUnit.SECONDS));
assertTrue(clientException instanceof SSLHandshakeException);
} else {
// ALPN
SelfSignedCertificate ssc = new SelfSignedCertificate();
JdkApplicationProtocolNegotiator clientApn = new JdkAlpnApplicationProtocolNegotiator(true, true, PREFERRED_APPLICATION_LEVEL_PROTOCOL);
JdkApplicationProtocolNegotiator serverApn = new JdkAlpnApplicationProtocolNegotiator(new ProtocolSelectorFactory() {
@Override
public ProtocolSelector newSelector(SSLEngine engine, Set<String> supportedProtocols) {
return new ProtocolSelector() {
@Override
public void unsupported() {
}
@Override
public String select(List<String> protocols) {
return APPLICATION_LEVEL_PROTOCOL_NOT_COMPATIBLE;
}
};
}
}, JdkBaseApplicationProtocolNegotiator.FAIL_SELECTION_LISTENER_FACTORY, APPLICATION_LEVEL_PROTOCOL_NOT_COMPATIBLE);
SslContext serverSslCtx = new JdkSslServerContext(param.providerType.provider(), ssc.certificate(), ssc.privateKey(), null, null, IdentityCipherSuiteFilter.INSTANCE, serverApn, 0, 0, null);
SslContext clientSslCtx = new JdkSslClientContext(param.providerType.provider(), null, InsecureTrustManagerFactory.INSTANCE, null, IdentityCipherSuiteFilter.INSTANCE, clientApn, 0, 0);
setupHandlers(param.type(), param.delegate(), new TestDelegatingSslContext(param, serverSslCtx), new TestDelegatingSslContext(param, clientSslCtx));
assertTrue(clientLatch.await(2, TimeUnit.SECONDS));
// When using TLSv1.3 the handshake is NOT sent in an extra round trip which means there will be
// no exception reported in this case but just the channel will be closed.
assertTrue(clientException instanceof SSLHandshakeException || clientException == null);
}
} catch (SkipTestException e) {
// java version incompatibility don't fail the test, but instead just skip the test
throw new AssumptionViolatedException("Not expected", e);
}
}
use of org.junit.AssumptionViolatedException in project java-sdk by watson-developer-cloud.
the class NaturalLanguageClassifierIT method bGetClassifier.
/**
* Test get classifier.
*/
@Test
public void bGetClassifier() {
final Classifier classifier;
try {
GetClassifierOptions getOptions = new GetClassifierOptions.Builder().classifierId(classifierId).build();
classifier = service.getClassifier(getOptions).execute();
} catch (NotFoundException e) {
// The build should not fail here, because this is out of our control.
throw new AssumptionViolatedException(e.getMessage(), e);
}
assertNotNull(classifier);
assertEquals(classifierId, classifier.getClassifierId());
assertEquals(Classifier.Status.TRAINING, classifier.getStatus());
}
use of org.junit.AssumptionViolatedException in project flink by apache.
the class SocketClientSinkTest method testRetry.
@Test
public void testRetry() throws Exception {
final ServerSocket[] serverSocket = new ServerSocket[1];
final ExecutorService[] executor = new ExecutorService[1];
try {
serverSocket[0] = new ServerSocket(0);
executor[0] = Executors.newCachedThreadPool();
int port = serverSocket[0].getLocalPort();
Callable<Void> serverTask = new Callable<Void>() {
@Override
public Void call() throws Exception {
Socket socket = NetUtils.acceptWithoutTimeout(serverSocket[0]);
BufferedReader reader = new BufferedReader(new InputStreamReader(socket.getInputStream()));
String value = reader.readLine();
assertEquals("0", value);
socket.close();
return null;
}
};
Future<Void> serverFuture = executor[0].submit(serverTask);
final SocketClientSink<String> sink = new SocketClientSink<>(host, serverSocket[0].getLocalPort(), simpleSchema, -1, true);
// Create the connection
sink.open(new Configuration());
// Initial payload => this will be received by the server an then the socket will be
// closed.
sink.invoke("0\n", SinkContextUtil.forTimestamp(0));
// Get future an make sure there was no problem. This will rethrow any Exceptions from
// the server.
serverFuture.get();
// Shutdown the server socket
serverSocket[0].close();
assertTrue(serverSocket[0].isClosed());
// No retries expected at this point
assertEquals(0, sink.getCurrentNumberOfRetries());
final CountDownLatch retryLatch = new CountDownLatch(1);
final CountDownLatch again = new CountDownLatch(1);
Callable<Void> sinkTask = new Callable<Void>() {
@Override
public Void call() throws Exception {
// connection.
while (retryLatch.getCount() != 0) {
sink.invoke("1\n");
}
return null;
}
};
Future<Void> sinkFuture = executor[0].submit(sinkTask);
while (sink.getCurrentNumberOfRetries() == 0) {
// Wait for a retry
Thread.sleep(100);
}
// OK the poor guy retried to write
retryLatch.countDown();
// Restart the server
try {
serverSocket[0] = new ServerSocket(port);
} catch (BindException be) {
// some other process may be using this port now
throw new AssumptionViolatedException("Could not bind server to previous port.", be);
}
Socket socket = NetUtils.acceptWithoutTimeout(serverSocket[0]);
BufferedReader reader = new BufferedReader(new InputStreamReader(socket.getInputStream()));
// Wait for the reconnect
String value = reader.readLine();
assertEquals("1", value);
// OK the sink re-connected. :)
} finally {
if (serverSocket[0] != null) {
serverSocket[0].close();
}
if (executor[0] != null) {
executor[0].shutdown();
}
}
}
use of org.junit.AssumptionViolatedException in project flink by apache.
the class NettyEpollITCase method trySetUpCluster.
private MiniClusterWithClientResource trySetUpCluster() throws Exception {
try {
Configuration config = new Configuration();
config.setString(NettyShuffleEnvironmentOptions.TRANSPORT_TYPE, "epoll");
MiniClusterWithClientResource cluster = new MiniClusterWithClientResource(new MiniClusterResourceConfiguration.Builder().setConfiguration(config).setNumberTaskManagers(NUM_TASK_MANAGERS).setNumberSlotsPerTaskManager(1).build());
cluster.before();
return cluster;
} catch (UnsatisfiedLinkError ex) {
// If we failed to init netty because we are not on Linux platform, abort the test.
if (findThrowableWithMessage(ex, "Only supported on Linux").isPresent()) {
throw new AssumptionViolatedException("This test is only supported on linux");
}
throw ex;
}
}
use of org.junit.AssumptionViolatedException in project flink by apache.
the class IPv6HostnamesITCase method getConfiguration.
private Configuration getConfiguration() {
final Inet6Address ipv6address = getLocalIPv6Address();
if (ipv6address == null) {
throw new AssumptionViolatedException("--- Cannot find a non-loopback local IPv6 address that Akka/Netty can bind to; skipping IPv6HostnamesITCase");
}
final String addressString = ipv6address.getHostAddress();
log.info("Test will use IPv6 address " + addressString + " for connection tests");
Configuration config = new Configuration();
config.setString(JobManagerOptions.ADDRESS, addressString);
config.setString(TaskManagerOptions.HOST, addressString);
config.set(TaskManagerOptions.MANAGED_MEMORY_SIZE, MemorySize.parse("16m"));
return config;
}
Aggregations