package owltools.io;

import static org.junit.Assert.*;

import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.Map;

import org.junit.Test;
import org.semanticweb.owlapi.model.IRI;

import owltools.OWLToolsTestBasics;
import owltools.io.CatalogXmlIRIMapper;

public class CatalogXmlIRIMapperTest extends OWLToolsTestBasics {

	@Test
	public void testParseCatalogXML() throws Exception {
		File resource = getResource("catalog-v001.xml");
		InputStream inputStream = new FileInputStream(resource);
		File parentFolder = resource.getParentFile();
		Map<IRI, IRI> mappings = CatalogXmlIRIMapper.parseCatalogXml(inputStream, parentFolder);
		assertEquals(4, mappings.size());
	}
	
	@Test
	public void testParseCatalogXML2() throws Exception {
		CatalogXmlIRIMapper m = new CatalogXmlIRIMapper("src/test/resources/test-catalog.xml");
		IRI iri = m.getDocumentIRI(IRI.create("http://purl.obolibrary.org/obo/go.owl"));
		assertNotNull(iri);
	}

}

@@ -217,16 +217,128 @@
 del.IRI;
+%0Aimport org.semanticweb.owlapi.model.OWLOntology;%0Aimport org.semanticweb.owlapi.model.OWLOntologyLoaderListener;
 %0A%0Aimport
@@ -475,16 +475,59 @@
 sics %7B%0A%0A
+%09private static boolean verbose = false;%0A%09%0A
 %09@Test%0A%09
@@ -1129,11 +1129,1253 @@
 ri);%0A%09%7D%0A
+%09%0A%09@Test%0A%09public void testParseCatalogXML3() throws Exception %7B%0A%09%09CatalogXmlIRIMapper m = new CatalogXmlIRIMapper(%22src/test/resources/catalog-v001.xml%22);%0A%09%09ParserWrapper p = new ParserWrapper();%0A%09%09p.addIRIMapper(m);%0A%09%09if (verbose) %7B%0A%09%09%09p.manager.addOntologyLoaderListener(new PrintingOntologLoaderListener());%0A%09%09%7D%0A%09%09OWLOntology owlOntology = p.parse(getResourceIRIString(%22wine.owl%22));%0A%09%09assertNotNull(owlOntology);%0A%09%7D%0A%09%0A%09@Test%0A%09public void testParseCatalogXML4() throws Exception %7B%0A%09%09CatalogXmlIRIMapper m = new CatalogXmlIRIMapper(%22src/test/resources/catalog-v001.xml%22);%0A%09%09ParserWrapper p = new ParserWrapper();%0A%09%09p.addIRIMapper(m);%0A%09%09if (verbose) %7B%0A%09%09%09p.manager.addOntologyLoaderListener(new PrintingOntologLoaderListener());%0A%09%09%7D%0A%09%09OWLOntology owlOntology = p.parse(getResourceIRIString(%22mutual-import-1.owl%22));%0A%09%09assertNotNull(owlOntology);%0A%09%7D%0A%0A%09public static final class PrintingOntologLoaderListener implements%0A%09%09%09OWLOntologyLoaderListener %7B%0A%09%09@Override%0A%09%09public void startedLoadingOntology(LoadingStartedEvent event) %7B%0A%09%09%09System.out.println(%22Loading: %22+event.getDocumentIRI());%0A%09%09%09%0A%09%09%7D%0A%09%0A%09%09@Override%0A%09%09public void finishedLoadingOntology(LoadingFinishedEvent event) %7B%0A%09%09%09System.out.println(%22Finished: %22+event.getDocumentIRI());%0A%09%09%7D%0A%09%7D%0A%09
 %0A%7D%0A

extend test case for IRI mapper