Created
April 27, 2016 22:41
-
-
Save alexlehm/d04dedc0cb252521872d0bada5691d3b to your computer and use it in GitHub Desktop.
LocalhostTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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