Package org.apache.commons.betwixt

Examples of org.apache.commons.betwixt.XMLIntrospector$DynaClassBeanType


        AddressBean bean = new AddressBean();
        bean.setStreet("DEFAULT");
        bean.setCode("DEFAULT");
        bean.setCountry("DEFAULT");
       
        XMLIntrospector introspector = new XMLIntrospector();
        ReadContext context = new ReadContext(new BindingConfiguration(), new ReadConfiguration());
        context.pushBean(bean);
        context.markClassMap(AddressBean.class);
        context.pushElement("street");
        context.setXMLIntrospector(introspector);
View Full Code Here


*/
public class TestInterfaceIntrospection extends TestCase {

    public void testSuperInterfaceIntrospection() throws Exception {
       
        XMLIntrospector introspector = new XMLIntrospector();
       
        XMLBeanInfo beanInfo = introspector.introspect(ICopyableDateRange.class);
        ElementDescriptor[] childDescriptors = beanInfo.getElementDescriptor().getElementDescriptors();
       
        assertEquals("Date range child elements", 2, childDescriptors.length);
        int code = 0;
        for (int i=0; i<2; i++)
View Full Code Here

    }
   

    public void testSuperInterfaceIntrospectionWithDotBetwixt() throws Exception {
       
        XMLIntrospector introspector = new XMLIntrospector();
       
        XMLBeanInfo beanInfo = introspector.introspect(ILaughingCount.class);
        ElementDescriptor[] childDescriptors = beanInfo.getElementDescriptor().getElementDescriptors();
       
        assertEquals("Laughing count child elements", 1, childDescriptors.length);
        assertEquals("Laughing count super interface matched", "count", childDescriptors[0].getPropertyName());   
        assertEquals("Laughing count super interface matched", Integer.TYPE, childDescriptors[0].getPropertyType())
View Full Code Here

  private List simpleTypes = new ArrayList();
   
    private XMLIntrospector introspector;
 
    public Schema() {
        this(new XMLIntrospector());
    }
View Full Code Here

        super(testName);
    }

    public void testNoNameIntrospection() throws Exception {
       
        XMLIntrospector xmlIntrospector = new XMLIntrospector();
        xmlIntrospector.getConfiguration().setWrapCollectionsInElement(false);
        XMLBeanInfo xmlBeanInfo = xmlIntrospector.introspect(MixedCollectionBean.class);
        ElementDescriptor elementDescriptor = xmlBeanInfo.getElementDescriptor();
        ElementDescriptor[] childDescriptors = elementDescriptor.getElementDescriptors();
        assertEquals("One child", 1, childDescriptors.length);  
        assertNull("Expected null name", childDescriptors[0].getLocalName());  
    }
View Full Code Here

    }

//---------------------------------- Tests
   
    public void testForceAccessibleSuper() throws Exception {
        XMLIntrospector xmlIntrospector = new XMLIntrospector();
        XMLBeanInfo xmlBeanInfo = xmlIntrospector.introspect(MixedUpdatersBean.class);
        ElementDescriptor[] descriptors = xmlBeanInfo.getElementDescriptor().getElementDescriptors();
        boolean propertyFound = false;
        for (int i=0; i<descriptors.length ; i++) {
            ElementDescriptor descriptor = descriptors[i];
            if ("private-super".equals(descriptor.getLocalName())) {
View Full Code Here

        "                </element>" +
        "            </class>" +
        "     </betwixt-config>";

    public void testRegisterMultiMapping() throws Exception {
        XMLIntrospector xmlIntrospector = new XMLIntrospector();
        Class[] mapped = xmlIntrospector.register(new InputSource(new StringReader(MAPPING)));
       
        assertEquals("Mapped classes", 3, mapped.length);
       
        XMLBeanInfo beanInfo = xmlIntrospector.introspect(AddressBean.class);
        assertNotNull("Bean info mapping", beanInfo);
        ElementDescriptor descriptor = beanInfo.getElementDescriptor();
        assertEquals("Root element name", "not-address", descriptor.getLocalName());
        ElementDescriptor[] childDescriptors = descriptor.getElementDescriptors();
        assertEquals("4 child elements", 4, childDescriptors.length);
        assertEquals("First element", "not-street", childDescriptors[0].getLocalName());
        assertEquals("Second element", "not-city", childDescriptors[1].getLocalName());
        assertEquals("Third element", "not-code", childDescriptors[2].getLocalName());
        assertEquals("Forth element", "not-country", childDescriptors[3].getLocalName());
             
        beanInfo = xmlIntrospector.introspect(SimpleTestBean.class);
        assertNotNull("Bean info mapping", beanInfo);
        descriptor = beanInfo.getElementDescriptor();
        assertEquals("Root element name", "jelly", descriptor.getLocalName());
        childDescriptors = descriptor.getElementDescriptors();
        assertEquals("Child elements", 2, childDescriptors.length);
View Full Code Here

        result.getBindingConfiguration().setMapIDs(false);
        return result;
    }

    private XMLIntrospector newXMLIntrospector(NameMapper mapper) {
        XMLIntrospector introspector = new XMLIntrospector();
        introspector.getConfiguration().setAttributesForPrimitives(true);
        introspector.getConfiguration().setWrapCollectionsInElement(false);
        introspector.getConfiguration().setElementNameMapper(mapper);
        return introspector;
    }
View Full Code Here

        // simple test this one
        // a problem was reported when introspecting classes with 'add' properties
        // when using the HyphenatedNameMapper
        // basically, the test is that no exception is thrown
        //
        XMLIntrospector introspector = new XMLIntrospector();
        introspector.getConfiguration().setElementNameMapper(new HyphenatedNameMapper());
        introspector.introspect(new ArrayList());
    }
View Full Code Here

     * / Turbine projects. Maybe a static helper method - question is what to
     * call it???
     */
    protected XMLIntrospector createXMLIntrospector()
    {
        XMLIntrospector introspector = new XMLIntrospector();

        // set elements for attributes to true
        introspector.getConfiguration().setAttributesForPrimitives(false);

        // wrap collections in an XML element
        introspector.getConfiguration().setWrapCollectionsInElement(false);

        // turn bean elements first letter into lower case
        introspector.getConfiguration().setElementNameMapper( new DecapitalizeNameMapper() );

        // Set default plural stemmer.
        introspector.getConfiguration().setPluralStemmer( new DefaultPluralStemmer() );

        return introspector;
    }
View Full Code Here

TOP

Related Classes of org.apache.commons.betwixt.XMLIntrospector$DynaClassBeanType

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.