Examples of XMLBeanInfo


Examples of org.apache.commons.betwixt.XMLBeanInfo

            }
        }
       
        Object top = digester.peek();
        if ( top instanceof XMLBeanInfo ) {
            XMLBeanInfo beanInfo = (XMLBeanInfo) top;
            ElementDescriptor elementDescriptor = beanInfo.getElementDescriptor();
            if (elementDescriptor == null) {
                elementDescriptor.addContentDescriptor( descriptor );
            }
           
        } else if ( top instanceof ElementDescriptor ) {
View Full Code Here

Examples of org.apache.commons.betwixt.XMLBeanInfo

        bean.addActor(new PersonBean("Helen", "Mirren"));
        bean.addActor(new PersonBean("Nicol", "Williamson"));
       
        TestWritingAPI writer = new TestWritingAPI();
        writer.getXMLIntrospector().getConfiguration().setAttributesForPrimitives(true);
        XMLBeanInfo personXmlBeanInfo
            = writer.getXMLIntrospector().introspect(PersonBean.class);
        XMLBeanInfo movieXmlBeanInfo
            = writer.getXMLIntrospector().introspect(MovieBean.class);
        writer.write(bean);
       
        List expected = new ArrayList();
        ElementDescriptor movieElementdescriptor
            = movieXmlBeanInfo.getElementDescriptor();
        ElementDescriptor nameDescriptor
            = movieElementdescriptor.getElementDescriptors()[0];
        ElementDescriptor yearDescriptor
            = movieElementdescriptor.getElementDescriptors()[1];
        ElementDescriptor directorDescriptor
View Full Code Here

Examples of org.apache.commons.betwixt.XMLBeanInfo

    //todo: note to self need to consider how the design of the introspection will work when you have strategy which takes
    // singular property which is not know until after the digestion
   
    public void testDefaultMappingDerivationStrategy() throws Exception {
        XMLIntrospector xmlIntrospector = new XMLIntrospector();
        XMLBeanInfo xmlBeanInfo = xmlIntrospector.introspect(Animals.class);
        ElementDescriptor animalsDescriptor = xmlBeanInfo.getElementDescriptor();
        assertEquals("Use bind time type", true, animalsDescriptor.isUseBindTimeTypeForMapping());
        ElementDescriptor animalDescriptor = animalsDescriptor.getElementDescriptors()[0];
        assertEquals("Use bind time type", true, animalDescriptor.isUseBindTimeTypeForMapping());
    }
View Full Code Here

Examples of org.apache.commons.betwixt.XMLBeanInfo

    }
   
    public void testIntrospectionTimeMappingDerivationStrategy() throws Exception {
        XMLIntrospector xmlIntrospector = new XMLIntrospector();
        xmlIntrospector.getConfiguration().setMappingDerivationStrategy(MappingDerivationStrategy.USE_INTROSPECTION_TIME_TYPE);
        XMLBeanInfo xmlBeanInfo = xmlIntrospector.introspect(Animals.class);
        ElementDescriptor animalsDescriptor = xmlBeanInfo.getElementDescriptor();
        assertEquals("Use introspection time type", false, animalsDescriptor.isUseBindTimeTypeForMapping());
        ElementDescriptor animalDescriptor = animalsDescriptor.getElementDescriptors()[0];
        assertEquals("Use introspection time type", false, animalDescriptor.isUseBindTimeTypeForMapping());
    }
View Full Code Here

Examples of org.apache.commons.betwixt.XMLBeanInfo

    }

    public void testBindTypeMappingDerivationStrategy() throws Exception {
        XMLIntrospector xmlIntrospector = new XMLIntrospector();
        xmlIntrospector.getConfiguration().setMappingDerivationStrategy(MappingDerivationStrategy.USE_BIND_TIME_TYPE);
        XMLBeanInfo xmlBeanInfo = xmlIntrospector.introspect(Animals.class);
        ElementDescriptor animalsDescriptor = xmlBeanInfo.getElementDescriptor();
        assertEquals("Use bind time type", true, animalsDescriptor.isUseBindTimeTypeForMapping());
        ElementDescriptor animalDescriptor = animalsDescriptor.getElementDescriptors()[0];
        assertEquals("Use bind time type", true, animalDescriptor.isUseBindTimeTypeForMapping());
    }
View Full Code Here

Examples of org.apache.commons.betwixt.XMLBeanInfo

            "  <element name='pet' property='pet' mappingDerivation='bind'/>" +
            "</element>" +
            "</info>";
        XMLIntrospector xmlIntrospector = new XMLIntrospector();
        xmlIntrospector.getConfiguration().setMappingDerivationStrategy(MappingDerivationStrategy.USE_INTROSPECTION_TIME_TYPE);
        XMLBeanInfo xmlBeanInfo = xmlIntrospector.introspect(PetBean.class, new InputSource(new StringReader(mappingDocument)));
        ElementDescriptor petDescriptor = xmlBeanInfo.getElementDescriptor();
        assertEquals("Use type from strategy", true, petDescriptor.isUseBindTimeTypeForMapping());
        ElementDescriptor animalDescriptor = petDescriptor.getElementDescriptors()[0];
        assertEquals("Use type from document", true, animalDescriptor.isUseBindTimeTypeForMapping());
    }
