Package restx.server

Examples of restx.server.WebServer


    public static final String WEB_INF_LOCATION = "src/main/webapp/WEB-INF/web.xml";
    public static final String WEB_APP_LOCATION = "src/main/webapp";

    public static void main(String[] args) throws Exception {
        int port = Integer.valueOf(Optional.fromNullable(System.getenv("PORT")).or("{{defaultPort}}"));
        WebServer server = new JettyWebServer(WEB_INF_LOCATION, WEB_APP_LOCATION, port, "0.0.0.0");

        /*
         * load mode from system property if defined, or default to dev
         * be careful with that setting, if you use this class to launch your server in production, make sure to launch
         * it with -Drestx.mode=prod or change the default here
         */
        System.setProperty("restx.mode", System.getProperty("restx.mode", "dev"));
        System.setProperty("restx.app.package", "{{mainPackage}}");

        server.startAndAwait();
    }
View Full Code Here


* Time: 14:18
*/
public class AppServer {
    public static void main(String[] args) throws Exception {
        int port = Integer.valueOf(Optional.fromNullable(System.getenv("PORT")).or("8080"));
        WebServer server = SimpleWebServer.builder().setRouterPath("/api").setPort(port).build();

        /*
         * load mode from system property if defined, or default to dev
         * be careful with that setting, if you use this class to launch your server in production, make sure to launch
         * it with -Drestx.mode=prod or change the default here
         */
        System.setProperty("restx.mode", System.getProperty("restx.mode", "dev"));

        server.startAndAwait();
    }
View Full Code Here

        this.factory = factory;
    }

    public RunningServer start() throws Exception {
        System.setProperty("restx.mode", RestxContext.Modes.INFINIREST);
        WebServer server = webServerSupplier.newWebServer(port);
        server.start();
        RestxSpecLoader specLoader = new RestxSpecLoader(factory);
        RestxSpecRunner runner = new RestxSpecRunner(specLoader, routerPath, server.getServerId(), server.baseUrl(), factory);
        RestxSpecRepository repository = new HotReloadRestxSpecRepository(specLoader);

        final RunningServer runningServer = new RunningServer(
                server, runner, repository,
                factory.getComponent(UUIDGenerator.class),
                factory.getComponent(RestxErrors.class),
                factory.getComponent(RunningServerSettings.class));

        Factory.getFactory(server.getServerId()).get().getComponent(EventBus.class).register(new Object() {
            @Subscribe
            public void onCompilationFinished(
                    CompilationFinishedEvent event) {
                runningServer.submitTestRequest(new TestRequest().setTest("specs/*"));
            }
View Full Code Here

* Time: 12:24 PM
*/
public class SpecsServerTest {
    @Test
    public void should_use_spec() throws Exception {
        WebServer server = SpecsServer.getServer(WebServers.findAvailablePort(), "/api", ".");
        server.start();
        try {
            HttpRequest httpRequest = HttpRequest.get(server.baseUrl() + "/api/message?who=xavier");

            assertThat(httpRequest.code()).isEqualTo(200);
            assertThat(httpRequest.body().trim()).isEqualTo("{\"message\":\"hello xavier, it's 14:33:18\"}");
        } finally {
            server.stop();
        }

    }
View Full Code Here

TOP

Related Classes of restx.server.WebServer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.