Skip to content

Commit 71e0237

Browse files
akash1994deeptobiasdiez
authored andcommitted
Fix for issue 4641: Remove usage of TempDirectory extension from junit-pioneer (#4644)
* Removed the TempDirectory extension from junit-pioneer with the built in extension of junit 5.4 * Removed unused import
1 parent 891a93b commit 71e0237

24 files changed

+69
-119
lines changed

build.gradle

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,6 @@ dependencies {
165165
testRuntimeOnly 'org.junit.vintage:junit-vintage-engine:5.4.0'
166166
testCompile 'org.junit.platform:junit-platform-launcher:1.4.0'
167167

168-
testCompile 'org.junit-pioneer:junit-pioneer:0.3.0'
169168
testRuntime 'org.apache.logging.log4j:log4j-core:2.11.1'
170169
testRuntime 'org.apache.logging.log4j:log4j-jul:2.11.1'
171170
testCompile 'org.mockito:mockito-core:2.24.0'
@@ -190,9 +189,6 @@ dependencyUpdates {
190189
outputFormatter = "json"
191190
}
192191

193-
//We have to use this as long as junit-pioneer has no official release
194-
dependencyUpdates.revision = 'integration'
195-
196192
// We have some dependencies which cannot be updated due to various reasons.
197193
dependencyUpdates.resolutionStrategy = {
198194
componentSelection { rules ->

src/test/java/org/jabref/gui/externalfiles/AutoSetFileLinksUtilTest.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,13 @@
1616

1717
import org.junit.jupiter.api.BeforeEach;
1818
import org.junit.jupiter.api.Test;
19-
import org.junit.jupiter.api.extension.ExtendWith;
20-
import org.junitpioneer.jupiter.TempDirectory;
19+
import org.junit.jupiter.api.io.TempDir;
2120

2221
import static org.junit.jupiter.api.Assertions.assertEquals;
2322
import static org.mockito.ArgumentMatchers.any;
2423
import static org.mockito.Mockito.mock;
2524
import static org.mockito.Mockito.when;
2625

27-
@ExtendWith(TempDirectory.class)
2826
public class AutoSetFileLinksUtilTest {
2927

3028
private final FilePreferences fileDirPrefs = mock(FilePreferences.class);
@@ -34,7 +32,7 @@ public class AutoSetFileLinksUtilTest {
3432
private final BibEntry entry = new BibEntry(BibtexEntryTypes.ARTICLE);
3533

3634
@BeforeEach
37-
public void setUp(@TempDirectory.TempDir Path folder) throws Exception {
35+
public void setUp(@TempDir Path folder) throws Exception {
3836
Path path = folder.resolve("CiteKey.pdf");
3937
Files.createFile(path);
4038
entry.setCiteKey("CiteKey");

src/test/java/org/jabref/gui/fieldeditors/LinkedFileViewModelTest.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@
1717

1818
import org.junit.jupiter.api.BeforeEach;
1919
import org.junit.jupiter.api.Test;
20-
import org.junit.jupiter.api.extension.ExtendWith;
21-
import org.junitpioneer.jupiter.TempDirectory;
20+
import org.junit.jupiter.api.io.TempDir;
2221
import org.mockito.Answers;
2322

2423
import static org.junit.jupiter.api.Assertions.assertFalse;
@@ -31,7 +30,6 @@
3130
import static org.mockito.Mockito.verifyZeroInteractions;
3231
import static org.mockito.Mockito.when;
3332

34-
@ExtendWith(TempDirectory.class)
3533
class LinkedFileViewModelTest {
3634

3735
private Path tempFile;
@@ -43,7 +41,7 @@ class LinkedFileViewModelTest {
4341
private DialogService dialogService;
4442

4543
@BeforeEach
46-
void setUp(@TempDirectory.TempDir Path tempFolder) throws Exception {
44+
void setUp(@TempDir Path tempFolder) throws Exception {
4745
entry = new BibEntry();
4846
databaseContext = new BibDatabaseContext();
4947
taskExecutor = mock(TaskExecutor.class);

src/test/java/org/jabref/gui/journals/ManageJournalAbbreviationsViewModelTest.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@
2323

2424
import org.junit.jupiter.api.BeforeEach;
2525
import org.junit.jupiter.api.Test;
26-
import org.junit.jupiter.api.extension.ExtendWith;
27-
import org.junitpioneer.jupiter.TempDirectory;
26+
import org.junit.jupiter.api.io.TempDir;
2827

2928
import static org.jabref.logic.util.OS.NEWLINE;
3029
import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -37,7 +36,6 @@
3736
import static org.mockito.Mockito.verify;
3837
import static org.mockito.Mockito.when;
3938

40-
@ExtendWith(TempDirectory.class)
4139
class ManageJournalAbbreviationsViewModelTest {
4240

4341
private ManageJournalAbbreviationsViewModel viewModel;
@@ -50,7 +48,7 @@ class ManageJournalAbbreviationsViewModelTest {
5048
private DialogService dialogService;
5149

5250
@BeforeEach
53-
void setUpViewModel(@TempDirectory.TempDir Path tempFolder) throws Exception {
51+
void setUpViewModel(@TempDir Path tempFolder) throws Exception {
5452
abbreviationPreferences = mock(JournalAbbreviationPreferences.class);
5553
PreferencesService preferences = mock(PreferencesService.class);
5654
when(preferences.getJournalAbbreviationPreferences()).thenReturn(abbreviationPreferences);

src/test/java/org/jabref/gui/util/FileDialogConfigurationTest.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,14 @@
1212
import org.jabref.logic.util.StandardFileType;
1313

1414
import org.junit.jupiter.api.Test;
15-
import org.junit.jupiter.api.extension.ExtendWith;
16-
import org.junitpioneer.jupiter.TempDirectory;
15+
import org.junit.jupiter.api.io.TempDir;
1716

1817
import static org.junit.jupiter.api.Assertions.assertEquals;
1918

20-
@ExtendWith(TempDirectory.class)
2119
class FileDialogConfigurationTest {
2220

2321
@Test
24-
void testWithValidDirectoryString(@TempDirectory.TempDir Path folder) {
22+
void testWithValidDirectoryString(@TempDir Path folder) {
2523
String tempFolder = folder.toAbsolutePath().toString();
2624

2725
FileDialogConfiguration fileDialogConfiguration = new FileDialogConfiguration.Builder()
@@ -31,7 +29,7 @@ void testWithValidDirectoryString(@TempDirectory.TempDir Path folder) {
3129
}
3230

3331
@Test
34-
void testWithValidDirectoryPath(@TempDirectory.TempDir Path tempFolder) {
32+
void testWithValidDirectoryPath(@TempDir Path tempFolder) {
3533
FileDialogConfiguration fileDialogConfiguration = new FileDialogConfiguration.Builder()
3634
.withInitialDirectory(tempFolder).build();
3735

src/test/java/org/jabref/logic/cleanup/CleanupWorkerTest.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@
3434

3535
import org.junit.jupiter.api.BeforeEach;
3636
import org.junit.jupiter.api.Test;
37-
import org.junit.jupiter.api.extension.ExtendWith;
38-
import org.junitpioneer.jupiter.TempDirectory;
37+
import org.junit.jupiter.api.io.TempDir;
3938
import org.mockito.Answers;
4039

4140
import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -44,14 +43,13 @@
4443
import static org.mockito.Mockito.mock;
4544
import static org.mockito.Mockito.when;
4645

47-
@ExtendWith(TempDirectory.class)
4846
class CleanupWorkerTest {
4947

5048
private final CleanupPreset emptyPreset = new CleanupPreset(EnumSet.noneOf(CleanupPreset.CleanupStep.class));
5149
private CleanupWorker worker;
5250

5351
@BeforeEach
54-
void setUp(@TempDirectory.TempDir Path bibFolder) throws IOException {
52+
void setUp(@TempDir Path bibFolder) throws IOException {
5553

5654
Path path = bibFolder.resolve("ARandomlyNamedFolder");
5755
Files.createDirectory(path);
@@ -82,7 +80,7 @@ void cleanupNullEntryThrowsException() {
8280
}
8381

8482
@Test
85-
void cleanupDoesNothingByDefault(@TempDirectory.TempDir Path bibFolder) throws IOException {
83+
void cleanupDoesNothingByDefault(@TempDir Path bibFolder) throws IOException {
8684
BibEntry entry = new BibEntry();
8785
entry.setCiteKey("Toot");
8886
entry.setField("pdf", "aPdfFile");
@@ -220,7 +218,7 @@ void cleanupFixFileLinksMovesSingleDescriptionToLink() {
220218
}
221219

222220
@Test
223-
void cleanupMoveFilesMovesFileFromSubfolder(@TempDirectory.TempDir Path bibFolder) throws IOException {
221+
void cleanupMoveFilesMovesFileFromSubfolder(@TempDir Path bibFolder) throws IOException {
224222
CleanupPreset preset = new CleanupPreset(CleanupPreset.CleanupStep.MOVE_PDF);
225223

226224
Path path = bibFolder.resolve("AnotherRandomlyNamedFolder");
@@ -238,7 +236,7 @@ void cleanupMoveFilesMovesFileFromSubfolder(@TempDirectory.TempDir Path bibFolde
238236
}
239237

240238
@Test
241-
void cleanupRelativePathsConvertAbsoluteToRelativePath(@TempDirectory.TempDir Path bibFolder) throws IOException {
239+
void cleanupRelativePathsConvertAbsoluteToRelativePath(@TempDir Path bibFolder) throws IOException {
242240
CleanupPreset preset = new CleanupPreset(CleanupPreset.CleanupStep.MAKE_PATHS_RELATIVE);
243241

244242
Path path = bibFolder.resolve("AnotherRandomlyNamedFile");
@@ -254,7 +252,7 @@ void cleanupRelativePathsConvertAbsoluteToRelativePath(@TempDirectory.TempDir Pa
254252
}
255253

256254
@Test
257-
void cleanupRenamePdfRenamesRelativeFile(@TempDirectory.TempDir Path bibFolder) throws IOException {
255+
void cleanupRenamePdfRenamesRelativeFile(@TempDir Path bibFolder) throws IOException {
258256
CleanupPreset preset = new CleanupPreset(CleanupPreset.CleanupStep.RENAME_PDF);
259257

260258
Path path = bibFolder.resolve("AnotherRandomlyNamedFile.tmp");

src/test/java/org/jabref/logic/cleanup/MoveFilesCleanupTest.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,14 @@
1717

1818
import org.junit.jupiter.api.BeforeEach;
1919
import org.junit.jupiter.api.Test;
20-
import org.junit.jupiter.api.extension.ExtendWith;
21-
import org.junitpioneer.jupiter.TempDirectory;
20+
import org.junit.jupiter.api.io.TempDir;
2221

2322
import static org.junit.jupiter.api.Assertions.assertEquals;
2423
import static org.junit.jupiter.api.Assertions.assertFalse;
2524
import static org.junit.jupiter.api.Assertions.assertTrue;
2625
import static org.mockito.Mockito.mock;
2726
import static org.mockito.Mockito.when;
2827

29-
@ExtendWith(TempDirectory.class)
3028
class MoveFilesCleanupTest {
3129

3230
private Path defaultFileFolder;
@@ -36,7 +34,7 @@ class MoveFilesCleanupTest {
3634
private FilePreferences filePreferences;
3735

3836
@BeforeEach
39-
void setUp(@TempDirectory.TempDir Path bibFolder) throws IOException {
37+
void setUp(@TempDir Path bibFolder) throws IOException {
4038
// The folder where the files should be moved to
4139
defaultFileFolder = bibFolder.resolve("pdf");
4240
Files.createDirectory(defaultFileFolder);

src/test/java/org/jabref/logic/cleanup/RenamePdfCleanupTest.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,12 @@
1717

1818
import org.junit.jupiter.api.BeforeEach;
1919
import org.junit.jupiter.api.Test;
20-
import org.junit.jupiter.api.extension.ExtendWith;
21-
import org.junitpioneer.jupiter.TempDirectory;
20+
import org.junit.jupiter.api.io.TempDir;
2221

2322
import static org.junit.jupiter.api.Assertions.assertEquals;
2423
import static org.mockito.Mockito.mock;
2524
import static org.mockito.Mockito.when;
2625

27-
@ExtendWith(TempDirectory.class)
2826
class RenamePdfCleanupTest {
2927

3028
private BibEntry entry;
@@ -33,7 +31,7 @@ class RenamePdfCleanupTest {
3331
private RenamePdfCleanup cleanup;
3432

3533
@BeforeEach
36-
void setUp(@TempDirectory.TempDir Path testFolder) {
34+
void setUp(@TempDir Path testFolder) {
3735
Path path = testFolder.resolve("test.bib");
3836
MetaData metaData = new MetaData();
3937
BibDatabaseContext context = new BibDatabaseContext(new BibDatabase(), metaData, new Defaults());
@@ -51,7 +49,7 @@ void setUp(@TempDirectory.TempDir Path testFolder) {
5149
* Test for #466
5250
*/
5351
@Test
54-
void cleanupRenamePdfRenamesFileEvenIfOnlyDifferenceIsCase(@TempDirectory.TempDir Path testFolder) throws IOException {
52+
void cleanupRenamePdfRenamesFileEvenIfOnlyDifferenceIsCase(@TempDir Path testFolder) throws IOException {
5553
Path path = testFolder.resolve("toot.tmp");
5654
Files.createFile(path);
5755

@@ -66,7 +64,7 @@ void cleanupRenamePdfRenamesFileEvenIfOnlyDifferenceIsCase(@TempDirectory.TempDi
6664
}
6765

6866
@Test
69-
void cleanupRenamePdfRenamesWithMultipleFiles(@TempDirectory.TempDir Path testFolder) throws IOException {
67+
void cleanupRenamePdfRenamesWithMultipleFiles(@TempDir Path testFolder) throws IOException {
7068
Path path = testFolder.resolve("Toot.tmp");
7169
Files.createFile(path);
7270

@@ -84,7 +82,7 @@ void cleanupRenamePdfRenamesWithMultipleFiles(@TempDirectory.TempDir Path testFo
8482
}
8583

8684
@Test
87-
void cleanupRenamePdfRenamesFileStartingWithBibtexKey(@TempDirectory.TempDir Path testFolder) throws IOException {
85+
void cleanupRenamePdfRenamesFileStartingWithBibtexKey(@TempDir Path testFolder) throws IOException {
8886
Path path = testFolder.resolve("Toot.tmp");
8987
Files.createFile(path);
9088

@@ -100,7 +98,7 @@ void cleanupRenamePdfRenamesFileStartingWithBibtexKey(@TempDirectory.TempDir Pat
10098
}
10199

102100
@Test
103-
void cleanupRenamePdfRenamesFileInSameFolder(@TempDirectory.TempDir Path testFolder) throws IOException {
101+
void cleanupRenamePdfRenamesFileInSameFolder(@TempDir Path testFolder) throws IOException {
104102
Path path = testFolder.resolve("Toot.pdf");
105103
Files.createFile(path);
106104
LinkedFile fileField = new LinkedFile("", "Toot.pdf", "PDF");

src/test/java/org/jabref/logic/exporter/BibTeXMLExporterTestFiles.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,9 @@
1818
import org.jabref.model.util.DummyFileUpdateMonitor;
1919

2020
import org.junit.jupiter.api.BeforeEach;
21-
import org.junit.jupiter.api.extension.ExtendWith;
21+
import org.junit.jupiter.api.io.TempDir;
2222
import org.junit.jupiter.params.ParameterizedTest;
2323
import org.junit.jupiter.params.provider.MethodSource;
24-
import org.junitpioneer.jupiter.TempDirectory;
2524
import org.mockito.Answers;
2625
import org.xmlunit.builder.Input;
2726
import org.xmlunit.builder.Input.Builder;
@@ -32,7 +31,6 @@
3231
import static org.hamcrest.MatcherAssert.assertThat;
3332
import static org.mockito.Mockito.mock;
3433

35-
@ExtendWith(TempDirectory.class)
3634
public class BibTeXMLExporterTestFiles {
3735

3836
private static Path resourceDir;
@@ -52,7 +50,7 @@ public static Stream<String> fileNames() throws IOException, URISyntaxException
5250
}
5351

5452
@BeforeEach
55-
public void setUp(@TempDirectory.TempDir Path testFolder) throws Exception {
53+
public void setUp(@TempDir Path testFolder) throws Exception {
5654
databaseContext = new BibDatabaseContext();
5755
charset = StandardCharsets.UTF_8;
5856
bibtexmlExportFormat = new BibTeXMLExporter();

src/test/java/org/jabref/logic/exporter/CsvExportFormatTest.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,12 @@
1717
import org.junit.jupiter.api.AfterEach;
1818
import org.junit.jupiter.api.BeforeEach;
1919
import org.junit.jupiter.api.Test;
20-
import org.junit.jupiter.api.extension.ExtendWith;
21-
import org.junitpioneer.jupiter.TempDirectory;
20+
import org.junit.jupiter.api.io.TempDir;
2221
import org.mockito.Answers;
2322

2423
import static org.junit.jupiter.api.Assertions.assertEquals;
2524
import static org.mockito.Mockito.mock;
2625

27-
@ExtendWith(TempDirectory.class)
2826
public class CsvExportFormatTest {
2927

3028
public BibDatabaseContext databaseContext;
@@ -51,7 +49,7 @@ public void tearDown() {
5149
}
5250

5351
@Test
54-
public void testPerformExportForSingleAuthor(@TempDirectory.TempDir Path testFolder) throws Exception {
52+
public void testPerformExportForSingleAuthor(@TempDir Path testFolder) throws Exception {
5553
Path path = testFolder.resolve("ThisIsARandomlyNamedFile");
5654

5755
BibEntry entry = new BibEntry();
@@ -68,7 +66,7 @@ public void testPerformExportForSingleAuthor(@TempDirectory.TempDir Path testFol
6866
}
6967

7068
@Test
71-
public void testPerformExportForMultipleAuthors(@TempDirectory.TempDir Path testFolder) throws Exception {
69+
public void testPerformExportForMultipleAuthors(@TempDir Path testFolder) throws Exception {
7270
Path path = testFolder.resolve("ThisIsARandomlyNamedFile");
7371

7472
BibEntry entry = new BibEntry();
@@ -85,7 +83,7 @@ public void testPerformExportForMultipleAuthors(@TempDirectory.TempDir Path test
8583
}
8684

8785
@Test
88-
public void testPerformExportForSingleEditor(@TempDirectory.TempDir Path testFolder) throws Exception {
86+
public void testPerformExportForSingleEditor(@TempDir Path testFolder) throws Exception {
8987
Path path = testFolder.resolve("ThisIsARandomlyNamedFile");
9088
File tmpFile = path.toFile();
9189
BibEntry entry = new BibEntry();
@@ -102,7 +100,7 @@ public void testPerformExportForSingleEditor(@TempDirectory.TempDir Path testFol
102100
}
103101

104102
@Test
105-
public void testPerformExportForMultipleEditors(@TempDirectory.TempDir Path testFolder) throws Exception {
103+
public void testPerformExportForMultipleEditors(@TempDir Path testFolder) throws Exception {
106104
Path path = testFolder.resolve("ThisIsARandomlyNamedFile");
107105
File tmpFile = path.toFile();
108106
BibEntry entry = new BibEntry();

0 commit comments

Comments
 (0)