Skip to content

Commit

Permalink
Fix for issue 4641: Remove usage of TempDirectory extension from juni…
Browse files Browse the repository at this point in the history
…t-pioneer (#4644)

* Removed the TempDirectory extension from junit-pioneer with the built in
extension of junit 5.4

* Removed unused import
  • Loading branch information
akash1994deep authored and tobiasdiez committed Feb 9, 2019
1 parent 891a93b commit 71e0237
Show file tree
Hide file tree
Showing 24 changed files with 69 additions and 119 deletions.
4 changes: 0 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,6 @@ dependencies {
testRuntimeOnly 'org.junit.vintage:junit-vintage-engine:5.4.0'
testCompile 'org.junit.platform:junit-platform-launcher:1.4.0'

testCompile 'org.junit-pioneer:junit-pioneer:0.3.0'
testRuntime 'org.apache.logging.log4j:log4j-core:2.11.1'
testRuntime 'org.apache.logging.log4j:log4j-jul:2.11.1'
testCompile 'org.mockito:mockito-core:2.24.0'
Expand All @@ -190,9 +189,6 @@ dependencyUpdates {
outputFormatter = "json"
}

//We have to use this as long as junit-pioneer has no official release
dependencyUpdates.revision = 'integration'

// We have some dependencies which cannot be updated due to various reasons.
dependencyUpdates.resolutionStrategy = {
componentSelection { rules ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,13 @@

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junitpioneer.jupiter.TempDirectory;
import org.junit.jupiter.api.io.TempDir;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

@ExtendWith(TempDirectory.class)
public class AutoSetFileLinksUtilTest {

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

@BeforeEach
public void setUp(@TempDirectory.TempDir Path folder) throws Exception {
public void setUp(@TempDir Path folder) throws Exception {
Path path = folder.resolve("CiteKey.pdf");
Files.createFile(path);
entry.setCiteKey("CiteKey");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junitpioneer.jupiter.TempDirectory;
import org.junit.jupiter.api.io.TempDir;
import org.mockito.Answers;

import static org.junit.jupiter.api.Assertions.assertFalse;
Expand All @@ -31,7 +30,6 @@
import static org.mockito.Mockito.verifyZeroInteractions;
import static org.mockito.Mockito.when;

@ExtendWith(TempDirectory.class)
class LinkedFileViewModelTest {

private Path tempFile;
Expand All @@ -43,7 +41,7 @@ class LinkedFileViewModelTest {
private DialogService dialogService;

@BeforeEach
void setUp(@TempDirectory.TempDir Path tempFolder) throws Exception {
void setUp(@TempDir Path tempFolder) throws Exception {
entry = new BibEntry();
databaseContext = new BibDatabaseContext();
taskExecutor = mock(TaskExecutor.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junitpioneer.jupiter.TempDirectory;
import org.junit.jupiter.api.io.TempDir;

import static org.jabref.logic.util.OS.NEWLINE;
import static org.junit.jupiter.api.Assertions.assertEquals;
Expand All @@ -37,7 +36,6 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

@ExtendWith(TempDirectory.class)
class ManageJournalAbbreviationsViewModelTest {

private ManageJournalAbbreviationsViewModel viewModel;
Expand All @@ -50,7 +48,7 @@ class ManageJournalAbbreviationsViewModelTest {
private DialogService dialogService;

@BeforeEach
void setUpViewModel(@TempDirectory.TempDir Path tempFolder) throws Exception {
void setUpViewModel(@TempDir Path tempFolder) throws Exception {
abbreviationPreferences = mock(JournalAbbreviationPreferences.class);
PreferencesService preferences = mock(PreferencesService.class);
when(preferences.getJournalAbbreviationPreferences()).thenReturn(abbreviationPreferences);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,14 @@
import org.jabref.logic.util.StandardFileType;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junitpioneer.jupiter.TempDirectory;
import org.junit.jupiter.api.io.TempDir;

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

@ExtendWith(TempDirectory.class)
class FileDialogConfigurationTest {

@Test
void testWithValidDirectoryString(@TempDirectory.TempDir Path folder) {
void testWithValidDirectoryString(@TempDir Path folder) {
String tempFolder = folder.toAbsolutePath().toString();

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

@Test
void testWithValidDirectoryPath(@TempDirectory.TempDir Path tempFolder) {
void testWithValidDirectoryPath(@TempDir Path tempFolder) {
FileDialogConfiguration fileDialogConfiguration = new FileDialogConfiguration.Builder()
.withInitialDirectory(tempFolder).build();

Expand Down
14 changes: 6 additions & 8 deletions src/test/java/org/jabref/logic/cleanup/CleanupWorkerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junitpioneer.jupiter.TempDirectory;
import org.junit.jupiter.api.io.TempDir;
import org.mockito.Answers;

import static org.junit.jupiter.api.Assertions.assertEquals;
Expand All @@ -44,14 +43,13 @@
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

@ExtendWith(TempDirectory.class)
class CleanupWorkerTest {

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

@BeforeEach
void setUp(@TempDirectory.TempDir Path bibFolder) throws IOException {
void setUp(@TempDir Path bibFolder) throws IOException {

Path path = bibFolder.resolve("ARandomlyNamedFolder");
Files.createDirectory(path);
Expand Down Expand Up @@ -82,7 +80,7 @@ void cleanupNullEntryThrowsException() {
}

@Test
void cleanupDoesNothingByDefault(@TempDirectory.TempDir Path bibFolder) throws IOException {
void cleanupDoesNothingByDefault(@TempDir Path bibFolder) throws IOException {
BibEntry entry = new BibEntry();
entry.setCiteKey("Toot");
entry.setField("pdf", "aPdfFile");
Expand Down Expand Up @@ -220,7 +218,7 @@ void cleanupFixFileLinksMovesSingleDescriptionToLink() {
}

@Test
void cleanupMoveFilesMovesFileFromSubfolder(@TempDirectory.TempDir Path bibFolder) throws IOException {
void cleanupMoveFilesMovesFileFromSubfolder(@TempDir Path bibFolder) throws IOException {
CleanupPreset preset = new CleanupPreset(CleanupPreset.CleanupStep.MOVE_PDF);

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

@Test
void cleanupRelativePathsConvertAbsoluteToRelativePath(@TempDirectory.TempDir Path bibFolder) throws IOException {
void cleanupRelativePathsConvertAbsoluteToRelativePath(@TempDir Path bibFolder) throws IOException {
CleanupPreset preset = new CleanupPreset(CleanupPreset.CleanupStep.MAKE_PATHS_RELATIVE);

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

@Test
void cleanupRenamePdfRenamesRelativeFile(@TempDirectory.TempDir Path bibFolder) throws IOException {
void cleanupRenamePdfRenamesRelativeFile(@TempDir Path bibFolder) throws IOException {
CleanupPreset preset = new CleanupPreset(CleanupPreset.CleanupStep.RENAME_PDF);

Path path = bibFolder.resolve("AnotherRandomlyNamedFile.tmp");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,14 @@

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junitpioneer.jupiter.TempDirectory;
import org.junit.jupiter.api.io.TempDir;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

@ExtendWith(TempDirectory.class)
class MoveFilesCleanupTest {

private Path defaultFileFolder;
Expand All @@ -36,7 +34,7 @@ class MoveFilesCleanupTest {
private FilePreferences filePreferences;

@BeforeEach
void setUp(@TempDirectory.TempDir Path bibFolder) throws IOException {
void setUp(@TempDir Path bibFolder) throws IOException {
// The folder where the files should be moved to
defaultFileFolder = bibFolder.resolve("pdf");
Files.createDirectory(defaultFileFolder);
Expand Down
14 changes: 6 additions & 8 deletions src/test/java/org/jabref/logic/cleanup/RenamePdfCleanupTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,12 @@

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junitpioneer.jupiter.TempDirectory;
import org.junit.jupiter.api.io.TempDir;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

@ExtendWith(TempDirectory.class)
class RenamePdfCleanupTest {

private BibEntry entry;
Expand All @@ -33,7 +31,7 @@ class RenamePdfCleanupTest {
private RenamePdfCleanup cleanup;

@BeforeEach
void setUp(@TempDirectory.TempDir Path testFolder) {
void setUp(@TempDir Path testFolder) {
Path path = testFolder.resolve("test.bib");
MetaData metaData = new MetaData();
BibDatabaseContext context = new BibDatabaseContext(new BibDatabase(), metaData, new Defaults());
Expand All @@ -51,7 +49,7 @@ void setUp(@TempDirectory.TempDir Path testFolder) {
* Test for #466
*/
@Test
void cleanupRenamePdfRenamesFileEvenIfOnlyDifferenceIsCase(@TempDirectory.TempDir Path testFolder) throws IOException {
void cleanupRenamePdfRenamesFileEvenIfOnlyDifferenceIsCase(@TempDir Path testFolder) throws IOException {
Path path = testFolder.resolve("toot.tmp");
Files.createFile(path);

Expand All @@ -66,7 +64,7 @@ void cleanupRenamePdfRenamesFileEvenIfOnlyDifferenceIsCase(@TempDirectory.TempDi
}

@Test
void cleanupRenamePdfRenamesWithMultipleFiles(@TempDirectory.TempDir Path testFolder) throws IOException {
void cleanupRenamePdfRenamesWithMultipleFiles(@TempDir Path testFolder) throws IOException {
Path path = testFolder.resolve("Toot.tmp");
Files.createFile(path);

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

@Test
void cleanupRenamePdfRenamesFileStartingWithBibtexKey(@TempDirectory.TempDir Path testFolder) throws IOException {
void cleanupRenamePdfRenamesFileStartingWithBibtexKey(@TempDir Path testFolder) throws IOException {
Path path = testFolder.resolve("Toot.tmp");
Files.createFile(path);

Expand All @@ -100,7 +98,7 @@ void cleanupRenamePdfRenamesFileStartingWithBibtexKey(@TempDirectory.TempDir Pat
}

@Test
void cleanupRenamePdfRenamesFileInSameFolder(@TempDirectory.TempDir Path testFolder) throws IOException {
void cleanupRenamePdfRenamesFileInSameFolder(@TempDir Path testFolder) throws IOException {
Path path = testFolder.resolve("Toot.pdf");
Files.createFile(path);
LinkedFile fileField = new LinkedFile("", "Toot.pdf", "PDF");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@
import org.jabref.model.util.DummyFileUpdateMonitor;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.api.io.TempDir;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
import org.junitpioneer.jupiter.TempDirectory;
import org.mockito.Answers;
import org.xmlunit.builder.Input;
import org.xmlunit.builder.Input.Builder;
Expand All @@ -32,7 +31,6 @@
import static org.hamcrest.MatcherAssert.assertThat;
import static org.mockito.Mockito.mock;

@ExtendWith(TempDirectory.class)
public class BibTeXMLExporterTestFiles {

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

@BeforeEach
public void setUp(@TempDirectory.TempDir Path testFolder) throws Exception {
public void setUp(@TempDir Path testFolder) throws Exception {
databaseContext = new BibDatabaseContext();
charset = StandardCharsets.UTF_8;
bibtexmlExportFormat = new BibTeXMLExporter();
Expand Down
12 changes: 5 additions & 7 deletions src/test/java/org/jabref/logic/exporter/CsvExportFormatTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,12 @@
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junitpioneer.jupiter.TempDirectory;
import org.junit.jupiter.api.io.TempDir;
import org.mockito.Answers;

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

@ExtendWith(TempDirectory.class)
public class CsvExportFormatTest {

public BibDatabaseContext databaseContext;
Expand All @@ -51,7 +49,7 @@ public void tearDown() {
}

@Test
public void testPerformExportForSingleAuthor(@TempDirectory.TempDir Path testFolder) throws Exception {
public void testPerformExportForSingleAuthor(@TempDir Path testFolder) throws Exception {
Path path = testFolder.resolve("ThisIsARandomlyNamedFile");

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

@Test
public void testPerformExportForMultipleAuthors(@TempDirectory.TempDir Path testFolder) throws Exception {
public void testPerformExportForMultipleAuthors(@TempDir Path testFolder) throws Exception {
Path path = testFolder.resolve("ThisIsARandomlyNamedFile");

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

@Test
public void testPerformExportForSingleEditor(@TempDirectory.TempDir Path testFolder) throws Exception {
public void testPerformExportForSingleEditor(@TempDir Path testFolder) throws Exception {
Path path = testFolder.resolve("ThisIsARandomlyNamedFile");
File tmpFile = path.toFile();
BibEntry entry = new BibEntry();
Expand All @@ -102,7 +100,7 @@ public void testPerformExportForSingleEditor(@TempDirectory.TempDir Path testFol
}

@Test
public void testPerformExportForMultipleEditors(@TempDirectory.TempDir Path testFolder) throws Exception {
public void testPerformExportForMultipleEditors(@TempDir Path testFolder) throws Exception {
Path path = testFolder.resolve("ThisIsARandomlyNamedFile");
File tmpFile = path.toFile();
BibEntry entry = new BibEntry();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junitpioneer.jupiter.TempDirectory;
import org.junit.jupiter.api.io.TempDir;
import org.mockito.Answers;
import org.xmlunit.builder.Input;
import org.xmlunit.builder.Input.Builder;
Expand All @@ -32,7 +31,6 @@
import static org.hamcrest.MatcherAssert.assertThat;
import static org.mockito.Mockito.mock;

@ExtendWith(TempDirectory.class)
public class DocBook5ExporterTest {

public BibDatabaseContext databaseContext;
Expand Down Expand Up @@ -68,7 +66,7 @@ public void setUp() throws URISyntaxException {
}

@Test
public void testPerformExportForSingleEntry(@TempDirectory.TempDir Path testFolder) throws Exception {
public void testPerformExportForSingleEntry(@TempDir Path testFolder) throws Exception {

Path path = testFolder.resolve("ThisIsARandomlyNamedFile");

Expand Down
Loading

0 comments on commit 71e0237

Please sign in to comment.