View Full Code Here

Examples of org.apache.commons.betwixt.XMLBeanInfo

                new DynaProperty("two", String.class)};
        BasicDynaClass dynaClass = new BasicDynaClass("WibbleDynaBean", BasicDynaBean.class,
                dynaProperties);
        DynaBean dynaBean = dynaClass.newInstance();
        XMLIntrospector xmlIntrospector = new XMLIntrospector();
        XMLBeanInfo xmlBeanInfo = xmlIntrospector.introspect(dynaBean);
       
        ElementDescriptor dynaBeanDescriptor = xmlBeanInfo.getElementDescriptor();
        ElementDescriptor[] dynaPropertyDescriptors = dynaBeanDescriptor.getElementDescriptors();
        assertEquals("Two dyna properties expected", 2, dynaPropertyDescriptors.length);
       
        for (int i=0; i<2; i++) {
            if ("one".equals(dynaPropertyDescriptors[i].getPropertyName())
View Full Code Here

Examples of org.apache.commons.betwixt.XMLBeanInfo

            "  <element name='pet' property='pet' mappingDerivation='introspection'/>" +
            "</element>" +
            "</info>";
        XMLIntrospector xmlIntrospector = new XMLIntrospector();
        xmlIntrospector.getConfiguration().setMappingDerivationStrategy(MappingDerivationStrategy.USE_BIND_TIME_TYPE);
        XMLBeanInfo xmlBeanInfo = xmlIntrospector.introspect(PetBean.class, new InputSource(new StringReader(mappingDocument)));
        ElementDescriptor petDescriptor = xmlBeanInfo.getElementDescriptor();
        assertEquals("Use type from strategy", true, petDescriptor.isUseBindTimeTypeForMapping());
        ElementDescriptor animalDescriptor = petDescriptor.getElementDescriptors()[0];
        assertEquals("Use type from document", false, animalDescriptor.isUseBindTimeTypeForMapping());
    }
View Full Code Here

Examples of org.apache.commons.betwixt.XMLBeanInfo

            "   <addDefaults/>" +
            "</element>" +
            "</info>";
        XMLIntrospector xmlIntrospector = new XMLIntrospector();
        xmlIntrospector.getConfiguration().setMappingDerivationStrategy(MappingDerivationStrategy.USE_BIND_TIME_TYPE);
        XMLBeanInfo xmlBeanInfo = xmlIntrospector.introspect(PetBean.class, new InputSource(new StringReader(mappingDocument)));
        ElementDescriptor petDescriptor = xmlBeanInfo.getElementDescriptor();
        assertEquals("Use type from strategy", true, petDescriptor.isUseBindTimeTypeForMapping());
        ElementDescriptor animalDescriptor = petDescriptor.getElementDescriptors()[0];
        assertEquals("Use type from document", false, animalDescriptor.isUseBindTimeTypeForMapping());
        ElementDescriptor personDescriptor = petDescriptor.getElementDescriptors()[1];
        assertEquals("Use type from document", true, personDescriptor.isUseBindTimeTypeForMapping());
View Full Code Here

Examples of org.apache.commons.betwixt.XMLBeanInfo

       
        introspector.getConfiguration().setAttributesForPrimitives(true);
       
        Object bean = createBean();
       
        XMLBeanInfo info = introspector.introspect( bean );
       
        assertTrue( "Found XMLBeanInfo", info != null );
       
        ElementDescriptor descriptor = info.getElementDescriptor();
       
        assertTrue( "Found root element descriptor", descriptor != null );
       
        AttributeDescriptor[] attributes = descriptor.getAttributeDescriptors();
       
        assertTrue( "Found attributes", attributes != null && attributes.length > 0 );
       
        // test second introspection with caching on
        info = introspector.introspect( bean );
       
        assertTrue( "Found XMLBeanInfo", info != null );
       
        descriptor = info.getElementDescriptor();
       
        assertTrue( "Found root element descriptor", descriptor != null );
       
        attributes = descriptor.getAttributeDescriptors();
       
        assertTrue( "Found attributes", attributes != null && attributes.length > 0 );


        // test introspection with caching off     
        //introspector.setCachingEnabled(false); 
        introspector.setRegistry(new NoCacheRegistry());
        info = introspector.introspect( bean );
       
        assertTrue( "Found XMLBeanInfo", info != null );
       
        descriptor = info.getElementDescriptor();
       
        assertTrue( "Found root element descriptor", descriptor != null );
       
        attributes = descriptor.getAttributeDescriptors();
       
        assertTrue( "Found attributes", attributes != null && attributes.length > 0 );


        // test introspection after flushing cache
//        introspector.setCachingEnabled(true);
        introspector.setRegistry(new DefaultXMLBeanInfoRegistry());
        //introspector.flushCache();
        info = introspector.introspect( bean );
       
        assertTrue( "Found XMLBeanInfo", info != null );
       
        descriptor = info.getElementDescriptor();
       
        assertTrue( "Found root element descriptor", descriptor != null );
       
        attributes = descriptor.getAttributeDescriptors();
       
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.