list.add((String)item); }); obj.setExtraClasspath(list);
@Test(expected = IllegalArgumentException.class) public void testDeployInstanceSetExtraClasspath() throws Exception { vertx.deployVerticle(new MyVerticle(), new DeploymentOptions().setExtraClasspath(Arrays.asList("foo"))); }
@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); } }
options.setIsolationGroup(isolationGroup); options.setHa(ha); options.setExtraClasspath(cp); options.setIsolatedClasses(isol); options.setWorkerPoolName(poolName);
options.setIsolationGroup(isolationGroup); options.setHa(ha); options.setExtraClasspath(cp); options.setIsolatedClasses(isol); options.setWorkerPoolName(poolName);
assertNull(options.getExtraClasspath()); List<String> cp = Arrays.asList("foo", "bar"); assertEquals(options, options.setExtraClasspath(cp)); assertNull(options.getIsolatedClasses()); List<String> isol = Arrays.asList("com.foo.MyClass", "org.foo.*");
list.add((String)item); }); obj.setExtraClasspath(list);
@Test(expected = IllegalArgumentException.class) public void testDeployInstanceSetExtraClasspath() throws Exception { vertx.deployVerticle(new MyVerticle(), new DeploymentOptions().setExtraClasspath(Arrays.asList("foo"))); }
@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); } }
options.setIsolationGroup(isolationGroup); options.setHa(ha); options.setExtraClasspath(cp); options.setIsolatedClasses(isol); options.setWorkerPoolName(poolName);
options.setIsolationGroup(isolationGroup); options.setHa(ha); options.setExtraClasspath(cp); options.setIsolatedClasses(isol); options.setWorkerPoolName(poolName);
private DeploymentOptions createIsolatingDeploymentOptions(List<String> classPaths, Optional<String> config) throws IOException { DeploymentOptions result = new DeploymentOptions() .setExtraClasspath(classPaths) .setIsolationGroup(Long.toString(nextIsolationGroup.getAndIncrement())) .setIsolatedClasses(Collections.singletonList("*")); return assignConfig(classPaths, config, result); }
assertNull(options.getExtraClasspath()); List<String> cp = Arrays.asList("foo", "bar"); assertEquals(options, options.setExtraClasspath(cp)); assertNull(options.getIsolatedClasses()); List<String> isol = Arrays.asList("com.foo.MyClass", "org.foo.*");
@Test public void testOptions() throws Exception { CountDownLatch latch = new CountDownLatch(2); vertx.eventBus().<Boolean>localConsumer("moduleStarted").handler(message -> { assertTrue(message.body()); latch.countDown(); }); List<String> extraCP = Arrays.asList("foo"); // These options should be overridden by those in the service descriptor DeploymentOptions options = new DeploymentOptions().setIsolationGroup("othergroup").setWorker(false).setExtraClasspath(extraCP); vertx.deployVerticle("service:my.optionsmodule", options, res -> { assertTrue(res.succeeded()); latch.countDown(); }); awaitLatch(latch); }
@Override public void start() throws Exception { vertx.runOnContext(v -> { List<String> extraCP = Arrays.asList("blah", "wibble"); DeploymentOptions expected = new DeploymentOptions().setConfig(new JsonObject().put("foo", "bar")) .setWorker(true).setIsolationGroup("mygroup").setExtraClasspath(extraCP); Deployment dep = ((VertxInternal) vertx).getDeployment(Vertx.currentContext().deploymentID()); vertx.eventBus().publish("moduleStarted", expected.equals(dep.deploymentOptions())); }); }