Remove unnecessary throws declaration in tests

See gh-26441
This commit is contained in:
weixsun
2021-05-13 00:22:53 +08:00
committed by Stephane Nicoll
parent 574655dc84
commit 8a2be288a3
129 changed files with 345 additions and 369 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 the original author or authors.
* Copyright 2012-2021 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.
@@ -41,14 +41,14 @@ class IntegratingWithActuatorDocumentationTests {
GradleBuild gradleBuild;
@TestTemplate
void basicBuildInfo() throws IOException {
void basicBuildInfo() {
this.gradleBuild.script("src/docs/gradle/integrating-with-actuator/build-info-basic").build("bootBuildInfo");
assertThat(new File(this.gradleBuild.getProjectDir(), "build/resources/main/META-INF/build-info.properties"))
.isFile();
}
@TestTemplate
void buildInfoCustomValues() throws IOException {
void buildInfoCustomValues() {
this.gradleBuild.script("src/docs/gradle/integrating-with-actuator/build-info-custom-values")
.build("bootBuildInfo");
File file = new File(this.gradleBuild.getProjectDir(), "build/resources/main/META-INF/build-info.properties");
@@ -61,7 +61,7 @@ class IntegratingWithActuatorDocumentationTests {
}
@TestTemplate
void buildInfoAdditional() throws IOException {
void buildInfoAdditional() {
this.gradleBuild.script("src/docs/gradle/integrating-with-actuator/build-info-additional")
.build("bootBuildInfo");
File file = new File(this.gradleBuild.getProjectDir(), "build/resources/main/META-INF/build-info.properties");

View File

@@ -16,8 +16,6 @@
package org.springframework.boot.gradle.docs;
import java.io.IOException;
import org.junit.jupiter.api.TestTemplate;
import org.junit.jupiter.api.condition.DisabledForJreRange;
import org.junit.jupiter.api.condition.JRE;
@@ -41,14 +39,14 @@ class PublishingDocumentationTests {
@DisabledForJreRange(min = JRE.JAVA_16)
@TestTemplate
void mavenUpload() throws IOException {
void mavenUpload() {
assertThat(this.gradleBuild.expectDeprecationWarningsWithAtLeastVersion("5.6")
.script("src/docs/gradle/publishing/maven").build("deployerRepository").getOutput())
.contains("https://repo.example.com");
}
@TestTemplate
void mavenPublish() throws IOException {
void mavenPublish() {
assertThat(this.gradleBuild.script("src/docs/gradle/publishing/maven-publish").build("publishingConfiguration")
.getOutput()).contains("MavenPublication").contains("https://repo.example.com");
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 the original author or authors.
* Copyright 2012-2021 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.
@@ -65,25 +65,25 @@ class RunningDocumentationTests {
}
@TestTemplate
void bootRunSourceResources() throws IOException {
void bootRunSourceResources() {
assertThat(this.gradleBuild.script("src/docs/gradle/running/boot-run-source-resources")
.build("configuredClasspath").getOutput()).contains(new File("src/main/resources").getPath());
}
@TestTemplate
void bootRunDisableOptimizedLaunch() throws IOException {
void bootRunDisableOptimizedLaunch() {
assertThat(this.gradleBuild.script("src/docs/gradle/running/boot-run-disable-optimized-launch")
.build("optimizedLaunch").getOutput()).contains("false");
}
@TestTemplate
void bootRunSystemPropertyDefaultValue() throws IOException {
void bootRunSystemPropertyDefaultValue() {
assertThat(this.gradleBuild.script("src/docs/gradle/running/boot-run-system-property")
.build("configuredSystemProperties").getOutput()).contains("com.example.property = default");
}
@TestTemplate
void bootRunSystemPropetry() throws IOException {
void bootRunSystemPropetry() {
assertThat(this.gradleBuild.script("src/docs/gradle/running/boot-run-system-property")
.build("-Pexample=custom", "configuredSystemProperties").getOutput())
.contains("com.example.property = custom");

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 the original author or authors.
* Copyright 2012-2021 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.
@@ -42,7 +42,7 @@ class BuildInfoDslIntegrationTests {
GradleBuild gradleBuild;
@TestTemplate
void basicJar() throws IOException {
void basicJar() {
assertThat(this.gradleBuild.build("bootBuildInfo", "--stacktrace").task(":bootBuildInfo").getOutcome())
.isEqualTo(TaskOutcome.SUCCESS);
Properties properties = buildInfoProperties();
@@ -53,7 +53,7 @@ class BuildInfoDslIntegrationTests {
}
@TestTemplate
void jarWithCustomName() throws IOException {
void jarWithCustomName() {
assertThat(this.gradleBuild.build("bootBuildInfo", "--stacktrace").task(":bootBuildInfo").getOutcome())
.isEqualTo(TaskOutcome.SUCCESS);
Properties properties = buildInfoProperties();
@@ -64,7 +64,7 @@ class BuildInfoDslIntegrationTests {
}
@TestTemplate
void basicWar() throws IOException {
void basicWar() {
assertThat(this.gradleBuild.build("bootBuildInfo", "--stacktrace").task(":bootBuildInfo").getOutcome())
.isEqualTo(TaskOutcome.SUCCESS);
Properties properties = buildInfoProperties();
@@ -75,7 +75,7 @@ class BuildInfoDslIntegrationTests {
}
@TestTemplate
void warWithCustomName() throws IOException {
void warWithCustomName() {
assertThat(this.gradleBuild.build("bootBuildInfo", "--stacktrace").task(":bootBuildInfo").getOutcome())
.isEqualTo(TaskOutcome.SUCCESS);
Properties properties = buildInfoProperties();
@@ -86,7 +86,7 @@ class BuildInfoDslIntegrationTests {
}
@TestTemplate
void additionalProperties() throws IOException {
void additionalProperties() {
assertThat(this.gradleBuild.build("bootBuildInfo", "--stacktrace").task(":bootBuildInfo").getOutcome())
.isEqualTo(TaskOutcome.SUCCESS);
Properties properties = buildInfoProperties();
@@ -99,7 +99,7 @@ class BuildInfoDslIntegrationTests {
}
@TestTemplate
void classesDependency() throws IOException {
void classesDependency() {
assertThat(this.gradleBuild.build("classes", "--stacktrace").task(":bootBuildInfo").getOutcome())
.isEqualTo(TaskOutcome.SUCCESS);
}

View File

@@ -92,7 +92,7 @@ class BuildInfoIntegrationTests {
}
@TestTemplate
void notUpToDateWhenExecutedTwiceWithFixedTimeAndChangedProjectVersion() throws IOException {
void notUpToDateWhenExecutedTwiceWithFixedTimeAndChangedProjectVersion() {
assertThat(this.gradleBuild.scriptProperty("projectVersion", "0.1.0").build("buildInfo").task(":buildInfo")
.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
assertThat(this.gradleBuild.scriptProperty("projectVersion", "0.2.0").build("buildInfo").task(":buildInfo")

View File

@@ -86,7 +86,7 @@ abstract class AbstractBootArchiveIntegrationTests {
}
@TestTemplate
void basicBuild() throws InvalidRunnerConfigurationException, UnexpectedBuildFailure, IOException {
void basicBuild() {
assertThat(this.gradleBuild.build(this.taskName).task(":" + this.taskName).getOutcome())
.isEqualTo(TaskOutcome.SUCCESS);
}
@@ -106,7 +106,7 @@ abstract class AbstractBootArchiveIntegrationTests {
}
@TestTemplate
void upToDateWhenBuiltTwice() throws InvalidRunnerConfigurationException, UnexpectedBuildFailure, IOException {
void upToDateWhenBuiltTwice() {
assertThat(this.gradleBuild.build(this.taskName).task(":" + this.taskName).getOutcome())
.isEqualTo(TaskOutcome.SUCCESS);
assertThat(this.gradleBuild.build(this.taskName).task(":" + this.taskName).getOutcome())
@@ -114,8 +114,7 @@ abstract class AbstractBootArchiveIntegrationTests {
}
@TestTemplate
void upToDateWhenBuiltTwiceWithLaunchScriptIncluded()
throws InvalidRunnerConfigurationException, UnexpectedBuildFailure, IOException {
void upToDateWhenBuiltTwiceWithLaunchScriptIncluded() {
assertThat(this.gradleBuild.build("-PincludeLaunchScript=true", this.taskName).task(":" + this.taskName)
.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
assertThat(this.gradleBuild.build("-PincludeLaunchScript=true", this.taskName).task(":" + this.taskName)
@@ -167,7 +166,7 @@ abstract class AbstractBootArchiveIntegrationTests {
}
@TestTemplate
void duplicatesAreHandledGracefully() throws IOException {
void duplicatesAreHandledGracefully() {
assertThat(this.gradleBuild.build(this.taskName).task(":" + this.taskName).getOutcome())
.isEqualTo(TaskOutcome.SUCCESS);
}
@@ -257,7 +256,7 @@ abstract class AbstractBootArchiveIntegrationTests {
}
@TestTemplate
void layersWithCustomSourceSet() throws IOException {
void layersWithCustomSourceSet() {
assertThat(this.gradleBuild.build(this.taskName).task(":" + this.taskName).getOutcome())
.isEqualTo(TaskOutcome.SUCCESS);
}

View File

@@ -66,7 +66,7 @@ public class BootBuildImageRegistryIntegrationTests {
}
@TestTemplate
void buildsImageAndPublishesToRegistry() throws IOException, InterruptedException {
void buildsImageAndPublishesToRegistry() throws IOException {
writeMainClass();
String repoName = "test-image";
String imageName = this.registryAddress + "/" + repoName;

View File

@@ -17,8 +17,6 @@
package org.springframework.boot.gradle.tasks.bundling;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import org.gradle.testkit.runner.BuildResult;
import org.gradle.testkit.runner.TaskOutcome;
@@ -43,7 +41,7 @@ class MavenIntegrationTests {
GradleBuild gradleBuild;
@TestTemplate
void bootJarCanBeUploaded() throws FileNotFoundException, IOException {
void bootJarCanBeUploaded() {
BuildResult result = this.gradleBuild.expectDeprecationWarningsWithAtLeastVersion("6.0.0")
.build("uploadBootArchives");
assertThat(result.task(":uploadBootArchives").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
@@ -53,7 +51,7 @@ class MavenIntegrationTests {
}
@TestTemplate
void bootWarCanBeUploaded() throws IOException {
void bootWarCanBeUploaded() {
BuildResult result = this.gradleBuild.expectDeprecationWarningsWithAtLeastVersion("6.0.0")
.build("uploadBootArchives");
assertThat(result.task(":uploadBootArchives").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 the original author or authors.
* Copyright 2012-2021 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.
@@ -17,8 +17,6 @@
package org.springframework.boot.gradle.tasks.bundling;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import org.gradle.testkit.runner.BuildResult;
import org.gradle.testkit.runner.TaskOutcome;
@@ -41,7 +39,7 @@ class MavenPublishingIntegrationTests {
GradleBuild gradleBuild;
@TestTemplate
void bootJarCanBePublished() throws FileNotFoundException, IOException {
void bootJarCanBePublished() {
BuildResult result = this.gradleBuild.build("publish");
assertThat(result.task(":publish").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
assertThat(artifactWithSuffix("jar")).isFile();
@@ -50,7 +48,7 @@ class MavenPublishingIntegrationTests {
}
@TestTemplate
void bootWarCanBePublished() throws IOException {
void bootWarCanBePublished() {
BuildResult result = this.gradleBuild.build("publish");
assertThat(result.task(":publish").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
assertThat(artifactWithSuffix("war")).isFile();