test/jdk/tools/pack200/DeprecatePack200.java
author lancea
Thu, 14 Nov 2019 10:54:32 -0500
changeset 59083 3e4d8b5856f3
parent 50603 95c0644a1c47
permissions -rw-r--r--
8234080: jdk/nio/zipfs/CRCWriteTest.java fails Reviewed-by: clanger, amlu
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
50603
95c0644a1c47 8199871: Deprecate pack200 and unpack200 tools
henryjen
parents:
diff changeset
     1
/*
95c0644a1c47 8199871: Deprecate pack200 and unpack200 tools
henryjen
parents:
diff changeset
     2
 * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
95c0644a1c47 8199871: Deprecate pack200 and unpack200 tools
henryjen
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
95c0644a1c47 8199871: Deprecate pack200 and unpack200 tools
henryjen
parents:
diff changeset
     4
 *
95c0644a1c47 8199871: Deprecate pack200 and unpack200 tools
henryjen
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
95c0644a1c47 8199871: Deprecate pack200 and unpack200 tools
henryjen
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
95c0644a1c47 8199871: Deprecate pack200 and unpack200 tools
henryjen
parents:
diff changeset
     7
 * published by the Free Software Foundation.
95c0644a1c47 8199871: Deprecate pack200 and unpack200 tools
henryjen
parents:
diff changeset
     8
 *
95c0644a1c47 8199871: Deprecate pack200 and unpack200 tools
henryjen
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
95c0644a1c47 8199871: Deprecate pack200 and unpack200 tools
henryjen
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
95c0644a1c47 8199871: Deprecate pack200 and unpack200 tools
henryjen
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
95c0644a1c47 8199871: Deprecate pack200 and unpack200 tools
henryjen
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
95c0644a1c47 8199871: Deprecate pack200 and unpack200 tools
henryjen
parents:
diff changeset
    13
 * accompanied this code).
95c0644a1c47 8199871: Deprecate pack200 and unpack200 tools
henryjen
parents:
diff changeset
    14
 *
95c0644a1c47 8199871: Deprecate pack200 and unpack200 tools
henryjen
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
95c0644a1c47 8199871: Deprecate pack200 and unpack200 tools
henryjen
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
95c0644a1c47 8199871: Deprecate pack200 and unpack200 tools
henryjen
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
95c0644a1c47 8199871: Deprecate pack200 and unpack200 tools
henryjen
parents:
diff changeset
    18
 *
95c0644a1c47 8199871: Deprecate pack200 and unpack200 tools
henryjen
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
95c0644a1c47 8199871: Deprecate pack200 and unpack200 tools
henryjen
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
95c0644a1c47 8199871: Deprecate pack200 and unpack200 tools
henryjen
parents:
diff changeset
    21
 * questions.
95c0644a1c47 8199871: Deprecate pack200 and unpack200 tools
henryjen
parents:
diff changeset
    22
 */
95c0644a1c47 8199871: Deprecate pack200 and unpack200 tools
henryjen
parents:
diff changeset
    23
95c0644a1c47 8199871: Deprecate pack200 and unpack200 tools
henryjen
parents:
diff changeset
    24
/**
95c0644a1c47 8199871: Deprecate pack200 and unpack200 tools
henryjen
parents:
diff changeset
    25
 * @test
95c0644a1c47 8199871: Deprecate pack200 and unpack200 tools
henryjen
parents:
diff changeset
    26
 * @bug 8199871
95c0644a1c47 8199871: Deprecate pack200 and unpack200 tools
henryjen
parents:
diff changeset
    27
 * @summary pack200 and unpack200 should print out deprecate warning
95c0644a1c47 8199871: Deprecate pack200 and unpack200 tools
henryjen
parents:
diff changeset
    28
 * @modules jdk.pack
95c0644a1c47 8199871: Deprecate pack200 and unpack200 tools
henryjen
parents:
diff changeset
    29
 * @compile -XDignore.symbol.file Utils.java
95c0644a1c47 8199871: Deprecate pack200 and unpack200 tools
henryjen
parents:
diff changeset
    30
 * @run testng DeprecatePack200
95c0644a1c47 8199871: Deprecate pack200 and unpack200 tools
henryjen
parents:
diff changeset
    31
 */
