mirror of
https://github.com/spring-cloud/spring-cloud-netflix.git
synced 2026-09-17 15:49:00 +00:00
Merge branch '2.0.x'
This commit is contained in:
@@ -25,7 +25,7 @@
|
||||
<spring-cloud-config.version>2.1.0.BUILD-SNAPSHOT</spring-cloud-config.version>
|
||||
<spring-cloud-stream.version>Fishtown.BUILD-SNAPSHOT</spring-cloud-stream.version>
|
||||
<!-- Has to be a stable version (not one that depends on this version of netflix): -->
|
||||
<donotreplacespring-cloud-contract.version>2.0.1.RELEASE</donotreplacespring-cloud-contract.version>
|
||||
<donotreplacespring-cloud-contract.version>2.0.2.RELEASE</donotreplacespring-cloud-contract.version>
|
||||
|
||||
<!-- Sonar -->
|
||||
<sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>
|
||||
|
||||
+3
-2
@@ -37,13 +37,13 @@ import com.github.tomakehurst.wiremock.http.RequestMethod;
|
||||
import com.github.tomakehurst.wiremock.matching.MatchResult;
|
||||
import com.github.tomakehurst.wiremock.stubbing.StubMapping;
|
||||
import com.jayway.jsonpath.JsonPath;
|
||||
|
||||
import io.restassured.filter.Filter;
|
||||
import io.restassured.filter.FilterContext;
|
||||
import io.restassured.http.Header;
|
||||
import io.restassured.response.Response;
|
||||
import io.restassured.specification.FilterableRequestSpecification;
|
||||
import io.restassured.specification.FilterableResponseSpecification;
|
||||
|
||||
import org.springframework.util.Base64Utils;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
@@ -91,7 +91,7 @@ public class RequestVerifierFilter implements Filter {
|
||||
|
||||
@Override
|
||||
public Response filter(FilterableRequestSpecification requestSpec,
|
||||
FilterableResponseSpecification responseSpec, FilterContext context) {
|
||||
FilterableResponseSpecification responseSpec, FilterContext context) {
|
||||
Map<String, Object> configuration = getConfiguration(requestSpec, context);
|
||||
configuration.put("contract.jsonPaths", this.jsonPaths.keySet());
|
||||
Response response = context.next(requestSpec, responseSpec);
|
||||
@@ -356,4 +356,5 @@ class WireMockRestAssuredRequestAdapter implements Request {
|
||||
public Part getPart(String s) {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
<name>spring-cloud-netflix-hystrix-contract</name>
|
||||
<description>Spring Cloud Netflix Hystrix Contract</description>
|
||||
<properties>
|
||||
<donotreplacespring-cloud-contract.version>2.0.1.RELEASE</donotreplacespring-cloud-contract.version>
|
||||
<donotreplacespring-cloud-contract.version>2.0.2.RELEASE</donotreplacespring-cloud-contract.version>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
|
||||
+6
-4
@@ -111,16 +111,18 @@ public class RibbonProperties {
|
||||
Object property = this.config.getProperty(PoolKeepAliveTime);
|
||||
if (property instanceof Long) {
|
||||
return (Long) property;
|
||||
} else if (property instanceof String) {
|
||||
return Long.valueOf((String) property);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public long poolKeepAliveTime() {
|
||||
Object property = this.config.getProperty(PoolKeepAliveTime);
|
||||
if (property instanceof Long) {
|
||||
return (Long) property;
|
||||
Long poolKeepAliveTime = getPoolKeepAliveTime();
|
||||
if (poolKeepAliveTime != null) {
|
||||
return poolKeepAliveTime;
|
||||
}
|
||||
|
||||
return DEFAULT_POOL_KEEP_ALIVE_TIME;
|
||||
}
|
||||
|
||||
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* 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
|
||||
*
|
||||
* http://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.netflix.ribbon;
|
||||
|
||||
import com.netflix.client.config.CommonClientConfigKey;
|
||||
import com.netflix.client.config.DefaultClientConfigImpl;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* @author Spencer Gibb
|
||||
*/
|
||||
public class RibbonPropertiesTests {
|
||||
|
||||
@Test
|
||||
public void poolKeepAliveWorksWithString() {
|
||||
DefaultClientConfigImpl config = new DefaultClientConfigImpl();
|
||||
config.setProperty(CommonClientConfigKey.PoolKeepAliveTime, "714");
|
||||
RibbonProperties properties = new RibbonProperties(config);
|
||||
assertThat(properties.poolKeepAliveTime()).isEqualTo(714L);
|
||||
assertThat(properties.getPoolKeepAliveTime()).isEqualTo(714L);
|
||||
}
|
||||
}
|
||||
+19
-21
@@ -24,19 +24,23 @@ import java.io.InputStreamReader;
|
||||
import java.net.URI;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
||||
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
|
||||
import org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.web.server.LocalServerPort;
|
||||
import org.springframework.cloud.contract.stubrunner.StubTrigger;
|
||||
import org.springframework.cloud.contract.stubrunner.spring.AutoConfigureStubRunner;
|
||||
import org.springframework.cloud.contract.verifier.messaging.MessageVerifier;
|
||||
import org.springframework.cloud.contract.verifier.messaging.stream.StreamStubMessages;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.cloud.contract.stubrunner.spring.StubRunnerProperties.StubsMode;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
@@ -48,11 +52,9 @@ import org.springframework.http.client.ClientHttpRequestExecution;
|
||||
import org.springframework.http.client.ClientHttpRequestInterceptor;
|
||||
import org.springframework.http.client.ClientHttpResponse;
|
||||
import org.springframework.integration.support.management.MessageChannelMetrics;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.SubscribableChannel;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
|
||||
@@ -67,9 +69,8 @@ import static org.springframework.boot.test.context.SpringBootTest.WebEnvironmen
|
||||
// https://github.com/spring-cloud/spring-cloud-netflix/issues/1948
|
||||
"spring.cloud.stream.bindings.turbineStreamInput.destination=hystrixStreamOutput",
|
||||
"spring.jmx.enabled=true", "stubrunner.workOffline=true",
|
||||
"stubrunner.ids=org.springframework.cloud:spring-cloud-netflix-hystrix-stream:${projectVersion:2.0.0.BUILD-SNAPSHOT}:stubs",
|
||||
})
|
||||
@AutoConfigureStubRunner
|
||||
"stubrunner.ids=org.springframework.cloud:spring-cloud-netflix-hystrix-stream:${projectVersion:2.0.0.BUILD-SNAPSHOT}:stubs"})
|
||||
@AutoConfigureStubRunner(stubsMode = StubsMode.LOCAL)
|
||||
public class TurbineStreamTests {
|
||||
@Autowired
|
||||
StubTrigger stubTrigger;
|
||||
@@ -92,26 +93,23 @@ public class TurbineStreamTests {
|
||||
@EnableAutoConfiguration
|
||||
@EnableTurbineStream
|
||||
public static class Application {
|
||||
// Workaround for stub runner lowercasing id somewhere
|
||||
@Bean
|
||||
//TODO This can be removed after Finchley.RELEASE, once we can use Spring Cloud Contract Verifier 2.0.0
|
||||
//This is a hack to allow compatibility between Stream 2.0.0, which is sending everything as a byte array,
|
||||
//and contract which is assuming everything is a String.
|
||||
public MessageVerifier<Message<?>> customMessageVerifier(ApplicationContext context) {
|
||||
return new StreamStubMessages(context) {
|
||||
BeanDefinitionRegistryPostProcessor myBeanDefinitionRegistryPostProcessor() {
|
||||
return new BeanDefinitionRegistryPostProcessor() {
|
||||
@Override
|
||||
public <T> void send(T payload, Map<String, Object> headers, String destination) {
|
||||
if(String.class.isInstance(payload)){
|
||||
super.send(((String)payload).getBytes(), headers, destination);
|
||||
return;
|
||||
}
|
||||
super.send(payload, headers, destination);
|
||||
public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) throws BeansException {
|
||||
BeanDefinition beanDefinition = registry.getBeanDefinition(TurbineStreamClient.INPUT);
|
||||
registry.registerBeanDefinition(TurbineStreamClient.INPUT.toLowerCase(), beanDefinition);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { }
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore //FIXME: 2.1.0
|
||||
public void contextLoads() throws Exception {
|
||||
rest.getInterceptors().add(new NonClosingInterceptor());
|
||||
int count = ((MessageChannelMetrics) input).getSendCount();
|
||||
|
||||
Reference in New Issue
Block a user