Permalink
Browse files

update to use platform manager in 2.0 snapshot

  • Loading branch information...
pidster committed Feb 11, 2013
1 parent 038f001 commit 45b476dd01d04efe226d70a5d83709ffed751509
Showing with 2,040 additions and 160 deletions.
  1. +6 −5 build.gradle
  2. +2 −2 gradle.properties
  3. +4 −3 src/main/java/org/vertx/java/test/{VerticleManagerAware.java → ContainerAware.java}
  4. +29 −0 src/main/java/org/vertx/java/test/PlatformManagerAware.java
  5. +2 −0 src/main/java/org/vertx/java/test/TestVerticle.java
  6. +7 −7 src/main/java/org/vertx/java/test/VertxTestBase.java
  7. +4 −4 src/main/java/org/vertx/java/test/junit/JUnitDeploymentUtils.java
  8. +6 −7 src/main/java/org/vertx/java/test/junit/VertxExternalResource.java
  9. +36 −31 src/main/java/org/vertx/java/test/junit/VertxJUnit4ClassRunner.java
  10. +17 −13 src/main/java/org/vertx/java/test/utils/DeploymentUtils.java
  11. +8 −8 src/main/java/org/vertx/java/test/utils/InjectionUtils.java
  12. +1 −1 src/test/java/org/vertx/java/test/junit/JsonConfigVerticleTest.java
  13. +7 −14 src/test/java/org/vertx/java/test/junit/ModuleMethodRuleTest.java
  14. +18 −17 src/test/java/org/vertx/java/test/junit/SimpleModuleTest.java
  15. +1 −1 src/test/java/org/vertx/java/test/junit/SimpleTestBusModTest.java
  16. +11 −11 src/test/java/org/vertx/java/test/junit/SimpleVerticleTest.java
  17. +4 −6 src/test/java/org/vertx/java/test/junit/VerticleMethodRuleTest.java
  18. +2 −2 src/test/java/org/vertx/java/test/junit/VertxConfigurationTest.java
  19. +16 −0 src/test/mods/maven:io.vertx:lang-rhino:1.0.0-SNAPSHOT/coffee-script.js
  20. +20 −0 src/test/mods/maven:io.vertx:lang-rhino:1.0.0-SNAPSHOT/core/buffer.js
  21. +84 −0 src/test/mods/maven:io.vertx:lang-rhino:1.0.0-SNAPSHOT/core/deploy.js
  22. +27 −0 src/test/mods/maven:io.vertx:lang-rhino:1.0.0-SNAPSHOT/core/env.js
  23. +174 −0 src/test/mods/maven:io.vertx:lang-rhino:1.0.0-SNAPSHOT/core/event_bus.js
  24. +426 −0 src/test/mods/maven:io.vertx:lang-rhino:1.0.0-SNAPSHOT/core/filesystem.js
  25. +679 −0 src/test/mods/maven:io.vertx:lang-rhino:1.0.0-SNAPSHOT/core/http.js
  26. +35 −0 src/test/mods/maven:io.vertx:lang-rhino:1.0.0-SNAPSHOT/core/logger.js
  27. +27 −0 src/test/mods/maven:io.vertx:lang-rhino:1.0.0-SNAPSHOT/core/net.js
  28. +27 −0 src/test/mods/maven:io.vertx:lang-rhino:1.0.0-SNAPSHOT/core/parse_tools.js
  29. +39 −0 src/test/mods/maven:io.vertx:lang-rhino:1.0.0-SNAPSHOT/core/shared_data.js
  30. +66 −0 src/test/mods/maven:io.vertx:lang-rhino:1.0.0-SNAPSHOT/core/sockjs.js
  31. +53 −0 src/test/mods/maven:io.vertx:lang-rhino:1.0.0-SNAPSHOT/core/streams.js
  32. +36 −0 src/test/mods/maven:io.vertx:lang-rhino:1.0.0-SNAPSHOT/core/timers.js
  33. +23 −0 src/test/mods/maven:io.vertx:lang-rhino:1.0.0-SNAPSHOT/core/utils.js
  34. BIN src/test/mods/maven:io.vertx:lang-rhino:1.0.0-SNAPSHOT/lib/rhino-1.7R4.jar
  35. +4 −0 src/test/mods/maven:io.vertx:lang-rhino:1.0.0-SNAPSHOT/mod.json
  36. BIN .../maven:io.vertx:lang-rhino:1.0.0-SNAPSHOT/org/vertx/java/platform/impl/CoffeeScriptCompiler.class
  37. BIN ...s/maven:io.vertx:lang-rhino:1.0.0-SNAPSHOT/org/vertx/java/platform/impl/RhinoContextFactory.class
  38. BIN ...aven:io.vertx:lang-rhino:1.0.0-SNAPSHOT/org/vertx/java/platform/impl/RhinoVerticleFactory$1.class
  39. BIN ...aven:io.vertx:lang-rhino:1.0.0-SNAPSHOT/org/vertx/java/platform/impl/RhinoVerticleFactory$2.class
  40. BIN ...x:lang-rhino:1.0.0-SNAPSHOT/org/vertx/java/platform/impl/RhinoVerticleFactory$RhinoVerticle.class
  41. BIN .../maven:io.vertx:lang-rhino:1.0.0-SNAPSHOT/org/vertx/java/platform/impl/RhinoVerticleFactory.class
  42. +69 −0 src/test/mods/maven:io.vertx:lang-rhino:1.0.0-SNAPSHOT/test_utils.js
  43. +33 −0 src/test/mods/maven:io.vertx:lang-rhino:1.0.0-SNAPSHOT/vertx.js
  44. +32 −28 src/test/resources/langs.properties
  45. +5 −0 src/test/resources/repos.txt
