Search in sources :

Example 6 with Javalin

use of io.javalin.Javalin in project helloworld-web by dbelob.

the class Application method main.

public static void main(String[] args) {
    Javalin app = Javalin.create().start(8080);
    app.get("/", ctx -> ctx.result("Hello, World!"));
    app.get("/json", ctx -> ctx.json(new Entity("value")));
}
Also used : Javalin(io.javalin.Javalin)

Example 7 with Javalin

use of io.javalin.Javalin in project Artemis by mbizhani.

the class TestArtemis method test_error.

@Test
public void test_error() {
    final Javalin app = Javalin.create().start(8080);
    configure(app);
    final int degree = 9;
    try {
        ArtemisExecutor.run(new Config("artemis-error").addVar("backEnd", "http://localhost:8080").setParallel(degree));
        fail();
    } catch (TestFailedException e) {
        assertEquals(degree / 2 + degree % 2, e.getNoOfErrors());
        assertEquals(degree, e.getDegree());
    } catch (Exception e) {
        log.error("test_error", e);
        fail();
    }
    app.stop();
}
Also used : Javalin(io.javalin.Javalin) TestFailedException(org.devocative.artemis.TestFailedException) Config(org.devocative.artemis.cfg.Config) TestFailedException(org.devocative.artemis.TestFailedException) Test(org.junit.jupiter.api.Test)

Example 8 with Javalin

use of io.javalin.Javalin in project Artemis by mbizhani.

the class TestArtemis method test_devMode_baseUrlViaConfig.

@Test
public void test_devMode_baseUrlViaConfig() {
    final String baseUrl = "http://localhost:7777";
    final Javalin app = Javalin.create().start(7777);
    configure(app);
    ArtemisExecutor.run(new Config().setDevMode(true).setConsoleLog(false).setBaseUrl(baseUrl).setBaseDir("src/test/resources").addVar("backEnd", baseUrl));
    app.stop();
}
Also used : Javalin(io.javalin.Javalin) Config(org.devocative.artemis.cfg.Config) Test(org.junit.jupiter.api.Test)

Example 9 with Javalin

use of io.javalin.Javalin in project Artemis by mbizhani.

the class TestArtemis method test_defaultConfig.

@Test
public void test_defaultConfig() {
    final Javalin app = Javalin.create().start(8080);
    configure(app);
    ArtemisExecutor.run(new Config().addVar("backEnd", "http://localhost:8080").setParallel(1));
    app.stop();
}
Also used : Javalin(io.javalin.Javalin) Config(org.devocative.artemis.cfg.Config) Test(org.junit.jupiter.api.Test)

Example 10 with Javalin

use of io.javalin.Javalin in project Artemis by mbizhani.

the class TestArtemis method test_devMode.

@Test
public void test_devMode() {
    final Javalin app = Javalin.create().start(8080);
    configure(app);
    final File memFile = new File(".artemis-devMode.memory.json");
    memFile.delete();
    try {
        ArtemisExecutor.run(new Config("artemis-devMode", "artemis").setDevMode(true).addVar("backEnd", "http://localhost:8080"));
        fail();
    } catch (TestFailedException e) {
        assertEquals("Reached Break Point!", e.getMessage());
        assertTrue(memFile.exists());
    } catch (Exception e) {
        log.error("test_error", e);
        fail();
    }
    app.stop();
    memFile.delete();
}
Also used : Javalin(io.javalin.Javalin) TestFailedException(org.devocative.artemis.TestFailedException) Config(org.devocative.artemis.cfg.Config) File(java.io.File) TestFailedException(org.devocative.artemis.TestFailedException) Test(org.junit.jupiter.api.Test)

Aggregations

Javalin (io.javalin.Javalin)47 Test (org.junit.jupiter.api.Test)9 ApiBuilder.get (io.javalin.apibuilder.ApiBuilder.get)4 Context (io.javalin.http.Context)4 Config (org.devocative.artemis.cfg.Config)4 Server (org.eclipse.jetty.server.Server)4 OpenApiPlugin (io.javalin.plugin.openapi.OpenApiPlugin)3 Info (io.swagger.v3.oas.models.info.Info)3 Map (java.util.Map)3 HttpServletRequest (javax.servlet.http.HttpServletRequest)3 HttpServletResponse (javax.servlet.http.HttpServletResponse)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 Context (io.javalin.Context)2 Handler (io.javalin.Handler)2 ApiBuilder.path (io.javalin.apibuilder.ApiBuilder.path)2 Plugin (io.javalin.core.plugin.Plugin)2 ExceptionHandler (io.javalin.http.ExceptionHandler)2 Handler (io.javalin.http.Handler)2 HandlerEntry (io.javalin.http.HandlerEntry)2 HandlerType (io.javalin.http.HandlerType)2