Search in sources :

Example 1 with PubMedXMLParser

use of ubic.gemma.core.loader.entrez.pubmed.PubMedXMLParser in project Gemma by PavlidisLab.

the class BibRefControllerTest method setup.

/*
     * Add a bibliographic reference to the database for testing purposes.
     */
@Before
public void setup() throws Exception {
    assert brs != null;
    PubMedXMLParser pmp = new PubMedXMLParser();
    try {
        Collection<BibliographicReference> brl = pmp.parse(this.getClass().getResourceAsStream("/data/pubmed-test.xml"));
        br = brl.iterator().next();
        /* set the bib ref's pubmed accession number to the database entry. */
        br.setPubAccession(this.getTestPersistentDatabaseEntry());
        /* bibref is now set. Call service to persist to database. */
        br = brs.findOrCreate(br);
        assert br.getId() != null;
    } catch (RuntimeException e) {
        if (e.getCause() instanceof java.net.ConnectException) {
            log.warn("Test skipped due to connection exception");
            return;
        } else if (e.getCause() instanceof java.net.UnknownHostException) {
            log.warn("Test skipped due to unknown host exception");
            return;
        } else {
            throw (e);
        }
    }
    ready = true;
}
Also used : PubMedXMLParser(ubic.gemma.core.loader.entrez.pubmed.PubMedXMLParser) BibliographicReference(ubic.gemma.model.common.description.BibliographicReference) Before(org.junit.Before)

Aggregations

Before (org.junit.Before)1 PubMedXMLParser (ubic.gemma.core.loader.entrez.pubmed.PubMedXMLParser)1 BibliographicReference (ubic.gemma.model.common.description.BibliographicReference)1