changeset 14483:4fd9addf4669

Expand test coverage for java -XaddExports Contributed-by: sergei.pikalev@oracle.com
author alanb
date Sat, 14 Nov 2015 11:31:48 +0000
parents c98256f2e102
children b7d2a7346aa6
files test/jdk/jigsaw/launcher/addexports/AddExportsTest.java test/jdk/jigsaw/launcher/addexports/src/java.transaction/javax/transaction/Transaction.java test/jdk/jigsaw/launcher/addexports/src/java.transaction/javax/transaction/internal/InternalTransaction.java test/jdk/jigsaw/launcher/addexports/src/java.transaction/module-info.java test/jdk/jigsaw/launcher/addexports/src/one.more/module-info.java test/jdk/jigsaw/launcher/addexports/src/one.more/one/internal/InternalClass.java test/jdk/jigsaw/launcher/addexports/src/one.more/one/more/OneMoreClass.java test/jdk/jigsaw/launcher/addexports/src/testAdd/jdk/test/UsesInternalClass.java test/jdk/jigsaw/launcher/addexports/src/testAdd/module-info.java test/jdk/jigsaw/launcher/addexports/src/testUpgrade/jdk/test/UsesInternalTransaction.java test/jdk/jigsaw/launcher/addexports/src/testUpgrade/module-info.java
diffstat 11 files changed, 352 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/test/jdk/jigsaw/launcher/addexports/AddExportsTest.java	Sat Nov 14 08:35:13 2015 +0000
+++ b/test/jdk/jigsaw/launcher/addexports/AddExportsTest.java	Sat Nov 14 11:31:48 2015 +0000
@@ -48,12 +48,17 @@
 
     private static final Path SRC_DIR = Paths.get(TEST_SRC, "src");
     private static final Path MODS_DIR = Paths.get("mods");
+    private static final Path UPGRMODS_DIR = Paths.get("upgrmods");
 
     // the module name of the test module
     private static final String TEST_MODULE = "test";
+    private static final String TEST_MODULE_ADD = "testAdd";
+    private static final String TEST_MODULE_UPGRADE = "testUpgrade";
 
     // the module main class
     private static final String MAIN_CLASS = "jdk.test.UsesUnsafe";
+    private static final String MAIN_CLASS_ADD = "jdk.test.UsesInternalClass";
+    private static final String MAIN_CLASS_UPGRADE = "jdk.test.UsesInternalTransaction";
 
 
     @BeforeTest
@@ -64,8 +69,35 @@
             = CompilerUtils.compile(SRC_DIR.resolve(TEST_MODULE),
                                     MODS_DIR.resolve(TEST_MODULE),
                                     "-XaddExports:java.base/sun.misc=test");
+        assertTrue(compiled, "test module did not compile");
 
