Package org.webbitserver

Examples of org.webbitserver.WebServer.stop()


    @Test
    public void stopsServerCleanlyNotLeavingResourcesHanging() throws Exception {
        int threadCountStart = getCurrentThreadCount();
        WebServer server = new NettyWebServer(Executors.newSingleThreadScheduledExecutor(), 9080).start();
        assertEquals(threadCountStart+1, getCurrentThreadCount());
        server.stop().join();
        assertEquals(threadCountStart, getCurrentThreadCount());
    }

    // Failing test for https://github.com/joewalnes/webbit/issues/29
    @Test
View Full Code Here


        final WebServer server = new NettyWebServer(Executors.newSingleThreadScheduledExecutor(), 9080).start();
        server.add(new HttpHandler() {
            @Override
            public void handleHttpRequest(HttpRequest request, HttpResponse response, HttpControl control) throws Exception {
                System.out.println("We got here");
                server.stop().join();
                System.out.println("But never here");
                stopper.countDown();
            }
        });
        Socket client = new Socket(InetAddress.getLocalHost(), 9080);
View Full Code Here

        try {
            assertEquals("Hello world", contents(httpGet(webServer, "/index.html")));
            assertEquals("some js", contents(httpGet(webServer, "/foo.js?xx=y")));
            assertEquals("some txt", contents(httpGet(webServer, "/some/dir/content1.txt")));
        } finally {
            webServer.stop().join();
        }
    }

    // --- Test helpers
View Full Code Here

        try {
            URLConnection urlConnection = httpGet(webServer, "/");
            assertEquals("My Server", urlConnection.getHeaderField("Server"));
            assertEquals("body", contents(urlConnection));
        } finally {
            webServer.stop().join();
        }
    }

    @Test
    public void canBeOverriddenByOtherHandlers() throws IOException, InterruptedException {
View Full Code Here

        try {
            URLConnection urlConnection = httpGet(webServer, "/");
            assertEquals("No actually, this is My Server", urlConnection.getHeaderField("Server"));
            assertEquals("body", contents(urlConnection));
        } finally {
            webServer.stop().join();
        }
    }

    @Test
    public void canBeClearedByOtherHandlers() throws IOException, InterruptedException {
View Full Code Here

        try {
            URLConnection urlConnection = httpGet(webServer, "/");
            assertFalse(urlConnection.getHeaderFields().containsKey("Server"));
            assertEquals("body", contents(urlConnection));
        } finally {
            webServer.stop().join();
        }
    }
}
View Full Code Here

            client.close();

            assertEquals(getPolicyFile("59504"), result);

        } finally {
            webServer.stop().get();
        }
    }

    @Test
    public void returnsCrossDomainXMLWithPublicPort() throws IOException, InterruptedException, ExecutionException {
View Full Code Here

            client.close();

            assertEquals(getPolicyFile("800"), result);

        } finally {
            webServer.stop().get();
        }
    }

    @Test
    public void returnsCrossDomainXMLWithDefaultHTTPPublicPort() throws IOException, InterruptedException, ExecutionException {
View Full Code Here

            client.close();

            assertEquals(getPolicyFile("80"), result);

        } finally {
            webServer.stop().get();
        }
    }

    @Test
    public void returnsCrossDomainXMLWithDefaultHTTPSPublicPort() throws IOException, InterruptedException, ExecutionException {
View Full Code Here

            client.close();

            assertEquals(getPolicyFile("443"), result);

        } finally {
            webServer.stop().get();
        }
    }

    private String getPolicyFile(String port) {
        String policyFile = "<?xml version=\"1.0\"?>\r\n"
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.