8158044: Add test that checks uri of upgradeable modules
authormli
Mon, 30 May 2016 16:03:48 -0700
changeset 38744 c4ca9483156d
parent 38743 c57fc9cfae33
child 38745 be430178b177
8158044: Add test that checks uri of upgradeable modules Reviewed-by: alanb, mchung
jdk/test/tools/launcher/modules/upgrademodulepath/src/test/jdk/test/Main.java
--- a/jdk/test/tools/launcher/modules/upgrademodulepath/src/test/jdk/test/Main.java	Mon May 30 17:55:53 2016 +0100
+++ b/jdk/test/tools/launcher/modules/upgrademodulepath/src/test/jdk/test/Main.java	Mon May 30 16:03:48 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, 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
@@ -23,8 +23,12 @@
 
 package jdk.test;
 
+import java.lang.module.ModuleReference;
+import java.lang.reflect.Layer;
+import java.net.URI;
+
+import javax.enterprise.context.Scope;
 import javax.transaction.Transaction;
-import javax.enterprise.context.Scope;
 
 /**
  * Uses an upgraded version of module java.transaction.
@@ -34,6 +38,7 @@
 
     public static void main(String[] args) {
 
+        String TRANSACTION_MODULE = "java.transaction";
         ClassLoader scl = ClassLoader.getSystemClassLoader();
         ClassLoader pcl = ClassLoader.getPlatformClassLoader();
         assertTrue(pcl.getParent() == null);
@@ -43,9 +48,17 @@
 
         // javax.transaction.Transaction should be in module java.transaction
         // and defined by the platform class loader
-        assertTrue(Transaction.class.getModule().getName().equals("java.transaction"));
+        assertTrue(Transaction.class.getModule().getName().equals(TRANSACTION_MODULE));
         assertTrue(Transaction.class.getClassLoader() == pcl);
 
+        // javax.transaction should be found in boot layer.
+        ModuleReference ref =
+                Layer.boot().configuration().findModule(TRANSACTION_MODULE).get().reference();
+        // check uri of java.transaction found on the upgrade module path.
+        URI uri = ref.location().get();
+        System.out.println("uri: " + uri);
+        assertTrue(uri.getScheme().equalsIgnoreCase("file"));
+
         // javax.enterprise.context.Scope should be in module java.enterprise
         // and defined by the application class loader
         assertTrue(Scope.class.getModule().getName().equals("java.enterprise"));