@ -54,6 +54,50 @@ public class FeignBuilderTest {
@@ -54,6 +54,50 @@ public class FeignBuilderTest {
. hasBody ( "request data" ) ;
}
@Test
public void testUrlPathConcatUrlTrailingSlash ( ) throws Exception {
server . enqueue ( new MockResponse ( ) . setBody ( "response data" ) ) ;
String url = "http://localhost:" + server . getPort ( ) + "/" ;
TestInterface api = Feign . builder ( ) . target ( TestInterface . class , url ) ;
api . codecPost ( "request data" ) ;
assertThat ( server . takeRequest ( ) ) . hasPath ( "/" ) ;
}
@Test
public void testUrlPathConcatNoPathOnRequestLine ( ) throws Exception {
server . enqueue ( new MockResponse ( ) . setBody ( "response data" ) ) ;
String url = "http://localhost:" + server . getPort ( ) + "/" ;
TestInterface api = Feign . builder ( ) . target ( TestInterface . class , url ) ;
api . getNoPath ( ) ;
assertThat ( server . takeRequest ( ) ) . hasPath ( "/" ) ;
}
@Test
public void testUrlPathConcatNoInitialSlashOnPath ( ) throws Exception {
server . enqueue ( new MockResponse ( ) . setBody ( "response data" ) ) ;
String url = "http://localhost:" + server . getPort ( ) + "/" ;
TestInterface api = Feign . builder ( ) . target ( TestInterface . class , url ) ;
api . getNoInitialSlashOnSlash ( ) ;
assertThat ( server . takeRequest ( ) ) . hasPath ( "/api/thing" ) ;
}
@Test
public void testUrlPathConcatNoInitialSlashOnPathNoTrailingSlashOnUrl ( ) throws Exception {
server . enqueue ( new MockResponse ( ) . setBody ( "response data" ) ) ;
String url = "http://localhost:" + server . getPort ( ) ;
TestInterface api = Feign . builder ( ) . target ( TestInterface . class , url ) ;
api . getNoInitialSlashOnSlash ( ) ;
assertThat ( server . takeRequest ( ) ) . hasPath ( "/api/thing" ) ;
}
@Test
public void testOverrideEncoder ( ) throws Exception {
server . enqueue ( new MockResponse ( ) . setBody ( "response data" ) ) ;
@ -143,6 +187,11 @@ public class FeignBuilderTest {
@@ -143,6 +187,11 @@ public class FeignBuilderTest {
}
interface TestInterface {
@RequestLine ( "GET" )
Response getNoPath ( ) ;
@RequestLine ( "GET api/thing" )
Response getNoInitialSlashOnSlash ( ) ;
@RequestLine ( "POST /" )
Response codecPost ( String data ) ;