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.X4OLanguageConfiguration;
027import org.x4o.xml.core.config.X4OLanguagePropertyKeys;
028import org.x4o.xml.element.Element;
029import org.x4o.xml.element.ElementClass;
030import org.x4o.xml.element.ElementClassAttribute;
031import org.x4o.xml.test.TestParser;
032
033import junit.framework.TestCase;
034
035/**
036 * Tests some resulting options from the language config.
037 * 
038 * @author Willem Cazander
039 * @version 1.0 Jan 20, 2012
040 */
041public class X4OParserConfigurationTest extends TestCase {
042        
043        TestParser parser;
044        X4OLanguageConfiguration config;
045        
046        public void setUp() throws Exception {
047                parser = new TestParser();
048                parser.setProperty(X4OLanguagePropertyKeys.PHASE_SKIP_RELEASE, true);
049                try {
050                        parser.parseResource("tests/namespace/uri-simple.xml");
051                        config = parser.getElementLanguage().getLanguageConfiguration();
052                } finally {
053                        parser.doReleasePhaseManual();
054                }
055        }
056        
057        public void testParserConfigurationLanguage() {
058                assertEquals("test",config.getLanguage());
059                assertEquals(X4OLanguageConfiguration.DEFAULT_LANG_MODULES_FILE,config.getLanguageResourceModulesFileName());
060                assertEquals(X4OLanguageConfiguration.DEFAULT_LANG_PATH_PREFIX,config.getLanguageResourcePathPrefix());
061        }
062        
063        public void testParserConfigurationElement() {
064                assertNotNull(config.getDefaultElement());
065                assertTrue("No Element Inteface", Element.class.isAssignableFrom(config.getDefaultElement()));
066                
067                assertNotNull(config.getDefaultElementClass());
068                assertTrue("No ElementClass Inteface", ElementClass.class.isAssignableFrom(config.getDefaultElementClass()));
069                
070                assertNotNull(config.getDefaultElementClassAttribute());
071                assertTrue("No ElementClass Inteface", ElementClassAttribute.class.isAssignableFrom(config.getDefaultElementClassAttribute()));
072        }
073}