< prev index next >

test/jdk/java/util/ServiceLoader/ModulesTest.java

Print this page
rev 51881 : [mq]: 8211171
rev 51882 : [mq]: 8211171-1


   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  */
  23 
  24 /**
  25  * @test
  26  * @modules java.scripting
  27  * @library modules /test/lib
  28  * @build bananascript/*
  29  * @build JarUtils
  30  * @compile classpath/pearscript/org/pear/PearScriptEngineFactory.java
  31  *          classpath/pearscript/org/pear/PearScript.java
  32  * @run testng/othervm ModulesTest
  33  * @summary Basic test for ServiceLoader with a provider deployed as a module.
  34  */
  35 
  36 import java.io.File;
  37 import java.lang.module.Configuration;
  38 import java.lang.module.ModuleFinder;
  39 import java.nio.file.Files;
  40 import java.nio.file.Path;
  41 import java.nio.file.Paths;
  42 import java.nio.file.StandardCopyOption;
  43 import java.util.ArrayList;
  44 import java.util.Collections;
  45 import java.util.HashSet;
  46 import java.util.Iterator;
  47 import java.util.List;
  48 import java.util.Optional;
  49 import java.util.ServiceLoader;
  50 import java.util.ServiceLoader.Provider;
  51 import java.util.Set;
  52 import java.util.stream.Collectors;
  53 import java.util.stream.Stream;
  54 import javax.script.ScriptEngineFactory;
  55 


  56 import org.testng.annotations.Test;
  57 import org.testng.annotations.BeforeTest;
  58 import static org.testng.Assert.*;
  59 
  60 /**
  61  * Basic test for ServiceLoader. The test make use of two service providers:
  62  * 1. BananaScriptEngine - a ScriptEngineFactory deployed as a module on the
  63  *    module path. It implementations a singleton via the public static
  64  *    provider method.
  65  * 2. PearScriptEngine - a ScriptEngineFactory deployed on the class path
  66  *    with a service configuration file.
  67  */
  68 
  69 public class ModulesTest {
  70 
  71     // Copy the services configuration file for "pearscript" into place.
  72     @BeforeTest
  73     public void setup() throws Exception {
  74         Path src = Paths.get(System.getProperty("test.src"));
  75         Path classes = Paths.get(System.getProperty("test.classes"));




   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  */
  23 
  24 /**
  25  * @test
  26  * @modules java.scripting
  27  * @library modules /test/lib
  28  * @build bananascript/*
  29  * @build jdk.test.lib.util.JarUtils
  30  * @compile classpath/pearscript/org/pear/PearScriptEngineFactory.java
  31  *          classpath/pearscript/org/pear/PearScript.java
  32  * @run testng/othervm ModulesTest
  33  * @summary Basic test for ServiceLoader with a provider deployed as a module.
  34  */
  35 
  36 import java.io.File;
  37 import java.lang.module.Configuration;
  38 import java.lang.module.ModuleFinder;
  39 import java.nio.file.Files;
  40 import java.nio.file.Path;
  41 import java.nio.file.Paths;
  42 import java.nio.file.StandardCopyOption;
  43 import java.util.ArrayList;
  44 import java.util.Collections;
  45 import java.util.HashSet;
  46 import java.util.Iterator;
  47 import java.util.List;
  48 import java.util.Optional;
  49 import java.util.ServiceLoader;
  50 import java.util.ServiceLoader.Provider;
  51 import java.util.Set;
  52 import java.util.stream.Collectors;
  53 import java.util.stream.Stream;
  54 import javax.script.ScriptEngineFactory;
  55 
  56 import jdk.test.lib.util.JarUtils;
  57 
  58 import org.testng.annotations.Test;
  59 import org.testng.annotations.BeforeTest;
  60 import static org.testng.Assert.*;
  61 
  62 /**
  63  * Basic test for ServiceLoader. The test make use of two service providers:
  64  * 1. BananaScriptEngine - a ScriptEngineFactory deployed as a module on the
  65  *    module path. It implementations a singleton via the public static
  66  *    provider method.
  67  * 2. PearScriptEngine - a ScriptEngineFactory deployed on the class path
  68  *    with a service configuration file.
  69  */
  70 
  71 public class ModulesTest {
  72 
  73     // Copy the services configuration file for "pearscript" into place.
  74     @BeforeTest
  75     public void setup() throws Exception {
  76         Path src = Paths.get(System.getProperty("test.src"));
  77         Path classes = Paths.get(System.getProperty("test.classes"));


< prev index next >