@Test(expected = RuntimeException.class)
 public void test_validate_datasource_impossible_to_reinit() {
   XmlModelledBinaryStreamSource dataSource =
       new XmlModelledBinaryStreamSource(
           XmlModelledBinaryStreamSourceTest.class.getResourceAsStream("/samples/21703451.xml"));
   Assert.assertTrue(dataSource.validateSyntax());
   Iterator<ModelledBinaryInteraction> iterator = dataSource.getInteractionsIterator();
 }
  @Test(expected = RuntimeException.class)
  public void test_validate_datasource_impossible_to_reinit_2() {

    XmlModelledBinaryStreamSource dataSource = new XmlModelledBinaryStreamSource();
    Map<String, Object> options = new HashMap<String, Object>();
    options.put(
        MIFileDataSourceOptions.INPUT_OPTION_KEY,
        XmlModelledBinaryStreamSourceTest.class.getResourceAsStream("/samples/21703451.xml"));
    dataSource.initialiseContext(options);
    Assert.assertTrue(dataSource.validateSyntax());
    Iterator<ModelledBinaryInteraction> iterator = dataSource.getInteractionsIterator();
  }
  @Test
  public void parse_valid_file() throws IOException {
    XmlModelledBinaryStreamSource dataSource =
        new XmlModelledBinaryStreamSource(
            new File(
                XmlModelledBinaryStreamSourceTest.class
                    .getResource("/samples/10049915.xml")
                    .getFile()));
    Iterator<ModelledBinaryInteraction> iterator = dataSource.getInteractionsIterator();
    Interaction i1 = iterator.next();
    Assert.assertNotNull(i1);
    Assert.assertFalse(iterator.hasNext());
    Assert.assertTrue(dataSource.validateSyntax());
    dataSource.close();

    dataSource = new XmlModelledBinaryStreamSource();
    Map<String, Object> options = new HashMap<String, Object>();
    options.put(
        MIFileDataSourceOptions.INPUT_OPTION_KEY,
        new File(
            XmlModelledBinaryStreamSourceTest.class
                .getResource("/samples/10049915.xml")
                .getFile()));
    dataSource.initialiseContext(options);
    iterator = dataSource.getInteractionsIterator();
    i1 = iterator.next();
    Assert.assertNotNull(i1);
    Assert.assertFalse(iterator.hasNext());
    Assert.assertTrue(dataSource.validateSyntax());
    dataSource.close();
  }
  @Test
  public void iterate_invalid_file() {
    XmlModelledBinaryStreamSource dataSource =
        new XmlModelledBinaryStreamSource(
            new File(
                XmlModelledBinaryStreamSourceTest.class
                    .getResource("/samples/empty.xml")
                    .getFile()));
    Iterator<ModelledBinaryInteraction> iterator = dataSource.getInteractionsIterator();
    Assert.assertFalse(iterator.hasNext());
    Assert.assertFalse(dataSource.validateSyntax());
    dataSource.close();

    dataSource = new XmlModelledBinaryStreamSource();
    Map<String, Object> options = new HashMap<String, Object>();
    options.put(
        MIFileDataSourceOptions.INPUT_OPTION_KEY,
        new File(
            XmlModelledBinaryStreamSourceTest.class.getResource("/samples/empty.xml").getFile()));
    dataSource.initialiseContext(options);
    iterator = dataSource.getInteractionsIterator();
    Assert.assertFalse(iterator.hasNext());
    Assert.assertFalse(dataSource.validateSyntax());
    dataSource.close();
  }
  @Test
  public void validate_invalid_file() {
    XmlModelledBinaryStreamSource dataSource =
        new XmlModelledBinaryStreamSource(
            XmlModelledBinaryStreamSourceTest.class.getResourceAsStream("/samples/empty.xml"));
    Assert.assertFalse(dataSource.validateSyntax());

    dataSource = new XmlModelledBinaryStreamSource();
    Map<String, Object> options = new HashMap<String, Object>();
    options.put(
        MIFileDataSourceOptions.INPUT_OPTION_KEY,
        XmlModelledBinaryStreamSourceTest.class.getResourceAsStream("/samples/empty.xml"));
    dataSource.initialiseContext(options);
    Assert.assertFalse(dataSource.validateSyntax());
    dataSource.close();
  }
 @Test
 public void test_validate_datasource_reinit() throws IOException {
   XmlModelledBinaryStreamSource dataSource =
       new XmlModelledBinaryStreamSource(
           new File(
               XmlModelledBinaryStreamSourceTest.class
                   .getResource("/samples/10049915.xml")
                   .getFile()));
   Assert.assertTrue(dataSource.validateSyntax());
   Iterator<ModelledBinaryInteraction> iterator = dataSource.getInteractionsIterator();
   Interaction i1 = iterator.next();
   Assert.assertNotNull(i1);
   Assert.assertFalse(iterator.hasNext());
   Assert.assertTrue(dataSource.validateSyntax());
   Assert.assertTrue(dataSource.validateSyntax());
   dataSource.close();
 }
 @Test(expected = IllegalStateException.class)
 public void test_iterate_fails_not_initialised() {
   XmlModelledBinaryStreamSource dataSource = new XmlModelledBinaryStreamSource();
   dataSource.getInteractionsIterator();
 }
 @Test(expected = IllegalStateException.class)
 public void test_validate_fails_not_initialised() {
   XmlModelledBinaryStreamSource dataSource = new XmlModelledBinaryStreamSource();
   dataSource.validateSyntax();
 }