use of io.javalin.util.SimpleHttpClient in project javalin by tipsy.
the class TestAsync method test_async.
@Test
@Ignore("Just for running manually")
public void test_async() throws Exception {
Javalin app = Javalin.create().embeddedServer(new EmbeddedJettyFactory(() -> new Server(new QueuedThreadPool(16, 10, 60_000)))).port(5454).start();
app.get("/test-async", ctx -> ctx.async(() -> {
CompletableFuture<Void> future = new CompletableFuture<>();
new Timer().schedule(new TimerTask() {
public void run() {
ctx.status(418);
future.complete(null);
}
}, 1000);
return future;
}));
long startTime = System.currentTimeMillis();
ForkJoinPool forkJoinPool = new ForkJoinPool(200);
forkJoinPool.submit(() -> IntStream.range(0, 50).parallel().forEach(i -> {
try {
assertThat(new SimpleHttpClient().http_GET("http://localhost:5454/test-async").getStatus(), is(418));
} catch (IOException e) {
e.printStackTrace();
}
})).get();
log.info("took " + (System.currentTimeMillis() - startTime) + " milliseconds");
app.stop();
}
use of io.javalin.util.SimpleHttpClient in project javalin by tipsy.
the class _SimpleClientBaseTest method setup.
@BeforeClass
public static void setup() throws IOException {
app = Javalin.create().port(0).start();
simpleHttpClient = new SimpleHttpClient();
origin = "http://localhost:" + app.port();
}
Aggregations