Package org.apache.commons.betwixt

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


        }
    }
   
    /** 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);
View Full Code Here


        assertNotNull("Value should have an updater", valueDescriptor.getUpdater());
    }
   
    /** 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);
View Full Code Here

        assertFalse("Is simple therefore not hollow",  valueDescriptor.isHollow());
        assertNotNull("Value should have an updater", valueDescriptor.getUpdater());
    }
   
    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);
       
View Full Code Here

        ElementDescriptor[] entryChildren = entry.getElementDescriptors();
        assertEquals("Expected key and entry elements", 2 , entryChildren.length);       
    }
   
    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);
View Full Code Here

       
//        log.debug(buffer.getBuffer().toString());
       
        StringReader in = new StringReader(buffer.getBuffer().toString());
        reader = createBeanReader();
        XMLIntrospector intro = createXMLIntrospector();
        DefaultXMLBeanInfoRegistry registry = new DefaultXMLBeanInfoRegistry();
        intro.setRegistry(registry);
        // we have written the xml file back with element collections,
        // so we have to say to the reader we want to use that now
        // (the default when creating in this test is not to use them)
        intro.getConfiguration().setWrapCollectionsInElement(true);
        // first flush the cash, else setting other options, doesn't
        // end up in rereading / mapping the object model.
        registry.flush();
        // set the xmlIntrospector back to the reader
        reader.setXMLIntrospector(intro);
View Full Code Here

   
    /**
     * Set up the XMLIntroSpector
     */
    protected XMLIntrospector createXMLIntrospector() {
        XMLIntrospector introspector = new XMLIntrospector();

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

        // Since we don't want to have collectionelements
        // line <DBMSS>, we have to set this to false,
        // since the default is true.
        introspector.getConfiguration().setWrapCollectionsInElement(false);

        // We have to use the HyphenatedNameMapper
        // Since we want the names to resolve from eg PhysicalSchema
        // to PHYSICAL_SCHEMA.
        // we pass to the mapper we want uppercase and use _ for name
        // seperation.
        // This will set our ElementMapper.
        introspector.getConfiguration().setElementNameMapper(new HyphenatedNameMapper(true, "_"));
        // since our attribute names will use a different
        // naming convention in our xml file (just all lowercase)
        // we set another mapper for the attributes
        introspector.getConfiguration().setAttributeNameMapper(new DecapitalizeNameMapper());

        return introspector;
    }
View Full Code Here

        AlphaTwoImpl two = (AlphaTwoImpl)list.get(1);
        assertEquals("2", two.alpha());
    }

  public void testIntrospection() throws Exception   {
    XMLIntrospector introspector = new XMLIntrospector();
    XMLBeanInfo beanInfo = introspector.introspect(AlphaList.class);
    ElementDescriptor[] descriptors = beanInfo.getElementDescriptor().getElementDescriptors();
    assertEquals("One descriptor", 1, descriptors.length);
        assertTrue(descriptors[0].isHollow());
        assertNotNull(descriptors[0].getContextExpression());
        assertNotNull(descriptors[0].getUpdater());
View Full Code Here

        configuration.setMapIDs(false);
    }
   

    public void testIntrospection() throws Exception {
        XMLIntrospector introspector = new XMLIntrospector();
       
        StringReader mapping = new StringReader(MAPPING);
        introspector.register(new InputSource(mapping));
      
        XMLBeanInfo beanInfo = introspector.introspect(AlphaListHolder.class);
        ElementDescriptor descriptor = beanInfo.getElementDescriptor();
        assertNotNull(descriptor);
        ElementDescriptor[] descriptors = descriptor.getElementDescriptors();
        assertNotNull(descriptors);
        assertEquals("Only one descriptor", 1, descriptors.length);
View Full Code Here

        //log = new
        // SimpleLog("[testReadwithCollectionsInElementRoundTrip:XMLIntrospector]");
        //log.setLevel(SimpleLog.LOG_LEVEL_TRACE);

        XMLIntrospector intro = createXMLIntrospector();
        //intro.setLog(log);
        intro.getConfiguration().setWrapCollectionsInElement(true);

        //log = new
        // SimpleLog("[testReadwithCollectionsInElementRoundTrip:BeanReader]");
        //log.setLevel(SimpleLog.LOG_LEVEL_TRACE);
View Full Code Here

        //  log = new
        // SimpleLog("[testReadWithoutCollectionsInElementRoundTrip:XMLIntrospector]");
        //        log.setLevel(SimpleLog.LOG_LEVEL_TRACE);

        XMLIntrospector intro = createXMLIntrospector();
        intro.getConfiguration().setWrapCollectionsInElement(false);
        //        intro.setLog(log);
        //        log = new
        // SimpleLog("[testReadWithoutCollectionsInElementRoundTrip:XMLIntrospectorHelper]");
        //        log.setLevel(SimpleLog.LOG_LEVEL_TRACE);
        //        XMLIntrospectorHelper.setLog(log);
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.