author | alanb |
Fri, 07 Apr 2017 08:05:54 +0000 | |
changeset 44545 | 83b611b88ac8 |
parent 42338 | a60f280f803c |
permissions | -rw-r--r-- |
36511 | 1 |
/* |
2 |
* Copyright (c) 2015, 2016, 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 |
*/ |
|
23 |
||
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
24 |
import java.io.InputStream; |
36511 | 25 |
import java.lang.module.Configuration; |
26 |
import java.lang.module.ResolvedModule; |
|
27 |
import java.io.IOException; |
|
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
28 |
import java.net.URL; |
36511 | 29 |
import java.nio.file.Files; |
30 |
import java.nio.file.Path; |
|
31 |
import java.nio.file.Paths; |
|
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
32 |
import java.util.ArrayList; |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
33 |
import java.util.Enumeration; |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
34 |
import java.util.List; |
36511 | 35 |
|
36 |
/** |
|
37 |
* Basic test of ClassLoader getResource and getResourceAsStream when |
|
38 |
* invoked from code in named modules. |
|
39 |
*/ |
|
40 |
||
41 |
public class Main { |
|
42 |
||
43 |
static final String NAME = "myresource"; |
|
44 |
||
45 |
public static void main(String[] args) throws IOException { |
|
46 |
||
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
47 |
// create resources in m1 |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
48 |
createResource("m1", Paths.get("."), "m1"); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
49 |
createResource("m1", Paths.get("p1"), "m1/p1"); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
50 |
createResource("m1", Paths.get("p1", "impl"), "m1/p1.impl"); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
51 |
createResource("m1", Paths.get("p1", "resources"), "m1/p1.resources"); |
36511 | 52 |
|
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
53 |
// create resources in m2 |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
54 |
createResource("m2", Paths.get("."), "m2"); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
55 |
createResource("m2", Paths.get("p2"), "m2/p2"); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
56 |
createResource("m2", Paths.get("p2", "impl"), "m2/p2.impl"); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
57 |
createResource("m2", Paths.get("p2", "resources"), "m2/p2.resources"); |
36511 | 58 |
|
59 |
||
60 |
// invoke ClassLoader getResource from the unnamed module |
|
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
61 |
ClassLoader thisLoader = Main.class.getClassLoader(); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
62 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
63 |
URL url = thisLoader.getResource(NAME); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
64 |
assertNotNull(url); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
65 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
66 |
url = thisLoader.getResource("p1/" + NAME); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
67 |
assertNull(url); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
68 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
69 |
url = thisLoader.getResource("p1/impl/" + NAME); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
70 |
assertNull(url); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
71 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
72 |
url = thisLoader.getResource("p1/resources/" + NAME); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
73 |
assertEquals(readAllAsString(url), "m1/p1.resources"); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
74 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
75 |
url = thisLoader.getResource("p2/" + NAME); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
76 |
assertNull(url); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
77 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
78 |
url = thisLoader.getResource("p2/impl/" + NAME); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
79 |
assertNull(url); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
80 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
81 |
url = thisLoader.getResource("p2/resources/" + NAME); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
82 |
assertNull(url); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
83 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
84 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
85 |
// invoke ClassLoader getResource from module m1 |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
86 |
url = p1.Main.getResourceInClassLoader(NAME); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
87 |
assertNotNull(url); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
88 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
89 |
url = p1.Main.getResourceInClassLoader("p1/" + NAME); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
90 |
assertNull(url); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
91 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
92 |
url = p1.Main.getResourceInClassLoader("p1/impl/" + NAME); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
93 |
assertNull(url); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
94 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
95 |
url = p1.Main.getResourceInClassLoader("p1/resources/" + NAME); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
96 |
assertEquals(readAllAsString(url), "m1/p1.resources"); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
97 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
98 |
url = p1.Main.getResourceInClassLoader("p2/" + NAME); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
99 |
assertNull(url); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
100 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
101 |
url = p1.Main.getResourceInClassLoader("p2/impl/" + NAME); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
102 |
assertNull(url); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
103 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
104 |
url = p1.Main.getResourceInClassLoader("p2/resources/" + NAME); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
105 |
assertNull(url); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
106 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
107 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
108 |
// invoke ClassLoader getResource from module m2 |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
109 |
url = p2.Main.getResourceInClassLoader(NAME); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
110 |
assertNotNull(url); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
111 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
112 |
url = p2.Main.getResourceInClassLoader("p1/" + NAME); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
113 |
assertNull(url); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
114 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
115 |
url = p2.Main.getResourceInClassLoader("p1/impl/" + NAME); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
116 |
assertNull(url); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
117 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
118 |
url = p2.Main.getResourceInClassLoader("p1/resources/" + NAME); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
119 |
assertEquals(readAllAsString(url), "m1/p1.resources"); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
120 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
121 |
url = p2.Main.getResourceInClassLoader("p2/" + NAME); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
122 |
assertNull(url); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
123 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
124 |
url = p2.Main.getResourceInClassLoader("p2/impl/" + NAME); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
125 |
assertNull(url); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
126 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
127 |
url = p2.Main.getResourceInClassLoader("p2/resources/" + NAME); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
128 |
assertNull(url); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
129 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
130 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
131 |
// invoke ClassLoader getResources from the unnamed module |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
132 |
Enumeration<URL> urls = thisLoader.getResources(NAME); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
133 |
List<String> resources = readAllAsStrings(urls); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
134 |
assertTrue(resources.size() == 2); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
135 |
assertTrue(resources.contains("m1")); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
136 |
assertTrue(resources.contains("m2")); |
36511 | 137 |
|
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
138 |
urls = thisLoader.getResources("p1/" + NAME); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
139 |
assertTrue(readAllAsStrings(urls).isEmpty()); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
140 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
141 |
urls = thisLoader.getResources("p1/impl/" + NAME); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
142 |
assertTrue(readAllAsStrings(urls).isEmpty()); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
143 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
144 |
urls = thisLoader.getResources("p1/resources/" + NAME); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
145 |
resources = readAllAsStrings(urls); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
146 |
assertTrue(resources.size() == 1); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
147 |
assertTrue(resources.contains("m1/p1.resources")); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
148 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
149 |
urls = thisLoader.getResources("p2/" + NAME); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
150 |
assertTrue(readAllAsStrings(urls).isEmpty()); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
151 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
152 |
urls = thisLoader.getResources("p2/impl/" + NAME); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
153 |
assertTrue(readAllAsStrings(urls).isEmpty()); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
154 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
155 |
urls = thisLoader.getResources("p2/resources/" + NAME); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
156 |
assertTrue(readAllAsStrings(urls).isEmpty()); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
157 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
158 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
159 |
// invoke ClassLoader getResources from m1 |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
160 |
urls = p1.Main.getResourcesInClassLoader(NAME); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
161 |
resources = readAllAsStrings(urls); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
162 |
assertTrue(resources.size() == 2); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
163 |
assertTrue(resources.contains("m1")); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
164 |
assertTrue(resources.contains("m2")); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
165 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
166 |
urls = p1.Main.getResourcesInClassLoader("p1/" + NAME); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
167 |
assertTrue(readAllAsStrings(urls).isEmpty()); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
168 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
169 |
urls = p1.Main.getResourcesInClassLoader("p1/impl/" + NAME); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
170 |
assertTrue(readAllAsStrings(urls).isEmpty()); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
171 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
172 |
urls = p1.Main.getResourcesInClassLoader("p1/resources/" + NAME); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
173 |
resources = readAllAsStrings(urls); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
174 |
assertTrue(resources.size() == 1); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
175 |
assertTrue(resources.contains("m1/p1.resources")); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
176 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
177 |
urls = p1.Main.getResourcesInClassLoader("p2/" + NAME); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
178 |
assertTrue(readAllAsStrings(urls).isEmpty()); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
179 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
180 |
urls = p1.Main.getResourcesInClassLoader("p2/impl/" + NAME); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
181 |
assertTrue(readAllAsStrings(urls).isEmpty()); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
182 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
183 |
urls = p1.Main.getResourcesInClassLoader("p2/resources/" + NAME); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
184 |
assertTrue(readAllAsStrings(urls).isEmpty()); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
185 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
186 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
187 |
// invoke ClassLoader getResources from m2 |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
188 |
urls = p2.Main.getResourcesInClassLoader(NAME); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
189 |
resources = readAllAsStrings(urls); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
190 |
assertTrue(resources.size() == 2); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
191 |
assertTrue(resources.contains("m1")); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
192 |
assertTrue(resources.contains("m2")); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
193 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
194 |
urls = p2.Main.getResourcesInClassLoader("p1/" + NAME); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
195 |
assertTrue(readAllAsStrings(urls).isEmpty()); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
196 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
197 |
urls = p2.Main.getResourcesInClassLoader("p1/impl/" + NAME); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
198 |
assertTrue(readAllAsStrings(urls).isEmpty()); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
199 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
200 |
urls = p2.Main.getResourcesInClassLoader("p1/resources/" + NAME); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
201 |
resources = readAllAsStrings(urls); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
202 |
assertTrue(resources.size() == 1); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
203 |
assertTrue(resources.contains("m1/p1.resources")); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
204 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
205 |
urls = p2.Main.getResourcesInClassLoader("p2/" + NAME); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
206 |
assertTrue(readAllAsStrings(urls).isEmpty()); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
207 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
208 |
urls = p2.Main.getResourcesInClassLoader("p2/impl/" + NAME); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
209 |
assertTrue(readAllAsStrings(urls).isEmpty()); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
210 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
211 |
urls = p2.Main.getResourcesInClassLoader("p2/resources/" + NAME); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
212 |
assertTrue(readAllAsStrings(urls).isEmpty()); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
213 |
|
36511 | 214 |
|
215 |
// invoke ClassLoader getResourceAsStream from the unnamed module |
|
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
216 |
InputStream in = thisLoader.getResourceAsStream(NAME); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
217 |
assertNotNull(in); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
218 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
219 |
in = thisLoader.getResourceAsStream("p1/" + NAME); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
220 |
assertNull(in); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
221 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
222 |
in = thisLoader.getResourceAsStream("p1/impl/" + NAME); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
223 |
assertNull(in); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
224 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
225 |
in = thisLoader.getResourceAsStream("p1/resources/" + NAME); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
226 |
assertEquals(readAllAsString(in), "m1/p1.resources"); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
227 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
228 |
in = thisLoader.getResourceAsStream("p2/" + NAME); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
229 |
assertNull(in); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
230 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
231 |
in = thisLoader.getResourceAsStream("p2/impl/" + NAME); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
232 |
assertNull(in); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
233 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
234 |
in = thisLoader.getResourceAsStream("p2/resources/" + NAME); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
235 |
assertNull(in); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
236 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
237 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
238 |
// invoke ClassLoader getResource from modules m1 |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
239 |
in = p1.Main.getResourceAsStreamInClassLoader(NAME); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
240 |
assertNotNull(in); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
241 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
242 |
in = p1.Main.getResourceAsStreamInClassLoader("p1/" + NAME); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
243 |
assertNull(in); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
244 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
245 |
in = p1.Main.getResourceAsStreamInClassLoader("p1/impl/" + NAME); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
246 |
assertNull(in); |
36511 | 247 |
|
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
248 |
in = p1.Main.getResourceAsStreamInClassLoader("p1/resources/" + NAME); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
249 |
assertEquals(readAllAsString(in), "m1/p1.resources"); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
250 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
251 |
in = p1.Main.getResourceAsStreamInClassLoader("p2/" + NAME); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
252 |
assertNull(in); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
253 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
254 |
in = p1.Main.getResourceAsStreamInClassLoader("p2/impl/" + NAME); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
255 |
assertNull(in); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
256 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
257 |
in = p1.Main.getResourceAsStreamInClassLoader("p2/resources/" + NAME); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
258 |
assertNull(in); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
259 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
260 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
261 |
// invoke ClassLoader getResource from modules m2 |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
262 |
in = p2.Main.getResourceAsStreamInClassLoader(NAME); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
263 |
assertNotNull(in); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
264 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
265 |
in = p2.Main.getResourceAsStreamInClassLoader("p1/" + NAME); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
266 |
assertNull(in); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
267 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
268 |
in = p2.Main.getResourceAsStreamInClassLoader("p1/impl/" + NAME); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
269 |
assertNull(in); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
270 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
271 |
in = p2.Main.getResourceAsStreamInClassLoader("p1/resources/" + NAME); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
272 |
assertEquals(readAllAsString(in), "m1/p1.resources"); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
273 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
274 |
in = p2.Main.getResourceAsStreamInClassLoader("p2/" + NAME); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
275 |
assertNull(in); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
276 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
277 |
in = p2.Main.getResourceAsStreamInClassLoader("p2/impl/" + NAME); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
278 |
assertNull(in); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
279 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
280 |
in = p2.Main.getResourceAsStreamInClassLoader("p2/resources/" + NAME); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
281 |
assertNull(in); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
282 |
|
36511 | 283 |
|
284 |
// SecurityManager case |
|
285 |
System.setSecurityManager(new SecurityManager()); |
|
286 |
||
287 |
assertNull(Main.class.getClassLoader().getResource("/" + NAME)); |
|
288 |
assertNull(p1.Main.getResourceInClassLoader("/" + NAME)); |
|
289 |
assertNull(p2.Main.getResourceInClassLoader("/" + NAME)); |
|
290 |
||
291 |
assertNull(Main.class.getClassLoader().getResourceAsStream("/" + NAME)); |
|
292 |
assertNull(p1.Main.getResourceAsStreamInClassLoader("/" + NAME)); |
|
293 |
assertNull(p2.Main.getResourceAsStreamInClassLoader("/" + NAME)); |
|
294 |
||
295 |
System.out.println("Success!"); |
|
296 |
} |
|
297 |
||
298 |
/** |
|
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
299 |
* Create a resource in the sub-directory of the given exploded module |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
300 |
*/ |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
301 |
static void createResource(String mn, Path subdir, String msg) throws IOException { |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
302 |
Path dir = directoryFor(mn).resolve(subdir); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
303 |
Path file = dir.resolve(NAME); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
304 |
Files.write(file, msg.getBytes("UTF-8")); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
305 |
} |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
306 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
307 |
/** |
36511 | 308 |
* Returns the directory for the given module (by name). |
309 |
*/ |
|
310 |
static Path directoryFor(String mn) { |
|
44545
83b611b88ac8
8177530: Module system implementation refresh (4/2017)
alanb
parents:
42338
diff
changeset
|
311 |
Configuration cf = ModuleLayer.boot().configuration(); |
36511 | 312 |
ResolvedModule resolvedModule = cf.findModule(mn).orElse(null); |
313 |
if (resolvedModule == null) |
|
314 |
throw new RuntimeException("not found: " + mn); |
|
315 |
Path dir = Paths.get(resolvedModule.reference().location().get()); |
|
316 |
if (!Files.isDirectory(dir)) |
|
317 |
throw new RuntimeException("not a directory: " + dir); |
|
318 |
return dir; |
|
319 |
} |
|
320 |
||
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
321 |
static String readAllAsString(InputStream in) throws IOException { |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
322 |
if (in == null) |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
323 |
return null; |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
324 |
try (in) { |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
325 |
return new String(in.readAllBytes(), "UTF-8"); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
326 |
} |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
327 |
} |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
328 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
329 |
static String readAllAsString(URL url) throws IOException { |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
330 |
if (url == null) |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
331 |
return null; |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
332 |
InputStream in = url.openStream(); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
333 |
return readAllAsString(url.openStream()); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
334 |
} |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
335 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
336 |
static List<String> readAllAsStrings(Enumeration<URL> urls) throws IOException { |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
337 |
List<String> result = new ArrayList<>(); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
338 |
while (urls.hasMoreElements()) { |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
339 |
URL url = urls.nextElement(); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
340 |
result.add(readAllAsString(url)); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
341 |
} |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
342 |
return result; |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
343 |
} |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
344 |
|
36511 | 345 |
static void assertTrue(boolean condition) { |
346 |
if (!condition) throw new RuntimeException(); |
|
347 |
} |
|
348 |
||
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
349 |
static void assertFalse(boolean condition) { |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
350 |
if (condition) throw new RuntimeException(); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
351 |
} |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
352 |
|
36511 | 353 |
static void assertNull(Object o) { |
354 |
assertTrue(o == null); |
|
355 |
} |
|
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
356 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
357 |
static void assertNotNull(Object o) { |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
358 |
assertTrue(o != null); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
359 |
} |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
360 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
361 |
static void assertEquals(Object actual, Object expected) { |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
362 |
if (expected == null) { |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
363 |
assertNull(actual); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
364 |
} else { |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
365 |
assertTrue(expected.equals(actual)); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
366 |
} |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
367 |
} |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
368 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
369 |
static void assertNotEquals(Object actual, Object expected) { |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
370 |
if (expected == null) { |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
371 |
assertNotNull(actual); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
372 |
} else { |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
373 |
assertTrue(!expected.equals(actual)); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
374 |
} |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36511
diff
changeset
|
375 |
} |
36511 | 376 |
} |
377 |