Skip to content

Updated to use vert.x 2.0.2-final #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
apply plugin: 'java'
apply from: 'gradle/setup.gradle'
apply from: 'gradle/maven.gradle'
apply plugin: 'eclipse'

defaultTasks = ['assemble']

Expand All @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
junitVersion=4.11
90 changes: 48 additions & 42 deletions src/main/java/org/vertx/java/test/junit/JUnitDeploymentUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,58 +32,64 @@

/**
* @author swilliams
*
*
*/
public class JUnitDeploymentUtils {

/**
* @param manager
* @param description
* @return map
*/
public static Map<Annotation, String> deploy(PlatformManager platformManager, File modDir, Description description, long timeout) {
/**
* @param platformManager
* @param description
* @return map
*/
public static Map<Annotation, String> deploy(
PlatformManager platformManager, File modDir,
Description description, long timeout) {

Map<Annotation, String> deployments = new HashMap<>();
Map<Annotation, String> deployments = new HashMap<>();

// ------------------------------------------------------------------------------
// Discover and deploy verticles
Set<TestVerticle> verticles = new HashSet<>();
TestVerticle testVerticle = description.getAnnotation(TestVerticle.class);
if (testVerticle != null) {
verticles.add(testVerticle);
}
// ------------------------------------------------------------------------------
// Discover and deploy verticles
Set<TestVerticle> 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<Annotation, String> verticleDeployments = DeploymentUtils.deployVerticles(platformManager, modDir, verticles, timeout);
deployments.putAll(verticleDeployments);
Map<Annotation, String> verticleDeployments = DeploymentUtils
.deployVerticles(platformManager, modDir, verticles, timeout);
deployments.putAll(verticleDeployments);

// ------------------------------------------------------------------------------
// Discover and deploy modules
Set<TestModule> modules = new HashSet<>();
TestModule testModule = description.getAnnotation(TestModule.class);
if (testModule != null) {
modules.add(testModule);
}
// ------------------------------------------------------------------------------
// Discover and deploy modules
Set<TestModule> 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<Annotation, String> modulesDeployments = DeploymentUtils.deployModules(platformManager, modDir, modules, timeout);
deployments.putAll(modulesDeployments);
Map<Annotation, String> modulesDeployments = DeploymentUtils
.deployModules(platformManager, modDir, modules, timeout);
deployments.putAll(modulesDeployments);

// ------------------------------------------------------------------------------
// return result
return deployments;
}
// ------------------------------------------------------------------------------
// return result
return deployments;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<T> implements Handler<T> {
public class CountDownLatchDoneHandler<T> implements Handler<AsyncResult<T>> {

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<T> event) {
latch.countDown();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public CountDownLatchHandler(int size, long timeout, TimeUnit timeUnit) {

@Override
public void handle(Message<T> event) {
boolean added = queue.offer(event.body);
boolean added = queue.offer(event.body());
if (added) {
latch.countDown();
}
Expand Down
57 changes: 31 additions & 26 deletions src/main/java/org/vertx/java/test/utils/DeploymentHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> {

private final CountDownLatch latch;

private final Set<String> 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<AsyncResult<String>> {

private final CountDownLatch latch;

private final Set<String> 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<String> 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();
}

}
Loading