コード例 #1
0
 /**
  * If the server is non null, stop it
  *
  * @param server to stop
  * @throws Exception on any failure
  */
 public static void stop(HttpServer2 server) throws Exception {
   if (server != null) {
     server.stop();
   }
 }
コード例 #2
0
 /**
  * Pass in a server, return a URL bound to localhost and its port
  *
  * @param server server
  * @return a URL bonded to the base of the server
  * @throws MalformedURLException if the URL cannot be created.
  */
 public static URL getServerURL(HttpServer2 server) throws MalformedURLException {
   assertNotNull("No server", server);
   return new URL("http://" + NetUtils.getHostPortString(server.getConnectorAddress(0)));
 }
コード例 #3
0
 /**
  * Create and start a server with the test webapp
  *
  * @return the newly started server
  * @throws IOException on any failure
  * @throws AssertionError if a condition was not met
  */
 public static HttpServer2 createAndStartTestServer() throws IOException {
   HttpServer2 server = createTestServer();
   server.start();
   return server;
 }