Path: blob/master/test/langtools/jdk/javadoc/tool/modules/ReleaseOptions.java
40974 views
/*1* Copyright (c) 2017, 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*/2223/**24* @test25* @bug 8175346 817527726* @summary Test release option interactions27* @modules28* jdk.javadoc/jdk.javadoc.internal.api29* jdk.javadoc/jdk.javadoc.internal.tool30* jdk.compiler/com.sun.tools.javac.api31* jdk.compiler/com.sun.tools.javac.main32* @library /tools/lib33* @build toolbox.ToolBox toolbox.TestRunner34* @run main ReleaseOptions35*/3637import java.nio.file.Path;38import java.nio.file.Paths;3940import toolbox.*;4142public class ReleaseOptions extends ModuleTestBase {4344public static void main(String... args) throws Exception {45new ReleaseOptions().runTests();46}4748@Test49public void testReleaseWithPatchModule(Path base) throws Exception {50Path src = Paths.get(base.toString(), "src");51Path mpath = Paths.get(src. toString(), "m");5253tb.writeJavaFiles(mpath,54"module m { exports p; }",55"package p; public class C { }");5657Task.Result result = execNegativeTask("--release", "8",58"--patch-module", "m=" + mpath.toString(),59"p");60assertMessagePresent(".*not allowed with target 8.*");61assertMessageNotPresent(".*Exception*");62assertMessageNotPresent(".java.lang.AssertionError.*");63}6465@Test66public void testReleaseWithSourcepath(Path base) throws Exception {67Path src = Paths.get(base.toString(), "src");68Path mpath = Paths.get(src. toString(), "m");6970tb.writeJavaFiles(mpath,71"module m { exports p; }",72"package p; public class C { }");7374Task.Result result = execNegativeTask("--release", "8",75"--source-path", mpath.toString(),76"--module", "m");77assertMessagePresent(".*(use -source 9 or higher to enable modules).*");78assertMessageNotPresent(".*Exception*");79assertMessageNotPresent(".java.lang.AssertionError.*");80}8182@Test83public void testReleaseWithModuleSourcepath(Path base) throws Exception {84Path src = Paths.get(base.toString(), "src");85Path mpath = Paths.get(src.toString(), "m");8687tb.writeJavaFiles(mpath,88"module m { exports p; }",89"package p; public class C { }");9091Task.Result result = execNegativeTask("--release", "8",92"--module-source-path", src.toString(),93"--module", "m");94assertMessagePresent(".*not allowed with target 8.*");95assertMessageNotPresent(".*Exception*");96assertMessageNotPresent(".java.lang.AssertionError.*");97}98}99100101