hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r721833 - in /httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http: client/protocol/TestRedirects.java localserver/LocalTestServer.java
Date Sun, 30 Nov 2008 15:49:04 GMT
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



Mime
View raw message