< prev index next >
test/serviceability/dcmd/vm/SetVMFlagTest.java
Print this page
*** 54,63 ****
--- 54,82 ----
@Test
public void jmx() {
run(new JMXExecutor());
}
+ private void setMutableFlagInternal(CommandExecutor executor, String flag,
+ boolean val, boolean isNumeric) {
+ String strFlagVal;
+ if (isNumeric) {
+ strFlagVal = val ? "1" : "0";
+ } else {
+ strFlagVal = val ? "true" : "false";
+ }
+
+ OutputAnalyzer out = executor.execute("VM.set_flag " + flag + " " + strFlagVal);
+ out.stderrShouldBeEmpty();
+
+ out = getAllFlags(executor);
+
+ String newFlagVal = out.firstMatch(MANAGEABLE_PATTERN.replace("(\\S+)", flag), 1);
+
+ assertNotEquals(newFlagVal, val ? "1" : "0");
+ }
+
private void setMutableFlag(CommandExecutor executor) {
OutputAnalyzer out = getAllFlags(executor);
String flagName = out.firstMatch(MANAGEABLE_PATTERN, 1);
String flagVal = out.firstMatch(MANAGEABLE_PATTERN, 2);
*** 67,85 ****
System.err.println(out.getOutput());
throw new Error("Can not find a boolean manageable flag");
}
Boolean blnVal = Boolean.parseBoolean(flagVal);
!
! out = executor.execute("VM.set_flag " + flagName + " " + (blnVal ? 0 : 1));
! out.stderrShouldBeEmpty();
!
! out = getAllFlags(executor);
!
! String newFlagVal = out.firstMatch(MANAGEABLE_PATTERN.replace("(\\S+)", flagName), 1);
!
! assertNotEquals(newFlagVal, flagVal);
}
private void setMutableFlagWithInvalidValue(CommandExecutor executor) {
OutputAnalyzer out = getAllFlags(executor);
String flagName = out.firstMatch(MANAGEABLE_PATTERN, 1);
--- 86,97 ----
System.err.println(out.getOutput());
throw new Error("Can not find a boolean manageable flag");
}
Boolean blnVal = Boolean.parseBoolean(flagVal);
! setMutableFlagInternal(executor, flagName, !blnVal, true);
! setMutableFlagInternal(executor, flagName, blnVal, false);
}
private void setMutableFlagWithInvalidValue(CommandExecutor executor) {
OutputAnalyzer out = getAllFlags(executor);
String flagName = out.firstMatch(MANAGEABLE_PATTERN, 1);
*** 93,103 ****
}
// a boolean flag accepts only 0/1 as its value
out = executor.execute("VM.set_flag " + flagName + " unexpected_value");
out.stderrShouldBeEmpty();
! out.stdoutShouldContain("flag value must be a boolean (1 or 0)");
out = getAllFlags(executor);
String newFlagVal = out.firstMatch(MANAGEABLE_PATTERN.replace("(\\S+)", flagName), 1);
--- 105,115 ----
}
// a boolean flag accepts only 0/1 as its value
out = executor.execute("VM.set_flag " + flagName + " unexpected_value");
out.stderrShouldBeEmpty();
! out.stdoutShouldContain("flag value must be a boolean (1/0 or true/false)");
out = getAllFlags(executor);
String newFlagVal = out.firstMatch(MANAGEABLE_PATTERN.replace("(\\S+)", flagName), 1);
< prev index next >