Package org.apache.commons.betwixt

Examples of org.apache.commons.betwixt.ElementDescriptor


        BaseMixedContentEncodingStrategy mceStrategy = new TestBaseMixedContentEncoding(false);
        assertEquals("Check basic escaping", "<![CDATA[<greeting>ab]]&gt;ba</greeting>]]>", mceStrategy.encodeInCDATA("<greeting>ab]]>ba</greeting>"));
    }
   
    public void testBaseMixedEncode() {
        ElementDescriptor descriptor = new ElementDescriptor();
        TestBaseMixedContentEncoding mceStrategy = new TestBaseMixedContentEncoding(false);
        assertEquals(
                        "Using character escaping",
                        "&lt;exclaim&gt;hello, mum&lt;/exclaim&gt;",
                        mceStrategy.encode("<exclaim>hello, mum</exclaim>", descriptor));
View Full Code Here


       
        assertEquals("Descriptor set", descriptor, mceStrategy.element);
    }
   
    public void testDefaultImplementation() {
        ElementDescriptor descriptor = new ElementDescriptor();
        assertEquals(
            "Default implementation uses character escaping",
            "&lt;proclaim&gt;The King Is Dead, Long Live The King&lt;/proclaim&gt;",
            MixedContentEncodingStrategy.DEFAULT.encode("<proclaim>The King Is Dead, Long Live The King</proclaim>", descriptor));
    }
View Full Code Here

            "&lt;proclaim&gt;The King Is Dead, Long Live The King&lt;/proclaim&gt;",
            MixedContentEncodingStrategy.DEFAULT.encode("<proclaim>The King Is Dead, Long Live The King</proclaim>", descriptor));
    }
   
    public void testEscapedCharactersImplementation() {
        ElementDescriptor descriptor = new ElementDescriptor();
        assertEquals(
            "Default implementation uses character escaping",
            "&lt;proclaim&gt;The King Is Dead, Long Live The King&lt;/proclaim&gt;",
            MixedContentEncodingStrategy.ESCAPED_CHARACTERS.encode("<proclaim>The King Is Dead, Long Live The King</proclaim>", descriptor));
    }
View Full Code Here

            "&lt;proclaim&gt;The King Is Dead, Long Live The King&lt;/proclaim&gt;",
            MixedContentEncodingStrategy.ESCAPED_CHARACTERS.encode("<proclaim>The King Is Dead, Long Live The King</proclaim>", descriptor));
    }
   
    public void testCDATAImplementation() {
        ElementDescriptor descriptor = new ElementDescriptor();
        assertEquals(
            "Default implementation uses character escaping",
            "<![CDATA[<proclaim>The King Is Dead, Long Live The King</proclaim>]]>",
            MixedContentEncodingStrategy.CDATA.encode("<proclaim>The King Is Dead, Long Live The King</proclaim>", descriptor));
    }
View Full Code Here

    public void testNoNameIntrospection() throws Exception {
       
        XMLIntrospector xmlIntrospector = new XMLIntrospector();
        xmlIntrospector.getConfiguration().setWrapCollectionsInElement(false);
        XMLBeanInfo xmlBeanInfo = xmlIntrospector.introspect(MixedCollectionBean.class);
        ElementDescriptor elementDescriptor = xmlBeanInfo.getElementDescriptor();
        ElementDescriptor[] childDescriptors = elementDescriptor.getElementDescriptors();
        assertEquals("One child", 1, childDescriptors.length);  
        assertNull("Expected null name", childDescriptors[0].getLocalName());  
    }
View Full Code Here

        XMLIntrospector xmlIntrospector = new XMLIntrospector();
        XMLBeanInfo xmlBeanInfo = xmlIntrospector.introspect(MixedUpdatersBean.class);
        ElementDescriptor[] descriptors = xmlBeanInfo.getElementDescriptor().getElementDescriptors();
        boolean propertyFound = false;
        for (int i=0; i<descriptors.length ; i++) {
            ElementDescriptor descriptor = descriptors[i];
            if ("private-super".equals(descriptor.getLocalName())) {
                propertyFound = true;
                assertNotNull("Updater found", descriptor.getUpdater());
                assertNotNull("Expression found", descriptor.getTextExpression());
            }
        }
        assertTrue("Found inaccessible super methods", propertyFound);
    }
