/*
 *    GeoTools - OpenSource mapping toolkit
 *    http://geotools.org
 *    (C) 2002-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;
 *    version 2.1 of the License.
 *
 *    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.xs.bindings;

import javax.xml.bind.ValidationException;
import javax.xml.namespace.QName;

import org.geotools.xs.TestSchema;


public class XSBooleanStrategyTest extends TestSchema {
    /**
     * An instance of a datatype that is defined as ??boolean?? can have the
     * following legal literals {true, false, 1, 0}.
     * @throws Exception
     *
     */

    /*
     * Test method for 'org.geotools.xs.strategies.XSBooleanStrategy.parse(Element, Node[], Object)'
     */
    public void testTruth() throws Exception {
        validateValues("true", Boolean.TRUE);
        validateValues("false", Boolean.FALSE);
        validateValues("1", Boolean.TRUE);
        validateValues("0", Boolean.FALSE);
    }

    public void testUntruth() throws Exception {
        try {
            validateValues("TRUE", Boolean.FALSE);
            fail("TRUTH is not absolute");
        } catch (ValidationException expected) {
            // yeah!
        }
    }

    protected QName getQName() {
        return XS.BOOLEAN;
    }
}
