Package org.apache.commons.betwixt

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


        propertyDescriptors = null;

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

        XMLIntrospector introspector = new XMLIntrospector();
        introspector.getConfiguration().setAttributesForPrimitives(false);
//        introspector.setLog(log);
       
        XMLBeanInfo xmlBeanInfo = introspector.introspect(BeanWithBeanInfoBean.class);
       
        ElementDescriptor[] elementDescriptors = xmlBeanInfo.getElementDescriptor().getElementDescriptors();
       
//        log = new SimpleLog("[testBeanWithBeanInfo]");
//        log.setLevel(SimpleLog.LOG_LEVEL_DEBUG);
View Full Code Here


                    parseString(out.toString()));
        }
    }
   
    public void testDefaultClassNormalizer() throws Exception {
        XMLIntrospector introspector = new XMLIntrospector();
       
        FaceImpl face = new FaceImpl();
        XMLBeanInfo info = introspector.introspect( face );
        ElementDescriptor elementDescriptor = info.getElementDescriptor();
   
        AttributeDescriptor[] attributeDescriptor = elementDescriptor.getAttributeDescriptors();     
        ElementDescriptor[] children = elementDescriptor.getElementDescriptors();
       
View Full Code Here

        assertEquals("Expected no attributes", 0, attributeDescriptor.length);
        assertEquals("Expected two elements", 2, children.length);
   
   
    public void testClassNormalizer() throws Exception {
        XMLIntrospector introspector = new XMLIntrospector();
        introspector.getConfiguration().setClassNormalizer( new ClassNormalizer() {
               
                public Class normalize(Class clazz) {
                    if (IFace.class.isAssignableFrom( clazz )) {
                        return IFace.class;
                   
                    return super.normalize( clazz );
               
            });
       
        FaceImpl face = new FaceImpl();
        XMLBeanInfo info = introspector.introspect( face );
        ElementDescriptor elementDescriptor = info.getElementDescriptor();
        assertEquals("Expected only itself", 1, elementDescriptor.getElementDescriptors().length);
   
        AttributeDescriptor[] attributeDescriptor = elementDescriptor.getAttributeDescriptors();     
        ElementDescriptor[] children = elementDescriptor.getElementDescriptors();
View Full Code Here

   
   
    public void testListedClassNormalizer() throws Exception {
        ListedClassNormalizer classNormalizer = new ListedClassNormalizer();
        classNormalizer.addSubstitution( IFace.class );
        XMLIntrospector introspector = new XMLIntrospector();
        introspector.getConfiguration().setClassNormalizer(classNormalizer);
       
        FaceImpl face = new FaceImpl();
       
        XMLBeanInfo info = introspector.introspect( face );
        ElementDescriptor elementDescriptor = info.getElementDescriptor();
        AttributeDescriptor[] attributeDescriptor = elementDescriptor.getAttributeDescriptors();     
        ElementDescriptor[] children = elementDescriptor.getElementDescriptors();
       
        assertEquals("Expected no attributes", 0, attributeDescriptor.length);
View Full Code Here

                            parseString(xml),
                            true);
   
   
    public void testBetwixtFileType() throws Exception {
      XMLIntrospector introspector = new XMLIntrospector();
      XMLBeanInfo info = introspector.introspect( Channel.class );
     
      ElementDescriptor elementDescriptor = info.getElementDescriptor();
     
    Class clazz = elementDescriptor.getSingularPropertyType();
    assertEquals( "Element type correct", Channel.class , clazz);
View Full Code Here

    public TestSimpleTypeMapper(String name) {
        super(name);
    }
   
    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

        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

  private List simpleTypes = new ArrayList();
   
    private XMLIntrospector introspector;
 
    public Schema() {
        this(new XMLIntrospector());
    }
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.