< prev index next >

test/jdk/tools/launcher/modules/addmods/AddModsTest.java

Print this page


   1 /*
   2  * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */


  81 
  82     /**
  83      * Basic test of --add-modules ALL-DEFAULT. Module java.sql should be
  84      * resolved and the types in that module should be visible.
  85      */
  86     public void testAddDefaultModules1() throws Exception {
  87 
  88         // java --add-modules ALL-DEFAULT --module-path mods1 -m test ...
  89         int exitValue
  90             = executeTestJava("--module-path", MODS1_DIR.toString(),
  91                               "--add-modules", "ALL-DEFAULT",
  92                               "-m", TEST_MID,
  93                               "java.sql.Connection")
  94                 .outputTo(System.out)
  95                 .errorTo(System.out)
  96                 .getExitValue();
  97 
  98         assertTrue(exitValue == 0);
  99     }
 100 
 101     /**
 102      * Basic test of --add-modules ALL-DEFAULT. Module java.xml.ws.annotation
 103      * should not resolved and so the types in that module should not be
 104      * visible.
 105      */
 106     public void testAddDefaultModules2() throws Exception {
 107 
 108         // java --add-modules ALL-DEFAULT --module-path mods1 -m test ...
 109         int exitValue
 110             = executeTestJava("--module-path", MODS1_DIR.toString(),
 111                               "--add-modules", "ALL-DEFAULT",
 112                               "-m", TEST_MID,
 113                               "javax.annotation.Generated")
 114                 .outputTo(System.out)
 115                 .errorTo(System.out)
 116                 .shouldContain("ClassNotFoundException")
 117                 .getExitValue();
 118 
 119         assertTrue(exitValue != 0);
 120     }
 121 
 122     /**
 123      * Basic test of --add-modules ALL-SYSTEM. All system modules should be resolved
 124      * and thus all types in those modules should be visible.
 125      */
 126     public void testAddSystemModules() throws Exception {
 127 
 128         // java --add-modules ALL-SYSTEM --module-path mods1 -m test ...
 129         int exitValue
 130             = executeTestJava("--module-path", MODS1_DIR.toString(),
 131                               "--add-modules", "ALL-SYSTEM",
 132                               "-m", TEST_MID,
 133                               "java.sql.Connection",
 134                               "javax.annotation.Generated")
 135                 .outputTo(System.out)
 136                 .errorTo(System.out)
 137                 .getExitValue();
 138 
 139         assertTrue(exitValue == 0);
 140     }
 141 
 142 
 143     /**
 144      * Run test on class path to load a type in a module on the application
 145      * module path, uses {@code --add-modules logger}.
 146      */
 147     public void testRunWithAddMods() throws Exception {
 148 
 149         // java --module-path mods --add-modules logger -cp classes test.Main
 150         String classpath = MODS1_DIR.resolve(TEST_MODULE).toString();
 151         String modulepath = MODS2_DIR.toString();
 152         int exitValue
 153             = executeTestJava("--module-path", modulepath,
 154                               "--add-modules", LOGGER_MODULE,
 155                               "-cp", classpath,
 156                               TEST_MAIN_CLASS,
 157                               "logger.Logger")
 158                 .outputTo(System.out)
 159                 .errorTo(System.out)
 160                 .getExitValue();
 161 


   1 /*
   2  * Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */


  81 
  82     /**
  83      * Basic test of --add-modules ALL-DEFAULT. Module java.sql should be
  84      * resolved and the types in that module should be visible.
  85      */
  86     public void testAddDefaultModules1() throws Exception {
  87 
  88         // java --add-modules ALL-DEFAULT --module-path mods1 -m test ...
  89         int exitValue
  90             = executeTestJava("--module-path", MODS1_DIR.toString(),
  91                               "--add-modules", "ALL-DEFAULT",
  92                               "-m", TEST_MID,
  93                               "java.sql.Connection")
  94                 .outputTo(System.out)
  95                 .errorTo(System.out)
  96                 .getExitValue();
  97 
  98         assertTrue(exitValue == 0);
  99     }
 100 









































 101 
 102     /**
 103      * Run test on class path to load a type in a module on the application
 104      * module path, uses {@code --add-modules logger}.
 105      */
 106     public void testRunWithAddMods() throws Exception {
 107 
 108         // java --module-path mods --add-modules logger -cp classes test.Main
 109         String classpath = MODS1_DIR.resolve(TEST_MODULE).toString();
 110         String modulepath = MODS2_DIR.toString();
 111         int exitValue
 112             = executeTestJava("--module-path", modulepath,
 113                               "--add-modules", LOGGER_MODULE,
 114                               "-cp", classpath,
 115                               TEST_MAIN_CLASS,
 116                               "logger.Logger")
 117                 .outputTo(System.out)
 118                 .errorTo(System.out)
 119                 .getExitValue();
 120 


< prev index next >