/*
 *    GeoTools - OpenSource mapping toolkit
 *    http://geotools.org
 *    (C) 2004-2006, Geotools Project Managment Committee (PMC)
 *
 *    This library is free software; you can redistribute it and/or
 *    modify it under the terms of the GNU Lesser General Public
 *    License as published by the Free Software Foundation; either
 *    version 2.1 of the License, or (at your option) any later version.
 *
 *    This library is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *    Lesser General Public License for more details.
 */
package org.geotools.xml;

import java.io.File;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.logging.Level;

import junit.framework.TestCase;

import org.geotools.TestData;
import org.geotools.xml.schema.Schema;


/**
 * <p>
 * DOCUMENT ME!
 * </p>
 * @
 *
 * @author dzwiers www.refractions.net
 * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/library/xml/src/test/java/org/geotools/xml/SchemaParser2Test.java $
 */
public class SchemaParser2Test extends TestCase {
    //	public void testMail(){
    //		runit("","test/mails.xsd");
    //	}
    public void testWFS() throws URISyntaxException {
        runit(new URI("http://www.opengis.net/wfs"), "xml/wfs/WFS-basic.xsd");
    }

    public void testGMLFeature() throws URISyntaxException {
        runit(new URI("http://www.opengis.net/gml"), "xml/gml/feature.xsd");
    }

    public void testGMLGeometry() throws URISyntaxException {
        runit(new URI("http://www.opengis.net/gml"), "xml/gml/geometry.xsd");
    }

    public void testGMLXLinks() throws URISyntaxException {
        runit(new URI("http://www.w3.org/1999/xlink"), "xml/gml/xlinks.xsd");
    }

    private void runit(URI targetNS, String path) {
        Schema s = null;

        try {
            File f = TestData.copy(this,path);
            s = SchemaFactory.getInstance(targetNS, f.toURI(),
                    Level.INFO);
        } catch (Exception e) {
            e.printStackTrace();
            fail(e.toString());
        }

        assertNotNull("Schema missing", s);
        System.out.println(s);

        Schema s2 = null;
        s2 = SchemaFactory.getInstance(targetNS);
        assertTrue("Should be the same", s == s2);
    }
}
