Skip to content

Instantly share code, notes, and snippets.

@alexlehm
Created April 27, 2016 22:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexlehm/d04dedc0cb252521872d0bada5691d3b to your computer and use it in GitHub Desktop.
Save alexlehm/d04dedc0cb252521872d0bada5691d3b to your computer and use it in GitHub Desktop.
LocalhostTest.java
package cx.lehmann.vertx;
import org.junit.Test;
import org.junit.runner.RunWith;
import io.vertx.core.Vertx;
import io.vertx.core.net.NetClient;
import io.vertx.ext.unit.Async;
import io.vertx.ext.unit.TestContext;
import io.vertx.ext.unit.junit.VertxUnitRunner;
/**
* @author <a href="http://oss.lehmann.cx/">Alexander Lehmann</a>
*
*/
@RunWith(VertxUnitRunner.class)
public class LocalhostTest {
@Test
public void testError(TestContext context) {
Async async = context.async();
Vertx vertx = Vertx.vertx();
NetClient client = vertx.createNetClient();
client.connect(8080, "LOCALHOST", res -> {
if (res.succeeded()) {
System.out.println("success");
async.complete();
} else {
context.fail(res.cause());
}
});
}
@Test
public void testOK(TestContext context) {
Async async = context.async();
Vertx vertx = Vertx.vertx();
NetClient client = vertx.createNetClient();
client.connect(8080, "localhost", res -> {
if (res.succeeded()) {
System.out.println("success");
async.complete();
} else {
context.fail(res.cause());
}
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment