@Test public void testSimpleServlet() throws IOException { SimpleWebServer server = new SimpleWebServer(9999); server.addServlet(new HelloWorldServlet(), "/test"); server.start(); String result = readURL("http://127.0.0.1:9999/test"); server.stop(); Assert.assertEquals("Hello world!\n", result); }
@Ignore @Test public void testSimpleServletPost() throws IOException { SimpleWebServer server = new SimpleWebServer(9876); server.addServlet(new HelloWorldServlet(), "/test"); server.start(); String result = readURL("http://localhost:9876/test"); postToURL("http://localhost:9876/test", "switch=true&"); String result2 = readURL("http://localhost:9876/test"); server.stop(); Assert.assertEquals("Hello world!\n", result); Assert.assertEquals("Goodbye world!\n", result2); }