-        assertTrue(compiled, "test module did not compile");
+        // javac -d upgrmods/$ADDMODULE src/$ADDMODULE/**
+        compiled
+            = CompilerUtils.compile(SRC_DIR.resolve("one.more"),
+                                    MODS_DIR.resolve("one.more"));
+        assertTrue(compiled, "added module did not compile");
+
+        // javac -d mods/$TESTADD src/$TESTADD/**
+        compiled
+            = CompilerUtils.compile(SRC_DIR.resolve(TEST_MODULE_ADD),
+                                    MODS_DIR.resolve(TEST_MODULE_ADD),
+                                    "-mp", MODS_DIR.toString(),
+                                    "-XaddExports:one.more/one.internal=testAdd");
+        assertTrue(compiled, "test add module did not compile");
+
+        // javac -d upgrmods/$UPGRMODULE src/$UPGRMODULE/**
+        compiled
+            = CompilerUtils.compile(SRC_DIR.resolve("java.transaction"),
+                                    UPGRMODS_DIR.resolve("java.transaction"));
+        assertTrue(compiled, "upgraded module did not compile");
+
+        // javac -d mods/$TESTUPGRADE src/$TESTUPGRADE/**
+        compiled
+            = CompilerUtils.compile(SRC_DIR.resolve(TEST_MODULE_UPGRADE),
+                                    MODS_DIR.resolve(TEST_MODULE_UPGRADE),
+                                    "-upgrademodulepath", UPGRMODS_DIR.toString(),
+                                    "-XaddExports:java.transaction/javax.transaction.internal=testUpgrade");
+        assertTrue(compiled, "test upgrade module did not compile");
     }
 
     /**
@@ -126,6 +158,48 @@
     }
 
     /**
+     * Run added modules with -XaddExports
+     */
+    public void testAdddedModule() throws Exception {
+
+        // java -XaddExports:one.more/one.internal=testAdd
+        // -mp mods -addmods one.more -m testAdd/jdk.test.UsesInternalClas
+
+        String mid = TEST_MODULE_ADD + "/" + MAIN_CLASS_ADD;
+        int exitValue =
+            executeTestJava("-XaddExports:one.more/one.internal=testAdd",
+                            "-mp", MODS_DIR.toString(),
+                            "-addmods", "one.more",
+                            "-m", mid)
+                .outputTo(System.out)
+                .errorTo(System.out)
+                .getExitValue();
+
+        assertTrue(exitValue == 0);
+    }
+
+    /**
+     * Run upgraded modules with -XaddExports
+     */
+    public void testUpgradedModule() throws Exception {
+
+        // java -upgrademodulepath upgrmods -mp mods
+        // -m testUpgrade/jdk.test.UsesInternalTransaction
+
+        String mid = TEST_MODULE_UPGRADE + "/" + MAIN_CLASS_UPGRADE;
+        int exitValue =
+            executeTestJava("-XaddExports:java.transaction/javax.transaction.internal=testUpgrade",
+                            "-upgrademodulepath", UPGRMODS_DIR.toString(),
+                            "-mp", MODS_DIR.toString(),
+                            "-m", mid)
+                .outputTo(System.out)
+                .errorTo(System.out)
+                .getExitValue();
+
+        assertTrue(exitValue == 0);
+    }
+
+    /**
      * -XaddExports can only be specified once
      */
     public void testWithDuplicateOption() throws Exception {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/jigsaw/launcher/addexports/src/java.transaction/javax/transaction/Transaction.java	Sat Nov 14 11:31:48 2015 +0000
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package javax.transaction;
+
+public class Transaction {
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/jigsaw/launcher/addexports/src/java.transaction/javax/transaction/internal/InternalTransaction.java	Sat Nov 14 11:31:48 2015 +0000
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package javax.transaction.internal;
+
+public class InternalTransaction {
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/jigsaw/launcher/addexports/src/java.transaction/module-info.java	Sat Nov 14 11:31:48 2015 +0000
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+module java.transaction {
+    exports javax.transaction;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/jigsaw/launcher/addexports/src/one.more/module-info.java	Sat Nov 14 11:31:48 2015 +0000
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+module one.more {
+    exports one.more;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/jigsaw/launcher/addexports/src/one.more/one/internal/InternalClass.java	Sat Nov 14 11:31:48 2015 +0000
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package one.internal;
+
+public class InternalClass {
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/jigsaw/launcher/addexports/src/one.more/one/more/OneMoreClass.java	Sat Nov 14 11:31:48 2015 +0000
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package one.more;
+
+public class OneMoreClass {
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/jigsaw/launcher/addexports/src/testAdd/jdk/test/UsesInternalClass.java	Sat Nov 14 11:31:48 2015 +0000
@@ -0,0 +1,32 @@
+/**
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.test;
+
+import one.internal.InternalClass;
+
+public class UsesInternalClass {
+    public static void main(String[] args) throws Exception {
+        InternalClass ic = new InternalClass();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/jigsaw/launcher/addexports/src/testAdd/module-info.java	Sat Nov 14 11:31:48 2015 +0000
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+module testAdd {
+    requires one.more;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/jigsaw/launcher/addexports/src/testUpgrade/jdk/test/UsesInternalTransaction.java	Sat Nov 14 11:31:48 2015 +0000
@@ -0,0 +1,32 @@
+/**
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.test;
+
+import javax.transaction.internal.InternalTransaction;
+
+public class UsesInternalTransaction {
+    public static void main(String[] args) throws Exception {
+        InternalTransaction ic = new InternalTransaction();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/jigsaw/launcher/addexports/src/testUpgrade/module-info.java	Sat Nov 14 11:31:48 2015 +0000
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+module testUpgrade {
+    requires java.transaction;
+}
+