|
|
|
@ -16,7 +16,9 @@
@@ -16,7 +16,9 @@
|
|
|
|
|
|
|
|
|
|
package org.springframework.cloud.openfeign; |
|
|
|
|
|
|
|
|
|
import java.io.IOException; |
|
|
|
|
import java.lang.reflect.Type; |
|
|
|
|
import java.net.SocketTimeoutException; |
|
|
|
|
import java.util.Collections; |
|
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
|
@ -78,6 +80,8 @@ public class FeignClientUsingPropertiesTests {
@@ -78,6 +80,8 @@ public class FeignClientUsingPropertiesTests {
|
|
|
|
|
|
|
|
|
|
private FeignClientFactoryBean barFactoryBean; |
|
|
|
|
|
|
|
|
|
private FeignClientFactoryBean unwrapFactoryBean; |
|
|
|
|
|
|
|
|
|
private FeignClientFactoryBean formFactoryBean; |
|
|
|
|
|
|
|
|
|
public FeignClientUsingPropertiesTests() { |
|
|
|
@ -89,6 +93,10 @@ public class FeignClientUsingPropertiesTests {
@@ -89,6 +93,10 @@ public class FeignClientUsingPropertiesTests {
|
|
|
|
|
this.barFactoryBean.setContextId("bar"); |
|
|
|
|
this.barFactoryBean.setType(FeignClientFactoryBean.class); |
|
|
|
|
|
|
|
|
|
this.unwrapFactoryBean = new FeignClientFactoryBean(); |
|
|
|
|
this.unwrapFactoryBean.setContextId("unwrap"); |
|
|
|
|
this.unwrapFactoryBean.setType(FeignClientFactoryBean.class); |
|
|
|
|
|
|
|
|
|
this.formFactoryBean = new FeignClientFactoryBean(); |
|
|
|
|
this.formFactoryBean.setContextId("form"); |
|
|
|
|
this.formFactoryBean.setType(FeignClientFactoryBean.class); |
|
|
|
@ -106,6 +114,12 @@ public class FeignClientUsingPropertiesTests {
@@ -106,6 +114,12 @@ public class FeignClientUsingPropertiesTests {
|
|
|
|
|
"http://localhost:" + this.port); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public UnwrapClient unwrapClient() { |
|
|
|
|
this.unwrapFactoryBean.setApplicationContext(this.applicationContext); |
|
|
|
|
return this.unwrapFactoryBean.feign(this.context).target(UnwrapClient.class, |
|
|
|
|
"http://localhost:" + this.port); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public FormClient formClient() { |
|
|
|
|
this.formFactoryBean.setApplicationContext(this.applicationContext); |
|
|
|
|
return this.formFactoryBean.feign(this.context).target(FormClient.class, |
|
|
|
@ -124,6 +138,12 @@ public class FeignClientUsingPropertiesTests {
@@ -124,6 +138,12 @@ public class FeignClientUsingPropertiesTests {
|
|
|
|
|
fail("it should timeout"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test(expected = SocketTimeoutException.class) |
|
|
|
|
public void testUnwrap() throws Exception { |
|
|
|
|
unwrapClient().unwrap(); |
|
|
|
|
fail("it should timeout"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void testForm() { |
|
|
|
|
Map<String, String> request = Collections.singletonMap("form", "Data"); |
|
|
|
@ -145,6 +165,13 @@ public class FeignClientUsingPropertiesTests {
@@ -145,6 +165,13 @@ public class FeignClientUsingPropertiesTests {
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
protected interface UnwrapClient { |
|
|
|
|
|
|
|
|
|
@RequestMapping(method = RequestMethod.GET, value = "/bar") // intentionally /bar
|
|
|
|
|
String unwrap() throws IOException; |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
protected interface FormClient { |
|
|
|
|
|
|
|
|
|
@RequestMapping(value = "/form", method = RequestMethod.POST, |
|
|
|
|