Package org.apache.commons.betwixt

Examples of org.apache.commons.betwixt.XMLBeanInfo


   
    public void testUnwrappedCollective() throws Exception {
        XMLIntrospector introspector = new XMLIntrospector();
        introspector.getConfiguration().setWrapCollectionsInElement(false);
        introspector.getConfiguration().setAttributesForPrimitives(true);
        XMLBeanInfo out = introspector.introspect(PhoneBookBean.class);
       
        // with wrapped collective, we expect a spacer element descriptor
        // (for the collective) containing a single collective descriptor
        ElementDescriptor phoneBookBeanDescriptor = out.getElementDescriptor();
        ElementDescriptor[] phoneBookChildDescriptors = phoneBookBeanDescriptor.getElementDescriptors();
        assertEquals("Expected single child descriptor", 1, phoneBookChildDescriptors.length);
       
        ElementDescriptor hollowPhoneNumberDescriptor = phoneBookChildDescriptors[0];
View Full Code Here


   
    public void testUnwrappedMap() throws Exception {
        XMLIntrospector introspector = new XMLIntrospector();
        introspector.getConfiguration().setWrapCollectionsInElement(false);
        introspector.getConfiguration().setAttributesForPrimitives(true);
        XMLBeanInfo out = introspector.introspect(DateFormatterBean.class);
       
        ElementDescriptor formatterDescriptor = out.getElementDescriptor();
        ElementDescriptor[] formatterChildDescriptors = formatterDescriptor.getElementDescriptors();
       
        assertEquals("Only one top level child", 1, formatterChildDescriptors.length);
       
        ElementDescriptor entryDescriptor = formatterChildDescriptors[0];
View Full Code Here

   
    public void testWrappedMap() throws Exception {
        XMLIntrospector introspector = new XMLIntrospector();
        introspector.getConfiguration().setWrapCollectionsInElement(true);
        introspector.getConfiguration().setAttributesForPrimitives(true);
        XMLBeanInfo out = introspector.introspect(DateFormatterBean.class);
       
        ElementDescriptor formatterDescriptor = out.getElementDescriptor();
        ElementDescriptor[] formatterChildDescriptors = formatterDescriptor.getElementDescriptors();
       
        assertEquals("Only one top level child", 1, formatterChildDescriptors.length);
       
        ElementDescriptor spacerDescriptor = formatterChildDescriptors[0];
View Full Code Here

   
    public void testIsSimpleForPrimitives() throws Exception {
        XMLIntrospector introspector = new XMLIntrospector();
        introspector.getConfiguration().setWrapCollectionsInElement(true);
        introspector.getConfiguration().setAttributesForPrimitives(false);
        XMLBeanInfo out = introspector.introspect(PhoneNumberBean.class);
       
        // the bean is mapped to a complex type structure and so should not be simple
        ElementDescriptor phoneNumberDescriptor = out.getElementDescriptor();
       
        assertFalse("Phone number descriptor is complex", phoneNumberDescriptor.isSimple());
       
        ElementDescriptor[] phoneNumberChildDescriptors = phoneNumberDescriptor.getElementDescriptors();
        assertEquals("Expected three child elements", 3, phoneNumberChildDescriptors.length);
View Full Code Here

   
    public void testSimpleForRSS() throws Exception {
        XMLIntrospector introspector = new XMLIntrospector();
        introspector.getConfiguration().setWrapCollectionsInElement(true);
        introspector.getConfiguration().setAttributesForPrimitives(false);
        XMLBeanInfo out = introspector.introspect(Channel.class);
       
        ElementDescriptor channelDescriptor = out.getElementDescriptor();
        ElementDescriptor[] childNodesOfRSS = channelDescriptor.getElementDescriptors();
        assertEquals("RSS has only one child, channel", 1, childNodesOfRSS.length);
        ElementDescriptor[] childNodesOfChannel = childNodesOfRSS[0].getElementDescriptors();
       
        boolean matched = false;
View Full Code Here

    /** Tests for setting for map with a simple key */
    public void testMapWithSimpleKey() throws Exception {
        XMLIntrospector introspector = new XMLIntrospector();
        introspector.getConfiguration().setWrapCollectionsInElement(false);
        introspector.getConfiguration().setAttributesForPrimitives(true);
        XMLBeanInfo out = introspector.introspect(AddressBook.class);
       
        ElementDescriptor formatterDescriptor = out.getElementDescriptor();
        ElementDescriptor[] formatterChildDescriptors = formatterDescriptor.getElementDescriptors();
       
        assertEquals("Two top level children", 2, formatterChildDescriptors.length);
       
        ElementDescriptor entryDescriptor = formatterChildDescriptors[0];
View Full Code Here

    /** Tests introspector of map with simple entries */
    public void testMapWithSimpleEntry() throws Exception {
        XMLIntrospector introspector = new XMLIntrospector();
        introspector.getConfiguration().setWrapCollectionsInElement(false);
        introspector.getConfiguration().setAttributesForPrimitives(true);
        XMLBeanInfo out = introspector.introspect(AddressBook.class);
       
        ElementDescriptor formatterDescriptor = out.getElementDescriptor();
        ElementDescriptor[] formatterChildDescriptors = formatterDescriptor.getElementDescriptors();
       
        assertEquals("Two top level children", 2, formatterChildDescriptors.length);
       
        ElementDescriptor entryDescriptor = formatterChildDescriptors[1];
View Full Code Here

    }
   
    public void testConcreteMapNoWrap() throws Exception {
        XMLIntrospector introspector = new XMLIntrospector();
        introspector.getConfiguration().setWrapCollectionsInElement(false);
        XMLBeanInfo beanInfo = introspector.introspect(BeanWithConcreteMap.class);
        ElementDescriptor beanDescriptor = beanInfo.getElementDescriptor();
       
        ElementDescriptor[] beanChildDescriptors = beanDescriptor.getElementDescriptors();
        assertEquals("One Entry element", 1, beanChildDescriptors.length);
       
        ElementDescriptor entry = beanChildDescriptors[0];
View Full Code Here

    }
   
    public void testConcreteMapWithWrap() throws Exception {
        XMLIntrospector introspector = new XMLIntrospector();
        introspector.getConfiguration().setWrapCollectionsInElement(true);
        XMLBeanInfo beanInfo = introspector.introspect(BeanWithConcreteMap.class);
       
        ElementDescriptor beanDescriptor = beanInfo.getElementDescriptor();
       
        ElementDescriptor[] beanChildDescriptors = beanDescriptor.getElementDescriptors();
        assertEquals("One wrapper element", 1, beanChildDescriptors.length);
       
        ElementDescriptor wrapper = beanChildDescriptors[0];
View Full Code Here

public class TestValueSuppressionStrategy extends TestCase {

    public void testALLOW_ALL_VALUESStrategy() throws Exception {
        XMLIntrospector introspector = new XMLIntrospector();
        introspector.getConfiguration().setAttributesForPrimitives(true);
        XMLBeanInfo beanInfo = introspector.introspect(AddressBean.class);
        AttributeDescriptor[] descriptors = beanInfo.getElementDescriptor().getAttributeDescriptors();
        assertTrue(descriptors.length>0);
        for (int i=0;i<descriptors.length;i++)
        {
            assertFalse(ValueSuppressionStrategy.ALLOW_ALL_VALUES.suppressAttribute(descriptors[i], "Arbitrary Value"));
            assertFalse(ValueSuppressionStrategy.ALLOW_ALL_VALUES.suppressAttribute(descriptors[i], ""));
View Full Code Here

TOP

Related Classes of org.apache.commons.betwixt.XMLBeanInfo

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.