Restores ignored tests.
fixes gh-280
This commit is contained in:
@@ -38,7 +38,6 @@ import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingClass;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.cloud.client.actuator.HasFeatures;
|
||||
@@ -95,7 +94,6 @@ public class FeignAutoConfiguration {
|
||||
// for load balanced ribbon clients.
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@ConditionalOnClass(ApacheHttpClient.class)
|
||||
@ConditionalOnMissingClass("com.netflix.loadbalancer.ILoadBalancer")
|
||||
@ConditionalOnMissingBean(CloseableHttpClient.class)
|
||||
@ConditionalOnProperty(value = "feign.httpclient.enabled", matchIfMissing = true)
|
||||
protected static class HttpClientFeignConfiguration {
|
||||
@@ -161,7 +159,6 @@ public class FeignAutoConfiguration {
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@ConditionalOnClass(OkHttpClient.class)
|
||||
@ConditionalOnMissingClass("com.netflix.loadbalancer.ILoadBalancer")
|
||||
@ConditionalOnMissingBean(okhttp3.OkHttpClient.class)
|
||||
@ConditionalOnProperty("feign.okhttp.enabled")
|
||||
protected static class OkHttpFeignConfiguration {
|
||||
|
||||
@@ -28,7 +28,7 @@ import org.springframework.core.annotation.AliasFor;
|
||||
* Annotation for interfaces declaring that a REST client with that interface should be
|
||||
* created (e.g. for autowiring into another component). If ribbon is available it will be
|
||||
* used to load balance the backend requests, and the load balancer can be configured
|
||||
* using a <code>@RibbonClient</code> with the same name (i.e. value) as the feign client.
|
||||
* using the same name (i.e. value) as the feign client.
|
||||
*
|
||||
* @author Spencer Gibb
|
||||
* @author Venil Noronha
|
||||
@@ -112,8 +112,7 @@ public @interface FeignClient {
|
||||
Class<?> fallbackFactory() default void.class;
|
||||
|
||||
/**
|
||||
* @return path prefix to be used by all method-level mappings. Can be used with or
|
||||
* without <code>@RibbonClient</code>.
|
||||
* @return path prefix to be used by all method-level mappings.
|
||||
*/
|
||||
String path() default "";
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@ package org.springframework.cloud.openfeign;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
@@ -69,7 +68,6 @@ public class DefaultGzipDecoderTests extends FeignClientFactoryBean {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore // FIXME: 3.0.0
|
||||
public void testBodyDecompress() {
|
||||
ResponseEntity<Hello> response = testClient().getGzipResponse();
|
||||
assertThat(response).as("response was null").isNotNull();
|
||||
@@ -82,7 +80,6 @@ public class DefaultGzipDecoderTests extends FeignClientFactoryBean {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore // FIXME: 3.0.0
|
||||
public void testNullBodyDecompress() {
|
||||
ResponseEntity<Hello> response = testClient().getNullResponse();
|
||||
assertThat(response).as("response was null").isNotNull();
|
||||
@@ -94,7 +91,6 @@ public class DefaultGzipDecoderTests extends FeignClientFactoryBean {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore // FIXME: 3.0.0
|
||||
public void testCharsetDecompress() {
|
||||
ResponseEntity<Hello> response = testClient().getUtf8Response();
|
||||
assertThat(response).as("response was null").isNotNull();
|
||||
|
||||
@@ -17,16 +17,14 @@
|
||||
package org.springframework.cloud.openfeign;
|
||||
|
||||
import feign.codec.Encoder;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.cloud.openfeign.support.PageableSpringEncoder;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
@@ -42,7 +40,6 @@ public class EnableFeignClientsSpringDataTests {
|
||||
private FeignContext feignContext;
|
||||
|
||||
@Test
|
||||
@Ignore // FIXME: 3.0.0
|
||||
public void encoderDefaultCorrect() {
|
||||
|
||||
PageableSpringEncoder.class
|
||||
@@ -50,7 +47,7 @@ public class EnableFeignClientsSpringDataTests {
|
||||
}
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@Import({ PropertyPlaceholderAutoConfiguration.class, FeignAutoConfiguration.class })
|
||||
@EnableAutoConfiguration
|
||||
protected static class PlainConfiguration {
|
||||
|
||||
}
|
||||
|
||||
@@ -26,7 +26,6 @@ import java.util.List;
|
||||
|
||||
import org.hamcrest.Matchers;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
@@ -124,12 +123,11 @@ public class FeignClientBuilderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore // FIXME: 3.0.0
|
||||
public void forType_allFieldsSetOnBuilder() {
|
||||
// when:
|
||||
final FeignClientBuilder.Builder builder = this.feignClientBuilder
|
||||
.forType(TestFeignClient.class, "TestClient").decode404(true).url("Url/")
|
||||
.contextId("TestContext");
|
||||
.path("/Path").contextId("TestContext");
|
||||
|
||||
// then:
|
||||
assertFactoryBeanField(builder, "applicationContext", this.applicationContext);
|
||||
|
||||
@@ -32,18 +32,16 @@ import feign.codec.ErrorDecoder;
|
||||
import feign.optionals.OptionalDecoder;
|
||||
import feign.querymap.BeanQueryMapEncoder;
|
||||
import feign.slf4j.Slf4jLogger;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.cloud.openfeign.support.PageableSpringEncoder;
|
||||
import org.springframework.cloud.openfeign.support.SpringMvcContract;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
@@ -69,42 +67,36 @@ public class FeignClientOverrideDefaultsTests {
|
||||
private BarClient bar;
|
||||
|
||||
@Test
|
||||
@Ignore // FIXME: 3.0.0
|
||||
public void clientsAvailable() {
|
||||
assertThat(this.foo).isNotNull();
|
||||
assertThat(this.bar).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore // FIXME: 3.0.0
|
||||
public void overrideDecoder() {
|
||||
Decoder.Default.class.cast(this.context.getInstance("foo", Decoder.class));
|
||||
OptionalDecoder.class.cast(this.context.getInstance("bar", Decoder.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore // FIXME: 3.0.0
|
||||
public void overrideEncoder() {
|
||||
Encoder.Default.class.cast(this.context.getInstance("foo", Encoder.class));
|
||||
PageableSpringEncoder.class.cast(this.context.getInstance("bar", Encoder.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore // FIXME: 3.0.0
|
||||
public void overrideLogger() {
|
||||
Logger.JavaLogger.class.cast(this.context.getInstance("foo", Logger.class));
|
||||
Slf4jLogger.class.cast(this.context.getInstance("bar", Logger.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore // FIXME: 3.0.0
|
||||
public void overrideContract() {
|
||||
Contract.Default.class.cast(this.context.getInstance("foo", Contract.class));
|
||||
SpringMvcContract.class.cast(this.context.getInstance("bar", Contract.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore // FIXME: 3.0.0
|
||||
public void overrideLoggerLevel() {
|
||||
assertThat(this.context.getInstance("foo", Logger.Level.class)).isNull();
|
||||
assertThat(this.context.getInstance("bar", Logger.Level.class))
|
||||
@@ -112,7 +104,6 @@ public class FeignClientOverrideDefaultsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore // FIXME: 3.0.0
|
||||
public void overrideRetryer() {
|
||||
assertThat(this.context.getInstance("foo", Retryer.class))
|
||||
.isEqualTo(Retryer.NEVER_RETRY);
|
||||
@@ -120,7 +111,6 @@ public class FeignClientOverrideDefaultsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore // FIXME: 3.0.0
|
||||
public void overrideErrorDecoder() {
|
||||
assertThat(this.context.getInstance("foo", ErrorDecoder.class)).isNull();
|
||||
ErrorDecoder.Default.class
|
||||
@@ -128,7 +118,6 @@ public class FeignClientOverrideDefaultsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore // FIXME: 3.0.0
|
||||
public void overrideRequestOptions() {
|
||||
assertThat(this.context.getInstance("foo", Request.Options.class)).isNull();
|
||||
Request.Options options = this.context.getInstance("bar", Request.Options.class);
|
||||
@@ -137,7 +126,6 @@ public class FeignClientOverrideDefaultsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore // FIXME: 3.0.0
|
||||
public void overrideQueryMapEncoder() {
|
||||
QueryMapEncoder.Default.class
|
||||
.cast(this.context.getInstance("foo", QueryMapEncoder.class));
|
||||
@@ -146,7 +134,6 @@ public class FeignClientOverrideDefaultsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore // FIXME: 3.0.0
|
||||
public void addRequestInterceptor() {
|
||||
assertThat(this.context.getInstances("foo", RequestInterceptor.class).size())
|
||||
.isEqualTo(1);
|
||||
@@ -155,7 +142,6 @@ public class FeignClientOverrideDefaultsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore // FIXME: 3.0.0
|
||||
public void exceptionPropagationPolicy() {
|
||||
assertThat(this.context.getInstances("foo", ExceptionPropagationPolicy.class))
|
||||
.isNull();
|
||||
@@ -183,7 +169,7 @@ public class FeignClientOverrideDefaultsTests {
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@EnableFeignClients(clients = { FooClient.class, BarClient.class })
|
||||
@Import({ PropertyPlaceholderAutoConfiguration.class, FeignAutoConfiguration.class })
|
||||
@EnableAutoConfiguration
|
||||
protected static class TestConfiguration {
|
||||
|
||||
@Bean
|
||||
|
||||
@@ -32,7 +32,6 @@ import feign.Retryer;
|
||||
import feign.codec.EncodeException;
|
||||
import feign.codec.Encoder;
|
||||
import feign.codec.ErrorDecoder;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
@@ -128,28 +127,24 @@ public class FeignClientUsingPropertiesTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore // FIXME: 3.0.0
|
||||
public void testFoo() {
|
||||
String response = fooClient().foo();
|
||||
assertThat(response).isEqualTo("OK");
|
||||
}
|
||||
|
||||
@Test(expected = RetryableException.class)
|
||||
@Ignore // FIXME: 3.0.0
|
||||
public void testBar() {
|
||||
barClient().bar();
|
||||
fail("it should timeout");
|
||||
}
|
||||
|
||||
@Test(expected = SocketTimeoutException.class)
|
||||
@Ignore // FIXME: 3.0.0
|
||||
public void testUnwrap() throws Exception {
|
||||
unwrapClient().unwrap();
|
||||
fail("it should timeout");
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore // FIXME: 3.0.0
|
||||
public void testForm() {
|
||||
Map<String, String> request = Collections.singletonMap("form", "Data");
|
||||
String response = formClient().form(request);
|
||||
|
||||
@@ -18,7 +18,6 @@ package org.springframework.cloud.openfeign;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
@@ -81,13 +80,11 @@ public class FeignClientsRegistrarTests {
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@Ignore // FIXME: 3.0.0
|
||||
public void testFallback() {
|
||||
new AnnotationConfigApplicationContext(FallbackTestConfig.class);
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@Ignore // FIXME: 3.0.0
|
||||
public void testFallbackFactory() {
|
||||
new AnnotationConfigApplicationContext(FallbackFactoryTestConfig.class);
|
||||
}
|
||||
|
||||
@@ -25,7 +25,6 @@ import feign.Target;
|
||||
import feign.httpclient.ApacheHttpClient;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
@@ -81,7 +80,6 @@ public class FeignHttpClientUrlTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore // FIXME: 3.0.0
|
||||
public void testUrlHttpClient() {
|
||||
assertThat(this.urlClient).as("UrlClient was null").isNotNull();
|
||||
Hello hello = this.urlClient.getHello();
|
||||
@@ -91,7 +89,6 @@ public class FeignHttpClientUrlTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore // FIXME: 3.0.0
|
||||
public void testBeanUrl() {
|
||||
Hello hello = this.beanClient.getHello();
|
||||
assertThat(hello).as("hello was null").isNotNull();
|
||||
@@ -100,7 +97,6 @@ public class FeignHttpClientUrlTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore // FIXME: 3.0.0
|
||||
public void testBeanUrlNoProtocol() {
|
||||
Hello hello = this.beanClientNoProtocol.getHello();
|
||||
assertThat(hello).as("hello was null").isNotNull();
|
||||
|
||||
@@ -21,15 +21,14 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
|
||||
import org.springframework.boot.web.server.LocalServerPort;
|
||||
import org.springframework.cloud.openfeign.test.NoSecurityConfiguration;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
@@ -57,7 +56,7 @@ public class SpringDecoderTests extends FeignClientFactoryBean {
|
||||
@Autowired
|
||||
FeignContext context;
|
||||
|
||||
@Value("${local.server.port}")
|
||||
@LocalServerPort
|
||||
private int port = 0;
|
||||
|
||||
public SpringDecoderTests() {
|
||||
@@ -77,7 +76,6 @@ public class SpringDecoderTests extends FeignClientFactoryBean {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore // FIXME: 3.0.0
|
||||
public void testResponseEntity() {
|
||||
ResponseEntity<Hello> response = testClient().getHelloResponse();
|
||||
assertThat(response).as("response was null").isNotNull();
|
||||
@@ -90,7 +88,6 @@ public class SpringDecoderTests extends FeignClientFactoryBean {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore // FIXME: 3.0.0
|
||||
public void testSimpleType() {
|
||||
Hello hello = testClient().getHello();
|
||||
assertThat(hello).as("hello was null").isNotNull();
|
||||
@@ -99,7 +96,6 @@ public class SpringDecoderTests extends FeignClientFactoryBean {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore // FIXME: 3.0.0
|
||||
public void testUserParameterizedTypeDecode() {
|
||||
List<Hello> hellos = testClient().getHellos();
|
||||
assertThat(hellos).as("hellos was null").isNotNull();
|
||||
@@ -109,7 +105,6 @@ public class SpringDecoderTests extends FeignClientFactoryBean {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore // FIXME: 3.0.0
|
||||
public void testSimpleParameterizedTypeDecode() {
|
||||
List<String> hellos = testClient().getHelloStrings();
|
||||
assertThat(hellos).as("hellos was null").isNotNull();
|
||||
@@ -119,7 +114,6 @@ public class SpringDecoderTests extends FeignClientFactoryBean {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore // FIXME: 3.0.0
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testWildcardTypeDecode() {
|
||||
ResponseEntity<?> wildcard = testClient().getWildcard();
|
||||
@@ -136,7 +130,6 @@ public class SpringDecoderTests extends FeignClientFactoryBean {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore // FIXME: 3.0.0
|
||||
public void testResponseEntityVoid() {
|
||||
ResponseEntity<Void> response = testClient().getHelloVoid();
|
||||
assertThat(response).as("response was null").isNotNull();
|
||||
@@ -148,13 +141,11 @@ public class SpringDecoderTests extends FeignClientFactoryBean {
|
||||
}
|
||||
|
||||
@Test(expected = RuntimeException.class)
|
||||
@Ignore // FIXME: 3.0.0
|
||||
public void test404() {
|
||||
testClient().getNotFound();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore // FIXME: 3.0.0
|
||||
public void testDecodes404() {
|
||||
final ResponseEntity<String> response = testClient(true).getNotFound();
|
||||
assertThat(response).as("response was null").isNotNull();
|
||||
|
||||
@@ -1,66 +0,0 @@
|
||||
/*
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.openfeign;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.boot.WebApplicationType;
|
||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||
import org.springframework.cloud.client.loadbalancer.LoadBalancerAutoConfiguration;
|
||||
import org.springframework.cloud.test.ClassPathExclusions;
|
||||
import org.springframework.cloud.test.ModifiedClassPathRunner;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
|
||||
/**
|
||||
* @author Ryan Baxter
|
||||
*/
|
||||
@RunWith(ModifiedClassPathRunner.class)
|
||||
@ClassPathExclusions({ "spring-retry-*.jar", "spring-boot-starter-aop-*.jar" })
|
||||
public class SpringRetryDisabledTests {
|
||||
|
||||
private ConfigurableApplicationContext context;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
this.context = new SpringApplicationBuilder().web(WebApplicationType.NONE)
|
||||
.sources(LoadBalancerAutoConfiguration.class).run();
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
if (this.context != null) {
|
||||
this.context.close();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLoadBalancedRetryFactoryBean() throws Exception {
|
||||
// FIXME: 3.0.0
|
||||
/*
|
||||
* Map<String, CachingSpringLoadBalancerFactory> lbFactorys = this.context
|
||||
* .getBeansOfType(CachingSpringLoadBalancerFactory.class);
|
||||
* assertThat(lbFactorys.values()).hasSize(1); FeignLoadBalancer lb =
|
||||
* lbFactorys.values().iterator().next().create("foo");
|
||||
* assertThat(lb).isInstanceOf(FeignLoadBalancer.class);
|
||||
* assertThat(lb).isNotInstanceOf(RetryableFeignLoadBalancer.class);
|
||||
*/
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
/*
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.openfeign;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.cloud.client.loadbalancer.LoadBalancerAutoConfiguration;
|
||||
import org.springframework.cloud.commons.httpclient.HttpClientConfiguration;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationContextAware;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
/**
|
||||
* @author Ryan Baxter
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(
|
||||
classes = { LoadBalancerAutoConfiguration.class, HttpClientConfiguration.class })
|
||||
public class SpringRetryEnabledTests implements ApplicationContextAware {
|
||||
|
||||
private ApplicationContext context;
|
||||
|
||||
@Test
|
||||
public void testLoadBalancedRetryFactoryBean() throws Exception {
|
||||
// FIXME: 3.0.0
|
||||
/*
|
||||
* Map<String, CachingSpringLoadBalancerFactory> lbFactorys = this.context
|
||||
* .getBeansOfType(CachingSpringLoadBalancerFactory.class);
|
||||
* assertThat(lbFactorys.values()).hasSize(1); FeignLoadBalancer lb =
|
||||
* lbFactorys.values().iterator().next().create("foo");
|
||||
* assertThat(lb).isInstanceOf(RetryableFeignLoadBalancer.class);
|
||||
*/
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setApplicationContext(ApplicationContext context) throws BeansException {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -38,6 +38,9 @@ import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
|
||||
import org.springframework.boot.web.server.LocalServerPort;
|
||||
import org.springframework.cloud.loadbalancer.annotation.LoadBalancerClient;
|
||||
import org.springframework.cloud.loadbalancer.core.ServiceInstanceListSupplier;
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.cloud.openfeign.FeignClientBuilder;
|
||||
@@ -45,6 +48,7 @@ import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.mock.web.MockMultipartFile;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
@@ -100,7 +104,6 @@ public class FeignClientTests {
|
||||
private MultipartClient multipartClient;
|
||||
|
||||
@Test
|
||||
@Ignore // FIXME: 3.0.0
|
||||
public void testAnnotations() {
|
||||
Map<String, Object> beans = this.context
|
||||
.getBeansWithAnnotation(FeignClient.class);
|
||||
@@ -109,7 +112,6 @@ public class FeignClientTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore // FIXME: 3.0.0
|
||||
public void testClient() {
|
||||
assertThat(this.testClient).as("testClient was null").isNotNull();
|
||||
assertThat(this.extraClient).as("extraClient was null").isNotNull();
|
||||
@@ -120,7 +122,6 @@ public class FeignClientTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore // FIXME: 3.0.0
|
||||
public void extraClient() {
|
||||
assertThat(this.extraClient).as("extraClient was null").isNotNull();
|
||||
assertThat(Proxy.isProxyClass(this.extraClient.getClass()))
|
||||
@@ -131,7 +132,6 @@ public class FeignClientTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore // FIXME: 3.0.0
|
||||
public void buildByBuilder() {
|
||||
assertThat(this.buildByBuilder).as("buildByBuilder was null").isNotNull();
|
||||
assertThat(Proxy.isProxyClass(this.buildByBuilder.getClass()))
|
||||
@@ -142,14 +142,14 @@ public class FeignClientTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore // FIXME: 3.0.0
|
||||
@Ignore // FIXME: multipart
|
||||
public void testSingleRequestPart() {
|
||||
String response = this.multipartClient.singlePart("abc");
|
||||
assertThat(response).isEqualTo("abc");
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore // FIXME: 3.0.0
|
||||
@Ignore // FIXME: multipart
|
||||
public void testMultipleRequestParts() {
|
||||
MockMultipartFile file = new MockMultipartFile("file", "hello.bin", null,
|
||||
"hello".getBytes());
|
||||
@@ -158,7 +158,7 @@ public class FeignClientTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore // FIXME: 3.0.0
|
||||
@Ignore // FIXME: multipart
|
||||
public void testRequestPartWithListOfMultipartFiles() {
|
||||
List<MultipartFile> multipartFiles = Arrays.asList(
|
||||
new MockMultipartFile("file1", "hello1.bin", null, "hello".getBytes()),
|
||||
@@ -172,7 +172,7 @@ public class FeignClientTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore // FIXME: 3.0.0
|
||||
@Ignore // FIXME: multipart
|
||||
public void testRequestBodyWithSingleMultipartFile() {
|
||||
String partName = UUID.randomUUID().toString();
|
||||
MockMultipartFile file1 = new MockMultipartFile(partName, "hello1.bin", null,
|
||||
@@ -182,7 +182,7 @@ public class FeignClientTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore // FIXME: 3.0.0
|
||||
@Ignore // FIXME: multipart
|
||||
public void testRequestBodyWithListOfMultipartFiles() {
|
||||
MockMultipartFile file1 = new MockMultipartFile("file1", "hello1.bin", null,
|
||||
"hello".getBytes());
|
||||
@@ -194,7 +194,7 @@ public class FeignClientTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore // FIXME: 3.0.0
|
||||
@Ignore // FIXME: multipart
|
||||
public void testRequestBodyWithMap() {
|
||||
MockMultipartFile file1 = new MockMultipartFile("file1", "hello1.bin", null,
|
||||
"hello".getBytes());
|
||||
@@ -209,7 +209,7 @@ public class FeignClientTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore // FIXME: 3.0.0
|
||||
@Ignore // FIXME: multipart
|
||||
public void testInvalidMultipartFile() {
|
||||
MockMultipartFile file = new MockMultipartFile("file1", "hello1.bin", null,
|
||||
"hello".getBytes());
|
||||
@@ -222,6 +222,8 @@ public class FeignClientTests {
|
||||
@RestController
|
||||
@EnableFeignClients
|
||||
@Import(FeignClientBuilder.class)
|
||||
@LoadBalancerClient(name = "localapp8",
|
||||
configuration = LocalLoadBalancerClientConfiguration.class)
|
||||
protected static class Application {
|
||||
|
||||
@Bean("build-by-builder")
|
||||
@@ -329,4 +331,19 @@ public class FeignClientTests {
|
||||
|
||||
}
|
||||
|
||||
// Load balancer with fixed server list for "local" pointing to localhost
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
public static class LocalLoadBalancerClientConfiguration {
|
||||
|
||||
@LocalServerPort
|
||||
private int port = 0;
|
||||
|
||||
@Bean
|
||||
public ServiceInstanceListSupplier staticServiceInstanceListSupplier(
|
||||
Environment env) {
|
||||
return ServiceInstanceListSupplier.fixed(env).instance(port, "local").build();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,20 +18,23 @@ package org.springframework.cloud.openfeign.encoding;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.web.server.LocalServerPort;
|
||||
import org.springframework.cloud.loadbalancer.annotation.LoadBalancerClient;
|
||||
import org.springframework.cloud.loadbalancer.core.ServiceInstanceListSupplier;
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
import org.springframework.cloud.openfeign.encoding.app.client.InvoiceClient;
|
||||
import org.springframework.cloud.openfeign.encoding.app.domain.Invoice;
|
||||
import org.springframework.cloud.openfeign.test.NoSecurityConfiguration;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
@@ -56,7 +59,6 @@ public class FeignAcceptEncodingTests {
|
||||
private InvoiceClient invoiceClient;
|
||||
|
||||
@Test
|
||||
@Ignore // FIXME 3.0.0
|
||||
public void compressedResponse() {
|
||||
|
||||
// when
|
||||
@@ -71,7 +73,7 @@ public class FeignAcceptEncodingTests {
|
||||
}
|
||||
|
||||
@EnableFeignClients(clients = InvoiceClient.class)
|
||||
// @RibbonClient(name = "local", configuration = LocalRibbonClientConfiguration.class)
|
||||
@LoadBalancerClient(name = "local", configuration = LocalClientConfiguration.class)
|
||||
@SpringBootApplication(
|
||||
scanBasePackages = "org.springframework.cloud.openfeign.encoding.app")
|
||||
@Import(NoSecurityConfiguration.class)
|
||||
@@ -80,16 +82,16 @@ public class FeignAcceptEncodingTests {
|
||||
}
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
static class LocalRibbonClientConfiguration {
|
||||
static class LocalClientConfiguration {
|
||||
|
||||
@Value("${local.server.port}")
|
||||
@LocalServerPort
|
||||
private int port = 0;
|
||||
|
||||
/*
|
||||
* @Bean public ILoadBalancer ribbonLoadBalancer() { BaseLoadBalancer balancer =
|
||||
* new BaseLoadBalancer(); balancer.setServersList( Collections.singletonList(new
|
||||
* Server("localhost", this.port))); return balancer; }
|
||||
*/
|
||||
@Bean
|
||||
public ServiceInstanceListSupplier staticServiceInstanceListSupplier(
|
||||
Environment env) {
|
||||
return ServiceInstanceListSupplier.fixed(env).instance(port, "local").build();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -18,20 +18,23 @@ package org.springframework.cloud.openfeign.encoding;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.web.server.LocalServerPort;
|
||||
import org.springframework.cloud.loadbalancer.annotation.LoadBalancerClient;
|
||||
import org.springframework.cloud.loadbalancer.core.ServiceInstanceListSupplier;
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
import org.springframework.cloud.openfeign.encoding.app.client.InvoiceClient;
|
||||
import org.springframework.cloud.openfeign.encoding.app.domain.Invoice;
|
||||
import org.springframework.cloud.openfeign.test.NoSecurityConfiguration;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
@@ -56,7 +59,6 @@ public class FeignContentEncodingTests {
|
||||
private InvoiceClient invoiceClient;
|
||||
|
||||
@Test
|
||||
@Ignore // FIXME 3.0.0
|
||||
public void compressedResponse() {
|
||||
|
||||
// given
|
||||
@@ -75,7 +77,7 @@ public class FeignContentEncodingTests {
|
||||
}
|
||||
|
||||
@EnableFeignClients(clients = InvoiceClient.class)
|
||||
// @RibbonClient(name = "local", configuration = LocalRibbonClientConfiguration.class)
|
||||
@LoadBalancerClient(name = "local", configuration = LocalClientConfiguration.class)
|
||||
@SpringBootApplication(
|
||||
scanBasePackages = "org.springframework.cloud.openfeign.encoding.app")
|
||||
@Import(NoSecurityConfiguration.class)
|
||||
@@ -84,16 +86,16 @@ public class FeignContentEncodingTests {
|
||||
}
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
static class LocalRibbonClientConfiguration {
|
||||
static class LocalClientConfiguration {
|
||||
|
||||
@Value("${local.server.port}")
|
||||
@LocalServerPort
|
||||
private int port = 0;
|
||||
|
||||
/*
|
||||
* @Bean public ILoadBalancer ribbonLoadBalancer() { BaseLoadBalancer balancer =
|
||||
* new BaseLoadBalancer(); balancer.setServersList( Collections.singletonList(new
|
||||
* Server("localhost", this.port))); return balancer; }
|
||||
*/
|
||||
@Bean
|
||||
public ServiceInstanceListSupplier staticServiceInstanceListSupplier(
|
||||
Environment env) {
|
||||
return ServiceInstanceListSupplier.fixed(env).instance(port, "local").build();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -16,22 +16,25 @@
|
||||
|
||||
package org.springframework.cloud.openfeign.encoding;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.autoconfigure.data.rest.RepositoryRestMvcAutoConfiguration;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.web.server.LocalServerPort;
|
||||
import org.springframework.cloud.loadbalancer.annotation.LoadBalancerClient;
|
||||
import org.springframework.cloud.loadbalancer.core.ServiceInstanceListSupplier;
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
import org.springframework.cloud.openfeign.FeignClientsConfiguration;
|
||||
import org.springframework.cloud.openfeign.encoding.app.client.InvoiceClient;
|
||||
import org.springframework.cloud.openfeign.encoding.app.domain.Invoice;
|
||||
import org.springframework.cloud.openfeign.test.NoSecurityConfiguration;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
@@ -61,7 +64,6 @@ public class FeignPageableEncodingTests {
|
||||
private InvoiceClient invoiceClient;
|
||||
|
||||
@Test
|
||||
@Ignore // FIXME 3.0.0
|
||||
public void testPageable() {
|
||||
|
||||
// given
|
||||
@@ -80,7 +82,7 @@ public class FeignPageableEncodingTests {
|
||||
}
|
||||
|
||||
@EnableFeignClients(clients = InvoiceClient.class)
|
||||
// @RibbonClient(name = "local", configuration = LocalRibbonClientConfiguration.class)
|
||||
@LoadBalancerClient(name = "local", configuration = LocalClientConfiguration.class)
|
||||
@SpringBootApplication(
|
||||
scanBasePackages = "org.springframework.cloud.openfeign.encoding.app",
|
||||
exclude = { RepositoryRestMvcAutoConfiguration.class })
|
||||
@@ -91,16 +93,16 @@ public class FeignPageableEncodingTests {
|
||||
}
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
static class LocalRibbonClientConfiguration {
|
||||
static class LocalClientConfiguration {
|
||||
|
||||
@Value("${local.server.port}")
|
||||
@LocalServerPort
|
||||
private int port = 0;
|
||||
|
||||
/*
|
||||
* @Bean public ILoadBalancer ribbonLoadBalancer() { BaseLoadBalancer balancer =
|
||||
* new BaseLoadBalancer(); balancer.setServersList( Collections.singletonList(new
|
||||
* Server("localhost", this.port))); return balancer; }
|
||||
*/
|
||||
@Bean
|
||||
public ServiceInstanceListSupplier staticServiceInstanceListSupplier(
|
||||
Environment env) {
|
||||
return ServiceInstanceListSupplier.fixed(env).instance(port, "local").build();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@ package org.springframework.cloud.openfeign.hateoas;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
@@ -52,7 +51,6 @@ public class FeignHalTests {
|
||||
private FeignHalClient feignHalClient;
|
||||
|
||||
@Test
|
||||
@Ignore // FIXME 3.0.0
|
||||
public void testEntityModel() {
|
||||
EntityModel<MarsRover> entity = feignHalClient.entity();
|
||||
assertThat(entity).isNotNull();
|
||||
@@ -68,7 +66,6 @@ public class FeignHalTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore // FIXME 3.0.0
|
||||
public void testCollectionModel() {
|
||||
CollectionModel<MarsRover> collectionModel = feignHalClient.collection();
|
||||
assertThat(collectionModel).isNotNull();
|
||||
@@ -89,7 +86,6 @@ public class FeignHalTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore // FIXME 3.0.0
|
||||
public void testPagedModel() {
|
||||
PagedModel<MarsRover> paged = feignHalClient.paged();
|
||||
assertThat(paged).isNotNull();
|
||||
|
||||
@@ -18,9 +18,14 @@ package org.springframework.cloud.openfeign.hateoas.app;
|
||||
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.autoconfigure.data.rest.RepositoryRestMvcAutoConfiguration;
|
||||
import org.springframework.boot.web.server.LocalServerPort;
|
||||
import org.springframework.cloud.loadbalancer.annotation.LoadBalancerClient;
|
||||
import org.springframework.cloud.loadbalancer.core.ServiceInstanceListSupplier;
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
import org.springframework.cloud.openfeign.test.NoSecurityConfiguration;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.core.env.Environment;
|
||||
|
||||
/**
|
||||
* Test HATEOAS application.
|
||||
@@ -31,7 +36,23 @@ import org.springframework.context.annotation.Import;
|
||||
@SpringBootApplication(
|
||||
scanBasePackages = "org.springframework.cloud.openfeign.hateoas.app",
|
||||
exclude = RepositoryRestMvcAutoConfiguration.class)
|
||||
@LoadBalancerClient(name = "local", configuration = LocalHalClientConfiguration.class)
|
||||
@Import(NoSecurityConfiguration.class)
|
||||
public class FeignHalApplication {
|
||||
|
||||
// Load balancer with fixed server list for "local" pointing to localhost
|
||||
|
||||
}
|
||||
|
||||
class LocalHalClientConfiguration {
|
||||
|
||||
@LocalServerPort
|
||||
private int port = 0;
|
||||
|
||||
@Bean
|
||||
public ServiceInstanceListSupplier staticServiceInstanceListSupplier(
|
||||
Environment env) {
|
||||
return ServiceInstanceListSupplier.fixed(env).instance(port, "local").build();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,6 +18,17 @@ package org.springframework.cloud.openfeign.loadbalancer;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import feign.Client;
|
||||
import feign.httpclient.ApacheHttpClient;
|
||||
import feign.okhttp.OkHttpClient;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.boot.WebApplicationType;
|
||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||
import org.springframework.cloud.commons.httpclient.HttpClientConfiguration;
|
||||
import org.springframework.cloud.loadbalancer.blocking.client.BlockingLoadBalancerClient;
|
||||
import org.springframework.cloud.loadbalancer.config.BlockingLoadBalancerClientAutoConfiguration;
|
||||
import org.springframework.cloud.loadbalancer.config.LoadBalancerAutoConfiguration;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
@@ -25,67 +36,54 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
/**
|
||||
* @author Olga Maciaszek-Sharma
|
||||
*/
|
||||
class FeignLoadBalancerAutoConfigurationTests {
|
||||
public class FeignLoadBalancerAutoConfigurationTests {
|
||||
|
||||
// FIXME: 3.0.0
|
||||
/*
|
||||
* @Test void
|
||||
* shouldInstantiateDefaultFeignBlockingLoadBalancerClientWhenHttpClientDisabled() {
|
||||
* ConfigurableApplicationContext context = initContext(
|
||||
* "spring.cloud.loadbalancer.ribbon.enabled=false",
|
||||
* "feign.httpclient.enabled=false"); assertThatOneBeanPresent(context,
|
||||
* BlockingLoadBalancerClient.class); assertLoadBalanced(context,
|
||||
* Client.Default.class); assertThatBeanNotPresent(context,
|
||||
* LoadBalancerFeignClient.class); }
|
||||
*
|
||||
* @Test void shouldInstantiateHttpFeignClientWhenEnabled() {
|
||||
* ConfigurableApplicationContext context = initContext(
|
||||
* "spring.cloud.loadbalancer.ribbon.enabled=false");
|
||||
* assertThatOneBeanPresent(context, BlockingLoadBalancerClient.class);
|
||||
* assertLoadBalanced(context, ApacheHttpClient.class);
|
||||
* assertThatBeanNotPresent(context, LoadBalancerFeignClient.class); }
|
||||
*
|
||||
* @Test void shouldInstantiateOkHttpFeignClientWhenEnabled() {
|
||||
* ConfigurableApplicationContext context = initContext(
|
||||
* "spring.cloud.loadbalancer.ribbon.enabled=false", "feign.httpclient.enabled=false",
|
||||
* "feign.okhttp.enabled=true"); assertThatOneBeanPresent(context,
|
||||
* BlockingLoadBalancerClient.class); assertLoadBalanced(context, OkHttpClient.class);
|
||||
* assertThatBeanNotPresent(context, LoadBalancerFeignClient.class); }
|
||||
*
|
||||
* @Test void shouldNotProcessLoadBalancerConfigurationWhenRibbonEnabled() {
|
||||
* ConfigurableApplicationContext context = initContext(
|
||||
* "spring.cloud.loadbalancer.ribbon.enabled=true"); assertThatOneBeanPresent(context,
|
||||
* LoadBalancerFeignClient.class); assertThatBeanNotPresent(context,
|
||||
* BlockingLoadBalancerClient.class); assertThatBeanNotPresent(context,
|
||||
* FeignBlockingLoadBalancerClient.class); }
|
||||
*
|
||||
* private ConfigurableApplicationContext initContext(String... properties) { return
|
||||
* new SpringApplicationBuilder().web(WebApplicationType.NONE) .properties(properties)
|
||||
* .sources(HttpClientConfiguration.class, RibbonAutoConfiguration.class,
|
||||
* LoadBalancerAutoConfiguration.class,
|
||||
* BlockingLoadBalancerClientAutoConfiguration.class,
|
||||
* FeignRibbonClientAutoConfiguration.class, FeignLoadBalancerAutoConfiguration.class)
|
||||
* .run(); }
|
||||
*/
|
||||
@Test
|
||||
public void shouldInstantiateDefaultFeignBlockingLoadBalancerClientWhenHttpClientDisabled() {
|
||||
ConfigurableApplicationContext context = initContext(
|
||||
"feign.httpclient.enabled=false");
|
||||
assertThatOneBeanPresent(context, BlockingLoadBalancerClient.class);
|
||||
assertLoadBalanced(context, Client.Default.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldInstantiateHttpFeignClientWhenEnabled() {
|
||||
ConfigurableApplicationContext context = initContext(
|
||||
"spring.cloud.loadbalancer.ribbon.enabled=false");
|
||||
assertThatOneBeanPresent(context, BlockingLoadBalancerClient.class);
|
||||
assertLoadBalanced(context, ApacheHttpClient.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldInstantiateOkHttpFeignClientWhenEnabled() {
|
||||
ConfigurableApplicationContext context = initContext(
|
||||
"feign.httpclient.enabled=false", "feign.okhttp.enabled=true");
|
||||
assertThatOneBeanPresent(context, BlockingLoadBalancerClient.class);
|
||||
assertLoadBalanced(context, OkHttpClient.class);
|
||||
}
|
||||
|
||||
private ConfigurableApplicationContext initContext(String... properties) {
|
||||
return new SpringApplicationBuilder().web(WebApplicationType.NONE)
|
||||
.properties(properties)
|
||||
.sources(HttpClientConfiguration.class,
|
||||
LoadBalancerAutoConfiguration.class,
|
||||
BlockingLoadBalancerClientAutoConfiguration.class,
|
||||
FeignLoadBalancerAutoConfiguration.class)
|
||||
.run();
|
||||
}
|
||||
|
||||
private void assertThatOneBeanPresent(ConfigurableApplicationContext context,
|
||||
Class<?> beanClass) {
|
||||
Map<String, ?> beans = context.getBeansOfType(beanClass);
|
||||
assertThat(beans).hasSize(1);
|
||||
assertThat(beans).as("Missing bean of type %s", beanClass).hasSize(1);
|
||||
}
|
||||
|
||||
private void assertLoadBalanced(ConfigurableApplicationContext context,
|
||||
Class delegateClass) {
|
||||
Map<String, FeignBlockingLoadBalancerClient> beans = context
|
||||
.getBeansOfType(FeignBlockingLoadBalancerClient.class);
|
||||
assertThat(beans).hasSize(1);
|
||||
assertThat(beans).as("Missing bean of type %s", delegateClass).hasSize(1);
|
||||
assertThat(beans.get("feignClient").getDelegate()).isInstanceOf(delegateClass);
|
||||
}
|
||||
|
||||
private void assertThatBeanNotPresent(ConfigurableApplicationContext context,
|
||||
Class<?> beanClass) {
|
||||
Map<String, ?> beans = context.getBeansOfType(beanClass);
|
||||
assertThat(beans).isEmpty();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ package org.springframework.cloud.openfeign.support;
|
||||
|
||||
import feign.RequestTemplate;
|
||||
import feign.codec.Encoder;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
@@ -58,7 +57,6 @@ public class PageableEncoderTests {
|
||||
private FeignContext context;
|
||||
|
||||
@Test
|
||||
@Ignore // FIXME 3.0.0
|
||||
public void testPaginationAndSortingRequest() {
|
||||
Encoder encoder = this.context.getInstance("foo", Encoder.class);
|
||||
assertThat(encoder).isNotNull();
|
||||
@@ -80,7 +78,6 @@ public class PageableEncoderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore // FIXME 3.0.0
|
||||
public void testPaginationRequest() {
|
||||
Encoder encoder = this.context.getInstance("foo", Encoder.class);
|
||||
assertThat(encoder).isNotNull();
|
||||
@@ -100,7 +97,6 @@ public class PageableEncoderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore // FIXME 3.0.0
|
||||
public void testSortingRequest() {
|
||||
Encoder encoder = this.context.getInstance("foo", Encoder.class);
|
||||
assertThat(encoder).isNotNull();
|
||||
@@ -118,7 +114,6 @@ public class PageableEncoderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore // FIXME 3.0.0
|
||||
public void testUnpagedRequest() {
|
||||
Encoder encoder = this.context.getInstance("foo", Encoder.class);
|
||||
assertThat(encoder).isNotNull();
|
||||
|
||||
@@ -26,7 +26,6 @@ import java.util.List;
|
||||
import feign.RequestTemplate;
|
||||
import feign.codec.EncodeException;
|
||||
import feign.codec.Encoder;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
@@ -85,7 +84,6 @@ public class SpringEncoderTests {
|
||||
private GenericHttpMessageConverter<?> myGenericConverter;
|
||||
|
||||
@Test
|
||||
@Ignore // FIXME 3.0.0
|
||||
public void testCustomHttpMessageConverter() {
|
||||
Encoder encoder = this.context.getInstance("foo", Encoder.class);
|
||||
assertThat(encoder).isNotNull();
|
||||
@@ -109,7 +107,6 @@ public class SpringEncoderTests {
|
||||
|
||||
// gh-225
|
||||
@Test
|
||||
@Ignore // FIXME 3.0.0
|
||||
public void testCustomGenericHttpMessageConverter() {
|
||||
Encoder encoder = this.context.getInstance("foo", Encoder.class);
|
||||
assertThat(encoder).isNotNull();
|
||||
@@ -137,7 +134,6 @@ public class SpringEncoderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore // FIXME 3.0.0
|
||||
public void testBinaryData() {
|
||||
Encoder encoder = this.context.getInstance("foo", Encoder.class);
|
||||
assertThat(encoder).isNotNull();
|
||||
@@ -152,7 +148,6 @@ public class SpringEncoderTests {
|
||||
}
|
||||
|
||||
@Test(expected = EncodeException.class)
|
||||
@Ignore // FIXME 3.0.0
|
||||
public void testMultipartFile1() {
|
||||
Encoder encoder = this.context.getInstance("foo", Encoder.class);
|
||||
assertThat(encoder).isNotNull();
|
||||
@@ -165,7 +160,6 @@ public class SpringEncoderTests {
|
||||
|
||||
// gh-105, gh-107
|
||||
@Test
|
||||
@Ignore // FIXME 3.0.0
|
||||
public void testMultipartFile2() {
|
||||
Encoder encoder = this.context.getInstance("foo", Encoder.class);
|
||||
assertThat(encoder).isNotNull();
|
||||
|
||||
@@ -20,8 +20,11 @@ import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import feign.Client;
|
||||
import feign.httpclient.ApacheHttpClient;
|
||||
import org.apache.http.Header;
|
||||
import org.apache.http.StatusLine;
|
||||
import org.apache.http.client.HttpClient;
|
||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||
import org.apache.http.client.methods.HttpUriRequest;
|
||||
import org.apache.http.config.RegistryBuilder;
|
||||
@@ -30,9 +33,9 @@ import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.impl.client.HttpClientBuilder;
|
||||
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
|
||||
import org.apache.http.message.BasicHeader;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.MockingDetails;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -45,6 +48,7 @@ import org.springframework.cloud.commons.httpclient.DefaultApacheHttpClientConne
|
||||
import org.springframework.cloud.commons.httpclient.DefaultApacheHttpClientFactory;
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.cloud.openfeign.loadbalancer.FeignBlockingLoadBalancerClient;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
@@ -55,13 +59,13 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.mockingDetails;
|
||||
|
||||
/**
|
||||
* @author Ryan Baxter
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@SpringBootTest(
|
||||
properties = { "feign.okhttp.enabled: false", "ribbon.eureka.enabled = false" })
|
||||
@SpringBootTest(properties = { "feign.okhttp.enabled: false" })
|
||||
@DirtiesContext
|
||||
public class ApacheHttpClientConfigurationTests {
|
||||
|
||||
@@ -71,12 +75,10 @@ public class ApacheHttpClientConfigurationTests {
|
||||
@Autowired
|
||||
ApacheHttpClientFactory httpClientFactory;
|
||||
|
||||
/*
|
||||
* @Autowired LoadBalancerFeignClient feignClient;
|
||||
*/
|
||||
@Autowired
|
||||
FeignBlockingLoadBalancerClient feignClient;
|
||||
|
||||
@Test
|
||||
@Ignore // FIXME 3.0.0
|
||||
public void testFactories() {
|
||||
assertThat(this.connectionManagerFactory)
|
||||
.isInstanceOf(ApacheHttpClientConnectionManagerFactory.class);
|
||||
@@ -88,14 +90,13 @@ public class ApacheHttpClientConfigurationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore // FIXME 3.0.0
|
||||
public void testHttpClientWithFeign() {
|
||||
// Client delegate = this.feignClient.getDelegate();
|
||||
// assertThat(ApacheHttpClient.class.isInstance(delegate)).isTrue();
|
||||
// ApacheHttpClient apacheHttpClient = (ApacheHttpClient) delegate; HttpClient
|
||||
// httpClient = getField(apacheHttpClient, "client"); MockingDetails
|
||||
// httpClientDetails = mockingDetails(httpClient);
|
||||
// assertThat(httpClientDetails.isMock()).isTrue();
|
||||
Client delegate = this.feignClient.getDelegate();
|
||||
assertThat(ApacheHttpClient.class.isInstance(delegate)).isTrue();
|
||||
ApacheHttpClient apacheHttpClient = (ApacheHttpClient) delegate;
|
||||
HttpClient httpClient = getField(apacheHttpClient, "client");
|
||||
MockingDetails httpClientDetails = mockingDetails(httpClient);
|
||||
assertThat(httpClientDetails.isMock()).isTrue();
|
||||
}
|
||||
|
||||
protected <T> T getField(Object target, String name) {
|
||||
|
||||
@@ -16,14 +16,14 @@
|
||||
|
||||
package org.springframework.cloud.openfeign.test;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import feign.Client;
|
||||
import okhttp3.ConnectionPool;
|
||||
import okhttp3.OkHttpClient;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.MockingDetails;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.SpringBootConfiguration;
|
||||
@@ -34,13 +34,15 @@ import org.springframework.cloud.commons.httpclient.DefaultOkHttpClientFactory;
|
||||
import org.springframework.cloud.commons.httpclient.OkHttpClientConnectionPoolFactory;
|
||||
import org.springframework.cloud.commons.httpclient.OkHttpClientFactory;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.cloud.openfeign.loadbalancer.FeignBlockingLoadBalancerClient;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.mockingDetails;
|
||||
|
||||
/**
|
||||
* @author Ryan Baxter
|
||||
@@ -60,12 +62,10 @@ public class OkHttpClientConfigurationTests {
|
||||
@Autowired
|
||||
OkHttpClientConnectionPoolFactory connectionPoolFactory;
|
||||
|
||||
/*
|
||||
* @Autowired LoadBalancerFeignClient feignClient;
|
||||
*/
|
||||
@Autowired
|
||||
FeignBlockingLoadBalancerClient feignClient;
|
||||
|
||||
@Test
|
||||
@Ignore // FIXME 3.0.0
|
||||
public void testFactories() {
|
||||
assertThat(this.connectionPoolFactory)
|
||||
.isInstanceOf(OkHttpClientConnectionPoolFactory.class);
|
||||
@@ -77,24 +77,21 @@ public class OkHttpClientConfigurationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore // FIXME 3.0.0
|
||||
public void testHttpClientWithFeign() {
|
||||
// Client delegate = this.feignClient.getDelegate();
|
||||
// assertThat(feign.okhttp.OkHttpClient.class.isInstance(delegate)).isTrue();
|
||||
// feign.okhttp.OkHttpClient okHttpClient = (feign.okhttp.OkHttpClient) delegate;
|
||||
// OkHttpClient httpClient = getField(okHttpClient, "delegate"); MockingDetails
|
||||
// httpClientDetails = mockingDetails(httpClient);
|
||||
// assertThat(httpClientDetails.isMock()).isTrue();
|
||||
Client delegate = this.feignClient.getDelegate();
|
||||
assertThat(feign.okhttp.OkHttpClient.class.isInstance(delegate)).isTrue();
|
||||
feign.okhttp.OkHttpClient okHttpClient = (feign.okhttp.OkHttpClient) delegate;
|
||||
OkHttpClient httpClient = getField(okHttpClient, "delegate");
|
||||
MockingDetails httpClientDetails = mockingDetails(httpClient);
|
||||
assertThat(httpClientDetails.isMock()).isTrue();
|
||||
}
|
||||
|
||||
protected <T> T getField(Object target, String name) {
|
||||
Field field = ReflectionUtils.findField(target.getClass(), name);
|
||||
ReflectionUtils.makeAccessible(field);
|
||||
Object value = ReflectionUtils.getField(field, target);
|
||||
Object value = ReflectionTestUtils.getField(target, target.getClass(), name);
|
||||
return (T) value;
|
||||
}
|
||||
|
||||
@FeignClient(name = "foo", serviceId = "foo")
|
||||
@FeignClient(name = "foo")
|
||||
interface FooClient {
|
||||
|
||||
}
|
||||
|
||||
@@ -19,19 +19,21 @@ package org.springframework.cloud.openfeign.valid;
|
||||
import java.util.List;
|
||||
|
||||
import feign.Logger;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.web.server.LocalServerPort;
|
||||
import org.springframework.cloud.loadbalancer.annotation.LoadBalancerClient;
|
||||
import org.springframework.cloud.loadbalancer.core.ServiceInstanceListSupplier;
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
@@ -56,15 +58,6 @@ public class FeignClientNotPrimaryTests {
|
||||
|
||||
public static final String HELLO_WORLD_1 = "hello world 1";
|
||||
|
||||
public static final String OI_TERRA_2 = "oi terra 2";
|
||||
|
||||
public static final String MYHEADER1 = "myheader1";
|
||||
|
||||
public static final String MYHEADER2 = "myheader2";
|
||||
|
||||
@Value("${local.server.port}")
|
||||
private int port = 0;
|
||||
|
||||
@Autowired
|
||||
private TestClient testClient;
|
||||
|
||||
@@ -72,20 +65,17 @@ public class FeignClientNotPrimaryTests {
|
||||
private List<TestClient> testClients;
|
||||
|
||||
@Test
|
||||
@Ignore // FIXME 3.0.0
|
||||
public void testClientType() {
|
||||
assertThat(this.testClient).as("testClient was of wrong type")
|
||||
.isInstanceOf(PrimaryTestClient.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore // FIXME 3.0.0
|
||||
public void testClientCount() {
|
||||
assertThat(this.testClients).as("testClients was wrong").hasSize(2);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore // FIXME 3.0.0
|
||||
public void testSimpleType() {
|
||||
Hello hello = this.testClient.getHello();
|
||||
assertThat(hello).as("hello was null").isNull();
|
||||
@@ -104,8 +94,7 @@ public class FeignClientNotPrimaryTests {
|
||||
@RestController
|
||||
@EnableFeignClients(clients = { TestClient.class },
|
||||
defaultConfiguration = TestDefaultFeignConfig.class)
|
||||
// @RibbonClient(name = "localapp", configuration =
|
||||
// LocalRibbonClientConfiguration.class)
|
||||
@LoadBalancerClient(name = "localapp", configuration = LocalClientConfiguration.class)
|
||||
protected static class Application {
|
||||
|
||||
@Bean
|
||||
@@ -163,15 +152,17 @@ public class FeignClientNotPrimaryTests {
|
||||
|
||||
// Load balancer with fixed server list for "local" pointing to localhost
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
public static class LocalRibbonClientConfiguration {
|
||||
public static class LocalClientConfiguration {
|
||||
|
||||
@Value("${local.server.port}")
|
||||
@LocalServerPort
|
||||
private int port = 0;
|
||||
|
||||
/*
|
||||
* @Bean public ServerList<Server> ribbonServerList() { return new
|
||||
* StaticServerList<>(new Server("localhost", this.port)); }
|
||||
*/
|
||||
@Bean
|
||||
public ServiceInstanceListSupplier staticServiceInstanceListSupplier(
|
||||
Environment env) {
|
||||
return ServiceInstanceListSupplier.fixed(env).instance(port, "localapp")
|
||||
.build();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -32,24 +32,29 @@ import feign.Client;
|
||||
import feign.Logger;
|
||||
import feign.RequestInterceptor;
|
||||
import feign.RequestTemplate;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import rx.Single;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
|
||||
import org.springframework.boot.web.server.LocalServerPort;
|
||||
import org.springframework.cloud.loadbalancer.annotation.LoadBalancerClient;
|
||||
import org.springframework.cloud.loadbalancer.annotation.LoadBalancerClients;
|
||||
import org.springframework.cloud.loadbalancer.core.ServiceInstanceListSupplier;
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.cloud.openfeign.FeignFormatterRegistrar;
|
||||
import org.springframework.cloud.openfeign.loadbalancer.FeignBlockingLoadBalancerClient;
|
||||
import org.springframework.cloud.openfeign.test.NoSecurityConfiguration;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.format.Formatter;
|
||||
import org.springframework.format.FormatterRegistry;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
@@ -103,6 +108,10 @@ public class FeignClientTests {
|
||||
@Autowired
|
||||
private DecodingTestClient decodingTestClient;
|
||||
|
||||
@Autowired
|
||||
@Qualifier("localapp2FeignClient")
|
||||
private DecodingTestClient namedFeignClient;
|
||||
|
||||
@Autowired
|
||||
private Client feignClient;
|
||||
|
||||
@@ -114,7 +123,6 @@ public class FeignClientTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore // FIXME: 3.0.0
|
||||
public void testClient() {
|
||||
assertThat(this.testClient).as("testClient was null").isNotNull();
|
||||
assertThat(Proxy.isProxyClass(this.testClient.getClass()))
|
||||
@@ -124,7 +132,6 @@ public class FeignClientTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore // FIXME: 3.0.0
|
||||
public void testRequestMappingClassLevelPropertyReplacement() {
|
||||
Hello hello = this.testClient.getHelloUsingPropertyPlaceHolder();
|
||||
assertThat(hello).as("hello was null").isNotNull();
|
||||
@@ -132,7 +139,6 @@ public class FeignClientTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore // FIXME: 3.0.0
|
||||
public void testSimpleType() {
|
||||
Hello hello = this.testClient.getHello();
|
||||
assertThat(hello).as("hello was null").isNotNull();
|
||||
@@ -141,14 +147,12 @@ public class FeignClientTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore // FIXME: 3.0.0
|
||||
public void testOptional() {
|
||||
Optional<Hello> hello = this.testClient.getOptionalHello();
|
||||
assertThat(hello).isNotNull().isPresent().contains(new Hello(HELLO_WORLD_1));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore // FIXME: 3.0.0
|
||||
public void testGenericType() {
|
||||
List<Hello> hellos = this.testClient.getHellos();
|
||||
assertThat(hellos).as("hellos was null").isNotNull();
|
||||
@@ -156,7 +160,6 @@ public class FeignClientTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore // FIXME: 3.0.0
|
||||
public void testRequestInterceptors() {
|
||||
List<String> headers = this.testClient.getHelloHeaders();
|
||||
assertThat(headers).as("headers was null").isNotNull();
|
||||
@@ -167,7 +170,6 @@ public class FeignClientTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore // FIXME: 3.0.0
|
||||
public void testHeaderPlaceholders() {
|
||||
String header = this.testClient.getHelloHeadersPlaceholders();
|
||||
assertThat(header).as("header was null").isNotNull();
|
||||
@@ -175,16 +177,14 @@ public class FeignClientTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore // FIXME 3.0.0
|
||||
public void testFeignClientType() throws IllegalAccessException {
|
||||
// assertThat(this.feignClient).isInstanceOf(LoadBalancerFeignClient.class);
|
||||
// LoadBalancerFeignClient client = (LoadBalancerFeignClient) this.feignClient;
|
||||
// Client delegate = client.getDelegate();
|
||||
// assertThat(delegate).isInstanceOf(Client.Default.class);
|
||||
assertThat(this.feignClient).isInstanceOf(FeignBlockingLoadBalancerClient.class);
|
||||
FeignBlockingLoadBalancerClient client = (FeignBlockingLoadBalancerClient) this.feignClient;
|
||||
Client delegate = client.getDelegate();
|
||||
assertThat(delegate).isInstanceOf(Client.Default.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore // FIXME 3.0.0
|
||||
public void testServiceId() {
|
||||
assertThat(this.testClientServiceId).as("testClientServiceId was null")
|
||||
.isNotNull();
|
||||
@@ -195,7 +195,6 @@ public class FeignClientTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore // FIXME 3.0.0
|
||||
public void testParams() {
|
||||
List<String> list = Arrays.asList("a", "1", "test");
|
||||
List<String> params = this.testClient.getParams(list);
|
||||
@@ -204,7 +203,6 @@ public class FeignClientTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore // FIXME 3.0.0
|
||||
public void testFormattedParams() {
|
||||
List<LocalDate> list = Arrays.asList(LocalDate.of(2001, 1, 1),
|
||||
LocalDate.of(2018, 6, 10));
|
||||
@@ -214,18 +212,6 @@ public class FeignClientTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore // FIXME 3.0.0
|
||||
public void testSingle() {
|
||||
Single<Hello> single = this.testClient.getHelloSingle();
|
||||
assertThat(single).as("single was null").isNotNull();
|
||||
Hello hello = single.toBlocking().value();
|
||||
assertThat(hello).as("hello was null").isNotNull();
|
||||
assertThat(hello).as("first hello didn't match")
|
||||
.isEqualTo(new Hello(HELLO_WORLD_1));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore // FIXME 3.0.0
|
||||
public void testNoContentResponse() {
|
||||
ResponseEntity<Void> response = this.testClient.noContent();
|
||||
assertThat(response).as("response was null").isNotNull();
|
||||
@@ -234,7 +220,6 @@ public class FeignClientTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore // FIXME 3.0.0
|
||||
public void testHeadResponse() {
|
||||
ResponseEntity<Void> response = this.testClient.head();
|
||||
assertThat(response).as("response was null").isNotNull();
|
||||
@@ -243,7 +228,6 @@ public class FeignClientTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore // FIXME 3.0.0
|
||||
public void testHttpEntity() {
|
||||
HttpEntity<Hello> entity = this.testClient.getHelloEntity();
|
||||
assertThat(entity).as("entity was null").isNotNull();
|
||||
@@ -254,7 +238,6 @@ public class FeignClientTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore // FIXME 3.0.0
|
||||
public void testMoreComplexHeader() {
|
||||
String response = this.testClient.moreComplexContentType("{\"value\":\"OK\"}");
|
||||
assertThat(response).as("response was null").isNotNull();
|
||||
@@ -263,7 +246,6 @@ public class FeignClientTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore // FIXME 3.0.0
|
||||
public void testDecodeNotFound() {
|
||||
ResponseEntity<String> response = this.decodingTestClient.notFound();
|
||||
assertThat(response).as("response was null").isNotNull();
|
||||
@@ -273,14 +255,12 @@ public class FeignClientTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore // FIXME 3.0.0
|
||||
public void testOptionalNotFound() {
|
||||
Optional<String> s = this.decodingTestClient.optional();
|
||||
assertThat(s).isNotPresent();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore // FIXME 3.0.0
|
||||
public void testConvertingExpander() {
|
||||
assertThat(this.testClient.getToString(Arg.A)).isEqualTo(Arg.A.toString());
|
||||
assertThat(this.testClient.getToString(Arg.B)).isEqualTo(Arg.B.toString());
|
||||
@@ -296,11 +276,8 @@ public class FeignClientTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore // FIXME 3.0.0
|
||||
public void namedFeignClientWorks() {
|
||||
// FIXME: 3.0.0
|
||||
// assertThat(this.namedHystrixClient).as("namedHystrixClient was
|
||||
// null").isNotNull();
|
||||
assertThat(this.namedFeignClient).as("namedFeignClient was null").isNotNull();
|
||||
}
|
||||
|
||||
protected enum Arg {
|
||||
@@ -327,9 +304,6 @@ public class FeignClientTests {
|
||||
path = "${feignClient.methodLevelRequestMappingPath}")
|
||||
Hello getHelloUsingPropertyPlaceHolder();
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, path = "/hello")
|
||||
Single<Hello> getHelloSingle();
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, path = "/hellos")
|
||||
List<Hello> getHellos();
|
||||
|
||||
@@ -441,33 +415,16 @@ public class FeignClientTests {
|
||||
clients = { TestClientServiceId.class, TestClient.class,
|
||||
DecodingTestClient.class },
|
||||
defaultConfiguration = TestDefaultFeignConfig.class)
|
||||
/*
|
||||
* @RibbonClients({
|
||||
*
|
||||
* @RibbonClient(name = "localapp", configuration =
|
||||
* LocalRibbonClientConfiguration.class),
|
||||
*
|
||||
* @RibbonClient(name = "localapp1", configuration =
|
||||
* LocalRibbonClientConfiguration.class),
|
||||
*
|
||||
* @RibbonClient(name = "localapp2", configuration =
|
||||
* LocalRibbonClientConfiguration.class),
|
||||
*
|
||||
* @RibbonClient(name = "localapp3", configuration =
|
||||
* LocalRibbonClientConfiguration.class),
|
||||
*
|
||||
* @RibbonClient(name = "localapp4", configuration =
|
||||
* LocalRibbonClientConfiguration.class),
|
||||
*
|
||||
* @RibbonClient(name = "localapp5", configuration =
|
||||
* LocalRibbonClientConfiguration.class),
|
||||
*
|
||||
* @RibbonClient(name = "localapp6", configuration =
|
||||
* LocalRibbonClientConfiguration.class),
|
||||
*
|
||||
* @RibbonClient(name = "localapp7", configuration =
|
||||
* LocalRibbonClientConfiguration.class) })
|
||||
*/
|
||||
@LoadBalancerClients({
|
||||
|
||||
@LoadBalancerClient(name = "localapp",
|
||||
configuration = LocalLoadBalancerClientConfiguration.class),
|
||||
|
||||
@LoadBalancerClient(name = "localapp1",
|
||||
configuration = LocalLoadBalancerClientConfiguration.class),
|
||||
|
||||
@LoadBalancerClient(name = "localapp2",
|
||||
configuration = LocalLoadBalancerClientConfiguration.class) })
|
||||
@Import(NoSecurityConfiguration.class)
|
||||
protected static class Application {
|
||||
|
||||
@@ -658,15 +615,16 @@ public class FeignClientTests {
|
||||
|
||||
// Load balancer with fixed server list for "local" pointing to localhost
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
public static class LocalRibbonClientConfiguration {
|
||||
public static class LocalLoadBalancerClientConfiguration {
|
||||
|
||||
@Value("${local.server.port}")
|
||||
@LocalServerPort
|
||||
private int port = 0;
|
||||
|
||||
/*
|
||||
* @Bean public ServerList<Server> ribbonServerList() { return new
|
||||
* StaticServerList<>(new Server("localhost", this.port)); }
|
||||
*/
|
||||
@Bean
|
||||
public ServiceInstanceListSupplier staticServiceInstanceListSupplier(
|
||||
Environment env) {
|
||||
return ServiceInstanceListSupplier.fixed(env).instance(port, "local").build();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -18,10 +18,12 @@ package org.springframework.cloud.openfeign.valid;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.cloud.client.loadbalancer.LoadBalancerAutoConfiguration;
|
||||
import org.springframework.cloud.commons.httpclient.HttpClientConfiguration;
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
import org.springframework.cloud.openfeign.FeignAutoConfiguration;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.cloud.openfeign.loadbalancer.FeignLoadBalancerAutoConfiguration;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
@@ -53,15 +55,13 @@ public class FeignClientValidationTests {
|
||||
|
||||
@Test
|
||||
public void validLoadBalanced() {
|
||||
// FIXME: 3.0.0
|
||||
/*
|
||||
* AnnotationConfigApplicationContext context = new
|
||||
* AnnotationConfigApplicationContext( LoadBalancerAutoConfiguration.class,
|
||||
* RibbonAutoConfiguration.class, FeignRibbonClientAutoConfiguration.class,
|
||||
* GoodServiceIdConfiguration.class);
|
||||
* assertThat(context.getBean(GoodServiceIdConfiguration.Client.class)).isNotNull(
|
||||
* ); context.close();
|
||||
*/
|
||||
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(
|
||||
LoadBalancerAutoConfiguration.class,
|
||||
org.springframework.cloud.loadbalancer.config.LoadBalancerAutoConfiguration.class,
|
||||
FeignLoadBalancerAutoConfiguration.class,
|
||||
GoodServiceIdConfiguration.class);
|
||||
assertThat(context.getBean(GoodServiceIdConfiguration.Client.class)).isNotNull();
|
||||
context.close();
|
||||
}
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
|
||||
@@ -19,7 +19,6 @@ package org.springframework.cloud.openfeign.valid;
|
||||
import java.util.Objects;
|
||||
|
||||
import feign.Client;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
@@ -28,11 +27,17 @@ import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
|
||||
import org.springframework.boot.web.server.LocalServerPort;
|
||||
import org.springframework.cloud.loadbalancer.annotation.LoadBalancerClient;
|
||||
import org.springframework.cloud.loadbalancer.annotation.LoadBalancerClients;
|
||||
import org.springframework.cloud.loadbalancer.core.ServiceInstanceListSupplier;
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.cloud.openfeign.loadbalancer.FeignBlockingLoadBalancerClient;
|
||||
import org.springframework.cloud.openfeign.test.NoSecurityConfiguration;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
@@ -70,7 +75,6 @@ public class FeignHttpClientTests {
|
||||
private UserClient userClient;
|
||||
|
||||
@Test
|
||||
@Ignore // FIXME 3.0.0
|
||||
public void testSimpleType() {
|
||||
Hello hello = this.testClient.getHello();
|
||||
assertThat(hello).as("hello was null").isNotNull();
|
||||
@@ -79,7 +83,6 @@ public class FeignHttpClientTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore // FIXME 3.0.0
|
||||
public void testPatch() {
|
||||
ResponseEntity<Void> response = this.testClient.patchHello(new Hello("foo"));
|
||||
assertThat(response).isNotNull();
|
||||
@@ -88,16 +91,14 @@ public class FeignHttpClientTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore // FIXME 3.0.0
|
||||
public void testFeignClientType() throws IllegalAccessException {
|
||||
// assertThat(this.feignClient).isInstanceOf(LoadBalancerFeignClient.class);
|
||||
// LoadBalancerFeignClient client = (LoadBalancerFeignClient) this.feignClient;
|
||||
// Client delegate = client.getDelegate();
|
||||
// assertThat(delegate).isInstanceOf(feign.httpclient.ApacheHttpClient.class);
|
||||
assertThat(this.feignClient).isInstanceOf(FeignBlockingLoadBalancerClient.class);
|
||||
FeignBlockingLoadBalancerClient client = (FeignBlockingLoadBalancerClient) this.feignClient;
|
||||
Client delegate = client.getDelegate();
|
||||
assertThat(delegate).isInstanceOf(feign.httpclient.ApacheHttpClient.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore // FIXME 3.0.0
|
||||
public void testFeignInheritanceSupport() {
|
||||
assertThat(this.userClient).as("UserClient was null").isNotNull();
|
||||
final User user = this.userClient.getUser(1);
|
||||
@@ -139,15 +140,11 @@ public class FeignHttpClientTests {
|
||||
@EnableAutoConfiguration
|
||||
@RestController
|
||||
@EnableFeignClients(clients = { TestClient.class, UserClient.class })
|
||||
/*
|
||||
* @RibbonClients({
|
||||
*
|
||||
* @RibbonClient(name = "localapp", configuration =
|
||||
* LocalRibbonClientConfiguration.class),
|
||||
*
|
||||
* @RibbonClient(name = "localapp1", configuration =
|
||||
* LocalRibbonClientConfiguration.class) })
|
||||
*/
|
||||
@LoadBalancerClients({
|
||||
@LoadBalancerClient(name = "localapp",
|
||||
configuration = LocalClientConfiguration.class),
|
||||
@LoadBalancerClient(name = "localapp1",
|
||||
configuration = LocalClientConfiguration.class) })
|
||||
@Import(NoSecurityConfiguration.class)
|
||||
protected static class Application implements UserService {
|
||||
|
||||
@@ -255,15 +252,16 @@ public class FeignHttpClientTests {
|
||||
|
||||
// Load balancer with fixed server list for "local" pointing to localhost
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
static class LocalRibbonClientConfiguration {
|
||||
static class LocalClientConfiguration {
|
||||
|
||||
@LocalServerPort
|
||||
private int port = 0;
|
||||
|
||||
/*
|
||||
* @Bean public ServerList<Server> ribbonServerList() { return new
|
||||
* StaticServerList<>(new Server("localhost", this.port)); }
|
||||
*/
|
||||
@Bean
|
||||
public ServiceInstanceListSupplier staticServiceInstanceListSupplier(
|
||||
Environment env) {
|
||||
return ServiceInstanceListSupplier.fixed(env).instance(port, "local").build();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,6 @@ package org.springframework.cloud.openfeign.valid;
|
||||
import java.util.Objects;
|
||||
|
||||
import feign.Client;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
@@ -28,11 +27,18 @@ import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
|
||||
import org.springframework.boot.web.server.LocalServerPort;
|
||||
import org.springframework.cloud.loadbalancer.annotation.LoadBalancerClient;
|
||||
import org.springframework.cloud.loadbalancer.annotation.LoadBalancerClients;
|
||||
import org.springframework.cloud.loadbalancer.core.ServiceInstanceListSupplier;
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.cloud.openfeign.loadbalancer.FeignBlockingLoadBalancerClient;
|
||||
import org.springframework.cloud.openfeign.test.NoSecurityConfiguration;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
@@ -71,7 +77,6 @@ public class FeignOkHttpTests {
|
||||
private UserClient userClient;
|
||||
|
||||
@Test
|
||||
@Ignore // FIXME 3.0.0
|
||||
public void testSimpleType() {
|
||||
Hello hello = this.testClient.getHello();
|
||||
assertThat(hello).as("hello was null").isNotNull();
|
||||
@@ -80,7 +85,6 @@ public class FeignOkHttpTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore // FIXME 3.0.0
|
||||
public void testPatch() {
|
||||
ResponseEntity<Void> response = this.testClient.patchHello(new Hello("foo"));
|
||||
assertThat(response).isNotNull();
|
||||
@@ -89,16 +93,14 @@ public class FeignOkHttpTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore // FIXME 3.0.0
|
||||
public void testFeignClientType() throws IllegalAccessException {
|
||||
// assertThat(this.feignClient).isInstanceOf(LoadBalancerFeignClient.class);
|
||||
// LoadBalancerFeignClient client = (LoadBalancerFeignClient) this.feignClient;
|
||||
// Client delegate = client.getDelegate();
|
||||
// assertThat(delegate).isInstanceOf(feign.okhttp.OkHttpClient.class);
|
||||
assertThat(this.feignClient).isInstanceOf(FeignBlockingLoadBalancerClient.class);
|
||||
FeignBlockingLoadBalancerClient client = (FeignBlockingLoadBalancerClient) this.feignClient;
|
||||
Client delegate = client.getDelegate();
|
||||
assertThat(delegate).isInstanceOf(feign.okhttp.OkHttpClient.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore // FIXME 3.0.0
|
||||
public void testFeignInheritanceSupport() {
|
||||
assertThat(this.userClient).as("UserClient was null").isNotNull();
|
||||
final User user = this.userClient.getUser(1);
|
||||
@@ -138,15 +140,11 @@ public class FeignOkHttpTests {
|
||||
@EnableAutoConfiguration
|
||||
@RestController
|
||||
@EnableFeignClients(clients = { TestClient.class, UserClient.class })
|
||||
/*
|
||||
* @RibbonClients({
|
||||
*
|
||||
* @RibbonClient(name = "localapp", configuration =
|
||||
* LocalRibbonClientConfiguration.class),
|
||||
*
|
||||
* @RibbonClient(name = "localapp1", configuration =
|
||||
* LocalRibbonClientConfiguration.class) })
|
||||
*/
|
||||
@LoadBalancerClients({
|
||||
@LoadBalancerClient(name = "localapp",
|
||||
configuration = FeignHttpClientTests.LocalClientConfiguration.class),
|
||||
@LoadBalancerClient(name = "localapp1",
|
||||
configuration = FeignHttpClientTests.LocalClientConfiguration.class) })
|
||||
@Import(NoSecurityConfiguration.class)
|
||||
protected static class Application implements UserService {
|
||||
|
||||
@@ -254,15 +252,16 @@ public class FeignOkHttpTests {
|
||||
|
||||
// Load balancer with fixed server list for "local" pointing to localhost
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
static class LocalRibbonClientConfiguration {
|
||||
static class LocalClientConfiguration {
|
||||
|
||||
@Value("${local.server.port}")
|
||||
@LocalServerPort
|
||||
private int port = 0;
|
||||
|
||||
/*
|
||||
* @Bean public ServerList<Server> ribbonServerList() { return new
|
||||
* StaticServerList<>(new Server("localhost", this.port)); }
|
||||
*/
|
||||
@Bean
|
||||
public ServiceInstanceListSupplier staticServiceInstanceListSupplier(
|
||||
Environment env) {
|
||||
return ServiceInstanceListSupplier.fixed(env).instance(port, "local").build();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@ package org.springframework.cloud.openfeign.valid;
|
||||
|
||||
import io.vavr.collection.HashSet;
|
||||
import io.vavr.collection.Set;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
@@ -27,11 +26,15 @@ import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
|
||||
import org.springframework.boot.web.server.LocalServerPort;
|
||||
import org.springframework.cloud.loadbalancer.annotation.LoadBalancerClient;
|
||||
import org.springframework.cloud.loadbalancer.core.ServiceInstanceListSupplier;
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.cloud.openfeign.test.NoSecurityConfiguration;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
@@ -57,7 +60,6 @@ public class IterableParameterTests {
|
||||
private TestClient testClient;
|
||||
|
||||
@Test
|
||||
@Ignore // FIXME 3.0.0
|
||||
public void testClient() {
|
||||
assertThat(this.testClient).as("testClient was null").isNotNull();
|
||||
String results = this.testClient.echo(HashSet.of("a", "b"));
|
||||
@@ -76,8 +78,8 @@ public class IterableParameterTests {
|
||||
@EnableAutoConfiguration
|
||||
@RestController
|
||||
@EnableFeignClients(clients = TestClient.class)
|
||||
// @RibbonClient(name = "localapp", configuration =
|
||||
// LocalRibbonClientConfiguration.class)
|
||||
@LoadBalancerClient(name = "localapp",
|
||||
configuration = LocalRibbonClientConfiguration.class)
|
||||
@Import(NoSecurityConfiguration.class)
|
||||
protected static class Application {
|
||||
|
||||
@@ -94,10 +96,12 @@ public class IterableParameterTests {
|
||||
@LocalServerPort
|
||||
private int port = 0;
|
||||
|
||||
/*
|
||||
* @Bean public ServerList<Server> ribbonServerList() { return new
|
||||
* StaticServerList<>(new Server("localhost", this.port)); }
|
||||
*/
|
||||
@Bean
|
||||
public ServiceInstanceListSupplier staticServiceInstanceListSupplier(
|
||||
Environment env) {
|
||||
return ServiceInstanceListSupplier.fixed(env).instance(port, "localapp")
|
||||
.build();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -16,19 +16,22 @@
|
||||
|
||||
package org.springframework.cloud.openfeign.valid.scanning;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.web.server.LocalServerPort;
|
||||
import org.springframework.cloud.loadbalancer.annotation.LoadBalancerClient;
|
||||
import org.springframework.cloud.loadbalancer.core.ServiceInstanceListSupplier;
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
import org.springframework.cloud.openfeign.test.NoSecurityConfiguration;
|
||||
import org.springframework.cloud.openfeign.testclients.TestClient;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
@@ -54,7 +57,6 @@ public class FeignClientEnvVarTests {
|
||||
private TestClient testClient;
|
||||
|
||||
@Test
|
||||
@Ignore // FIXME 3.0.0
|
||||
public void testSimpleType() {
|
||||
String hello = this.testClient.getHello();
|
||||
assertThat(hello).as("hello was null").isNotNull();
|
||||
@@ -65,8 +67,7 @@ public class FeignClientEnvVarTests {
|
||||
@EnableAutoConfiguration
|
||||
@RestController
|
||||
@EnableFeignClients(basePackages = { "${basepackage}" })
|
||||
// @RibbonClient(name = "localapp", configuration =
|
||||
// LocalRibbonClientConfiguration.class)
|
||||
@LoadBalancerClient(name = "localapp", configuration = LocalClientConfiguration.class)
|
||||
@Import(NoSecurityConfiguration.class)
|
||||
protected static class Application {
|
||||
|
||||
@@ -79,15 +80,17 @@ public class FeignClientEnvVarTests {
|
||||
|
||||
// Load balancer with fixed server list for "local" pointing to localhost
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
public static class LocalRibbonClientConfiguration {
|
||||
public static class LocalClientConfiguration {
|
||||
|
||||
@Value("${local.server.port}")
|
||||
@LocalServerPort
|
||||
private int port = 0;
|
||||
|
||||
/*
|
||||
* @Bean public ServerList<Server> ribbonServerList() { return new
|
||||
* StaticServerList<>(new Server("localhost", this.port)); }
|
||||
*/
|
||||
@Bean
|
||||
public ServiceInstanceListSupplier staticServiceInstanceListSupplier(
|
||||
Environment env) {
|
||||
return ServiceInstanceListSupplier.fixed(env).instance(port, "localapp")
|
||||
.build();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
package org.springframework.cloud.openfeign.valid.scanning;
|
||||
|
||||
import feign.Client;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
@@ -25,11 +24,16 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.web.server.LocalServerPort;
|
||||
import org.springframework.cloud.loadbalancer.annotation.LoadBalancerClients;
|
||||
import org.springframework.cloud.loadbalancer.core.ServiceInstanceListSupplier;
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.cloud.openfeign.test.NoSecurityConfiguration;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
@@ -63,7 +67,6 @@ public class FeignClientScanningTests {
|
||||
private Client feignClient;
|
||||
|
||||
@Test
|
||||
@Ignore // FIXME 3.0.0
|
||||
public void testSimpleType() {
|
||||
String hello = this.testClient.getHello();
|
||||
assertThat(hello).as("hello was null").isNotNull();
|
||||
@@ -71,7 +74,6 @@ public class FeignClientScanningTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore // FIXME 3.0.0
|
||||
public void testSimpleTypeByKey() {
|
||||
String hello = this.testClientByKey.getHello();
|
||||
assertThat(hello).as("hello was null").isNotNull();
|
||||
@@ -98,7 +100,7 @@ public class FeignClientScanningTests {
|
||||
@EnableAutoConfiguration
|
||||
@RestController
|
||||
@EnableFeignClients // NO clients attribute. That's what this class is testing!
|
||||
// @RibbonClients(defaultConfiguration = LocalRibbonClientConfiguration.class)
|
||||
@LoadBalancerClients(defaultConfiguration = LocalClientConfiguration.class)
|
||||
@Import(NoSecurityConfiguration.class)
|
||||
protected static class Application {
|
||||
|
||||
@@ -111,15 +113,16 @@ public class FeignClientScanningTests {
|
||||
|
||||
// Load balancer with fixed server list for "local" pointing to localhost
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
public static class LocalRibbonClientConfiguration {
|
||||
static class LocalClientConfiguration {
|
||||
|
||||
@Value("${local.server.port}")
|
||||
@LocalServerPort
|
||||
private int port = 0;
|
||||
|
||||
/*
|
||||
* @Bean public ServerList<Server> ribbonServerList() { return new
|
||||
* StaticServerList<>(new Server("localhost", this.port)); }
|
||||
*/
|
||||
@Bean
|
||||
public ServiceInstanceListSupplier staticServiceInstanceListSupplier(
|
||||
Environment env) {
|
||||
return ServiceInstanceListSupplier.fixed(env).instance(port, "local").build();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user