Package org.apache.commons.betwixt

Examples of org.apache.commons.betwixt.XMLIntrospector.introspect()


                "        <element name='wibble' property='alpha'/>" +
                "        <element name='wobble' property='beta'/>" +
                "    </element>" +
                "</info>");
        XMLIntrospector introspector = new XMLIntrospector();
        XMLBeanInfo xmlBeanInfo = introspector.introspect(SimpleTestBean.class, new InputSource(reader));
       
        ElementDescriptor elementDescriptor = xmlBeanInfo.getElementDescriptor();
        assertEquals("Root is jelly", "jelly", elementDescriptor.getLocalName());
        ElementDescriptor[] childDescriptors = elementDescriptor.getElementDescriptors();
        assertEquals("Expected two child elements", 2, childDescriptors.length);
View Full Code Here


                "        <element name='no-wibble' property='alpha'/>" +
                "        <element name='no-wobble' property='beta'/>" +
                "    </element>" +
                "</info>");

        xmlBeanInfo = introspector.introspect(SimpleTestBean.class, new InputSource(reader));
       
        elementDescriptor = xmlBeanInfo.getElementDescriptor();
        assertEquals("Root is not-jelly", "not-jelly", elementDescriptor.getLocalName());
        childDescriptors = elementDescriptor.getElementDescriptors();
        assertEquals("Expected two child elements", 2, childDescriptors.length);
View Full Code Here

                "        <element name='wobble' property='beta'/>" +
                "    </element>" +
                "</info>");
        XMLIntrospector introspector = new XMLIntrospector();
        introspector.register(SimpleTestBean.class, new InputSource(reader));
        XMLBeanInfo xmlBeanInfo = introspector.introspect(SimpleTestBean.class);
       
        ElementDescriptor elementDescriptor = xmlBeanInfo.getElementDescriptor();
        assertEquals("Root is jelly", "jelly", elementDescriptor.getLocalName());
        ElementDescriptor[] childDescriptors = elementDescriptor.getElementDescriptors();
        assertEquals("Expected two child elements", 2, childDescriptors.length);
View Full Code Here

        //SimpleLog log = new SimpleLog("[testClassAttribute:ElementRule]");
        //log.setLevel(SimpleLog.LOG_LEVEL_TRACE);
        //ElementRule.setLog(log);
       
        XMLIntrospector introspector = new XMLIntrospector();
        XMLBeanInfo beanInfo = introspector.introspect(ExampleBean.class);
        ElementDescriptor[] elementDescriptors = beanInfo.getElementDescriptor().getElementDescriptors();
        ElementDescriptor elementsElementDescriptor = null;
        for ( int i=0, size = elementDescriptors.length; i<size ; i++ ) {
            if ( "example".equals( elementDescriptors[i].getLocalName() ) ) {
                elementsElementDescriptor = elementDescriptors[i];
View Full Code Here

    public void testNewStrategy() throws Exception {
        XMLIntrospector introspector = new XMLIntrospector();
        introspector.getConfiguration().setSimpleTypeMapper(new StringsAsElementsSimpleTypeMapper());
        introspector.getConfiguration().setWrapCollectionsInElement(true);
       
        XMLBeanInfo beanInfo = introspector.introspect(TuneBean.class);
        ElementDescriptor tuneBeanDescriptor = beanInfo.getElementDescriptor();
       
        AttributeDescriptor[] tuneBeanAttributes = tuneBeanDescriptor.getAttributeDescriptors();
        assertEquals("Only expect one attribute", 1, tuneBeanAttributes.length);
        AttributeDescriptor recordedAttribute = tuneBeanAttributes[0];
View Full Code Here

            result.getSpouse());
    }

    public void testIgnoredProperty() throws Exception {
        XMLIntrospector introspector = new XMLIntrospector();
        XMLBeanInfo beanInfo = introspector.introspect(IgnoreBean.class);
        ElementDescriptor ignoreDescriptor = beanInfo.getElementDescriptor();
       
        assertEquals("element name matches", "ignore", ignoreDescriptor.getLocalName());
        ElementDescriptor[] childDescriptors = ignoreDescriptor.getElementDescriptors();
        assertEquals("number of child elements", 1, childDescriptors.length);
View Full Code Here

     * @throws Exception
     */
    public void testIgnoredAdders() throws Exception {
        XMLIntrospector introspector = new XMLIntrospector();
        // ignore adders bean uses a dot betwixt file with add-adders false
        XMLBeanInfo beanInfo = introspector.introspect(IgnoreAddersBean.class);
        ElementDescriptor ignoreDescriptor = beanInfo.getElementDescriptor();
       
        assertEquals("element name matches", "ignore", ignoreDescriptor.getLocalName());
        ElementDescriptor[] childDescriptors = ignoreDescriptor.getElementDescriptors();
        assertEquals("number of child elements", 2, childDescriptors.length);
View Full Code Here

    }
   
    //TODO: complete these tests after refactoring the element descriptors produced is complete
    public void _testAddDefaults() throws Exception {
        XMLIntrospector introspector = new XMLIntrospector();
        XMLBeanInfo beanInfo = introspector.introspect(LibraryBean.class);
        ElementDescriptor libraryDescriptor = beanInfo.getElementDescriptor();
       
        AttributeDescriptor[] libraryAttributeDescriptors = libraryDescriptor.getAttributeDescriptors();
        assertEquals("Only one attribute", 1, libraryAttributeDescriptors.length);
       
View Full Code Here

   
    /** Tests whether a standard property's ElementDescriptor is hollow (as expected) */
    public void testStandardPropertyIsHollow() throws Exception {
        XMLIntrospector introspector = new XMLIntrospector();
        introspector.getConfiguration().setAttributesForPrimitives(true);
        XMLBeanInfo out = introspector.introspect(CompanyBean.class);
       
        ElementDescriptor companyBeanDescriptor = out.getElementDescriptor();
        ElementDescriptor[] childDescriptors = companyBeanDescriptor.getElementDescriptors();
        assertEquals("Correct number of child descriptors", 1, childDescriptors.length);
       
View Full Code Here

    /** Tests whether a simple element's ElementDescriptor is hollow */
    public void testSimpleElementIsHollow() throws Exception {
        XMLIntrospector introspector = new XMLIntrospector();
        introspector.getConfiguration().setAttributesForPrimitives(false);
        XMLBeanInfo out = introspector.introspect(CompanyBean.class);
       
        ElementDescriptor companyBeanDescriptor = out.getElementDescriptor();
        ElementDescriptor[] childDescriptors = companyBeanDescriptor.getElementDescriptors();
        assertEquals("Correct number of child descriptors", 2, childDescriptors.length);
       
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.