1 /* 2 * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 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 package nsk.jdi.VirtualMachineManager.majorInterfaceVersion; 25 26 import nsk.share.*; 27 import nsk.share.jpda.*; 28 import nsk.share.jdi.*; 29 30 import com.sun.jdi.*; 31 import java.util.*; 32 import java.io.*; 33 34 /** 35 * The test for the implementation of an object of the type <BR> 36 * VirtualMachineManager. <BR> 37 * <BR> 38 * The test checks up that results of the method <BR> 39 * <code>com.sun.jdi.VirtualMachineManager.majorInterfaceVersion()</code> <BR> 40 * complies with its specification. <BR> 41 * <BR> 42 * The test checks up that invoking the method <BR> 43 * VirtualMachineManager.majorInterfaceVersion() doesn't throw<BR> 44 * an exception and a returned value is of the int type. <BR> 45 */ 46 47 public class major001 { 48 49 //----------------------------------------------------- templete section 50 static final int PASSED = 0; 51 static final int FAILED = 2; 52 static final int PASS_BASE = 95; 53 54 //----------------------------------------------------- templete parameters 55 static final String 56 sHeader1 = "\n==> nsk/jdi/VirtualMachineManager/majorInterfaceVersion/major001 ", 57 sHeader2 = "--> debugger: ", 58 sHeader3 = "##> debugger: "; 59 60 //----------------------------------------------------- main method 61 main(String argv[])62 public static void main (String argv[]) { 63 int result = run(argv, System.out); 64 System.exit(result + PASS_BASE); 65 } 66 run(String argv[], PrintStream out)67 public static int run (String argv[], PrintStream out) { 68 return new major001().runThis(argv, out); 69 } 70 71 //-------------------------------------------------- log procedures 72 73 private static Log logHandler; 74 log1(String message)75 private static void log1(String message) { 76 logHandler.display(sHeader1 + message); 77 } log2(String message)78 private static void log2(String message) { 79 logHandler.display(sHeader2 + message); 80 } log3(String message)81 private static void log3(String message) { 82 logHandler.complain(sHeader3 + message); 83 } 84 85 // ************************************************ test parameters 86 //====================================================== test program 87 //------------------------------------------------------ common section 88 89 static ArgumentHandler argsHandler; 90 91 static int waitTime; 92 93 static int testExitCode = PASSED; 94 95 static final int returnCode0 = 0; 96 static final int returnCode1 = 1; 97 static final int returnCode2 = 2; 98 static final int returnCode3 = 3; 99 static final int returnCode4 = 4; 100 101 //------------------------------------------------------ methods 102 runThis(String argv[], PrintStream out)103 private int runThis (String argv[], PrintStream out) { 104 105 argsHandler = new ArgumentHandler(argv); 106 logHandler = new Log(out, argsHandler); 107 108 waitTime = argsHandler.getWaitTime(); 109 110 //------------------------------------------------------ testing section 111 log1(" TESTING BEGINS"); 112 113 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ variable part 114 115 log2("......call to Bootstrap.virtualMachineManager()"); 116 VirtualMachineManager vmm = Bootstrap.virtualMachineManager(); 117 if (vmm == null) { 118 log3("ERROR: null returned"); 119 testExitCode = FAILED; 120 } else { 121 122 log2("......call to vmm.majorInterfaceVersion()"); 123 int majorVersion; 124 try { 125 majorVersion = vmm.majorInterfaceVersion(); 126 log2(" majorInterfaceVersion() == " + majorVersion); 127 } catch ( Exception e) { 128 log3("ERROR: Exception : " + e); 129 testExitCode = FAILED; 130 } 131 } 132 133 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 134 log1(" TESTING ENDS"); 135 136 //-------------------------------------------------- test summary section 137 //------------------------------------------------- standard end section 138 139 if (testExitCode != PASSED) { 140 logHandler.complain("TEST FAILED"); 141 } 142 return testExitCode; 143 } 144 } 145