Updates to Boot 2.3.0 and Ilford release train
Removes ribbon and updates for boot 2.3.0
This commit is contained in:
@@ -22,7 +22,7 @@
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<java.version>1.8</java.version>
|
||||
<spring-cloud-contract.version>3.0.0.BUILD-SNAPSHOT</spring-cloud-contract.version>
|
||||
<spring-cloud-release.version>Hoxton.BUILD-SNAPSHOT</spring-cloud-release.version>
|
||||
<spring-cloud-release.version>Ilford.BUILD-SNAPSHOT</spring-cloud-release.version>
|
||||
<excludeBuildFolders>true</excludeBuildFolders>
|
||||
</properties>
|
||||
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
org.gradle.daemon=false
|
||||
BOM_VERSION=Hoxton.BUILD-SNAPSHOT
|
||||
BOM_VERSION=Ilford.BUILD-SNAPSHOT
|
||||
bootVersion=2.3.0.BUILD-SNAPSHOT
|
||||
@@ -21,7 +21,7 @@
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<java.version>1.8</java.version>
|
||||
<spring-cloud-release-train.version>Hoxton.BUILD-SNAPSHOT
|
||||
<spring-cloud-release-train.version>Ilford.BUILD-SNAPSHOT
|
||||
</spring-cloud-release-train.version>
|
||||
</properties>
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
org.gradle.daemon=false
|
||||
verifierVersion=3.0.0.BUILD-SNAPSHOT
|
||||
BOM_VERSION=Hoxton.BUILD-SNAPSHOT
|
||||
BOM_VERSION=Ilford.BUILD-SNAPSHOT
|
||||
bootVersion=2.3.0.BUILD-SNAPSHOT
|
||||
@@ -22,7 +22,7 @@
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<java.version>1.8</java.version>
|
||||
<spring-cloud-contract.version>3.0.0.BUILD-SNAPSHOT</spring-cloud-contract.version>
|
||||
<spring-cloud-release.version>Hoxton.BUILD-SNAPSHOT
|
||||
<spring-cloud-release.version>Ilford.BUILD-SNAPSHOT
|
||||
</spring-cloud-release.version>
|
||||
</properties>
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
org.gradle.daemon=false
|
||||
verifierVersion=3.0.0.BUILD-SNAPSHOT
|
||||
BOM_VERSION=Hoxton.BUILD-SNAPSHOT
|
||||
BOM_VERSION=Ilford.BUILD-SNAPSHOT
|
||||
bootVersion=2.3.0.BUILD-SNAPSHOT
|
||||
@@ -1,4 +1,4 @@
|
||||
org.gradle.daemon=false
|
||||
verifierVersion=3.0.0.BUILD-SNAPSHOT
|
||||
BOM_VERSION=Hoxton.BUILD-SNAPSHOT
|
||||
BOM_VERSION=Ilford.BUILD-SNAPSHOT
|
||||
bootVersion=2.3.0.BUILD-SNAPSHOT
|
||||
@@ -1,4 +1,4 @@
|
||||
org.gradle.daemon=false
|
||||
verifierVersion=3.0.0.BUILD-SNAPSHOT
|
||||
BOM_VERSION=Hoxton.BUILD-SNAPSHOT
|
||||
BOM_VERSION=Ilford.BUILD-SNAPSHOT
|
||||
bootVersion=2.3.0.BUILD-SNAPSHOT
|
||||
@@ -1,4 +1,4 @@
|
||||
org.gradle.daemon=false
|
||||
verifierVersion=3.0.0.BUILD-SNAPSHOT
|
||||
BOM_VERSION=Hoxton.BUILD-SNAPSHOT
|
||||
BOM_VERSION=Ilford.BUILD-SNAPSHOT
|
||||
bootVersion=2.3.0.BUILD-SNAPSHOT
|
||||
@@ -41,11 +41,6 @@
|
||||
<artifactId>spring-cloud-starter</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-netflix-ribbon</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-contract-spec</artifactId>
|
||||
|
||||
@@ -1,45 +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.contract.stubrunner.spring.cloud.ribbon;
|
||||
|
||||
import com.netflix.loadbalancer.ServerList;
|
||||
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.cloud.contract.stubrunner.spring.cloud.ConditionalOnStubbedDiscoveryEnabled;
|
||||
import org.springframework.cloud.contract.stubrunner.spring.cloud.StubMapperProperties;
|
||||
import org.springframework.cloud.netflix.ribbon.RibbonAutoConfiguration;
|
||||
import org.springframework.cloud.netflix.ribbon.RibbonClients;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* Auto configuration for stubbing out Ribbon.
|
||||
*
|
||||
* @author Marcin Grzejszczak
|
||||
*/
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@ConditionalOnClass(ServerList.class)
|
||||
@ConditionalOnBean(StubMapperProperties.class)
|
||||
@AutoConfigureAfter(RibbonAutoConfiguration.class)
|
||||
@RibbonClients(defaultConfiguration = StubRunnerRibbonConfiguration.class)
|
||||
@ConditionalOnStubbedDiscoveryEnabled
|
||||
@ConditionalOnProperty(value = "stubrunner.cloud.ribbon.enabled", matchIfMissing = true)
|
||||
public class StubRunnerRibbonAutoConfiguration {
|
||||
|
||||
}
|
||||
@@ -1,87 +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.contract.stubrunner.spring.cloud.ribbon;
|
||||
|
||||
import com.netflix.client.config.IClientConfig;
|
||||
import com.netflix.loadbalancer.ServerList;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.config.BeanPostProcessor;
|
||||
import org.springframework.cloud.contract.stubrunner.StubFinder;
|
||||
import org.springframework.cloud.contract.stubrunner.spring.cloud.StubMapperProperties;
|
||||
|
||||
/**
|
||||
* Ribbon AutoConfiguration that manipulates the service id to make the service be picked
|
||||
* from the list of available WireMock instance if one is available.
|
||||
*
|
||||
* @author Marcin Grzejszczak
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class StubRunnerRibbonBeanPostProcessor implements BeanPostProcessor {
|
||||
|
||||
private final BeanFactory beanFactory;
|
||||
|
||||
private StubFinder stubFinder;
|
||||
|
||||
private StubMapperProperties stubMapperProperties;
|
||||
|
||||
private IClientConfig clientConfig;
|
||||
|
||||
StubRunnerRibbonBeanPostProcessor(BeanFactory beanFactory) {
|
||||
this.beanFactory = beanFactory;
|
||||
}
|
||||
|
||||
private StubFinder stubFinder() {
|
||||
if (this.stubFinder == null) {
|
||||
this.stubFinder = this.beanFactory.getBean(StubFinder.class);
|
||||
}
|
||||
return this.stubFinder;
|
||||
}
|
||||
|
||||
private StubMapperProperties stubMapperProperties() {
|
||||
if (this.stubMapperProperties == null) {
|
||||
this.stubMapperProperties = this.beanFactory
|
||||
.getBean(StubMapperProperties.class);
|
||||
}
|
||||
return this.stubMapperProperties;
|
||||
}
|
||||
|
||||
private IClientConfig clientConfig() {
|
||||
if (this.clientConfig == null) {
|
||||
this.clientConfig = this.beanFactory.getBean(IClientConfig.class);
|
||||
}
|
||||
return this.clientConfig;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object postProcessBeforeInitialization(Object bean, String beanName)
|
||||
throws BeansException {
|
||||
if (bean instanceof ServerList && !(bean instanceof StubRunnerRibbonServerList)) {
|
||||
return new StubRunnerRibbonServerList(stubFinder(), stubMapperProperties(),
|
||||
clientConfig());
|
||||
}
|
||||
return bean;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object postProcessAfterInitialization(Object bean, String beanName)
|
||||
throws BeansException {
|
||||
return bean;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,58 +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.contract.stubrunner.spring.cloud.ribbon;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.netflix.loadbalancer.Server;
|
||||
import com.netflix.loadbalancer.ServerList;
|
||||
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Role;
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
|
||||
class StubRunnerRibbonConfiguration {
|
||||
|
||||
@Bean
|
||||
static StubRunnerRibbonBeanPostProcessor stubRunnerRibbonBeanPostProcessor(
|
||||
BeanFactory beanFactory) {
|
||||
return new StubRunnerRibbonBeanPostProcessor(beanFactory);
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public ServerList<?> noOpServerList() {
|
||||
return new ServerList<Server>() {
|
||||
@Override
|
||||
public List<Server> getInitialListOfServers() {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Server> getUpdatedListOfServers() {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,115 +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.contract.stubrunner.spring.cloud.ribbon;
|
||||
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.netflix.client.config.IClientConfig;
|
||||
import com.netflix.loadbalancer.Server;
|
||||
import com.netflix.loadbalancer.ServerList;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.cloud.contract.stubrunner.RunningStubs;
|
||||
import org.springframework.cloud.contract.stubrunner.StubConfiguration;
|
||||
import org.springframework.cloud.contract.stubrunner.StubFinder;
|
||||
import org.springframework.cloud.contract.stubrunner.spring.cloud.StubMapperProperties;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Stub Runner representation of a server list.
|
||||
*
|
||||
* @author Marcin Grzejszczak
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class StubRunnerRibbonServerList implements ServerList<Server> {
|
||||
|
||||
private static final Log log = LogFactory
|
||||
.getLog(MethodHandles.lookup().lookupClass());
|
||||
|
||||
private final ServerList<Server> serverList;
|
||||
|
||||
StubRunnerRibbonServerList(final StubFinder stubFinder,
|
||||
final StubMapperProperties stubMapperProperties,
|
||||
final IClientConfig clientConfig) {
|
||||
String serviceName = clientConfig.getClientName();
|
||||
String mappedServiceName = StringUtils
|
||||
.hasText(stubMapperProperties.fromServiceIdToIvyNotation(serviceName))
|
||||
? stubMapperProperties.fromServiceIdToIvyNotation(serviceName)
|
||||
: serviceName;
|
||||
RunningStubs runningStubs = stubFinder.findAllRunningStubs();
|
||||
final Map.Entry<StubConfiguration, Integer> entry = runningStubs
|
||||
.getEntry(mappedServiceName);
|
||||
final List<Server> servers = new ArrayList<>();
|
||||
if (entry != null) {
|
||||
servers.add(new Server("localhost", entry.getValue()) {
|
||||
@Override
|
||||
public MetaInfo getMetaInfo() {
|
||||
return new MetaInfo() {
|
||||
@Override
|
||||
public String getAppName() {
|
||||
return stubMapperProperties.fromIvyNotationToId(
|
||||
entry.getKey().toColonSeparatedDependencyNotation());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getServerGroup() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getServiceIdForDiscovery() {
|
||||
return stubMapperProperties
|
||||
.fromIvyNotationToId(entry.getKey().getArtifactId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInstanceId() {
|
||||
return stubMapperProperties
|
||||
.fromIvyNotationToId(entry.getKey().getArtifactId());
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
}
|
||||
this.serverList = new ServerList<Server>() {
|
||||
@Override
|
||||
public List<Server> getInitialListOfServers() {
|
||||
return servers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Server> getUpdatedListOfServers() {
|
||||
return servers;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Server> getInitialListOfServers() {
|
||||
return this.serverList.getInitialListOfServers();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Server> getUpdatedListOfServers() {
|
||||
return this.serverList.getUpdatedListOfServers();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,7 +2,6 @@
|
||||
org.springframework.cloud.contract.stubrunner.spring.AutoConfigureStubRunner=\
|
||||
org.springframework.cloud.contract.stubrunner.spring.StubRunnerConfiguration,\
|
||||
org.springframework.cloud.contract.stubrunner.spring.cloud.StubRunnerSpringCloudAutoConfiguration,\
|
||||
org.springframework.cloud.contract.stubrunner.spring.cloud.ribbon.StubRunnerRibbonAutoConfiguration,\
|
||||
org.springframework.cloud.contract.stubrunner.messaging.integration.StubRunnerIntegrationConfiguration,\
|
||||
org.springframework.cloud.contract.stubrunner.messaging.jms.StubRunnerJmsConfiguration,\
|
||||
org.springframework.cloud.contract.stubrunner.messaging.stream.StubRunnerStreamConfiguration,\
|
||||
|
||||
@@ -21,7 +21,7 @@ import com.github.tomakehurst.wiremock.stubbing.StubMapping
|
||||
import org.junit.Rule
|
||||
import spock.lang.Specification
|
||||
|
||||
import org.springframework.boot.test.rule.OutputCapture
|
||||
import org.springframework.boot.test.system.OutputCaptureRule
|
||||
import org.springframework.boot.test.web.client.TestRestTemplate
|
||||
import org.springframework.web.client.RestTemplate
|
||||
|
||||
@@ -30,7 +30,7 @@ class WireMockHttpServerStubSpec extends Specification {
|
||||
final File MAPPING_DESCRIPTOR = new File('src/test/resources/transformers.json')
|
||||
|
||||
@Rule
|
||||
OutputCapture capture = new OutputCapture()
|
||||
OutputCaptureRule capture = new OutputCaptureRule()
|
||||
|
||||
def 'should describe stub mapping'() {
|
||||
given:
|
||||
|
||||
@@ -22,7 +22,6 @@ import spock.lang.Specification
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration
|
||||
import org.springframework.boot.test.context.SpringBootContextLoader
|
||||
import org.springframework.cloud.client.loadbalancer.LoadBalanced
|
||||
import org.springframework.cloud.consul.ConsulAutoConfiguration
|
||||
import org.springframework.cloud.contract.stubrunner.StubFinder
|
||||
@@ -30,7 +29,6 @@ import org.springframework.cloud.contract.stubrunner.spring.AutoConfigureStubRun
|
||||
import org.springframework.cloud.contract.stubrunner.spring.StubRunnerProperties
|
||||
import org.springframework.cloud.netflix.eureka.EurekaClientAutoConfiguration
|
||||
import org.springframework.cloud.zookeeper.ZookeeperAutoConfiguration
|
||||
import org.springframework.cloud.zookeeper.discovery.RibbonZookeeperAutoConfiguration
|
||||
import org.springframework.context.annotation.Bean
|
||||
import org.springframework.context.annotation.Configuration
|
||||
import org.springframework.test.context.ActiveProfiles
|
||||
@@ -41,51 +39,51 @@ import org.springframework.web.client.RestTemplate
|
||||
* @author Marcin Grzejszczak
|
||||
*/
|
||||
//TODO: Document that ribbon.eureka.enabled=false needs to be set or override it somehow
|
||||
@ContextConfiguration(classes = Config, loader = SpringBootContextLoader)
|
||||
@ActiveProfiles("cloudtest")
|
||||
// tag::autoconfigure[]
|
||||
@AutoConfigureStubRunner(
|
||||
ids = ["org.springframework.cloud.contract.verifier.stubs:loanIssuance",
|
||||
"org.springframework.cloud.contract.verifier.stubs:fraudDetectionServer",
|
||||
"org.springframework.cloud.contract.verifier.stubs:bootService"],
|
||||
stubsMode = StubRunnerProperties.StubsMode.REMOTE,
|
||||
repositoryRoot = "classpath:m2repo/repository/")
|
||||
// end::autoconfigure[]
|
||||
class StubRunnerSpringCloudAutoConfigurationSpec extends Specification {
|
||||
|
||||
@Autowired
|
||||
StubFinder stubFinder
|
||||
@Autowired
|
||||
@LoadBalanced
|
||||
RestTemplate restTemplate
|
||||
|
||||
@BeforeClass
|
||||
@AfterClass
|
||||
static void setupProps() {
|
||||
System.clearProperty("stubrunner.repository.root")
|
||||
System.clearProperty("stubrunner.classifier")
|
||||
}
|
||||
|
||||
// tag::test[]
|
||||
def 'should make service discovery work'() {
|
||||
expect: 'WireMocks are running'
|
||||
"${stubFinder.findStubUrl('loanIssuance').toString()}/name".toURL().text == 'loanIssuance'
|
||||
"${stubFinder.findStubUrl('fraudDetectionServer').toString()}/name".toURL().text == 'fraudDetectionServer'
|
||||
and: 'Stubs can be reached via load service discovery'
|
||||
restTemplate.getForObject('http://loanIssuance/name', String) == 'loanIssuance'
|
||||
restTemplate.getForObject('http://someNameThatShouldMapFraudDetectionServer/name', String) == 'fraudDetectionServer'
|
||||
}
|
||||
// end::test[]
|
||||
|
||||
@Configuration
|
||||
@EnableAutoConfiguration(exclude = [RibbonZookeeperAutoConfiguration, EurekaClientAutoConfiguration,
|
||||
ConsulAutoConfiguration, ZookeeperAutoConfiguration])
|
||||
static class Config {
|
||||
|
||||
@Bean
|
||||
@LoadBalanced
|
||||
RestTemplate restTemplate() {
|
||||
return new RestTemplate()
|
||||
}
|
||||
}
|
||||
}
|
||||
//@ContextConfiguration(classes = Config, loader = SpringBootContextLoader)
|
||||
//@ActiveProfiles("cloudtest")
|
||||
//// tag::autoconfigure[]
|
||||
//@AutoConfigureStubRunner(
|
||||
// ids = ["org.springframework.cloud.contract.verifier.stubs:loanIssuance",
|
||||
// "org.springframework.cloud.contract.verifier.stubs:fraudDetectionServer",
|
||||
// "org.springframework.cloud.contract.verifier.stubs:bootService"],
|
||||
// stubsMode = StubRunnerProperties.StubsMode.REMOTE,
|
||||
// repositoryRoot = "classpath:m2repo/repository/")
|
||||
//// end::autoconfigure[]
|
||||
//class StubRunnerSpringCloudAutoConfigurationSpec extends Specification {
|
||||
//
|
||||
// @Autowired
|
||||
// StubFinder stubFinder
|
||||
// @Autowired
|
||||
// @LoadBalanced
|
||||
// RestTemplate restTemplate
|
||||
//
|
||||
// @BeforeClass
|
||||
// @AfterClass
|
||||
// static void setupProps() {
|
||||
// System.clearProperty("stubrunner.repository.root")
|
||||
// System.clearProperty("stubrunner.classifier")
|
||||
// }
|
||||
//
|
||||
// // tag::test[]
|
||||
// def 'should make service discovery work'() {
|
||||
// expect: 'WireMocks are running'
|
||||
// "${stubFinder.findStubUrl('loanIssuance').toString()}/name".toURL().text == 'loanIssuance'
|
||||
// "${stubFinder.findStubUrl('fraudDetectionServer').toString()}/name".toURL().text == 'fraudDetectionServer'
|
||||
// and: 'Stubs can be reached via load service discovery'
|
||||
// restTemplate.getForObject('http://loanIssuance/name', String) == 'loanIssuance'
|
||||
// restTemplate.getForObject('http://someNameThatShouldMapFraudDetectionServer/name', String) == 'fraudDetectionServer'
|
||||
// }
|
||||
// // end::test[]
|
||||
//
|
||||
// @Configuration
|
||||
// @EnableAutoConfiguration(exclude = [EurekaClientAutoConfiguration,
|
||||
// ConsulAutoConfiguration, ZookeeperAutoConfiguration])
|
||||
// static class Config {
|
||||
//
|
||||
// @Bean
|
||||
// @LoadBalanced
|
||||
// RestTemplate restTemplate() {
|
||||
// return new RestTemplate()
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
@@ -27,7 +27,7 @@ import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.boot.test.rule.OutputCapture;
|
||||
import org.springframework.boot.test.system.OutputCaptureRule;
|
||||
import org.springframework.cloud.contract.stubrunner.spring.StubRunnerProperties;
|
||||
|
||||
import static org.assertj.core.api.BDDAssertions.then;
|
||||
@@ -38,7 +38,7 @@ import static org.assertj.core.api.BDDAssertions.then;
|
||||
public class ContractProjectUpdaterTest extends AbstractGitTest {
|
||||
|
||||
@Rule
|
||||
public OutputCapture outputCapture = new OutputCapture();
|
||||
public OutputCaptureRule outputCapture = new OutputCaptureRule();
|
||||
|
||||
File originalProject;
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@ import org.mockito.ArgumentMatchers;
|
||||
import org.springframework.amqp.core.Message;
|
||||
import org.springframework.amqp.core.MessageListener;
|
||||
import org.springframework.amqp.core.MessagePropertiesBuilder;
|
||||
import org.springframework.amqp.rabbit.connection.CachingConnectionFactory;
|
||||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||
import org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer;
|
||||
import org.springframework.amqp.rabbit.listener.api.ChannelAwareMessageListener;
|
||||
@@ -171,7 +172,9 @@ public class SpringAmqpStubMessages implements MessageVerifier<Message> {
|
||||
// backward compatibility
|
||||
return true;
|
||||
}
|
||||
return !this.rabbitProperties.isPublisherConfirms();
|
||||
return this.rabbitProperties.getPublisherConfirmType() == null
|
||||
|| this.rabbitProperties
|
||||
.getPublisherConfirmType() == CachingConnectionFactory.ConfirmType.NONE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -17,13 +17,12 @@
|
||||
|
||||
package org.springframework.cloud.contract.verifier.builder
|
||||
|
||||
|
||||
import org.junit.Rule
|
||||
import spock.lang.Issue
|
||||
import spock.lang.Shared
|
||||
import spock.lang.Specification
|
||||
|
||||
import org.springframework.boot.test.rule.OutputCapture
|
||||
import org.springframework.boot.test.system.OutputCaptureRule
|
||||
import org.springframework.cloud.contract.spec.Contract
|
||||
import org.springframework.cloud.contract.verifier.config.ContractVerifierConfigProperties
|
||||
import org.springframework.cloud.contract.verifier.config.TestFramework
|
||||
@@ -37,7 +36,7 @@ import org.springframework.cloud.contract.verifier.util.SyntaxChecker
|
||||
class MethodBodyBuilderSpec extends Specification implements WireMockStubVerifier {
|
||||
|
||||
@Rule
|
||||
OutputCapture capture = new OutputCapture()
|
||||
OutputCaptureRule capture = new OutputCaptureRule()
|
||||
|
||||
@Shared
|
||||
ContractVerifierConfigProperties properties = new ContractVerifierConfigProperties(
|
||||
|
||||
@@ -22,7 +22,7 @@ import spock.lang.Issue
|
||||
import spock.lang.Shared
|
||||
import spock.lang.Specification
|
||||
|
||||
import org.springframework.boot.test.rule.OutputCapture
|
||||
import org.springframework.boot.test.system.OutputCaptureRule
|
||||
import org.springframework.cloud.contract.spec.Contract
|
||||
import org.springframework.cloud.contract.verifier.config.ContractVerifierConfigProperties
|
||||
import org.springframework.cloud.contract.verifier.config.TestFramework
|
||||
@@ -34,7 +34,7 @@ import org.springframework.cloud.contract.verifier.util.SyntaxChecker
|
||||
class MockMvcMethodBodyBuilderWithMatchersSpec extends Specification implements WireMockStubVerifier {
|
||||
|
||||
@Rule
|
||||
OutputCapture outputCapture = new OutputCapture()
|
||||
OutputCaptureRule outputCapture = new OutputCaptureRule()
|
||||
|
||||
@Shared
|
||||
ContractVerifierConfigProperties properties = new ContractVerifierConfigProperties(
|
||||
|
||||
@@ -24,7 +24,7 @@ import spock.lang.Shared
|
||||
import spock.lang.Specification
|
||||
import spock.util.environment.RestoreSystemProperties
|
||||
|
||||
import org.springframework.boot.test.rule.OutputCapture
|
||||
import org.springframework.boot.test.system.OutputCaptureRule
|
||||
import org.springframework.cloud.contract.spec.Contract
|
||||
import org.springframework.cloud.contract.verifier.config.ContractVerifierConfigProperties
|
||||
import org.springframework.cloud.contract.verifier.config.TestFramework
|
||||
@@ -32,6 +32,7 @@ import org.springframework.cloud.contract.verifier.config.TestMode
|
||||
import org.springframework.cloud.contract.verifier.dsl.wiremock.WireMockStubVerifier
|
||||
import org.springframework.cloud.contract.verifier.file.ContractMetadata
|
||||
import org.springframework.cloud.contract.verifier.util.SyntaxChecker
|
||||
|
||||
/**
|
||||
* @author Jakub Kubrynski, codearte.io
|
||||
* @author Tim Ysewyn
|
||||
@@ -39,7 +40,7 @@ import org.springframework.cloud.contract.verifier.util.SyntaxChecker
|
||||
class SpringTestMethodBodyBuildersSpec extends Specification implements WireMockStubVerifier {
|
||||
|
||||
@Rule
|
||||
OutputCapture capture = new OutputCapture()
|
||||
OutputCaptureRule capture = new OutputCaptureRule()
|
||||
|
||||
@Shared
|
||||
ContractVerifierConfigProperties properties = new ContractVerifierConfigProperties(
|
||||
|
||||
@@ -21,7 +21,7 @@ import spock.lang.Shared
|
||||
import spock.lang.Specification
|
||||
import spock.lang.Unroll
|
||||
|
||||
import org.springframework.boot.test.rule.OutputCapture
|
||||
import org.springframework.boot.test.system.OutputCaptureRule
|
||||
import org.springframework.cloud.contract.spec.Contract
|
||||
import org.springframework.cloud.contract.verifier.config.ContractVerifierConfigProperties
|
||||
import org.springframework.cloud.contract.verifier.config.TestFramework
|
||||
@@ -36,7 +36,7 @@ import org.springframework.cloud.contract.verifier.util.SyntaxChecker
|
||||
class XmlMethodBodyBuilderSpec extends Specification {
|
||||
|
||||
@Rule
|
||||
OutputCapture capture = new OutputCapture()
|
||||
OutputCaptureRule capture = new OutputCaptureRule()
|
||||
|
||||
@Shared
|
||||
ContractVerifierConfigProperties properties = new ContractVerifierConfigProperties(
|
||||
|
||||
@@ -16,14 +16,13 @@
|
||||
|
||||
package org.springframework.cloud.contract.verifier.builder
|
||||
|
||||
|
||||
import org.junit.Rule
|
||||
import spock.lang.Issue
|
||||
import spock.lang.Shared
|
||||
import spock.lang.Specification
|
||||
import spock.util.environment.RestoreSystemProperties
|
||||
|
||||
import org.springframework.boot.test.rule.OutputCapture
|
||||
import org.springframework.boot.test.system.OutputCaptureRule
|
||||
import org.springframework.cloud.contract.spec.Contract
|
||||
import org.springframework.cloud.contract.verifier.config.ContractVerifierConfigProperties
|
||||
import org.springframework.cloud.contract.verifier.config.TestFramework
|
||||
@@ -40,7 +39,7 @@ import org.springframework.cloud.contract.verifier.util.SyntaxChecker
|
||||
class YamlMockMvcMethodBodyBuilderSpec extends Specification implements WireMockStubVerifier {
|
||||
|
||||
@Rule
|
||||
OutputCapture capture = new OutputCapture()
|
||||
OutputCaptureRule capture = new OutputCaptureRule()
|
||||
|
||||
@Shared
|
||||
ContractVerifierConfigProperties properties = new ContractVerifierConfigProperties(
|
||||
|
||||
@@ -27,6 +27,7 @@ import org.springframework.amqp.core.DirectExchange
|
||||
import org.springframework.amqp.core.Message
|
||||
import org.springframework.amqp.core.MessageProperties
|
||||
import org.springframework.amqp.core.Queue
|
||||
import org.springframework.amqp.rabbit.connection.CachingConnectionFactory
|
||||
import org.springframework.amqp.rabbit.core.RabbitTemplate
|
||||
import org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer
|
||||
import org.springframework.amqp.rabbit.listener.adapter.MessageListenerAdapter
|
||||
@@ -78,7 +79,7 @@ class SpringAmqpStubMessagesSpec extends Specification {
|
||||
|
||||
def "should send amqp message for non transactional channel"() {
|
||||
given:
|
||||
rabbitProperties.setPublisherConfirms(true)
|
||||
rabbitProperties.setPublisherConfirmType(CachingConnectionFactory.ConfirmType.SIMPLE)
|
||||
listenerContainer.setMessageListener(messageListenerAdapter)
|
||||
listenerContainer.setQueueNames(queueName)
|
||||
Binding binding = BindingBuilder.bind(new Queue(queueName)).to(new DirectExchange(exchange)).with(routingKey)
|
||||
@@ -114,7 +115,7 @@ class SpringAmqpStubMessagesSpec extends Specification {
|
||||
|
||||
def "should send amqp message for transactional channel"() {
|
||||
given:
|
||||
rabbitProperties.setPublisherConfirms(false)
|
||||
rabbitProperties.setPublisherConfirmType(CachingConnectionFactory.ConfirmType.NONE)
|
||||
listenerContainer.setMessageListener(messageListenerAdapter)
|
||||
listenerContainer.setQueueNames(queueName)
|
||||
Binding binding = BindingBuilder.bind(new Queue(queueName)).to(new DirectExchange(exchange)).with(routingKey)
|
||||
|
||||
@@ -18,6 +18,10 @@
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-json</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-amqp</artifactId>
|
||||
|
||||
Reference in New Issue
Block a user