Bumped Maven to 3.6.2

migrated aether to maven-provider

fixes gh-1218
This commit is contained in:
Marcin Grzejszczak
2019-09-19 17:02:29 +02:00
parent 2437cd341b
commit b59398878f
12 changed files with 236 additions and 299 deletions

45
pom.xml
View File

@@ -55,9 +55,8 @@
<!-- We need to have compatibility with Gradle -->
<groovy.version>2.5.8</groovy.version>
<!-- For Takari plugin -->
<maven.version>3.3.9</maven.version>
<aether.version>1.1.0</aether.version>
<maven.version>3.6.2</maven.version>
<maven.resolver.version>1.4.1</maven.resolver.version>
<xpath2.processor.version>2.1.100</xpath2.processor.version>
<xerces.version>2.11.0</xerces.version>
<jacoco-maven-plugin.version>0.8.4</jacoco-maven-plugin.version>
@@ -97,6 +96,16 @@
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-function-compiler</artifactId>
<version>${spring-cloud-function.version}</version>
<exclusions>
<exclusion>
<groupId>org.apache.maven</groupId>
<artifactId>*</artifactId>
</exclusion>
<exclusion>
<groupId>org.eclipse.aether</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
@@ -390,7 +399,7 @@
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-aether-provider</artifactId>
<artifactId>maven-resolver-provider</artifactId>
<version>${maven.version}</version>
</dependency>
<dependency>
@@ -404,29 +413,11 @@
<version>${maven.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.aether</groupId>
<artifactId>aether-api</artifactId>
<version>${aether.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.aether</groupId>
<artifactId>aether-impl</artifactId>
<version>${aether.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.aether</groupId>
<artifactId>aether-transport-file</artifactId>
<version>${aether.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.aether</groupId>
<artifactId>aether-transport-http</artifactId>
<version>${aether.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.aether</groupId>
<artifactId>aether-connector-basic</artifactId>
<version>${aether.version}</version>
<groupId>org.apache.maven.resolver</groupId>
<artifactId>maven-resolver</artifactId>
<version>${maven.resolver.version}</version>
<scope>import</scope>
<type>pom</type>
</dependency>
<dependency>
<groupId>com.rackspace.eclipse.webtools.sourceediting</groupId>

View File

@@ -18,7 +18,7 @@
<wiremock.version>2.24.1</wiremock.version>
<jsonassert.version>0.4.13</jsonassert.version>
<rest-assured.version>4.0.0</rest-assured.version>
<maven.version>3.3.9</maven.version>
<maven.version>3.6.2</maven.version>
</properties>
<dependencyManagement>
<dependencies>

View File

@@ -8,7 +8,7 @@
<org.eclipse.sisu.plexus.version>0.1.1</org.eclipse.sisu.plexus.version>
<sisu-guice.version>4.2.0</sisu-guice.version>
<guice.version>4.2.2</guice.version>
<guava.version>27.1-jre</guava.version>
<guava.version>28.1-jre</guava.version>
<asm.version>7.1</asm.version>
<checker.version>2.11.0</checker.version>
@@ -28,33 +28,53 @@
<description>Spring Cloud Contract Shaded Dependencies</description>
<dependencies>
<dependency>
<groupId>org.eclipse.aether</groupId>
<artifactId>aether-api</artifactId>
<groupId>org.apache.maven.resolver</groupId>
<artifactId>maven-resolver-api</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.eclipse.aether</groupId>
<artifactId>aether-impl</artifactId>
<groupId>org.apache.maven.resolver</groupId>
<artifactId>maven-resolver-spi</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.eclipse.aether</groupId>
<artifactId>aether-transport-file</artifactId>
<groupId>org.apache.maven.resolver</groupId>
<artifactId>maven-resolver-util</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.eclipse.aether</groupId>
<artifactId>aether-transport-http</artifactId>
<groupId>org.apache.maven.resolver</groupId>
<artifactId>maven-resolver-impl</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.eclipse.aether</groupId>
<artifactId>aether-connector-basic</artifactId>
<groupId>org.apache.maven.resolver</groupId>
<artifactId>maven-resolver-connector-basic</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.apache.maven.resolver</groupId>
<artifactId>maven-resolver-transport-classpath</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.apache.maven.resolver</groupId>
<artifactId>maven-resolver-transport-file</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.apache.maven.resolver</groupId>
<artifactId>maven-resolver-transport-http</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.apache.maven.resolver</groupId>
<artifactId>maven-resolver-transport-wagon</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-aether-provider</artifactId>
<artifactId>maven-resolver-provider</artifactId>
<optional>true</optional>
<exclusions>
<exclusion>

View File

@@ -55,8 +55,8 @@
</dependency>
<!-- for Stub Runner's Aether -->
<dependency>
<groupId>org.eclipse.aether</groupId>
<artifactId>aether-api</artifactId>
<groupId>org.apache.maven.resolver</groupId>
<artifactId>maven-resolver-api</artifactId>
</dependency>
</dependencies>
<build>

View File

@@ -56,8 +56,8 @@
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.eclipse.aether</groupId>
<artifactId>aether-api</artifactId>
<groupId>org.apache.maven.resolver</groupId>
<artifactId>maven-resolver-api</artifactId>
<optional>true</optional>
</dependency>
<dependency>
@@ -98,6 +98,8 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>compile</scope>
<optional>true</optional>
</dependency>
<!-- Git Stub Downloader-->
<dependency>

View File

@@ -26,24 +26,21 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<dependency.locations.enabled>false</dependency.locations.enabled>
<maven.plugin.plugin.version>3.5</maven.plugin.plugin.version>
<maven.plugin.plugin.version>3.6.0</maven.plugin.plugin.version>
<maven-failsafe-plugin.version>2.22.0</maven-failsafe-plugin.version>
<maven-failsafe-plugin.version>3.0.0-M3</maven-failsafe-plugin.version>
<asciidoctor-maven-plugin.version>1.5.7.1</asciidoctor-maven-plugin.version>
<maven-filtering.version>3.1.1</maven-filtering.version>
<takari-plugin-testing.version>2.9.2</takari-plugin-testing.version>
<takari-plugin-integration-testing.version>2.9.2
</takari-plugin-integration-testing.version>
<maven-scm-publish-plugin.version>3.0.0</maven-scm-publish-plugin.version>
<maven-project-info-reports-plugin.version>3.0.0
</maven-project-info-reports-plugin.version>
<maven-plugin-annotations.version>3.5.2</maven-plugin-annotations.version>
<maven-plugin-annotations.version>3.6.0</maven-plugin-annotations.version>
<maven-archiver.version>3.4.0</maven-archiver.version>
<plexus-archiver.version>4.1.0</plexus-archiver.version>
<coveralls-maven-plugin.version>4.3.0</coveralls-maven-plugin.version>
<maven-site-plugin.version>3.7.1</maven-site-plugin.version>
<maven-site-plugin.version>3.8.2</maven-site-plugin.version>
<plexus-component-metadata.version>2.0.0</plexus-component-metadata.version>
<takari-lifecycle-plugin.version>1.13.7</takari-lifecycle-plugin.version>
<maven-plugin-testing-harness.version>3.3.0</maven-plugin-testing-harness.version>
</properties>
<inceptionYear>2016</inceptionYear>
@@ -63,21 +60,6 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>io.takari.maven.plugins</groupId>
<artifactId>takari-lifecycle-plugin</artifactId>
<version>${takari-lifecycle-plugin.version}</version>
<extensions>true</extensions>
<executions>
<execution>
<id>testProperties</id>
<phase>process-test-resources</phase>
<goals>
<goal>testProperties</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
@@ -285,33 +267,33 @@
</dependency>
<dependency>
<groupId>org.eclipse.aether</groupId>
<artifactId>aether-api</artifactId>
<groupId>org.apache.maven.resolver</groupId>
<artifactId>maven-resolver-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.eclipse.aether</groupId>
<artifactId>aether-impl</artifactId>
<groupId>org.apache.maven.resolver</groupId>
<artifactId>maven-resolver-impl</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.eclipse.aether</groupId>
<artifactId>aether-transport-file</artifactId>
<groupId>org.apache.maven.resolver</groupId>
<artifactId>maven-resolver-transport-file</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.eclipse.aether</groupId>
<artifactId>aether-transport-http</artifactId>
<groupId>org.apache.maven.resolver</groupId>
<artifactId>maven-resolver-transport-http</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.eclipse.aether</groupId>
<artifactId>aether-connector-basic</artifactId>
<groupId>org.apache.maven.resolver</groupId>
<artifactId>maven-resolver-connector-basic</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-aether-provider</artifactId>
<artifactId>maven-resolver-provider</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
@@ -386,19 +368,6 @@
<version>${plexus-archiver.version}</version>
</dependency>
<dependency>
<groupId>io.takari.maven.plugins</groupId>
<artifactId>takari-plugin-testing</artifactId>
<version>${takari-plugin-testing.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.takari.maven.plugins</groupId>
<artifactId>takari-plugin-integration-testing</artifactId>
<version>${takari-plugin-integration-testing.version}</version>
<type>pom</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-compat</artifactId>
@@ -420,6 +389,12 @@
<artifactId>spring-cloud-contract-pact</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.maven.plugin-testing</groupId>
<artifactId>maven-plugin-testing-harness</artifactId>
<version>${maven-plugin-testing-harness.version}</version>
<scope>test</scope>
</dependency>
</dependencies>

View File

@@ -0,0 +1,81 @@
/*
* 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.maven.verifier;
import java.io.File;
import java.io.IOException;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.plugin.testing.MojoRule;
import org.apache.maven.project.MavenProject;
import org.assertj.core.api.BDDAssertions;
import org.codehaus.plexus.util.xml.Xpp3Dom;
import org.junit.Before;
import org.junit.Rule;
import org.junit.rules.TemporaryFolder;
import org.springframework.boot.test.system.OutputCaptureRule;
import org.springframework.util.FileSystemUtils;
public abstract class AbstractMojoTest {
@Rule
public MojoRule rule = new MojoRule() {
@Override
protected void before() throws Throwable {
}
@Override
protected void after() {
}
};
@Rule
public TemporaryFolder tmp = new TemporaryFolder();
@Rule
public OutputCaptureRule capture = new OutputCaptureRule();
File tmpFolder;
@Before
public void setupTemp() throws IOException {
this.tmpFolder = this.tmp.newFolder();
File projects = new File("src/test/projects");
FileSystemUtils.copyRecursively(projects, this.tmpFolder);
}
protected File getBasedir(String name) {
return new File(this.tmpFolder, name);
}
protected void executeMojo(File baseDir, String goal, Xpp3Dom... parameters)
throws Exception {
MavenProject mavenProject = rule.readMavenProject(baseDir);
MavenSession mavenSession = rule.newMavenSession(mavenProject);
rule.executeMojo(mavenSession, mavenProject, goal, parameters);
}
protected void assertFilesPresent(File file, String name) {
BDDAssertions.then(new File(file, name)).exists();
}
protected void assertFilesNotPresent(File file, String name) {
BDDAssertions.then(new File(file, name)).doesNotExist();
}
}

View File

@@ -1,128 +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.maven.verifier;
import java.io.File;
import io.takari.maven.testing.TestProperties;
import io.takari.maven.testing.TestResources;
import io.takari.maven.testing.executor.MavenRuntime;
import io.takari.maven.testing.executor.MavenVersions;
import io.takari.maven.testing.executor.junit.MavenJUnitTestRunner;
import org.junit.Assume;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.util.SocketUtils;
@RunWith(MavenJUnitTestRunner.class)
@MavenVersions({ "3.5.0" })
public class PluginIT {
@Rule
public final TestResources resources = new TestResources();
private final TestProperties properties = new TestProperties();
private final MavenRuntime maven;
public PluginIT(MavenRuntime.MavenRuntimeBuilder mavenBuilder) throws Exception {
this.maven = mavenBuilder.withCliOptions("-B", "-U").build();
}
@Before
public void doNotRunForWindows() {
Assume.assumeFalse(isWindows());
}
private boolean isWindows() {
return System.getProperty("os.name").startsWith("Windows");
}
@Test
public void should_build_project_Spring_Boot_Groovy_with_Accurest() throws Exception {
File basedir = this.resources.getBasedir("spring-boot-groovy");
this.maven.forProject(basedir).execute("package").assertErrorFreeLog()
.assertLogText(
"Generating server tests source code for Spring Cloud Contract Verifier contract verification")
.assertLogText("Generated 1 test classes.")
.assertLogText(
"Converting from Spring Cloud Contract Verifier contracts to WireMock stubs mappings")
.assertLogText("Creating new stub")
.assertLogText("Running hello.ContractVerifierSpec").assertErrorFreeLog();
}
@Test
public void should_build_project_Spring_Boot_Java_with_Accurest() throws Exception {
File basedir = this.resources.getBasedir("spring-boot-java");
this.maven.forProject(basedir).execute("package").assertErrorFreeLog()
.assertLogText(
"Generating server tests source code for Spring Cloud Contract Verifier contract verification")
.assertLogText("Generated 1 test classes.")
.assertLogText(
"Converting from Spring Cloud Contract Verifier contracts to WireMock stubs mappings")
.assertLogText("Creating new stub")
.assertLogText("Running hello.ContractVerifierTest").assertErrorFreeLog();
}
@Test
public void should_build_project_with_plugin_extension() throws Exception {
File basedir = this.resources.getBasedir("plugin-extension");
this.maven.forProject(basedir).execute("package").assertErrorFreeLog()
.assertLogText(
"Generating server tests source code for Spring Cloud Contract Verifier contract verification")
.assertLogText("Generated 1 test classes.")
.assertLogText(
"Converting from Spring Cloud Contract Verifier contracts to WireMock stubs mappings")
.assertLogText("Creating new stub")
.assertLogText("Running hello.ContractVerifierTest").assertErrorFreeLog();
}
@Test
public void should_convert_Accurest_Contracts_to_WireMock_Stubs_mappings()
throws Exception {
File basedir = this.resources.getBasedir("pomless");
this.properties.getPluginVersion();
this.maven.forProject(basedir).withCliOption("-X").execute(String.format(
"org.springframework.cloud:spring-cloud-contract-maven-plugin:%s:convert",
this.properties.getPluginVersion()))
.assertLogText(
"Converting from Spring Cloud Contract Verifier contracts to WireMock stubs mappings")
.assertLogText("Creating new stub").assertErrorFreeLog();
}
@Test
public void should_run_WireMock_Stubs_mappings() throws Exception {
int availableTcpPort = SocketUtils.findAvailableTcpPort();
File basedir = this.resources.getBasedir("generatedStubsOnly");
this.properties.getPluginVersion();
this.maven.forProject(basedir).withCliOption("-X")
.withCliOption(
"-Dspring.cloud.contract.verifier.http.port=" + availableTcpPort)
.withCliOption(
"-Dspring.cloud.contract.verifier.wait-for-key-pressed=false")
.execute(String.format(
"org.springframework.cloud:spring-cloud-contract-maven-plugin:%s:run",
this.properties.getPluginVersion()))
.assertLogText("All stubs are now running RunningStubs [namesAndPorts={="
+ availableTcpPort + "}]")
.assertErrorFreeLog();
}
}

View File

@@ -18,37 +18,22 @@ package org.springframework.cloud.contract.maven.verifier;
import java.io.File;
import io.takari.maven.testing.TestMavenRuntime;
import io.takari.maven.testing.TestResources;
import org.codehaus.plexus.util.xml.Xpp3Dom;
import org.junit.Rule;
import org.junit.Test;
import org.springframework.boot.test.rule.OutputCapture;
import org.springframework.util.StringUtils;
import static io.takari.maven.testing.TestMavenRuntime.newParameter;
import static io.takari.maven.testing.TestResources.assertFilesNotPresent;
import static io.takari.maven.testing.TestResources.assertFilesPresent;
import static java.nio.charset.Charset.defaultCharset;
import static org.apache.commons.io.FileUtils.readFileToString;
import static org.apache.maven.plugin.testing.MojoParameters.newParameter;
import static org.assertj.core.api.BDDAssertions.then;
public class PluginUnitTest {
@Rule
public final TestResources resources = new TestResources();
@Rule
public final TestMavenRuntime maven = new TestMavenRuntime();
@Rule
public OutputCapture capture = new OutputCapture();
public class PluginUnitTest extends AbstractMojoTest {
@Test
public void shouldGenerateWireMockStubsInDefaultLocation() throws Exception {
File basedir = this.resources.getBasedir("basic");
this.maven.executeMojo(basedir, "convert", defaultPackageForTests());
File basedir = getBasedir("basic");
executeMojo(basedir, "convert");
assertFilesPresent(basedir,
"target/stubs/META-INF/org.springframework.cloud.verifier.sample/sample-project/0.1/mappings/Sample.json"
.replace("/", File.separator));
@@ -64,8 +49,8 @@ public class PluginUnitTest {
@Test
public void shouldGenerateWireMockFromStubsDirectory() throws Exception {
File basedir = this.resources.getBasedir("withStubs");
this.maven.executeMojo(basedir, "convert", defaultPackageForTests(),
File basedir = getBasedir("withStubs");
executeMojo(basedir, "convert",
newParameter("contractsDirectory", "src/test/resources/stubs"));
assertFilesPresent(basedir,
"target/stubs/META-INF/org.springframework.cloud.verifier.sample/sample-project/0.1/mappings/Sample.json"
@@ -74,8 +59,8 @@ public class PluginUnitTest {
@Test
public void shouldCopyContracts() throws Exception {
File basedir = this.resources.getBasedir("basic");
this.maven.executeMojo(basedir, "convert", defaultPackageForTests());
File basedir = getBasedir("basic");
executeMojo(basedir, "convert");
assertFilesPresent(basedir,
"target/stubs/META-INF/org.springframework.cloud.verifier.sample/sample-project/0.1/contracts/Sample.groovy"
.replace("/", File.separator));
@@ -86,17 +71,16 @@ public class PluginUnitTest {
@Test
public void shouldGenerateWireMockStubsInSelectedLocation() throws Exception {
File basedir = this.resources.getBasedir("basic");
this.maven.executeMojo(basedir, "convert", defaultPackageForTests(),
newParameter("stubsDirectory", "target/foo"));
File basedir = getBasedir("basic");
executeMojo(basedir, "convert", newParameter("stubsDirectory", "target/foo"));
assertFilesPresent(basedir,
"target/foo/META-INF/org.springframework.cloud.verifier.sample/sample-project/0.1/mappings/Sample.json");
}
@Test
public void shouldGenerateContractSpecificationInDefaultLocation() throws Exception {
File basedir = this.resources.getBasedir("basic");
this.maven.executeMojo(basedir, "generateTests", defaultPackageForTests(),
File basedir = getBasedir("basic");
executeMojo(basedir, "generateTests", defaultPackageForTests(),
newParameter("testFramework", "SPOCK"));
String path = "target/generated-test-sources/contracts/org/springframework/cloud/contract/verifier/tests/ContractVerifierSpec.groovy";
assertFilesPresent(basedir, path);
@@ -106,16 +90,16 @@ public class PluginUnitTest {
@Test
public void shouldGenerateContractTestsInDefaultLocation() throws Exception {
File basedir = this.resources.getBasedir("basic");
this.maven.executeMojo(basedir, "generateTests", defaultPackageForTests());
File basedir = getBasedir("basic");
executeMojo(basedir, "generateTests", defaultPackageForTests());
assertFilesPresent(basedir,
"target/generated-test-sources/contracts/org/springframework/cloud/contract/verifier/tests/ContractVerifierTest.java");
}
@Test
public void shouldGenerateContractTestsWithCustomImports() throws Exception {
File basedir = this.resources.getBasedir("basic");
this.maven.executeMojo(basedir, "generateTests", defaultPackageForTests(),
File basedir = getBasedir("basic");
executeMojo(basedir, "generateTests", defaultPackageForTests(),
newParameter("imports", ""));
assertFilesPresent(basedir,
"target/generated-test-sources/contracts/org/springframework/cloud/contract/verifier/tests/ContractVerifierTest.java");
@@ -123,8 +107,8 @@ public class PluginUnitTest {
@Test
public void shouldGenerateContractTestsWithoutArraySize() throws Exception {
File basedir = this.resources.getBasedir("basic");
this.maven.executeMojo(basedir, "generateTests", defaultPackageForTests());
File basedir = getBasedir("basic");
executeMojo(basedir, "generateTests", defaultPackageForTests());
assertFilesPresent(basedir,
"target/generated-test-sources/contracts/org/springframework/cloud/contract/verifier/tests/ContractVerifierTest.java");
File test = new File(basedir,
@@ -134,8 +118,8 @@ public class PluginUnitTest {
@Test
public void shouldGenerateContractTestsWithArraySize() throws Exception {
File basedir = this.resources.getBasedir("basic");
this.maven.executeMojo(basedir, "generateTests", defaultPackageForTests(),
File basedir = getBasedir("basic");
executeMojo(basedir, "generateTests", defaultPackageForTests(),
newParameter("assertJsonSize", "true"));
assertFilesPresent(basedir,
"target/generated-test-sources/contracts/org/springframework/cloud/contract/verifier/tests/ContractVerifierTest.java");
@@ -146,32 +130,30 @@ public class PluginUnitTest {
@Test
public void shouldGenerateStubs() throws Exception {
File basedir = this.resources.getBasedir("generatedStubs");
this.maven.executeMojo(basedir, "generateStubs", defaultPackageForTests());
File basedir = getBasedir("generatedStubs");
executeMojo(basedir, "generateStubs");
assertFilesPresent(basedir, "target/sample-project-stubs.jar");
}
@Test
public void shouldGenerateStubsWithMappingsOnly() throws Exception {
File basedir = this.resources.getBasedir("generatedStubs");
this.maven.executeMojo(basedir, "generateStubs", defaultPackageForTests(),
newParameter("attachContracts", "false"));
File basedir = getBasedir("generatedStubs");
executeMojo(basedir, "generateStubs");
assertFilesPresent(basedir, "target/sample-project-stubs.jar");
// FIXME: add assertion for jar content
}
@Test
public void shouldGenerateStubsWithCustomClassifier() throws Exception {
File basedir = this.resources.getBasedir("generatedStubs");
this.maven.executeMojo(basedir, "generateStubs", defaultPackageForTests(),
newParameter("classifier", "foo"));
File basedir = getBasedir("generatedStubs");
executeMojo(basedir, "generateStubs", newParameter("classifier", "foo"));
assertFilesPresent(basedir, "target/sample-project-foo.jar");
}
@Test
public void shouldGenerateStubsByDownloadingContractsFromARepo() throws Exception {
File basedir = this.resources.getBasedir("basic-remote-contracts");
this.maven.executeMojo(basedir, "convert", defaultPackageForTests(),
File basedir = getBasedir("basic-remote-contracts");
executeMojo(basedir, "convert",
newParameter("contractsRepositoryUrl",
"file://" + PluginUnitTest.class.getClassLoader()
.getResource("m2repo/repository").getFile()
@@ -183,8 +165,8 @@ public class PluginUnitTest {
@Test
public void shouldGenerateStubsByDownloadingContractsFromARepoWhenCustomPathIsProvided()
throws Exception {
File basedir = this.resources.getBasedir("complex-remote-contracts");
this.maven.executeMojo(basedir, "convert", defaultPackageForTests(),
File basedir = getBasedir("complex-remote-contracts");
executeMojo(basedir, "convert",
newParameter("contractsRepositoryUrl",
"file://" + PluginUnitTest.class.getClassLoader()
.getResource("m2repo/repository").getFile()
@@ -199,8 +181,8 @@ public class PluginUnitTest {
@Test
public void shouldGenerateOutputWhenCalledConvertFromRootProject() throws Exception {
File basedir = this.resources.getBasedir("different-module-configuration");
this.maven.executeMojo(basedir, "convert", defaultPackageForTests());
File basedir = getBasedir("different-module-configuration");
executeMojo(basedir, "convert");
assertFilesPresent(basedir,
"target/stubs/META-INF/com.blogspot.toomuchcoding.frauddetection/frauddetection-parent/0.1.0/mappings/shouldMarkClientAsFraud.json");
}
@@ -208,16 +190,16 @@ public class PluginUnitTest {
@Test
public void shouldGenerateOutputWhenCalledGenerateTestsFromRootProject()
throws Exception {
File basedir = this.resources.getBasedir("different-module-configuration");
this.maven.executeMojo(basedir, "generateTests", defaultPackageForTests());
File basedir = getBasedir("different-module-configuration");
executeMojo(basedir, "generateTests", defaultPackageForTests());
assertFilesPresent(basedir,
"target/generated-test-sources/contracts/org/springframework/cloud/contract/verifier/tests/ContractVerifierTest.java");
}
@Test
public void shouldGenerateTestsByDownloadingContractsFromARepo() throws Exception {
File basedir = this.resources.getBasedir("basic-remote-contracts");
this.maven.executeMojo(basedir, "generateTests", defaultPackageForTests(),
File basedir = getBasedir("basic-remote-contracts");
executeMojo(basedir, "generateTests", defaultPackageForTests(),
newParameter("contractsRepositoryUrl",
"file://" + PluginUnitTest.class.getClassLoader()
.getResource("m2repo/repository").getFile()
@@ -229,8 +211,8 @@ public class PluginUnitTest {
@Test
public void shouldGenerateTestsByDownloadingContractsFromARepoWhenCustomPathIsProvided()
throws Exception {
File basedir = this.resources.getBasedir("complex-remote-contracts");
this.maven.executeMojo(basedir, "generateTests", defaultPackageForTests(),
File basedir = getBasedir("complex-remote-contracts");
executeMojo(basedir, "generateTests", defaultPackageForTests(),
newParameter("contractsRepositoryUrl",
"file://" + PluginUnitTest.class.getClassLoader()
.getResource("m2repo/repository").getFile()
@@ -246,9 +228,9 @@ public class PluginUnitTest {
@Test
public void shouldGenerateContractTestsWithBaseClassResolvedFromConvention()
throws Exception {
File basedir = this.resources.getBasedir("basic-generated-baseclass");
File basedir = getBasedir("basic-generated-baseclass");
this.maven.executeMojo(basedir, "generateTests", defaultPackageForTests(),
executeMojo(basedir, "generateTests", defaultPackageForTests(),
newParameter("testFramework", "JUNIT"));
String path = "target/generated-test-sources/contracts/org/springframework/cloud/contract/verifier/tests/hello/V1Test.java";
@@ -261,9 +243,9 @@ public class PluginUnitTest {
@Test
public void shouldGenerateContractTestsWithBaseClassResolvedFromConventionForSpock()
throws Exception {
File basedir = this.resources.getBasedir("basic-generated-baseclass");
File basedir = getBasedir("basic-generated-baseclass");
this.maven.executeMojo(basedir, "generateTests", defaultPackageForTests(),
executeMojo(basedir, "generateTests", defaultPackageForTests(),
newParameter("testFramework", "SPOCK"));
String path = "target/generated-test-sources/contracts/org/springframework/cloud/contract/verifier/tests/hello/V1Spec.groovy";
@@ -276,9 +258,9 @@ public class PluginUnitTest {
@Test
public void shouldGenerateContractTestsWithBaseClassResolvedFromMapping()
throws Exception {
File basedir = this.resources.getBasedir("basic-baseclass-from-mappings");
File basedir = getBasedir("basic-baseclass-from-mappings");
this.maven.executeMojo(basedir, "generateTests", defaultPackageForTests(),
executeMojo(basedir, "generateTests", defaultPackageForTests(),
newParameter("testFramework", "JUNIT"));
String path = "target/generated-test-sources/contracts/org/springframework/cloud/contract/verifier/tests/com/hello/V1Test.java";
@@ -291,9 +273,9 @@ public class PluginUnitTest {
@Test
public void shouldGenerateContractTestsWithBaseClassResolvedFromMappingNameForSpock()
throws Exception {
File basedir = this.resources.getBasedir("basic-baseclass-from-mappings");
File basedir = getBasedir("basic-baseclass-from-mappings");
this.maven.executeMojo(basedir, "generateTests", defaultPackageForTests(),
executeMojo(basedir, "generateTests", defaultPackageForTests(),
newParameter("testFramework", "SPOCK"));
String path = "target/generated-test-sources/contracts/org/springframework/cloud/contract/verifier/tests/com/hello/V1Spec.groovy";
@@ -306,9 +288,9 @@ public class PluginUnitTest {
@Test
public void shouldGenerateContractTestsWithAFileContainingAListOfContracts()
throws Exception {
File basedir = this.resources.getBasedir("multiple-contracts");
File basedir = getBasedir("multiple-contracts");
this.maven.executeMojo(basedir, "generateTests", defaultPackageForTests(),
executeMojo(basedir, "generateTests", defaultPackageForTests(),
newParameter("testFramework", "JUNIT"));
String path = "target/generated-test-sources/contracts/org/springframework/cloud/contract/verifier/tests/com/hello/V1Test.java";
@@ -322,10 +304,9 @@ public class PluginUnitTest {
@Test
public void shouldGenerateStubsWithAFileContainingAListOfContracts()
throws Exception {
File basedir = this.resources.getBasedir("multiple-contracts");
File basedir = getBasedir("multiple-contracts");
this.maven.executeMojo(basedir, "convert", defaultPackageForTests(),
newParameter("stubsDirectory", "target/foo"));
executeMojo(basedir, "convert", newParameter("stubsDirectory", "target/foo"));
String firstFile = "target/foo/META-INF/org.springframework.cloud.verifier.sample/sample-project/0.1/mappings/com/hello/v1/should post a user.json";
File test = new File(basedir, firstFile);
@@ -341,14 +322,14 @@ public class PluginUnitTest {
@Test
public void shouldGenerateStubsForCommonRepoWithTargetFolder() throws Exception {
File basedir = this.resources.getBasedir("common-repo");
File basedir = getBasedir("common-repo");
this.maven.executeMojo(basedir, "convert", defaultPackageForTests());
executeMojo(basedir, "convert");
assertFilesNotPresent(basedir, "target/generated-test-sources/contracts/");
// there will be no stubs cause all files are copied to `target` folder
assertFilesNotPresent(basedir,
"target/stubs/META-INF/org.springframework.cloud.verifier.sample/common-repo/0.1/mappings/");
assertFilesPresent(basedir,
"target/stubs/META-INF/org.springframework.cloud.verifier.sample/common-repo/0.1/mappings/consumer1");
assertFilesPresent(basedir,
"target/stubs/META-INF/org.springframework.cloud.verifier.sample/common-repo/0.1/contracts/consumer1/Messaging.groovy");
assertFilesPresent(basedir,
@@ -357,9 +338,9 @@ public class PluginUnitTest {
@Test
public void shouldGenerateContractTestsForPactAndMaintainIndents() throws Exception {
File basedir = this.resources.getBasedir("pact");
File basedir = getBasedir("pact");
this.maven.executeMojo(basedir, "generateTests", defaultPackageForTests());
executeMojo(basedir, "generateTests", defaultPackageForTests());
assertFilesPresent(basedir,
"target/generated-test-sources/contracts/org/springframework/cloud/contract/verifier/tests/ContractVerifierTest.java");
@@ -373,9 +354,9 @@ public class PluginUnitTest {
@Test
public void shouldRunPushStubsToScm() throws Exception {
File basedir = this.resources.getBasedir("git-basic-remote-contracts");
File basedir = getBasedir("git-basic-remote-contracts");
this.maven.executeMojo(basedir, "pushStubsToScm", defaultPackageForTests());
executeMojo(basedir, "pushStubsToScm");
then(this.capture.toString())
.contains("Skipping pushing stubs to scm since your");
@@ -383,9 +364,9 @@ public class PluginUnitTest {
@Test
public void shouldGenerateContractTestsForIncludedFilesPattern() throws Exception {
File basedir = this.resources.getBasedir("complex-common-repo-with-messaging");
File basedir = getBasedir("complex-common-repo-with-messaging");
this.maven.executeMojo(basedir, "generateTests", defaultPackageForTests(),
executeMojo(basedir, "generateTests", defaultPackageForTests(),
newParameter("contractsRepositoryUrl",
"file://" + PluginUnitTest.class.getClassLoader()
.getResource("m2repo/repository").getFile()

View File

@@ -31,6 +31,7 @@
<plugin>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-contract-maven-plugin</artifactId>
<configuration></configuration>
</plugin>
</plugins>
</build>

View File

@@ -31,6 +31,7 @@
<plugin>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-contract-maven-plugin</artifactId>
<!--
<configuration>
<baseClassForTests>com.example.FooBase</baseClassForTests>
<baseClassMappings>
@@ -40,6 +41,7 @@
</baseClassMapping>
</baseClassMappings>
</configuration>
-->
</plugin>
</plugins>
</build>

View File

@@ -3,6 +3,9 @@
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<properties>
<javax.ws.rs-api.version>2.1</javax.ws.rs-api.version>
</properties>
<parent>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-contract-parent</artifactId>
@@ -93,6 +96,10 @@
<groupId>com.toomuchcoding.jsonassert</groupId>
<artifactId>jsonassert</artifactId>
</dependency>
<dependency>
<groupId>org.apache.maven.resolver</groupId>
<artifactId>maven-resolver-api</artifactId>
</dependency>
<dependency>
<groupId>com.rackspace.eclipse.webtools.sourceediting</groupId>
<artifactId>org.eclipse.wst.xml.xpath2.processor</artifactId>
@@ -158,6 +165,11 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
@@ -225,7 +237,7 @@
<dependency>
<artifactId>javax.ws.rs-api</artifactId>
<groupId>javax.ws.rs</groupId>
<version>2.1</version>
<version>${javax.ws.rs-api.version}</version>
<scope>test</scope>
</dependency>
<dependency>