01: package org.geotools.data.complex.config;
02:
03: import java.net.URL;
04:
05: import junit.framework.TestCase;
06:
07: import org.apache.xml.resolver.Catalog;
08: import org.apache.xml.resolver.tools.ResolvingXMLReader;
09: import org.geotools.test.TestData;
10:
11: public class OasisCatalogTest extends TestCase {
12: org.apache.xml.resolver.Catalog catalog;
13:
14: protected void setUp() throws Exception {
15: super .setUp();
16: catalog = new Catalog();
17: catalog.setupReaders();
18: }
19:
20: protected void tearDown() throws Exception {
21: super .tearDown();
22: }
23:
24: public void testParseCatalog() throws Exception {
25: URL file = TestData.url(this , "commonSchemas_new.oasis.xml");
26:
27: ResolvingXMLReader reader = new ResolvingXMLReader();
28: Catalog catalog = reader.getCatalog();
29: catalog.getCatalogManager().setVerbosity(9);
30:
31: catalog.parseCatalog(file);
32:
33: final URL baseUri = new URL("http://schemas.opengis.net/gml/");
34: //the system override defined in the catalog
35: final URL override = new URL("file:///schemas/gml/trunk/gml/");
36:
37: final String extraPath = "3.1.1/basicTypes.xsd";
38: final String uri = new URL(baseUri, extraPath).toExternalForm();
39: final String expected = new URL(override, extraPath)
40: .toExternalForm();
41:
42: String resolved = catalog.resolveSystem(uri);
43: assertNotNull(resolved);
44:
45: final String actual = new URL(resolved).toExternalForm();
46: assertEquals(expected, actual);
47: }
48: }
|