View
@@ -24,18 +24,19 @@ sourceCompatibility = '1.7'
targetCompatibility = '1.7'
repositories {
+ mavenLocal()
+ maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
mavenCentral()
}
dependencies {
compile "junit:junit-dep:$junitVersion"
- compile "org.vert-x:vertx-core:$vertxVersion"
- compile "org.vert-x:vertx-platform:$vertxVersion"
+ compile "io.vertx:vertx-core:$vertxVersion"
+ compile "io.vertx:vertx-platform:$vertxVersion"
- testCompile "org.vert-x:vertx-lang-java:$vertxVersion"
- testCompile "org.vert-x:vertx-lang-rhino:$vertxVersion"
+// testCompile "io.vertx:lang-java:$vertxVersion"
+ testCompile "io.vertx:lang-rhino:1.0.0-SNAPSHOT"
testCompile "org.mozilla:rhino:$rhinoVersion"
-
}
test {
View
@@ -13,12 +13,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-version=1.3.3-SNAPSHOT
+version=2.0.0-SNAPSHOT
group=org.vert-x
modulename=vertx-junit-annotations
gradleVersion=1.4
-vertxVersion=1.3.1.final
+vertxVersion=2.0.0-SNAPSHOT
rhinoVersion=1.7R4
junitVersion=4.11
@@ -15,14 +15,15 @@
*/
package org.vertx.java.test;
-import org.vertx.java.deploy.impl.VerticleManager;
+import org.vertx.java.platform.Container;
+
/**
* @author swilliams
*
*/
-public interface VerticleManagerAware {
+public interface ContainerAware {
- void setVerticleManager(VerticleManager verticleManager);
+ void setContainer(Container container);
}
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2012 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.vertx.java.test;
+
+import org.vertx.java.platform.PlatformManager;
+
+
+/**
+ * @author swilliams
+ *
+ */
+public interface PlatformManagerAware {
+
+ void setPlatformManager(PlatformManager platformManager);
+
+}
@@ -35,6 +35,8 @@
boolean worker() default false;
+ boolean multiThreaded() default false;
+
String main();
int instances() default 1;
@@ -28,7 +28,7 @@
import org.vertx.java.core.Vertx;
import org.vertx.java.core.eventbus.EventBus;
import org.vertx.java.core.eventbus.Message;
-import org.vertx.java.deploy.impl.VerticleManager;
+import org.vertx.java.platform.Container;
import org.vertx.java.test.utils.QueueReplyHandler;
import org.vertx.java.test.utils.SimpleLatchAsyncResultHandler;
@@ -37,11 +37,11 @@
* @author swilliams
*
*/
-public abstract class VertxTestBase implements VertxAware, VerticleManagerAware {
+public abstract class VertxTestBase implements VertxAware, ContainerAware {
private Vertx vertx;
- private VerticleManager manager;
+ private Container container;
@SuppressWarnings("rawtypes")
private Map<String, VertxHandlerMapping> mappings = new HashMap<>();
@@ -58,8 +58,8 @@ public void setVertx(Vertx vertx) {
}
@Override
- public void setVerticleManager(VerticleManager manager) {
- this.manager = manager;
+ public void setContainer(Container container) {
+ this.container = container;
}
protected Vertx getVertx() {
@@ -70,8 +70,8 @@ protected EventBus getEventBus() {
return vertx.eventBus();
}
- protected VerticleManager getManager() {
- return manager;
+ protected Container getContainer() {
+ return container;
}
protected static final void setAwaitTimeout(long awaitTimeout) {
@@ -23,7 +23,7 @@
import java.util.Set;
import org.junit.runner.Description;
-import org.vertx.java.deploy.impl.VerticleManager;
+import org.vertx.java.platform.PlatformManager;
import org.vertx.java.test.TestModule;
import org.vertx.java.test.TestModules;
import org.vertx.java.test.TestVerticle;
@@ -41,7 +41,7 @@
* @param description
* @return map
*/
- public static Map<Annotation, String> deploy(VerticleManager manager, File modDir, Description description, long timeout) {
+ public static Map<Annotation, String> deploy(PlatformManager platformManager, File modDir, Description description, long timeout) {
Map<Annotation, String> deployments = new HashMap<>();
@@ -60,7 +60,7 @@
}
}
- Map<Annotation, String> verticleDeployments = DeploymentUtils.deployVerticles(manager, modDir, verticles, timeout);
+ Map<Annotation, String> verticleDeployments = DeploymentUtils.deployVerticles(platformManager, modDir, verticles, timeout);
deployments.putAll(verticleDeployments);
// ------------------------------------------------------------------------------
@@ -78,7 +78,7 @@
}
}
- Map<Annotation, String> modulesDeployments = DeploymentUtils.deployModules(manager, modDir, modules, timeout);
+ Map<Annotation, String> modulesDeployments = DeploymentUtils.deployModules(platformManager, modDir, modules, timeout);
deployments.putAll(modulesDeployments);
// ------------------------------------------------------------------------------
@@ -22,9 +22,8 @@
import org.junit.rules.ExternalResource;
import org.junit.runner.Description;
import org.junit.runners.model.Statement;
-import org.vertx.java.deploy.impl.VerticleManager;
+import org.vertx.java.platform.PlatformManager;
import org.vertx.java.test.utils.DeploymentRegistry;
-import org.vertx.java.test.utils.DeploymentUtils;
/**
* @author swilliams
@@ -34,14 +33,14 @@
private File modDir;
- private VerticleManager manager;
+ private PlatformManager platformManager;
private Description description;
private Map<Annotation, String> methodDeployments;
- public VertxExternalResource(VerticleManager manager) {
- this.manager = manager;
+ public VertxExternalResource(PlatformManager platformManager) {
+ this.platformManager = platformManager;
}
@Override
@@ -59,15 +58,15 @@ public Statement apply(Statement base, Description description) {
@Override
protected void before() throws Throwable {
long timeout = Long.getLong("vertx.test.timeout", 15000L);
- this.methodDeployments = JUnitDeploymentUtils.deploy(manager, modDir, description, timeout);
+ this.methodDeployments = JUnitDeploymentUtils.deploy(platformManager, modDir, description, timeout);
DeploymentRegistry.register(methodDeployments);
super.before();
}
@Override
protected void after() {
if (methodDeployments.size() > 0) {
- DeploymentUtils.undeploy(manager, methodDeployments);
+ // DeploymentUtils.undeploy(container, methodDeployments);
}
super.after();
DeploymentRegistry.clear();
@@ -24,10 +24,13 @@
import org.junit.runner.Description;
import org.junit.runners.model.FrameworkMethod;
import org.junit.runners.model.InitializationError;
-import org.vertx.java.core.impl.VertxInternal;
-import org.vertx.java.deploy.Container;
-import org.vertx.java.deploy.Verticle;
-import org.vertx.java.deploy.impl.VerticleManager;
+import org.vertx.java.platform.Container;
+import org.vertx.java.platform.PlatformManagerFactory;
+import org.vertx.java.platform.Verticle;
+import org.vertx.java.platform.PlatformManager;
+import org.vertx.java.platform.impl.DefaultPlatformManagerFactory;
+import org.vertx.java.platform.impl.PlatformManagerInternal;
+
import org.vertx.java.test.VertxConfiguration;
import org.vertx.java.test.utils.CountDownLatchDoneHandler;
import org.vertx.java.test.utils.DeploymentRegistry;
@@ -40,9 +43,9 @@
*/
public class VertxJUnit4ClassRunner extends JUnit4ClassRunnerAdapter {
- private VertxInternal vertx;
-
- private VerticleManager manager;
+// private VertxInternal vertx;
+//
+ private PlatformManager platformManager;
private VertxConfiguration configuration;
@@ -61,30 +64,32 @@ public VertxJUnit4ClassRunner(Class<?> klass) throws InitializationError {
@Override
protected void beforeAll() {
- VertxBuilder builder = new VertxBuilder();
-
String vertxMods = System.getProperty("vertx.mods", "build/tmp/mods-test");
this.configuration = getDescription().getAnnotation(VertxConfiguration.class);
- if (configuration != null) {
- if (!"".equalsIgnoreCase(configuration.hostname())) {
- builder.setAddress(configuration.hostname());
- }
- if (configuration.port() > 0) {
- builder.setPort(configuration.port());
- }
- if (!"".equalsIgnoreCase(configuration.modsDir())) {
- vertxMods = configuration.modsDir();
- System.setProperty("vertx.mods", vertxMods);
- }
+ if (configuration != null && !"".equalsIgnoreCase(configuration.modsDir())) {
+ vertxMods = configuration.modsDir();
+ System.setProperty("vertx.mods", vertxMods);
+ }
+
+ // sysprops must be set before this is called
+ PlatformManagerFactory factory = new DefaultPlatformManagerFactory();
+
+ if (configuration != null && configuration.port() > 0) {
+ int clusterPort = configuration.port();
+ String clusterHost = configuration.hostname();
+ this.platformManager = factory.createPlatformManager(clusterPort, clusterHost);
+ }
+ else {
+ this.platformManager = factory.createPlatformManager();
}
+
this.modDir = new File(vertxMods);
if (!modDir.exists()) {
modDir.mkdirs();
}
- this.vertx = builder.build();
- this.manager = new VerticleManager(vertx);
+ this.platformManager = factory.createPlatformManager();
}
@Override
@@ -97,8 +102,8 @@ protected void afterCreateTest(Object target) {
if (target instanceof Verticle) {
this.verticle = (Verticle) target;
- verticle.setVertx(vertx);
- verticle.setContainer(new Container(manager));
+ verticle.setVertx(platformManager.getVertx());
+ verticle.setContainer(new Container((PlatformManagerInternal) platformManager));
try {
System.out.println("Starting test verticle!");
verticle.start();
@@ -111,8 +116,8 @@ protected void afterCreateTest(Object target) {
@Override
protected void injectResources(Object target) {
if ((configuration != null && configuration.injectResources()) || configuration == null) {
- InjectionUtils.inject(vertx, target);
- InjectionUtils.inject(manager, target);
+ InjectionUtils.inject(platformManager.getVertx(), target);
+ InjectionUtils.inject(platformManager, target);
}
}
@@ -124,20 +129,20 @@ protected void injectMethodResources(FrameworkMethod method, Object target) {
@Override
protected void beforeClass() {
long timeout = Long.getLong("vertx.test.timeout", 15000L);
- this.classDeployments = JUnitDeploymentUtils.deploy(manager, modDir, getDescription(), timeout);
+ this.classDeployments = JUnitDeploymentUtils.deploy(platformManager, modDir, getDescription(), timeout);
}
@Override
protected void beforeTest(Description description, Object target) {
long timeout = Long.getLong("vertx.test.timeout", 15000L);
- this.methodDeployments = JUnitDeploymentUtils.deploy(manager, modDir, description, timeout);
+ this.methodDeployments = JUnitDeploymentUtils.deploy(platformManager, modDir, description, timeout);
DeploymentRegistry.register(methodDeployments);
}
@Override
protected void afterTest(Description description, Object target) {
if (methodDeployments.size() > 0) {
- DeploymentUtils.undeploy(manager, methodDeployments);
+ DeploymentUtils.undeploy(platformManager, methodDeployments);
}
// avoid leaks
@@ -160,15 +165,15 @@ protected void beforeAfterClass() {
@Override
protected void afterClass() {
if (classDeployments.size() > 0) {
- DeploymentUtils.undeploy(manager, classDeployments);
+ DeploymentUtils.undeploy(platformManager, classDeployments);
}
}
@Override
protected void afterAll() {
CountDownLatch latch = new CountDownLatch(1);
CountDownLatchDoneHandler<Void> h = new CountDownLatchDoneHandler<>(latch);
- manager.undeployAll(h);
+ platformManager.undeployAll(h);
long timeout = 5L;
if (configuration != null) {
timeout = configuration.shutdownTimeoutSeconds();
Oops, something went wrong.

0 comments on commit 45b476d

Please sign in to comment.