use of jdk.testlibrary.OutputAnalyzer in project jdk8u_jdk by JetBrains.
the class PortAlreadyInUseTest method go.
protected void go() throws Exception {
jmxPort = Utils.getFreePort();
occupyPort();
log.info("Attempting to start a VM using the same port.");
OutputAnalyzer out = this.runVM();
out.shouldContain("Port already in use");
log.info("Failed as expected.");
log.info("Trying again using retries.");
this.run();
}
use of jdk.testlibrary.OutputAnalyzer in project jdk8u_jdk by JetBrains.
the class DynamicLauncher method runVM.
protected OutputAnalyzer runVM() throws Exception {
String[] options = this.options();
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(options);
OutputAnalyzer out = new OutputAnalyzer(pb.start());
System.out.println(out.getStdout());
System.err.println(out.getStderr());
return out;
}
use of jdk.testlibrary.OutputAnalyzer in project jdk8u_jdk by JetBrains.
the class KinitConfPlusProps method checkTicketFlags.
// check if a ticket has forwardable and proxiable flags
private static boolean checkTicketFlags() {
String[] command = new String[] { KLIST, "-f", "-c", CC_FILENAME };
try {
OutputAnalyzer out = ProcessTools.executeCommand(command);
out.shouldHaveExitValue(0);
out.shouldContain("FORWARDABLE");
out.shouldContain("PROXIABLE");
} catch (Throwable e) {
System.out.println("Unexpected exception: " + e);
e.printStackTrace(System.out);
return false;
}
return true;
}
use of jdk.testlibrary.OutputAnalyzer in project jdk8u_jdk by JetBrains.
the class KinitConfPlusProps method main.
public static void main(String[] args) throws Exception {
// define principals
Map<String, String> principals = new HashMap<>();
principals.put(USER_PRINCIPAL, null);
principals.put(KRBTGT_PRINCIPAL, null);
System.setProperty("java.security.krb5.conf", KRB5_CONF_FILENAME);
// start a local KDC instance
KDC kdc = KDC.startKDC(HOST, null, REALM, principals, KEYTAB_FILE, KDC.KtabMode.APPEND);
KDC.saveConfig(KRB5_CONF_FILENAME, kdc, "forwardable = true", "proxiable = true");
boolean success = true;
/*
* kinit should fail since java.security.krb5.kdc
* and java.security.krb5.realm properties override correct values
* in krb5 conf file
*/
String[] command = { KINIT, "-k", "-J-Djava.security.krb5.realm=" + REALM, // without port
"-J-Djava.security.krb5.kdc=" + HOST, "-J-Djava.security.krb5.conf=" + KRB5_CONF_FILENAME, "-t", KEYTAB_FILE, "-c", CC_FILENAME, USER };
try {
OutputAnalyzer out = ProcessTools.executeCommand(command);
out.shouldHaveExitValue(-1);
out.shouldContain(PortUnreachableException.class.getName());
} catch (Throwable e) {
System.out.println("Unexpected exception: " + e);
e.printStackTrace(System.out);
success = false;
}
/*
* kinit should succeed
* since realm should be picked up from principal name
*/
command = new String[] { KINIT, "-k", "-J-Djava.security.krb5.realm=" + ANOTHER_REALM, "-J-Djava.security.krb5.kdc=" + HOST, "-J-Djava.security.krb5.conf=" + KRB5_CONF_FILENAME, "-t", KEYTAB_FILE, "-c", CC_FILENAME, USER_PRINCIPAL };
try {
OutputAnalyzer out = ProcessTools.executeCommand(command);
out.shouldHaveExitValue(0);
out.shouldContain(CC_FILENAME);
} catch (Throwable e) {
System.out.println("Unexpected exception: " + e);
e.printStackTrace(System.out);
success = false;
}
success &= checkTicketFlags();
/*
* kinit should succeed
* since realm should be picked up from principal name,
* and other data should come from krb5 conf file
*/
command = new String[] { KINIT, "-k", "-J-Djava.security.krb5.conf=" + KRB5_CONF_FILENAME, "-t", KEYTAB_FILE, "-c", CC_FILENAME, USER_PRINCIPAL };
try {
OutputAnalyzer out = ProcessTools.executeCommand(command);
out.shouldHaveExitValue(0);
out.shouldContain(CC_FILENAME);
} catch (Throwable e) {
System.out.println("Unexpected exception: " + e);
e.printStackTrace(System.out);
success = false;
}
success &= checkTicketFlags();
// kinit should succeed even if a principal name doesn't have realm
command = new String[] { KINIT, "-k", "-J-Djava.security.krb5.conf=" + KRB5_CONF_FILENAME, "-t", KEYTAB_FILE, "-c", CC_FILENAME, USER };
try {
OutputAnalyzer out = ProcessTools.executeCommand(command);
out.shouldHaveExitValue(0);
out.shouldContain(CC_FILENAME);
} catch (Throwable e) {
System.out.println("Unexpected exception: " + e);
e.printStackTrace(System.out);
success = false;
}
success &= checkTicketFlags();
if (!success) {
throw new RuntimeException("At least one test case failed");
}
System.out.println("Test passed");
}
Aggregations