use of org.junit.AssumptionViolatedException in project pinpoint by naver.
the class SocketAddressUtilsTest method setNameServiceFieldValue.
private static void setNameServiceFieldValue(String fieldName, Object nameService) {
try {
Field nameServiceField = InetAddress.class.getDeclaredField(fieldName);
nameServiceField.setAccessible(true);
nameServiceField.set(null, nameService);
} catch (NoSuchFieldException e) {
throw new IllegalStateException("Expected field : [" + fieldName + "] not found");
} catch (Exception e) {
LOGGER.error("[{}] {} - Unexpected error while setting field [{}], skipping test", JvmUtils.getType(), JvmUtils.getVersion(), fieldName, e);
throw new AssumptionViolatedException("Unexpected reflection exception", e);
}
}
use of org.junit.AssumptionViolatedException in project pinpoint by naver.
the class SocketAddressUtilsTest method getNameServiceFieldValue.
private static Object getNameServiceFieldValue(String fieldName) {
try {
Field nameServiceField = InetAddress.class.getDeclaredField(fieldName);
nameServiceField.setAccessible(true);
return nameServiceField.get(null);
} catch (NoSuchFieldException e) {
// This can happen depending on jvm
return null;
} catch (Exception e) {
LOGGER.error("[{}] {} - Unexpected error while getting field [{}], skipping test", JvmUtils.getType(), JvmUtils.getVersion(), fieldName, e);
throw new AssumptionViolatedException("Unexpected reflection exception", e);
}
}
use of org.junit.AssumptionViolatedException in project instrumentation-java by census-instrumentation.
the class JaegerExporterHandlerIntegrationTest method startContainer.
/**
* Starts a docker container optionally. For example, skips if Docker is unavailable.
*/
@SuppressWarnings("rawtypes")
@BeforeClass
public static void startContainer() {
try {
container = new GenericContainer(JAEGER_IMAGE).withExposedPorts(JAEGER_HTTP_PORT, JAEGER_HTTP_PORT_THRIFT).waitingFor(new HttpWaitStrategy());
container.start();
} catch (RuntimeException e) {
throw new AssumptionViolatedException("could not start docker container", e);
}
}
use of org.junit.AssumptionViolatedException in project alluxio by Alluxio.
the class BaseIntegrationTest method logHandler.
private TestWatcher logHandler() {
return new TestWatcher() {
private String mLogPath;
private Appender mAppender;
@Override
protected void starting(Description description) {
try {
mLogPath = logPath(description);
// In case the file already exists, truncate it.
new FileWriter(mLogPath).close();
mAppender = new FileAppender(new PatternLayout("%d{ISO8601} [%t] %-5p %c{2} (%F:%M) - %m%n"), mLogPath);
LogManager.getRootLogger().addAppender(mAppender);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
@Override
protected void succeeded(Description description) {
try {
Files.delete(Paths.get(mLogPath));
} catch (Throwable t) {
LOG.error("Failed to delete success log file {}", mLogPath);
}
}
@Override
protected void skipped(AssumptionViolatedException e, Description description) {
succeeded(description);
}
@Override
protected void finished(Description description) {
LogManager.getRootLogger().removeAppender(mAppender);
}
private String logPath(Description description) {
String basename = String.format("tests-%s-%s.log", description.getClassName(), description.getMethodName());
return PathUtils.concatPath(Constants.TEST_LOG_DIR, basename);
}
};
}
use of org.junit.AssumptionViolatedException in project netty by netty.
the class JdkSslEngineTest method testAlpnCompatibleProtocolsDifferentClientOrder.
@MethodSource("newJdkParams")
@ParameterizedTest
public void testAlpnCompatibleProtocolsDifferentClientOrder(JdkSSLEngineTestParam param) throws Exception {
try {
param.providerType.activate(this);
if (param.providerType == ProviderType.NPN_JETTY) {
// This test only applies to ALPN.
throw tlsExtensionNotFound(param.providerType.protocol());
}
// Even the preferred application protocol appears second in the client's list, it will be picked
// because it's the first one on server's list.
ApplicationProtocolConfig clientApn = acceptingNegotiator(Protocol.ALPN, FALLBACK_APPLICATION_LEVEL_PROTOCOL, PREFERRED_APPLICATION_LEVEL_PROTOCOL);
ApplicationProtocolConfig serverApn = failingNegotiator(Protocol.ALPN, PREFERRED_APPLICATION_LEVEL_PROTOCOL, FALLBACK_APPLICATION_LEVEL_PROTOCOL);
setupHandlers(param, serverApn, clientApn);
assertNull(serverException);
runTest(PREFERRED_APPLICATION_LEVEL_PROTOCOL);
} catch (SkipTestException e) {
// java version incompatibility don't fail the test, but instead just skip the test
throw new AssumptionViolatedException("Not expected", e);
}
}
Aggregations