< prev index next >

test/runtime/CommandLine/OptionsValidation/TestJcmdOutput.java

Print this page




   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /*
  25  * @test
  26  * @summary Verify jcmd error message for out-of-range value and for
  27  *          value which is not allowed by constraint. Also check that
  28  *          jcmd does not print an error message to the target process output.
  29  * @library /testlibrary
  30  * @modules java.base/jdk.internal.misc
  31  *          java.management
  32  *          jdk.management
  33  * @run main TestJcmdOutput
  34  */
  35 
  36 import jdk.test.lib.Asserts;
  37 import jdk.test.lib.DynamicVMOption;
  38 import jdk.test.lib.OutputAnalyzer;
  39 import jdk.test.lib.ProcessTools;
  40 import jdk.test.lib.dcmd.PidJcmdExecutor;
  41 
  42 public class TestJcmdOutput {
  43 
  44     /* Message printed by jcmd for value which is out-of-range */
  45     static final String JCMD_OUT_OF_RANGE_MESSAGE = "error: must have value in range";
  46     /* Message printed by jcmd for value which is not allowed by constraint */
  47     static final String JCMD_CONSTRAINT_MESSAGE = "value violates its flag's constraint";
  48 
  49     public static void main(String[] args) throws Exception {
  50         OutputAnalyzer output;
  51 
  52         System.out.println("Verify jcmd error message and that jcmd does not write errors to the target process output");
  53         output = new OutputAnalyzer((ProcessTools.createJavaProcessBuilder(
  54                 "-Dtest.jdk=" + System.getProperty("test.jdk"),
  55                 "-XX:MinHeapFreeRatio=20", "-XX:MaxHeapFreeRatio=80", runJcmd.class.getName())).start());
  56 
  57         output.shouldHaveExitValue(0);
  58         /* Verify that jcmd not print error message to the target process output */
  59         output.shouldNotContain(JCMD_OUT_OF_RANGE_MESSAGE);




   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /*
  25  * @test
  26  * @summary Verify jcmd error message for out-of-range value and for
  27  *          value which is not allowed by constraint. Also check that
  28  *          jcmd does not print an error message to the target process output.
  29  * @library /test/lib
  30  * @modules java.base/jdk.internal.misc
  31  *          java.management
  32  *          jdk.management
  33  * @run main TestJcmdOutput
  34  */
  35 
  36 import jdk.test.lib.Asserts;
  37 import jdk.test.lib.DynamicVMOption;
  38 import jdk.test.lib.process.OutputAnalyzer;
  39 import jdk.test.lib.process.ProcessTools;
  40 import jdk.test.lib.dcmd.PidJcmdExecutor;
  41 
  42 public class TestJcmdOutput {
  43 
  44     /* Message printed by jcmd for value which is out-of-range */
  45     static final String JCMD_OUT_OF_RANGE_MESSAGE = "error: must have value in range";
  46     /* Message printed by jcmd for value which is not allowed by constraint */
  47     static final String JCMD_CONSTRAINT_MESSAGE = "value violates its flag's constraint";
  48 
  49     public static void main(String[] args) throws Exception {
  50         OutputAnalyzer output;
  51 
  52         System.out.println("Verify jcmd error message and that jcmd does not write errors to the target process output");
  53         output = new OutputAnalyzer((ProcessTools.createJavaProcessBuilder(
  54                 "-Dtest.jdk=" + System.getProperty("test.jdk"),
  55                 "-XX:MinHeapFreeRatio=20", "-XX:MaxHeapFreeRatio=80", runJcmd.class.getName())).start());
  56 
  57         output.shouldHaveExitValue(0);
  58         /* Verify that jcmd not print error message to the target process output */
  59         output.shouldNotContain(JCMD_OUT_OF_RANGE_MESSAGE);


< prev index next >