Path: blob/master/test/jdk/java/lang/ModuleTests/access/AccessTest.java
41153 views
/*1* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223import java.nio.file.Path;24import java.nio.file.Paths;25import java.util.Arrays;26import java.util.List;2728import jdk.test.lib.compiler.CompilerUtils;29import static jdk.test.lib.process.ProcessTools.executeTestJava;3031import org.testng.annotations.BeforeTest;32import org.testng.annotations.Test;33import static org.testng.Assert.*;3435/**36* @test37* @library /test/lib38* @modules jdk.compiler39* @build AccessTest jdk.test.lib.compiler.CompilerUtils40* @run testng AccessTest41* @summary Driver for test that checks access to access to types in42* exported and non-exported packages.43*/4445@Test46public class AccessTest {4748private static final String TEST_SRC = System.getProperty("test.src");4950private static final Path SRC_DIR = Paths.get(TEST_SRC, "src");51private static final Path MODS_DIR = Paths.get("mods");525354// the names of the modules in this test55private static List<String> modules = Arrays.asList("test", "target");565758/**59* Compiles all modules used by the test60*/61@BeforeTest62public void compileAll() throws Exception {63for (String mn : modules) {64Path src = SRC_DIR.resolve(mn);65Path mods = MODS_DIR.resolve(mn);66assertTrue(CompilerUtils.compile(src, mods));67}68}6970/**71* Run the test72*/73public void runTest() throws Exception {74int exitValue75= executeTestJava("--module-path", MODS_DIR.toString(),76"--add-modules", "target",77"-Dsun.reflect.enableStrictMode=true",78"-m", "test/test.Main")79.outputTo(System.out)80.errorTo(System.out)81.getExitValue();8283assertTrue(exitValue == 0);84}8586}878889