-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
57 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
src/test/java/net/sf/jabref/importer/fileformat/PdfContentImporterTestFiles.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package net.sf.jabref.importer.fileformat; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.util.Arrays; | ||
import java.util.Collection; | ||
import java.util.List; | ||
|
||
import org.junit.Assert; | ||
import org.junit.BeforeClass; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.junit.runners.Parameterized; | ||
import org.junit.runners.Parameterized.Parameter; | ||
import org.junit.runners.Parameterized.Parameters; | ||
|
||
import net.sf.jabref.Globals; | ||
import net.sf.jabref.JabRefPreferences; | ||
import net.sf.jabref.bibtex.BibtexEntryAssert; | ||
import net.sf.jabref.model.entry.BibEntry; | ||
|
||
@RunWith(Parameterized.class) | ||
public class PdfContentImporterTestFiles { | ||
|
||
@BeforeClass | ||
public static void setUp() { | ||
Globals.prefs = JabRefPreferences.getInstance(); | ||
} | ||
|
||
@Parameters(name = "{index}: {0}") | ||
public static Collection<Object[]> fileNames() { | ||
// The test folder contains pairs of PDFs and BibTeX files. We check each pair. | ||
// This method returns the basenames of the available pairs | ||
|
||
// currently, only one test case "LNCS-minimal" is existing | ||
// code review demanded that @Paramters should be used | ||
// Arrays.asList only works for multiple parameters, therefore, there are two parameters written | ||
return Arrays.asList(new Object[] {"LNCS-minimal"}, new Object[] {"LNCS-minimal"}); | ||
} | ||
|
||
|
||
@Parameter | ||
public String fileName; | ||
|
||
@Test | ||
public void correctContent() throws IOException { | ||
String pdfFileName = fileName + ".pdf"; | ||
String bibFileName = fileName + ".bib"; | ||
PdfContentImporter importer = new PdfContentImporter(); | ||
try (InputStream is = PdfContentImporter.class.getResourceAsStream(pdfFileName)) { | ||
List<BibEntry> result = importer.importEntries(is, null); | ||
Assert.assertEquals(1, result.size()); | ||
BibtexEntryAssert.assertEquals(PdfContentImporterTest.class, bibFileName, result.get(0)); | ||
} | ||
} | ||
|
||
} |