Migrated to non snapshot versions for classpath tests
This commit is contained in:
@@ -12,16 +12,21 @@
|
|||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<name>spring-cloud-contract-wiremock</name>
|
<name>spring-cloud-contract-wiremock</name>
|
||||||
<description>Spring Cloud Contract Wiremock</description>
|
<description>Spring Cloud Contract Wiremock</description>
|
||||||
|
<repositories>
|
||||||
|
<repository>
|
||||||
|
<id>spring-milestones</id>
|
||||||
|
<name>Spring Milestones</name>
|
||||||
|
<url>https://repo.spring.io/libs-milestone-local</url>
|
||||||
|
<snapshots>
|
||||||
|
<enabled>false</enabled>
|
||||||
|
</snapshots>
|
||||||
|
</repository>
|
||||||
|
</repositories>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.tomakehurst</groupId>
|
<groupId>com.github.tomakehurst</groupId>
|
||||||
<artifactId>wiremock-standalone</artifactId>
|
<artifactId>wiremock-standalone</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.httpcomponents</groupId>
|
|
||||||
<artifactId>httpclient</artifactId>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.rest-assured</groupId>
|
<groupId>io.rest-assured</groupId>
|
||||||
<artifactId>rest-assured</artifactId>
|
<artifactId>rest-assured</artifactId>
|
||||||
@@ -94,13 +99,11 @@
|
|||||||
<artifactId>spring-cloud-contract-verifier</artifactId>
|
<artifactId>spring-cloud-contract-verifier</artifactId>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- TODO: We had to remove any dependencies that contain snaps versions.
|
<dependency>
|
||||||
We have to figure out how to solve this (maybe release a RELEASE version for tests) -->
|
<groupId>com.example.github</groupId>
|
||||||
<!--<dependency>
|
<artifactId>github-webhook</artifactId>
|
||||||
<groupId>sagan</groupId>
|
|
||||||
<artifactId>sagan-site</artifactId>
|
|
||||||
<classifier>stubs</classifier>
|
<classifier>stubs</classifier>
|
||||||
<version>1.0.0.BUILD-SNAP...</version>
|
<version>1.0.0.M1-190120_193303-VERSION</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
<exclusions>
|
<exclusions>
|
||||||
<exclusion>
|
<exclusion>
|
||||||
@@ -111,9 +114,9 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.example.github</groupId>
|
<groupId>com.example.github</groupId>
|
||||||
<artifactId>github-webhook</artifactId>
|
<artifactId>github-analytics</artifactId>
|
||||||
<classifier>stubs</classifier>
|
<classifier>stubs</classifier>
|
||||||
<version>0.0.1-SNAP...</version>
|
<version>1.0.0.M1-190120_105104-VERSION</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
<exclusions>
|
<exclusions>
|
||||||
<exclusion>
|
<exclusion>
|
||||||
@@ -121,6 +124,6 @@
|
|||||||
<artifactId>*</artifactId>
|
<artifactId>*</artifactId>
|
||||||
</exclusion>
|
</exclusion>
|
||||||
</exclusions>
|
</exclusions>
|
||||||
</dependency>-->
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
@@ -17,173 +17,48 @@
|
|||||||
|
|
||||||
package org.springframework.cloud.contract.wiremock;
|
package org.springframework.cloud.contract.wiremock;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import org.assertj.core.api.BDDAssertions;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
|
||||||
import org.junit.Ignore;
|
|
||||||
import org.junit.Test;
|
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.beans.factory.annotation.Value;
|
||||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
import org.springframework.web.client.RestTemplate;
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
import static org.assertj.core.api.BDDAssertions.then;
|
@RunWith(SpringRunner.class)
|
||||||
|
@SpringBootTest(classes = AutoConfigureWireMockFilesApplicationWithUrlResourceTests.Config.class,
|
||||||
//@RunWith(SpringRunner.class)
|
properties = "app.baseUrl=http://localhost:${wiremock.server.port}",
|
||||||
//@SpringBootTest(classes = AutoConfigureWireMockFilesApplicationWithUrlResourceTests.Config.class,
|
webEnvironment = SpringBootTest.WebEnvironment.NONE)
|
||||||
// properties = "app.baseUrl=http://localhost:${wiremock.server.port}",
|
|
||||||
// webEnvironment = WebEnvironment.NONE)
|
|
||||||
// tag::load_all_stubs[]
|
// tag::load_all_stubs[]
|
||||||
@AutoConfigureWireMock(port = 0, stubs = "classpath*:/META-INF/**/mappings/**/*.json")
|
@AutoConfigureWireMock(port = 0, stubs = "classpath*:/META-INF/**/mappings/**/*.json")
|
||||||
// end::load_all_stubs[]
|
// end::load_all_stubs[]
|
||||||
// Ignore for a GA Release
|
|
||||||
@Ignore
|
|
||||||
public class AutoConfigureWireMockFilesApplicationWithUrlResourceTests {
|
public class AutoConfigureWireMockFilesApplicationWithUrlResourceTests {
|
||||||
|
|
||||||
@Autowired
|
@Value("${wiremock.server.port}")
|
||||||
private RestTemplateSaganClient client;
|
int wiremockPort;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void contextLoads() throws Exception {
|
public void should_work_for_analytics() throws Exception {
|
||||||
Release release = this.client.getRelease("spring-framework", "5.0.0.RC4");
|
String count =
|
||||||
|
new RestTemplate().getForObject("http://localhost:" + this.wiremockPort + "/issues/count", String.class);
|
||||||
|
|
||||||
then(release.releaseStatus).isEqualTo("PRERELEASE");
|
BDDAssertions.then(count).isEqualTo("5");
|
||||||
then(release.refDocUrl).isEqualTo("http://docs.spring.io/spring/docs/{version}/spring-framework-reference/");
|
}
|
||||||
then(release.apiDocUrl).isEqualTo("http://docs.spring.io/spring/docs/{version}/javadoc-api/");
|
|
||||||
then(release.groupId).isEqualTo("org.springframework");
|
@Test
|
||||||
then(release.artifactId).isEqualTo("spring-context");
|
public void should_work_for_webhook() throws Exception {
|
||||||
then(release.repository.id).isEqualTo("spring-milestones");
|
String response =
|
||||||
then(release.repository.name).isEqualTo("Spring Milestones");
|
new RestTemplate().getForObject("http://localhost:" + this.wiremockPort + "/", String.class);
|
||||||
then(release.repository.url).isEqualTo("https://repo.spring.io/libs-milestone");
|
|
||||||
then(release.repository.snapshotsEnabled).isFalse();
|
BDDAssertions.then(response).contains("spring-cloud/spring-cloud-netflix");
|
||||||
then(release.version).isEqualTo("5.0.0.RC4");
|
|
||||||
then(release.current).isFalse();
|
|
||||||
then(release.generalAvailability).isFalse();
|
|
||||||
then(release.preRelease).isTrue();
|
|
||||||
then(release.versionDisplayName).isEqualTo("5.0.0 RC4");
|
|
||||||
then(release.snapshot).isFalse();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@EnableAutoConfiguration
|
@EnableAutoConfiguration
|
||||||
static class Config {
|
static class Config {
|
||||||
@Bean
|
|
||||||
RestTemplateSaganClient restTemplateSaganClient(@Value("${app.baseUrl}") String url) {
|
|
||||||
return new RestTemplateSaganClient(new RestTemplate(), url);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Marcin Grzejszczak
|
|
||||||
*/
|
|
||||||
class RestTemplateSaganClient {
|
|
||||||
|
|
||||||
private final RestTemplate restTemplate;
|
|
||||||
private final String baseUrl;
|
|
||||||
|
|
||||||
RestTemplateSaganClient(RestTemplate restTemplate, String url) {
|
|
||||||
this.restTemplate = restTemplate;
|
|
||||||
this.baseUrl = url;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Release getRelease(String projectName, String releaseVersion) {
|
|
||||||
return this.restTemplate.getForObject(this.baseUrl + "/project_metadata/{projectName}/releases/{releaseVersion}", Release.class, projectName, releaseVersion);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Marcin Grzejszczak
|
|
||||||
*/
|
|
||||||
@JsonInclude(value = JsonInclude.Include.NON_NULL)
|
|
||||||
class Project {
|
|
||||||
public String id = "";
|
|
||||||
public String name = "";
|
|
||||||
public String repoUrl = "";
|
|
||||||
public String siteUrl = "";
|
|
||||||
public String category = "";
|
|
||||||
public String stackOverflowTags;
|
|
||||||
public List<Release> projectReleases = new ArrayList<>();
|
|
||||||
public List<String> stackOverflowTagList = new ArrayList<>();
|
|
||||||
public Boolean aggregator;
|
|
||||||
|
|
||||||
@Override public String toString() {
|
|
||||||
return "Project{" + "id='" + this.id + '\'' + ", name='" + this.name + '\'' + ", repoUrl='"
|
|
||||||
+ this.repoUrl + '\'' + ", siteUrl='" + this.siteUrl + '\'' + ", category='"
|
|
||||||
+ this.category + '\'' + ", stackOverflowTags='" + this.stackOverflowTags + '\''
|
|
||||||
+ ", projectReleases=" + this.projectReleases + ", stackOverflowTagList="
|
|
||||||
+ this.stackOverflowTagList + ", aggregator=" + this.aggregator + '}';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Marcin Grzejszczak
|
|
||||||
*/
|
|
||||||
@JsonInclude(value = JsonInclude.Include.NON_NULL)
|
|
||||||
class Release {
|
|
||||||
public String releaseStatus = "";
|
|
||||||
public String refDocUrl = "";
|
|
||||||
public String apiDocUrl = "";
|
|
||||||
public String groupId = "";
|
|
||||||
public String artifactId = "";
|
|
||||||
public Repository repository;
|
|
||||||
public String version = "";
|
|
||||||
public boolean current;
|
|
||||||
public boolean generalAvailability;
|
|
||||||
public boolean preRelease;
|
|
||||||
public String versionDisplayName = "";
|
|
||||||
public boolean snapshot;
|
|
||||||
|
|
||||||
@Override public String toString() {
|
|
||||||
return "Release{" + "releaseStatus='" + this.releaseStatus + '\'' + ", refDocUrl='"
|
|
||||||
+ this.refDocUrl + '\'' + ", apiDocUrl='" + this.apiDocUrl + '\'' + ", groupId='"
|
|
||||||
+ this.groupId + '\'' + ", artifactId='" + this.artifactId + '\'' + ", repository="
|
|
||||||
+ this.repository + ", version='" + this.version + '\'' + ", current=" + this.current
|
|
||||||
+ ", generalAvailability=" + this.generalAvailability + ", preRelease="
|
|
||||||
+ this.preRelease + ", versionDisplayName='" + this.versionDisplayName + '\''
|
|
||||||
+ ", snapshot=" + this.snapshot + '}';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Marcin Grzejszczak
|
|
||||||
*/
|
|
||||||
@JsonInclude(value = JsonInclude.Include.NON_NULL)
|
|
||||||
class ReleaseUpdate {
|
|
||||||
public String groupId = "";
|
|
||||||
public String artifactId = "";
|
|
||||||
public String version = "";
|
|
||||||
public String releaseStatus = "";
|
|
||||||
public String refDocUrl = "";
|
|
||||||
public String apiDocUrl = "";
|
|
||||||
public Boolean current;
|
|
||||||
public Repository repository;
|
|
||||||
|
|
||||||
@Override public String toString() {
|
|
||||||
return "ReleaseUpdate{" + "groupId='" + this.groupId + '\'' + ", artifactId='"
|
|
||||||
+ this.artifactId + '\'' + ", version='" + this.version + '\'' + ", releaseStatus='"
|
|
||||||
+ this.releaseStatus + '\'' + ", refDocUrl='" + this.refDocUrl + '\''
|
|
||||||
+ ", apiDocUrl='" + this.apiDocUrl + '\'' + ", repository=" + this.repository + '}';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Marcin Grzejszczak
|
|
||||||
*/
|
|
||||||
@JsonInclude(value = JsonInclude.Include.NON_NULL)
|
|
||||||
class Repository {
|
|
||||||
public String id;
|
|
||||||
public String name;
|
|
||||||
public String url;
|
|
||||||
public Boolean snapshotsEnabled;
|
|
||||||
|
|
||||||
@Override public String toString() {
|
|
||||||
return "Repository{" + "id='" + this.id + '\'' + ", name='" + this.name + '\'' + ", url='"
|
|
||||||
+ this.url + '\'' + ", snapshotsEnabled=" + this.snapshotsEnabled + '}';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user