46 import java.util.Optional; 47 import java.util.ServiceLoader; 48 import java.util.Set; 49 import java.util.stream.Collectors; 50 51 import org.testng.annotations.BeforeTest; 52 import org.testng.annotations.Test; 53 import static org.testng.Assert.*; 54 55 @Test 56 public class LayerAndLoadersTest { 57 58 private static final String TEST_SRC = System.getProperty("test.src"); 59 60 private static final Path SRC_DIR = Paths.get(TEST_SRC, "src"); 61 private static final Path MODS_DIR = Paths.get("mods"); 62 63 @BeforeTest 64 public void setup() throws Exception { 65 66 // javac -d mods -modulesourcepath src src/** 67 assertTrue(CompilerUtils.compile(SRC_DIR, MODS_DIR, 68 "-modulesourcepath", SRC_DIR.toString())); 69 } 70 71 72 /** 73 * Basic test of Layer defineModulesWithOneLoader 74 * 75 * Test scenario: 76 * m1 requires m2 and m3 77 */ 78 public void testWithOneLoader() throws Exception { 79 80 Configuration cf = resolveRequires("m1"); 81 82 ClassLoader scl = ClassLoader.getSystemClassLoader(); 83 84 Layer layer = Layer.boot().defineModulesWithOneLoader(cf, scl); 85 86 checkLayer(layer, "m1", "m2", "m3"); 87 88 ClassLoader cl1 = layer.findLoader("m1"); | 46 import java.util.Optional; 47 import java.util.ServiceLoader; 48 import java.util.Set; 49 import java.util.stream.Collectors; 50 51 import org.testng.annotations.BeforeTest; 52 import org.testng.annotations.Test; 53 import static org.testng.Assert.*; 54 55 @Test 56 public class LayerAndLoadersTest { 57 58 private static final String TEST_SRC = System.getProperty("test.src"); 59 60 private static final Path SRC_DIR = Paths.get(TEST_SRC, "src"); 61 private static final Path MODS_DIR = Paths.get("mods"); 62 63 @BeforeTest 64 public void setup() throws Exception { 65 66 // javac -d mods --module-source-path src src/** 67 assertTrue(CompilerUtils.compile(SRC_DIR, MODS_DIR, 68 "--module-source-path", SRC_DIR.toString())); 69 } 70 71 72 /** 73 * Basic test of Layer defineModulesWithOneLoader 74 * 75 * Test scenario: 76 * m1 requires m2 and m3 77 */ 78 public void testWithOneLoader() throws Exception { 79 80 Configuration cf = resolveRequires("m1"); 81 82 ClassLoader scl = ClassLoader.getSystemClassLoader(); 83 84 Layer layer = Layer.boot().defineModulesWithOneLoader(cf, scl); 85 86 checkLayer(layer, "m1", "m2", "m3"); 87 88 ClassLoader cl1 = layer.findLoader("m1"); |