jdk/test/java/lang/System/LoggerFinder/modules/NamedLoggerForJDKTest.java
author iignatyev
Tue, 06 Jun 2017 19:54:08 -0700
changeset 45393 de4e1efc8eec
parent 44672 1359e7ce8945
permissions -rw-r--r--
8181335: remove packageless CompilerUtils Reviewed-by: alanb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
44672
1359e7ce8945 8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff changeset
     1
/*
1359e7ce8945 8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff changeset
     2
 * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
1359e7ce8945 8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
1359e7ce8945 8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff changeset
     4
 *
1359e7ce8945 8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
1359e7ce8945 8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
1359e7ce8945 8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
1359e7ce8945 8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
1359e7ce8945 8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
1359e7ce8945 8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff changeset
    10
 *
1359e7ce8945 8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
1359e7ce8945 8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1359e7ce8945 8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
1359e7ce8945 8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
1359e7ce8945 8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff changeset
    15
 * accompanied this code).
1359e7ce8945 8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff changeset
    16
 *
1359e7ce8945 8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
1359e7ce8945 8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
1359e7ce8945 8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1359e7ce8945 8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff changeset
    20
 *
1359e7ce8945 8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1359e7ce8945 8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
1359e7ce8945 8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff changeset
    23
 * questions.
1359e7ce8945 8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff changeset
    24
 */
1359e7ce8945 8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff changeset
    25
1359e7ce8945 8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff changeset
    26
import java.io.File;
1359e7ce8945 8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff changeset
    27
import java.nio.file.Files;
1359e7ce8945 8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff changeset
    28
import java.nio.file.Path;
1359e7ce8945 8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff changeset
    29
import java.nio.file.Paths;
1359e7ce8945 8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff changeset
    30
import java.nio.file.StandardCopyOption;
1359e7ce8945 8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff changeset
    31
import java.util.ArrayList;
1359e7ce8945 8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff changeset
    32
import java.util.List;
1359e7ce8945 8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff changeset
    33
import java.util.stream.Stream;
1359e7ce8945 8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff changeset
    34
1359e7ce8945 8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff changeset
    35
import jdk.testlibrary.JDKToolFinder;
1359e7ce8945 8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff changeset
    36
1359e7ce8945 8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff changeset
    37
import static jdk.testlibrary.ProcessTools.executeCommand;
1359e7ce8945 8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff changeset
    38
1359e7ce8945 8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff changeset
    39
/*
1359e7ce8945 8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff changeset
    40
 * @test
1359e7ce8945 8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff changeset
    41
 * @modules jdk.compiler
1359e7ce8945 8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff changeset
    42
 * @summary Test cases which run against the JDK image, check the situation where
1359e7ce8945 8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff changeset
    43
 *            1. logger providers are in named module,
1359e7ce8945 8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff changeset
    44
 *            2. clients are in named/unnamed module,
1359e7ce8945 8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff changeset
    45
 *               patched system module, or Xbootclasspath
1359e7ce8945 8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff changeset
    46
 *          This test does not require existence of java.logging module,
1359e7ce8945 8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff changeset
    47
 *          but require jdk.compiler module
45393
de4e1efc8eec 8181335: remove packageless CompilerUtils
iignatyev
parents: 44672
diff changeset
    48
 * @library /lib/testlibrary /test/lib
de4e1efc8eec 8181335: remove packageless CompilerUtils
iignatyev
parents: 44672
diff changeset
    49
 * @build Base jdk.test.lib.compiler.CompilerUtils jdk.testlibrary.*
44672
1359e7ce8945 8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff changeset
    50
 * @run main/othervm NamedLoggerForJDKTest
1359e7ce8945 8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff changeset
    51
 */
1359e7ce8945 8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff changeset
    52
1359e7ce8945 8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff changeset
    53
public class NamedLoggerForJDKTest extends Base {
1359e7ce8945 8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff changeset
    54
1359e7ce8945 8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff changeset
    55
    public static void main(String args[]) throws Throwable {
1359e7ce8945 8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff changeset
    56
        NamedLoggerForJDKTest t = new NamedLoggerForJDKTest();
1359e7ce8945 8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff changeset
    57
        t.setup();
1359e7ce8945 8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff changeset
    58
        t.test();
1359e7ce8945 8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff changeset
    59
    }
1359e7ce8945 8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff changeset
    60
1359e7ce8945 8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff changeset
    61
    private void setup() throws Throwable {
1359e7ce8945 8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff changeset
    62
        setupAllClient();
1359e7ce8945 8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff changeset
    63
1359e7ce8945 8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff changeset
    64
        setupNamedLogger();
1359e7ce8945 8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff changeset
    65
    }
1359e7ce8945 8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff changeset
    66
1359e7ce8945 8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff changeset
    67
    private void test() throws Throwable {
1359e7ce8945 8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff changeset
    68
        // logger client is in named module m.t.a
1359e7ce8945 8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff changeset
    69
        runTest(JDK_IMAGE,
1359e7ce8945 8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff changeset
    70
                "--module-path", DEST_NAMED_LOGGER.toString()
1359e7ce8945 8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff changeset
    71
                    + File.pathSeparator + DEST_NAMED_CLIENT.toString(),
1359e7ce8945 8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff changeset
    72
                "-m", CLIENT_A, "named", LOGGER_A);
1359e7ce8945 8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff changeset
    73
        // logger client is in unnamed module
1359e7ce8945 8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff changeset
    74
        runTest(JDK_IMAGE,
1359e7ce8945 8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff changeset
    75
                "--module-path", DEST_NAMED_LOGGER.toString(),
1359e7ce8945 8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff changeset
    76
                "--class-path", DEST_UNNAMED_CLIENT.toString(),
1359e7ce8945 8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff changeset
    77
                CLIENT_B, "named", LOGGER_A);
1359e7ce8945 8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff changeset
    78
        // logger client gets logger through boot class BootUsage
1359e7ce8945 8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff changeset
    79
        runTest(JDK_IMAGE,
1359e7ce8945 8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff changeset
    80
                "--module-path", DEST_NAMED_LOGGER.toString(),
1359e7ce8945 8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff changeset
    81
                "-Xbootclasspath/a:" + DEST_BOOT_USAGE.toString(),
1359e7ce8945 8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff changeset
    82
                "--class-path", DEST_BOOT_CLIENT.toString(),
1359e7ce8945 8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff changeset
    83
                BOOT_CLIENT, "system", LAZY_LOGGER, LOGGER_A);
1359e7ce8945 8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff changeset
    84
        // logger client gets logger through patched class
1359e7ce8945 8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff changeset
    85
        // java.base/java.lang.PatchedUsage
1359e7ce8945 8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff changeset
    86
        runTest(JDK_IMAGE,
1359e7ce8945 8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff changeset
    87
                "--module-path", DEST_NAMED_LOGGER.toString(),
1359e7ce8945 8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff changeset
    88
                "--patch-module", "java.base=" + DEST_PATCHED_USAGE.toString(),
1359e7ce8945 8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff changeset
    89
                "--class-path", DEST_PATCHED_CLIENT.toString(),
1359e7ce8945 8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff changeset
    90
                PATCHED_CLIENT, "system", LAZY_LOGGER, LOGGER_A);
1359e7ce8945 8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff changeset
    91
    }
1359e7ce8945 8145163: Test Task for Platform Logging API and Service -- for moduralization
mli
parents:
diff changeset
    92
}