Skip to content

Commit

Permalink
Fixed the failing IRIMapperTest and moved all the test resources from
Browse files Browse the repository at this point in the history
the ./test directory to the ./src/test/resources directory.  The
IRIMapperTest was failing because the parameters (represented as
static variables) of the IRIMapperTest needed to match the data in the
redirect-to-pizza.xml file.
  • Loading branch information
stdotjohn committed Mar 4, 2014
1 parent 594627f commit d8886d5
Show file tree
Hide file tree
Showing 21 changed files with 20 additions and 19 deletions.
6 changes: 3 additions & 3 deletions src/test/java/org/protege/xmlcatalog/CatalogTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class CatalogTest extends TestCase {

public void testExample1() {
try {
CatalogUtilities.parseDocument(new File("test/Example1.xml").toURI().toURL());
CatalogUtilities.parseDocument(new File("src/test/resources/Example1.xml").toURI().toURL());
}
catch (Throwable t) {
log.warn("Test failed", t);
Expand All @@ -21,7 +21,7 @@ public void testExample1() {

public void testExample2() {
try {
CatalogUtilities.parseDocument(new File("test/Example2.xml").toURI().toURL());
CatalogUtilities.parseDocument(new File("src/test/resources/Example2.xml").toURI().toURL());
}
catch (Throwable t) {
log.warn("Test failed", t);
Expand All @@ -31,7 +31,7 @@ public void testExample2() {

public void testCatalog8() {
try {
CatalogUtilities.parseDocument(new File("test/catalog08.xml").toURI().toURL());
CatalogUtilities.parseDocument(new File("src/test/resources/catalog08.xml").toURI().toURL());
}
catch (Throwable t) {
log.warn("Test failed", t);
Expand Down
24 changes: 12 additions & 12 deletions src/test/java/org/protege/xmlcatalog/ResolveTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class ResolveTest extends TestCase {
private XMLCatalog catalog;

public void test01() throws TransformerException, MalformedURLException, IOException {
readCatalog("test/catalog01.xml");
readCatalog("src/test/resources/catalog01.xml");

URI u = URI.create("http://www.tigraworld.com/protege/ontology1.owl");
URI redirect = URI.create("file:/home/tredmond/Shared/ontologies/simple/ontology1.owl");
Expand All @@ -26,7 +26,7 @@ public void test01() throws TransformerException, MalformedURLException, IOExcep
}

public void test02() throws MalformedURLException, IOException, TransformerException {
readCatalog("test/catalog02.xml");
readCatalog("src/test/resources/catalog02.xml");

URI u = URI.create("http://www.tigraworld.com/protege/ontology1.owl");
URI redirect = URI.create("file:/home/tredmond/Shared/simple/ontology1.owl");
Expand All @@ -35,19 +35,19 @@ public void test02() throws MalformedURLException, IOException, TransformerExcep
}

public void test03() throws MalformedURLException, IOException, TransformerException {
readCatalog("test/catalog03.xml");
readCatalog("src/test/resources/catalog03.xml");

URI u = URI.create("http://www.tigraworld.com/protege/ontology1.owl");
URI redirect = new File("test/simple/ontology1.owl").toURI();
URI redirect = new File("src/test/resources/simple/ontology1.owl").toURI();
// needs trim because of a seemingly silly problem involving the URI for the outer xml base.
checkBothAlgorithmsSame(u, true);
assertTrue(CatalogUtilities.getRedirect(u, catalog).equals(redirect));
}

public void test04() throws MalformedURLException, IOException, TransformerException {
readCatalog("test/catalog04.xml");
readCatalog("src/test/resources/catalog04.xml");
URI u = URI.create("http://www.tigraworld.com/protege/ontology1.owl");
URI redirect = new File("test/dir1/dir2/simple/ontology1.owl").toURI();
URI redirect = new File("src/test/resources/dir1/dir2/simple/ontology1.owl").toURI();
// The apache resolver behaves differently in Java 1.5 and Java 1.6
// I have aligned this library with the 1.6 behavior
if (!JunitUtilities.isJava5()) {
Expand All @@ -57,9 +57,9 @@ public void test04() throws MalformedURLException, IOException, TransformerExcep
}

public void test05() throws MalformedURLException, IOException, TransformerException {
readCatalog("test/catalog05.xml");
readCatalog("src/test/resources/catalog05.xml");
URI u = URI.create("http://www.tigraworld.com/protege/ontology1.owl");
URI redirect = new File("test/dir1/dir2/simple/ontology1.owl").toURI();
URI redirect = new File("src/test/resources/dir1/dir2/simple/ontology1.owl").toURI();
// The apache resolver behaves differently in Java 1.5 and Java 1.6
// I have aligned this library with the 1.6 behavior
if (!JunitUtilities.isJava5()) {
Expand All @@ -69,25 +69,25 @@ public void test05() throws MalformedURLException, IOException, TransformerExcep
}

public void test06() throws MalformedURLException, IOException, TransformerException {
readCatalog("test/catalog06.xml");
readCatalog("src/test/resources/catalog06.xml");
URI u = URI.create("http://www.tigraworld.com/protege/pizza.owl");
// Predicting redirect is hard because it's system dependent. Windows adds a "C:".
checkBothAlgorithmsSame(u, true);
}

public void test07() throws TransformerException, MalformedURLException, IOException {
readCatalog("test/catalog07.xml");
readCatalog("src/test/resources/catalog07.xml");
doTest07();

}

public void test08() throws TransformerException, MalformedURLException, IOException {
readCatalog("test/catalog08.xml");
readCatalog("src/test/resources/catalog08.xml");
doTest07();
}

public void test09() throws TransformerException, MalformedURLException, IOException {
readCatalog("test/catalog09.xml");
readCatalog("src/test/resources/catalog09.xml");
doTest07();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,20 @@

public class IRIMapperTest extends TestCase {
public final static IRI IMPORT_LOCATION = IRI.create("http://test.org/TestPizzaImport.owl");
public final static IRI REDIRECT_LOCATION = IRI.create("http://www.co-ode.org/ontologies/pizza/pizza.owl");
public final static IRI PIZZA_IRI = IRI.create("http://www.co-ode.org/ontologies/pizza/pizza.owl");
public final static IRI REDIRECT_LOCATION = IRI.create("http://protege.stanford.edu/ontologies/pizza/pizza.owl");

public void testIRIMapper() throws MalformedURLException, IOException, OWLOntologyCreationException {
OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
manager.addIRIMapper(new XMLCatalogIRIMapper(new File("test/owl/redirect-to-pizza.xml")));
OWLOntology ontology = manager.loadOntology(IRI.create(new File("test/owl/TestFunnyPizzaImport.owl")));
manager.addIRIMapper(new XMLCatalogIRIMapper(new File("src/test/resources/owl/redirect-to-pizza.xml")));
OWLOntology ontology = manager.loadOntology(IRI.create(new File("src/test/resources/owl/TestFunnyPizzaImport.owl")));
Set<OWLImportsDeclaration> importDeclarations = ontology.getImportsDeclarations();
assertEquals(1, importDeclarations.size());
assertEquals(IMPORT_LOCATION, importDeclarations.iterator().next().getIRI());
Set<OWLOntology> importedOntologies = ontology.getImports();
assertEquals(1, importedOntologies.size());
OWLOntology pizzaOntology = importedOntologies.iterator().next();
assertEquals(REDIRECT_LOCATION, pizzaOntology.getOntologyID().getOntologyIRI());
assertEquals(PIZZA_IRI, pizzaOntology.getOntologyID().getOntologyIRI());
assertEquals(REDIRECT_LOCATION, manager.getOntologyDocumentIRI(pizzaOntology));
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit d8886d5

Please sign in to comment.