Package org.apache.commons.betwixt

Examples of org.apache.commons.betwixt.ElementDescriptor


       
        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();
       
        assertTrue( "Found attributes", attributes != null && attributes.length > 0 );

    }
View Full Code Here


    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();
       
        assertEquals("Expected no attributes", 0, attributeDescriptor.length);
        assertEquals("Expected two elements", 2, children.length);
   
View Full Code Here

               
            });
       
        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();
       
        assertEquals("Expected no attributes", 0, attributeDescriptor.length);
        assertEquals("Expected one elements", 1, children.length);
        assertEquals("Expected element", "name", children[0].getLocalName());
   
View Full Code Here

    private Rule valueRule;
    private ElementDescriptor elementDescriptor;

    protected void setUp() throws Exception {
        super.setUp();
        elementDescriptor = new ElementDescriptor();
        digester = new Digester();
        digester.push(elementDescriptor);
        optionRule = new OptionRule();
        optionRule.setDigester(digester);
        nameRule = optionRule.getNameRule();
View Full Code Here

        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);
        assertEquals("Expected one elements", 1, children.length);
        assertEquals("Expected element", "name", children[0].getLocalName());
    }     
View Full Code Here

   
    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);
   
    assertEquals( "Element name correct", "rss", elementDescriptor.getLocalName());
    }
View Full Code Here

           
        XMLBeanInfoDigester digester = new XMLBeanInfoDigester();
        digester.setXMLIntrospector(new XMLIntrospector());
        digester.setBeanClass(ExampleBean.class);
        XMLBeanInfo xmlBeanInfo = (XMLBeanInfo) digester.parse(new StringReader(xml));
        ElementDescriptor baseDescriptor = xmlBeanInfo.getElementDescriptor();
       
        assertEquals("Value one set on base", "value one",  baseDescriptor.getOptions().getValue("one"));
        assertEquals("Value two set on base", "value two",  baseDescriptor.getOptions().getValue("two"));
        assertNull("Value three not set on base",  baseDescriptor.getOptions().getValue("three"));

        assertEquals("Number of child elements", 1, baseDescriptor.getElementDescriptors().length);
       
        ElementDescriptor childDescriptor = baseDescriptor.getElementDescriptors()[0];
        assertNull("Value one set on base",  childDescriptor.getOptions().getValue("one"));
        assertNull("Value two set on base",  childDescriptor.getOptions().getValue("two"));
        assertEquals("Value three set on child", "value three",  childDescriptor.getOptions().getValue("three"));
    }
View Full Code Here

        assertTrue( beanInfoMap.containsKey(TestDigestMultiMapping.class));
       
        XMLBeanInfo xmlBeanInfo = (XMLBeanInfo) beanInfoMap.get(TestDigestMultiMapping.class);
        assertNotNull(xmlBeanInfo);
       
        ElementDescriptor baseDescriptor = xmlBeanInfo.getElementDescriptor();
       
        assertEquals("Value one set on base", "test-value-a",  baseDescriptor.getOptions().getValue("test-key-a"));
        assertEquals("Value two set on base", "test-value-b",  baseDescriptor.getOptions().getValue("test-key-b"));
        assertNull("Value three not set on base",  baseDescriptor.getOptions().getValue("three"));

        assertEquals("Number of child elements", 1, baseDescriptor.getElementDescriptors().length);
       
        ElementDescriptor childDescriptor = baseDescriptor.getElementDescriptors()[0];
        assertNull("Value one set on base",  childDescriptor.getOptions().getValue("test-key-a"));
        assertNull("Value two set on base",  childDescriptor.getOptions().getValue("test-key-b"));
        assertEquals("Value three set on child", "test-value-c",  childDescriptor.getOptions().getValue("test-key-c"));
    }
View Full Code Here

        bean.setStreet("DEFAULT");
        bean.setCode("DEFAULT");
        bean.setCountry("DEFAULT");
       
        XMLIntrospector introspector = new XMLIntrospector();
        ElementDescriptor elementDescriptor = introspector.introspect(AddressBean.class).getElementDescriptor();
       
        ReadContext context = new ReadContext(new BindingConfiguration(), new ReadConfiguration());
        context.setBean(bean);
        context.markClassMap(AddressBean.class);
        context.pushElement("NoMatch");
View Full Code Here

   * Generates an XML Schema model from the given XMLBeanInfo
   * @param xmlBeanInfo not null
   * @return Schema model, not null
   */
  public Schema generate(XMLBeanInfo xmlBeanInfo) throws IntrospectionException {
       ElementDescriptor elementDescriptor = xmlBeanInfo.getElementDescriptor();
     Schema schema = new Schema(introspector);
       schema.addGlobalElementType(configuration, elementDescriptor);
       return schema;
  }
View Full Code Here

TOP

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

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.