@ -16,7 +16,8 @@
@@ -16,7 +16,8 @@
package org.springframework.cloud.netflix.feign.valid ;
import static org.hamcrest.Matchers.* ;
import static org.hamcrest.Matchers.instanceOf ;
import static org.hamcrest.Matchers.is ;
import static org.junit.Assert.assertEquals ;
import static org.junit.Assert.assertNotNull ;
import static org.junit.Assert.assertThat ;
@ -65,6 +66,7 @@ import feign.RequestTemplate;
@@ -65,6 +66,7 @@ import feign.RequestTemplate;
/ * *
* @author Spencer Gibb
* @author Jakub Narloch
* /
@RunWith ( SpringJUnit4ClassRunner . class )
@SpringApplicationConfiguration ( classes = FeignClientTests . Application . class )
@ -80,6 +82,9 @@ public class FeignClientTests {
@@ -80,6 +82,9 @@ public class FeignClientTests {
@Autowired
private TestClient testClient ;
@Autowired
private TestClientServiceId testClientServiceId ;
@Autowired
private Client feignClient ;
@ -99,6 +104,12 @@ public class FeignClientTests {
@@ -99,6 +104,12 @@ public class FeignClientTests {
public List < String > getHelloHeaders ( ) ;
}
@FeignClient ( serviceId = "localapp" )
protected static interface TestClientServiceId {
@RequestMapping ( method = RequestMethod . GET , value = "/hello" )
public Hello getHello ( ) ;
}
@Configuration
@EnableAutoConfiguration
@RestController
@ -210,6 +221,14 @@ public class FeignClientTests {
@@ -210,6 +221,14 @@ public class FeignClientTests {
assertThat ( delegate , is ( instanceOf ( feign . Client . Default . class ) ) ) ;
}
@Test
public void testServiceId ( ) {
assertNotNull ( "testClientServiceId was null" , testClientServiceId ) ;
final Hello hello = testClientServiceId . getHello ( ) ;
assertNotNull ( "The hello response was null" , hello ) ;
assertEquals ( "first hello didn't match" , new Hello ( "hello world 1" ) , hello ) ;
}
@Data
@AllArgsConstructor
@NoArgsConstructor