001/*
002 * Copyright (c) 2004-2012, Willem Cazander
003 * All rights reserved.
004 *
005 * Redistribution and use in source and binary forms, with or without modification, are permitted provided
006 * that the following conditions are met:
007 * 
008 * * Redistributions of source code must retain the above copyright notice, this list of conditions and the
009 *   following disclaimer.
010 * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
011 *   the following disclaimer in the documentation and/or other materials provided with the distribution.
012 * 
013 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
014 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
015 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
016 * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
017 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
018 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
019 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
020 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
021 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
022 */
023
024package org.x4o.xml.core;
025
026import org.x4o.xml.core.config.X4OLanguagePropertyKeys;
027import org.x4o.xml.test.TestParser;
028
029import junit.framework.TestCase;
030
031/**
032 * Tests emptry uri namespace laoding.
033 * 
034 * @author Willem Cazander
035 * @version 1.0 May 1, 2011
036 */
037public class NamespaceUriTest extends TestCase {
038        
039        public void testSimpleUri() throws Exception {
040                TestParser parser = new TestParser();
041                parser.setProperty(X4OLanguagePropertyKeys.PHASE_SKIP_RELEASE, true);
042                try {
043                        parser.parseResource("tests/namespace/uri-simple.xml");
044                        assertEquals(true,parser.getElementLanguage().getRootElement().getChilderen().size()==1);
045                } finally {
046                        parser.doReleasePhaseManual();
047                }
048        }
049        
050        public void testEmptyUri() throws Exception {
051                TestParser parser = new TestParser();
052                parser.setProperty(X4OLanguagePropertyKeys.PHASE_SKIP_RELEASE, true);
053                parser.setProperty(X4OLanguagePropertyKeys.INPUT_EMPTY_NAMESPACE_URI, "http://test.x4o.org/xml/ns/test-lang");
054                try {
055                        parser.parseResource("tests/namespace/uri-empty.xml");
056                        assertEquals(true,parser.getElementLanguage().getRootElement().getChilderen().size()==1);
057                } finally {
058                        parser.doReleasePhaseManual();
059                }
060        }
061        
062        public void testSchemaUri() throws Exception {
063                TestParser parser = new TestParser();
064                parser.setProperty(X4OLanguagePropertyKeys.PHASE_SKIP_RELEASE, true);
065                try {
066                        parser.parseResource("tests/namespace/uri-schema.xml");
067                        assertEquals(true,parser.getElementLanguage().getRootElement().getChilderen().size()==1);
068                } finally {
069                        parser.doReleasePhaseManual();
070                }
071        }
072}