1 import com.oracle.java.testlibrary.OutputAnalyzer; 2 import com.oracle.java.testlibrary.Platform; 3 import com.oracle.java.testlibrary.dcmd.CommandExecutor; 4 import com.oracle.java.testlibrary.dcmd.JMXExecutor; 5 import org.testng.annotations.Test; 6 7 /* 8 * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved. 9 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 10 * 11 * This code is free software; you can redistribute it and/or modify it 12 * under the terms of the GNU General Public License version 2 only, as 13 * published by the Free Software Foundation. 14 * 15 * This code is distributed in the hope that it will be useful, but WITHOUT 16 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 17 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 18 * version 2 for more details (a copy is included in the LICENSE file that 19 * accompanied this code). 20 * 21 * You should have received a copy of the GNU General Public License version 22 * 2 along with this work; if not, write to the Free Software Foundation, 23 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 24 * 25 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 26 * or visit www.oracle.com if you need additional information or have any 27 * questions. 28 */ 29 30 /* 31 * @test 32 * @summary Test of VM.dynlib diagnostic command via MBean 33 * @library /testlibrary 34 * @build com.oracle.java.testlibrary.* 35 * @build com.oracle.java.testlibrary.dcmd.* 36 * @run testng DynLibsTest 37 */ 38 39 public class DynLibsTest { 40 41 public void run(CommandExecutor executor) { 42 OutputAnalyzer output = executor.execute("VM.dynlibs"); 43 44 String osDependentBaseString = null; 45 if (Platform.isAix()) { 46 osDependentBaseString = "lib%s.so"; 47 } else if (Platform.isLinux()) { 48 osDependentBaseString = "lib%s.so"; 49 } else if (Platform.isOSX()) { 50 osDependentBaseString = "lib%s.dylib"; 51 } else if (Platform.isSolaris()) { 52 osDependentBaseString = "lib%s.so"; 53 } else if (Platform.isWindows()) { 54 osDependentBaseString = "%s.dll"; 55 } 56 57 if (osDependentBaseString == null) { 58 throw new RuntimeException("Unsupported OS"); 59 } 60 61 output.shouldContain(String.format(osDependentBaseString, "jvm")); 62 output.shouldContain(String.format(osDependentBaseString, "java")); 63 output.shouldContain(String.format(osDependentBaseString, "management")); 64 } 65 66 @Test 67 public void jmx() { 68 run(new JMXExecutor()); 69 } 70 }