You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2008/11/30 16:49:04 UTC

svn commit: r721833 - in /httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http: client/protocol/TestRedirects.java localserver/LocalTestServer.java

Author: olegk
Date: Sun Nov 30 07:49:04 2008
New Revision: 721833

URL: http://svn.apache.org/viewvc?rev=721833&view=rev
Log:
Fixed test case failing on MS Vista

Modified:
    httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/client/protocol/TestRedirects.java
    httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/localserver/LocalTestServer.java

Modified: httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/client/protocol/TestRedirects.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/client/protocol/TestRedirects.java?rev=721833&r1=721832&r2=721833&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/client/protocol/TestRedirects.java (original)
+++ httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/client/protocol/TestRedirects.java Sun Nov 30 07:49:04 2008
@@ -476,7 +476,7 @@
 
     public void testRelativeRedirect() throws Exception {
         int port = this.localServer.getServicePort();
-        String host = "localhost";
+        String host = this.localServer.getServiceHostName();
         this.localServer.register("*", new RelativeRedirectService());
 
         DefaultHttpClient client = new DefaultHttpClient(); 
@@ -505,7 +505,7 @@
 
     public void testRelativeRedirect2() throws Exception {
         int port = this.localServer.getServicePort();
-        String host = "localhost";
+        String host = this.localServer.getServiceHostName();
         this.localServer.register("*", new RelativeRedirectService2());
 
         DefaultHttpClient client = new DefaultHttpClient(); 

Modified: httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/localserver/LocalTestServer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/localserver/LocalTestServer.java?rev=721833&r1=721832&r2=721833&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/localserver/LocalTestServer.java (original)
+++ httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/localserver/LocalTestServer.java Sun Nov 30 07:49:04 2008
@@ -291,6 +291,20 @@
 
 
     /**
+     * Obtains the hostname of the server.
+     *
+     * @return  the hostname
+     */
+    public String getServiceHostName() {
+        ServerSocket ssock = servicedSocket; // avoid synchronization
+        if (ssock == null)
+            throw new IllegalStateException("not running");
+
+        return ((InetSocketAddress) ssock.getLocalSocketAddress()).getHostName();
+    }
+
+
+    /**
      * Obtains the local address the server is listening on
      *  
      * @return the service address