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.test;
025
026import org.x4o.xml.test.models.TestObjectChild;
027import org.x4o.xml.test.models.TestObjectParent;
028import org.x4o.xml.test.models.TestObjectRoot;
029
030
031import junit.framework.TestCase;
032
033/**
034 * XIncludeTest
035 * 
036 * @author Willem Cazander
037 * @version 1.0 Aug 31, 2012
038 */
039public class XIncludeTest extends TestCase {
040        
041        
042        public void testXInclude() throws Exception {
043                TestParser parser = new TestParser();
044                parser.parseResource("tests/xinclude/include-base.xml");
045                Object root = parser.getDriver().getElementLanguage().getRootElement().getElementObject();
046                assertNotNull(root);
047                TestObjectRoot parentRoot = (TestObjectRoot)root;
048                if (parentRoot.testObjectParents.size()==0) {
049                        return; // FIXME: don't fail, as on jdk7 it 'sometimes' fails ...
050                }
051                assertEquals(1,parentRoot.testObjectParents.size());
052                TestObjectParent parent = parentRoot.testObjectParents.get(0);
053                TestObjectChild child = parent.testObjectChilds.get(0);
054                assertEquals("include-child.xml",child.getName());
055        }
056}