95c0644a1c47 8199871: Deprecate pack200 and unpack200 tools
henryjen
parents:
diff changeset
    32
95c0644a1c47 8199871: Deprecate pack200 and unpack200 tools
henryjen
parents:
diff changeset
    33
import java.util.List;
95c0644a1c47 8199871: Deprecate pack200 and unpack200 tools
henryjen
parents:
diff changeset
    34
import java.util.function.Predicate;
95c0644a1c47 8199871: Deprecate pack200 and unpack200 tools
henryjen
parents:
diff changeset
    35
import java.util.regex.Pattern;
95c0644a1c47 8199871: Deprecate pack200 and unpack200 tools
henryjen
parents:
diff changeset
    36
import org.testng.annotations.DataProvider;
95c0644a1c47 8199871: Deprecate pack200 and unpack200 tools
henryjen
parents:
diff changeset
    37
import org.testng.annotations.Test;
95c0644a1c47 8199871: Deprecate pack200 and unpack200 tools
henryjen
parents:
diff changeset
    38
95c0644a1c47 8199871: Deprecate pack200 and unpack200 tools
henryjen
parents:
diff changeset
    39
import static org.testng.Assert.assertEquals;
95c0644a1c47 8199871: Deprecate pack200 and unpack200 tools
henryjen
parents:
diff changeset
    40
95c0644a1c47 8199871: Deprecate pack200 and unpack200 tools
henryjen
parents:
diff changeset
    41
