1 /* 2 * Copyright (c) 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 /* 25 * @test 26 * @summary jpackager create image verbose test 27 * @build JPackagerHelper 28 * @modules jdk.jpackager 29 * @run main/othervm -Xmx512m JPackagerCreateImageVerboseTest 30 */ 31 public class JPackagerCreateImageVerboseTest { 32 33 private static final String[] CMD = { 34 "create-image", 35 "--input", "input", 36 "--output", "output", 37 "--name", "test", 38 "--main-jar", "hello.jar", 39 "--class", "Hello", 40 "--force", 41 "--files", "hello.jar"}; 42 43 private static final String[] CMD_VERBOSE = { 44 "create-image", 45 "--input", "input", 46 "--output", "output", 47 "--name", "test", 48 "--main-jar", "hello.jar", 49 "--class", "Hello", 50 "--files", "hello.jar", 51 "--force", 52 "--verbose"}; 53 54 private static void validate(String result, String resultVerbose) 55 throws Exception { 56 String[] r = result.split("\n"); 57 String[] rv = resultVerbose.split("\n"); 58 59 if (r.length >= rv.length) { 60 System.err.println("r.length: " + r.length); 61 System.err.println(result); 62 System.err.println("rv.length: " + rv.length); 63 System.err.println(resultVerbose); 64 throw new AssertionError( 65 "non-verbose output is less or equal to verbose output"); 66 } 67 } 68 69 private static void testCreateImage() throws Exception { 70 String result = JPackagerHelper.executeCLI(true, CMD); 71 String resultVerbose = JPackagerHelper.executeCLI(true, CMD_VERBOSE); 72 validate(result, resultVerbose); 73 } 74 75 private static void testCreateImageToolProvider() throws Exception { 76 String result = JPackagerHelper.executeToolProvider(true, CMD); 77 String resultVerbose = 78 JPackagerHelper.executeToolProvider(true, CMD_VERBOSE); 79 validate(result, resultVerbose); 80 } 81 82 public static void main(String[] args) throws Exception { 83 JPackagerHelper.createHelloJar(); 84 testCreateImage(); 85 testCreateImageToolProvider(); 86 } 87 88 }