|
29 | 29 |
|
30 | 30 | import static org.hamcrest.MatcherAssert.assertThat; |
31 | 31 |
|
| 32 | +import java.net.InetAddress; |
32 | 33 | import java.net.URI; |
33 | 34 |
|
| 35 | +import org.apache.hc.client5.http.impl.DefaultSchemePortResolver; |
34 | 36 | import org.apache.hc.client5.http.routing.RoutingSupport; |
35 | 37 | import org.apache.hc.core5.http.HttpHost; |
36 | 38 | import org.apache.hc.core5.http.HttpRequest; |
@@ -62,4 +64,24 @@ public void testDetermineHostMissingScheme() throws Exception { |
62 | 64 | RoutingSupport.determineHost(request1)); |
63 | 65 | } |
64 | 66 |
|
| 67 | + @Test |
| 68 | + public void testNormalizeHost() throws Exception { |
| 69 | + Assertions.assertEquals(new HttpHost("http", "somehost", 80), |
| 70 | + RoutingSupport.normalize( |
| 71 | + new HttpHost("http", "somehost", -1), |
| 72 | + DefaultSchemePortResolver.INSTANCE)); |
| 73 | + Assertions.assertEquals(new HttpHost("https", "somehost", 443), |
| 74 | + RoutingSupport.normalize( |
| 75 | + new HttpHost("https", "somehost", -1), |
| 76 | + DefaultSchemePortResolver.INSTANCE)); |
| 77 | + Assertions.assertEquals(new HttpHost("http", InetAddress.getLocalHost(), "localhost", 80), |
| 78 | + RoutingSupport.normalize( |
| 79 | + new HttpHost("http", InetAddress.getLocalHost(), "localhost", -1), |
| 80 | + DefaultSchemePortResolver.INSTANCE)); |
| 81 | + Assertions.assertEquals(new HttpHost("http", "somehost", 8080), |
| 82 | + RoutingSupport.normalize( |
| 83 | + new HttpHost("http", "somehost", 8080), |
| 84 | + DefaultSchemePortResolver.INSTANCE)); |
| 85 | + } |
| 86 | + |
65 | 87 | } |
0 commit comments