From 9120d256c123b6b41fe1acedabacadddf5a0f9c9 Mon Sep 17 00:00:00 2001
From: TheSnoozer <6849390+TheSnoozer@users.noreply.github.com>
Date: Tue, 19 Mar 2024 21:58:01 +0100
Subject: [PATCH 1/2]
https://github.com/git-commit-id/git-commit-id-plugin-core/issues/113:
replace junit:junit:4.13.2:test with
org.junit.jupiter:junit-jupiter-*:5.10.2:test
---
pom.xml | 24 +-
.../GitCommitIdPluginIntegrationTest.java | 256 +++++++++---------
.../project13/core/GitDataProviderTest.java | 2 +-
.../pl/project13/core/ProcessHandlerTest.java | 53 ++--
.../core/PropertiesFileGeneratorTest.java | 71 +++--
.../core/UriUserInfoRemoverTest.java | 19 +-
.../core/jgit/DescribeCommandOptionsTest.java | 15 +-
.../project13/core/jgit/JGitCommonTest.java | 2 +-
.../core/util/GitDirLocatorTest.java | 30 +-
.../project13/core/util/TestJsonManager.java | 48 ++--
10 files changed, 268 insertions(+), 252 deletions(-)
diff --git a/pom.xml b/pom.xml
index e21bec2..49f4edd 100644
--- a/pom.xml
+++ b/pom.xml
@@ -45,7 +45,7 @@
https://github.com/eclipse-jgit/jgit/issues/36
-->
6.7.0.202309050840-r
- 4.13.2
+ 5.10.2
5.11.0
3.25.3
@@ -253,8 +253,20 @@
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter-api
+ ${junit.version}
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
+ ${junit.version}
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-params
${junit.version}
test
@@ -277,12 +289,6 @@
jar
test
-
- pl.pragmatists
- JUnitParams
- 1.1.1
- test
-
org.slf4j
diff --git a/src/test/java/pl/project13/core/GitCommitIdPluginIntegrationTest.java b/src/test/java/pl/project13/core/GitCommitIdPluginIntegrationTest.java
index 340b116..6fc3221 100644
--- a/src/test/java/pl/project13/core/GitCommitIdPluginIntegrationTest.java
+++ b/src/test/java/pl/project13/core/GitCommitIdPluginIntegrationTest.java
@@ -20,16 +20,17 @@
import jakarta.json.Json;
import jakarta.json.JsonObject;
import jakarta.json.JsonReader;
-import junitparams.JUnitParamsRunner;
-import junitparams.Parameters;
import org.apache.commons.io.FileUtils;
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.ResetCommand;
-import org.junit.*;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
import pl.project13.core.git.GitDescribeConfig;
import pl.project13.core.util.GenericFileManager;
-
import javax.annotation.Nonnull;
import java.io.File;
import java.io.FileInputStream;
@@ -54,10 +55,7 @@
import static java.util.Arrays.asList;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-@RunWith(JUnitParamsRunner.class)
public class GitCommitIdPluginIntegrationTest {
public static Collection> useNativeGit() {
return asList(true, false);
@@ -69,20 +67,20 @@ public static Collection> useDirty() {
private Path sandbox;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
sandbox = Files.createTempDirectory("sandbox.git-commit-id-core");
}
- @After
+ @AfterEach
public void tearDown() throws Exception {
if (sandbox != null) {
deleteDir(sandbox);
}
}
- @Test
- @Parameters(method = "useNativeGit")
+ @ParameterizedTest
+ @MethodSource("useNativeGit")
public void shouldIncludeExpectedProperties(boolean useNativeGit) throws Exception {
// given
File dotGitDirectory = createTmpDotGitDirectory(AvailableGitTestRepo.WITH_ONE_COMMIT);
@@ -114,8 +112,8 @@ public void shouldIncludeExpectedProperties(boolean useNativeGit) throws Excepti
);
}
- @Test
- @Parameters(method = "useNativeGit")
+ @ParameterizedTest
+ @MethodSource("useNativeGit")
public void shouldExcludeAsConfiguredProperties(boolean useNativeGit) throws Exception {
// given
File dotGitDirectory = createTmpDotGitDirectory(AvailableGitTestRepo.WITH_ONE_COMMIT);
@@ -155,8 +153,8 @@ public void shouldExcludeAsConfiguredProperties(boolean useNativeGit) throws Exc
);
}
- @Test
- @Parameters(method = "useNativeGit")
+ @ParameterizedTest
+ @MethodSource("useNativeGit")
public void shouldIncludeOnlyAsConfiguredProperties(boolean useNativeGit) throws Exception {
// given
File dotGitDirectory = createTmpDotGitDirectory(AvailableGitTestRepo.WITH_ONE_COMMIT);
@@ -194,8 +192,8 @@ public void shouldIncludeOnlyAsConfiguredProperties(boolean useNativeGit) throws
);
}
- @Test
- @Parameters(method = "useNativeGit")
+ @ParameterizedTest
+ @MethodSource("useNativeGit")
public void shouldExcludeAndIncludeAsConfiguredProperties(boolean useNativeGit) throws Exception {
// given
File dotGitDirectory = createTmpDotGitDirectory(AvailableGitTestRepo.WITH_ONE_COMMIT);
@@ -238,8 +236,8 @@ public void shouldExcludeAndIncludeAsConfiguredProperties(boolean useNativeGit)
);
}
- @Test
- @Parameters(method = "useNativeGit")
+ @ParameterizedTest
+ @MethodSource("useNativeGit")
public void shouldHaveNoPrefixWhenConfiguredPrefixIsEmptyStringAsConfiguredProperties(boolean useNativeGit) throws Exception {
// given
File dotGitDirectory = createTmpDotGitDirectory(AvailableGitTestRepo.WITH_ONE_COMMIT);
@@ -264,8 +262,8 @@ public void shouldHaveNoPrefixWhenConfiguredPrefixIsEmptyStringAsConfiguredPrope
assertThat(properties).containsKey("remote.origin.url");
}
- @Test
- @Parameters(method = "useNativeGit")
+ @ParameterizedTest
+ @MethodSource("useNativeGit")
public void shouldSkipDescribeWhenConfiguredToDoSo(boolean useNativeGit) throws Exception {
// given
File dotGitDirectory = createTmpDotGitDirectory(AvailableGitTestRepo.WITH_ONE_COMMIT);
@@ -288,8 +286,8 @@ public void shouldSkipDescribeWhenConfiguredToDoSo(boolean useNativeGit) throws
assertThat(properties).doesNotContainKey("git.commit.id.describe");
}
- @Test
- @Parameters(method = "useNativeGit")
+ @ParameterizedTest
+ @MethodSource("useNativeGit")
public void shouldNotUseBuildEnvironmentBranchInfoWhenParameterSet(boolean useNativeGit) throws Exception {
// given
File dotGitDirectory = createTmpDotGitDirectory(AvailableGitTestRepo.WITH_COMMIT_THAT_HAS_TWO_TAGS);
@@ -321,8 +319,8 @@ public void shouldNotUseBuildEnvironmentBranchInfoWhenParameterSet(boolean useNa
assertPropertyPresentAndEqual(properties, "git.branch", "test_branch");
}
- @Test
- @Parameters(method = "useNativeGit")
+ @ParameterizedTest
+ @MethodSource("useNativeGit")
public void shouldUseJenkinsBranchInfoWhenAvailable(boolean useNativeGit) throws Exception {
// given
Map env = new HashMap<>();
@@ -399,8 +397,8 @@ private void shouldUseJenkinsBranchInfoWhenAvailableHelperAndAssertBranch(boolea
assertPropertyPresentAndEqual(properties, "git.branch", expectedBranchName);
}
- @Test
- @Parameters(method = "useNativeGit")
+ @ParameterizedTest
+ @MethodSource("useNativeGit")
public void shouldResolvePropertiesOnDefaultSettingsForNonPomProject(boolean useNativeGit) throws Exception {
// given
File dotGitDirectory = createTmpDotGitDirectory(AvailableGitTestRepo.WITH_ONE_COMMIT);
@@ -419,8 +417,8 @@ public void shouldResolvePropertiesOnDefaultSettingsForNonPomProject(boolean use
assertGitPropertiesPresentInProject(properties);
}
- @Test(expected = GitCommitIdExecutionException.class)
- @Parameters(method = "useNativeGit")
+ @ParameterizedTest
+ @MethodSource("useNativeGit")
public void shouldFailWithExceptionWhenNoGitRepoFound(boolean useNativeGit) throws Exception {
// given
File emptyGitDir = sandbox.resolve("empty_git_dir").toFile();
@@ -435,11 +433,13 @@ public void shouldFailWithExceptionWhenNoGitRepoFound(boolean useNativeGit) thro
Properties properties = new Properties();
// when
- GitCommitIdPlugin.runPlugin(cb, properties);
+ org.junit.jupiter.api.Assertions.assertThrows(GitCommitIdExecutionException.class, () -> {
+ GitCommitIdPlugin.runPlugin(cb, properties);
+ });
}
- @Test
- @Parameters(method = "useNativeGit")
+ @ParameterizedTest
+ @MethodSource("useNativeGit")
public void shouldGenerateCustomPropertiesFileProperties(boolean useNativeGit) throws Exception {
// given
File dotGitDirectory = createTmpDotGitDirectory(AvailableGitTestRepo.WITH_ONE_COMMIT_WITH_SPECIAL_CHARACTERS);
@@ -466,8 +466,8 @@ public void shouldGenerateCustomPropertiesFileProperties(boolean useNativeGit) t
}
}
- @Test
- @Parameters(method = "useNativeGit")
+ @ParameterizedTest
+ @MethodSource("useNativeGit")
public void shouldGenerateCustomPropertiesFileJson(boolean useNativeGit) throws Exception {
// given
File dotGitDirectory = createTmpDotGitDirectory(AvailableGitTestRepo.WITH_ONE_COMMIT_WITH_SPECIAL_CHARACTERS);
@@ -492,11 +492,11 @@ public void shouldGenerateCustomPropertiesFileJson(boolean useNativeGit) throws
assertThat(targetFilePath).exists();
Properties p = GenericFileManager.readPropertiesAsUtf8(commitIdPropertiesOutputFormat, targetFilePath);
assertThat(p.size()).isGreaterThan(10);
- Assert.assertEquals(p, properties);
+ Assertions.assertEquals(p, properties);
}
- @Test
- @Parameters(method = "useNativeGit")
+ @ParameterizedTest
+ @MethodSource("useNativeGit")
// https://github.com/git-commit-id/git-commit-id-maven-plugin/pull/123
public void shouldGenerateJsonWithCorrectObjectStructure(boolean useNativeGit) throws Exception {
// given
@@ -611,8 +611,8 @@ private TreeNode findChild(TreeNode node, String value) {
return null;
}
- @Test
- @Parameters(method = "useNativeGit")
+ @ParameterizedTest
+ @MethodSource("useNativeGit")
public void shouldGenerateCustomPropertiesFileXml(boolean useNativeGit) throws Exception {
// given
File dotGitDirectory = createTmpDotGitDirectory(AvailableGitTestRepo.WITH_ONE_COMMIT_WITH_SPECIAL_CHARACTERS);
@@ -637,11 +637,11 @@ public void shouldGenerateCustomPropertiesFileXml(boolean useNativeGit) throws E
assertThat(targetFilePath).exists();
Properties p = GenericFileManager.readPropertiesAsUtf8(commitIdPropertiesOutputFormat, targetFilePath);
assertThat(p.size()).isGreaterThan(10);
- Assert.assertEquals(p, properties);
+ Assertions.assertEquals(p, properties);
}
- @Test
- @Parameters(method = "useNativeGit")
+ @ParameterizedTest
+ @MethodSource("useNativeGit")
public void shouldGenerateCustomPropertiesFileYml(boolean useNativeGit) throws Exception {
// given
File dotGitDirectory = createTmpDotGitDirectory(AvailableGitTestRepo.WITH_ONE_COMMIT_WITH_SPECIAL_CHARACTERS);
@@ -666,11 +666,11 @@ public void shouldGenerateCustomPropertiesFileYml(boolean useNativeGit) throws E
assertThat(targetFilePath).exists();
Properties p = GenericFileManager.readPropertiesAsUtf8(commitIdPropertiesOutputFormat, targetFilePath);
assertThat(p.size()).isGreaterThan(10);
- Assert.assertEquals(p, properties);
+ Assertions.assertEquals(p, properties);
}
- @Test
- @Parameters(method = "useNativeGit")
+ @ParameterizedTest
+ @MethodSource("useNativeGit")
public void shouldGenerateDescribeWithTagOnlyWhenForceLongFormatIsFalse(boolean useNativeGit) throws Exception {
// given
File dotGitDirectory = createTmpDotGitDirectory(AvailableGitTestRepo.ON_A_TAG);
@@ -693,8 +693,8 @@ public void shouldGenerateDescribeWithTagOnlyWhenForceLongFormatIsFalse(boolean
assertPropertyPresentAndEqual(properties, "git.commit.id.describe", "v1.0.0-dirty");
}
- @Test
- @Parameters(method = "useNativeGit")
+ @ParameterizedTest
+ @MethodSource("useNativeGit")
public void shouldGenerateDescribeWithTagOnlyWhenForceLongFormatIsFalseAndAbbrevLengthIsNonDefault(boolean useNativeGit) throws Exception {
// given
File dotGitDirectory = createTmpDotGitDirectory(AvailableGitTestRepo.ON_A_TAG);
@@ -718,8 +718,8 @@ public void shouldGenerateDescribeWithTagOnlyWhenForceLongFormatIsFalseAndAbbrev
assertPropertyPresentAndEqual(properties, "git.commit.id.describe-short", "v1.0.0");
}
- @Test
- @Parameters(method = "useNativeGit")
+ @ParameterizedTest
+ @MethodSource("useNativeGit")
public void shouldGenerateDescribeWithTagAndZeroAndCommitIdWhenForceLongFormatIsTrue(boolean useNativeGit) throws Exception {
// given
File dotGitDirectory = createTmpDotGitDirectory(AvailableGitTestRepo.ON_A_TAG);
@@ -741,8 +741,8 @@ public void shouldGenerateDescribeWithTagAndZeroAndCommitIdWhenForceLongFormatIs
assertPropertyPresentAndEqual(properties, "git.commit.id.describe", "v1.0.0-0-gde4db35");
}
- @Test
- @Parameters(method = "useNativeGit")
+ @ParameterizedTest
+ @MethodSource("useNativeGit")
public void shouldGenerateDescribeWithTagAndZeroAndCommitIdWhenForceLongFormatIsTrueAndAbbrevLengthIsNonDefault(boolean useNativeGit) throws Exception {
// given
File dotGitDirectory = createTmpDotGitDirectory(AvailableGitTestRepo.ON_A_TAG);
@@ -766,8 +766,8 @@ public void shouldGenerateDescribeWithTagAndZeroAndCommitIdWhenForceLongFormatIs
assertPropertyPresentAndEqual(properties, "git.commit.id.describe-short", "v1.0.0-0");
}
- @Test
- @Parameters(method = "useNativeGit")
+ @ParameterizedTest
+ @MethodSource("useNativeGit")
public void shouldGenerateCommitIdAbbrevWithDefaultLength(boolean useNativeGit) throws Exception {
// given
File dotGitDirectory = createTmpDotGitDirectory(AvailableGitTestRepo.ON_A_TAG);
@@ -787,8 +787,8 @@ public void shouldGenerateCommitIdAbbrevWithDefaultLength(boolean useNativeGit)
assertPropertyPresentAndEqual(properties, "git.commit.id.abbrev", "de4db35");
}
- @Test
- @Parameters(method = "useNativeGit")
+ @ParameterizedTest
+ @MethodSource("useNativeGit")
public void shouldGenerateCommitIdAbbrevWithNonDefaultLength(boolean useNativeGit) throws Exception {
// given
File dotGitDirectory = createTmpDotGitDirectory(AvailableGitTestRepo.ON_A_TAG);
@@ -808,8 +808,8 @@ public void shouldGenerateCommitIdAbbrevWithNonDefaultLength(boolean useNativeGi
assertThat(properties).containsEntry("git.commit.id.abbrev", "de4db35917");
}
- @Test
- @Parameters(method = "useNativeGit")
+ @ParameterizedTest
+ @MethodSource("useNativeGit")
public void shouldFormatDate(boolean useNativeGit) throws Exception {
// given
File dotGitDirectory = createTmpDotGitDirectory(AvailableGitTestRepo.ON_A_TAG);
@@ -836,8 +836,8 @@ public void shouldFormatDate(boolean useNativeGit) throws Exception {
assertThat(properties).containsEntry("git.commit.time", "08/19/2012");
}
- @Test
- @Parameters(method = "useNativeGit")
+ @ParameterizedTest
+ @MethodSource("useNativeGit")
public void shouldSkipGitDescribe(boolean useNativeGit) throws Exception {
// given
File dotGitDirectory = createTmpDotGitDirectory(AvailableGitTestRepo.ON_A_TAG);
@@ -860,8 +860,8 @@ public void shouldSkipGitDescribe(boolean useNativeGit) throws Exception {
assertThat(properties).doesNotContainKey("git.commit.id.describe");
}
- @Test
- @Parameters(method = "useNativeGit")
+ @ParameterizedTest
+ @MethodSource("useNativeGit")
public void shouldMarkGitDescribeAsDirty(boolean useNativeGit) throws Exception {
// given
File dotGitDirectory = createTmpDotGitDirectory(AvailableGitTestRepo.ON_A_TAG_DIRTY);
@@ -885,8 +885,8 @@ public void shouldMarkGitDescribeAsDirty(boolean useNativeGit) throws Exception
assertThat(properties).containsEntry("git.commit.id.describe", "v1.0.0-0-gde4db35" + dirtySuffix);
}
- @Test
- @Parameters(method = "useNativeGit")
+ @ParameterizedTest
+ @MethodSource("useNativeGit")
public void shouldAlwaysPrintGitDescribe(boolean useNativeGit) throws Exception {
// given
File dotGitDirectory = createTmpDotGitDirectory(AvailableGitTestRepo.WITH_ONE_COMMIT);
@@ -909,8 +909,8 @@ public void shouldAlwaysPrintGitDescribe(boolean useNativeGit) throws Exception
assertPropertyPresentAndEqual(properties, "git.commit.id.describe", "0b0181b");
}
- @Test
- @Parameters(method = "useNativeGit")
+ @ParameterizedTest
+ @MethodSource("useNativeGit")
public void shouldWorkWithEmptyGitDescribe(boolean useNativeGit) throws Exception {
// given
File dotGitDirectory = createTmpDotGitDirectory(AvailableGitTestRepo.WITH_ONE_COMMIT);
@@ -932,8 +932,8 @@ public void shouldWorkWithEmptyGitDescribe(boolean useNativeGit) throws Exceptio
assertGitPropertiesPresentInProject(properties);
}
- @Test
- @Parameters(method = "useNativeGit")
+ @ParameterizedTest
+ @MethodSource("useNativeGit")
public void shouldWorkWithNullGitDescribe(boolean useNativeGit) throws Exception {
// given
File dotGitDirectory = createTmpDotGitDirectory(AvailableGitTestRepo.WITH_ONE_COMMIT);
@@ -955,8 +955,8 @@ public void shouldWorkWithNullGitDescribe(boolean useNativeGit) throws Exception
assertGitPropertiesPresentInProject(properties);
}
- @Test
- @Parameters(method = "useNativeGit")
+ @ParameterizedTest
+ @MethodSource("useNativeGit")
public void shouldExtractTagsOnGivenCommit(boolean useNativeGit) throws Exception {
// given
File dotGitDirectory = createTmpDotGitDirectory(AvailableGitTestRepo.WITH_COMMIT_THAT_HAS_TWO_TAGS);
@@ -989,8 +989,8 @@ public void shouldExtractTagsOnGivenCommit(boolean useNativeGit) throws Exceptio
assertPropertyPresentAndEqual(properties, "git.total.commit.count", "2");
}
- @Test
- @Parameters(method = "useNativeGit")
+ @ParameterizedTest
+ @MethodSource("useNativeGit")
public void shouldExtractTagsOnGivenCommitWithOldestCommit(boolean useNativeGit) throws Exception {
// given
File dotGitDirectory = createTmpDotGitDirectory(AvailableGitTestRepo.WITH_COMMIT_THAT_HAS_TWO_TAGS);
@@ -1024,8 +1024,8 @@ public void shouldExtractTagsOnGivenCommitWithOldestCommit(boolean useNativeGit)
assertPropertyPresentAndEqual(properties, "git.total.commit.count", "1");
}
- @Test
- @Parameters(method = "useNativeGit")
+ @ParameterizedTest
+ @MethodSource("useNativeGit")
public void shouldExtractTagsOnHead(boolean useNativeGit) throws Exception {
// given
File dotGitDirectory = createTmpDotGitDirectory(AvailableGitTestRepo.ON_A_TAG);
@@ -1053,8 +1053,8 @@ public void shouldExtractTagsOnHead(boolean useNativeGit) throws Exception {
.containsOnly("v1.0.0");
}
- @Test
- @Parameters(method = "useNativeGit")
+ @ParameterizedTest
+ @MethodSource("useNativeGit")
public void runGitDescribeWithMatchOption(boolean useNativeGit) throws Exception {
// given
String headCommitId = "b0c6d28b3b83bf7b905321bae67d9ca4c75a203f";
@@ -1095,8 +1095,8 @@ public void runGitDescribeWithMatchOption(boolean useNativeGit) throws Exception
}
}
- @Test
- @Parameters(method = "useNativeGit")
+ @ParameterizedTest
+ @MethodSource("useNativeGit")
public void shouldGenerateClosestTagInformationWhenOnATag(boolean useNativeGit) throws Exception {
// given
File dotGitDirectory = createTmpDotGitDirectory(AvailableGitTestRepo.ON_A_TAG);
@@ -1121,8 +1121,8 @@ public void shouldGenerateClosestTagInformationWhenOnATag(boolean useNativeGit)
assertPropertyPresentAndEqual(properties, "git.closest.tag.commit.count", "0");
}
- @Test
- @Parameters(method = "useNativeGit")
+ @ParameterizedTest
+ @MethodSource("useNativeGit")
public void shouldGenerateTagInformationWhenOnATag(boolean useNativeGit) throws Exception {
// given
File dotGitDirectory = createTmpDotGitDirectory(AvailableGitTestRepo.ON_A_TAG);
@@ -1145,8 +1145,8 @@ public void shouldGenerateTagInformationWhenOnATag(boolean useNativeGit) throws
assertPropertyPresentAndEqual(properties, "git.tag", "v1.0.0");
}
- @Test
- @Parameters(method = "useNativeGit")
+ @ParameterizedTest
+ @MethodSource("useNativeGit")
public void shouldGenerateClosestTagInformationWhenOnATagAndDirty(boolean useNativeGit) throws Exception {
// given
File dotGitDirectory = createTmpDotGitDirectory(AvailableGitTestRepo.ON_A_TAG_DIRTY);
@@ -1172,8 +1172,8 @@ public void shouldGenerateClosestTagInformationWhenOnATagAndDirty(boolean useNat
assertPropertyPresentAndEqual(properties, "git.closest.tag.commit.count", "0");
}
- @Test
- @Parameters(method = "useNativeGit")
+ @ParameterizedTest
+ @MethodSource("useNativeGit")
public void shouldGenerateClosestTagInformationWhenCommitHasTwoTags(boolean useNativeGit) throws Exception {
// given
File dotGitDirectory = createTmpDotGitDirectory(AvailableGitTestRepo.WITH_COMMIT_THAT_HAS_TWO_TAGS);
@@ -1202,8 +1202,8 @@ public void shouldGenerateClosestTagInformationWhenCommitHasTwoTags(boolean useN
assertPropertyPresentAndEqual(properties, "git.closest.tag.commit.count", "0");
}
- @Test
- @Parameters(method = "useNativeGit")
+ @ParameterizedTest
+ @MethodSource("useNativeGit")
public void shouldGenerateCommitterAndAuthorInformation(boolean useNativeGit) throws Exception {
// given
File dotGitDirectory = createTmpDotGitDirectory(AvailableGitTestRepo.COMMITTER_DIFFERENT_FROM_AUTHOR);
@@ -1241,8 +1241,8 @@ public void shouldGenerateCommitterAndAuthorInformation(boolean useNativeGit) th
assertPropertyPresentAndEqual(properties, "git.commit.user.name", "John Doe");
}
- @Test
- @Parameters(method = "useNativeGit")
+ @ParameterizedTest
+ @MethodSource("useNativeGit")
public void shouldUseDateFormatTimeZone(boolean useNativeGit) throws Exception {
// given
File dotGitDirectory = createTmpDotGitDirectory(AvailableGitTestRepo.ON_A_TAG_DIRTY);
@@ -1282,8 +1282,8 @@ public void shouldUseDateFormatTimeZone(boolean useNativeGit) throws Exception {
TimeZone.setDefault(currentDefaultTimeZone);
}
- @Test
- @Parameters(method = "useNativeGit")
+ @ParameterizedTest
+ @MethodSource("useNativeGit")
public void shouldGenerateCommitIdOldFashioned(boolean useNativeGit) throws Exception {
// given
File dotGitDirectory = createTmpDotGitDirectory(AvailableGitTestRepo.ON_A_TAG_DIRTY);
@@ -1304,8 +1304,8 @@ public void shouldGenerateCommitIdOldFashioned(boolean useNativeGit) throws Exce
assertThat(properties).doesNotContainKey("git.commit.id.full");
}
- @Test
- @Parameters(method = "useNativeGit")
+ @ParameterizedTest
+ @MethodSource("useNativeGit")
public void testDetectCleanWorkingDirectory(boolean useNativeGit) throws Exception {
// given
File dotGitDirectory = createTmpDotGitDirectory(AvailableGitTestRepo.GIT_WITH_NO_CHANGES);
@@ -1331,8 +1331,8 @@ public void testDetectCleanWorkingDirectory(boolean useNativeGit) throws Excepti
assertThat(properties).containsEntry("git.commit.id.describe", "85c2888"); // assert no dirtySuffix at the end!
}
- @Test
- @Parameters(method = "useNativeGit")
+ @ParameterizedTest
+ @MethodSource("useNativeGit")
public void testDetectDirtyWorkingDirectory(boolean useNativeGit) throws Exception {
// given
File dotGitDirectory = createTmpDotGitDirectory(AvailableGitTestRepo.WITH_ONE_COMMIT);
@@ -1358,8 +1358,8 @@ public void testDetectDirtyWorkingDirectory(boolean useNativeGit) throws Excepti
assertThat(properties).containsEntry("git.commit.id.describe", "0b0181b" + dirtySuffix); // assert dirtySuffix at the end!
}
- @Test
- @Parameters(method = "useNativeGit")
+ @ParameterizedTest
+ @MethodSource("useNativeGit")
public void shouldGenerateClosestTagInformationWithExcludeLightweightTagsForClosestTag(boolean useNativeGit) throws Exception {
// given
File dotGitDirectory = createTmpDotGitDirectory(AvailableGitTestRepo.WITH_LIGHTWEIGHT_TAG_BEFORE_ANNOTATED_TAG);
@@ -1391,8 +1391,8 @@ public void shouldGenerateClosestTagInformationWithExcludeLightweightTagsForClos
assertPropertyPresentAndEqual(properties, "git.total.commit.count", "3");
}
- @Test
- @Parameters(method = "useNativeGit")
+ @ParameterizedTest
+ @MethodSource("useNativeGit")
public void shouldGenerateClosestTagInformationWithIncludeLightweightTagsForClosestTag(boolean useNativeGit) throws Exception {
// given
File dotGitDirectory = createTmpDotGitDirectory(AvailableGitTestRepo.WITH_LIGHTWEIGHT_TAG_BEFORE_ANNOTATED_TAG);
@@ -1422,8 +1422,8 @@ public void shouldGenerateClosestTagInformationWithIncludeLightweightTagsForClos
assertPropertyPresentAndEqual(properties, "git.closest.tag.commit.count", "1");
}
- @Test
- @Parameters(method = "useNativeGit")
+ @ParameterizedTest
+ @MethodSource("useNativeGit")
public void shouldGenerateClosestTagInformationWithIncludeLightweightTagsForClosestTagAndPreferAnnotatedTags(boolean useNativeGit) throws Exception {
// given
File dotGitDirectory = createTmpDotGitDirectory(AvailableGitTestRepo.WITH_COMMIT_THAT_HAS_TWO_TAGS);
@@ -1453,8 +1453,8 @@ public void shouldGenerateClosestTagInformationWithIncludeLightweightTagsForClos
assertPropertyPresentAndEqual(properties, "git.closest.tag.commit.count", "1");
}
- @Test
- @Parameters(method = "useNativeGit")
+ @ParameterizedTest
+ @MethodSource("useNativeGit")
public void shouldGenerateClosestTagInformationWithIncludeLightweightTagsForClosestTagAndFilter(boolean useNativeGit) throws Exception {
// given
File dotGitDirectory = createTmpDotGitDirectory(AvailableGitTestRepo.WITH_COMMIT_THAT_HAS_TWO_TAGS);
@@ -1485,8 +1485,8 @@ public void shouldGenerateClosestTagInformationWithIncludeLightweightTagsForClos
assertPropertyPresentAndEqual(properties, "git.closest.tag.commit.count", "1");
}
- @Test
- @Parameters(method = "useNativeGit")
+ @ParameterizedTest
+ @MethodSource("useNativeGit")
public void verifyEvalOnDifferentCommitWithParentOfHead(boolean useNativeGit) throws Exception {
// given
File dotGitDirectory = createTmpDotGitDirectory(AvailableGitTestRepo.WITH_TAG_ON_DIFFERENT_BRANCH);
@@ -1516,8 +1516,8 @@ public void verifyEvalOnDifferentCommitWithParentOfHead(boolean useNativeGit) th
assertPropertyPresentAndEqual(properties, "git.dirty", "true");
}
- @Test
- @Parameters(method = "useNativeGit")
+ @ParameterizedTest
+ @MethodSource("useNativeGit")
public void verifyEvalOnDifferentCommitWithBranchName(boolean useNativeGit) throws Exception {
// given
File dotGitDirectory = createTmpDotGitDirectory(AvailableGitTestRepo.WITH_TAG_ON_DIFFERENT_BRANCH);
@@ -1551,8 +1551,8 @@ public void verifyEvalOnDifferentCommitWithBranchName(boolean useNativeGit) thro
assertPropertyPresentAndEqual(properties, "git.total.commit.count", "2");
}
- @Test
- @Parameters(method = "useNativeGit")
+ @ParameterizedTest
+ @MethodSource("useNativeGit")
public void verifyEvalOnDifferentCommitWithTagName(boolean useNativeGit) throws Exception {
// given
File dotGitDirectory = createTmpDotGitDirectory(AvailableGitTestRepo.WITH_TAG_ON_DIFFERENT_BRANCH);
@@ -1586,8 +1586,8 @@ public void verifyEvalOnDifferentCommitWithTagName(boolean useNativeGit) throws
assertPropertyPresentAndEqual(properties, "git.total.commit.count", "2");
}
- @Test
- @Parameters(method = "useNativeGit")
+ @ParameterizedTest
+ @MethodSource("useNativeGit")
public void verifyEvalOnDifferentCommitWithCommitHash(boolean useNativeGit) throws Exception {
// given
File dotGitDirectory = createTmpDotGitDirectory(AvailableGitTestRepo.WITH_TAG_ON_DIFFERENT_BRANCH);
@@ -1621,8 +1621,8 @@ public void verifyEvalOnDifferentCommitWithCommitHash(boolean useNativeGit) thro
assertPropertyPresentAndEqual(properties, "git.total.commit.count", "2");
}
- @Test
- @Parameters(method = "useNativeGit")
+ @ParameterizedTest
+ @MethodSource("useNativeGit")
public void verifyEvalOnCommitWithTwoBranches(boolean useNativeGit) throws Exception {
// given
File dotGitDirectory = createTmpDotGitDirectory(AvailableGitTestRepo.WITH_TAG_ON_DIFFERENT_BRANCH);
@@ -1651,8 +1651,8 @@ public void verifyEvalOnCommitWithTwoBranches(boolean useNativeGit) throws Excep
assertPropertyPresentAndEqual(properties, "git.branch", "another_branch,master,z_branch");
}
- @Test
- @Parameters(method = "useNativeGit")
+ @ParameterizedTest
+ @MethodSource("useNativeGit")
public void verifyDetachedHeadIsNotReportedAsBranch(boolean useNativeGit) throws Exception {
// given
File dotGitDirectory = createTmpDotGitDirectory(AvailableGitTestRepo.WITH_TAG_ON_DIFFERENT_BRANCH);
@@ -1678,8 +1678,8 @@ public void verifyDetachedHeadIsNotReportedAsBranch(boolean useNativeGit) throws
assertPropertyPresentAndEqual(properties, "git.branch", "master");
}
- @Test
- @Parameters(method = "useNativeGit")
+ @ParameterizedTest
+ @MethodSource("useNativeGit")
public void shouldGeneratePropertiesWithMultiplePrefixesAndReactorProject(boolean useNativeGit) throws Exception {
// given
File dotGitDirectory = createTmpDotGitDirectory(AvailableGitTestRepo.ON_A_TAG);
@@ -1716,8 +1716,8 @@ public void shouldGeneratePropertiesWithMultiplePrefixesAndReactorProject(boolea
}
}
- @Test
- @Parameters(method = "useNativeGit")
+ @ParameterizedTest
+ @MethodSource("useNativeGit")
public void shouldWorkWithRelativeSubmodules(boolean useNativeGit) throws Exception {
// given
File parentProjectDotGit =
@@ -1748,16 +1748,16 @@ public void shouldWorkWithRelativeSubmodules(boolean useNativeGit) throws Except
@Test
public void verifyAllowedCharactersForEvaluateOnCommit() {
Pattern p = GitCommitIdPlugin.allowedCharactersForEvaluateOnCommit;
- assertTrue(p.matcher("5957e419d").matches());
- assertTrue(p.matcher("my_tag").matches());
- assertTrue(p.matcher("my-tag").matches());
- assertTrue(p.matcher("my.tag").matches());
- assertTrue(p.matcher("HEAD^1").matches());
- assertTrue(p.matcher("feature/branch").matches());
-
- assertFalse(p.matcher("; CODE INJECTION").matches());
- assertFalse(p.matcher("|exit").matches());
- assertFalse(p.matcher("&&cat /etc/passwd").matches());
+ Assertions.assertTrue(p.matcher("5957e419d").matches());
+ Assertions.assertTrue(p.matcher("my_tag").matches());
+ Assertions.assertTrue(p.matcher("my-tag").matches());
+ Assertions.assertTrue(p.matcher("my.tag").matches());
+ Assertions.assertTrue(p.matcher("HEAD^1").matches());
+ Assertions.assertTrue(p.matcher("feature/branch").matches());
+
+ Assertions.assertFalse(p.matcher("; CODE INJECTION").matches());
+ Assertions.assertFalse(p.matcher("|exit").matches());
+ Assertions.assertFalse(p.matcher("&&cat /etc/passwd").matches());
}
private GitDescribeConfig createGitDescribeConfig(boolean forceLongFormat, int abbrev) {
diff --git a/src/test/java/pl/project13/core/GitDataProviderTest.java b/src/test/java/pl/project13/core/GitDataProviderTest.java
index c37eb45..d2bd704 100644
--- a/src/test/java/pl/project13/core/GitDataProviderTest.java
+++ b/src/test/java/pl/project13/core/GitDataProviderTest.java
@@ -17,7 +17,7 @@
package pl.project13.core;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import pl.project13.core.log.LogInterface;
import java.util.Properties;
diff --git a/src/test/java/pl/project13/core/ProcessHandlerTest.java b/src/test/java/pl/project13/core/ProcessHandlerTest.java
index 37bbbde..76c8392 100644
--- a/src/test/java/pl/project13/core/ProcessHandlerTest.java
+++ b/src/test/java/pl/project13/core/ProcessHandlerTest.java
@@ -17,10 +17,8 @@
package pl.project13.core;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertThrows;
-import static org.junit.Assert.assertTrue;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
import java.io.File;
import java.nio.file.Files;
@@ -30,7 +28,6 @@
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Consumer;
-import org.junit.Test;
public class ProcessHandlerTest {
@FunctionalInterface
@@ -93,9 +90,15 @@ public void exitSuccess() {
int actualExitCode = processHandler.exitValue(5, TimeUnit.SECONDS);
String stderr = processHandler.getStderr();
// For troubleshooting include `stderr` in message, e.g. in case there is a compilation error
- assertEquals("Process failed:\n" + stderr, exitCode, actualExitCode);
- assertEquals(STDOUT_LINE + "1\n" + STDOUT_LINE + "2\n", stdoutBuilder.toString());
- assertEquals(STDERR_LINE + "1\n" + STDERR_LINE + "2\n", stderr);
+ Assertions.assertEquals(
+ exitCode, actualExitCode,
+ "Process failed:\n" + stderr);
+ Assertions.assertEquals(
+ STDOUT_LINE + "1\n" + STDOUT_LINE + "2\n",
+ stdoutBuilder.toString());
+ Assertions.assertEquals(
+ STDERR_LINE + "1\n" + STDERR_LINE + "2\n",
+ stderr);
}
});
}
@@ -112,9 +115,11 @@ public void noOutput() {
int actualExitCode = processHandler.exitValue(5, TimeUnit.SECONDS);
String stderr = processHandler.getStderr();
// For troubleshooting include `stderr` in message, e.g. in case there is a compilation error
- assertEquals("Process failed:\n" + stderr, exitCode, actualExitCode);
- assertNull(lastStdoutLine.get());
- assertEquals("", stderr);
+ Assertions.assertEquals(
+ exitCode, actualExitCode,
+ "Process failed:\n" + stderr);
+ Assertions.assertNull(lastStdoutLine.get());
+ Assertions.assertEquals("", stderr);
}
});
}
@@ -129,9 +134,13 @@ public void exitError() {
StringBuilder stdoutBuilder = new StringBuilder();
try (ProcessHandler processHandler = new ProcessHandler(process, outLine -> stdoutBuilder.append(outLine).append('\n'))) {
int actualExitCode = processHandler.exitValue(5, TimeUnit.SECONDS);
- assertEquals(exitCode, actualExitCode);
- assertEquals(STDOUT_LINE + "1\n" + STDOUT_LINE + "2\n", stdoutBuilder.toString());
- assertEquals(STDERR_LINE + "1\n" + STDERR_LINE + "2\n", processHandler.getStderr());
+ Assertions.assertEquals(exitCode, actualExitCode);
+ Assertions.assertEquals(
+ STDOUT_LINE + "1\n" + STDOUT_LINE + "2\n",
+ stdoutBuilder.toString());
+ Assertions.assertEquals(
+ STDERR_LINE + "1\n" + STDERR_LINE + "2\n",
+ processHandler.getStderr());
}
});
}
@@ -146,8 +155,10 @@ public void timeout() {
// Ignore stdout; it is not deterministic how many output has already been read
Consumer stdoutConsumer = line -> {};
try (ProcessHandler processHandler = new ProcessHandler(process, stdoutConsumer)) {
- assertThrows(TimeoutException.class, () -> processHandler.exitValue(1, TimeUnit.MILLISECONDS));
- assertThrows(IllegalStateException.class, processHandler::getStderr);
+ Assertions.assertThrows(
+ TimeoutException.class, () -> processHandler.exitValue(1, TimeUnit.MILLISECONDS));
+ Assertions.assertThrows(
+ IllegalStateException.class, processHandler::getStderr);
}
});
}
@@ -182,11 +193,13 @@ public void largeOutput() {
int actualExitCode = processHandler.exitValue(5, TimeUnit.SECONDS);
String stderr = processHandler.getStderr();
// For troubleshooting include `stderr` in message, e.g. in case there is a compilation error
- assertEquals("Process failed:\n" + stderr, exitCode, actualExitCode);
- assertEquals(STDOUT_LINE + outputRepeatCount, lastStdoutLine.get());
+ Assertions.assertEquals(
+ exitCode, actualExitCode,
+ "Process failed:\n" + stderr);
+ Assertions.assertEquals(STDOUT_LINE + outputRepeatCount, lastStdoutLine.get());
- assertTrue(stderr.startsWith(STDERR_LINE + 1));
- assertTrue(stderr.endsWith(STDERR_LINE + outputRepeatCount + "\n"));
+ Assertions.assertTrue(stderr.startsWith(STDERR_LINE + 1));
+ Assertions.assertTrue(stderr.endsWith(STDERR_LINE + outputRepeatCount + "\n"));
}
});
}
diff --git a/src/test/java/pl/project13/core/PropertiesFileGeneratorTest.java b/src/test/java/pl/project13/core/PropertiesFileGeneratorTest.java
index 24f7ca5..f509a49 100644
--- a/src/test/java/pl/project13/core/PropertiesFileGeneratorTest.java
+++ b/src/test/java/pl/project13/core/PropertiesFileGeneratorTest.java
@@ -17,14 +17,12 @@
package pl.project13.core;
-import junitparams.JUnitParamsRunner;
-import junitparams.Parameters;
-import org.junit.Assert;
-import org.junit.Ignore;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.io.TempDir;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
import pl.project13.core.log.LogInterface;
import pl.project13.core.util.BuildFileChangeListener;
import pl.project13.core.util.GenericFileManager;
@@ -38,18 +36,14 @@
import java.util.Optional;
import java.util.Properties;
import java.util.stream.Collectors;
-import java.util.stream.Stream;
import static java.nio.charset.StandardCharsets.UTF_8;
-import static java.util.Arrays.asList;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
-@RunWith(JUnitParamsRunner.class)
+
public class PropertiesFileGeneratorTest {
- @Rule
- public final TemporaryFolder temporaryFolder = new TemporaryFolder();
+ @TempDir
+ public Path temporaryFolder;
private LogInterface getLogInterface() {
return mock(LogInterface.class);
@@ -90,16 +84,16 @@ public void generatedPropertiesFileDoesNotEscapeUnicode() throws GitCommitIdExec
properties.put(GitCommitPropertyConstant.BRANCH, "develop");
properties.put(GitCommitPropertyConstant.COMMIT_MESSAGE_SHORT, "測試中文");
- Path propertiesPath = temporaryFolder.getRoot().toPath().resolve("git.properties");
+ Path propertiesPath = temporaryFolder.resolve("git.properties");
getPropertiesFileGenerator().maybeGeneratePropertiesFile(
- properties, temporaryFolder.getRoot(), propertiesPath.toFile(), UTF_8, false);
+ properties, temporaryFolder.toFile(), propertiesPath.toFile(), UTF_8, false);
String actualContent = Files.readString(propertiesPath, UTF_8);
String expectedContent = convertLineBreaks("#Generated by Git-Commit-Id-Plugin\n"
+ "branch=develop\n"
+ "commit.id.full=b5993378ffadd1f84dc8da220b9204d157ec0f29\n"
+ "commit.message.short=測試中文\n");
- assertEquals(expectedContent, actualContent);
+ Assertions.assertEquals(expectedContent, actualContent);
}
@Test
@@ -109,16 +103,16 @@ public void generatedPropertiesFileEscapeUnicode() throws GitCommitIdExecutionEx
properties.put(GitCommitPropertyConstant.BRANCH, "develop");
properties.put(GitCommitPropertyConstant.COMMIT_MESSAGE_SHORT, "測試中文");
- Path propertiesPath = temporaryFolder.getRoot().toPath().resolve("git.properties");
+ Path propertiesPath = temporaryFolder.resolve("git.properties");
getPropertiesFileGenerator().maybeGeneratePropertiesFile(
- properties, temporaryFolder.getRoot(), propertiesPath.toFile(), UTF_8, true);
+ properties, temporaryFolder.toFile(), propertiesPath.toFile(), UTF_8, true);
String actualContent = Files.readString(propertiesPath, UTF_8);
String expectedContent = convertLineBreaks("#Generated by Git-Commit-Id-Plugin\n"
+ "branch=develop\n"
+ "commit.id.full=b5993378ffadd1f84dc8da220b9204d157ec0f29\n"
+ "commit.message.short=\\u6E2C\\u8A66\\u4E2D\\u6587\n");
- assertEquals(expectedContent, actualContent);
+ Assertions.assertEquals(expectedContent, actualContent);
}
@Test
@@ -127,15 +121,15 @@ public void generatedPropertiesFileDoesNotContainDateComment() throws GitCommitI
properties.put(GitCommitPropertyConstant.COMMIT_ID_FULL, "b5993378ffadd1f84dc8da220b9204d157ec0f29");
properties.put(GitCommitPropertyConstant.BRANCH, "develop");
- Path propertiesPath = temporaryFolder.getRoot().toPath().resolve("git.properties");
+ Path propertiesPath = temporaryFolder.resolve("git.properties");
getPropertiesFileGenerator().maybeGeneratePropertiesFile(
- properties, temporaryFolder.getRoot(), propertiesPath.toFile(), UTF_8, true);
+ properties, temporaryFolder.toFile(), propertiesPath.toFile(), UTF_8, true);
String actualContent = Files.readString(propertiesPath, UTF_8);
String expectedContent = convertLineBreaks("#Generated by Git-Commit-Id-Plugin\n"
+ "branch=develop\n"
+ "commit.id.full=b5993378ffadd1f84dc8da220b9204d157ec0f29\n");
- assertEquals(expectedContent, actualContent);
+ Assertions.assertEquals(expectedContent, actualContent);
}
@Test
@@ -145,19 +139,19 @@ public void reReadGeneratedPropertiesFile() throws GitCommitIdExecutionException
properties.put(GitCommitPropertyConstant.BRANCH, "develop");
PropertiesFileGenerator propertiesFileGenerator = getPropertiesFileGenerator();
- Path propertiesPath = temporaryFolder.getRoot().toPath().resolve("git.properties");
+ Path propertiesPath = temporaryFolder.resolve("git.properties");
propertiesFileGenerator.maybeGeneratePropertiesFile(
- properties, temporaryFolder.getRoot(), propertiesPath.toFile(), UTF_8, true);
+ properties, temporaryFolder.toFile(), propertiesPath.toFile(), UTF_8, true);
// Re-read the generated properties file.
propertiesFileGenerator.maybeGeneratePropertiesFile(
- properties, temporaryFolder.getRoot(), propertiesPath.toFile(), UTF_8, true);
+ properties, temporaryFolder.toFile(), propertiesPath.toFile(), UTF_8, true);
String actualContent = Files.readString(propertiesPath, UTF_8);
String expectedContent = convertLineBreaks("#Generated by Git-Commit-Id-Plugin\n"
+ "branch=develop\n"
+ "commit.id.full=b5993378ffadd1f84dc8da220b9204d157ec0f29\n");
- assertEquals(expectedContent, actualContent);
+ Assertions.assertEquals(expectedContent, actualContent);
}
@Test
@@ -167,18 +161,18 @@ public void worksWithRelativeFileLocation() throws GitCommitIdExecutionException
Path relativePath = new File("src/blah/blub/git.properties").toPath();
getPropertiesFileGenerator().maybeGeneratePropertiesFile(
- properties, temporaryFolder.getRoot(), relativePath.toFile(), UTF_8, false);
+ properties, temporaryFolder.toFile(), relativePath.toFile(), UTF_8, false);
- Path absolutePath = temporaryFolder.getRoot().toPath().resolve("src/blah/blub/git.properties");
- assertTrue(absolutePath.toFile().exists());
+ Path absolutePath = temporaryFolder.resolve("src/blah/blub/git.properties");
+ Assertions.assertTrue(absolutePath.toFile().exists());
String actualContent = Files.readString(absolutePath, UTF_8);
String expectedContent = convertLineBreaks("#Generated by Git-Commit-Id-Plugin\n"
+ "commit.id.full=b5993378ffadd1f84dc8da220b9204d157ec0f29\n");
- assertEquals(expectedContent, actualContent);
+ Assertions.assertEquals(expectedContent, actualContent);
}
- public Collection> dumpAndReadFormats() {
+ public static Collection> dumpAndReadFormats() {
Collection> collection = Arrays.stream(CommitIdPropertiesOutputFormat.values()).flatMap(f1 ->
Arrays.stream(CommitIdPropertiesOutputFormat.values()).map(f2 -> {
if (f1.equals(f2)) {
@@ -191,10 +185,9 @@ public Collection> dumpAndReadFormats() {
return collection;
}
-
- @Test
- @Parameters(method = "dumpAndReadFormats")
- @Ignore("Read and write is not consistent...")
+ @ParameterizedTest
+ @MethodSource("dumpAndReadFormats")
+ @Disabled("Read and write is not consistent...")
// https://github.com/git-commit-id/git-commit-id-plugin-core/issues/99
public void reReadGeneratedPropertiesFileWithDifferentFormats(
CommitIdPropertiesOutputFormat dumpFormat,
@@ -204,7 +197,7 @@ public void reReadGeneratedPropertiesFileWithDifferentFormats(
dumpedProperties.put(GitCommitPropertyConstant.COMMIT_ID_FULL, "b5993378ffadd1f84dc8da220b9204d157ec0f29");
dumpedProperties.put(GitCommitPropertyConstant.BRANCH, "develop");
- Path propertiesPath = temporaryFolder.getRoot().toPath().resolve("git.json");
+ Path propertiesPath = temporaryFolder.resolve("git.json");
GenericFileManager.dumpProperties(
getLogInterface(),
dumpFormat,
@@ -221,6 +214,6 @@ public void reReadGeneratedPropertiesFileWithDifferentFormats(
UTF_8,
"test"
);
- Assert.assertEquals(dumpedProperties, readProperties);
+ Assertions.assertEquals(dumpedProperties, readProperties);
}
}
diff --git a/src/test/java/pl/project13/core/UriUserInfoRemoverTest.java b/src/test/java/pl/project13/core/UriUserInfoRemoverTest.java
index 72711a0..ff55517 100644
--- a/src/test/java/pl/project13/core/UriUserInfoRemoverTest.java
+++ b/src/test/java/pl/project13/core/UriUserInfoRemoverTest.java
@@ -17,21 +17,18 @@
package pl.project13.core;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.ArgumentMatchers;
-import static org.junit.Assert.assertEquals;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
+import org.mockito.ArgumentMatchers;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
-import junitparams.JUnitParamsRunner;
-import junitparams.Parameters;
-
import java.util.Arrays;
import java.util.Collection;
-@RunWith(JUnitParamsRunner.class)
+
public class UriUserInfoRemoverTest {
public static Collection