diff --git a/build.gradle b/build.gradle index d0ae321..e638024 100644 --- a/build.gradle +++ b/build.gradle @@ -17,6 +17,7 @@ apply plugin: 'java' apply from: 'gradle/setup.gradle' apply from: 'gradle/maven.gradle' +apply plugin: 'eclipse' defaultTasks = ['assemble'] @@ -35,8 +36,8 @@ dependencies { compile "io.vertx:vertx-platform:$vertxVersion" // testCompile "io.vertx:lang-java:$vertxVersion" - testCompile "io.vertx:lang-rhino:1.0.0-SNAPSHOT" - testCompile "org.mozilla:rhino:$rhinoVersion" +// testCompile "io.vertx:lang-rhino:1.0.0-SNAPSHOT" +// testCompile "org.mozilla:rhino:$rhinoVersion" } test { diff --git a/gradle.properties b/gradle.properties index 3bcddb4..17295e4 100644 --- a/gradle.properties +++ b/gradle.properties @@ -13,12 +13,12 @@ # See the License for the specific language governing permissions and # limitations under the License. # -version=2.0.0-SNAPSHOT +version=2.0.2-SNAPSHOT group=io.vertx modulename=vertx-junit-annotations gradleVersion=1.4 -vertxVersion=2.0.0-SNAPSHOT +vertxVersion=2.0.2-final rhinoVersion=1.7R4 -junitVersion=4.11 \ No newline at end of file +junitVersion=4.11 diff --git a/src/main/java/org/vertx/java/test/junit/JUnitDeploymentUtils.java b/src/main/java/org/vertx/java/test/junit/JUnitDeploymentUtils.java index 4f697ef..b7b11f6 100644 --- a/src/main/java/org/vertx/java/test/junit/JUnitDeploymentUtils.java +++ b/src/main/java/org/vertx/java/test/junit/JUnitDeploymentUtils.java @@ -32,58 +32,64 @@ /** * @author swilliams - * + * */ public class JUnitDeploymentUtils { - /** - * @param manager - * @param description - * @return map - */ - public static Map deploy(PlatformManager platformManager, File modDir, Description description, long timeout) { + /** + * @param platformManager + * @param description + * @return map + */ + public static Map deploy( + PlatformManager platformManager, File modDir, + Description description, long timeout) { - Map deployments = new HashMap<>(); + Map deployments = new HashMap<>(); - // ------------------------------------------------------------------------------ - // Discover and deploy verticles - Set verticles = new HashSet<>(); - TestVerticle testVerticle = description.getAnnotation(TestVerticle.class); - if (testVerticle != null) { - verticles.add(testVerticle); - } + // ------------------------------------------------------------------------------ + // Discover and deploy verticles + Set verticles = new HashSet<>(); + TestVerticle testVerticle = description + .getAnnotation(TestVerticle.class); + if (testVerticle != null) { + verticles.add(testVerticle); + } - TestVerticles testVerticles = description.getAnnotation(TestVerticles.class); - if (testVerticles != null) { - for (TestVerticle v : testVerticles.value()) { - verticles.add(v); - } - } + TestVerticles testVerticles = description + .getAnnotation(TestVerticles.class); + if (testVerticles != null) { + for (TestVerticle v : testVerticles.value()) { + verticles.add(v); + } + } - Map verticleDeployments = DeploymentUtils.deployVerticles(platformManager, modDir, verticles, timeout); - deployments.putAll(verticleDeployments); + Map verticleDeployments = DeploymentUtils + .deployVerticles(platformManager, modDir, verticles, timeout); + deployments.putAll(verticleDeployments); - // ------------------------------------------------------------------------------ - // Discover and deploy modules - Set modules = new HashSet<>(); - TestModule testModule = description.getAnnotation(TestModule.class); - if (testModule != null) { - modules.add(testModule); - } + // ------------------------------------------------------------------------------ + // Discover and deploy modules + Set modules = new HashSet<>(); + TestModule testModule = description.getAnnotation(TestModule.class); + if (testModule != null) { + modules.add(testModule); + } - TestModules testModules = description.getAnnotation(TestModules.class); - if (testModules != null) { - for (TestModule v : testModules.value()) { - modules.add(v); - } - } + TestModules testModules = description.getAnnotation(TestModules.class); + if (testModules != null) { + for (TestModule v : testModules.value()) { + modules.add(v); + } + } - Map modulesDeployments = DeploymentUtils.deployModules(platformManager, modDir, modules, timeout); - deployments.putAll(modulesDeployments); + Map modulesDeployments = DeploymentUtils + .deployModules(platformManager, modDir, modules, timeout); + deployments.putAll(modulesDeployments); - // ------------------------------------------------------------------------------ - // return result - return deployments; - } + // ------------------------------------------------------------------------------ + // return result + return deployments; + } } diff --git a/src/main/java/org/vertx/java/test/junit/VertxJUnit4ClassRunner.java b/src/main/java/org/vertx/java/test/junit/VertxJUnit4ClassRunner.java index 4f0f1ca..211490f 100644 --- a/src/main/java/org/vertx/java/test/junit/VertxJUnit4ClassRunner.java +++ b/src/main/java/org/vertx/java/test/junit/VertxJUnit4ClassRunner.java @@ -102,8 +102,8 @@ protected void afterCreateTest(Object target) { if (target instanceof Verticle) { this.verticle = (Verticle) target; - verticle.setVertx(platformManager.getVertx()); - verticle.setContainer(new Container((PlatformManagerInternal) platformManager)); + verticle.setVertx(platformManager.vertx()); +// verticle.setContainer(new Container((PlatformManagerInternal) platformManager)); try { System.out.println("Starting test verticle!"); verticle.start(); @@ -116,7 +116,7 @@ protected void afterCreateTest(Object target) { @Override protected void injectResources(Object target) { if ((configuration != null && configuration.injectResources()) || configuration == null) { - InjectionUtils.inject(platformManager.getVertx(), target); + InjectionUtils.inject(platformManager.vertx(), target); InjectionUtils.inject(platformManager, target); } } diff --git a/src/main/java/org/vertx/java/test/utils/CountDownLatchDoneHandler.java b/src/main/java/org/vertx/java/test/utils/CountDownLatchDoneHandler.java index 0616123..1c6efe1 100644 --- a/src/main/java/org/vertx/java/test/utils/CountDownLatchDoneHandler.java +++ b/src/main/java/org/vertx/java/test/utils/CountDownLatchDoneHandler.java @@ -17,24 +17,24 @@ import java.util.concurrent.CountDownLatch; +import org.vertx.java.core.AsyncResult; import org.vertx.java.core.Handler; - /** * @author swilliams - * + * */ -public class CountDownLatchDoneHandler implements Handler { +public class CountDownLatchDoneHandler implements Handler> { - private final CountDownLatch latch; + private final CountDownLatch latch; - public CountDownLatchDoneHandler(final CountDownLatch latch) { - this.latch = latch; - } + public CountDownLatchDoneHandler(final CountDownLatch latch) { + this.latch = latch; + } - @Override - public void handle(T event) { - latch.countDown(); - } + @Override + public void handle(AsyncResult event) { + latch.countDown(); + } } \ No newline at end of file diff --git a/src/main/java/org/vertx/java/test/utils/CountDownLatchHandler.java b/src/main/java/org/vertx/java/test/utils/CountDownLatchHandler.java index 22a16e3..353e371 100644 --- a/src/main/java/org/vertx/java/test/utils/CountDownLatchHandler.java +++ b/src/main/java/org/vertx/java/test/utils/CountDownLatchHandler.java @@ -49,7 +49,7 @@ public CountDownLatchHandler(int size, long timeout, TimeUnit timeUnit) { @Override public void handle(Message event) { - boolean added = queue.offer(event.body); + boolean added = queue.offer(event.body()); if (added) { latch.countDown(); } diff --git a/src/main/java/org/vertx/java/test/utils/DeploymentHandler.java b/src/main/java/org/vertx/java/test/utils/DeploymentHandler.java index 0bbd7d2..f7b969b 100644 --- a/src/main/java/org/vertx/java/test/utils/DeploymentHandler.java +++ b/src/main/java/org/vertx/java/test/utils/DeploymentHandler.java @@ -19,36 +19,41 @@ import java.util.Set; import java.util.concurrent.CountDownLatch; +import org.vertx.java.core.AsyncResult; import org.vertx.java.core.Handler; - /** * @author swilliams - * + * */ -public class DeploymentHandler implements Handler { - - private final CountDownLatch latch; - - private final Set deploymentIDs = new HashSet<>(); - - public DeploymentHandler(final CountDownLatch latch) { - this.latch = latch; - } - - @Override - public void handle(String event) { - if (event != null) { - deploymentIDs.add(event); - } - latch.countDown(); - } - - public String getDeploymentID() { - if (deploymentIDs.size() == 0) { - return null; - } - return deploymentIDs.iterator().next(); - } +public class DeploymentHandler implements Handler> { + + private final CountDownLatch latch; + + private final Set deploymentIDs = new HashSet<>(); + + public DeploymentHandler(final CountDownLatch latch) { + this.latch = latch; + } + + public String getDeploymentID() { + if (deploymentIDs.size() == 0) { + return null; + } + return deploymentIDs.iterator().next(); + } + + @Override + public void handle(AsyncResult event) { + if (event.succeeded()) { + if (event.result() != null) { + deploymentIDs.add(event.result()); + } + } else { + throw new RuntimeException("Unable to deploy module/verticle", + event.cause()); + } + latch.countDown(); + } } \ No newline at end of file diff --git a/src/main/java/org/vertx/java/test/utils/DeploymentUtils.java b/src/main/java/org/vertx/java/test/utils/DeploymentUtils.java index fd0be9a..b63f2c1 100644 --- a/src/main/java/org/vertx/java/test/utils/DeploymentUtils.java +++ b/src/main/java/org/vertx/java/test/utils/DeploymentUtils.java @@ -27,13 +27,14 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Map; -import java.util.Set; import java.util.Map.Entry; +import java.util.Set; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import java.util.logging.Level; import java.util.logging.Logger; +import org.vertx.java.core.AsyncResult; import org.vertx.java.core.Handler; import org.vertx.java.core.json.JsonObject; import org.vertx.java.platform.PlatformManager; @@ -42,225 +43,246 @@ /** * @author swilliams - * + * */ public class DeploymentUtils { - private static final Logger LOG = Logger.getLogger(DeploymentUtils.class.getName()); - - public static Map deployVerticles(PlatformManager platformManager, File modDir, Set verticles, long timeout) { - Map deployments = new HashMap<>(); - - if (verticles.size() > 0) { - CountDownLatch latch = new CountDownLatch(verticles.size()); - Map handlers = new HashMap<>(); - - for (TestVerticle v : verticles) { - DeploymentHandler doneHandler = new DeploymentHandler(latch); - handlers.put(v, doneHandler); - - JsonObject config = getJsonConfig(v.jsonConfig()); - URL[] classpath = findVerticleURLs(v); - - LOG.log(Level.FINE, "deployVerticle(%s)%n", v); - - // we are having to set null here which is not that clever - String includes = ("".equals(v.includes())) ? null : v.includes(); - - try { - if (v.worker()) { - platformManager.deployWorkerVerticle(v.multiThreaded(), v.main(), config, classpath, v.instances(), includes, doneHandler); - } - else { - platformManager.deployVerticle(v.main(), config, classpath, v.instances(), includes, doneHandler); - } - } catch (Throwable e) { - e.printStackTrace(); - LOG.log(Level.WARNING, String.format("Problem deploying (%s) %n", v), e); - } - finally { - // - } - System.out.println("latch: " + latch.getCount()); - } - - System.out.println("latch: " + latch.getCount()); - - await(latch); - - // await(latch, timeout); // Eh? - - Set> entrySet = handlers.entrySet(); - for (Entry e : entrySet) { - String id = e.getValue().getDeploymentID(); - if (id != null) deployments.put(e.getKey(), id); - } - } - - return deployments; - } - - public static Map deployModules(PlatformManager platformManager, File modDir, Set modules, long timeout) { - Map deployments = new HashMap<>(); - - if (modules.size() > 0) { - CountDownLatch latch = new CountDownLatch(modules.size()); - Map handlers = new HashMap<>(); - - for (TestModule m : modules) { - DeploymentHandler handler = new DeploymentHandler(latch); - handlers.put(m, handler); - - JsonObject config = getJsonConfig(m.jsonConfig()); - - LOG.log(Level.FINE, "deployModule(%s)%n", m); - try { - platformManager.deployModule(m.name(), config, m.instances(), handler); - } catch (Throwable e) { - e.printStackTrace(); - LOG.log(Level.WARNING, String.format("Problem deploying (%s) %n", m), e); - latch.countDown(); - } - } - - await(latch); - // FIXME - why does this cause NPE's? - // latch.await(timeout, TimeUnit.MILLISECONDS); - - Set> entrySet = handlers.entrySet(); - for (Entry e : entrySet) { - String id = e.getValue().getDeploymentID(); - if (id != null) deployments.put(e.getKey(), id); - } - } - - return deployments; - } - - public static void undeploy(PlatformManager container, Map deployments) { - - final CountDownLatch latch = new CountDownLatch(deployments.size()); - - for (Annotation a : deployments.keySet()) { - final String id = deployments.get(a); - - if (id != null) { - try { - container.undeploy(id, new Handler() { - @Override - public void handle(Void event) { - LOG.log(Level.FINE, String.format("DeploymentUtils undeployed (%s) %n", id)); - latch.countDown(); - } - }); - } catch (Exception e) { - LOG.log(Level.WARNING, String.format("Problem undeploying (%s) %n", id), e); - } - } - } - - await(latch, 2000L); // FIXME this appears to hang - } - - public static JsonObject getJsonConfig(String jsonConfig) { - JsonObject config; - - if (jsonConfig.startsWith("file:")) { - String filename = jsonConfig.replaceFirst("file:", ""); - - try { - // TCCL may be problematic - URL url = Thread.currentThread().getContextClassLoader().getResource(filename); - Path json = Paths.get(url.toURI()); - Charset utf8 = Charset.forName("UTF-8"); - byte[] bytes = Files.readAllBytes(json); - config = new JsonObject(new String(bytes, utf8)); - - } catch (IOException e) { - throw new RuntimeException(e); - } catch (URISyntaxException e) { - throw new RuntimeException(e); - } - } - else { - config = new JsonObject(jsonConfig); - } - - return config; - } - - public static URL[] findVerticleURLs(TestVerticle v) { - Set urlSet = new HashSet(); - - if (v.urls().length > 0) { - for (String path : v.urls()) { - - try { - - URL url = new File(path).toURI().toURL(); - urlSet.add(url); - - } catch (Exception e) { - LOG.log(Level.SEVERE, e.getMessage(), e); - } - } - } - - try { - String main = v.main(); - if (main.indexOf(':') > -1) { - main = main.substring(main.indexOf(':') + 1); - } - - // check for class, prep for locating root URL - int parts = 0; - if (!main.endsWith(".xml")) { - parts = main.split("\\.").length; - main = main.replaceAll("\\.", "/"); - main = main + ".class"; - } - - // contortions to get parent, may not be entirely accurate... - // URL url = getClass().getClassLoader().getResource(main); - URL url = Thread.currentThread().getContextClassLoader().getResource(main); - - if (url != null) { - Path path = Paths.get(url.toURI()); - - int i = parts; - while (i > 0) { - path = path.getParent(); - i--; - } - - url = path.toUri().toURL(); - urlSet.add(url); - } - - } catch (Exception e) { - // TODO log something here - e.printStackTrace(); - } - - URL[] urls = new URL[urlSet.size()]; - return urlSet.toArray(urls); - } - - public static void await(final CountDownLatch latch) { - try { - latch.await(); - } catch (Throwable e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - - public static void await(final CountDownLatch latch, final long timeout) { - try { - latch.await(timeout, TimeUnit.MILLISECONDS); - } catch (Throwable e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } + private static final Logger LOG = Logger.getLogger(DeploymentUtils.class + .getName()); + + public static Map deployVerticles( + PlatformManager platformManager, File modDir, + Set verticles, long timeout) { + Map deployments = new HashMap<>(); + + if (verticles.size() > 0) { + CountDownLatch latch = new CountDownLatch(verticles.size()); + Map handlers = new HashMap<>(); + + for (TestVerticle v : verticles) { + DeploymentHandler doneHandler = new DeploymentHandler(latch); + handlers.put(v, doneHandler); + + JsonObject config = getJsonConfig(v.jsonConfig()); + URL[] classpath = findVerticleURLs(v); + + LOG.log(Level.FINE, "deployVerticle(%s)%n", v); + + // we are having to set null here which is not that clever + String includes = ("".equals(v.includes())) ? null : v + .includes(); + + try { + if (v.worker()) { + platformManager.deployWorkerVerticle(v.multiThreaded(), + v.main(), config, classpath, v.instances(), + includes, doneHandler); + } else { + platformManager + .deployVerticle(v.main(), config, classpath, + v.instances(), includes, doneHandler); + } + } catch (Throwable e) { + e.printStackTrace(); + LOG.log(Level.WARNING, + String.format("Problem deploying (%s) %n", v), e); + } finally { + // + } + System.out.println("latch: " + latch.getCount()); + } + + System.out.println("latch: " + latch.getCount()); + + await(latch); + + // await(latch, timeout); // Eh? + + Set> entrySet = handlers + .entrySet(); + for (Entry e : entrySet) { + String id = e.getValue().getDeploymentID(); + if (id != null) { + deployments.put(e.getKey(), id); + } + } + } + + return deployments; + } + + public static Map deployModules( + PlatformManager platformManager, File modDir, + Set modules, long timeout) { + Map deployments = new HashMap<>(); + + if (modules.size() > 0) { + CountDownLatch latch = new CountDownLatch(modules.size()); + Map handlers = new HashMap<>(); + + for (TestModule m : modules) { + DeploymentHandler handler = new DeploymentHandler(latch); + handlers.put(m, handler); + + JsonObject config = getJsonConfig(m.jsonConfig()); + + LOG.log(Level.FINE, "deployModule(%s)%n", m); + try { + platformManager.deployModule(m.name(), config, + m.instances(), handler); + } catch (Throwable e) { + e.printStackTrace(); + LOG.log(Level.WARNING, + String.format("Problem deploying (%s) %n", m), e); + latch.countDown(); + } + } + + await(latch); + // FIXME - why does this cause NPE's? + // latch.await(timeout, TimeUnit.MILLISECONDS); + + Set> entrySet = handlers + .entrySet(); + for (Entry e : entrySet) { + String id = e.getValue().getDeploymentID(); + if (id != null) { + deployments.put(e.getKey(), id); + } + } + } + + return deployments; + } + + public static void undeploy(PlatformManager container, + Map deployments) { + + final CountDownLatch latch = new CountDownLatch(deployments.size()); + + for (Annotation a : deployments.keySet()) { + final String id = deployments.get(a); + + if (id != null) { + try { + container.undeploy(id, new Handler>() { + @Override + public void handle(AsyncResult event) { + LOG.log(Level.FINE, String.format( + "DeploymentUtils undeployed (%s) %n", id)); + latch.countDown(); + } + }); + } catch (Exception e) { + LOG.log(Level.WARNING, + String.format("Problem undeploying (%s) %n", id), e); + } + } + } + + await(latch, 2000L); // FIXME this appears to hang + } + + public static JsonObject getJsonConfig(String jsonConfig) { + JsonObject config; + + if (jsonConfig.startsWith("file:")) { + String filename = jsonConfig.replaceFirst("file:", ""); + + try { + // TCCL may be problematic + URL url = Thread.currentThread().getContextClassLoader() + .getResource(filename); + Path json = Paths.get(url.toURI()); + Charset utf8 = Charset.forName("UTF-8"); + byte[] bytes = Files.readAllBytes(json); + config = new JsonObject(new String(bytes, utf8)); + + } catch (IOException e) { + throw new RuntimeException(e); + } catch (URISyntaxException e) { + throw new RuntimeException(e); + } + } else { + config = new JsonObject(jsonConfig); + } + + return config; + } + + public static URL[] findVerticleURLs(TestVerticle v) { + Set urlSet = new HashSet(); + + if (v.urls().length > 0) { + for (String path : v.urls()) { + + try { + + URL url = new File(path).toURI().toURL(); + urlSet.add(url); + + } catch (Exception e) { + LOG.log(Level.SEVERE, e.getMessage(), e); + } + } + } + + try { + String main = v.main(); + if (main.indexOf(':') > -1) { + main = main.substring(main.indexOf(':') + 1); + } + + // check for class, prep for locating root URL + int parts = 0; + if (!main.endsWith(".xml")) { + parts = main.split("\\.").length; + main = main.replaceAll("\\.", "/"); + main = main + ".class"; + } + + // contortions to get parent, may not be entirely accurate... + // URL url = getClass().getClassLoader().getResource(main); + URL url = Thread.currentThread().getContextClassLoader() + .getResource(main); + + if (url != null) { + Path path = Paths.get(url.toURI()); + + int i = parts; + while (i > 0) { + path = path.getParent(); + i--; + } + + url = path.toUri().toURL(); + urlSet.add(url); + } + + } catch (Exception e) { + // TODO log something here + e.printStackTrace(); + } + + URL[] urls = new URL[urlSet.size()]; + return urlSet.toArray(urls); + } + + public static void await(final CountDownLatch latch) { + try { + latch.await(); + } catch (Throwable e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + public static void await(final CountDownLatch latch, final long timeout) { + try { + latch.await(timeout, TimeUnit.MILLISECONDS); + } catch (Throwable e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } } diff --git a/src/main/java/org/vertx/java/test/utils/QueueReplyHandler.java b/src/main/java/org/vertx/java/test/utils/QueueReplyHandler.java index 8a5c664..d6fc414 100644 --- a/src/main/java/org/vertx/java/test/utils/QueueReplyHandler.java +++ b/src/main/java/org/vertx/java/test/utils/QueueReplyHandler.java @@ -24,41 +24,42 @@ /** * @author swilliams - * + * * @param */ public class QueueReplyHandler implements Handler> { - private final LinkedBlockingQueue queue; + private final LinkedBlockingQueue queue; - private final long timeout; + private final long timeout; - private final TimeUnit timeUnit; + private final TimeUnit timeUnit; - public QueueReplyHandler(LinkedBlockingQueue queue) { - this(queue, 5000L); - } + public QueueReplyHandler(LinkedBlockingQueue queue) { + this(queue, 5000L); + } - public QueueReplyHandler(LinkedBlockingQueue queue, long timeout) { - this(queue, timeout, TimeUnit.MILLISECONDS); - } + public QueueReplyHandler(LinkedBlockingQueue queue, long timeout) { + this(queue, timeout, TimeUnit.MILLISECONDS); + } - public QueueReplyHandler(LinkedBlockingQueue queue, long timeout, TimeUnit timeUnit) { - this.queue = queue; - this.timeout = timeout; - this.timeUnit = timeUnit; - } + public QueueReplyHandler(LinkedBlockingQueue queue, long timeout, + TimeUnit timeUnit) { + this.queue = queue; + this.timeout = timeout; + this.timeUnit = timeUnit; + } - @Override - public void handle(Message event) { + @Override + public void handle(Message event) { - try { - if (event != null && event.body != null) { - queue.offer(event.body, timeout, timeUnit); - } + try { + if (event != null && event.body() != null) { + queue.offer(event.body(), timeout, timeUnit); + } - } catch (InterruptedException e) { - Assert.fail(e.getMessage()); - } - } + } catch (InterruptedException e) { + Assert.fail(e.getMessage()); + } + } } \ No newline at end of file diff --git a/src/test/java/org/vertx/java/test/junit/ModuleMethodRuleTest.java b/src/test/java/org/vertx/java/test/junit/ModuleMethodRuleTest.java index 81cbc50..767acde 100644 --- a/src/test/java/org/vertx/java/test/junit/ModuleMethodRuleTest.java +++ b/src/test/java/org/vertx/java/test/junit/ModuleMethodRuleTest.java @@ -22,77 +22,86 @@ import org.junit.Before; import org.junit.Rule; import org.junit.Test; - import org.vertx.java.platform.PlatformManager; import org.vertx.java.platform.impl.DefaultPlatformManagerFactory; import org.vertx.java.test.TestModule; import org.vertx.java.test.TestModules; import org.vertx.java.test.utils.QueueReplyHandler; - /** * @author swilliams - * + * */ + public class ModuleMethodRuleTest { - private final PlatformManager manager = new DefaultPlatformManagerFactory().createPlatformManager(); + static { + System.setProperty("vertx.mods", "src/test/mods"); + } + + private final PlatformManager manager = new DefaultPlatformManagerFactory() + .createPlatformManager(); - @Rule - public VertxExternalResource rule = new VertxExternalResource(manager); + @Rule + public VertxExternalResource rule = new VertxExternalResource(manager); - private long timeout = 10L; + private long timeout = 10L; - @Before - public void setup() { - this.timeout = Long.parseLong(System.getProperty("vertx.test.timeout", "15L")); - try { - Thread.sleep(1000L); // FIXME this sucks - } catch (InterruptedException e) { - // - } - } + @Before + public void setup() { + this.timeout = Long.parseLong(System.getProperty("vertx.test.timeout", + "15")); + try { + Thread.sleep(1000L); // FIXME this sucks + } catch (InterruptedException e) { + // + } + } - @Test - @TestModule(name="test.echo1-v1.0") - public void testModuleEcho1() { - String QUESTION = "Is it beer oclock yet?"; + @Test + @TestModule(name = "test~echo1~1.0") + public void testModuleEcho1() { + String QUESTION = "Is it beer oclock yet?"; - final LinkedBlockingQueue queue = new LinkedBlockingQueue<>(); + final LinkedBlockingQueue queue = new LinkedBlockingQueue<>(); - manager.getVertx().eventBus().send("vertx.test.mods.echo1", QUESTION, new QueueReplyHandler(queue, timeout)); + manager.vertx() + .eventBus() + .send("vertx.test.mods.echo1", QUESTION, + new QueueReplyHandler(queue, timeout)); - try { - String answer = queue.poll(timeout, TimeUnit.SECONDS); - System.out.println("answer: " + answer); - Assert.assertTrue(QUESTION.equals(answer)); + try { + String answer = queue.poll(timeout, TimeUnit.SECONDS); + System.out.println("answer: " + answer); + Assert.assertTrue(QUESTION.equals(answer)); - } catch (InterruptedException e) { - Assert.fail(e.getMessage()); - } + } catch (InterruptedException e) { + Assert.fail(e.getMessage()); + } - } + } - @Test - @TestModules({ - @TestModule(name="test.echo2-v1.0") - }) - public void testModulesEcho2() { - String QUESTION = "What ho!"; + @Test + @TestModules({ @TestModule(name = "test~echo2~1.0") }) + public void testModulesEcho2() { + String QUESTION = "What ho!"; - final LinkedBlockingQueue queue = new LinkedBlockingQueue<>(); + final LinkedBlockingQueue queue = new LinkedBlockingQueue<>(); - manager.getVertx().eventBus().send("vertx.test.mods.echo2", QUESTION, new QueueReplyHandler(queue, timeout)); + manager.vertx() + .eventBus() + .send("vertx.test.mods.echo2", QUESTION, + new QueueReplyHandler(queue, timeout)); - try { - String answer = queue.poll(timeout, TimeUnit.SECONDS); - System.out.println("answer: " + answer); - Assert.assertTrue(QUESTION.equals(answer)); + try { + String answer = queue.poll(timeout, TimeUnit.SECONDS); + System.out.println("answer: " + answer); + Assert.assertTrue(QUESTION.equals(answer)); - } catch (InterruptedException e) { - Assert.fail(e.getMessage()); - } + } catch (InterruptedException e) { + Assert.fail(e.getMessage()); + } - } + } } diff --git a/src/test/java/org/vertx/java/test/junit/ModuleRunWithTest.java b/src/test/java/org/vertx/java/test/junit/ModuleRunWithTest.java index d774d18..77f612f 100644 --- a/src/test/java/org/vertx/java/test/junit/ModuleRunWithTest.java +++ b/src/test/java/org/vertx/java/test/junit/ModuleRunWithTest.java @@ -22,90 +22,90 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; - import org.vertx.java.test.TestModule; import org.vertx.java.test.TestModules; +import org.vertx.java.test.VertxConfiguration; import org.vertx.java.test.VertxTestBase; import org.vertx.java.test.utils.QueueReplyHandler; - /** * @author swilliams - * + * */ @RunWith(VertxJUnit4ClassRunner.class) -@TestModules({ - @TestModule(name="test.echo0-v1.0") -}) +@VertxConfiguration(modsDir = "src/test/mods") +@TestModules({ @TestModule(name = "test~echo0~1.0") }) public class ModuleRunWithTest extends VertxTestBase { - private long timeout = 10L; + private long timeout = 10L; + + @Before + public void setup() { + this.timeout = Long.parseLong(System.getProperty("vertx.test.timeout", + "15")); + } + + @Test + public void testModuleEcho0() { + + String QUESTION = "How now brown cow?"; - @Before - public void setup() { - this.timeout = Long.parseLong(System.getProperty("vertx.test.timeout", "15L")); - } + final LinkedBlockingQueue queue = new LinkedBlockingQueue<>(); - @Test - public void testModuleEcho0() { + getVertx().eventBus().send("vertx.test.mods.echo0", QUESTION, + new QueueReplyHandler(queue, timeout)); - String QUESTION = "How now brown cow?"; + try { + String answer = queue.poll(timeout, TimeUnit.SECONDS); + System.out.println("answer: " + answer); + Assert.assertTrue(QUESTION.equals(answer)); - final LinkedBlockingQueue queue = new LinkedBlockingQueue<>(); + } catch (InterruptedException e) { + Assert.fail(e.getMessage()); + } - getVertx().eventBus().send("vertx.test.mods.echo0", QUESTION, new QueueReplyHandler(queue, timeout)); - - try { - String answer = queue.poll(timeout, TimeUnit.SECONDS); - System.out.println("answer: " + answer); - Assert.assertTrue(QUESTION.equals(answer)); + } - } catch (InterruptedException e) { - Assert.fail(e.getMessage()); - } + @Test + @TestModule(name = "test~echo1~1.0") + public void testModuleEcho1() { + String QUESTION = "Is it beer oclock yet?"; - } + final LinkedBlockingQueue queue = new LinkedBlockingQueue<>(); - @Test - @TestModule(name="test.echo1-v1.0") - public void testModuleEcho1() { - String QUESTION = "Is it beer oclock yet?"; + getVertx().eventBus().send("vertx.test.mods.echo1", QUESTION, + new QueueReplyHandler(queue, timeout)); - final LinkedBlockingQueue queue = new LinkedBlockingQueue<>(); + try { + String answer = queue.poll(timeout, TimeUnit.SECONDS); + System.out.println("answer: " + answer); + Assert.assertTrue(QUESTION.equals(answer)); - getVertx().eventBus().send("vertx.test.mods.echo1", QUESTION, new QueueReplyHandler(queue, timeout)); - - try { - String answer = queue.poll(timeout, TimeUnit.SECONDS); - System.out.println("answer: " + answer); - Assert.assertTrue(QUESTION.equals(answer)); + } catch (InterruptedException e) { + Assert.fail(e.getMessage()); + } - } catch (InterruptedException e) { - Assert.fail(e.getMessage()); - } + } - } + @Test + @TestModules({ @TestModule(name = "test~echo2~1.0") }) + public void testModulesEcho2() { + String QUESTION = "What ho!"; - @Test - @TestModules({ - @TestModule(name="test.echo2-v1.0") - }) - public void testModulesEcho2() { - String QUESTION = "What ho!"; + final LinkedBlockingQueue queue = new LinkedBlockingQueue<>(); - final LinkedBlockingQueue queue = new LinkedBlockingQueue<>(); + getVertx().eventBus().send("vertx.test.mods.echo2", QUESTION, + new QueueReplyHandler(queue, timeout)); - getVertx().eventBus().send("vertx.test.mods.echo2", QUESTION, new QueueReplyHandler(queue, timeout)); - - try { - String answer = queue.poll(timeout, TimeUnit.SECONDS); - System.out.println("answer: " + answer); - Assert.assertTrue(QUESTION.equals(answer)); + try { + String answer = queue.poll(timeout, TimeUnit.SECONDS); + System.out.println("answer: " + answer); + Assert.assertTrue(QUESTION.equals(answer)); - } catch (InterruptedException e) { - Assert.fail(e.getMessage()); - } + } catch (InterruptedException e) { + Assert.fail(e.getMessage()); + } - } + } } diff --git a/src/test/java/org/vertx/java/test/junit/SimpleEchoTest.java b/src/test/java/org/vertx/java/test/junit/SimpleEchoTest.java index 4cd3fd0..5a8de5d 100644 --- a/src/test/java/org/vertx/java/test/junit/SimpleEchoTest.java +++ b/src/test/java/org/vertx/java/test/junit/SimpleEchoTest.java @@ -28,63 +28,64 @@ import org.vertx.java.test.VertxAware; import org.vertx.java.test.utils.QueueReplyHandler; - /** * @author swilliams - * + * */ @RunWith(VertxJUnit4ClassRunner.class) public class SimpleEchoTest implements VertxAware { - private static final String QUESTION = "Hello World"; - - private static final String TEST_ADDRESS = "vertx.test.echo"; - - private Vertx vertx; - - @Override - public void setVertx(Vertx vertx) { - this.vertx = vertx; - } - - @Before - public void setup() { - Assert.assertNotNull(vertx); - - vertx.eventBus().registerHandler(TEST_ADDRESS, new Handler>() { - @Override - public void handle(Message event) { - if (QUESTION.equals(event.body)) { - event.reply(event.body); - } - else { - event.reply("huh?"); - } - }}); - - try { - Thread.sleep(1000L); // FIXME this sucks - } catch (InterruptedException e) { - // - } - } - - @Test - public void test() { - - final long timeout = 10L; - final LinkedBlockingQueue queue = new LinkedBlockingQueue<>(); - - vertx.eventBus().send(TEST_ADDRESS, QUESTION, new QueueReplyHandler(queue, timeout)); - - try { - String answer = queue.poll(timeout, TimeUnit.SECONDS); - System.out.println("answer: " + answer); - Assert.assertTrue(QUESTION.equals(answer)); - - } catch (InterruptedException e) { - // - } - } + private static final String QUESTION = "Hello World"; + + private static final String TEST_ADDRESS = "vertx.test.echo"; + + private Vertx vertx; + + @Override + public void setVertx(Vertx vertx) { + this.vertx = vertx; + } + + @Before + public void setup() { + Assert.assertNotNull(vertx); + + vertx.eventBus().registerHandler(TEST_ADDRESS, + new Handler>() { + @Override + public void handle(Message event) { + if (QUESTION.equals(event.body())) { + event.reply(event.body()); + } else { + event.reply("huh?"); + } + } + }); + + try { + Thread.sleep(1000L); // FIXME this sucks + } catch (InterruptedException e) { + // + } + } + + @Test + public void test() { + + final long timeout = 10L; + final LinkedBlockingQueue queue = new LinkedBlockingQueue<>(); + + vertx.eventBus().send(TEST_ADDRESS, QUESTION, + new QueueReplyHandler(queue, timeout)); + + try { + String answer = queue.poll(timeout, TimeUnit.SECONDS); + System.out.println("answer: " + answer); + Assert.assertTrue(QUESTION.equals(answer)); + + } catch (InterruptedException e) { + // + } + } } diff --git a/src/test/java/org/vertx/java/test/junit/SimpleModuleTest.java b/src/test/java/org/vertx/java/test/junit/SimpleModuleTest.java index b91db61..5ff79f0 100644 --- a/src/test/java/org/vertx/java/test/junit/SimpleModuleTest.java +++ b/src/test/java/org/vertx/java/test/junit/SimpleModuleTest.java @@ -15,7 +15,6 @@ */ package org.vertx.java.test.junit; - import org.junit.After; import org.junit.Assert; import org.junit.Before; @@ -25,65 +24,62 @@ import org.vertx.java.test.PlatformManagerAware; import org.vertx.java.test.TestModule; import org.vertx.java.test.TestModules; - import org.vertx.java.test.VertxConfiguration; @RunWith(VertxJUnit4ClassRunner.class) -@VertxConfiguration(modsDir="src/test/mods") -@TestModule(name="test.echo0-v1.0") +@VertxConfiguration(modsDir = "src/test/mods") +@TestModule(name = "test~echo0~1.0") public class SimpleModuleTest implements PlatformManagerAware { - private volatile PlatformManager platformManager; + private volatile PlatformManager platformManager; - @Override - public void setPlatformManager(PlatformManager platformManager) { - this.platformManager = platformManager; - } + @Override + public void setPlatformManager(PlatformManager platformManager) { + this.platformManager = platformManager; + } - @Before - @TestModule(name="test.echo0-v1.0") - public void before() { - System.out.printf("test.before %s %n", platformManager.listInstances()); - } + @Before + @TestModule(name = "test~echo0~1.0") + public void before() { + System.out.printf("test.before %s %n", platformManager.listInstances()); + } - @Test - @TestModules({ - @TestModule(name="test.echo0-v1.0"), - @TestModule(name="test.echo1-v1.0"), - @TestModule(name="test.echo2-v1.0") - }) - public void test1() { - int instances = platformManager.listInstances().size(); - System.out.printf("test.test1 %s %n", platformManager.listInstances()); - Assert.assertEquals(instances, 4); - } + @Test + @TestModules({ @TestModule(name = "test~echo0~1.0"), + @TestModule(name = "test~echo1~1.0"), + @TestModule(name = "test~echo2~1.0") }) + public void test1() { + int instances = platformManager.listInstances().size(); + System.out.printf("test.test1 %s %n", platformManager.listInstances()); + Assert.assertEquals(instances, 4); + } - @Test - @TestModule(name="test.echo1-v1.0", instances=3) - public void test2() { - int instances = platformManager.listInstances().size(); - System.out.printf("test.test2 %s %n", platformManager.listInstances()); - Assert.assertEquals(instances, 2); - } + @Test + @TestModule(name = "test~echo1~1.0", instances = 3) + public void test2() { + int instances = platformManager.listInstances().size(); + System.out.printf("test.test2 %s %n", platformManager.listInstances()); + Assert.assertEquals(instances, 2); + } - @Test - @TestModule(name="test.echo2-v1.0", jsonConfig="{\"port\":8091}") - public void test3() { - int instances = platformManager.listInstances().size(); - System.out.printf("test.test3 %s %n", platformManager.listInstances()); - Assert.assertEquals(instances, 2); - } + @Test + @TestModule(name = "test~echo2~1.0", jsonConfig = "{\"port\":8091}") + public void test3() { + int instances = platformManager.listInstances().size(); + System.out.printf("test.test3 %s %n", platformManager.listInstances()); + Assert.assertEquals(instances, 2); + } - @Test - @TestModule(name="test.echo0-v1.0") - public void test4() { - int instances = platformManager.listInstances().size(); - System.out.printf("test.test4 %s %n", platformManager.listInstances()); - Assert.assertEquals(instances, 2); - } + @Test + @TestModule(name = "test~echo0~1.0") + public void test4() { + int instances = platformManager.listInstances().size(); + System.out.printf("test.test4 %s %n", platformManager.listInstances()); + Assert.assertEquals(instances, 2); + } - @After - public void after() { - System.out.printf("test.after %s %n", platformManager.listInstances()); - } + @After + public void after() { + System.out.printf("test.after %s %n", platformManager.listInstances()); + } } diff --git a/src/test/java/org/vertx/java/test/junit/SimpleTestBusModTest.java b/src/test/java/org/vertx/java/test/junit/SimpleTestBusModTest.java index 0e7197c..de56cdb 100644 --- a/src/test/java/org/vertx/java/test/junit/SimpleTestBusModTest.java +++ b/src/test/java/org/vertx/java/test/junit/SimpleTestBusModTest.java @@ -27,35 +27,35 @@ @VertxConfiguration public class SimpleTestBusModTest extends Verticle { - private boolean started; - - @Override - public void start() throws Exception { - System.out.println("verticle.start"); - this.started = true; - } - - @Before - public void before() throws Exception { - System.out.println("verticle.before"); - Assert.assertTrue(started); - } - - @Test - public void test() throws Exception { - System.out.println("verticle.test"); - } - - @After - public void after() throws Exception { - System.out.println("verticle.after"); - } - - @Override - public void stop() throws Exception { - System.out.println("verticle.stop"); - this.started = false; - super.stop(); - } + private boolean started; + + @Override + public void start() { + System.out.println("verticle.start"); + this.started = true; + } + + @Before + public void before() throws Exception { + System.out.println("verticle.before"); + Assert.assertTrue(started); + } + + @Test + public void test() throws Exception { + System.out.println("verticle.test"); + } + + @After + public void after() throws Exception { + System.out.println("verticle.after"); + } + + @Override + public void stop() { + System.out.println("verticle.stop"); + this.started = false; + super.stop(); + } } diff --git a/src/test/java/org/vertx/java/test/junit/SimpleTestVerticleTest.java b/src/test/java/org/vertx/java/test/junit/SimpleTestVerticleTest.java index 5c4b889..364f6f4 100644 --- a/src/test/java/org/vertx/java/test/junit/SimpleTestVerticleTest.java +++ b/src/test/java/org/vertx/java/test/junit/SimpleTestVerticleTest.java @@ -27,35 +27,35 @@ @VertxConfiguration public class SimpleTestVerticleTest extends BusModBase { - private boolean started; - - @Override - public void start() { - System.out.println("busmod.start"); - this.started = true; - } - - @Before - public void before() throws Exception { - System.out.println("busmod.before"); - Assert.assertTrue(started); - } - - @Test - public void test() throws Exception { - System.out.println("busmod.test"); - } - - @After - public void after() throws Exception { - System.out.println("busmod.after"); - } - - @Override - public void stop() throws Exception { - System.out.println("busmod.stop"); - started = false; - super.stop(); - } + private boolean started; + + @Override + public void start() { + System.out.println("busmod.start"); + this.started = true; + } + + @Before + public void before() throws Exception { + System.out.println("busmod.before"); + Assert.assertTrue(started); + } + + @Test + public void test() throws Exception { + System.out.println("busmod.test"); + } + + @After + public void after() throws Exception { + System.out.println("busmod.after"); + } + + @Override + public void stop() { + System.out.println("busmod.stop"); + started = false; + super.stop(); + } } diff --git a/src/test/java/org/vertx/java/test/junit/VerticleMethodRuleTest.java b/src/test/java/org/vertx/java/test/junit/VerticleMethodRuleTest.java index f77469e..a8d174c 100644 --- a/src/test/java/org/vertx/java/test/junit/VerticleMethodRuleTest.java +++ b/src/test/java/org/vertx/java/test/junit/VerticleMethodRuleTest.java @@ -22,7 +22,6 @@ import org.junit.Before; import org.junit.Rule; import org.junit.Test; - import org.vertx.java.core.Vertx; import org.vertx.java.platform.PlatformManager; import org.vertx.java.platform.impl.DefaultPlatformManagerFactory; @@ -32,69 +31,72 @@ /** * @author swilliams - * + * */ + public class VerticleMethodRuleTest { - private final PlatformManager manager = new DefaultPlatformManagerFactory().createPlatformManager(); - - @Rule - public VertxExternalResource rule = new VertxExternalResource(manager); - - private long timeout = 10L; - - public Vertx getVertx() { - return manager.getVertx(); - } - - @Before - public void setup() { - this.timeout = Long.parseLong(System.getProperty("vertx.test.timeout", "15L")); - try { - Thread.sleep(1000L); // FIXME this sucks - } catch (InterruptedException e) { - // - } - } - - @Test - @TestVerticle(main="test_verticle1.js") - public void testVerticle1() { - String QUESTION = "Oh no. Not penalties again..."; - - final LinkedBlockingQueue queue = new LinkedBlockingQueue<>(); - - getVertx().eventBus().send("vertx.test.echo1", QUESTION, new QueueReplyHandler(queue, timeout)); - - try { - String answer = queue.poll(timeout, TimeUnit.SECONDS); - System.out.println("answer: " + answer); - Assert.assertTrue(QUESTION.equals(answer)); - - } catch (InterruptedException e) { - // - } - } - - @Test - @TestVerticles({ - @TestVerticle(main="test_verticle2.js") - }) - public void testVerticles2() { - String QUESTION = "Smashing fun, what!"; - - final LinkedBlockingQueue queue = new LinkedBlockingQueue<>(); - - getVertx().eventBus().send("vertx.test.echo2", QUESTION, new QueueReplyHandler(queue, timeout)); - - try { - String answer = queue.poll(timeout, TimeUnit.SECONDS); - System.out.println("answer: " + answer); - Assert.assertTrue(QUESTION.equals(answer)); - - } catch (InterruptedException e) { - // - } - } + private final PlatformManager manager = new DefaultPlatformManagerFactory() + .createPlatformManager(); + + @Rule + public VertxExternalResource rule = new VertxExternalResource(manager); + + private long timeout = 10L; + + public Vertx getVertx() { + return manager.vertx(); + } + + @Before + public void setup() { + this.timeout = Long.parseLong(System.getProperty("vertx.test.timeout", + "15")); + try { + Thread.sleep(1000L); // FIXME this sucks + } catch (InterruptedException e) { + // + } + } + + @Test + @TestVerticle(main = "test_verticle1.js") + public void testVerticle1() { + String QUESTION = "Oh no. Not penalties again..."; + + final LinkedBlockingQueue queue = new LinkedBlockingQueue<>(); + + getVertx().eventBus().send("vertx.test.echo1", QUESTION, + new QueueReplyHandler(queue, timeout)); + + try { + String answer = queue.poll(timeout, TimeUnit.SECONDS); + System.out.println("answer: " + answer); + Assert.assertTrue(QUESTION.equals(answer)); + + } catch (InterruptedException e) { + // + } + } + + @Test + @TestVerticles({ @TestVerticle(main = "test_verticle2.js") }) + public void testVerticles2() { + String QUESTION = "Smashing fun, what!"; + + final LinkedBlockingQueue queue = new LinkedBlockingQueue<>(); + + getVertx().eventBus().send("vertx.test.echo2", QUESTION, + new QueueReplyHandler(queue, timeout)); + + try { + String answer = queue.poll(timeout, TimeUnit.SECONDS); + System.out.println("answer: " + answer); + Assert.assertTrue(QUESTION.equals(answer)); + + } catch (InterruptedException e) { + // + } + } } diff --git a/src/test/java/org/vertx/java/test/junit/VerticleRunWithTest.java b/src/test/java/org/vertx/java/test/junit/VerticleRunWithTest.java index bb77374..9e22c1f 100644 --- a/src/test/java/org/vertx/java/test/junit/VerticleRunWithTest.java +++ b/src/test/java/org/vertx/java/test/junit/VerticleRunWithTest.java @@ -22,84 +22,84 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; - import org.vertx.java.test.TestVerticle; import org.vertx.java.test.TestVerticles; import org.vertx.java.test.VertxTestBase; import org.vertx.java.test.utils.QueueReplyHandler; - /** * @author swilliams - * + * */ @RunWith(VertxJUnit4ClassRunner.class) -@TestVerticle(main="test_verticle0.js") +@TestVerticle(main = "test_verticle0.js") public class VerticleRunWithTest extends VertxTestBase { - private long timeout = 10L; - - @Before - public void setup() { - this.timeout = Long.parseLong(System.getProperty("vertx.test.timeout", "15L")); - } - - @Test - public void testVerticle0() { - String QUESTION = "I say, anyone for cricket?"; - - final LinkedBlockingQueue queue = new LinkedBlockingQueue<>(); - - getVertx().eventBus().send("vertx.test.echo0", QUESTION, new QueueReplyHandler(queue, timeout)); - - try { - String answer = queue.poll(timeout, TimeUnit.SECONDS); - System.out.println("answer: " + answer); - Assert.assertTrue(QUESTION.equals(answer)); - - } catch (InterruptedException e) { - // - } - } - - @Test - @TestVerticle(main="test_verticle1.js") - public void testVerticle1() { - String QUESTION = "Oh no. Not penalties again..."; - - final LinkedBlockingQueue queue = new LinkedBlockingQueue<>(); - - getVertx().eventBus().send("vertx.test.echo1", QUESTION, new QueueReplyHandler(queue, timeout)); - - try { - String answer = queue.poll(timeout, TimeUnit.SECONDS); - System.out.println("answer: " + answer); - Assert.assertTrue(QUESTION.equals(answer)); - - } catch (InterruptedException e) { - // - } - } - - @Test - @TestVerticles({ - @TestVerticle(main="test_verticle2.js") - }) - public void testVerticles2() { - String QUESTION = "Smashing fun, what!"; - - final LinkedBlockingQueue queue = new LinkedBlockingQueue<>(); - - getVertx().eventBus().send("vertx.test.echo2", QUESTION, new QueueReplyHandler(queue, timeout)); - - try { - String answer = queue.poll(timeout, TimeUnit.SECONDS); - System.out.println("answer: " + answer); - Assert.assertTrue(QUESTION.equals(answer)); - - } catch (InterruptedException e) { - // - } - } + private long timeout = 10L; + + @Before + public void setup() { + this.timeout = Long.parseLong(System.getProperty("vertx.test.timeout", + "15")); + } + + @Test + public void testVerticle0() { + String QUESTION = "I say, anyone for cricket?"; + + final LinkedBlockingQueue queue = new LinkedBlockingQueue<>(); + + getVertx().eventBus().send("vertx.test.echo0", QUESTION, + new QueueReplyHandler(queue, timeout)); + + try { + String answer = queue.poll(timeout, TimeUnit.SECONDS); + System.out.println("answer: " + answer); + Assert.assertTrue(QUESTION.equals(answer)); + + } catch (InterruptedException e) { + // + } + } + + @Test + @TestVerticle(main = "test_verticle1.js") + public void testVerticle1() { + String QUESTION = "Oh no. Not penalties again..."; + + final LinkedBlockingQueue queue = new LinkedBlockingQueue<>(); + + getVertx().eventBus().send("vertx.test.echo1", QUESTION, + new QueueReplyHandler(queue, timeout)); + + try { + String answer = queue.poll(timeout, TimeUnit.SECONDS); + System.out.println("answer: " + answer); + Assert.assertTrue(QUESTION.equals(answer)); + + } catch (InterruptedException e) { + // + } + } + + @Test + @TestVerticles({ @TestVerticle(main = "test_verticle2.js") }) + public void testVerticles2() { + String QUESTION = "Smashing fun, what!"; + + final LinkedBlockingQueue queue = new LinkedBlockingQueue<>(); + + getVertx().eventBus().send("vertx.test.echo2", QUESTION, + new QueueReplyHandler(queue, timeout)); + + try { + String answer = queue.poll(timeout, TimeUnit.SECONDS); + System.out.println("answer: " + answer); + Assert.assertTrue(QUESTION.equals(answer)); + + } catch (InterruptedException e) { + // + } + } } diff --git a/src/test/mods/test.echo0-v1.0/echo0.js b/src/test/mods/test~echo0~1.0/echo0.js similarity index 95% rename from src/test/mods/test.echo0-v1.0/echo0.js rename to src/test/mods/test~echo0~1.0/echo0.js index 341f3b4..a8b2901 100644 --- a/src/test/mods/test.echo0-v1.0/echo0.js +++ b/src/test/mods/test~echo0~1.0/echo0.js @@ -14,7 +14,7 @@ * limitations under the License. */ -load('vertx.js') +var vertx = require('vertx.js') var eb = vertx.eventBus; var address = 'vertx.test.mods.echo0'; diff --git a/src/test/mods/test.echo0-v1.0/mod.json b/src/test/mods/test~echo0~1.0/mod.json similarity index 100% rename from src/test/mods/test.echo0-v1.0/mod.json rename to src/test/mods/test~echo0~1.0/mod.json diff --git a/src/test/mods/test.echo1-v1.0/echo1.js b/src/test/mods/test~echo1~1.0/echo1.js similarity index 95% rename from src/test/mods/test.echo1-v1.0/echo1.js rename to src/test/mods/test~echo1~1.0/echo1.js index fdd1d78..1feebe5 100644 --- a/src/test/mods/test.echo1-v1.0/echo1.js +++ b/src/test/mods/test~echo1~1.0/echo1.js @@ -14,7 +14,7 @@ * limitations under the License. */ -load('vertx.js') +var vertx = require('vertx.js') var eb = vertx.eventBus; var address = 'vertx.test.mods.echo1'; diff --git a/src/test/mods/test.echo1-v1.0/mod.json b/src/test/mods/test~echo1~1.0/mod.json similarity index 100% rename from src/test/mods/test.echo1-v1.0/mod.json rename to src/test/mods/test~echo1~1.0/mod.json diff --git a/src/test/mods/test.echo2-v1.0/echo2.js b/src/test/mods/test~echo2~1.0/echo2.js similarity index 95% rename from src/test/mods/test.echo2-v1.0/echo2.js rename to src/test/mods/test~echo2~1.0/echo2.js index 93d107a..62d8af3 100644 --- a/src/test/mods/test.echo2-v1.0/echo2.js +++ b/src/test/mods/test~echo2~1.0/echo2.js @@ -14,7 +14,7 @@ * limitations under the License. */ -load('vertx.js') +var vertx = require('vertx.js') var eb = vertx.eventBus; var address = 'vertx.test.mods.echo2'; diff --git a/src/test/mods/test.echo2-v1.0/mod.json b/src/test/mods/test~echo2~1.0/mod.json similarity index 100% rename from src/test/mods/test.echo2-v1.0/mod.json rename to src/test/mods/test~echo2~1.0/mod.json diff --git a/src/test/resources/langs.properties b/src/test/resources/__langs.properties similarity index 100% rename from src/test/resources/langs.properties rename to src/test/resources/__langs.properties diff --git a/src/test/resources/test_client.js b/src/test/resources/test_client.js index fde21cb..0422aa5 100644 --- a/src/test/resources/test_client.js +++ b/src/test/resources/test_client.js @@ -15,7 +15,7 @@ */ load('test_utils.js') -load('vertx.js') +var vertx = require('vertx.js') var tu = new TestUtils(); var eb = vertx.eventBus; diff --git a/src/test/resources/test_json0.js b/src/test/resources/test_json0.js index f5b771a..765ee08 100644 --- a/src/test/resources/test_json0.js +++ b/src/test/resources/test_json0.js @@ -14,12 +14,12 @@ * limitations under the License. */ -load('vertx.js') +var vertx = require('vertx.js') +var container = require('vertx/container'); var eb = vertx.eventBus; - var address = 'vertx.test.echo0'; eb.registerHandler(address, function(msg, reply) { - reply(vertx.config.foo); + reply(container.config.foo); }); diff --git a/src/test/resources/test_verticle0.js b/src/test/resources/test_verticle0.js index f652654..707e90a 100644 --- a/src/test/resources/test_verticle0.js +++ b/src/test/resources/test_verticle0.js @@ -14,7 +14,7 @@ * limitations under the License. */ -load('vertx.js') +var vertx = require('vertx.js') var eb = vertx.eventBus; diff --git a/src/test/resources/test_verticle1.js b/src/test/resources/test_verticle1.js index 87c2a2a..7101966 100644 --- a/src/test/resources/test_verticle1.js +++ b/src/test/resources/test_verticle1.js @@ -14,7 +14,7 @@ * limitations under the License. */ -load('vertx.js') +var vertx = require('vertx.js') var eb = vertx.eventBus; diff --git a/src/test/resources/test_verticle2.js b/src/test/resources/test_verticle2.js index df69b6a..7be2f0e 100644 --- a/src/test/resources/test_verticle2.js +++ b/src/test/resources/test_verticle2.js @@ -14,7 +14,7 @@ * limitations under the License. */ -load('vertx.js') +var vertx = require('vertx.js') var eb = vertx.eventBus; diff --git a/src/test/resources/test_verticle3.js b/src/test/resources/test_verticle3.js index 6d7b1b5..90f043b 100644 --- a/src/test/resources/test_verticle3.js +++ b/src/test/resources/test_verticle3.js @@ -14,7 +14,7 @@ * limitations under the License. */ -load('vertx.js') +var vertx = require('vertx.js') var eb = vertx.eventBus; diff --git a/src/test/resources/test_verticle4.js b/src/test/resources/test_verticle4.js index 927f0db..0e8a166 100644 --- a/src/test/resources/test_verticle4.js +++ b/src/test/resources/test_verticle4.js @@ -14,7 +14,7 @@ * limitations under the License. */ -load('vertx.js') +var vertx = require('vertx.js') var eb = vertx.eventBus; diff --git a/src/test/resources/test_verticle5.js b/src/test/resources/test_verticle5.js index f939e04..924cc7d 100644 --- a/src/test/resources/test_verticle5.js +++ b/src/test/resources/test_verticle5.js @@ -14,7 +14,7 @@ * limitations under the License. */ -load('vertx.js') +var vertx = require('vertx.js') var eb = vertx.eventBus; diff --git a/src/test/resources/test_verticle6.js b/src/test/resources/test_verticle6.js index a49ac92..db54e19 100644 --- a/src/test/resources/test_verticle6.js +++ b/src/test/resources/test_verticle6.js @@ -14,7 +14,7 @@ * limitations under the License. */ -load('vertx.js') +var vertx = require('vertx.js') var eb = vertx.eventBus;