View Full Code Here

       
        assertEquals("Mapped classes", 3, mapped.length);
       
        XMLBeanInfo beanInfo = xmlIntrospector.introspect(AddressBean.class);
        assertNotNull("Bean info mapping", beanInfo);
        ElementDescriptor descriptor = beanInfo.getElementDescriptor();
        assertEquals("Root element name", "not-address", descriptor.getLocalName());
        ElementDescriptor[] childDescriptors = descriptor.getElementDescriptors();
        assertEquals("4 child elements", 4, childDescriptors.length);
        assertEquals("First element", "not-street", childDescriptors[0].getLocalName());
        assertEquals("Second element", "not-city", childDescriptors[1].getLocalName());
        assertEquals("Third element", "not-code", childDescriptors[2].getLocalName());
        assertEquals("Forth element", "not-country", childDescriptors[3].getLocalName());
             
        beanInfo = xmlIntrospector.introspect(SimpleTestBean.class);
        assertNotNull("Bean info mapping", beanInfo);
        descriptor = beanInfo.getElementDescriptor();
        assertEquals("Root element name", "jelly", descriptor.getLocalName());
        childDescriptors = descriptor.getElementDescriptors();
        assertEquals("Child elements", 2, childDescriptors.length);
        assertEquals("First element", "wibble", childDescriptors[0].getLocalName());
        assertEquals("Second element", "wobble", childDescriptors[1].getLocalName());
            
    }
View Full Code Here

        // 2 Element descriptors
        ElementDescriptor[] elementDescriptors = beanInfo
                .getElementDescriptor().getElementDescriptors();
        assertEquals("Need 2 element descriptors", 2, elementDescriptors.length);

        ElementDescriptor element1Descriptor = beanInfo.getElementDescriptor()
                .getElementDescriptor("element1");
        log.info("element1Descriptor: " + element1Descriptor);
        debugOptions(element1Descriptor.getOptions());
        assertNotNull(element1Descriptor);
        assertEquals("1", element1Descriptor.getOptions().getValue(
                "version-from"));
        assertNull(element1Descriptor.getOptions().getValue("version-until"));

        ElementDescriptor element2Descriptor = beanInfo.getElementDescriptor()
                .getElementDescriptor("element2");
        log.info("element2Descriptor: " + element2Descriptor);
        debugOptions(element2Descriptor.getOptions());
        assertNotNull(element2Descriptor);
        assertEquals("2", element2Descriptor.getOptions().getValue(
                "version-from"));
        assertNull(element2Descriptor.getOptions().getValue("version-until"));

        // 2 Attribute descriptors
        AttributeDescriptor[] attributeDescriptors = beanInfo
                .getElementDescriptor().getAttributeDescriptors();
        assertEquals("Need 2 attribute descriptors", 2,
View Full Code Here

     * This is the first match when calling the defaultStemmer.
     * It just adds an s to the the property and it should find it..
     */
    public void testFirstMatch() {
       
        ElementDescriptor des = new ElementDescriptor();
        des.setQualifiedName("FooBars");
        des.setPropertyType(java.util.List.class);
        HashMap map = new HashMap();
        map.put("FooBars", des);
        DefaultPluralStemmer dps = new DefaultPluralStemmer();
        ElementDescriptor result = dps.findPluralDescriptor("FooBar", map);
        assertEquals(des, result);
    }
View Full Code Here

    /**
     * Tests if the y is nicely replaces with ies and the correct
     * ElementDescriptor is returned
     */
    public void testSecondMatch() {
        ElementDescriptor des = new ElementDescriptor();
        des.setQualifiedName("FooBary");
        des.setPropertyType(java.util.List.class);
        HashMap map = new HashMap();
        map.put("FooBaries", des);
        DefaultPluralStemmer dps = new DefaultPluralStemmer();
        ElementDescriptor result = dps.findPluralDescriptor("FooBary", map);
        assertEquals(des, result);
    }
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.