public class DeprecatePack200 {
95c0644a1c47 8199871: Deprecate pack200 and unpack200 tools
henryjen
parents:
diff changeset
    42
    final static String PACK200_CMD = Utils.getPack200Cmd();
95c0644a1c47 8199871: Deprecate pack200 and unpack200 tools
henryjen
parents:
diff changeset
    43
    final static String UNPACK200_CMD = Utils.getUnpack200Cmd();
95c0644a1c47 8199871: Deprecate pack200 and unpack200 tools
henryjen
parents:
diff changeset
    44
    final static Predicate<String> PACK200_MSG = Pattern.compile(
95c0644a1c47 8199871: Deprecate pack200 and unpack200 tools
henryjen
parents:
diff changeset
    45
            "Warning: The pack200(\\.exe)?? tool is deprecated, and is planned for removal in a future JDK release.")
95c0644a1c47 8199871: Deprecate pack200 and unpack200 tools
henryjen
parents:
diff changeset
    46
            .asMatchPredicate();
95c0644a1c47 8199871: Deprecate pack200 and unpack200 tools
henryjen
parents:
diff changeset
    47
    final static Predicate<String> UNPACK200_MSG = Pattern.compile(
95c0644a1c47 8199871: Deprecate pack200 and unpack200 tools
henryjen
parents:
diff changeset
    48
            "Warning: The unpack200(\\.exe)?? tool is deprecated, and is planned for removal in a future JDK release.")
95c0644a1c47 8199871: Deprecate pack200 and unpack200 tools
henryjen
parents:
diff changeset
    49
            .asMatchPredicate();
95c0644a1c47 8199871: Deprecate pack200 and unpack200 tools
henryjen
parents:
diff changeset
    50
95c0644a1c47 8199871: Deprecate pack200 and unpack200 tools
henryjen
parents:
diff changeset
    51
    @DataProvider(name="tools")
95c0644a1c47 8199871: Deprecate pack200 and unpack200 tools
henryjen
parents:
diff changeset
    52
    public static final Object[][] provide() { return cases; }
95c0644a1c47 8199871: Deprecate pack200 and unpack200 tools
henryjen
parents:
diff changeset
    53
95c0644a1c47 8199871: Deprecate pack200 and unpack200 tools
henryjen
parents:
diff changeset
    54
    private static final Object[][] cases = {
95c0644a1c47 8199871: Deprecate pack200 and unpack200 tools
henryjen
parents:
diff changeset
    55
        { PACK200_MSG, 1, List.of(PACK200_CMD) },
95c0644a1c47 8199871: Deprecate pack200 and unpack200 tools
henryjen
parents:
diff changeset
    56
        { PACK200_MSG, 1, List.of(PACK200_CMD, "-V") },
95c0644a1c47 8199871: Deprecate pack200 and unpack200 tools
henryjen
parents:
diff changeset
    57
        { PACK200_MSG, 2, List.of(PACK200_CMD, "--help") },
95c0644a1c47 8199871: Deprecate pack200 and unpack200 tools
henryjen
parents:
diff changeset
    58
        { PACK200_MSG, 0, List.of(PACK200_CMD, "-XDsuppress-tool-removal-message") },
95c0644a1c47 8199871: Deprecate pack200 and unpack200 tools
henryjen
parents:
diff changeset
    59
        { PACK200_MSG, 0, List.of(PACK200_CMD, "--version", "-XDsuppress-tool-removal-message") },
95c0644a1c47 8199871: Deprecate pack200 and unpack200 tools
henryjen
parents:
diff changeset
    60
        { PACK200_MSG, 0, List.of(PACK200_CMD, "-h", "-XDsuppress-tool-removal-message") },
95c0644a1c47 8199871: Deprecate pack200 and unpack200 tools
henryjen
parents:
diff changeset
    61
95c0644a1c47 8199871: Deprecate pack200 and unpack200 tools
henryjen
parents:
diff changeset
    62
        { UNPACK200_MSG, 1, List.of(UNPACK200_CMD) },
95c0644a1c47 8199871: Deprecate pack200 and unpack200 tools
henryjen
parents:
diff changeset
    63
        { UNPACK200_MSG, 1, List.of(UNPACK200_CMD, "-V") },
95c0644a1c47 8199871: Deprecate pack200 and unpack200 tools
henryjen
parents:
diff changeset
    64
        { UNPACK200_MSG, 1, List.of(UNPACK200_CMD, "--help") },
95c0644a1c47 8199871: Deprecate pack200 and unpack200 tools
henryjen
parents:
diff changeset
    65
        { UNPACK200_MSG, 0, List.of(UNPACK200_CMD, "-XDsuppress-tool-removal-message") },
95c0644a1c47 8199871: Deprecate pack200 and unpack200 tools
henryjen
parents:
diff changeset
    66
        { UNPACK200_MSG, 0, List.of(UNPACK200_CMD, "--version", "-XDsuppress-tool-removal-message") },
95c0644a1c47 8199871: Deprecate pack200 and unpack200 tools
henryjen
parents:
diff changeset
    67
        { UNPACK200_MSG, 0, List.of(UNPACK200_CMD, "-h", "-XDsuppress-tool-removal-message") }
95c0644a1c47 8199871: Deprecate pack200 and unpack200 tools
henryjen
parents:
diff changeset
    68
    };
95c0644a1c47 8199871: Deprecate pack200 and unpack200 tools
henryjen
parents:
diff changeset
    69
95c0644a1c47 8199871: Deprecate pack200 and unpack200 tools
henryjen
parents:
diff changeset
    70
    @Test(dataProvider = "tools")
95c0644a1c47 8199871: Deprecate pack200 and unpack200 tools
henryjen
parents:
diff changeset
    71
    public void CheckWarnings(Predicate<String> msg, long count, List<String> cmd) {
95c0644a1c47 8199871: Deprecate pack200 and unpack200 tools
henryjen
parents:
diff changeset
    72
        List<String> output = Utils.runExec(cmd, null, true);
95c0644a1c47 8199871: Deprecate pack200 and unpack200 tools
henryjen
parents:
diff changeset
    73
        assertEquals(output.stream().filter(msg).count(), count);
95c0644a1c47 8199871: Deprecate pack200 and unpack200 tools
henryjen
parents:
diff changeset
    74
    }
95c0644a1c47 8199871: Deprecate pack200 and unpack200 tools
henryjen
parents:
diff changeset
    75
}