Package org.teiid.query.mapping.xml

Examples of org.teiid.query.mapping.xml.MappingElement


       
        MappingDocument doc = loadMappingDocument(xml);
       
        assertEquals("license", doc.getRootNode().getName()); //$NON-NLS-1$
       
        MappingElement license = (MappingElement)doc.getRootNode();
        MappingAttribute usenamespace = (MappingAttribute)license.getAttributes().get(0);
       
        assertEquals("usenamespace", usenamespace.getName()); //$NON-NLS-1$
       
        // by the time the document is loaded the namspace must have been resolved.
        Namespace ns = usenamespace.getNamespace();           
View Full Code Here


       
        MappingNode node = doc.getRootNode();
       
        // parent element
        assertTrue(node instanceof MappingElement);       
        MappingElement element = (MappingElement)node;
        assertEquals("parentNode", element.getName()); //$NON-NLS-1$
        assertTrue(element.isRootRecursiveNode());
        assertFalse(element.isRecursive());
        assertEquals("parentSource", element.getSource()); //$NON-NLS-1$
       
        // recursive source
        node = (MappingNode)element.getNodeChildren().get(0);
        assertTrue(node instanceof MappingRecursiveElement);       
        MappingRecursiveElement relement = (MappingRecursiveElement)node;
       
        assertTrue(relement.isRecursive());
        assertEquals("childNode", relement.getName()); //$NON-NLS-1$
View Full Code Here

        assertEquals(MappingNodeConstants.Defaults.DEFAULT_DOCUMENT_ENCODING, doc.getDocumentEncoding());
    }
   
    public void testDoc2() {
        MappingDocument doc = new MappingDocument("UTF-16", false); //$NON-NLS-1$
        MappingElement root = new MappingElement("test"); //$NON-NLS-1$
        doc.addChildElement(root);
        assertNotNull(doc.getRootNode());
       
        assertFalse(doc.isFormatted());
        assertEquals("UTF-16", doc.getDocumentEncoding()); //$NON-NLS-1$
View Full Code Here

        assertEquals("UTF-16", doc.getDocumentEncoding()); //$NON-NLS-1$
    }

    public void testDoc3() {
        MappingDocument doc = new MappingDocument("UTF-16", false); //$NON-NLS-1$
        MappingElement root = new MappingElement("test"); //$NON-NLS-1$
        root.setMinOccurrs(2);
        root.setMaxOccurrs(-1);
       
        doc.addChildElement(root);
       
        assertNotNull(doc.getRootNode());
       
        assertFalse(doc.isFormatted());
        assertEquals("UTF-16", doc.getDocumentEncoding()); //$NON-NLS-1$
       
        // the root can not re-occur more than once..
        root = (MappingElement)doc.getRootNode();
        assertEquals(1, root.getMinOccurence());
        assertEquals(1, root.getMaxOccurence());
    }
View Full Code Here

   
    public void testTagRoot() {
        MappingDocument doc = new MappingDocument("UTF-16", false); //$NON-NLS-1$
        MappingSourceNode source = new MappingSourceNode("source"); //$NON-NLS-1$
        doc.addSourceNode(source);
        MappingElement tagroot = new MappingElement("test"); //$NON-NLS-1$
        source.addChildElement(tagroot);
       
        assertTrue(doc.getRootNode() == source);
        assertTrue(doc.getTagRootElement() == tagroot);
       
View Full Code Here

* Test the Mapping Element
*/
public class TestMappingElement extends TestCase {
  
    public void testRecusrive() {
        MappingElement element = new MappingElement("Test"); //$NON-NLS-1$
        assertFalse(element.isRecursive());
    }
View Full Code Here

        MappingElement element = new MappingElement("Test"); //$NON-NLS-1$
        assertFalse(element.isRecursive());
    }
   
    public void testNamespace() {
        MappingElement element = new MappingElement("Test"); //$NON-NLS-1$
        assertEquals("Test", element.getName()); //$NON-NLS-1$
        assertNull(element.getNamespacePrefix());
       
        Namespace namespace = new Namespace("foo", "protocol://someuri"); //$NON-NLS-1$ //$NON-NLS-2$
        element = new MappingElement("Test", namespace); //$NON-NLS-1$
        assertEquals("foo", element.getNamespacePrefix()); //$NON-NLS-1$
        assertEquals(element.getNamespaces().length, 0);
       
        element.addNamespace(namespace);
        assertEquals(element.getNamespaces().length, 1);
       
        element.addNamespace(new Namespace("ns1", "http://mm.com")); //$NON-NLS-1$ //$NON-NLS-2$
        assertEquals(element.getNamespaces().length, 2);
       
        // they may be switch some times, need a better way to test this?
        assertEquals("ns1", element.getNamespaces()[0].getPrefix()); //$NON-NLS-1$
        assertEquals("foo", element.getNamespaces()[1].getPrefix()); //$NON-NLS-1$
    }
View Full Code Here

        assertEquals("foo", element.getNamespaces()[1].getPrefix()); //$NON-NLS-1$
    }
   
   
    public void testNameInSource() {
        MappingElement element = new MappingElement("Test"); //$NON-NLS-1$
        assertNull(element.getNameInSource());
       
        element.setNameInSource(null);       
        assertNull(element.getNameInSource());
       
        element.setNameInSource("sourceName"); //$NON-NLS-1$
        assertEquals("sourceName", element.getNameInSource()); //$NON-NLS-1$
       
        element = new MappingElement("Test", "sourceName"); //$NON-NLS-1$ //$NON-NLS-2$
        assertEquals("sourceName", element.getNameInSource()); //$NON-NLS-1$       
    }
View Full Code Here

        element = new MappingElement("Test", "sourceName"); //$NON-NLS-1$ //$NON-NLS-2$
        assertEquals("sourceName", element.getNameInSource()); //$NON-NLS-1$       
    }
   
    public void testNillable() {
        MappingElement element = new MappingElement("Test"); //$NON-NLS-1$
        assertFalse(element.isNillable());

        element.setNillable(true);
        assertTrue(element.isNillable());
    }
View Full Code Here

        element.setNillable(true);
        assertTrue(element.isNillable());
    }
   
    public void testDefaultValue() {
        MappingElement element = new MappingElement("Test"); //$NON-NLS-1$
        assertNull(element.getDefaultValue());

        element.setDefaultValue("foo"); //$NON-NLS-1$
        assertEquals("foo", element.getDefaultValue()); //$NON-NLS-1$
    }
View Full Code Here

TOP

Related Classes of org.teiid.query.mapping.xml.MappingElement

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.