LingeredAppTest.java revision 1524:609627f9db3f
195533Smike/* 295533Smike * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. 395533Smike * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 495533Smike * 595533Smike * This code is free software; you can redistribute it and/or modify it 695533Smike * under the terms of the GNU General Public License version 2 only, as 795533Smike * published by the Free Software Foundation. 895533Smike * 995533Smike * This code is distributed in the hope that it will be useful, but WITHOUT 1095533Smike * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1195533Smike * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1295533Smike * version 2 for more details (a copy is included in the LICENSE file that 1395533Smike * accompanied this code). 1495533Smike * 1595533Smike * You should have received a copy of the GNU General Public License version 1695533Smike * 2 along with this work; if not, write to the Free Software Foundation, 1795533Smike * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1895533Smike * 1995533Smike * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2095533Smike * or visit www.oracle.com if you need additional information or have any 2195533Smike * questions. 2295533Smike */ 2395533Smike 2495533Smike/* 2595533Smike * @test 2695533Smike * @summary Unit test for LingeredApp 2795533Smike * @compile LingeredAppTest.java 2895533Smike * @compile LingeredApp.java 2995533Smike * @run main LingeredAppTest 3095533Smike */ 3195533Smike 3295533Smikepackage jdk.test.lib.apps; 3395737Smike 3495533Smikeimport java.io.IOException; 3595533Smikeimport java.util.ArrayList; 36208331Sphk 37208331Sphkpublic class LingeredAppTest { 38208331Sphk 39208331Sphk public static void main(String[] args) { 40208331Sphk try { 4195737Smike System.out.println("Starting LingeredApp with default parameters"); 4295737Smike 4395737Smike ArrayList<String> cmd = new ArrayList<String>(); 4495737Smike 4595737Smike // Propagate test.vm.options to LingeredApp, filter out possible empty options 4695737Smike String testVmOpts[] = System.getProperty("test.vm.opts","").split("\\s+"); 4795737Smike for (String s : testVmOpts) { 4895737Smike if (!s.equals("")) { 4995737Smike cmd.add(s); 5095737Smike } 5195737Smike } 5295737Smike 5395737Smike cmd.add("-XX:+PrintFlagsFinal"); 5495737Smike 5595737Smike LingeredApp a = LingeredApp.startApp(cmd); 5695533Smike System.out.printf("App pid: %d\n", a.getPid()); 5795533Smike a.stopApp(); 5895533Smike 5995533Smike System.out.println("App output:"); 6095533Smike int count = 0; 6195533Smike for (String line : a.getAppOutput()) { 6295533Smike count += 1; 6395533Smike } 6495533Smike System.out.println("Found " + count + " lines in VM output"); 6595533Smike System.out.println("Test PASSED"); 6695533Smike } catch (IOException ex) { 6795533Smike ex.printStackTrace(); 6895533Smike System.out.println("Test ERROR"); 6995533Smike System.exit(3); 7095533Smike } 7195737Smike } 7295737Smike} 7395737Smike