Example #1
0
 public static void main(String[] args) throws Exception {
   MyAuthenticator auth = new MyAuthenticator();
   Authenticator.setDefault(auth);
   try {
     server = new HttpServer(new AuthHeaderTest(), 1, 10, 0);
     System.out.println("Server: listening on port: " + server.getLocalPort());
     client("http://localhost:" + server.getLocalPort() + "/d1/foo.html");
   } catch (Exception e) {
     if (server != null) {
       server.terminate();
     }
     throw e;
   }
   int f = auth.getCount();
   if (f != 1) {
     except("Authenticator was called " + f + " times. Should be 1");
   }
   server.terminate();
 }
Example #2
0
 public static void except(String s) {
   server.terminate();
   throw new RuntimeException(s);
 }