Here are the examples of the java api jdk.test.lib.process.OutputAnalyzer taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
702 Examples
19
Source : CommandLineOptionTest.java
with GNU General Public License v2.0
from Tencent
with GNU General Public License v2.0
from Tencent
/**
* Verifies that value of specified JVM options are the same as
* expected values.
* Generates command line option flags from
* {@code optionNames} and {@code expectedValues}.
*
* @param optionNames names of tested options.
* @param expectedValues expected values of tested options.
* @throws Throwable if verification fails or some other issues occur.
*/
public static void verifyOptionValues(String[] optionNames, String[] expectedValues) throws Throwable {
Outputreplacedyzer outputreplacedyzer = startVMWithOptions(optionNames, expectedValues, "-XX:+PrintFlagsFinal");
verifyOptionValuesFromOutput(outputreplacedyzer, optionNames, expectedValues);
}
19
Source : CDSTestUtils.java
with GNU General Public License v2.0
from Tencent
with GNU General Public License v2.0
from Tencent
// ============================= Logging
public static Outputreplacedyzer executeAndLog(ProcessBuilder pb, String logName) throws Exception {
long started = System.currentTimeMillis();
Outputreplacedyzer output = new Outputreplacedyzer(pb.start());
writeFile(getOutputFile(logName + ".stdout"), output.getStdout());
writeFile(getOutputFile(logName + ".stderr"), output.getStderr());
System.out.println("[ELAPSED: " + (System.currentTimeMillis() - started) + " ms]");
System.out.println("[STDERR]\n" + output.getStderr());
if (CopyChildStdoutToMainStdout)
System.out.println("[STDOUT]\n" + output.getStdout());
return output;
}
19
Source : CDSTestUtils.java
with GNU General Public License v2.0
from Tencent
with GNU General Public License v2.0
from Tencent
public static boolean checkCommonExecExceptions(Outputreplacedyzer output) throws Exception {
return checkCommonExecExceptions(output, null);
}
19
Source : CDSTestUtils.java
with GNU General Public License v2.0
from Tencent
with GNU General Public License v2.0
from Tencent
public static Outputreplacedyzer checkExec(Outputreplacedyzer output, String... extraMatches) throws Exception {
CDSOptions opts = new CDSOptions();
return checkExec(output, opts, extraMatches);
}
19
Source : CDSTestUtils.java
with GNU General Public License v2.0
from Tencent
with GNU General Public License v2.0
from Tencent
public static Outputreplacedyzer checkMatches(Outputreplacedyzer output, String... matches) throws Exception {
for (String match : matches) {
output.shouldContain(match);
}
return output;
}
19
Source : TestJcmdStopInvalidFile.java
with GNU General Public License v2.0
from Tencent
with GNU General Public License v2.0
from Tencent
public static void main(String[] args) throws Exception {
String name = "testStopWithIllegalFilename";
Outputreplacedyzer output = JcmdHelper.jcmd("JFR.start", "name=" + name);
Jcmdreplacederts.replacedertRecordingHreplacedtarted(output);
JcmdHelper.waitUntilRunning(name);
output = JcmdHelper.jcmd("JFR.stop", "name=" + name, "filename=" + ILLEGAL_FILE_NAME);
Jcmdreplacederts.replacedertFileNotFoundException(output, name);
output = JcmdHelper.jcmd("JFR.check");
JcmdHelper.replacedertRecordingIsRunning(name);
JcmdHelper.stopAndCheck(name);
}
19
Source : TestJcmdStartWithSettings.java
with GNU General Public License v2.0
from Tencent
with GNU General Public License v2.0
from Tencent
private static void testSingleSettingFile() throws Exception {
String name = "testSingleSettingFile";
File recording = new File(name + ".jfr");
Outputreplacedyzer output = JcmdHelper.jcmd("JFR.start", "name=" + name, "duration=1h", "settings=" + SETTINGS.getCanonicalPath(), "filename=" + recording.getCanonicalPath());
Jcmdreplacederts.replacedertRecordingHreplacedtarted(output);
JcmdHelper.waitUntilRunning(name);
output = JcmdHelper.jcmdCheck(name, true);
Jcmdreplacederts.replacedertThreadSleepThresholdIsSet(output);
Thread.sleep(100);
JcmdHelper.stopAndCheck(name);
replacedertHasEvent(recording, EventNames.ThreadSleep, Thread.currentThread().getName());
}
19
Source : TestJcmdStartWithSettings.java
with GNU General Public License v2.0
from Tencent
with GNU General Public License v2.0
from Tencent
/**
* It should be possible to use "profile" as non-path preset,
* both with and without '.jfc'
*/
private static void testPresetSettings() throws Exception {
String name = "testPresetSettingsJfc";
Outputreplacedyzer output = JcmdHelper.jcmd("JFR.start", "name=" + name, "settings=profile.jfc");
Jcmdreplacederts.replacedertRecordingHreplacedtarted(output);
JcmdHelper.waitUntilRunning(name);
JcmdHelper.stopAndCheck(name);
name = "testPresetSettingsNoJfc";
output = JcmdHelper.jcmd("JFR.start", "name=" + name, "settings=profile");
Jcmdreplacederts.replacedertRecordingHreplacedtarted(output);
JcmdHelper.waitUntilRunning(name);
JcmdHelper.stopAndCheck(name);
}
19
Source : TestJcmdStartWithSettings.java
with GNU General Public License v2.0
from Tencent
with GNU General Public License v2.0
from Tencent
/**
* It should not be possible to start a recording
* with a non-existing setting file
*/
private static void testNonExistingSettingFile() throws Exception {
String name = "testNonExistingSettingFile";
Outputreplacedyzer output = JcmdHelper.jcmd("JFR.start", "name=" + name, "settings=nonexisting.jfc");
Jcmdreplacederts.replacedertNotAbleToFindSettingsFile(output);
JcmdHelper.replacedertRecordingNotExist(name);
}
19
Source : TestJcmdStartWithOptions.java
with GNU General Public License v2.0
from Tencent
with GNU General Public License v2.0
from Tencent
/**
* Check the maxsize is the same as MBean value
*/
private static void testMaxSize() throws Exception {
String name = "testMaxSize";
long maxSize = 2 * 1024 * 1024;
Outputreplacedyzer output = JcmdHelper.jcmd("JFR.start", "name=" + name, "settings=" + SETTINGS.getAbsolutePath(), "maxsize=" + maxSize);
Jcmdreplacederts.replacedertRecordingHreplacedtarted(output);
JcmdHelper.waitUntilRunning(name);
Jcmdreplacederts.replacedertMaxSizeEqualsMBeanValue(name, maxSize);
JcmdHelper.stopAndCheck(name);
}
19
Source : TestJcmdStartWithOptions.java
with GNU General Public License v2.0
from Tencent
with GNU General Public License v2.0
from Tencent
private static void testDuration() throws Exception {
String name = "testDuration";
long duration = 3600 * 1000;
String durationS = String.valueOf(duration / 1000) + "s";
Outputreplacedyzer output = JcmdHelper.jcmd("JFR.start", "name=" + name, "duration=" + durationS);
Jcmdreplacederts.replacedertRecordingHreplacedtarted(output);
JcmdHelper.waitUntilRunning(name);
Jcmdreplacederts.replacedertDurationEqualsMBeanValue(name, duration);
JcmdHelper.stopAndCheck(name);
}
19
Source : TestJcmdStartWithOptions.java
with GNU General Public License v2.0
from Tencent
with GNU General Public License v2.0
from Tencent
private static void testDelayLessThan1s() throws Exception {
String name = "testDelayLessThan1s";
Outputreplacedyzer output = JcmdHelper.jcmd("JFR.start", "name=" + name, "delay=10ms");
Jcmdreplacederts.replacedertDelayAtLeast1s(output);
output = JcmdHelper.jcmd("JFR.check");
Jcmdreplacederts.replacedertNoRecordingsAvailable(output);
}
19
Source : TestJcmdStartWithOptions.java
with GNU General Public License v2.0
from Tencent
with GNU General Public License v2.0
from Tencent
/**
* Check the maxage is the same as MBean value
*/
private static void testMaxAge() throws Exception {
String name = "testMaxAge";
long maxAge = 2 * 1000;
Outputreplacedyzer output = JcmdHelper.jcmd("JFR.start", "name=" + name, "settings=" + SETTINGS.getAbsolutePath(), "maxage=2s");
Jcmdreplacederts.replacedertRecordingHreplacedtarted(output);
JcmdHelper.waitUntilRunning(name);
Jcmdreplacederts.replacedertMaxAgeEqualsMBeanValue(name, maxAge);
JcmdHelper.stopAndCheck(name);
}
19
Source : TestJcmdStartWithOptions.java
with GNU General Public License v2.0
from Tencent
with GNU General Public License v2.0
from Tencent
private static void testDurationLessThan1s() throws Exception {
String name = "testDurationLessThan1s";
Outputreplacedyzer output = JcmdHelper.jcmd("JFR.start", "name=" + name, "duration=10ms");
Jcmdreplacederts.replacedertDurationAtLeast1s(output);
JcmdHelper.checkAndreplacedertNoRecordingsAvailable();
}
19
Source : TestJcmdStartInvaldFile.java
with GNU General Public License v2.0
from Tencent
with GNU General Public License v2.0
from Tencent
public static void main(String[] args) throws Exception {
String name = "testStartWithIllegalFilename";
Outputreplacedyzer output = JcmdHelper.jcmd("JFR.start", "name=" + name, "duration=10s", "filename=" + ILLEGAL_FILE_NAME);
Jcmdreplacederts.replacedertNotAbleToWriteToFile(output);
JcmdHelper.replacedertRecordingNotExist(name);
}
19
Source : TestJcmdDumpGeneratedFilename.java
with GNU General Public License v2.0
from Tencent
with GNU General Public License v2.0
from Tencent
private static void testDumpFilename() throws Exception {
Outputreplacedyzer output = JcmdHelper.jcmd("JFR.dump");
verifyFile(readFilename(output), null);
}
19
Source : JcmdHelper.java
with GNU General Public License v2.0
from Tencent
with GNU General Public License v2.0
from Tencent
public static void stopCompressAndCheck(String name, File file) throws Exception {
Outputreplacedyzer output = jcmd("JFR.stop", "name=\"" + name + "\"", "compress=true", "filename=\"" + file.getAbsolutePath() + "\"");
Jcmdreplacederts.replacedertStoppedAndWrittenTo(output, name, file);
checkAndreplacedertNoRecordingsAvailable();
}
19
Source : JcmdHelper.java
with GNU General Public License v2.0
from Tencent
with GNU General Public License v2.0
from Tencent
public static void stopWriteToFileAndCheck(String name, File file) throws Exception {
Outputreplacedyzer output = jcmd("JFR.stop", "name=\"" + name + "\"", "filename=\"" + file.getAbsolutePath() + "\"");
Jcmdreplacederts.replacedertStoppedAndWrittenTo(output, name, file);
replacedertRecordingNotRunning(name);
}
19
Source : JcmdHelper.java
with GNU General Public License v2.0
from Tencent
with GNU General Public License v2.0
from Tencent
public static void checkAndreplacedertNoRecordingsAvailable() throws Exception {
Outputreplacedyzer output = jcmd("JFR.check");
Jcmdreplacederts.replacedertNoRecordingsAvailable(output);
}
19
Source : JcmdHelper.java
with GNU General Public License v2.0
from Tencent
with GNU General Public License v2.0
from Tencent
public static void replacedertRecordingNotExist(String name) throws Exception {
Outputreplacedyzer output = jcmdCheck(name, false);
Jcmdreplacederts.replacedertRecordingNotExist(output, name);
}
19
Source : JcmdHelper.java
with GNU General Public License v2.0
from Tencent
with GNU General Public License v2.0
from Tencent
public static void replacedertRecordingIsRunning(String name) throws Exception {
Outputreplacedyzer output = jcmdCheck(name, false);
Jcmdreplacederts.replacedertRecordingIsRunning(output, name);
}
19
Source : JcmdHelper.java
with GNU General Public License v2.0
from Tencent
with GNU General Public License v2.0
from Tencent
public static void replacedertRecordingNotRunning(String name) throws Exception {
Outputreplacedyzer output = jcmdCheck(name, false);
Jcmdreplacederts.replacedertRecordingNotRunning(output, name);
}
19
Source : JcmdHelper.java
with GNU General Public License v2.0
from Tencent
with GNU General Public License v2.0
from Tencent
public static void stopDefaultRecordingAndCheck() throws Exception {
Outputreplacedyzer output = jcmd("JFR.stop", "recording=0");
Jcmdreplacederts.replacedertStoppedDefaultRecording(output);
checkAndreplacedertNoRecordingsAvailable();
}
19
Source : JcmdAsserts.java
with GNU General Public License v2.0
from Tencent
with GNU General Public License v2.0
from Tencent
public static void replacedertRecordingIsScheduled(Outputreplacedyzer output, String name, String delay) {
output.stdoutShouldMatch("^\\s*Recording\\s+" + name + "\\s+scheduled to start in " + delay);
}
19
Source : JcmdAsserts.java
with GNU General Public License v2.0
from Tencent
with GNU General Public License v2.0
from Tencent
public static void replacedertCouldNotStartDefaultRecording(Outputreplacedyzer output) {
output.shouldContain("The only option that can be combined with defaultrecording is settings");
}
19
Source : JcmdAsserts.java
with GNU General Public License v2.0
from Tencent
with GNU General Public License v2.0
from Tencent
public static void replacedertDurationAtLeast1s(Outputreplacedyzer output) {
output.shouldContain("Could not start recording, duration must be at least 1 second.");
}
19
Source : JcmdAsserts.java
with GNU General Public License v2.0
from Tencent
with GNU General Public License v2.0
from Tencent
// public static void replacedertNotAbleToSetFilename(Outputreplacedyzer output) {
// output.shouldContain(
// "Filename can only be set for a recording with a duration, " +
// "or if dumponexit=true");
// }
public static void replacedertNotAbleToFindSettingsFile(Outputreplacedyzer output) {
output.shouldContain("Could not parse setting");
}
19
Source : JcmdAsserts.java
with GNU General Public License v2.0
from Tencent
with GNU General Public License v2.0
from Tencent
public static void replacedertMonitorWaitThresholdIsSet(Outputreplacedyzer output) throws Exception {
output.stdoutShouldMatch("\\s+\\W{1}" + EventNames.JavaMonitorWait + "\\W{1}" + NEW_LINE + ".*threshold=1 ms.*");
}
19
Source : JcmdAsserts.java
with GNU General Public License v2.0
from Tencent
with GNU General Public License v2.0
from Tencent
public static void replacedertThreadSleepThresholdIsSet(Outputreplacedyzer output) throws Exception {
output.stdoutShouldMatch("\\s+\\W{1}" + EventNames.ThreadSleep + "\\W{1}" + NEW_LINE + ".*threshold=1 ms.*");
}
19
Source : JcmdAsserts.java
with GNU General Public License v2.0
from Tencent
with GNU General Public License v2.0
from Tencent
public static void replacedertRecordingIsUnstarted(Outputreplacedyzer output, String name, String duration) {
output.stdoutShouldMatch("^Recording \\d+: name=" + name + " duration=" + duration + " .*\\W{1}unstarted\\W{1}");
}
19
Source : JcmdAsserts.java
with GNU General Public License v2.0
from Tencent
with GNU General Public License v2.0
from Tencent
public static void replacedertRecordingNotRunning(Outputreplacedyzer output, String name) {
output.shouldNotMatch(".*" + name + ".*running");
}
19
Source : JcmdAsserts.java
with GNU General Public License v2.0
from Tencent
with GNU General Public License v2.0
from Tencent
public static void replacedertStoppedDefaultRecording(Outputreplacedyzer output) {
output.shouldContain("Stopped recording 0");
}
19
Source : JcmdAsserts.java
with GNU General Public License v2.0
from Tencent
with GNU General Public License v2.0
from Tencent
public static void replacedertStoppedRecording(Outputreplacedyzer output, String name) {
output.shouldContain("Stopped recording \"" + name + "\"");
}
19
Source : JcmdAsserts.java
with GNU General Public License v2.0
from Tencent
with GNU General Public License v2.0
from Tencent
public static void replacedertRecordingIsStopped(Outputreplacedyzer output, String name) {
output.stdoutShouldMatch("^Recording \\d+: name=" + name + " .*\\W{1}stopped\\W{1}");
}
19
Source : JcmdAsserts.java
with GNU General Public License v2.0
from Tencent
with GNU General Public License v2.0
from Tencent
public static void replacedertNoRecordingsAvailable(Outputreplacedyzer output) {
output.shouldContain("No available recordings");
}
19
Source : JcmdAsserts.java
with GNU General Public License v2.0
from Tencent
with GNU General Public License v2.0
from Tencent
public static void replacedertDelayAtLeast1s(Outputreplacedyzer output) {
output.shouldContain("Could not start recording, delay must be at least 1 second.");
}
19
Source : JcmdAsserts.java
with GNU General Public License v2.0
from Tencent
with GNU General Public License v2.0
from Tencent
public static void replacedertNotAbleToWriteToFile(Outputreplacedyzer output) {
output.shouldContain("Could not start recording, not able to write to file");
}
19
Source : JcmdAsserts.java
with GNU General Public License v2.0
from Tencent
with GNU General Public License v2.0
from Tencent
public static void replacedertCouldNotStartDefaultRecordingWithName(Outputreplacedyzer output) {
output.shouldContain("It's not possible to set custom name for the defaultrecording");
}
19
Source : JcmdAsserts.java
with GNU General Public License v2.0
from Tencent
with GNU General Public License v2.0
from Tencent
public static void replacedertRecordingNotExist(Outputreplacedyzer output, String name) {
output.shouldContain("Could not find " + name);
}
19
Source : JcmdAsserts.java
with GNU General Public License v2.0
from Tencent
with GNU General Public License v2.0
from Tencent
public static void replacedertRecordingIsStopped(Outputreplacedyzer output, String name, String duration) {
output.stdoutShouldMatch("^Recording \\d+: name=" + name + " duration=" + duration + " .*\\W{1}stopped\\W{1}");
}
19
Source : JcmdAsserts.java
with GNU General Public License v2.0
from Tencent
with GNU General Public License v2.0
from Tencent
public static void replacedertRecordingHreplacedtarted(Outputreplacedyzer output) {
output.shouldContain("Started recording");
}
19
Source : CDSTestUtils.java
with GNU General Public License v2.0
from hzio
with GNU General Public License v2.0
from hzio
public static Outputreplacedyzer checkExtraMatches(Outputreplacedyzer output, String... extraMatches) throws Exception {
for (String match : extraMatches) {
output.shouldContain(match);
}
return output;
}
19
Source : WeakAlg.java
with GNU General Public License v2.0
from hzio
with GNU General Public License v2.0
from hzio
static void checkCertReq(String alias, String options, String bad) {
Outputreplacedyzer oa = certreq(alias, options);
if (bad == null) {
oa.shouldNotContain("Warning");
} else {
oa.shouldContain("Warning").shouldMatch("The generated certificate request.*" + bad + ".*risk");
}
oa = kt("-printcertreq -file " + alias + ".req");
if (bad == null) {
oa.shouldNotContain("Warning").shouldNotContain("(weak)");
} else {
oa.shouldContain("Warning").shouldMatch("The certificate request.*" + bad + ".*risk").shouldContain(bad + " (weak)");
}
}
19
Source : WeakAlg.java
with GNU General Public License v2.0
from hzio
with GNU General Public License v2.0
from hzio
static void checkGenCRL(String alias, String options, String bad) {
Outputreplacedyzer oa = kt("-gencrl -alias " + alias + " -id 1 -file " + alias + ".crl " + options);
if (bad == null) {
oa.shouldNotContain("Warning");
} else {
oa.shouldContain("Warning").shouldMatch("The generated CRL.*" + bad + ".*risk");
}
oa = kt("-printcrl -file " + alias + ".crl");
if (bad == null) {
oa.shouldNotContain("Warning").shouldContain("Verified by " + alias + " in keystore").shouldNotContain("(weak");
} else {
oa.shouldContain("Warning:").shouldMatch("The CRL.*" + bad + ".*risk").shouldContain("Verified by " + alias + " in keystore").shouldContain(bad + " (weak)");
}
}
19
Source : WeakAlg.java
with GNU General Public License v2.0
from hzio
with GNU General Public License v2.0
from hzio
static void checkGenKeyPair(String alias, String options, String bad) {
Outputreplacedyzer oa = genkeypair(alias, options);
if (bad == null) {
oa.shouldNotContain("Warning");
} else {
oa.shouldContain("Warning").shouldMatch("The generated certificate.*" + bad + ".*risk");
}
oa = kt("-exportcert -alias " + alias + " -file " + alias + ".cert");
if (bad == null) {
oa.shouldNotContain("Warning");
} else {
oa.shouldContain("Warning").shouldMatch("The certificate.*" + bad + ".*risk");
}
oa = kt("-exportcert -rfc -alias " + alias + " -file " + alias + ".cert");
if (bad == null) {
oa.shouldNotContain("Warning");
} else {
oa.shouldContain("Warning").shouldMatch("The certificate.*" + bad + ".*risk");
}
oa = kt("-printcert -rfc -file " + alias + ".cert");
if (bad == null) {
oa.shouldNotContain("Warning");
} else {
oa.shouldContain("Warning").shouldMatch("The certificate.*" + bad + ".*risk");
}
oa = kt("-list -alias " + alias);
if (bad == null) {
oa.shouldNotContain("Warning");
} else {
oa.shouldContain("Warning").shouldMatch("The certificate.*" + bad + ".*risk");
}
// With cert content
oa = kt("-printcert -file " + alias + ".cert");
if (bad == null) {
oa.shouldNotContain("Warning");
} else {
oa.shouldContain("Warning").shouldContain(bad + " (weak)").shouldMatch("The certificate.*" + bad + ".*risk");
}
oa = kt("-list -v -alias " + alias);
if (bad == null) {
oa.shouldNotContain("Warning");
} else {
oa.shouldContain("Warning").shouldContain(bad + " (weak)").shouldMatch("The certificate.*" + bad + ".*risk");
}
}
19
Source : Compatibility.java
with GNU General Public License v2.0
from hzio
with GNU General Public License v2.0
from hzio
// Using specified jarsigner to verify the signed jar.
private static Outputreplacedyzer verifyJar(String jarsignerPath, String signedJar) throws Throwable {
Outputreplacedyzer outputreplacedyzer = execTool(jarsignerPath, "-J-Djava.security.properties=" + JAVA_SECURITY, "-debug", "-verbose", "-certs", "-keystore", KEYSTORE, "-verify", signedJar + ".jar");
return outputreplacedyzer;
}
19
Source : CtwTest.java
with GNU General Public License v2.0
from hzio
with GNU General Public License v2.0
from hzio
protected void dump(Outputreplacedyzer output, String name) {
try (Writer w = new FileWriter(name + ".out")) {
String s = output.getStdout();
w.write(s, s.length(), 0);
} catch (IOException io) {
io.printStackTrace();
}
try (Writer w = new FileWriter(name + ".err")) {
String s = output.getStderr();
w.write(s, s.length(), 0);
} catch (IOException io) {
io.printStackTrace();
}
}
19
Source : LoaderConstraintsTest.java
with GNU General Public License v2.0
from hzio
with GNU General Public License v2.0
from hzio
public clreplaced LoaderConstraintsTest {
private static Outputreplacedyzer out;
private static ProcessBuilder pb;
private static clreplaced ClreplacedUnloadTestMain {
public static void main(String... args) throws Exception {
String clreplacedName = "test.Empty";
ClreplacedLoader cl = ClreplacedUnloadCommon.newClreplacedLoader();
Clreplaced<?> c = cl.loadClreplaced(clreplacedName);
cl = null;
c = null;
ClreplacedUnloadCommon.triggerUnloading();
}
}
// Use the same command-line heap size setting as ../ClreplacedUnload/UnloadTest.java
static ProcessBuilder exec(String... args) throws Exception {
List<String> argsList = new ArrayList<>();
Collections.addAll(argsList, args);
Collections.addAll(argsList, "-Xmn8m");
Collections.addAll(argsList, "-Dtest.clreplacedes=" + System.getProperty("test.clreplacedes", "."));
Collections.addAll(argsList, ClreplacedUnloadTestMain.clreplaced.getName());
return ProcessTools.createJavaProcessBuilder(argsList.toArray(new String[argsList.size()]));
}
public static void main(String... args) throws Exception {
// -XX:+TraceLoaderConstraints
pb = exec("-XX:+TraceLoaderConstraints");
out = new Outputreplacedyzer(pb.start());
out.getOutput();
out.shouldContain("[clreplaced,loader,constraints] adding new constraint for name: java/lang/Clreplaced, loader[0]: jdk/internal/loader/ClreplacedLoaders$AppClreplacedLoader, loader[1]: <bootloader>");
// -Xlog:clreplaced+loader+constraints=info
pb = exec("-Xlog:clreplaced+loader+constraints=info");
out = new Outputreplacedyzer(pb.start());
out.shouldContain("[clreplaced,loader,constraints] adding new constraint for name: java/lang/Clreplaced, loader[0]: jdk/internal/loader/ClreplacedLoaders$AppClreplacedLoader, loader[1]: <bootloader>");
// -XX:-TraceLoaderConstraints
pb = exec("-XX:-TraceLoaderConstraints");
out = new Outputreplacedyzer(pb.start());
out.shouldNotContain("[clreplaced,loaderconstraints]");
// -Xlog:clreplaced+loader+constraints=off
pb = exec("-Xlog:clreplaced+loader+constraints=off");
out = new Outputreplacedyzer(pb.start());
out.shouldNotContain("[clreplaced,loader,constraints]");
}
}
19
Source : ClassLoadUnloadTest.java
with GNU General Public License v2.0
from hzio
with GNU General Public License v2.0
from hzio
public clreplaced ClreplacedLoadUnloadTest {
private static Outputreplacedyzer out;
private static ProcessBuilder pb;
private static clreplaced ClreplacedUnloadTestMain {
public static void main(String... args) throws Exception {
String clreplacedName = "test.Empty";
ClreplacedLoader cl = ClreplacedUnloadCommon.newClreplacedLoader();
Clreplaced<?> c = cl.loadClreplaced(clreplacedName);
cl = null;
c = null;
ClreplacedUnloadCommon.triggerUnloading();
}
}
static void checkFor(String... outputStrings) throws Exception {
out = new Outputreplacedyzer(pb.start());
for (String s : outputStrings) {
out.shouldContain(s);
}
out.shouldHaveExitValue(0);
}
static void checkAbsent(String... outputStrings) throws Exception {
out = new Outputreplacedyzer(pb.start());
for (String s : outputStrings) {
out.shouldNotContain(s);
}
out.shouldHaveExitValue(0);
}
// Use the same command-line heap size setting as ../ClreplacedUnload/UnloadTest.java
static ProcessBuilder exec(String... args) throws Exception {
List<String> argsList = new ArrayList<>();
Collections.addAll(argsList, args);
Collections.addAll(argsList, "-Xmn8m");
Collections.addAll(argsList, "-Dtest.clreplaced.path=" + System.getProperty("test.clreplaced.path", "."));
Collections.addAll(argsList, ClreplacedUnloadTestMain.clreplaced.getName());
return ProcessTools.createJavaProcessBuilder(argsList.toArray(new String[argsList.size()]));
}
public static void main(String... args) throws Exception {
// -Xlog:clreplaced+unload=info
pb = exec("-Xlog:clreplaced+unload=info");
checkFor("[clreplaced,unload]", "unloading clreplaced");
// -Xlog:clreplaced+unload=off
pb = exec("-Xlog:clreplaced+unload=off");
checkAbsent("[clreplaced,unload]");
// -XX:+TraceClreplacedUnloading
pb = exec("-XX:+TraceClreplacedUnloading");
checkFor("[clreplaced,unload]", "unloading clreplaced");
// -XX:-TraceClreplacedUnloading
pb = exec("-XX:-TraceClreplacedUnloading");
checkAbsent("[clreplaced,unload]");
// -Xlog:clreplaced+load=info
pb = exec("-Xlog:clreplaced+load=info");
checkFor("[clreplaced,load]", "java.lang.Object", "source:");
// -Xlog:clreplaced+load=debug
pb = exec("-Xlog:clreplaced+load=debug");
checkFor("[clreplaced,load]", "java.lang.Object", "source:", "klreplaced:", "super:", "loader:", "bytes:");
// -Xlog:clreplaced+load=off
pb = exec("-Xlog:clreplaced+load=off");
checkAbsent("[clreplaced,load]");
// -XX:+TraceClreplacedLoading
pb = exec("-XX:+TraceClreplacedLoading");
checkFor("[clreplaced,load]", "java.lang.Object", "source:");
// -XX:-TraceClreplacedLoading
pb = exec("-XX:-TraceClreplacedLoading");
checkAbsent("[clreplaced,load]");
// -verbose:clreplaced
pb = exec("-verbose:clreplaced");
checkFor("[clreplaced,load]", "java.lang.Object", "source:");
checkFor("[clreplaced,unload]", "unloading clreplaced");
// -Xlog:clreplaced+loader+data=trace
pb = exec("-Xlog:clreplaced+loader+data=trace");
checkFor("[clreplaced,loader,data]", "create clreplaced loader data");
}
}
19
Source : VMAliasOptions.java
with GNU General Public License v2.0
from hzio
with GNU General Public License v2.0
from hzio
static void testAliases(String[][] optionInfo) throws Throwable {
String[] aliasNames = new String[optionInfo.length];
String[] optionNames = new String[optionInfo.length];
String[] expectedValues = new String[optionInfo.length];
for (int i = 0; i < optionInfo.length; i++) {
aliasNames[i] = optionInfo[i][0];
optionNames[i] = optionInfo[i][1];
expectedValues[i] = optionInfo[i][2];
}
Outputreplacedyzer output = CommandLineOptionTest.startVMWithOptions(aliasNames, expectedValues, "-XX:+PrintFlagsFinal");
CommandLineOptionTest.verifyOptionValuesFromOutput(output, optionNames, expectedValues);
}
See More Examples