From 886e3513d5e9c84815a82e8fb7c78ccce6d474b5 Mon Sep 17 00:00:00 2001 From: Robert McNees <86265089+robertmcnees@users.noreply.github.com> Date: Mon, 21 Mar 2022 11:44:02 -0400 Subject: [PATCH] Update Unit Tests from JUnit4 to JUnit5 (#251) * JUnit5 upgrade * Refactor JUnit4 TemporaryFolder * Remove JUnit4 dependency --- .../SpringCloudCustomMavenBomTests.java | 4 +- .../SpringCloudMavenBomParserTests.java | 16 +- .../SpringCloudProjectPomUpdaterTests.java | 2 +- ...ustomProjectDocumentationUpdaterTests.java | 16 +- .../github/SpringCloudGithubIssuesTests.java | 13 +- .../AbstractSpringCloudAcceptanceTests.java | 7 +- ...bstractSpringCloudMetaAcceptanceTests.java | 6 +- .../SpringMetaReleaseAcceptanceTests.java | 140 +++++++++++------- .../SpringSingleProjectAcceptanceTests.java | 101 ++++++++----- releaser-core/pom.xml | 5 - .../internal/PomUpdateAcceptanceTests.java | 16 +- .../internal/ReleaserPropertiesTests.java | 4 +- .../java/releaser/internal/ReleaserTests.java | 34 ++--- .../buildsystem/LoggerToMavenLogTests.java | 10 +- .../buildsystem/MavenBomParserTests.java | 8 +- .../internal/buildsystem/PomReaderTests.java | 8 +- .../internal/buildsystem/PomUpdaterTests.java | 20 +-- .../buildsystem/ProjectPomUpdaterTests.java | 4 +- .../buildsystem/ProjectVersionTests.java | 8 +- .../internal/buildsystem/ProjectsTests.java | 4 +- .../buildsystem/PropertyStorerTests.java | 10 +- .../PropertyVersionChangerTests.java | 10 +- .../buildsystem/VersionsFromBomTests.java | 4 +- .../docs/ReleaseTrainContentsParserTests.java | 4 +- .../ReleaseTrainContentsUpdaterTests.java | 20 +-- .../java/releaser/internal/docs/RowTests.java | 4 +- .../docs/SpringCloudGhPagesParserTests.java | 17 +-- .../releaser/internal/git/GitRepoTests.java | 45 +++--- .../internal/git/ProjectGitHandlerTests.java | 10 +- .../internal/github/GithubIssuesTests.java | 18 +-- .../github/GithubMilestonesTests.java | 51 ++++--- .../internal/gradle/GradleUpdaterTests.java | 16 +- .../postrelease/PostReleaseActionsTests.java | 20 +-- .../project/ProjectCommandExecutorTests.java | 27 ++-- .../sagan/RestTemplateSaganClientTests.java | 15 +- .../internal/sagan/SaganUpdaterTest.java | 8 +- .../template/TemplateGeneratorTests.java | 4 +- releaser-spring/pom.xml | 5 - .../ReleaserPropertiesUpdaterTests.java | 4 +- releaser-test/pom.xml | 5 - .../spring/AbstractSpringAcceptanceTests.java | 24 ++- .../releaser/internal/spring/ArgsBuilder.java | 60 ++++---- ...tractSpringMetaReleaseAcceptanceTests.java | 58 ++++---- 43 files changed, 427 insertions(+), 438 deletions(-) diff --git a/projects/spring-cloud/src/test/java/releaser/cloud/buildsystem/SpringCloudCustomMavenBomTests.java b/projects/spring-cloud/src/test/java/releaser/cloud/buildsystem/SpringCloudCustomMavenBomTests.java index 1862dcf4..bda5a688 100644 --- a/projects/spring-cloud/src/test/java/releaser/cloud/buildsystem/SpringCloudCustomMavenBomTests.java +++ b/projects/spring-cloud/src/test/java/releaser/cloud/buildsystem/SpringCloudCustomMavenBomTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2019 the original author or authors. + * Copyright 2013-2022 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. @@ -21,7 +21,7 @@ import java.util.HashSet; import java.util.List; import java.util.Set; -import org.junit.Test; +import org.junit.jupiter.api.Test; import releaser.cloud.SpringCloudReleaserProperties; import releaser.internal.buildsystem.CustomBomParser; import releaser.internal.buildsystem.VersionsFromBom; diff --git a/projects/spring-cloud/src/test/java/releaser/cloud/buildsystem/SpringCloudMavenBomParserTests.java b/projects/spring-cloud/src/test/java/releaser/cloud/buildsystem/SpringCloudMavenBomParserTests.java index 3eca8aa0..724a1477 100644 --- a/projects/spring-cloud/src/test/java/releaser/cloud/buildsystem/SpringCloudMavenBomParserTests.java +++ b/projects/spring-cloud/src/test/java/releaser/cloud/buildsystem/SpringCloudMavenBomParserTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2019 the original author or authors. + * Copyright 2013-2022 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. @@ -22,10 +22,9 @@ import java.net.URISyntaxException; import java.util.Arrays; import org.eclipse.jgit.api.errors.GitAPIException; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.TemporaryFolder; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; import releaser.cloud.SpringCloudReleaserProperties; import releaser.cloud.docs.TestUtils; import releaser.internal.ReleaserProperties; @@ -43,18 +42,15 @@ import static org.assertj.core.api.BDDAssertions.thenThrownBy; */ public class SpringCloudMavenBomParserTests { - @Rule - public TemporaryFolder tmp = new TemporaryFolder(); - + @TempDir File tmpFolder; File springCloudReleaseProject; ReleaserProperties properties = SpringCloudReleaserProperties.get(); - @Before + @BeforeEach public void setup() throws URISyntaxException, IOException, GitAPIException { - this.tmpFolder = this.tmp.newFolder(); TestUtils.prepareLocalRepo(); FileSystemUtils.copyRecursively(file("/projects"), this.tmpFolder); this.springCloudReleaseProject = new File(this.tmpFolder, "/spring-cloud-release"); diff --git a/projects/spring-cloud/src/test/java/releaser/cloud/buildsystem/SpringCloudProjectPomUpdaterTests.java b/projects/spring-cloud/src/test/java/releaser/cloud/buildsystem/SpringCloudProjectPomUpdaterTests.java index af473ad9..c2f9acb3 100644 --- a/projects/spring-cloud/src/test/java/releaser/cloud/buildsystem/SpringCloudProjectPomUpdaterTests.java +++ b/projects/spring-cloud/src/test/java/releaser/cloud/buildsystem/SpringCloudProjectPomUpdaterTests.java @@ -21,7 +21,7 @@ import java.util.Map; import java.util.stream.Collectors; import org.assertj.core.api.BDDAssertions; -import org.junit.Test; +import org.junit.jupiter.api.Test; import releaser.cloud.SpringCloudReleaserProperties; import releaser.internal.ReleaserProperties; import releaser.internal.buildsystem.MavenBomParserAccessor; diff --git a/projects/spring-cloud/src/test/java/releaser/cloud/docs/SpringCloudCustomProjectDocumentationUpdaterTests.java b/projects/spring-cloud/src/test/java/releaser/cloud/docs/SpringCloudCustomProjectDocumentationUpdaterTests.java index 0a086610..fd30854f 100644 --- a/projects/spring-cloud/src/test/java/releaser/cloud/docs/SpringCloudCustomProjectDocumentationUpdaterTests.java +++ b/projects/spring-cloud/src/test/java/releaser/cloud/docs/SpringCloudCustomProjectDocumentationUpdaterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2019 the original author or authors. + * Copyright 2013-2022 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. @@ -26,10 +26,9 @@ import java.util.Collections; import javax.validation.constraints.NotNull; import org.assertj.core.api.BDDAssertions; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.TemporaryFolder; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; import org.mockito.BDDMockito; import releaser.cloud.SpringCloudReleaserProperties; import releaser.cloud.github.SpringCloudGithubIssuesAccessor; @@ -48,11 +47,9 @@ import org.springframework.util.FileSystemUtils; */ public class SpringCloudCustomProjectDocumentationUpdaterTests { - @Rule - public TemporaryFolder tmp = new TemporaryFolder(); - File project; + @TempDir File tmpFolder; ProjectGitHandler handler; @@ -63,9 +60,8 @@ public class SpringCloudCustomProjectDocumentationUpdaterTests { ReleaserProperties properties = SpringCloudReleaserProperties.get(); - @Before + @BeforeEach public void setup() throws IOException, URISyntaxException { - this.tmpFolder = this.tmp.newFolder(); this.project = new File(SpringCloudCustomProjectDocumentationUpdater.class .getResource("/projects/spring-cloud-static").toURI()); TestUtils.prepareLocalRepo(); diff --git a/projects/spring-cloud/src/test/java/releaser/cloud/github/SpringCloudGithubIssuesTests.java b/projects/spring-cloud/src/test/java/releaser/cloud/github/SpringCloudGithubIssuesTests.java index 9b3d7e83..763cebcc 100644 --- a/projects/spring-cloud/src/test/java/releaser/cloud/github/SpringCloudGithubIssuesTests.java +++ b/projects/spring-cloud/src/test/java/releaser/cloud/github/SpringCloudGithubIssuesTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2019 the original author or authors. + * Copyright 2013-2022 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. @@ -25,10 +25,8 @@ import com.jcabi.github.Issue; import com.jcabi.github.Repo; import com.jcabi.github.Repos; import com.jcabi.github.mock.MkGithub; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.TemporaryFolder; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.BDDMockito; import releaser.cloud.SpringCloudReleaserProperties; import releaser.internal.ReleaserProperties; @@ -44,16 +42,13 @@ import static org.assertj.core.api.BDDAssertions.thenThrownBy; */ public class SpringCloudGithubIssuesTests { - @Rule - public TemporaryFolder folder = new TemporaryFolder(); - ReleaserProperties properties = SpringCloudReleaserProperties.get(); MkGithub github; Repo repo; - @Before + @BeforeEach public void setup() throws IOException { this.github = github("spring-guides"); this.properties.getGit().setOauthToken("a"); diff --git a/projects/spring-cloud/src/test/java/releaser/cloud/spring/AbstractSpringCloudAcceptanceTests.java b/projects/spring-cloud/src/test/java/releaser/cloud/spring/AbstractSpringCloudAcceptanceTests.java index b00ca0fd..f79edb21 100644 --- a/projects/spring-cloud/src/test/java/releaser/cloud/spring/AbstractSpringCloudAcceptanceTests.java +++ b/projects/spring-cloud/src/test/java/releaser/cloud/spring/AbstractSpringCloudAcceptanceTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2019 the original author or authors. + * Copyright 2013-2022 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. @@ -19,7 +19,7 @@ package releaser.cloud.spring; import java.io.File; import java.util.Arrays; -import org.junit.Before; +import org.junit.jupiter.api.BeforeEach; import releaser.internal.buildsystem.TestUtils; import releaser.internal.spring.AbstractSpringAcceptanceTests; @@ -33,9 +33,8 @@ public class AbstractSpringCloudAcceptanceTests extends AbstractSpringAcceptance public File springCloudBuildProject; - @Before + @BeforeEach public void setupCloud() throws Exception { - this.temporaryFolder = this.tmp.newFolder(); this.springCloudConsulProject = new File( AbstractSpringAcceptanceTests.class.getResource("/projects/spring-cloud-consul").toURI()); this.springCloudBuildProject = new File( diff --git a/projects/spring-cloud/src/test/java/releaser/cloud/spring/meta/AbstractSpringCloudMetaAcceptanceTests.java b/projects/spring-cloud/src/test/java/releaser/cloud/spring/meta/AbstractSpringCloudMetaAcceptanceTests.java index 6ad8de2e..a90f2a30 100644 --- a/projects/spring-cloud/src/test/java/releaser/cloud/spring/meta/AbstractSpringCloudMetaAcceptanceTests.java +++ b/projects/spring-cloud/src/test/java/releaser/cloud/spring/meta/AbstractSpringCloudMetaAcceptanceTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2019 the original author or authors. + * Copyright 2013-2022 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. @@ -19,7 +19,7 @@ package releaser.cloud.spring.meta; import java.io.File; import java.util.Arrays; -import org.junit.Before; +import org.junit.jupiter.api.BeforeEach; import releaser.internal.spring.meta.AbstractSpringMetaReleaseAcceptanceTests; import static org.assertj.core.api.BDDAssertions.then; @@ -30,7 +30,7 @@ public class AbstractSpringCloudMetaAcceptanceTests extends AbstractSpringMetaRe public File springCloudBuildProject; - @Before + @BeforeEach public void setupCloud() throws Exception { this.springCloudConsulProject = new File( AbstractSpringCloudMetaAcceptanceTests.class.getResource("/projects/spring-cloud-consul").toURI()); diff --git a/projects/spring-cloud/src/test/java/releaser/cloud/spring/meta/SpringMetaReleaseAcceptanceTests.java b/projects/spring-cloud/src/test/java/releaser/cloud/spring/meta/SpringMetaReleaseAcceptanceTests.java index 20dd81e3..6929692a 100644 --- a/projects/spring-cloud/src/test/java/releaser/cloud/spring/meta/SpringMetaReleaseAcceptanceTests.java +++ b/projects/spring-cloud/src/test/java/releaser/cloud/spring/meta/SpringMetaReleaseAcceptanceTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2019 the original author or authors. + * Copyright 2013-2022 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. @@ -21,7 +21,8 @@ import java.util.Collections; import java.util.LinkedHashMap; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; import org.mockito.BDDMockito; import releaser.internal.Releaser; import releaser.internal.ReleaserProperties; @@ -39,7 +40,6 @@ import releaser.internal.tasks.TrainPostReleaseReleaserTask; import releaser.internal.tasks.composite.MetaReleaseCompositeTask; import releaser.internal.tasks.composite.ReleaseCompositeTask; import releaser.internal.tasks.release.BuildProjectReleaseTask; -import releaser.internal.tech.BuildUnstableException; import releaser.internal.tech.ExecutionResult; import org.springframework.beans.factory.annotation.Value; @@ -64,17 +64,35 @@ import static org.mockito.BDDMockito.given; */ public class SpringMetaReleaseAcceptanceTests extends AbstractSpringCloudMetaAcceptanceTests { + @TempDir + File tempDirTestSamplesProject; + + @TempDir + File tempDirReleaseTrainDocs; + + @TempDir + File tempDirSpringCloud; + + @TempDir + File tempDirReleaseTrainWiki; + + @TempDir + File tempDirAllTestSample; + @Test - public void should_perform_a_meta_release_of_sc_release_and_consul() throws Exception { + public void should_perform_a_meta_release_of_sc_release_and_consul(@TempDir File tempDirSpringCloudConsulOrigin, + @TempDir File tempDirSpringCloudConsulProject) throws Exception { checkoutReleaseTrainBranch("/projects/spring-cloud-release/", "Greenwich"); - File origin = cloneToTemporaryDirectory(this.springCloudConsulProject); + File origin = cloneToTemporaryDirectory(tempDirSpringCloudConsulOrigin, this.springCloudConsulProject); assertThatClonedConsulProjectIsInSnapshots(origin); - File project = cloneToTemporaryDirectory(tmpFile("spring-cloud-consul")); + File project = cloneToTemporaryDirectory(tempDirSpringCloudConsulProject, tmpFile("spring-cloud-consul")); GitTestUtils.setOriginOnProjectToTmp(origin, project); run(defaultRunner(), - properties("debugx=true").properties("test.metarelease=true").properties( - metaReleaseArgs(project).bomBranch("vGreenwich.SR2").addFixedVersions(edgwareSr10()).build()), + properties("debugx=true").properties("test.metarelease=true") + .properties(metaReleaseArgs(project, tempDirTestSamplesProject, tempDirReleaseTrainDocs, + tempDirSpringCloud, tempDirReleaseTrainWiki, tempDirAllTestSample) + .bomBranch("vGreenwich.SR2").addFixedVersions(edgwareSr10()).build()), context -> { SpringReleaser releaser = context.getBean(SpringReleaser.class); NonAssertingTestProjectGitHandler nonAssertingTestProjectGitHandler = context @@ -104,16 +122,18 @@ public class SpringMetaReleaseAcceptanceTests extends AbstractSpringCloudMetaAcc } @Test - public void should_perform_a_meta_release_of_sc_release_and_consul_in_parallel() throws Exception { + public void should_perform_a_meta_release_of_sc_release_and_consul_in_parallel( + @TempDir File tempDirSpringCloudConsulOrigin, @TempDir File tempDirSpringCloudConsulProject) + throws Exception { checkoutReleaseTrainBranch("/projects/spring-cloud-release/", "Greenwich"); - File origin = cloneToTemporaryDirectory(this.springCloudConsulProject); + File origin = cloneToTemporaryDirectory(tempDirSpringCloudConsulOrigin, this.springCloudConsulProject); assertThatClonedConsulProjectIsInSnapshots(origin); - File project = cloneToTemporaryDirectory(tmpFile("spring-cloud-consul")); + File project = cloneToTemporaryDirectory(tempDirSpringCloudConsulProject, tmpFile("spring-cloud-consul")); GitTestUtils.setOriginOnProjectToTmp(origin, project); - run(defaultRunner(), - properties("debugx=true").properties("test.metarelease=true") - .properties(metaReleaseArgsForParallel(project).bomBranch("vGreenwich.SR2") + run(defaultRunner(), properties("debugx=true").properties("test.metarelease=true") + .properties(metaReleaseArgsForParallel(project, tempDirTestSamplesProject, tempDirReleaseTrainDocs, + tempDirSpringCloud, tempDirReleaseTrainWiki, tempDirAllTestSample).bomBranch("vGreenwich.SR2") .addFixedVersions(edgwareSr10()) .metaReleaseGroups("example1,example2", "spring-cloud-build,spring-cloud-consul,spring-cloud-release") @@ -150,16 +170,20 @@ public class SpringMetaReleaseAcceptanceTests extends AbstractSpringCloudMetaAcc } @Test - public void should_perform_a_meta_release_dry_run_of_sc_release_and_consul() throws Exception { + public void should_perform_a_meta_release_dry_run_of_sc_release_and_consul( + @TempDir File tempDirSpringCloudConsulOrigin, @TempDir File tempDirSpringCloudConsulProject) + throws Exception { checkoutReleaseTrainBranch("/projects/spring-cloud-release/", "Greenwich"); - File origin = cloneToTemporaryDirectory(this.springCloudConsulProject); + File origin = cloneToTemporaryDirectory(tempDirSpringCloudConsulOrigin, this.springCloudConsulProject); assertThatClonedConsulProjectIsInSnapshots(origin); - File project = cloneToTemporaryDirectory(tmpFile("spring-cloud-consul")); + File project = cloneToTemporaryDirectory(tempDirSpringCloudConsulProject, tmpFile("spring-cloud-consul")); GitTestUtils.setOriginOnProjectToTmp(origin, project); run(defaultRunner(), - properties("debugx=true").properties("test.metarelease=true").properties( - metaReleaseArgs(project).bomBranch("vGreenwich.SR2").addFixedVersions(edgwareSr10()).build()), + properties("debugx=true").properties("test.metarelease=true") + .properties(metaReleaseArgs(project, tempDirTestSamplesProject, tempDirReleaseTrainDocs, + tempDirSpringCloud, tempDirReleaseTrainWiki, tempDirAllTestSample) + .bomBranch("vGreenwich.SR2").addFixedVersions(edgwareSr10()).build()), context -> { SpringReleaser releaser = context.getBean(SpringReleaser.class); NonAssertingTestProjectGitHandler nonAssertingTestProjectGitHandler = context @@ -191,18 +215,22 @@ public class SpringMetaReleaseAcceptanceTests extends AbstractSpringCloudMetaAcc } @Test - public void should_not_release_any_projects_when_they_are_on_list_of_projects_to_skip() throws Exception { + public void should_not_release_any_projects_when_they_are_on_list_of_projects_to_skip( + @TempDir File tempDirSpringCloudConsulOrigin, @TempDir File tempDirSpringCloudConsulProject, + @TempDir File temporaryDestination) throws Exception { checkoutReleaseTrainBranch("/projects/spring-cloud-release/", "Greenwich"); - File origin = cloneToTemporaryDirectory(this.springCloudConsulProject); + File origin = cloneToTemporaryDirectory(tempDirSpringCloudConsulOrigin, this.springCloudConsulProject); assertThatClonedConsulProjectIsInSnapshots(origin); - File project = cloneToTemporaryDirectory(tmpFile("spring-cloud-consul")); + File project = cloneToTemporaryDirectory(tempDirSpringCloudConsulProject, tmpFile("spring-cloud-consul")); GitTestUtils.setOriginOnProjectToTmp(origin, project); - File temporaryDestination = this.tmp.newFolder(); - run(defaultRunner(), properties("debugx=true").properties("test.metarelease=true", "test.mockBuild=true") - .properties(metaReleaseArgs(project).bomBranch("Greenwich") - .addFixedVersions(consulAndReleaseSnapshots()).updateReleaseTrainWiki(false) - .cloneDestinationDirectory(temporaryDestination).projectsToSkip("spring-cloud-consul").build()), + run(defaultRunner(), + properties("debugx=true").properties("test.metarelease=true", "test.mockBuild=true") + .properties(metaReleaseArgs(project, tempDirTestSamplesProject, tempDirReleaseTrainDocs, + tempDirSpringCloud, tempDirReleaseTrainWiki, tempDirAllTestSample) + .bomBranch("Greenwich").addFixedVersions(consulAndReleaseSnapshots()) + .updateReleaseTrainWiki(false).cloneDestinationDirectory(temporaryDestination) + .projectsToSkip("spring-cloud-consul").build()), context -> { SpringReleaser releaser = context.getBean(SpringReleaser.class); BuildProjectReleaseTask build = context.getBean(BuildProjectReleaseTask.class); @@ -222,19 +250,21 @@ public class SpringMetaReleaseAcceptanceTests extends AbstractSpringCloudMetaAcc } @Test - public void should_perform_a_meta_release_of_consul_only_when_run_from_got_passed() throws Exception { + public void should_perform_a_meta_release_of_consul_only_when_run_from_got_passed( + @TempDir File tempDirSpringCloudConsulOrigin, @TempDir File tempDirSpringCloudConsulProject, + @TempDir File temporaryDestination) throws Exception { checkoutReleaseTrainBranch("/projects/spring-cloud-release/", "Greenwich"); - File origin = cloneToTemporaryDirectory(this.springCloudConsulProject); + File origin = cloneToTemporaryDirectory(tempDirSpringCloudConsulOrigin, this.springCloudConsulProject); assertThatClonedConsulProjectIsInSnapshots(origin); - File project = cloneToTemporaryDirectory(tmpFile("spring-cloud-consul")); + File project = cloneToTemporaryDirectory(tempDirSpringCloudConsulProject, tmpFile("spring-cloud-consul")); GitTestUtils.setOriginOnProjectToTmp(origin, project); - File temporaryDestination = this.tmp.newFolder(); run(defaultRunner(), properties("debugx=true").properties("test.metarelease=true", "test.mockBuild=true") - .properties(metaReleaseArgs(project).bomBranch("Greenwich") - .addFixedVersions(releaseConsulBuildSnapshots()) - .cloneDestinationDirectory(temporaryDestination).build()), + .properties(metaReleaseArgs(project, tempDirTestSamplesProject, tempDirReleaseTrainDocs, + tempDirSpringCloud, tempDirReleaseTrainWiki, tempDirAllTestSample) + .bomBranch("Greenwich").addFixedVersions(releaseConsulBuildSnapshots()) + .cloneDestinationDirectory(temporaryDestination).build()), context -> { SpringReleaser releaser = context.getBean(SpringReleaser.class); BuildProjectReleaseTask build = context.getBean(BuildProjectReleaseTask.class); @@ -263,19 +293,21 @@ public class SpringMetaReleaseAcceptanceTests extends AbstractSpringCloudMetaAcc } @Test - public void should_perform_a_meta_release_of_consul_only_when_task_names_got_passed() throws Exception { + public void should_perform_a_meta_release_of_consul_only_when_task_names_got_passed( + @TempDir File tempDirSpringCloudConsulOrigin, @TempDir File tempDirSpringCloudConsulProject, + @TempDir File temporaryDestination) throws Exception { checkoutReleaseTrainBranch("/projects/spring-cloud-release/", "Greenwich"); - File origin = cloneToTemporaryDirectory(this.springCloudConsulProject); + File origin = cloneToTemporaryDirectory(tempDirSpringCloudConsulOrigin, this.springCloudConsulProject); assertThatClonedConsulProjectIsInSnapshots(origin); - File project = cloneToTemporaryDirectory(tmpFile("spring-cloud-consul")); + File project = cloneToTemporaryDirectory(tempDirSpringCloudConsulProject, tmpFile("spring-cloud-consul")); GitTestUtils.setOriginOnProjectToTmp(origin, project); - File temporaryDestination = this.tmp.newFolder(); run(defaultRunner(), properties("debugx=true").properties("test.metarelease=true", "test.mockBuild=true") - .properties(metaReleaseArgs(project).bomBranch("Greenwich") - .addFixedVersions(releaseConsulBuildSnapshots()) - .cloneDestinationDirectory(temporaryDestination).build()), + .properties(metaReleaseArgs(project, tempDirTestSamplesProject, tempDirReleaseTrainDocs, + tempDirSpringCloud, tempDirReleaseTrainWiki, tempDirAllTestSample) + .bomBranch("Greenwich").addFixedVersions(releaseConsulBuildSnapshots()) + .cloneDestinationDirectory(temporaryDestination).build()), context -> { SpringReleaser releaser = context.getBean(SpringReleaser.class); BuildProjectReleaseTask build = context.getBean(BuildProjectReleaseTask.class); @@ -304,18 +336,22 @@ public class SpringMetaReleaseAcceptanceTests extends AbstractSpringCloudMetaAcc } @Test - public void should_not_execute_any_subsequent_task_when_first_one_fails() throws Exception { + public void should_not_execute_any_subsequent_task_when_first_one_fails( + @TempDir File tempDirSpringCloudConsulOrigin, @TempDir File tempDirSpringCloudConsulProject) + throws Exception { checkoutReleaseTrainBranch("/projects/spring-cloud-release/", "Greenwich"); - File origin = cloneToTemporaryDirectory(this.springCloudConsulProject); + File origin = cloneToTemporaryDirectory(tempDirSpringCloudConsulOrigin, this.springCloudConsulProject); assertThatClonedConsulProjectIsInSnapshots(origin); - File project = cloneToTemporaryDirectory(tmpFile("spring-cloud-consul")); + File project = cloneToTemporaryDirectory(tempDirSpringCloudConsulProject, tmpFile("spring-cloud-consul")); GitTestUtils.setOriginOnProjectToTmp(origin, project); - run(failingBuildRunner(), properties("debugx=true") - .properties("test.metarelease=true", "test.metarelease.failing=true", - "releaser.flow.default-enabled=false") - .properties( - metaReleaseArgs(project).bomBranch("vGreenwich.SR2").addFixedVersions(edgwareSr10()).build()), + run(failingBuildRunner(), + properties("debugx=true") + .properties("test.metarelease=true", "test.metarelease.failing=true", + "releaser.flow.default-enabled=false") + .properties(metaReleaseArgs(project, tempDirTestSamplesProject, tempDirReleaseTrainDocs, + tempDirSpringCloud, tempDirReleaseTrainWiki, tempDirAllTestSample) + .bomBranch("vGreenwich.SR2").addFixedVersions(edgwareSr10()).build()), context -> { SpringReleaser releaser = context.getBean(SpringReleaser.class); NonAssertingTestProjectGitHandler nonAssertingTestProjectGitHandler = context @@ -502,7 +538,7 @@ class FirstTask implements ReleaseReleaserTask { } @Override - public ExecutionResult runTask(Arguments args) throws BuildUnstableException, RuntimeException { + public ExecutionResult runTask(Arguments args) throws RuntimeException { return ExecutionResult.failure(new IllegalStateException("Failure")); } @@ -536,7 +572,7 @@ class SecondTask implements ReleaseReleaserTask { } @Override - public ExecutionResult runTask(Arguments args) throws BuildUnstableException, RuntimeException { + public ExecutionResult runTask(Arguments args) throws RuntimeException { return ExecutionResult.success(); } @@ -570,7 +606,7 @@ class PostReleaseTask implements TrainPostReleaseReleaserTask { } @Override - public ExecutionResult runTask(Arguments args) throws BuildUnstableException, RuntimeException { + public ExecutionResult runTask(Arguments args) throws RuntimeException { return ExecutionResult.success(); } diff --git a/projects/spring-cloud/src/test/java/releaser/cloud/spring/single/SpringSingleProjectAcceptanceTests.java b/projects/spring-cloud/src/test/java/releaser/cloud/spring/single/SpringSingleProjectAcceptanceTests.java index 6557da25..22e29234 100644 --- a/projects/spring-cloud/src/test/java/releaser/cloud/spring/single/SpringSingleProjectAcceptanceTests.java +++ b/projects/spring-cloud/src/test/java/releaser/cloud/spring/single/SpringSingleProjectAcceptanceTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2019 the original author or authors. + * Copyright 2013-2022 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. @@ -22,7 +22,8 @@ import java.util.Iterator; import org.assertj.core.api.BDDAssertions; import org.eclipse.jgit.revwalk.RevCommit; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; import org.mockito.BDDMockito; import releaser.cloud.spring.AbstractSpringCloudAcceptanceTests; import releaser.internal.ReleaserProperties; @@ -59,23 +60,41 @@ import static org.mockito.Mockito.times; */ public class SpringSingleProjectAcceptanceTests extends AbstractSpringCloudAcceptanceTests { + @TempDir + File tempDirTestSamplesProject; + + @TempDir + File tempDirReleaseTrainDocs; + + @TempDir + File tempDirSpringCloud; + + @TempDir + File tempDirReleaseTrainWiki; + + @TempDir + File tempDirAllTestSample; + SpringApplicationBuilder runner = new SpringApplicationBuilder( SpringSingleProjectAcceptanceTests.SingleProjectReleaseConfig.class, SpringSingleProjectAcceptanceTests.SingleProjectScanningConfiguration.class).web(WebApplicationType.NONE) .properties("spring.jmx.enabled=false"); @Test - public void should_fail_to_perform_a_release_of_consul_when_sc_release_contains_snapshots() throws Exception { + public void should_fail_to_perform_a_release_of_consul_when_sc_release_contains_snapshots( + @TempDir File tempDirSpringCloudConsulOrigin, @TempDir File tempDirSpringCloudConsulProject) + throws Exception { checkoutReleaseTrainBranch("/projects/spring-cloud-release-with-snapshot/", "vCamden.SR5.BROKEN"); - File origin = cloneToTemporaryDirectory(this.springCloudConsulProject); + File origin = cloneToTemporaryDirectory(tempDirSpringCloudConsulOrigin, this.springCloudConsulProject); assertThatClonedConsulProjectIsInSnapshots(origin); - File project = cloneToTemporaryDirectory(tmpFile("spring-cloud-consul")); + File project = cloneToTemporaryDirectory(tempDirSpringCloudConsulProject, tmpFile("spring-cloud-consul")); GitTestUtils.setOriginOnProjectToTmp(origin, project); run(this.runner, - properties("debugx=true").properties(new ArgsBuilder(project, this.tmp) - .releaseTrainUrl("/projects/spring-cloud-release-with-snapshot/") - .bomBranch("vCamden.SR5.BROKEN").expectedVersion("1.1.2.RELEASE").build()), + properties("debugx=true").properties(new ArgsBuilder(project, tempDirTestSamplesProject, + tempDirReleaseTrainDocs, tempDirSpringCloud, tempDirReleaseTrainWiki, tempDirAllTestSample) + .releaseTrainUrl("/projects/spring-cloud-release-with-snapshot/") + .bomBranch("vCamden.SR5.BROKEN").expectedVersion("1.1.2.RELEASE").build()), context -> { SpringReleaser releaser = context.getBean(SpringReleaser.class); BDDAssertions.thenThrownBy(releaser::release).hasMessageContaining( @@ -85,17 +104,19 @@ public class SpringSingleProjectAcceptanceTests extends AbstractSpringCloudAccep } @Test - public void should_perform_a_release_of_consul() throws Exception { + public void should_perform_a_release_of_consul(@TempDir File tempDirSpringCloudConsulOrigin, + @TempDir File tempDirSpringCloudConsulProject) throws Exception { checkoutReleaseTrainBranch("/projects/spring-cloud-release/", "Greenwich"); - File origin = cloneToTemporaryDirectory(this.springCloudConsulProject); + File origin = cloneToTemporaryDirectory(tempDirSpringCloudConsulOrigin, this.springCloudConsulProject); assertThatClonedConsulProjectIsInSnapshots(origin); - File project = cloneToTemporaryDirectory(tmpFile("spring-cloud-consul")); + File project = cloneToTemporaryDirectory(tempDirSpringCloudConsulProject, tmpFile("spring-cloud-consul")); GitTestUtils.setOriginOnProjectToTmp(origin, project); run(this.runner, - properties("debugx=true").properties( - new ArgsBuilder(project, this.tmp).releaseTrainUrl("/projects/spring-cloud-release/") - .bomBranch("vGreenwich.SR2").expectedVersion("2.1.2.RELEASE").build()), + properties("debugx=true").properties(new ArgsBuilder(project, tempDirTestSamplesProject, + tempDirReleaseTrainDocs, tempDirSpringCloud, tempDirReleaseTrainWiki, tempDirAllTestSample) + .releaseTrainUrl("/projects/spring-cloud-release/").bomBranch("vGreenwich.SR2") + .expectedVersion("2.1.2.RELEASE").build()), context -> { SpringReleaser releaser = context.getBean(SpringReleaser.class); TestProjectGitHubHandler gitHubHandler = context.getBean(TestProjectGitHubHandler.class); @@ -137,17 +158,19 @@ public class SpringSingleProjectAcceptanceTests extends AbstractSpringCloudAccep // issue #74 @Test - public void should_perform_a_release_of_sc_build() throws Exception { + public void should_perform_a_release_of_sc_build(@TempDir File tempDirSpringCloudConsulOrigin, + @TempDir File tempDirSpringCloudConsulProject) throws Exception { checkoutReleaseTrainBranch("/projects/spring-cloud-release/", "vGreenwich.SR2"); - File origin = cloneToTemporaryDirectory(this.springCloudBuildProject); + File origin = cloneToTemporaryDirectory(tempDirSpringCloudConsulOrigin, this.springCloudBuildProject); assertThatClonedBuildProjectIsInSnapshots(origin); - File project = cloneToTemporaryDirectory(tmpFile("spring-cloud-build")); + File project = cloneToTemporaryDirectory(tempDirSpringCloudConsulProject, tmpFile("spring-cloud-build")); GitTestUtils.setOriginOnProjectToTmp(origin, project); run(this.runner, - properties("debugx=true").properties(new ArgsBuilder(project, this.tmp) - .releaseTrainUrl("/projects/spring-cloud-release/").bomBranch("vGreenwich.SR2") - .projectName("spring-cloud-build").expectedVersion("2.1.6.RELEASE").build()), + properties("debugx=true").properties(new ArgsBuilder(project, tempDirTestSamplesProject, + tempDirReleaseTrainDocs, tempDirSpringCloud, tempDirReleaseTrainWiki, tempDirAllTestSample) + .releaseTrainUrl("/projects/spring-cloud-release/").bomBranch("vGreenwich.SR2") + .projectName("spring-cloud-build").expectedVersion("2.1.6.RELEASE").build()), context -> { SpringReleaser releaser = context.getBean(SpringReleaser.class); TestProjectGitHubHandler gitHubHandler = context.getBean(TestProjectGitHubHandler.class); @@ -188,17 +211,19 @@ public class SpringSingleProjectAcceptanceTests extends AbstractSpringCloudAccep } @Test - public void should_perform_a_release_of_consul_rc1() throws Exception { + public void should_perform_a_release_of_consul_rc1(@TempDir File tempDirSpringCloudConsulOrigin, + @TempDir File tempDirSpringCloudConsulProject) throws Exception { checkoutReleaseTrainBranch("/projects/spring-cloud-release/", "vDalston.RC1"); - File origin = cloneToTemporaryDirectory(this.springCloudConsulProject); + File origin = cloneToTemporaryDirectory(tempDirSpringCloudConsulOrigin, this.springCloudConsulProject); assertThatClonedConsulProjectIsInSnapshots(origin); - File project = cloneToTemporaryDirectory(tmpFile("spring-cloud-consul")); + File project = cloneToTemporaryDirectory(tempDirSpringCloudConsulProject, tmpFile("spring-cloud-consul")); GitTestUtils.setOriginOnProjectToTmp(origin, project); run(this.runner, - properties("debugx=true").properties( - new ArgsBuilder(project, this.tmp).releaseTrainUrl("/projects/spring-cloud-release/") - .bomBranch("vDalston.RC1").expectedVersion("1.2.0.RC1").build()), + properties("debugx=true").properties(new ArgsBuilder(project, tempDirTestSamplesProject, + tempDirReleaseTrainDocs, tempDirSpringCloud, tempDirReleaseTrainWiki, tempDirAllTestSample) + .releaseTrainUrl("/projects/spring-cloud-release/").bomBranch("vDalston.RC1") + .expectedVersion("1.2.0.RC1").build()), context -> { SpringReleaser releaser = context.getBean(SpringReleaser.class); TestProjectGitHubHandler gitHubHandler = context.getBean(TestProjectGitHubHandler.class); @@ -239,22 +264,24 @@ public class SpringSingleProjectAcceptanceTests extends AbstractSpringCloudAccep } @Test - public void should_not_clone_when_option_not_to_clone_was_switched_on() throws Exception { + public void should_not_clone_when_option_not_to_clone_was_switched_on(@TempDir File tempDirSpringCloudConsulOrigin, + @TempDir File tempDirSpringCloudConsulProject, @TempDir File temporaryDestination) throws Exception { checkoutReleaseTrainBranch("/projects/spring-cloud-release/", "master"); - File origin = cloneToTemporaryDirectory(this.springCloudConsulProject); + File origin = cloneToTemporaryDirectory(tempDirSpringCloudConsulOrigin, this.springCloudConsulProject); assertThatClonedConsulProjectIsInSnapshots(origin); - File project = cloneToTemporaryDirectory(tmpFile("spring-cloud-consul")); + File project = cloneToTemporaryDirectory(tempDirSpringCloudConsulProject, tmpFile("spring-cloud-consul")); GitTestUtils.setOriginOnProjectToTmp(origin, project); - final File temporaryDestination = this.tmp.newFolder(); run(this.runner, - properties("debugx=true").properties(new ArgsBuilder(project, this.tmp) - .releaseTrainUrl("/projects/spring-cloud-release/").bomBranch("vCamden.SR5") - .expectedVersion("1.1.2.RELEASE") - // just build - .chosenOption("6").fetchVersionsFromGit(false).cloneDestinationDirectory(temporaryDestination) - .addFixedVersion("spring-cloud-release", "Finchley.RELEASE") - .addFixedVersion("spring-cloud-consul", "2.3.4.RELEASE").build()), + properties("debugx=true").properties(new ArgsBuilder(project, tempDirTestSamplesProject, + tempDirReleaseTrainDocs, tempDirSpringCloud, tempDirReleaseTrainWiki, tempDirAllTestSample) + .releaseTrainUrl("/projects/spring-cloud-release/").bomBranch("vCamden.SR5") + .expectedVersion("1.1.2.RELEASE") + // just build + .chosenOption("6").fetchVersionsFromGit(false) + .cloneDestinationDirectory(temporaryDestination) + .addFixedVersion("spring-cloud-release", "Finchley.RELEASE") + .addFixedVersion("spring-cloud-consul", "2.3.4.RELEASE").build()), context -> { SpringReleaser releaser = context.getBean(SpringReleaser.class); diff --git a/releaser-core/pom.xml b/releaser-core/pom.xml index 2d09698a..31676203 100644 --- a/releaser-core/pom.xml +++ b/releaser-core/pom.xml @@ -110,11 +110,6 @@ ${awaitility.version} test - - org.junit.vintage - junit-vintage-engine - test - io.spring.sagan sagan-site diff --git a/releaser-core/src/test/java/releaser/internal/PomUpdateAcceptanceTests.java b/releaser-core/src/test/java/releaser/internal/PomUpdateAcceptanceTests.java index 1b006fb7..5d53ffe2 100644 --- a/releaser-core/src/test/java/releaser/internal/PomUpdateAcceptanceTests.java +++ b/releaser-core/src/test/java/releaser/internal/PomUpdateAcceptanceTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2019 the original author or authors. + * Copyright 2013-2022 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. @@ -24,10 +24,9 @@ import java.util.Collections; import org.apache.maven.model.Model; import org.assertj.core.api.BDDAssertions; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.TemporaryFolder; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; import releaser.SpringCloudReleaserProperties; import releaser.internal.buildsystem.MavenBomParserAccessor; import releaser.internal.buildsystem.ProjectPomUpdater; @@ -45,14 +44,11 @@ import static org.assertj.core.api.BDDAssertions.then; */ public class PomUpdateAcceptanceTests { - @Rule - public TemporaryFolder tmp = new TemporaryFolder(); - + @TempDir File temporaryFolder; - @Before + @BeforeEach public void setup() throws Exception { - this.temporaryFolder = this.tmp.newFolder(); TestUtils.prepareLocalRepo(); FileSystemUtils.copyRecursively(file("/projects/"), this.temporaryFolder); } diff --git a/releaser-core/src/test/java/releaser/internal/ReleaserPropertiesTests.java b/releaser-core/src/test/java/releaser/internal/ReleaserPropertiesTests.java index e81bd1cd..0ca9e6c8 100644 --- a/releaser-core/src/test/java/releaser/internal/ReleaserPropertiesTests.java +++ b/releaser-core/src/test/java/releaser/internal/ReleaserPropertiesTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2019 the original author or authors. + * Copyright 2013-2022 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. @@ -21,7 +21,7 @@ import java.util.HashMap; import java.util.Map; import org.assertj.core.api.BDDAssertions; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.BDDAssertions.then; diff --git a/releaser-core/src/test/java/releaser/internal/ReleaserTests.java b/releaser-core/src/test/java/releaser/internal/ReleaserTests.java index 0c9a53cb..513bc71b 100644 --- a/releaser-core/src/test/java/releaser/internal/ReleaserTests.java +++ b/releaser-core/src/test/java/releaser/internal/ReleaserTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2019 the original author or authors. + * Copyright 2013-2022 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. @@ -22,13 +22,12 @@ import java.net.URISyntaxException; import java.util.function.Supplier; import org.assertj.core.api.BDDAssertions; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.BDDMockito; import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; +import org.mockito.junit.jupiter.MockitoExtension; import releaser.SpringCloudReleaserProperties; import releaser.internal.buildsystem.GradleUpdater; import releaser.internal.buildsystem.ProjectPomUpdater; @@ -42,7 +41,8 @@ import releaser.internal.project.Projects; import releaser.internal.sagan.SaganUpdater; import releaser.internal.template.TemplateGenerator; -import org.springframework.boot.test.system.OutputCaptureRule; +import org.springframework.boot.test.system.CapturedOutput; +import org.springframework.boot.test.system.OutputCaptureExtension; import static org.mockito.ArgumentMatchers.any; import static org.mockito.BDDMockito.then; @@ -51,12 +51,9 @@ import static org.mockito.Mockito.never; /** * @author Marcin Grzejszczak */ -@RunWith(MockitoJUnitRunner.class) +@ExtendWith({ MockitoExtension.class, OutputCaptureExtension.class }) public class ReleaserTests { - @Rule - public OutputCaptureRule outputCapture = new OutputCaptureRule(); - @Mock ProjectPomUpdater projectPomUpdater; @@ -86,7 +83,7 @@ public class ReleaserTests { File pom; - @Before + @BeforeEach public void setup() throws URISyntaxException { URI pomUri = ReleaserTests.class.getResource("/projects/project/pom.xml").toURI(); this.pom = new File(pomUri); @@ -110,30 +107,31 @@ public class ReleaserTests { } @Test - public void should_not_bump_versions_for_original_release_project() { + public void should_not_bump_versions_for_original_release_project(CapturedOutput capturedOutput) { releaser(() -> new ProjectVersion("original", "1.0.0.RELEASE")).rollbackReleaseVersion(this.pom, new Projects(new ProjectVersion("changed", "1.0.0.RELEASE")), new ProjectVersion("changed", "1.0.0.RELEASE")); - BDDAssertions.then(this.outputCapture.toString()) + BDDAssertions.then(capturedOutput.toString()) .contains("Successfully reverted the commit and came back to snapshot versions"); then(this.projectGitHandler).should(never()).commitAfterBumpingVersions(any(File.class), any(ProjectVersion.class)); } @Test - public void should_not_bump_versions_for_original_snapshot_project_and_current_snapshot() { + public void should_not_bump_versions_for_original_snapshot_project_and_current_snapshot( + CapturedOutput capturedOutput) { releaser(() -> new ProjectVersion("original", "1.0.0.BUILD-SNAPSHOT")).rollbackReleaseVersion(this.pom, new Projects(new ProjectVersion("changed", "1.0.0.BUILD-SNAPSHOT")), new ProjectVersion("changed", "1.0.0.BUILD-SNAPSHOT")); - BDDAssertions.then(this.outputCapture.toString()).contains("Won't rollback a snapshot version"); + BDDAssertions.then(capturedOutput.toString()).contains("Won't rollback a snapshot version"); then(this.projectGitHandler).should(never()).commitAfterBumpingVersions(any(File.class), any(ProjectVersion.class)); } @Test - public void should_bump_versions_for_original_snapshot_project() { + public void should_bump_versions_for_original_snapshot_project(CapturedOutput capturedOutput) { ProjectVersion scReleaseVersion = new ProjectVersion("changed", "1.0.0.RELEASE"); releaser(() -> new ProjectVersion("original", "1.0.0.BUILD-SNAPSHOT")).rollbackReleaseVersion(this.pom, new Projects(new ProjectVersion("changed", "1.0.0.RELEASE"), @@ -141,7 +139,7 @@ public class ReleaserTests { new ProjectVersion("spring-boot-starter", "3.0.0.RELEASE")), scReleaseVersion); - BDDAssertions.then(this.outputCapture.toString()).contains("Project was successfully updated") + BDDAssertions.then(capturedOutput.toString()).contains("Project was successfully updated") .contains("Successfully reverted the commit and bumped snapshot versions") .contains("spring-boot-starter=>3.0.0.RELEASE").contains("spring-cloud-build=>2.0.1.SNAPSHOT") .contains("changed=>1.0.1.SNAPSHOT"); diff --git a/releaser-core/src/test/java/releaser/internal/buildsystem/LoggerToMavenLogTests.java b/releaser-core/src/test/java/releaser/internal/buildsystem/LoggerToMavenLogTests.java index 525f3dcc..1e086ed1 100644 --- a/releaser-core/src/test/java/releaser/internal/buildsystem/LoggerToMavenLogTests.java +++ b/releaser-core/src/test/java/releaser/internal/buildsystem/LoggerToMavenLogTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2019 the original author or authors. + * Copyright 2013-2022 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. @@ -16,11 +16,11 @@ package releaser.internal.buildsystem; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.InjectMocks; import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; +import org.mockito.junit.jupiter.MockitoExtension; import org.slf4j.Logger; import static org.mockito.BDDMockito.then; @@ -28,7 +28,7 @@ import static org.mockito.BDDMockito.then; /** * @author Marcin Grzejszczak */ -@RunWith(MockitoJUnitRunner.class) +@ExtendWith(MockitoExtension.class) public class LoggerToMavenLogTests { @Mock diff --git a/releaser-core/src/test/java/releaser/internal/buildsystem/MavenBomParserTests.java b/releaser-core/src/test/java/releaser/internal/buildsystem/MavenBomParserTests.java index b5fdfad5..779d3e33 100644 --- a/releaser-core/src/test/java/releaser/internal/buildsystem/MavenBomParserTests.java +++ b/releaser-core/src/test/java/releaser/internal/buildsystem/MavenBomParserTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2019 the original author or authors. + * Copyright 2013-2022 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. @@ -20,8 +20,8 @@ import java.io.File; import java.net.URISyntaxException; import java.util.Collections; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import releaser.SpringCloudReleaserProperties; import releaser.internal.ReleaserProperties; import releaser.internal.git.GitRepoTests; @@ -38,7 +38,7 @@ public class MavenBomParserTests { ReleaserProperties properties = SpringCloudReleaserProperties.get(); - @Before + @BeforeEach public void setup() throws URISyntaxException { this.springCloudReleaseProject = new File( GitRepoTests.class.getResource("/projects/spring-cloud-release").toURI()); diff --git a/releaser-core/src/test/java/releaser/internal/buildsystem/PomReaderTests.java b/releaser-core/src/test/java/releaser/internal/buildsystem/PomReaderTests.java index d756319c..c634c443 100644 --- a/releaser-core/src/test/java/releaser/internal/buildsystem/PomReaderTests.java +++ b/releaser-core/src/test/java/releaser/internal/buildsystem/PomReaderTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2019 the original author or authors. + * Copyright 2013-2022 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. @@ -23,8 +23,8 @@ import java.net.URISyntaxException; import org.apache.maven.model.Model; import org.codehaus.plexus.util.xml.pull.XmlPullParserException; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import releaser.internal.git.GitRepoTests; import releaser.internal.tech.PomReader; @@ -44,7 +44,7 @@ public class PomReaderTests { File licenseFile; - @Before + @BeforeEach public void setup() throws URISyntaxException { URI scRelease = GitRepoTests.class.getResource("/projects/spring-cloud-release").toURI(); this.springCloudReleaseProject = new File(scRelease); diff --git a/releaser-core/src/test/java/releaser/internal/buildsystem/PomUpdaterTests.java b/releaser-core/src/test/java/releaser/internal/buildsystem/PomUpdaterTests.java index 247d9e3d..0eccbb0a 100644 --- a/releaser-core/src/test/java/releaser/internal/buildsystem/PomUpdaterTests.java +++ b/releaser-core/src/test/java/releaser/internal/buildsystem/PomUpdaterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2019 the original author or authors. + * Copyright 2013-2022 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. @@ -26,16 +26,14 @@ import java.util.Set; import edu.emory.mathcs.backport.java.util.Collections; import org.apache.maven.model.Model; import org.assertj.core.api.BDDAssertions; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.TemporaryFolder; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; import releaser.SpringCloudReleaserProperties; import releaser.internal.git.GitRepoTests; import releaser.internal.project.Project; import releaser.internal.tech.PomReader; -import org.springframework.boot.test.system.OutputCaptureRule; import org.springframework.util.FileSystemUtils; /** @@ -43,23 +41,17 @@ import org.springframework.util.FileSystemUtils; */ public class PomUpdaterTests { - @Rule - public OutputCaptureRule capture = new OutputCaptureRule(); - - @Rule - public TemporaryFolder tmp = new TemporaryFolder(); - VersionsFromBom versionsFromBom = new VersionsFromBomBuilder() .releaserProperties(SpringCloudReleaserProperties.get()).projects(projects()) .parsers(Collections.emptyList()).retrieveFromBom(); PomUpdater pomUpdater = new PomUpdater(); + @TempDir File temporaryFolder; - @Before + @BeforeEach public void setup() throws Exception { - this.temporaryFolder = this.tmp.newFolder(); FileSystemUtils.copyRecursively(file("/projects/"), this.temporaryFolder); } diff --git a/releaser-core/src/test/java/releaser/internal/buildsystem/ProjectPomUpdaterTests.java b/releaser-core/src/test/java/releaser/internal/buildsystem/ProjectPomUpdaterTests.java index dd6bca53..4db63d83 100644 --- a/releaser-core/src/test/java/releaser/internal/buildsystem/ProjectPomUpdaterTests.java +++ b/releaser-core/src/test/java/releaser/internal/buildsystem/ProjectPomUpdaterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2019 the original author or authors. + * Copyright 2013-2022 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. @@ -19,7 +19,7 @@ package releaser.internal.buildsystem; import java.io.File; import java.util.Collections; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.mockito.BDDMockito; import releaser.SpringCloudReleaserProperties; import releaser.internal.ReleaserProperties; diff --git a/releaser-core/src/test/java/releaser/internal/buildsystem/ProjectVersionTests.java b/releaser-core/src/test/java/releaser/internal/buildsystem/ProjectVersionTests.java index f4e2cb1e..90bc4e5f 100644 --- a/releaser-core/src/test/java/releaser/internal/buildsystem/ProjectVersionTests.java +++ b/releaser-core/src/test/java/releaser/internal/buildsystem/ProjectVersionTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2019 the original author or authors. + * Copyright 2013-2022 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. @@ -22,8 +22,8 @@ import java.net.URISyntaxException; import java.util.List; import java.util.regex.Pattern; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import releaser.internal.git.GitRepoTests; import releaser.internal.project.ProjectVersion; @@ -40,7 +40,7 @@ public class ProjectVersionTests { File springCloudContract; - @Before + @BeforeEach public void setup() throws URISyntaxException { URI scRelease = GitRepoTests.class.getResource("/projects/spring-cloud-release").toURI(); URI scContract = GitRepoTests.class.getResource("/projects/spring-cloud-contract").toURI(); diff --git a/releaser-core/src/test/java/releaser/internal/buildsystem/ProjectsTests.java b/releaser-core/src/test/java/releaser/internal/buildsystem/ProjectsTests.java index 31ce41be..4f90af06 100644 --- a/releaser-core/src/test/java/releaser/internal/buildsystem/ProjectsTests.java +++ b/releaser-core/src/test/java/releaser/internal/buildsystem/ProjectsTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2019 the original author or authors. + * Copyright 2013-2022 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. @@ -22,7 +22,7 @@ import java.util.Collections; import java.util.HashSet; import java.util.Set; -import org.junit.Test; +import org.junit.jupiter.api.Test; import releaser.SpringCloudReleaserProperties; import releaser.internal.ReleaserProperties; import releaser.internal.project.ProjectVersion; diff --git a/releaser-core/src/test/java/releaser/internal/buildsystem/PropertyStorerTests.java b/releaser-core/src/test/java/releaser/internal/buildsystem/PropertyStorerTests.java index 6940e05e..ef649e85 100644 --- a/releaser-core/src/test/java/releaser/internal/buildsystem/PropertyStorerTests.java +++ b/releaser-core/src/test/java/releaser/internal/buildsystem/PropertyStorerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2019 the original author or authors. + * Copyright 2013-2022 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. @@ -18,12 +18,12 @@ package releaser.internal.buildsystem; import org.apache.maven.plugin.logging.Log; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.BDDMockito; import org.mockito.InjectMocks; import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; +import org.mockito.junit.jupiter.MockitoExtension; import releaser.internal.project.Project; import static org.mockito.BDDMockito.then; @@ -31,7 +31,7 @@ import static org.mockito.BDDMockito.then; /** * @author Marcin Grzejszczak */ -@RunWith(MockitoJUnitRunner.class) +@ExtendWith(MockitoExtension.class) public class PropertyStorerTests { @Mock diff --git a/releaser-core/src/test/java/releaser/internal/buildsystem/PropertyVersionChangerTests.java b/releaser-core/src/test/java/releaser/internal/buildsystem/PropertyVersionChangerTests.java index 3407358a..cf30b663 100644 --- a/releaser-core/src/test/java/releaser/internal/buildsystem/PropertyVersionChangerTests.java +++ b/releaser-core/src/test/java/releaser/internal/buildsystem/PropertyVersionChangerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2019 the original author or authors. + * Copyright 2013-2022 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. @@ -22,10 +22,10 @@ import java.util.Set; import edu.emory.mathcs.backport.java.util.Arrays; import org.apache.maven.model.Model; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; +import org.mockito.junit.jupiter.MockitoExtension; import releaser.internal.ReleaserProperties; import releaser.internal.project.Project; @@ -36,7 +36,7 @@ import static org.mockito.Mockito.never; /** * @author Marcin Grzejszczak */ -@RunWith(MockitoJUnitRunner.class) +@ExtendWith(MockitoExtension.class) public class PropertyVersionChangerTests { @Mock diff --git a/releaser-core/src/test/java/releaser/internal/buildsystem/VersionsFromBomTests.java b/releaser-core/src/test/java/releaser/internal/buildsystem/VersionsFromBomTests.java index 5ec2e643..696e8e8a 100644 --- a/releaser-core/src/test/java/releaser/internal/buildsystem/VersionsFromBomTests.java +++ b/releaser-core/src/test/java/releaser/internal/buildsystem/VersionsFromBomTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2019 the original author or authors. + * Copyright 2013-2022 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. @@ -21,7 +21,7 @@ import java.util.HashSet; import java.util.Properties; import java.util.Set; -import org.junit.Test; +import org.junit.jupiter.api.Test; import releaser.SpringCloudReleaserProperties; import releaser.internal.ReleaserProperties; import releaser.internal.project.Project; diff --git a/releaser-core/src/test/java/releaser/internal/docs/ReleaseTrainContentsParserTests.java b/releaser-core/src/test/java/releaser/internal/docs/ReleaseTrainContentsParserTests.java index 996ad890..8da20546 100644 --- a/releaser-core/src/test/java/releaser/internal/docs/ReleaseTrainContentsParserTests.java +++ b/releaser-core/src/test/java/releaser/internal/docs/ReleaseTrainContentsParserTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2019 the original author or authors. + * Copyright 2013-2022 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. @@ -20,7 +20,7 @@ import java.io.File; import java.net.URISyntaxException; import org.assertj.core.api.BDDAssertions; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * @author Marcin Grzejszczak diff --git a/releaser-core/src/test/java/releaser/internal/docs/ReleaseTrainContentsUpdaterTests.java b/releaser-core/src/test/java/releaser/internal/docs/ReleaseTrainContentsUpdaterTests.java index 65fe7e10..5bafeba5 100644 --- a/releaser-core/src/test/java/releaser/internal/docs/ReleaseTrainContentsUpdaterTests.java +++ b/releaser-core/src/test/java/releaser/internal/docs/ReleaseTrainContentsUpdaterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2019 the original author or authors. + * Copyright 2013-2022 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. @@ -24,10 +24,9 @@ import java.util.Collections; import org.assertj.core.api.BDDAssertions; import org.eclipse.jgit.api.errors.GitAPIException; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.TemporaryFolder; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; import releaser.SpringCloudReleaserProperties; import releaser.internal.ReleaserProperties; import releaser.internal.buildsystem.TestUtils; @@ -45,9 +44,6 @@ import org.springframework.util.FileSystemUtils; */ public class ReleaseTrainContentsUpdaterTests { - @Rule - public TemporaryFolder tmp = new TemporaryFolder(); - ReleaserProperties properties = SpringCloudReleaserProperties.get(); ProjectGitHubHandler projectGitHubHandler = new ProjectGitHubHandler(this.properties, Collections.emptyList()) { @@ -57,10 +53,10 @@ public class ReleaseTrainContentsUpdaterTests { } }; - ProjectGitHandler projectGitHandler = new ProjectGitHandler(this.properties); - TemplateGenerator templateGenerator = new TemplateGenerator(this.properties, this.projectGitHubHandler); + ProjectGitHandler projectGitHandler = new ProjectGitHandler(this.properties); + ReleaseTrainContentsUpdater updater = new ReleaseTrainContentsUpdater(this.properties, this.projectGitHandler, this.templateGenerator); @@ -68,11 +64,11 @@ public class ReleaseTrainContentsUpdaterTests { File wikiRepo; + @TempDir File temporaryFolder; - @Before + @BeforeEach public void setup() throws Exception { - this.temporaryFolder = this.tmp.newFolder(); TestUtils.prepareLocalRepo(); FileSystemUtils.copyRecursively(file("/projects"), this.temporaryFolder); this.springCloudRepo = new File(this.temporaryFolder, "spring-cloud/"); diff --git a/releaser-core/src/test/java/releaser/internal/docs/RowTests.java b/releaser-core/src/test/java/releaser/internal/docs/RowTests.java index b59491ab..5104d01f 100644 --- a/releaser-core/src/test/java/releaser/internal/docs/RowTests.java +++ b/releaser-core/src/test/java/releaser/internal/docs/RowTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2019 the original author or authors. + * Copyright 2013-2022 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. @@ -19,7 +19,7 @@ package releaser.internal.docs; import java.util.List; import org.assertj.core.api.BDDAssertions; -import org.junit.Test; +import org.junit.jupiter.api.Test; import releaser.internal.project.ProjectVersion; import releaser.internal.project.Projects; diff --git a/releaser-core/src/test/java/releaser/internal/docs/SpringCloudGhPagesParserTests.java b/releaser-core/src/test/java/releaser/internal/docs/SpringCloudGhPagesParserTests.java index d75e84b6..98abc8c6 100644 --- a/releaser-core/src/test/java/releaser/internal/docs/SpringCloudGhPagesParserTests.java +++ b/releaser-core/src/test/java/releaser/internal/docs/SpringCloudGhPagesParserTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2019 the original author or authors. + * Copyright 2013-2022 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. @@ -20,19 +20,18 @@ import java.io.File; import java.net.URISyntaxException; import org.assertj.core.api.BDDAssertions; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; -import org.springframework.boot.test.system.OutputCaptureRule; +import org.springframework.boot.test.system.CapturedOutput; +import org.springframework.boot.test.system.OutputCaptureExtension; /** * @author Marcin Grzejszczak */ +@ExtendWith(OutputCaptureExtension.class) public class SpringCloudGhPagesParserTests { - @Rule - public OutputCaptureRule capture = new OutputCaptureRule(); - File rawHtml = new File( SpringCloudGhPagesParserTests.class.getResource("/raw/spring-cloud-gh-pages-index.html").toURI()); @@ -71,11 +70,11 @@ public class SpringCloudGhPagesParserTests { } @Test - public void should_not_parse_the_components_table_when_markers_are_not_found() { + public void should_not_parse_the_components_table_when_markers_are_not_found(CapturedOutput capturedOutput) { ReleaseTrainContents contents = new ReleaseTrainContentsParser().parseProjectPage(this.wrongHtml); BDDAssertions.then(contents).isNull(); - BDDAssertions.then(this.capture.toString()).contains("The page is missing the components table markers"); + BDDAssertions.then(capturedOutput.toString()).contains("The page is missing the components table markers"); } } diff --git a/releaser-core/src/test/java/releaser/internal/git/GitRepoTests.java b/releaser-core/src/test/java/releaser/internal/git/GitRepoTests.java index 0ca11af4..d285fbfd 100644 --- a/releaser-core/src/test/java/releaser/internal/git/GitRepoTests.java +++ b/releaser-core/src/test/java/releaser/internal/git/GitRepoTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2019 the original author or authors. + * Copyright 2013-2022 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. @@ -22,6 +22,7 @@ import java.io.IOException; import java.io.PrintStream; import java.net.URISyntaxException; import java.nio.file.Files; +import java.nio.file.Path; import java.util.List; import org.assertj.core.api.BDDAssertions; @@ -31,10 +32,9 @@ import org.eclipse.jgit.api.errors.GitAPIException; import org.eclipse.jgit.lib.Ref; import org.eclipse.jgit.revwalk.RevCommit; import org.eclipse.jgit.transport.URIish; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.TemporaryFolder; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; import releaser.internal.buildsystem.TestUtils; import static org.assertj.core.api.Assertions.fail; @@ -46,18 +46,15 @@ import static org.assertj.core.api.BDDAssertions.thenThrownBy; */ public class GitRepoTests { - @Rule - public TemporaryFolder tmp = new TemporaryFolder(); - File springCloudReleaseProject; + @TempDir File tmpFolder; GitRepo gitRepo; - @Before + @BeforeEach public void setup() throws IOException, URISyntaxException { - this.tmpFolder = this.tmp.newFolder(); this.springCloudReleaseProject = new File( GitRepoTests.class.getResource("/projects/spring-cloud-release").toURI()); TestUtils.prepareLocalRepo(); @@ -190,9 +187,10 @@ public class GitRepoTests { } @Test - public void should_push_changes_to_master_branch() throws Exception { - File origin = GitTestUtils.clonedProject(this.tmp.newFolder(), this.springCloudReleaseProject); - File project = new GitRepo(this.tmpFolder) + public void should_push_changes_to_master_branch(@TempDir Path tempDirOrigin, @TempDir Path tempDirProject) + throws Exception { + File origin = GitTestUtils.clonedProject(tempDirOrigin.toFile(), this.springCloudReleaseProject); + File project = new GitRepo(tempDirProject.toFile()) .cloneProject(new URIish(this.springCloudReleaseProject.toURI().toURL())); GitTestUtils.setOriginOnProjectToTmp(origin, project); createNewFile(project); @@ -207,9 +205,10 @@ public class GitRepoTests { } @Test - public void should_push_changes_to_current_branch() throws Exception { - File origin = GitTestUtils.clonedProject(this.tmp.newFolder(), this.springCloudReleaseProject); - File project = new GitRepo(this.tmpFolder) + public void should_push_changes_to_current_branch(@TempDir Path tempDirOrigin, @TempDir Path tempDirProject) + throws Exception { + File origin = GitTestUtils.clonedProject(tempDirOrigin.toFile(), this.springCloudReleaseProject); + File project = new GitRepo(tempDirProject.toFile()) .cloneProject(new URIish(this.springCloudReleaseProject.toURI().toURL())); GitTestUtils.setOriginOnProjectToTmp(origin, project); createNewFile(project); @@ -224,9 +223,10 @@ public class GitRepoTests { } @Test - public void should_return_the_branch_name() throws Exception { - File origin = GitTestUtils.clonedProject(this.tmp.newFolder(), this.springCloudReleaseProject); - File project = new GitRepo(this.tmpFolder) + public void should_return_the_branch_name(@TempDir Path tempDirOrigin, @TempDir Path tempDirProject) + throws Exception { + File origin = GitTestUtils.clonedProject(tempDirOrigin.toFile(), this.springCloudReleaseProject); + File project = new GitRepo(tempDirProject.toFile()) .cloneProject(new URIish(this.springCloudReleaseProject.toURI().toURL())); GitTestUtils.setOriginOnProjectToTmp(origin, project); createNewFile(project); @@ -237,9 +237,10 @@ public class GitRepoTests { } @Test - public void should_push_a_tag_to_new_branch_in_origin() throws Exception { - File origin = GitTestUtils.clonedProject(this.tmp.newFolder(), this.springCloudReleaseProject); - File project = new GitRepo(this.tmpFolder) + public void should_push_a_tag_to_new_branch_in_origin(@TempDir Path tempDirOrigin, @TempDir Path tempDirProject) + throws Exception { + File origin = GitTestUtils.clonedProject(tempDirOrigin.toFile(), this.springCloudReleaseProject); + File project = new GitRepo(tempDirProject.toFile()) .cloneProject(new URIish(this.springCloudReleaseProject.toURI().toURL())); GitTestUtils.setOriginOnProjectToTmp(origin, project); createNewFile(project); diff --git a/releaser-core/src/test/java/releaser/internal/git/ProjectGitHandlerTests.java b/releaser-core/src/test/java/releaser/internal/git/ProjectGitHandlerTests.java index 3f609b94..61e0b8ac 100644 --- a/releaser-core/src/test/java/releaser/internal/git/ProjectGitHandlerTests.java +++ b/releaser-core/src/test/java/releaser/internal/git/ProjectGitHandlerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2019 the original author or authors. + * Copyright 2013-2022 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. @@ -19,10 +19,10 @@ package releaser.internal.git; import java.io.File; import org.assertj.core.api.BDDAssertions; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; +import org.mockito.junit.jupiter.MockitoExtension; import releaser.SpringCloudReleaserProperties; import releaser.internal.ReleaserProperties; import releaser.internal.project.ProjectVersion; @@ -36,7 +36,7 @@ import static org.mockito.Mockito.never; /** * @author Marcin Grzejszczak */ -@RunWith(MockitoJUnitRunner.class) +@ExtendWith(MockitoExtension.class) public class ProjectGitHandlerTests { @Mock diff --git a/releaser-core/src/test/java/releaser/internal/github/GithubIssuesTests.java b/releaser-core/src/test/java/releaser/internal/github/GithubIssuesTests.java index 73e622de..33133a06 100644 --- a/releaser-core/src/test/java/releaser/internal/github/GithubIssuesTests.java +++ b/releaser-core/src/test/java/releaser/internal/github/GithubIssuesTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2019 the original author or authors. + * Copyright 2013-2022 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. @@ -23,32 +23,22 @@ import com.jcabi.github.Github; import com.jcabi.github.Repo; import com.jcabi.github.Repos; import com.jcabi.github.mock.MkGithub; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.TemporaryFolder; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.BDDMockito; import releaser.internal.project.ProjectVersion; import releaser.internal.project.Projects; -import org.springframework.boot.test.system.OutputCaptureRule; - /** * @author Marcin Grzejszczak */ public class GithubIssuesTests { - @Rule - public TemporaryFolder folder = new TemporaryFolder(); - - @Rule - public OutputCaptureRule capture = new OutputCaptureRule(); - MkGithub github; Repo repo; - @Before + @BeforeEach public void setup() throws IOException { this.github = github("spring-guides"); this.repo = createGettingStartedGuides(this.github); diff --git a/releaser-core/src/test/java/releaser/internal/github/GithubMilestonesTests.java b/releaser-core/src/test/java/releaser/internal/github/GithubMilestonesTests.java index 0971966e..1e92d676 100644 --- a/releaser-core/src/test/java/releaser/internal/github/GithubMilestonesTests.java +++ b/releaser-core/src/test/java/releaser/internal/github/GithubMilestonesTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2019 the original author or authors. + * Copyright 2013-2022 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. @@ -23,14 +23,14 @@ import com.jcabi.github.Milestone; import com.jcabi.github.Repo; import com.jcabi.github.Repos; import com.jcabi.github.mock.MkGithub; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.TemporaryFolder; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import releaser.internal.ReleaserProperties; import releaser.internal.project.ProjectVersion; -import org.springframework.boot.test.system.OutputCaptureRule; +import org.springframework.boot.test.system.CapturedOutput; +import org.springframework.boot.test.system.OutputCaptureExtension; import static org.assertj.core.api.BDDAssertions.then; import static org.assertj.core.api.BDDAssertions.thenThrownBy; @@ -38,26 +38,21 @@ import static org.assertj.core.api.BDDAssertions.thenThrownBy; /** * @author Marcin Grzejszczak */ +@ExtendWith(OutputCaptureExtension.class) public class GithubMilestonesTests { - @Rule - public TemporaryFolder folder = new TemporaryFolder(); - - @Rule - public OutputCaptureRule capture = new OutputCaptureRule(); - MkGithub github; Repo repo; - @Before + @BeforeEach public void setup() throws IOException { this.github = new MkGithub(); this.repo = createSleuthRepo(this.github); } @Test - public void should_close_milestone_if_there_is_one() throws IOException { + public void should_close_milestone_if_there_is_one(CapturedOutput capturedOutput) throws IOException { GithubMilestones milestones = new GithubMilestones(this.github, withToken()) { @Override String org() { @@ -73,12 +68,12 @@ public class GithubMilestonesTests { milestones.closeMilestone(nonGaSleuthProject()); - then(this.capture.toString()).doesNotContain("No matching milestone was found"); + then(capturedOutput.toString()).doesNotContain("No matching milestone was found"); } @Test - public void should_close_milestone_when_the_milestone_contains_numeric_version_only_and_version_is_ga() - throws IOException { + public void should_close_milestone_when_the_milestone_contains_numeric_version_only_and_version_is_ga( + CapturedOutput capturedOutput) throws IOException { GithubMilestones milestones = new GithubMilestones(this.github, withToken()) { @Override String org() { @@ -94,7 +89,7 @@ public class GithubMilestonesTests { milestones.closeMilestone(gaSleuthProject()); - then(this.capture.toString()).doesNotContain("No matching milestone was found"); + then(capturedOutput.toString()).doesNotContain("No matching milestone was found"); } private ProjectVersion gaSleuthProject() { @@ -102,7 +97,8 @@ public class GithubMilestonesTests { } @Test - public void should_not_close_milestone_when_the_milestone_contains_numeric_version_only() throws IOException { + public void should_not_close_milestone_when_the_milestone_contains_numeric_version_only( + CapturedOutput capturedOutput) throws IOException { GithubMilestones milestones = new GithubMilestones(this.github, withToken()) { @Override String org() { @@ -118,7 +114,7 @@ public class GithubMilestonesTests { milestones.closeMilestone(nonGaSleuthProject()); - then(this.capture.toString()).contains("No matching milestone was found"); + then(capturedOutput.toString()).contains("No matching milestone was found"); } @Test @@ -182,7 +178,8 @@ public class GithubMilestonesTests { } @Test - public void should_return_null_if_no_matching_milestone_was_found_within_threshold() throws IOException { + public void should_return_null_if_no_matching_milestone_was_found_within_threshold(CapturedOutput capturedOutput) + throws IOException { GithubMilestones milestones = new GithubMilestones(this.github, withThreshold()) { @Override String org() { @@ -198,7 +195,7 @@ public class GithubMilestonesTests { milestones.closeMilestone(gaSleuthProject()); - then(this.capture.toString()).contains("No matching milestones were found within the provided threshold [0]"); + then(capturedOutput.toString()).contains("No matching milestones were found within the provided threshold [0]"); } private ProjectVersion nonGaSleuthProject() { @@ -206,7 +203,8 @@ public class GithubMilestonesTests { } @Test - public void should_throw_exception_when_there_is_no_matching_milestone() throws IOException { + public void should_throw_exception_when_there_is_no_matching_milestone(CapturedOutput capturedOutput) + throws IOException { GithubMilestones milestones = new GithubMilestones(this.github, withToken()) { @Override String org() { @@ -221,11 +219,12 @@ public class GithubMilestonesTests { this.repo.milestones().create("v0.2.0.BUILD-SNAPSHOT"); milestones.closeMilestone(nonGaSleuthProject()); - then(this.capture.toString()).contains("No matching milestone was found"); + then(capturedOutput.toString()).contains("No matching milestone was found"); } @Test - public void should_print_that_no_milestones_were_found_when_io_problems_occurred() throws IOException { + public void should_print_that_no_milestones_were_found_when_io_problems_occurred(CapturedOutput capturedOutput) + throws IOException { GithubMilestones milestones = new GithubMilestones(this.github, withToken()) { @Override String org() { @@ -241,7 +240,7 @@ public class GithubMilestonesTests { milestones.closeMilestone(nonGaSleuthProject()); - then(this.capture.toString()).contains("No matching milestone was found"); + then(capturedOutput.toString()).contains("No matching milestone was found"); } private Repo createSleuthRepo(MkGithub github) throws IOException { diff --git a/releaser-core/src/test/java/releaser/internal/gradle/GradleUpdaterTests.java b/releaser-core/src/test/java/releaser/internal/gradle/GradleUpdaterTests.java index fc90e485..c8c29b3e 100644 --- a/releaser-core/src/test/java/releaser/internal/gradle/GradleUpdaterTests.java +++ b/releaser-core/src/test/java/releaser/internal/gradle/GradleUpdaterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2019 the original author or authors. + * Copyright 2013-2022 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. @@ -23,10 +23,9 @@ import java.nio.file.Files; import java.util.HashMap; import java.util.Map; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.TemporaryFolder; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; import releaser.internal.ReleaserProperties; import releaser.internal.buildsystem.GradleUpdater; import releaser.internal.project.ProjectVersion; @@ -42,14 +41,11 @@ import static org.assertj.core.api.BDDAssertions.thenThrownBy; */ public class GradleUpdaterTests { - @Rule - public TemporaryFolder tmp = new TemporaryFolder(); - + @TempDir File temporaryFolder; - @Before + @BeforeEach public void setup() throws Exception { - this.temporaryFolder = this.tmp.newFolder(); FileSystemUtils.copyRecursively(file("/projects/"), this.temporaryFolder); } diff --git a/releaser-core/src/test/java/releaser/internal/postrelease/PostReleaseActionsTests.java b/releaser-core/src/test/java/releaser/internal/postrelease/PostReleaseActionsTests.java index d9b428ff..b880df86 100644 --- a/releaser-core/src/test/java/releaser/internal/postrelease/PostReleaseActionsTests.java +++ b/releaser-core/src/test/java/releaser/internal/postrelease/PostReleaseActionsTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2019 the original author or authors. + * Copyright 2013-2022 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. @@ -30,11 +30,10 @@ import org.assertj.core.api.BDDAssertions; import org.awaitility.Awaitility; import org.eclipse.jgit.api.Git; import org.eclipse.jgit.revwalk.RevCommit; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.TemporaryFolder; +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 org.mockito.BDDMockito; import releaser.SpringCloudReleaserProperties; import releaser.internal.PomUpdateAcceptanceTests; @@ -60,9 +59,7 @@ import org.springframework.util.LinkedMultiValueMap; */ public class PostReleaseActionsTests { - @Rule - public TemporaryFolder tmp = new TemporaryFolder(); - + @TempDir File temporaryFolder; GradleUpdater gradleUpdater = BDDMockito.mock(GradleUpdater.class); @@ -114,9 +111,8 @@ public class PostReleaseActionsTests { return new VersionsFetcher(properties, updater); } - @Before + @BeforeEach public void setup() throws Exception { - this.temporaryFolder = this.tmp.newFolder(); TestUtils.prepareLocalRepo(); FileSystemUtils.copyRecursively(file("/projects/"), this.temporaryFolder); } @@ -200,7 +196,7 @@ public class PostReleaseActionsTests { BDDAssertions.then(this.cloned).isNull(); } - @Ignore("flakey on circle") + @Disabled("flakey on circle") @Test public void should_update_project_and_run_tests_and_release_train_docs_generation_is_called() { this.properties.getMetaRelease().setEnabled(true); diff --git a/releaser-core/src/test/java/releaser/internal/project/ProjectCommandExecutorTests.java b/releaser-core/src/test/java/releaser/internal/project/ProjectCommandExecutorTests.java index 9fa216e3..0822ad57 100644 --- a/releaser-core/src/test/java/releaser/internal/project/ProjectCommandExecutorTests.java +++ b/releaser-core/src/test/java/releaser/internal/project/ProjectCommandExecutorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2019 the original author or authors. + * Copyright 2013-2022 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. @@ -25,18 +25,18 @@ import java.net.URISyntaxException; import java.nio.file.Files; import java.util.concurrent.TimeoutException; -import org.junit.Assume; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.TemporaryFolder; +import org.junit.jupiter.api.Assumptions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.api.io.TempDir; import org.zeroturnaround.exec.ProcessExecutor; import org.zeroturnaround.exec.ProcessResult; import releaser.internal.PomUpdateAcceptanceTests; import releaser.internal.ReleaserProperties; import releaser.internal.buildsystem.TestUtils; -import org.springframework.boot.test.system.OutputCaptureRule; +import org.springframework.boot.test.system.OutputCaptureExtension; import org.springframework.util.FileSystemUtils; import static org.assertj.core.api.BDDAssertions.then; @@ -45,20 +45,15 @@ import static org.assertj.core.api.BDDAssertions.thenThrownBy; /** * @author Marcin Grzejszczak */ +@ExtendWith(OutputCaptureExtension.class) public class ProjectCommandExecutorTests { - @Rule - public TemporaryFolder tmp = new TemporaryFolder(); - - @Rule - public OutputCaptureRule outputCapture = new OutputCaptureRule(); - + @TempDir File temporaryFolder; - @Before + @BeforeEach public void checkOs() throws Exception { - Assume.assumeFalse(System.getProperty("os.name").toLowerCase().startsWith("win")); - this.temporaryFolder = this.tmp.newFolder(); + Assumptions.assumeFalse(System.getProperty("os.name").toLowerCase().startsWith("win")); TestUtils.prepareLocalRepo(); FileSystemUtils.copyRecursively(file("/projects"), this.temporaryFolder); } diff --git a/releaser-core/src/test/java/releaser/internal/sagan/RestTemplateSaganClientTests.java b/releaser-core/src/test/java/releaser/internal/sagan/RestTemplateSaganClientTests.java index 53c7e237..c24af32a 100644 --- a/releaser-core/src/test/java/releaser/internal/sagan/RestTemplateSaganClientTests.java +++ b/releaser-core/src/test/java/releaser/internal/sagan/RestTemplateSaganClientTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2019 the original author or authors. + * Copyright 2013-2022 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. @@ -19,10 +19,9 @@ package releaser.internal.sagan; import java.io.IOException; import com.fasterxml.jackson.databind.ObjectMapper; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import releaser.internal.ReleaserProperties; import org.springframework.beans.factory.annotation.Autowired; @@ -32,7 +31,6 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.web.client.RestTemplateBuilder; import org.springframework.cloud.contract.stubrunner.spring.AutoConfigureStubRunner; import org.springframework.context.annotation.Configuration; -import org.springframework.test.context.junit4.SpringRunner; import org.springframework.web.client.RestTemplate; import static org.assertj.core.api.BDDAssertions.then; @@ -40,7 +38,6 @@ import static org.assertj.core.api.BDDAssertions.then; /** * @author Marcin Grzejszczak */ -@RunWith(SpringRunner.class) @SpringBootTest(classes = RestTemplateSaganClientTests.Config.class) @AutoConfigureStubRunner(ids = "io.spring.sagan:sagan-site") public class RestTemplateSaganClientTests { @@ -53,7 +50,7 @@ public class RestTemplateSaganClientTests { SaganClient client; - @Before + @BeforeEach public void setup() { ReleaserProperties properties = new ReleaserProperties(); properties.getGit().setOauthToken("foo"); @@ -108,7 +105,7 @@ public class RestTemplateSaganClientTests { } @Test - @Ignore("no api yet https://github.com/spring-io/sagan/issues/1052") + @Disabled("no api yet https://github.com/spring-io/sagan/issues/1052") public void should_patch_a_project() throws IOException { String projectJson = "{\n \"id\" : \"spring-framework\",\n " + "\"rawBootConfig\" : \"rawBootConfig\",\n \"rawOverview\" : \"rawOverview\",\n " diff --git a/releaser-core/src/test/java/releaser/internal/sagan/SaganUpdaterTest.java b/releaser-core/src/test/java/releaser/internal/sagan/SaganUpdaterTest.java index 46109807..bea22796 100644 --- a/releaser-core/src/test/java/releaser/internal/sagan/SaganUpdaterTest.java +++ b/releaser-core/src/test/java/releaser/internal/sagan/SaganUpdaterTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2019 the original author or authors. + * Copyright 2013-2022 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. @@ -23,8 +23,8 @@ import java.nio.file.Path; import java.util.ArrayList; import java.util.Arrays; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.ArgumentMatcher; import releaser.internal.ReleaserProperties; import releaser.internal.project.ProjectVersion; @@ -56,7 +56,7 @@ public class SaganUpdaterTest { private Project project; - @Before + @BeforeEach public void setup() { project = new Project(); project.setReleases(Arrays.asList(release("2.2.0-RC1"), release("2.3.0-SNAPSHOT"), release("2.2.0-M4"))); diff --git a/releaser-core/src/test/java/releaser/internal/template/TemplateGeneratorTests.java b/releaser-core/src/test/java/releaser/internal/template/TemplateGeneratorTests.java index fb97cfae..13a50c24 100644 --- a/releaser-core/src/test/java/releaser/internal/template/TemplateGeneratorTests.java +++ b/releaser-core/src/test/java/releaser/internal/template/TemplateGeneratorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2019 the original author or authors. + * Copyright 2013-2022 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. @@ -22,7 +22,7 @@ import java.nio.file.Files; import java.util.Collections; import java.util.HashSet; -import org.junit.Test; +import org.junit.jupiter.api.Test; import releaser.SpringCloudReleaserProperties; import releaser.internal.ReleaserProperties; import releaser.internal.github.ProjectGitHubHandler; diff --git a/releaser-spring/pom.xml b/releaser-spring/pom.xml index 5af6a319..e69f4558 100644 --- a/releaser-spring/pom.xml +++ b/releaser-spring/pom.xml @@ -59,11 +59,6 @@ spring-boot-starter-test test - - org.junit.vintage - junit-vintage-engine - test - diff --git a/releaser-spring/src/test/java/releaser/internal/spring/ReleaserPropertiesUpdaterTests.java b/releaser-spring/src/test/java/releaser/internal/spring/ReleaserPropertiesUpdaterTests.java index 1d0f1588..fe28afd0 100644 --- a/releaser-spring/src/test/java/releaser/internal/spring/ReleaserPropertiesUpdaterTests.java +++ b/releaser-spring/src/test/java/releaser/internal/spring/ReleaserPropertiesUpdaterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2019 the original author or authors. + * Copyright 2013-2022 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. @@ -20,7 +20,7 @@ import java.io.File; import java.net.URISyntaxException; import org.assertj.core.api.BDDAssertions; -import org.junit.Test; +import org.junit.jupiter.api.Test; import releaser.internal.ReleaserProperties; import releaser.internal.ReleaserPropertiesUpdater; diff --git a/releaser-test/pom.xml b/releaser-test/pom.xml index 88a91e34..0de13123 100644 --- a/releaser-test/pom.xml +++ b/releaser-test/pom.xml @@ -40,11 +40,6 @@ spring-boot-starter-test compile - - org.junit.vintage - junit-vintage-engine - compile - diff --git a/releaser-test/src/main/java/releaser/internal/spring/AbstractSpringAcceptanceTests.java b/releaser-test/src/main/java/releaser/internal/spring/AbstractSpringAcceptanceTests.java index b42d61d6..0b73ffa8 100644 --- a/releaser-test/src/main/java/releaser/internal/spring/AbstractSpringAcceptanceTests.java +++ b/releaser-test/src/main/java/releaser/internal/spring/AbstractSpringAcceptanceTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2019 the original author or authors. + * Copyright 2013-2022 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. @@ -34,10 +34,9 @@ import org.eclipse.jgit.api.Git; import org.eclipse.jgit.api.ResetCommand; import org.eclipse.jgit.api.errors.GitAPIException; import org.eclipse.jgit.revwalk.RevCommit; -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.rules.TemporaryFolder; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.io.TempDir; import org.mockito.BDDMockito; import releaser.internal.ReleaserProperties; import releaser.internal.buildsystem.TestPomReader; @@ -68,9 +67,7 @@ import static org.assertj.core.api.BDDAssertions.then; */ public abstract class AbstractSpringAcceptanceTests { - @Rule - public TemporaryFolder tmp = new TemporaryFolder(); - + @TempDir public File temporaryFolder; public TestPomReader testPomReader = new TestPomReader(); @@ -89,15 +86,14 @@ public abstract class AbstractSpringAcceptanceTests { return release; } - @Before + @BeforeEach public void setup() throws Exception { - this.temporaryFolder = this.tmp.newFolder(); TestUtils.prepareLocalRepo(); FileSystemUtils.copyRecursively(file("/projects/"), this.temporaryFolder); clean(); } - @After + @AfterEach public void cleanup() throws Exception { clean(); } @@ -200,8 +196,8 @@ public abstract class AbstractSpringAcceptanceTests { return new String(Files.readAllBytes(file.toPath())); } - public File cloneToTemporaryDirectory(File project) throws IOException { - return GitTestUtils.clonedProject(this.tmp.newFolder(), project); + public File cloneToTemporaryDirectory(File tempDir, File project) throws IOException { + return GitTestUtils.clonedProject(tempDir, project); } public void checkoutReleaseTrainBranch(String fileToRepo, String branch) @@ -358,7 +354,7 @@ public abstract class AbstractSpringAcceptanceTests { public class Props { - private List args = new LinkedList<>(); + private final List args = new LinkedList<>(); public Props(String... args) { properties(args); diff --git a/releaser-test/src/main/java/releaser/internal/spring/ArgsBuilder.java b/releaser-test/src/main/java/releaser/internal/spring/ArgsBuilder.java index 00a4a5e2..2ed756dd 100644 --- a/releaser-test/src/main/java/releaser/internal/spring/ArgsBuilder.java +++ b/releaser-test/src/main/java/releaser/internal/spring/ArgsBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2019 the original author or authors. + * Copyright 2013-2022 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,44 +17,55 @@ package releaser.internal.spring; import java.io.File; -import java.io.IOException; import java.net.URISyntaxException; import java.util.Arrays; import java.util.LinkedList; import java.util.List; import java.util.Map; -import org.junit.rules.TemporaryFolder; import releaser.internal.git.GitTestUtils; public class ArgsBuilder { private final File project; - private final TemporaryFolder tmp; + private final File tempDirTestSamplesProject; + + private final File tempDirReleaseTrainDocs; + + private final File tempDirSpringCloud; + + private final File tempDirReleaseTrainWiki; + + private final File tempDirAllTestSample; List args = new LinkedList<>(); - public ArgsBuilder(File project, TemporaryFolder tmp) throws Exception { + public ArgsBuilder(File project, File tempDirTestSamplesProject, File tempDirReleaseTrainDocs, + File tempDirSpringCloud, File tempDirReleaseTrainWiki, File tempDirAllTestSample) throws Exception { this.project = project; - this.tmp = tmp; + this.tempDirTestSamplesProject = tempDirTestSamplesProject; + this.tempDirReleaseTrainDocs = tempDirReleaseTrainDocs; + this.tempDirSpringCloud = tempDirSpringCloud; + this.tempDirReleaseTrainWiki = tempDirReleaseTrainWiki; + this.tempDirAllTestSample = tempDirAllTestSample; defaults(); } public ArgsBuilder defaults() throws Exception { // @formatter:off this.args.addAll(Arrays.asList( - "releaser.git.documentation-url=" + file("/projects/spring-cloud-static-angel/").toURI().toString(), - "releaser.git.test-samples-project-url=" + this.tmp.newFolder().toString(), - "releaser.git.release-train-docs-url=" + this.tmp.newFolder().toString(), + "releaser.git.documentation-url=" + file("/projects/spring-cloud-static-angel/").toURI(), + "releaser.git.test-samples-project-url=" + tempDirTestSamplesProject.getAbsolutePath(), + "releaser.git.release-train-docs-url=" + tempDirReleaseTrainDocs.getAbsolutePath(), "releaser.maven.build-command=echo build", "releaser.maven.deploy-command=echo deploy", "releaser.maven.deploy-guides-command=echo guides", "releaser.maven.publish-docs-command=echo docs", "releaser.maven.generate-release-train-docs-command=echo releaseTrainDocs", "releaser.working-dir=" + project.getPath(), - "releaser.git.spring-project-url=" + tmpFile("spring-cloud").getAbsolutePath() + "/", - "releaser.git.release-train-wiki-url=" + tmpGitRepo("spring-cloud-wiki").getAbsolutePath() + "/", + "releaser.git.spring-project-url=" + tempDirSpringCloud.getAbsolutePath(), + "releaser.git.release-train-wiki-url=" + tmpGitRepo(tempDirReleaseTrainWiki).getAbsolutePath() + "/", "releaser.git.run-updated-samples=true", "releaser.git.update-spring-guides=true", "releaser.git.update-spring-project=true", @@ -63,11 +74,11 @@ public class ArgsBuilder { "releaser.git.update-documentation-repo=true", "releaser.git.update-github-milestones=true", "releaser.git.update-release-train-docs=true", - "releaser.git.all-test-sample-urls[spring-cloud-consul]=" + this.tmp.newFolder().toString(), + "releaser.git.all-test-sample-urls[spring-cloud-consul]=" + tempDirAllTestSample.getAbsolutePath(), "releaser.sagan.update-sagan=true", "releaser.template.enabled=true", "releaser.versions.all-versions-file-url=" - + ArgsBuilder.class.getResource("/raw/initializr.yml").toURI().toString() + + ArgsBuilder.class.getResource("/raw/initializr.yml").toURI() )); // @formatter:on fetchVersionsFromGit(true); @@ -155,7 +166,7 @@ public class ArgsBuilder { public ArgsBuilder releaseTrainUrl(String relativePath) throws Exception { removeIfPresent("releaser.git.release-train-bom-url"); - this.args.add("releaser.git.release-train-bom-url=" + file(relativePath).toURI().toString()); + this.args.add("releaser.git.release-train-bom-url=" + file(relativePath).toURI()); return this; } @@ -191,24 +202,9 @@ public class ArgsBuilder { return new File(ArgsBuilder.class.getResource(relativePath).toURI()); } - private File tmpFile(String relativePath) { - try { - return new File(this.tmp.newFolder(), relativePath); - } - catch (IOException e) { - throw new IllegalStateException(e); - } - } - - private File tmpGitRepo(String relativePath) { - try { - File file = new File(this.tmp.newFolder(), relativePath); - GitTestUtils.initGitProject(file); - return file; - } - catch (IOException e) { - throw new IllegalStateException(e); - } + private File tmpGitRepo(File tempDir) { + GitTestUtils.initGitProject(tempDir); + return tempDir; } } diff --git a/releaser-test/src/main/java/releaser/internal/spring/meta/AbstractSpringMetaReleaseAcceptanceTests.java b/releaser-test/src/main/java/releaser/internal/spring/meta/AbstractSpringMetaReleaseAcceptanceTests.java index 765f7aa7..5c8f3a11 100644 --- a/releaser-test/src/main/java/releaser/internal/spring/meta/AbstractSpringMetaReleaseAcceptanceTests.java +++ b/releaser-test/src/main/java/releaser/internal/spring/meta/AbstractSpringMetaReleaseAcceptanceTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2019 the original author or authors. + * Copyright 2013-2022 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. @@ -38,32 +38,40 @@ import static org.assertj.core.api.BDDAssertions.then; */ public abstract class AbstractSpringMetaReleaseAcceptanceTests extends AbstractSpringAcceptanceTests { - public ArgsBuilder metaReleaseArgs(File project) throws Exception { - return new ArgsBuilder(project, this.tmp).releaseTrainUrl("/projects/spring-cloud-release/") - .projectsToSkip("spring-boot", "spring-cloud-build", "spring-cloud-commons", "spring-cloud-stream", - "spring-cloud-task", "spring-cloud-function", "spring-cloud-aws", "spring-cloud-bus", - "spring-cloud-config", "spring-cloud-netflix", "spring-cloud-cloudfoundry", - "spring-cloud-gateway", "spring-cloud-security", "spring-cloud-zookeeper", - "spring-cloud-sleuth", "spring-cloud-contract", "spring-cloud-vault") - .mavenBuildCommand("echo '{{profiles}}' > /tmp/executed_build") - .mavenPublishCommand("echo '{{profiles}}' > /tmp/executed_docs") - .mavenDeployCommand("echo '{{profiles}}' > /tmp/executed_deploy") - .gitOrgUrl("file://" + this.temporaryFolder.getAbsolutePath()) - .releaseTrainBomUrl(file("/projects/spring-cloud-release/").toURI().toString()); + public ArgsBuilder metaReleaseArgs(File project, File tempDirTestSamplesProject, File tempDirReleaseTrainDocs, + File tempDirSpringCloud, File tempDirReleaseTrainWiki, File tempDirAllTestSample) throws Exception { + return new ArgsBuilder(project, tempDirTestSamplesProject, tempDirReleaseTrainDocs, tempDirSpringCloud, + tempDirReleaseTrainWiki, tempDirAllTestSample) + .releaseTrainUrl("/projects/spring-cloud-release/") + .projectsToSkip("spring-boot", "spring-cloud-build", "spring-cloud-commons", + "spring-cloud-stream", "spring-cloud-task", "spring-cloud-function", "spring-cloud-aws", + "spring-cloud-bus", "spring-cloud-config", "spring-cloud-netflix", + "spring-cloud-cloudfoundry", "spring-cloud-gateway", "spring-cloud-security", + "spring-cloud-zookeeper", "spring-cloud-sleuth", "spring-cloud-contract", + "spring-cloud-vault") + .mavenBuildCommand("echo '{{profiles}}' > /tmp/executed_build") + .mavenPublishCommand("echo '{{profiles}}' > /tmp/executed_docs") + .mavenDeployCommand("echo '{{profiles}}' > /tmp/executed_deploy") + .gitOrgUrl("file://" + this.temporaryFolder.getAbsolutePath()) + .releaseTrainBomUrl(file("/projects/spring-cloud-release/").toURI().toString()); } - public ArgsBuilder metaReleaseArgsForParallel(File project) throws Exception { - return new ArgsBuilder(project, this.tmp).releaseTrainUrl("/projects/spring-cloud-release/") - .projectsToSkip("spring-boot", "spring-cloud-commons", "spring-cloud-stream", "spring-cloud-task", - "spring-cloud-function", "spring-cloud-aws", "spring-cloud-bus", "spring-cloud-config", - "spring-cloud-netflix", "spring-cloud-cloudfoundry", "spring-cloud-gateway", - "spring-cloud-security", "spring-cloud-zookeeper", "spring-cloud-sleuth", - "spring-cloud-contract", "spring-cloud-vault") - .mavenBuildCommand("echo '{{profiles}}' > /tmp/executed_build") - .mavenPublishCommand("echo '{{profiles}}' > /tmp/executed_docs") - .mavenDeployCommand("echo '{{profiles}}' > /tmp/executed_deploy") - .gitOrgUrl("file://" + this.temporaryFolder.getAbsolutePath()) - .releaseTrainBomUrl(file("/projects/spring-cloud-release/").toURI().toString()); + public ArgsBuilder metaReleaseArgsForParallel(File project, File tempDirTestSamplesProject, + File tempDirReleaseTrainDocs, File tempDirSpringCloud, File tempDirReleaseTrainWiki, + File tempDirAllTestSample) throws Exception { + return new ArgsBuilder(project, tempDirTestSamplesProject, tempDirReleaseTrainDocs, tempDirSpringCloud, + tempDirReleaseTrainWiki, tempDirAllTestSample) + .releaseTrainUrl("/projects/spring-cloud-release/") + .projectsToSkip("spring-boot", "spring-cloud-commons", "spring-cloud-stream", + "spring-cloud-task", "spring-cloud-function", "spring-cloud-aws", "spring-cloud-bus", + "spring-cloud-config", "spring-cloud-netflix", "spring-cloud-cloudfoundry", + "spring-cloud-gateway", "spring-cloud-security", "spring-cloud-zookeeper", + "spring-cloud-sleuth", "spring-cloud-contract", "spring-cloud-vault") + .mavenBuildCommand("echo '{{profiles}}' > /tmp/executed_build") + .mavenPublishCommand("echo '{{profiles}}' > /tmp/executed_docs") + .mavenDeployCommand("echo '{{profiles}}' > /tmp/executed_deploy") + .gitOrgUrl("file://" + this.temporaryFolder.getAbsolutePath()) + .releaseTrainBomUrl(file("/projects/spring-cloud-release/").toURI().toString()); } public Map edgwareSr10() {