Path: blob/master/test/jdk/java/lang/management/RuntimeMXBean/InputArgument.java
41154 views
/*1* Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/*24* @bug 453053825* @summary Basic unit test of RuntimeMXBean.getInputArguments().26*27* @author Mandy Chung28*29*/3031import java.lang.management.*;32import java.util.List;33import java.util.ListIterator;3435public class InputArgument {36private static RuntimeMXBean rm = ManagementFactory.getRuntimeMXBean();37private static String vmOption = null;3839public static void main(String args[]) throws Exception {40// set the expected input argument41if (args.length > 0) {42vmOption = args[0];43}4445List<String> options = rm.getInputArguments();46if (vmOption == null) {47return;48}4950boolean testFailed = true;51System.out.println("Number of arguments = " + options.size());52int i = 0;53for (String arg : options) {54System.out.println("Input arg " + i + " = " + arg);55i++;56if (arg.equals(vmOption)) {57testFailed = false;58break;59}60}61if (testFailed) {62throw new RuntimeException("TEST FAILED: " +63"VM option " + vmOption + " not found");64}6566System.out.println("Test passed.");67}68}697071