@@ -54,6 +54,50 @@ public void testDefaults() throws Exception {
5454 .hasBody ("request data" );
5555 }
5656
57+ @ Test
58+ public void testUrlPathConcatUrlTrailingSlash () throws Exception {
59+ server .enqueue (new MockResponse ().setBody ("response data" ));
60+
61+ String url = "http://localhost:" + server .getPort () + "/" ;
62+ TestInterface api = Feign .builder ().target (TestInterface .class , url );
63+
64+ api .codecPost ("request data" );
65+ assertThat (server .takeRequest ()).hasPath ("/" );
66+ }
67+
68+ @ Test
69+ public void testUrlPathConcatNoPathOnRequestLine () throws Exception {
70+ server .enqueue (new MockResponse ().setBody ("response data" ));
71+
72+ String url = "http://localhost:" + server .getPort () + "/" ;
73+ TestInterface api = Feign .builder ().target (TestInterface .class , url );
74+
75+ api .getNoPath ();
76+ assertThat (server .takeRequest ()).hasPath ("/" );
77+ }
78+
79+ @ Test
80+ public void testUrlPathConcatNoInitialSlashOnPath () throws Exception {
81+ server .enqueue (new MockResponse ().setBody ("response data" ));
82+
83+ String url = "http://localhost:" + server .getPort () + "/" ;
84+ TestInterface api = Feign .builder ().target (TestInterface .class , url );
85+
86+ api .getNoInitialSlashOnSlash ();
87+ assertThat (server .takeRequest ()).hasPath ("/api/thing" );
88+ }
89+
90+ @ Test
91+ public void testUrlPathConcatNoInitialSlashOnPathNoTrailingSlashOnUrl () throws Exception {
92+ server .enqueue (new MockResponse ().setBody ("response data" ));
93+
94+ String url = "http://localhost:" + server .getPort ();
95+ TestInterface api = Feign .builder ().target (TestInterface .class , url );
96+
97+ api .getNoInitialSlashOnSlash ();
98+ assertThat (server .takeRequest ()).hasPath ("/api/thing" );
99+ }
100+
57101 @ Test
58102 public void testOverrideEncoder () throws Exception {
59103 server .enqueue (new MockResponse ().setBody ("response data" ));
@@ -143,6 +187,11 @@ public InvocationHandler create(Target target, Map<Method, MethodHandler> dispat
143187 }
144188
145189 interface TestInterface {
190+ @ RequestLine ("GET" )
191+ Response getNoPath ();
192+
193+ @ RequestLine ("GET api/thing" )
194+ Response getNoInitialSlashOnSlash ();
146195
147196 @ RequestLine ("POST /" )
148197 Response codecPost (String data );
0 commit comments