mirror of
https://github.com/spring-cloud/spring-cloud-netflix.git
synced 2026-09-17 15:49:00 +00:00
Updates stubrunner to 2.0.2.RELEASE
This commit is contained in:
@@ -26,7 +26,7 @@
|
||||
<spring-cloud-config.version>2.0.1.BUILD-SNAPSHOT</spring-cloud-config.version>
|
||||
<spring-cloud-stream.version>Elmhurst.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>1.2.4.RELEASE</donotreplacespring-cloud-contract.version>
|
||||
<donotreplacespring-cloud-contract.version>2.0.2.RELEASE</donotreplacespring-cloud-contract.version>
|
||||
|
||||
<!-- Plugin versions -->
|
||||
<maven-compiler-plugin.version>3.6.1</maven-compiler-plugin.version>
|
||||
|
||||
+20
-3
@@ -37,17 +37,18 @@ 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 wiremock.com.google.common.base.Optional;
|
||||
|
||||
import org.springframework.util.Base64Utils;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
import wiremock.com.google.common.base.Optional;
|
||||
import org.springframework.web.util.UriComponentsBuilder;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@@ -90,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);
|
||||
@@ -209,6 +210,21 @@ class WireMockRestAssuredRequestAdapter implements Request {
|
||||
return Optional.of(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getScheme() {
|
||||
return UriComponentsBuilder.fromUriString(request.getURI()).build().getScheme();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHost() {
|
||||
return UriComponentsBuilder.fromUriString(request.getURI()).build().getHost();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPort() {
|
||||
return request.getPort();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUrl() {
|
||||
return request.getDerivedPath();
|
||||
@@ -340,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.0.RELEASE</donotreplacespring-cloud-contract.version>
|
||||
<donotreplacespring-cloud-contract.version>2.0.2.RELEASE</donotreplacespring-cloud-contract.version>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
|
||||
+19
-17
@@ -22,18 +22,24 @@ import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.URI;
|
||||
import java.util.Map;
|
||||
|
||||
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;
|
||||
@@ -45,11 +51,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;
|
||||
@@ -65,7 +69,7 @@ import static org.springframework.boot.test.context.SpringBootTest.WebEnvironmen
|
||||
"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
|
||||
@AutoConfigureStubRunner(stubsMode = StubsMode.LOCAL)
|
||||
public class TurbineStreamTests {
|
||||
@Autowired
|
||||
StubTrigger stubTrigger;
|
||||
@@ -88,20 +92,18 @@ 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 { }
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user