Merge branch '2.1.x'

This commit is contained in:
Marcin Grzejszczak
2019-04-23 12:37:01 +04:00
10 changed files with 65 additions and 18 deletions

View File

@@ -48,6 +48,8 @@
<junit-platform.version>1.3.2</junit-platform.version>
<junit-vintage.version>5.4.2</junit-vintage.version>
<junit-jupiter.version>5.4.2</junit-jupiter.version>
<maven-surefire-plugin.version>3.0.0-M3</maven-surefire-plugin.version>
<gmavenplus-plugin.version>1.6.3</gmavenplus-plugin.version>
<!-- We need to have compatibility with Gradle -->
<groovy.version>2.4.16</groovy.version>
@@ -484,6 +486,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-plugin.version}</version>
<configuration>
<includes>
<include>**/*Spec.*</include>
@@ -497,7 +500,7 @@
<plugin>
<groupId>org.codehaus.gmavenplus</groupId>
<artifactId>gmavenplus-plugin</artifactId>
<version>1.6.2</version>
<version>${gmavenplus-plugin.version}</version>
<executions>
<execution>
<goals>

View File

@@ -192,6 +192,8 @@
</outputDirectory>
</artifactItem>
</artifactItems>
<includes>**/shaded/**/*.*,**/org/eclipse/**/*.*,**/org/codehaus/plexus/**/*.*
</includes>
</configuration>
</execution>
</executions>
@@ -224,4 +226,27 @@
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>ide</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<dependencies>
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>15.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
<version>1.3.9</version>
<scope>compile</scope>
</dependency>
</dependencies>
</profile>
</profiles>
</project>

View File

@@ -190,24 +190,23 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<dependencies>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-surefire-provider</artifactId>
<version>${junit-platform.version}</version>
</dependency>
<!-- let JUnit vintage engine run JUnit 3 or JUnit 4 tests -->
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<version>${junit-vintage.version}</version>
</dependency>
<!-- let JUnit 5 engine run JUnit 5 tests -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit-jupiter.version}</version>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<version>${junit-vintage.version}</version>
</dependency>
</dependencies>
<configuration>
<junitPlatformArtifactName>
org.junit.jupiter:junit-vintage-engine
</junitPlatformArtifactName>
</configuration>
</plugin>
</plugins>
</build>

View File

@@ -170,6 +170,7 @@ public class StubRunnerOptions {
.withDeleteStubsAfterTest(Boolean.parseBoolean(
System.getProperty("stubrunner.delete-stubs-after-test", "true")))
.withProperties(stubRunnerProps());
builder = httpStubConfigurer(builder);
String proxyHost = System.getProperty("stubrunner.proxy.host");
if (proxyHost != null) {
builder.withProxy(proxyHost,
@@ -178,6 +179,21 @@ public class StubRunnerOptions {
return builder.build();
}
private static StubRunnerOptionsBuilder httpStubConfigurer(
StubRunnerOptionsBuilder builder) {
String classProperty = System.getProperty(
"stubrunner.http-server-stub-configurer",
HttpServerStubConfigurer.NoOpHttpServerStubConfigurer.class.getName());
try {
Class clazz = Class.forName(classProperty);
return builder.withHttpServerStubConfigurer(clazz);
}
catch (ClassNotFoundException ex) {
throw new IllegalStateException("Class [" + classProperty + "] not found",
ex);
}
}
private static Map<String, String> stubRunnerProps() {
Map<String, String> map = new HashMap<>();
Properties properties = System.getProperties();

View File

@@ -195,6 +195,7 @@ public class StubRunnerOptionsBuilder {
? options.stubIdsToPortMapping : new LinkedHashMap<>();
this.deleteStubsAfterTest = options.isDeleteStubsAfterTest();
this.properties = options.getProperties();
this.httpServerStubConfigurer = options.getHttpServerStubConfigurer();
return this;
}

View File

@@ -158,8 +158,9 @@ class StubRunnerStreamMessageSelector implements MessageSelector {
BodyMatchers matchers = groovyDsl.getInput().getBodyMatchers();
matches = matchesForJsonPayload(groovyDsl, inputMessage, matchers, dslBody);
}
else if (dslBody instanceof RegexProperty && inputMessage instanceof String) {
Pattern pattern = ((RegexProperty) dslBody).getPattern();
else if ((dslBody instanceof RegexProperty || dslBody instanceof Pattern)
&& inputMessage instanceof String) {
Pattern pattern = new RegexProperty(dslBody).getPattern();
matches = pattern.matcher((String) inputMessage).matches();
bodyUnmatchedLog(dslBody, matches, pattern);
}

View File

@@ -290,7 +290,7 @@ class StubRunnerOptionsBuilderSpec extends Specification {
System.setProperty("stubrunner.properties.foo-bar", "bar")
System.setProperty("stubrunner.properties.foo-baz", "baz")
System.setProperty("stubrunner.properties.bar.bar", "foo")
System.setProperty("stubrunner.httpServerStubConfigurer", "org.springframework.cloud.contract.stubrunner.Foo")
System.setProperty("stubrunner.http-server-stub-configurer", "org.springframework.cloud.contract.stubrunner.Foo")
when:
StubRunnerOptions options = StubRunnerOptions.fromSystemProps()
then:

View File

@@ -31,7 +31,7 @@ class StubServerSpec extends Specification {
given:
List<File> mappingDescriptors = new StubRepository(repository).getStubs()
StubServer pingStubServer = new StubServer(stubConfiguration, mappingDescriptors, [],
new WireMockHttpServerStub()).start(STUB_SERVER_PORT)
new WireMockHttpServerStub()).start(new HttpServerStubConfiguration(new HttpServerStubConfigurer.NoOpHttpServerStubConfigurer(), StubRunnerOptions.fromSystemProps(), new StubConfiguration("a:b:c:d"), STUB_SERVER_PORT))
when:
pingStubServer.start()
then:
@@ -43,7 +43,7 @@ class StubServerSpec extends Specification {
given:
List<File> mappingDescriptors = new StubRepository(repository).getStubs()
StubServer pingStubServer = new StubServer(stubConfiguration, mappingDescriptors, [],
new WireMockHttpServerStub()).start(STUB_SERVER_PORT)
new WireMockHttpServerStub()).start(new HttpServerStubConfiguration(new HttpServerStubConfigurer.NoOpHttpServerStubConfigurer(), StubRunnerOptions.fromSystemProps(), new StubConfiguration("a:b:c:d"), STUB_SERVER_PORT))
when:
pingStubServer.start()
then:

View File

@@ -92,7 +92,7 @@ public class GitRepoTests extends AbstractGitTest {
fail("should throw an exception");
}
catch (IllegalStateException e) {
then(e).hasMessageContaining("Ref nonExistingBranch can not be resolved");
then(e).hasMessageContaining("Ref nonExistingBranch cannot be resolved");
}
}

View File

@@ -17,6 +17,7 @@
package org.springframework.cloud.contract.verifier.messaging.stream;
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
@@ -40,6 +41,7 @@ import org.springframework.util.Assert;
@ConditionalOnProperty(name = "stubrunner.stream.enabled", havingValue = "true",
matchIfMissing = true)
@AutoConfigureBefore(NoOpContractVerifierAutoConfiguration.class)
@ConditionalOnBean(MessageCollector.class)
public class ContractVerifierStreamAutoConfiguration {
@Bean