27 changed files with 465 additions and 604 deletions
@ -1,37 +0,0 @@
@@ -1,37 +0,0 @@
|
||||
/* |
||||
* Copyright 2002-2017 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 io.spring.gradle.convention |
||||
|
||||
import io.spring.gradle.testkit.junit.rules.TestKit |
||||
import org.gradle.testkit.runner.BuildResult |
||||
import org.junit.Rule |
||||
import spock.lang.Specification |
||||
|
||||
import static org.gradle.testkit.runner.TaskOutcome.SUCCESS |
||||
|
||||
class DependencySetPluginITest extends Specification { |
||||
@Rule final TestKit testKit = new TestKit() |
||||
|
||||
def "dependencies"() { |
||||
when: |
||||
BuildResult result = testKit.withProjectResource("samples/dependencyset") |
||||
.withArguments('dependencies') |
||||
.build(); |
||||
then: |
||||
result.task(":dependencies").outcome == SUCCESS |
||||
!result.output.contains("FAILED") |
||||
} |
||||
} |
||||
@ -1,95 +0,0 @@
@@ -1,95 +0,0 @@
|
||||
/* |
||||
* Copyright 2002-2017 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 io.spring.gradle.convention |
||||
|
||||
import io.spring.gradle.testkit.junit.rules.TestKit |
||||
import org.gradle.testkit.runner.BuildResult |
||||
import org.junit.Rule |
||||
import spock.lang.Specification |
||||
|
||||
import java.util.zip.ZipFile |
||||
|
||||
import static org.gradle.testkit.runner.TaskOutcome.FAILED |
||||
import static org.gradle.testkit.runner.TaskOutcome.SUCCESS |
||||
|
||||
class DocsPluginITest extends Specification { |
||||
@Rule final TestKit testKit = new TestKit() |
||||
|
||||
def "build triggers docs"() { |
||||
when: |
||||
BuildResult result = testKit.withProjectResource("samples/docs/simple/") |
||||
.withArguments('build') |
||||
.build(); |
||||
then: |
||||
result.task(":build").outcome == SUCCESS |
||||
and: |
||||
result.task(":docs").outcome == SUCCESS |
||||
and: |
||||
result.task(":docsZip").outcome == SUCCESS |
||||
and: |
||||
def zip = new File(testKit.getRootDir(), 'build/distributions/simple-1.0.0.BUILD-SNAPSHOT-docs.zip') |
||||
def names = new ZipFile(zip).entries()*.name |
||||
names.contains("docs/reference/html5/index.html") |
||||
names.contains("docs/reference/pdf/simple-reference.pdf") |
||||
} |
||||
|
||||
def "asciidoc copies images"() { |
||||
when: |
||||
BuildResult result = testKit.withProjectResource("samples/docs/simple/") |
||||
.withArguments('asciidoctor') |
||||
.build(); |
||||
then: |
||||
result.task(":asciidoctor").outcome == SUCCESS |
||||
new File(testKit.getRootDir(), "build/docs/asciidoc/images").exists() |
||||
} |
||||
|
||||
def "asciidoc docinfo from resources used"() { |
||||
when: |
||||
BuildResult result = testKit.withProjectResource("samples/docs/simple/") |
||||
.withArguments('asciidoctor') |
||||
.build(); |
||||
then: |
||||
result.task(":asciidoctor").outcome == SUCCESS |
||||
new File(testKit.getRootDir(), "build/docs/asciidoc/index.html").getText().contains("""<script type="text/javascript" src="js/tocbot/tocbot.min.js"></script>""") |
||||
} |
||||
|
||||
def "missing attribute fails"() { |
||||
when: |
||||
BuildResult result = testKit.withProjectResource("samples/docs/missing-attribute/") |
||||
.withArguments(':asciidoctor') |
||||
.buildAndFail(); |
||||
then: |
||||
result.task(":asciidoctor").outcome == FAILED |
||||
} |
||||
|
||||
def "missing include"() { |
||||
when: |
||||
BuildResult result = testKit.withProjectResource("samples/docs/missing-include/") |
||||
.withArguments(':asciidoctor') |
||||
.buildAndFail(); |
||||
then: |
||||
result.task(":asciidoctor").outcome == FAILED |
||||
} |
||||
|
||||
def "missing cross reference"() { |
||||
when: |
||||
BuildResult result = testKit.withProjectResource("samples/docs/missing-cross-reference/") |
||||
.withArguments(':asciidoctor') |
||||
.buildAndFail(); |
||||
then: |
||||
result.task(":asciidoctor").outcome == FAILED |
||||
} |
||||
} |
||||
@ -1,63 +0,0 @@
@@ -1,63 +0,0 @@
|
||||
/* |
||||
* Copyright 2016-2018 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 io.spring.gradle.convention |
||||
|
||||
import io.spring.gradle.testkit.junit.rules.TestKit |
||||
import org.gradle.testkit.runner.BuildResult |
||||
import org.junit.Rule |
||||
import spock.lang.Specification |
||||
|
||||
import static org.gradle.testkit.runner.TaskOutcome.SUCCESS |
||||
|
||||
class IntegrationTestPluginITest extends Specification { |
||||
@Rule final TestKit testKit = new TestKit() |
||||
|
||||
def "check with java plugin"() { |
||||
when: |
||||
BuildResult result = testKit.withProjectResource("samples/integrationtest/withjava/") |
||||
.withArguments('check') |
||||
.build(); |
||||
then: |
||||
result.task(":check").outcome == SUCCESS |
||||
and: |
||||
new File(testKit.getRootDir(), 'build/test-results/integrationTest/').exists() |
||||
new File(testKit.getRootDir(), 'build/reports/tests/integrationTest/').exists() |
||||
} |
||||
|
||||
def "check with propdeps"() { |
||||
when: |
||||
BuildResult result = testKit.withProjectResource("samples/integrationtest/withpropdeps/") |
||||
.withArguments('check') |
||||
.build(); |
||||
then: |
||||
result.task(":check").outcome == SUCCESS |
||||
and: |
||||
new File(testKit.getRootDir(), 'build/test-results/integrationTest/').exists() |
||||
new File(testKit.getRootDir(), 'build/reports/tests/integrationTest/').exists() |
||||
} |
||||
|
||||
def "check with groovy plugin"() { |
||||
when: |
||||
BuildResult result = testKit.withProjectResource("samples/integrationtest/withgroovy/") |
||||
.withArguments('check') |
||||
.build(); |
||||
then: |
||||
result.task(":check").outcome == SUCCESS |
||||
and: |
||||
new File(testKit.getRootDir(), 'build/test-results/integrationTest/').exists() |
||||
new File(testKit.getRootDir(), 'build/reports/tests/integrationTest/').exists() |
||||
} |
||||
} |
||||
@ -1,39 +0,0 @@
@@ -1,39 +0,0 @@
|
||||
/* |
||||
* Copyright 2002-2017 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 io.spring.gradle.convention |
||||
|
||||
import io.spring.gradle.testkit.junit.rules.TestKit |
||||
import org.gradle.testkit.runner.BuildResult |
||||
import org.junit.Rule |
||||
import spock.lang.Specification |
||||
|
||||
import static org.gradle.testkit.runner.TaskOutcome.SUCCESS |
||||
|
||||
class JacocoPluginITest extends Specification { |
||||
@Rule final TestKit testKit = new TestKit() |
||||
|
||||
def "check with java plugin"() { |
||||
when: |
||||
BuildResult result = testKit.withProjectResource("samples/jacoco/java/") |
||||
.withArguments('check') |
||||
.build(); |
||||
then: |
||||
result.task(":check").outcome == SUCCESS |
||||
and: |
||||
new File(testKit.getRootDir(), 'build/jacoco').exists() |
||||
new File(testKit.getRootDir(), 'build/reports/jacoco/test/html/').exists() |
||||
} |
||||
} |
||||
@ -1,48 +0,0 @@
@@ -1,48 +0,0 @@
|
||||
/* |
||||
* Copyright 2002-2017 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 io.spring.gradle.convention |
||||
|
||||
import org.gradle.testkit.runner.BuildResult |
||||
import org.gradle.testkit.runner.GradleRunner |
||||
import org.junit.Rule |
||||
import org.junit.rules.TemporaryFolder |
||||
import spock.lang.Specification |
||||
|
||||
import static org.gradle.testkit.runner.TaskOutcome.*; |
||||
|
||||
import io.spring.gradle.testkit.junit.rules.TestKit |
||||
import org.apache.commons.io.FileUtils |
||||
|
||||
class JavadocApiPluginITest extends Specification { |
||||
@Rule final TestKit testKit = new TestKit() |
||||
|
||||
def "multimodule api"() { |
||||
when: |
||||
BuildResult result = testKit.withProjectResource("samples/javadocapi/multimodule/") |
||||
.withArguments('api') |
||||
.build(); |
||||
then: |
||||
result.task(":api").outcome == SUCCESS |
||||
and: |
||||
File allClasses = new File(testKit.getRootDir(), 'build/api/allclasses-noframe.html'); |
||||
File index = new File(testKit.getRootDir(), 'build/api/allclasses.html'); |
||||
new File(testKit.getRootDir(), "build/api/").listFiles().each { println it } |
||||
File listing = allClasses.exists() ? allClasses : index |
||||
listing.text.contains('sample/Api.html') |
||||
listing.text.contains('sample/Impl.html') |
||||
!listing.text.contains('sample/Sample.html') |
||||
} |
||||
} |
||||
@ -1,126 +0,0 @@
@@ -1,126 +0,0 @@
|
||||
/* |
||||
* Copyright 2016-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 io.spring.gradle.convention |
||||
|
||||
import io.spring.gradle.testkit.junit.rules.TestKit |
||||
import org.gradle.testkit.runner.BuildResult |
||||
import org.gradle.testkit.runner.TaskOutcome |
||||
import org.junit.Rule |
||||
import spock.lang.Ignore |
||||
import spock.lang.Specification |
||||
|
||||
class ShowcaseITest extends Specification { |
||||
|
||||
@Rule final TestKit testKit = new TestKit() |
||||
|
||||
def "build"() { |
||||
when: |
||||
BuildResult result = testKit.withProjectResource("samples/showcase/") |
||||
.withArguments('build','--stacktrace') |
||||
.forwardOutput() |
||||
.build(); |
||||
then: 'entire build passes' |
||||
result.output.contains("BUILD SUCCESSFUL") |
||||
} |
||||
|
||||
@Ignore |
||||
def "install"() { |
||||
when: |
||||
BuildResult result = testKit.withProjectResource("samples/showcase/") |
||||
.withArguments('install','--stacktrace') |
||||
.build(); |
||||
then: |
||||
result.output.contains("SUCCESS") |
||||
|
||||
and: 'pom exists' |
||||
File pom = new File(testKit.getRootDir(), 'sgbcs-core/build/poms/pom-default.xml') |
||||
pom.exists() |
||||
String pomText = pom.getText() |
||||
|
||||
and: 'pom does not contain <dependencyManagement>' |
||||
!pomText.contains('<dependencyManagement>') |
||||
|
||||
and: 'creates optional dependencies correctly' |
||||
pomText.replaceAll('\\s','').contains("""<dependency> |
||||
<groupId>org.springframework</groupId> |
||||
<artifactId>spring-test</artifactId> |
||||
<scope>test</scope> |
||||
<version>4.3.6.RELEASE</version> |
||||
</dependency>""".replaceAll('\\s','')) |
||||
|
||||
and: 'adds author' |
||||
pomText.replaceAll('\\s','').contains("""<developers> |
||||
<developer> |
||||
<id>rwinch</id> |
||||
<name>Rob Winch</name> |
||||
<email>rwinch@pivotal.io</email> |
||||
</developer> |
||||
<developer> |
||||
<id>jgrandja</id> |
||||
<name>Joe Grandja</name> |
||||
<email>jgrandja@pivotal.io</email> |
||||
</developer> |
||||
</developers>""".replaceAll('\\s','')) |
||||
|
||||
and: 'adds repositories' |
||||
pomText.replaceAll('\\s','').contains("""<scm> |
||||
<connection>scm:git:git://github.com/spring-projects/spring-security</connection> |
||||
<developerConnection>scm:git:git://github.com/spring-projects/spring-security</developerConnection> |
||||
<url>https://github.com/spring-projects/spring-security</url> |
||||
</scm>""".replaceAll('\\s','')) |
||||
|
||||
and: 'adds description & url' |
||||
pomText.contains('<description>sgbcs-core</description>') |
||||
pomText.contains('<url>https://spring.io/spring-security</url>') |
||||
|
||||
and: 'adds organization' |
||||
pomText.replaceAll('\\s','').contains('''<organization> |
||||
<name>spring.io</name> |
||||
<url>https://spring.io/</url> |
||||
</organization>'''.replaceAll('\\s','')) |
||||
|
||||
and: 'adds licenses' |
||||
pomText.replaceAll('\\s','').contains(''' <licenses> |
||||
<license> |
||||
<name>The Apache Software License, Version 2.0</name> |
||||
<url>https://www.apache.org/licenses/LICENSE-2.0.txt</url> |
||||
<distribution>repo</distribution> |
||||
</license> |
||||
</licenses>'''.replaceAll('\\s','')) |
||||
|
||||
and: 'adds scm' |
||||
pomText.replaceAll('\\s','').replaceAll('\\s','').contains("""<scm> |
||||
<connection>scm:git:git://github.com/spring-projects/spring-security</connection> |
||||
<developerConnection>scm:git:git://github.com/spring-projects/spring-security</developerConnection> |
||||
<url>https://github.com/spring-projects/spring-security</url> |
||||
</scm>""".replaceAll('\\s','')) |
||||
|
||||
and: 'bom created' |
||||
File bom = new File(testKit.getRootDir(), 'bom/build/poms/pom-default.xml') |
||||
bom.exists() |
||||
String bomText = bom.getText() |
||||
bomText.contains("""<artifactId>sgbcs-core</artifactId>""") |
||||
|
||||
when: 'mavenBom ran again' |
||||
result = testKit.withProjectResource("samples/showcase/") |
||||
.withArguments('mavenBom','--stacktrace') |
||||
.build(); |
||||
then: 'mavenBom is not up to date since install is never up to date' |
||||
result.task(':bom:mavenBom').getOutcome() == TaskOutcome.SUCCESS |
||||
} |
||||
|
||||
} |
||||
@ -1,91 +0,0 @@
@@ -1,91 +0,0 @@
|
||||
/* |
||||
* Copyright 2016-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 io.spring.gradle.convention |
||||
|
||||
import io.spring.gradle.testkit.junit.rules.TestKit |
||||
import org.gradle.testkit.runner.BuildResult |
||||
import org.junit.Rule |
||||
import spock.lang.Ignore |
||||
import spock.lang.Specification |
||||
|
||||
import static org.gradle.testkit.runner.TaskOutcome.SUCCESS |
||||
|
||||
class SpringMavenPluginITest extends Specification { |
||||
|
||||
@Rule final TestKit testKit = new TestKit() |
||||
|
||||
@Ignore |
||||
def "install"() { |
||||
when: |
||||
BuildResult result = testKit.withProjectResource("samples/maven/install") |
||||
.withArguments('install') |
||||
.build(); |
||||
then: 'pom contains optional' |
||||
result.output.contains("SUCCESS") |
||||
File pom = new File(testKit.getRootDir(), 'build/poms/pom-default.xml') |
||||
pom.exists() |
||||
String pomText = pom.getText() |
||||
pomText.replaceAll('\\s','').contains("""<dependency> |
||||
<groupId>aopalliance</groupId> |
||||
<artifactId>aopalliance</artifactId> |
||||
<version>1.0</version> |
||||
<scope>compile</scope> |
||||
<optional>true</optional> |
||||
</dependency>""".replaceAll('\\s','')) |
||||
} |
||||
|
||||
@Ignore |
||||
def "signArchives when in memory"() { |
||||
when: |
||||
BuildResult result = testKit.withProjectResource("samples/maven/signing") |
||||
.withArguments('signArchives') |
||||
.withEnvironment(["ORG_GRADLE_PROJECT_signingKey" : signingKey, |
||||
"ORG_GRADLE_PROJECT_signingPassword" : "password"]) |
||||
.forwardOutput() |
||||
.build(); |
||||
then: |
||||
result.output.contains("SUCCESS") |
||||
File jar = new File(testKit.getRootDir(), 'build/libs/signing-1.0.0.RELEASE.jar') |
||||
jar.exists() |
||||
File signature = new File("${jar.absolutePath}.asc") |
||||
signature.exists() |
||||
} |
||||
|
||||
def "upload"() { |
||||
when: |
||||
BuildResult result = testKit.withProjectResource("samples/maven/upload") |
||||
.withArguments('uploadArchives') |
||||
.forwardOutput() |
||||
.build(); |
||||
then: 'pom contains optional' |
||||
result.output.contains("SUCCESS") |
||||
File pom = new File(testKit.getRootDir(), 'build/poms/pom-default.xml') |
||||
pom.exists() |
||||
String pomText = pom.getText() |
||||
pomText.replaceAll('\\s','').contains("""<dependency> |
||||
<groupId>aopalliance</groupId> |
||||
<artifactId>aopalliance</artifactId> |
||||
<version>1.0</version> |
||||
<scope>compile</scope> |
||||
<optional>true</optional> |
||||
</dependency>""".replaceAll('\\s','')) |
||||
} |
||||
|
||||
def getSigningKey() { |
||||
getClass().getResource("/test-private.pgp").text |
||||
} |
||||
} |
||||
@ -1,36 +0,0 @@
@@ -1,36 +0,0 @@
|
||||
/* |
||||
* Copyright 2002-2017 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 io.spring.gradle.convention |
||||
|
||||
import io.spring.gradle.testkit.junit.rules.TestKit |
||||
import org.gradle.testkit.runner.BuildResult |
||||
import org.junit.Rule |
||||
import spock.lang.Specification |
||||
|
||||
import static org.gradle.testkit.runner.TaskOutcome.SUCCESS |
||||
|
||||
class TestsConfigurationPluginITest extends Specification { |
||||
@Rule final TestKit testKit = new TestKit() |
||||
|
||||
def "can find dependency"() { |
||||
when: |
||||
BuildResult result = testKit.withProjectResource("samples/testsconfiguration") |
||||
.withArguments('check') |
||||
.build(); |
||||
then: |
||||
result.task(":web:check").outcome == SUCCESS |
||||
} |
||||
} |
||||
@ -0,0 +1,31 @@
@@ -0,0 +1,31 @@
|
||||
package io.spring.gradle.convention; |
||||
|
||||
import io.spring.gradle.TestKit; |
||||
import org.gradle.testkit.runner.BuildResult; |
||||
import org.junit.jupiter.api.BeforeEach; |
||||
import org.junit.jupiter.api.Test; |
||||
import org.junit.jupiter.api.io.TempDir; |
||||
|
||||
import java.nio.file.Path; |
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat; |
||||
import static org.gradle.testkit.runner.TaskOutcome.SUCCESS; |
||||
|
||||
public class DependencySetPluginITest { |
||||
private TestKit testKit; |
||||
|
||||
@BeforeEach |
||||
void setup(@TempDir Path tempDir) { |
||||
this.testKit = new TestKit(tempDir.toFile()); |
||||
} |
||||
|
||||
@Test |
||||
public void dependencies() throws Exception { |
||||
BuildResult result = testKit.withProjectResource("samples/dependencyset") |
||||
.withArguments("dependencies") |
||||
.build(); |
||||
|
||||
assertThat(result.task(":dependencies").getOutcome()).isEqualTo(SUCCESS); |
||||
assertThat(result.getOutput()).doesNotContain("FAILED"); |
||||
} |
||||
} |
||||
@ -0,0 +1,85 @@
@@ -0,0 +1,85 @@
|
||||
package io.spring.gradle.convention; |
||||
|
||||
import io.spring.gradle.TestKit; |
||||
import org.codehaus.groovy.runtime.ResourceGroovyMethods; |
||||
import org.gradle.testkit.runner.BuildResult; |
||||
import org.junit.jupiter.api.BeforeEach; |
||||
import org.junit.jupiter.api.Test; |
||||
import org.junit.jupiter.api.io.TempDir; |
||||
|
||||
import java.io.File; |
||||
import java.nio.file.Path; |
||||
import java.util.Collections; |
||||
import java.util.List; |
||||
import java.util.zip.ZipEntry; |
||||
import java.util.zip.ZipFile; |
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat; |
||||
import static org.gradle.testkit.runner.TaskOutcome.FAILED; |
||||
import static org.gradle.testkit.runner.TaskOutcome.SUCCESS; |
||||
|
||||
public class DocsPluginITest { |
||||
private TestKit testKit; |
||||
|
||||
@BeforeEach |
||||
void setup(@TempDir Path tempDir) { |
||||
this.testKit = new TestKit(tempDir.toFile()); |
||||
} |
||||
|
||||
@Test |
||||
public void buildTriggersDocs() throws Exception { |
||||
BuildResult result = testKit.withProjectResource("samples/docs/simple/") |
||||
.withArguments("build") |
||||
.build(); |
||||
assertThat(result.task(":build").getOutcome()).isEqualTo(SUCCESS); |
||||
assertThat(result.task(":docs").getOutcome()).isEqualTo(SUCCESS); |
||||
assertThat(result.task(":docsZip").getOutcome()).isEqualTo(SUCCESS); |
||||
File zip = new File(testKit.getRootDir(), "build/distributions/simple-1.0.0.BUILD-SNAPSHOT-docs.zip"); |
||||
List<? extends ZipEntry> entries = Collections.list(new ZipFile(zip).entries()); |
||||
assertThat(entries) |
||||
.extracting(ZipEntry::getName) |
||||
.contains("docs/reference/html5/index.html") |
||||
.contains("docs/reference/pdf/simple-reference.pdf"); |
||||
} |
||||
|
||||
@Test |
||||
public void asciidocCopiesImages() throws Exception { |
||||
BuildResult result = testKit.withProjectResource("samples/docs/simple/").withArguments("asciidoctor").build(); |
||||
assertThat(result.task(":asciidoctor").getOutcome()).isEqualTo(SUCCESS); |
||||
assertThat(new File(testKit.getRootDir(), "build/docs/asciidoc/images")).exists(); |
||||
} |
||||
|
||||
@Test |
||||
public void asciidocDocInfoFromResourcesUsed() throws Exception { |
||||
BuildResult result = this.testKit.withProjectResource("samples/docs/simple/") |
||||
.withArguments("asciidoctor") |
||||
.build(); |
||||
assertThat(result.task(":asciidoctor").getOutcome()).isEqualTo(SUCCESS); |
||||
assertThat(ResourceGroovyMethods.getText(new File(testKit.getRootDir(), "build/docs/asciidoc/index.html"))) |
||||
.contains("<script type=\"text/javascript\" src=\"js/tocbot/tocbot.min.js\"></script>"); |
||||
} |
||||
|
||||
@Test |
||||
public void missingAttributeFails() throws Exception { |
||||
BuildResult result = this.testKit.withProjectResource("samples/docs/missing-attribute/") |
||||
.withArguments(":asciidoctor") |
||||
.buildAndFail(); |
||||
assertThat(result.task(":asciidoctor").getOutcome()).isEqualTo(FAILED); |
||||
} |
||||
|
||||
@Test |
||||
public void missingInclude() throws Exception { |
||||
BuildResult result = this.testKit.withProjectResource("samples/docs/missing-include/") |
||||
.withArguments(":asciidoctor") |
||||
.buildAndFail(); |
||||
assertThat(result.task(":asciidoctor").getOutcome()).isEqualTo(FAILED); |
||||
} |
||||
|
||||
@Test |
||||
public void missingCrossReference() throws Exception { |
||||
BuildResult result = this.testKit.withProjectResource("samples/docs/missing-cross-reference/") |
||||
.withArguments(":asciidoctor") |
||||
.buildAndFail(); |
||||
assertThat(result.task(":asciidoctor").getOutcome()).isEqualTo(FAILED); |
||||
} |
||||
} |
||||
@ -0,0 +1,52 @@
@@ -0,0 +1,52 @@
|
||||
package io.spring.gradle.convention; |
||||
|
||||
import io.spring.gradle.TestKit; |
||||
import org.gradle.testkit.runner.BuildResult; |
||||
import org.gradle.testkit.runner.TaskOutcome; |
||||
import org.junit.Test; |
||||
import org.junit.jupiter.api.BeforeEach; |
||||
import org.junit.jupiter.api.io.TempDir; |
||||
|
||||
import java.io.File; |
||||
import java.nio.file.Path; |
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat; |
||||
|
||||
public class IntegrationTestPluginITest { |
||||
private io.spring.gradle.TestKit testKit; |
||||
|
||||
@BeforeEach |
||||
void setup(@TempDir Path tempDir) { |
||||
this.testKit = new TestKit(tempDir.toFile()); |
||||
} |
||||
|
||||
@Test |
||||
public void checkWithJavaPlugin() throws Exception { |
||||
BuildResult result = this.testKit.withProjectResource("samples/integrationtest/withjava/") |
||||
.withArguments("check") |
||||
.build(); |
||||
assertThat(result.task(":check").getOutcome()).isEqualTo(TaskOutcome.SUCCESS); |
||||
assertThat(new File(testKit.getRootDir(), "build/test-results/integrationTest/")).exists(); |
||||
assertThat(new File(testKit.getRootDir(), "build/reports/tests/integrationTest/")).exists(); |
||||
} |
||||
|
||||
@Test |
||||
public void checkWithPropdeps() throws Exception { |
||||
BuildResult result = this.testKit.withProjectResource("samples/integrationtest/withpropdeps/") |
||||
.withArguments("check") |
||||
.build(); |
||||
assertThat(result.task(":check").getOutcome()).isEqualTo(TaskOutcome.SUCCESS); |
||||
assertThat(new File(testKit.getRootDir(), "build/test-results/integrationTest/")).exists(); |
||||
assertThat(new File(testKit.getRootDir(), "build/reports/tests/integrationTest/")).exists(); |
||||
} |
||||
|
||||
@Test |
||||
public void checkWithGroovy() throws Exception { |
||||
BuildResult result = this.testKit.withProjectResource("samples/integrationtest/withgroovy/") |
||||
.withArguments("check") |
||||
.build(); |
||||
assertThat(result.task(":check").getOutcome()).isEqualTo(TaskOutcome.SUCCESS); |
||||
assertThat(new File(testKit.getRootDir(), "build/test-results/integrationTest/")).exists(); |
||||
assertThat(new File(testKit.getRootDir(), "build/reports/tests/integrationTest/")).exists(); |
||||
} |
||||
} |
||||
@ -0,0 +1,31 @@
@@ -0,0 +1,31 @@
|
||||
package io.spring.gradle.convention; |
||||
|
||||
import org.gradle.testkit.runner.BuildResult; |
||||
import org.gradle.testkit.runner.TaskOutcome; |
||||
import org.junit.Test; |
||||
import org.junit.jupiter.api.BeforeEach; |
||||
import org.junit.jupiter.api.io.TempDir; |
||||
|
||||
import java.io.File; |
||||
import java.nio.file.Path; |
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat; |
||||
|
||||
public class JacocoPluginITest{ |
||||
private io.spring.gradle.TestKit testKit; |
||||
|
||||
@BeforeEach |
||||
void setup(@TempDir Path tempDir) { |
||||
this.testKit = new io.spring.gradle.TestKit(tempDir.toFile()); |
||||
} |
||||
|
||||
@Test |
||||
public void checkWithJavaPlugin() throws Exception { |
||||
BuildResult result = this.testKit.withProjectResource("samples/jacoco/java/") |
||||
.withArguments("check") |
||||
.build(); |
||||
assertThat(result.task(":check").getOutcome()).isEqualTo(TaskOutcome.SUCCESS); |
||||
assertThat(new File(testKit.getRootDir(), "build/jacoco")).exists(); |
||||
assertThat(new File(testKit.getRootDir(), "build/reports/jacoco/test/html/")).exists(); |
||||
} |
||||
} |
||||
@ -0,0 +1,38 @@
@@ -0,0 +1,38 @@
|
||||
package io.spring.gradle.convention; |
||||
|
||||
import io.spring.gradle.TestKit; |
||||
import org.apache.commons.io.FileUtils; |
||||
import org.gradle.testkit.runner.BuildResult; |
||||
import org.gradle.testkit.runner.TaskOutcome; |
||||
import org.junit.jupiter.api.BeforeEach; |
||||
import org.junit.jupiter.api.Test; |
||||
import org.junit.jupiter.api.io.TempDir; |
||||
|
||||
import java.io.File; |
||||
import java.nio.file.Path; |
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat; |
||||
|
||||
public class JavadocApiPluginITest { |
||||
private TestKit testKit; |
||||
|
||||
@BeforeEach |
||||
void setup(@TempDir Path tempDir) { |
||||
this.testKit = new TestKit(tempDir.toFile()); |
||||
} |
||||
|
||||
@Test |
||||
public void multiModuleApi() throws Exception { |
||||
BuildResult result = this.testKit.withProjectResource("samples/javadocapi/multimodule/") |
||||
.withArguments("api") |
||||
.build(); |
||||
assertThat(result.task(":api").getOutcome()).isEqualTo(TaskOutcome.SUCCESS); |
||||
File allClasses = new File(testKit.getRootDir(), "build/api/allclasses-noframe.html"); |
||||
File index = new File(testKit.getRootDir(), "build/api/allclasses.html"); |
||||
File listing = allClasses.exists() ? allClasses : index; |
||||
String listingText = FileUtils.readFileToString(listing); |
||||
assertThat(listingText).contains("sample/Api.html"); |
||||
assertThat(listingText).contains("sample/Impl.html"); |
||||
assertThat(listingText).doesNotContain("sample/Sample.html"); |
||||
} |
||||
} |
||||
@ -0,0 +1,71 @@
@@ -0,0 +1,71 @@
|
||||
package io.spring.gradle.convention; |
||||
|
||||
import io.spring.gradle.TestKit; |
||||
import org.codehaus.groovy.runtime.ResourceGroovyMethods; |
||||
import org.gradle.testkit.runner.BuildResult; |
||||
import org.gradle.testkit.runner.TaskOutcome; |
||||
import org.junit.jupiter.api.BeforeEach; |
||||
import org.junit.jupiter.api.Disabled; |
||||
import org.junit.jupiter.api.Test; |
||||
import org.junit.jupiter.api.io.TempDir; |
||||
|
||||
import java.io.File; |
||||
import java.nio.file.Files; |
||||
import java.nio.file.Path; |
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat; |
||||
|
||||
public class ShowcaseITest { |
||||
private TestKit testKit; |
||||
|
||||
@BeforeEach |
||||
void setup(@TempDir Path tempDir) { |
||||
this.testKit = new TestKit(tempDir.toFile()); |
||||
} |
||||
|
||||
@Test |
||||
public void build() throws Exception { |
||||
BuildResult result = this.testKit.withProjectResource("samples/showcase/") |
||||
.withArguments("build", "--stacktrace") |
||||
.forwardOutput() |
||||
.build(); |
||||
assertThat(result.getOutput()).contains("BUILD SUCCESSFUL"); |
||||
} |
||||
|
||||
@Test |
||||
@Disabled |
||||
public void install() throws Exception { |
||||
BuildResult result = this.testKit |
||||
.withProjectResource("samples/showcase/") |
||||
.withArguments("install", "--stacktrace") |
||||
.build(); |
||||
|
||||
assertThat(result.getOutput()).contains("SUCCESS"); |
||||
|
||||
File pom = new File(testKit.getRootDir(), "sgbcs-core/build/poms/pom-default.xml"); |
||||
assertThat(pom).exists(); |
||||
|
||||
String pomText = new String(Files.readAllBytes(pom.toPath())); |
||||
String pomTextNoSpace = pomText.replaceAll("\\s", ""); |
||||
|
||||
assertThat(pomText).doesNotContain("<dependencyManagement>"); |
||||
|
||||
assertThat(pomTextNoSpace).contains("<dependency>\n <groupId>org.springframework</groupId>\n <artifactId>spring-test</artifactId>\n <scope>test</scope>\n <version>4.3.6.RELEASE</version>\n </dependency>".replaceAll("\\s", "")); |
||||
assertThat(pomTextNoSpace).contains("<developers>\n <developer>\n <id>rwinch</id>\n <name>Rob Winch</name>\n <email>rwinch@pivotal.io</email>\n </developer>\n <developer>\n <id>jgrandja</id>\n <name>Joe Grandja</name>\n <email>jgrandja@pivotal.io</email>\n </developer>\n </developers>".replaceAll("\\s", "")); |
||||
assertThat(pomTextNoSpace).contains("<scm>\n <connection>scm:git:git://github.com/spring-projects/spring-security</connection>\n <developerConnection>scm:git:git://github.com/spring-projects/spring-security</developerConnection>\n <url>https://github.com/spring-projects/spring-security</url>\n </scm>".replaceAll("\\s", "")); |
||||
assertThat(pomTextNoSpace).contains("<description>sgbcs-core</description>"); |
||||
assertThat(pomTextNoSpace).contains("<url>https://spring.io/spring-security</url>"); |
||||
assertThat(pomTextNoSpace).contains("<organization>\n <name>spring.io</name>\n <url>https://spring.io/</url>\n </organization>".replaceAll("\\s", "")); |
||||
assertThat(pomTextNoSpace).contains(" <licenses>\n <license>\n <name>The Apache Software License, Version 2.0</name>\n <url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>\n <distribution>repo</distribution>\n </license>\n </licenses>".replaceAll("\\s", "")); |
||||
assertThat(pomTextNoSpace).contains("<scm>\n <connection>scm:git:git://github.com/spring-projects/spring-security</connection>\n <developerConnection>scm:git:git://github.com/spring-projects/spring-security</developerConnection>\n <url>https://github.com/spring-projects/spring-security</url>\n </scm>".replaceAll("\\s", "")); |
||||
|
||||
File bom = new File(testKit.getRootDir(), "bom/build/poms/pom-default.xml"); |
||||
assertThat(bom).exists(); |
||||
assertThat(bom).hasContent("<artifactId>sgbcs-core</artifactId>"); |
||||
|
||||
BuildResult secondBuild = this.testKit.withProjectResource("samples/showcase/").withArguments("mavenBom", "--stacktrace").build(); |
||||
// mavenBom is not up to date since install is never up to date
|
||||
assertThat(result.task(":bom:mavenBom").getOutcome()).isEqualTo(TaskOutcome.SUCCESS); |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,74 @@
@@ -0,0 +1,74 @@
|
||||
package io.spring.gradle.convention; |
||||
|
||||
import io.spring.gradle.TestKit; |
||||
import org.apache.commons.io.IOUtils; |
||||
import org.gradle.testkit.runner.BuildResult; |
||||
import org.junit.jupiter.api.BeforeEach; |
||||
import org.junit.jupiter.api.Disabled; |
||||
import org.junit.jupiter.api.Test; |
||||
import org.junit.jupiter.api.io.TempDir; |
||||
|
||||
import java.io.File; |
||||
import java.nio.file.Files; |
||||
import java.nio.file.Path; |
||||
import java.util.LinkedHashMap; |
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat; |
||||
|
||||
public class SpringMavenPluginITest { |
||||
|
||||
private TestKit testKit; |
||||
|
||||
@BeforeEach |
||||
void setup(@TempDir Path tempDir) { |
||||
this.testKit = new TestKit(tempDir.toFile()); |
||||
} |
||||
|
||||
@Disabled |
||||
@Test |
||||
public void install() throws Exception { |
||||
BuildResult result = this.testKit.withProjectResource("samples/maven/install") |
||||
.withArguments("install") |
||||
.build(); |
||||
assertThat(result.getOutput()).contains("SUCCESS"); |
||||
File pom = new File(testKit.getRootDir(), "build/poms/pom-default.xml"); |
||||
assertThat(pom).exists(); |
||||
String pomText = new String(Files.readAllBytes(pom.toPath())); |
||||
assertThat(pomText.replaceAll("\\s", "")).contains("<dependency>\n <groupId>aopalliance</groupId>\n <artifactId>aopalliance</artifactId>\n <version>1.0</version>\n <scope>compile</scope>\n <optional>true</optional>\n </dependency>".replaceAll("\\s", "")); |
||||
} |
||||
|
||||
@Disabled |
||||
@Test |
||||
public void signArchivesWhenInMemory() throws Exception { |
||||
LinkedHashMap<String, String> map = new LinkedHashMap<String, String>(2); |
||||
map.put("ORG_GRADLE_PROJECT_signingKey", getSigningKey()); |
||||
map.put("ORG_GRADLE_PROJECT_signingPassword", "password"); |
||||
BuildResult result = this.testKit.withProjectResource("samples/maven/signing") |
||||
.withArguments("signArchives") |
||||
.withEnvironment(map) |
||||
.forwardOutput() |
||||
.build(); |
||||
assertThat(result.getOutput()).contains("SUCCESS"); |
||||
final File jar = new File(testKit.getRootDir(), "build/libs/signing-1.0.0.RELEASE.jar"); |
||||
assertThat(jar).exists(); |
||||
File signature = new File(jar.getAbsolutePath() + ".asc"); |
||||
assertThat(signature).exists(); |
||||
} |
||||
|
||||
@Test |
||||
public void upload() throws Exception { |
||||
BuildResult result = this.testKit.withProjectResource("samples/maven/upload") |
||||
.withArguments("uploadArchives") |
||||
.forwardOutput() |
||||
.build(); |
||||
assertThat(result.getOutput()).contains("SUCCESS"); |
||||
File pom = new File(testKit.getRootDir(), "build/poms/pom-default.xml"); |
||||
assertThat(pom).exists(); |
||||
String pomText = new String(Files.readAllBytes(pom.toPath())); |
||||
assertThat(pomText.replaceAll("\\s", "")).contains("<dependency>\n <groupId>aopalliance</groupId>\n <artifactId>aopalliance</artifactId>\n <version>1.0</version>\n <scope>compile</scope>\n <optional>true</optional>\n </dependency>".replaceAll("\\s", "")); |
||||
} |
||||
|
||||
public String getSigningKey() throws Exception { |
||||
return IOUtils.toString(getClass().getResource("/test-private.pgp")); |
||||
} |
||||
} |
||||
@ -0,0 +1,31 @@
@@ -0,0 +1,31 @@
|
||||
package io.spring.gradle.convention; |
||||
|
||||
import io.spring.gradle.TestKit; |
||||
import org.gradle.testkit.runner.BuildResult; |
||||
import org.gradle.testkit.runner.TaskOutcome; |
||||
import org.junit.jupiter.api.BeforeEach; |
||||
import org.junit.jupiter.api.Test; |
||||
import org.junit.jupiter.api.io.TempDir; |
||||
|
||||
import java.nio.file.Path; |
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat; |
||||
|
||||
public class TestsConfigurationPluginITest { |
||||
|
||||
private TestKit testKit; |
||||
|
||||
@BeforeEach |
||||
void setup(@TempDir Path tempDir) { |
||||
this.testKit = new TestKit(tempDir.toFile()); |
||||
} |
||||
|
||||
@Test |
||||
public void canFindDepencency() throws Exception { |
||||
BuildResult result = this.testKit.withProjectResource("samples/testsconfiguration") |
||||
.withArguments("check") |
||||
.build(); |
||||
assertThat(result.task(":web:check").getOutcome()).isEqualTo(TaskOutcome.SUCCESS); |
||||
} |
||||
|
||||
} |
||||
Loading…
Reference in new issue