50603
|
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 java.util.function.Predicate;
|
|
35 |
import java.util.regex.Pattern;
|
|
36 |
import org.testng.annotations.DataProvider;
|
|
37 |
import org.testng.annotations.Test;
|
|
38 |
|
|
39 |
import static org.testng.Assert.assertEquals;
|
|
40 |
|
|
41 |
public class DeprecatePack200 {
|
|
42 |
final static String PACK200_CMD = Utils.getPack200Cmd();
|
|
43 |
final static String UNPACK200_CMD = Utils.getUnpack200Cmd();
|
|
44 |
final static Predicate<String> PACK200_MSG = Pattern.compile(
|
|
45 |
"Warning: The pack200(\\.exe)?? tool is deprecated, and is planned for removal in a future JDK release.")
|
|
46 |
.asMatchPredicate();
|
|
47 |
final static Predicate<String> UNPACK200_MSG = Pattern.compile(
|
|
48 |
"Warning: The unpack200(\\.exe)?? tool is deprecated, and is planned for removal in a future JDK release.")
|
|
49 |
.asMatchPredicate();
|
|
50 |
|
|
51 |
@DataProvider(name="tools")
|
|
52 |
public static final Object[][] provide() { return cases; }
|
|
53 |
|
|
54 |
private static final Object[][] cases = {
|
|
55 |
{ PACK200_MSG, 1, List.of(PACK200_CMD) },
|
|
56 |
{ PACK200_MSG, 1, List.of(PACK200_CMD, "-V") },
|
|
57 |
{ PACK200_MSG, 2, List.of(PACK200_CMD, "--help") },
|
|
58 |
{ PACK200_MSG, 0, List.of(PACK200_CMD, "-XDsuppress-tool-removal-message") },
|
|
59 |
{ PACK200_MSG, 0, List.of(PACK200_CMD, "--version", "-XDsuppress-tool-removal-message") },
|
|
60 |
{ PACK200_MSG, 0, List.of(PACK200_CMD, "-h", "-XDsuppress-tool-removal-message") },
|
|
61 |
|
|
62 |
{ UNPACK200_MSG, 1, List.of(UNPACK200_CMD) },
|
|
63 |
{ UNPACK200_MSG, 1, List.of(UNPACK200_CMD, "-V") },
|
|
64 |
{ UNPACK200_MSG, 1, List.of(UNPACK200_CMD, "--help") },
|
|
65 |
{ UNPACK200_MSG, 0, List.of(UNPACK200_CMD, "-XDsuppress-tool-removal-message") },
|
|
66 |
{ UNPACK200_MSG, 0, List.of(UNPACK200_CMD, "--version", "-XDsuppress-tool-removal-message") },
|
|
67 |
{ UNPACK200_MSG, 0, List.of(UNPACK200_CMD, "-h", "-XDsuppress-tool-removal-message") }
|
|
68 |
};
|
|
69 |
|
|
70 |
@Test(dataProvider = "tools")
|
|
71 |
public void CheckWarnings(Predicate<String> msg, long count, List<String> cmd) {
|
|
72 |
List<String> output = Utils.runExec(cmd, null, true);
|
|
73 |
assertEquals(output.stream().filter(msg).count(), count);
|
|
74 |
}
|
|
75 |
}
|