示例#1
0
 /**
  * Unmarshal an XML file to an object.
  *
  * @param is the InputStream to read from
  * @return a collection of business objects
  * @throws InterMineException if an error occurs during unmarshalling
  */
 public List<FastPathObject> unmarshal(InputStream is) throws InterMineException {
   try {
     return FullParser.realiseObjects(FullParser.parse(is), model, false);
   } catch (Exception e) {
     throw new InterMineException("Error during unmarshalling", e);
   }
 }
  public void testEntrezPublicationRetriever() throws Exception {
    EntrezPublicationsRetriever eor = new TestEntrezPublicationsRetriever();

    // Create temp file.
    File temp = File.createTempFile("EntrezPublicationsRetriever", ".tmp");
    // Delete temp file when program exits.
    temp.deleteOnExit();

    eor.setLoadFullRecord(fullRecord); // use eFetch URL instead of summary

    eor.setOsAlias("os.bio-test");
    eor.setOutputFile(temp.getPath());
    // eor.setOutputFile("entrez-pub-tgt-items.xml");
    eor.setCacheDirName("build/");
    eor.execute();
    Collection<Item> actual = FullParser.parse(new FileInputStream(temp));

    Set<Item> expected;
    if ("true".equals(fullRecord)) {
      expected = readItemSet("EntrezPublicationsFullRecord_tgt.xml");
    } else {
      expected = readItemSet("EntrezPublicationsSummary_tgt.xml");
    }

    assertEquals(expected, new HashSet<Item>(actual));
  }
    @SuppressWarnings({"unchecked", "rawtypes"})
    protected List getPublications(ObjectStore os) {
      try {
        List<Item> items =
            FullParser.parse(
                getClass()
                    .getClassLoader()
                    .getResourceAsStream("EntrezPublicationsRetrieverTest_src.xml"));

        return FullParser.realiseObjects(items, Model.getInstanceByName("genomic"), false);
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
示例#4
0
 public Set<Item> readItemSet(String fileName) throws Exception {
   return new LinkedHashSet<Item>(
       FullParser.parse(getClass().getClassLoader().getResourceAsStream(fileName)));
 }