// - Only PortUnreachableException will allow to continue execution. // - SocketTimeoutException may occur on Mac because it will not throw // PortUnreachableException for unreachable port in which case the Test // execution will be skipped. // - For Reachable port, the Test execution will get skipped. // - Any other Exception will be treated as Test failure. if (!findPortUnreachableExc()) {
System.out.println(String.format("WARNING: Either a reachable "
+ "connection found to %s:%s or SocketTimeoutException "
+ "occured which means PortUnreachableException not thrown"
+ " by the platform.", HOST, PORT)); return;
}
KDC kdc = KDC.existing(REALM, HOST, PORT);
KDC.saveConfig(KRB_CONF, kdc);
ExecutorService executor = Executors.newSingleThreadExecutor();
Future<Exception> future = executor.submit(new Callable<Exception>() {
@Override public Exception call() {
System.setProperty("java.security.krb5.conf", KRB_CONF); try {
Config.refresh(); // If PortUnreachableException is not received, the login // will consume about 3*3*30 seconds and the test will // timeout. try {
Context.fromUserPass("name", "pass".toCharArray(), true);
} catch (LoginException le) { // This is OK
}
System.out.println("Execution successful.");
} catch (Exception e) { return e;
} returnnull;
}
}); try {
Exception ex = null; if ((ex = future.get(TIMEOUT, TimeUnit.SECONDS)) != null) { thrownew RuntimeException(ex);
}
} catch (TimeoutException e) {
future.cancel(true); thrownew RuntimeException("PortUnreachableException not thrown.");
} finally {
executor.shutdownNow();
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.