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 * @bug 8199871 27 * @summary pack200 and unpack200 should print out deprecate warning 28 * @modules jdk.pack 29 * @compile -XDignore.symbol.file Utils.java 30 * @run testng DeprecatePack200 31 */ 32 33 import java.util.List; 34 import org.testng.annotations.DataProvider; 35 import org.testng.annotations.Test; 36 37 import static org.testng.Assert.assertEquals; 38 39 public class DeprecatePack200 { 40 final static String PACK200_CMD = Utils.getPack200Cmd(); 41 final static String UNPACK200_CMD = Utils.getUnpack200Cmd(); 42 final static String PACK200_MSG = "Warning: The pack200 tool is planned to be removed in a future JDK release."; 43 final static String UNPACK200_MSG = "Warning: The unpack200 tool is planned to be removed in a future JDK release."; 44 45 @DataProvider(name="tools") 46 public static final Object[][] provide() { return cases; } 47 48 private static final Object[][] cases = { 49 { PACK200_MSG, 1, List.of(PACK200_CMD) }, 50 { PACK200_MSG, 1, List.of(PACK200_CMD, "-V") }, 51 { PACK200_MSG, 2, List.of(PACK200_CMD, "--help") }, 52 { PACK200_MSG, 0, List.of(PACK200_CMD, "-XDsuppress-tool-removal-message") }, 53 { PACK200_MSG, 0, List.of(PACK200_CMD, "--version", "-XDsuppress-tool-removal-message") }, 54 { PACK200_MSG, 0, List.of(PACK200_CMD, "-h", "-XDsuppress-tool-removal-message") }, 55 56 { UNPACK200_MSG, 1, List.of(UNPACK200_CMD) }, 57 { UNPACK200_MSG, 1, List.of(UNPACK200_CMD, "-V") }, 58 { UNPACK200_MSG, 1, List.of(UNPACK200_CMD, "--help") }, 59 { UNPACK200_MSG, 0, List.of(UNPACK200_CMD, "-XDsuppress-tool-removal-message") }, 60 { UNPACK200_MSG, 0, List.of(UNPACK200_CMD, "--version", "-XDsuppress-tool-removal-message") }, 61 { UNPACK200_MSG, 0, List.of(UNPACK200_CMD, "-h", "-XDsuppress-tool-removal-message") } 62 }; 63 64 @Test(dataProvider = "tools") 65 public void CheckWarnings(String msg, long count, List<String> cmd) { 66 List<String> output = Utils.runExec(cmd, null, true); 67 assertEquals(output.stream().filter(s -> s.equals(msg)).count(), count); 68 } 69 }