< prev index next >
test/serviceability/dcmd/vm/SetVMFlagTest.java
Print this page
@@ -54,10 +54,29 @@
@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,19 +86,12 @@
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);
+ 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,11 +105,11 @@
}
// 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.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 >