@Test public void testExtraClasspathLoaderAlreadyInParentLoader() throws Exception { String dir = createClassOutsideClasspath("MyVerticle"); URLClassLoader loader = new URLClassLoader(new URL[]{new File(dir).toURI().toURL()}, Thread.currentThread().getContextClassLoader()); List<String> extraClasspath = Arrays.asList(dir); ClassLoader currentCL = Thread.currentThread().getContextClassLoader(); Thread.currentThread().setContextClassLoader(loader); try { vertx.deployVerticle("java:" + ExtraCPVerticleAlreadyInParentLoader.class.getCanonicalName(), new DeploymentOptions().setIsolationGroup("somegroup"). setExtraClasspath(extraClasspath), ar -> { assertTrue(ar.succeeded()); testComplete(); }); } finally { Thread.currentThread().setContextClassLoader(currentCL); } await(); }
@Test public void testExtraClasspathLoaderNotInParentLoader() throws Exception { boolean expectedSuccess = Thread.currentThread().getContextClassLoader() instanceof URLClassLoader; String dir = createClassOutsideClasspath("MyVerticle"); List<String> extraClasspath = Arrays.asList(dir); try { vertx.deployVerticle("java:" + ExtraCPVerticleNotInParentLoader.class.getCanonicalName(), new DeploymentOptions().setIsolationGroup("somegroup"). setExtraClasspath(extraClasspath), ar -> { assertTrue(ar.succeeded()); testComplete(); }); assertTrue(expectedSuccess); await(); } catch (IllegalStateException e) { assertFalse(expectedSuccess); } }
@Test public void testExtraClasspathLoaderAlreadyInParentLoader() throws Exception { String dir = createClassOutsideClasspath("MyVerticle"); URLClassLoader loader = new URLClassLoader(new URL[]{new File(dir).toURI().toURL()}, Thread.currentThread().getContextClassLoader()); List<String> extraClasspath = Arrays.asList(dir); ClassLoader currentCL = Thread.currentThread().getContextClassLoader(); Thread.currentThread().setContextClassLoader(loader); try { vertx.deployVerticle("java:" + ExtraCPVerticleAlreadyInParentLoader.class.getCanonicalName(), new DeploymentOptions().setIsolationGroup("somegroup"). setExtraClasspath(extraClasspath), ar -> { assertTrue(ar.succeeded()); testComplete(); }); } finally { Thread.currentThread().setContextClassLoader(currentCL); } await(); }
@Test public void testExtraClasspathLoaderNotInParentLoader() throws Exception { boolean expectedSuccess = Thread.currentThread().getContextClassLoader() instanceof URLClassLoader; String dir = createClassOutsideClasspath("MyVerticle"); List<String> extraClasspath = Arrays.asList(dir); try { vertx.deployVerticle("java:" + ExtraCPVerticleNotInParentLoader.class.getCanonicalName(), new DeploymentOptions().setIsolationGroup("somegroup"). setExtraClasspath(extraClasspath), ar -> { assertTrue(ar.succeeded()); testComplete(); }); assertTrue(expectedSuccess); await(); } catch (IllegalStateException e) { assertFalse(expectedSuccess); } }