-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added the MedlineImporterTest and a testfile
- Loading branch information
Showing
2 changed files
with
256 additions
and
0 deletions.
There are no files selected for viewing
89 changes: 89 additions & 0 deletions
89
src/test/java/net/sf/jabref/importer/fileformat/MedlineImporterTest.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,89 @@ | ||
package net.sf.jabref.importer.fileformat; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
import net.sf.jabref.Globals; | ||
import net.sf.jabref.JabRefPreferences; | ||
import net.sf.jabref.importer.OutputPrinterToNull; | ||
import net.sf.jabref.model.entry.BibEntry; | ||
|
||
|
||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.junit.Assert; | ||
|
||
/** | ||
* @author Daniel Mair/Bruehl | ||
* | ||
*/ | ||
public class MedlineImporterTest { | ||
|
||
MedlineImporter medlineImporter; | ||
|
||
@Before | ||
public void setUp() throws Exception { | ||
Globals.prefs = JabRefPreferences.getInstance(); | ||
this.medlineImporter = new MedlineImporter(); | ||
} | ||
|
||
@Test | ||
public void testIsRecognizedFormatAccept() throws Throwable { | ||
List<String> list = Arrays.asList("MedlineImporterTest.xml"); | ||
for (String str : list) { | ||
try (InputStream is = MedlineImporterTest.class.getResourceAsStream(str);) { | ||
Assert.assertTrue(medlineImporter.isRecognizedFormat(is)); | ||
} | ||
} | ||
} | ||
|
||
@Test | ||
public void testIsRecognizedFormatReject() throws Throwable { | ||
List<String> list = Arrays.asList("CopacImporterTest1.txt", "CopacImporterTest2.txt", | ||
"IEEEImport1.txt", "IsiImporterTestWOS.isi"); | ||
for (String str : list) { | ||
try (InputStream is = MedlineImporterTest.class.getResourceAsStream(str);) { | ||
Assert.assertFalse(medlineImporter.isRecognizedFormat(is)); | ||
} | ||
} | ||
} | ||
|
||
@Test | ||
public void testImportEntries() throws IOException { | ||
try (InputStream is = MedlineImporter.class.getResourceAsStream("MedlineImporterTest.xml")) { | ||
List<BibEntry> entries = medlineImporter.importEntries(is, new OutputPrinterToNull()); | ||
Assert.assertEquals(1, entries.size()); | ||
} | ||
} | ||
|
||
@Test | ||
public void testImportEntries2() throws IOException { | ||
try (InputStream is = MedlineImporter.class.getResourceAsStream("CopacImporterTest1.txt")) { | ||
// Trigger a catchblock | ||
List<BibEntry> entries = medlineImporter.importEntries(is, new OutputPrinterToNull()); | ||
//Assert.fail("Error during XML parsing"); | ||
} | ||
} | ||
|
||
@Test | ||
public void testGetFormatName() { | ||
assertEquals("testGetFormatName failed", "Medline", medlineImporter.getFormatName()); | ||
} | ||
|
||
@Test | ||
public void testGetCLIId() { | ||
assertEquals("testGetCLIID failed", "medline", medlineImporter.getCLIId()); | ||
} | ||
|
||
@Test | ||
public void testFetchMedline() { | ||
List<BibEntry> validMedLine = medlineImporter.fetchMedline("1", new OutputPrinterToNull()); | ||
List<BibEntry> emptyMedLine = medlineImporter.fetchMedline("zzzzzz", new OutputPrinterToNull()); | ||
assertNotNull(validMedLine); | ||
assertEquals(0, emptyMedLine.size()); | ||
} | ||
|
||
} |
167 changes: 167 additions & 0 deletions
167
src/test/resources/net/sf/jabref/importer/fileformat/MedlineImporterTest.xml
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,167 @@ | ||
<PubmedArticleSet> | ||
<PubmedArticle> | ||
<MedlineCitation Owner="NLM" Status="MEDLINE"> | ||
<PMID Version="1">1</PMID> | ||
<DateCreated> | ||
<Year>1976</Year> | ||
<Month>01</Month> | ||
<Day>16</Day> | ||
</DateCreated> | ||
<DateCompleted> | ||
<Year>1976</Year> | ||
<Month>01</Month> | ||
<Day>16</Day> | ||
</DateCompleted> | ||
<DateRevised> | ||
<Year>2013</Year> | ||
<Month>11</Month> | ||
<Day>21</Day> | ||
</DateRevised> | ||
<Article PubModel="Print"> | ||
<Journal> | ||
<ISSN IssnType="Print">0006-2944</ISSN> | ||
<JournalIssue CitedMedium="Print"> | ||
<Volume>13</Volume> | ||
<Issue>2</Issue> | ||
<PubDate> | ||
<Year>1975</Year> | ||
<Month>Jun</Month> | ||
</PubDate> | ||
</JournalIssue> | ||
<Title>Biochemical medicine</Title> | ||
<ISOAbbreviation>Biochem Med</ISOAbbreviation> | ||
</Journal> | ||
<ArticleTitle> | ||
Formate assay in body fluids: application in methanol poisoning. | ||
</ArticleTitle> | ||
<Pagination> | ||
<MedlinePgn>117-26</MedlinePgn> | ||
</Pagination> | ||
<AuthorList CompleteYN="Y"> | ||
<Author ValidYN="Y"> | ||
<LastName>Makar</LastName> | ||
<ForeName>A B</ForeName> | ||
<Initials>AB</Initials> | ||
</Author> | ||
<Author ValidYN="Y"> | ||
<LastName>McMartin</LastName> | ||
<ForeName>K E</ForeName> | ||
<Initials>KE</Initials> | ||
</Author> | ||
<Author ValidYN="Y"> | ||
<LastName>Palese</LastName> | ||
<ForeName>M</ForeName> | ||
<Initials>M</Initials> | ||
</Author> | ||
<Author ValidYN="Y"> | ||
<LastName>Tephly</LastName> | ||
<ForeName>T R</ForeName> | ||
<Initials>TR</Initials> | ||
</Author> | ||
</AuthorList> | ||
<Language>eng</Language> | ||
<PublicationTypeList> | ||
<PublicationType UI="D016428">Journal Article</PublicationType> | ||
<PublicationType UI="D013487">Research Support, U.S. Gov't, P.H.S.</PublicationType> | ||
</PublicationTypeList> | ||
</Article> | ||
<MedlineJournalInfo> | ||
<Country>UNITED STATES</Country> | ||
<MedlineTA>Biochem Med</MedlineTA> | ||
<NlmUniqueID>0151424</NlmUniqueID> | ||
<ISSNLinking>0006-2944</ISSNLinking> | ||
</MedlineJournalInfo> | ||
<ChemicalList> | ||
<Chemical> | ||
<RegistryNumber>0</RegistryNumber> | ||
<NameOfSubstance UI="D005561">Formates</NameOfSubstance> | ||
</Chemical> | ||
<Chemical> | ||
<RegistryNumber>142M471B3J</RegistryNumber> | ||
<NameOfSubstance UI="D002245">Carbon Dioxide</NameOfSubstance> | ||
</Chemical> | ||
<Chemical> | ||
<RegistryNumber>EC 1.2.-</RegistryNumber> | ||
<NameOfSubstance UI="D000445">Aldehyde Oxidoreductases</NameOfSubstance> | ||
</Chemical> | ||
<Chemical> | ||
<RegistryNumber>Y4S76JWI15</RegistryNumber> | ||
<NameOfSubstance UI="D000432">Methanol</NameOfSubstance> | ||
</Chemical> | ||
</ChemicalList> | ||
<CitationSubset>IM</CitationSubset> | ||
<MeshHeadingList> | ||
<MeshHeading> | ||
<DescriptorName MajorTopicYN="N" UI="D000445">Aldehyde Oxidoreductases</DescriptorName> | ||
<QualifierName MajorTopicYN="N" UI="Q000378">metabolism</QualifierName> | ||
</MeshHeading> | ||
<MeshHeading> | ||
<DescriptorName MajorTopicYN="N" UI="D000818">Animals</DescriptorName> | ||
</MeshHeading> | ||
<MeshHeading> | ||
<DescriptorName MajorTopicYN="N" UI="D001826">Body Fluids</DescriptorName> | ||
<QualifierName MajorTopicYN="Y" UI="Q000032">analysis</QualifierName> | ||
</MeshHeading> | ||
<MeshHeading> | ||
<DescriptorName MajorTopicYN="N" UI="D002245">Carbon Dioxide</DescriptorName> | ||
<QualifierName MajorTopicYN="N" UI="Q000097">blood</QualifierName> | ||
</MeshHeading> | ||
<MeshHeading> | ||
<DescriptorName MajorTopicYN="N" UI="D005561">Formates</DescriptorName> | ||
<QualifierName MajorTopicYN="N" UI="Q000097">blood</QualifierName> | ||
<QualifierName MajorTopicYN="Y" UI="Q000506">poisoning</QualifierName> | ||
</MeshHeading> | ||
<MeshHeading> | ||
<DescriptorName MajorTopicYN="N" UI="D000882">Haplorhini</DescriptorName> | ||
</MeshHeading> | ||
<MeshHeading> | ||
<DescriptorName MajorTopicYN="N" UI="D006801">Humans</DescriptorName> | ||
</MeshHeading> | ||
<MeshHeading> | ||
<DescriptorName MajorTopicYN="N" UI="D006863">Hydrogen-Ion Concentration</DescriptorName> | ||
</MeshHeading> | ||
<MeshHeading> | ||
<DescriptorName MajorTopicYN="N" UI="D007700">Kinetics</DescriptorName> | ||
</MeshHeading> | ||
<MeshHeading> | ||
<DescriptorName MajorTopicYN="N" UI="D000432">Methanol</DescriptorName> | ||
<QualifierName MajorTopicYN="N" UI="Q000097">blood</QualifierName> | ||
</MeshHeading> | ||
<MeshHeading> | ||
<DescriptorName MajorTopicYN="N" UI="D008722">Methods</DescriptorName> | ||
</MeshHeading> | ||
<MeshHeading> | ||
<DescriptorName MajorTopicYN="N" UI="D011549">Pseudomonas</DescriptorName> | ||
<QualifierName MajorTopicYN="N" UI="Q000201">enzymology</QualifierName> | ||
</MeshHeading> | ||
</MeshHeadingList> | ||
</MedlineCitation> | ||
<PubmedData> | ||
<History> | ||
<PubMedPubDate PubStatus="pubmed"> | ||
<Year>1975</Year> | ||
<Month>6</Month> | ||
<Day>1</Day> | ||
</PubMedPubDate> | ||
<PubMedPubDate PubStatus="medline"> | ||
<Year>1975</Year> | ||
<Month>6</Month> | ||
<Day>1</Day> | ||
<Hour>0</Hour> | ||
<Minute>1</Minute> | ||
</PubMedPubDate> | ||
<PubMedPubDate PubStatus="entrez"> | ||
<Year>1975</Year> | ||
<Month>6</Month> | ||
<Day>1</Day> | ||
<Hour>0</Hour> | ||
<Minute>0</Minute> | ||
</PubMedPubDate> | ||
</History> | ||
<PublicationStatus>ppublish</PublicationStatus> | ||
<ArticleIdList> | ||
<ArticleId IdType="pubmed">1</ArticleId> | ||
</ArticleIdList> | ||
</PubmedData> | ||
</PubmedArticle> | ||
</PubmedArticleSet> |