8065222: sun/net/www/protocol/http/B6369510.java doesn't execute as expected
authormsheppar
Sat, 22 Nov 2014 14:56:16 +0000
changeset 27752 3f181f406145
parent 27751 e81623e39d23
child 27753 a6c284fa0745
8065222: sun/net/www/protocol/http/B6369510.java doesn't execute as expected Summary: changed address.getHostName() to InetAddress.getLocalHost().getHostName() in URL construction in test's doClient method Reviewed-by: chegar
jdk/test/sun/net/www/protocol/http/B6369510.java
--- a/jdk/test/sun/net/www/protocol/http/B6369510.java	Fri Nov 21 16:30:02 2014 -0800
+++ b/jdk/test/sun/net/www/protocol/http/B6369510.java	Sat Nov 22 14:56:16 2014 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -40,7 +40,7 @@
     com.sun.net.httpserver.HttpServer httpServer;
     ExecutorService executorService;
 
-    public static void main(String[] args)
+    public static void main(String[] args) throws Exception
     {
         new B6369510();
     }
@@ -58,13 +58,15 @@
     void doClient() {
         try {
             InetSocketAddress address = httpServer.getAddress();
+            String urlString = "http://" + InetAddress.getLocalHost().getHostName() + ":" + address.getPort() + "/test/";
+            System.out.println("URL == " + urlString);
 
             // GET Request
-            URL url = new URL("http://" + address.getHostName() + ":" + address.getPort() + "/test/");
+            URL url = new URL("http://" + InetAddress.getLocalHost().getHostName() + ":" + address.getPort() + "/test/");
             HttpURLConnection uc = (HttpURLConnection)url.openConnection();
             int resp = uc.getResponseCode();
             if (resp != 200)
-                throw new RuntimeException("Failed: Response code from GET is not 200");
+                throw new RuntimeException("Failed: Response code from GET is not 200 RSP == " + resp);
 
             System.out.println("Response code from GET = 200 OK");
 
@@ -75,12 +77,13 @@
             OutputStream os = uc.getOutputStream();
             resp = uc.getResponseCode();
             if (resp != 200)
-                throw new RuntimeException("Failed: Response code form POST is not 200");
+                throw new RuntimeException("Failed: Response code form POST is not 200 RSP == " + resp);
 
             System.out.println("Response code from POST = 200 OK");
 
         } catch (IOException e) {
             e.printStackTrace();
+            throw new RuntimeException("Failed with IOException");
         } finally {
             httpServer.stop(1);
             executorService.shutdown();