48 public class ProxyLayerTest {
49
50 private static final String TEST_SRC = System.getProperty("test.src");
51 private static final String TEST_CLASSES = System.getProperty("test.classes");
52
53 private static final Path SRC_DIR = Paths.get(TEST_SRC, "src");
54 private static final Path MODS_DIR = Paths.get("mods");
55 private static final Path CPATH_DIR = Paths.get(TEST_CLASSES);
56
57 // the names of the modules in this test
58 private static String[] modules = new String[] {"m1", "m2", "m3"};
59
60
61 /**
62 * Compiles all modules used by the test
63 */
64 @BeforeTest
65 public void compileAll() throws Exception {
66 for (String mn : modules) {
67 Path msrc = SRC_DIR.resolve(mn);
68 assertTrue(CompilerUtils.compile(msrc, MODS_DIR, "-modulesourcepath", SRC_DIR.toString()));
69 }
70 }
71
72 /**
73 * Test proxy implementing interfaces in a Layer defined in
74 * an unnamed module
75 */
76 @Test
77 public void testProxyInUnnamed() throws Exception {
78 ModuleFinder finder = ModuleFinder.of(MODS_DIR);
79 Layer bootLayer = Layer.boot();
80 Configuration cf = bootLayer
81 .configuration()
82 .resolveRequiresAndUses(ModuleFinder.of(), finder, Arrays.asList(modules));
83 ClassLoader scl = ClassLoader.getSystemClassLoader();
84 Layer layer = bootLayer.defineModulesWithOneLoader(cf, scl);
85
86 ClassLoader loader = layer.findLoader("m1");
87
88 assertTrue(layer.findModule("m1").isPresent());
|
48 public class ProxyLayerTest {
49
50 private static final String TEST_SRC = System.getProperty("test.src");
51 private static final String TEST_CLASSES = System.getProperty("test.classes");
52
53 private static final Path SRC_DIR = Paths.get(TEST_SRC, "src");
54 private static final Path MODS_DIR = Paths.get("mods");
55 private static final Path CPATH_DIR = Paths.get(TEST_CLASSES);
56
57 // the names of the modules in this test
58 private static String[] modules = new String[] {"m1", "m2", "m3"};
59
60
61 /**
62 * Compiles all modules used by the test
63 */
64 @BeforeTest
65 public void compileAll() throws Exception {
66 for (String mn : modules) {
67 Path msrc = SRC_DIR.resolve(mn);
68 assertTrue(CompilerUtils.compile(msrc, MODS_DIR, "--module-source-path", SRC_DIR.toString()));
69 }
70 }
71
72 /**
73 * Test proxy implementing interfaces in a Layer defined in
74 * an unnamed module
75 */
76 @Test
77 public void testProxyInUnnamed() throws Exception {
78 ModuleFinder finder = ModuleFinder.of(MODS_DIR);
79 Layer bootLayer = Layer.boot();
80 Configuration cf = bootLayer
81 .configuration()
82 .resolveRequiresAndUses(ModuleFinder.of(), finder, Arrays.asList(modules));
83 ClassLoader scl = ClassLoader.getSystemClassLoader();
84 Layer layer = bootLayer.defineModulesWithOneLoader(cf, scl);
85
86 ClassLoader loader = layer.findLoader("m1");
87
88 assertTrue(layer.findModule("m1").isPresent());
|