Package org.apache.commons.betwixt

Examples of org.apache.commons.betwixt.ElementDescriptor


   
    /**
     * Tests if it actually skips the y if the length not greater than 1.
     */
    public void testSecondNonMatch() {
        ElementDescriptor des = new ElementDescriptor();
        des.setQualifiedName("y");
        des.setPropertyType(java.util.List.class);
        HashMap map = new HashMap();
        map.put("yies", des);
        DefaultPluralStemmer dps = new DefaultPluralStemmer();
        ElementDescriptor result = dps.findPluralDescriptor("y", map);
        assertNotNull(result);
    }
View Full Code Here


    /**
     * Uses the third if in pluralstemmer.
     * It should return the specified y, without any changing.
     */
    public void testThirdMatch() {
        ElementDescriptor des = new ElementDescriptor();
        des.setQualifiedName("y");
        des.setPropertyType(java.util.List.class);
        HashMap map = new HashMap();
        map.put("y", des);
        DefaultPluralStemmer dps = new DefaultPluralStemmer();
        ElementDescriptor result = dps.findPluralDescriptor("y", map);
        assertEquals(des, result);
    }
View Full Code Here

    /**
     * Tests to see if you get warned when there are multiple matches
     * found
     */
    public void testMultipleMatches() {
        ElementDescriptor des = new ElementDescriptor();
        des.setQualifiedName("y");
        des.setPropertyType(java.util.List.class);
        ElementDescriptor desyes = new ElementDescriptor();
        desyes.setQualifiedName("yes");
        desyes.setPropertyType(java.util.List.class);
        ElementDescriptor desyesno = new ElementDescriptor();
        desyesno.setQualifiedName("yesno");
        desyesno.setPropertyType(java.util.List.class);
        HashMap map = new HashMap();
        map.put("y", des);
        map.put("yes", desyes);
        map.put("yesno", desyesno);
        DefaultPluralStemmer dps = new DefaultPluralStemmer();
        ElementDescriptor result = dps.findPluralDescriptor("y", map);
        assertEquals(des, result);
        result = dps.findPluralDescriptor("yes", map);
        assertEquals(desyes, result);
        result = dps.findPluralDescriptor("yesno", map);
        assertEquals(desyesno, result);
View Full Code Here

     *  Test to find matched where plural ending is "es"
     */
    public void testESPluralEndingMatch() {
        HashMap map = new HashMap();

        ElementDescriptor index = new ElementDescriptor("index", "index","");
        map.put("index", index);
        ElementDescriptor indexes = new ElementDescriptor("indexes", "indexes","");
        map.put("indexes", indexes);

        ElementDescriptor patch = new ElementDescriptor("patch", "patch","");
        map.put("patch", patch);
        ElementDescriptor patches = new ElementDescriptor("patches", "patches","");
        map.put("patches", patches);

        DefaultPluralStemmer stemmer = new DefaultPluralStemmer();
        ElementDescriptor result = stemmer.findPluralDescriptor("index", map);
        assertEquals(indexes, result);

        result = stemmer.findPluralDescriptor("patches", map);
        assertEquals(patches, result);
    }
View Full Code Here

    /**
     *  Test if the closest match mechanisme is working
     */
    public void testClosestMatch() {
        HashMap map = new HashMap();
        ElementDescriptor yes1 = new ElementDescriptor("yes1", "yes1","");
        map.put("yes1", yes1);
        ElementDescriptor yes12 = new ElementDescriptor("yes12", "yes12","");
        map.put("yes12", yes12);
        ElementDescriptor yes123 = new ElementDescriptor("yes123", "yes123","");
        map.put("yes123", yes123);
        DefaultPluralStemmer stemmer = new DefaultPluralStemmer();
        ElementDescriptor result = stemmer.findPluralDescriptor("yes", map);
        assertEquals(yes1, result);
    }   
View Full Code Here

    {
        XMLIntrospector introspector = new XMLIntrospector();
        introspector.register(new InputSource(new StringReader(MAPPING)));
       
       
        ElementDescriptor descriptor = introspector.introspect(Element.class).getElementDescriptor();
        ElementMapping elementMapping = new ElementMapping();
        elementMapping.setAttributes(new AttributesImpl());
        elementMapping.setName("Bogus");
        elementMapping.setDescriptor(descriptor);
        elementMapping.setType(Iterator.class);
View Full Code Here

                "    </element>" +
                "</info>");
        XMLIntrospector introspector = new XMLIntrospector();
        XMLBeanInfo xmlBeanInfo = introspector.introspect(SimpleTestBean.class, new InputSource(reader));
       
        ElementDescriptor elementDescriptor = xmlBeanInfo.getElementDescriptor();
        assertEquals("Root is jelly", "jelly", elementDescriptor.getLocalName());
        ElementDescriptor[] childDescriptors = elementDescriptor.getElementDescriptors();
        assertEquals("Expected two child elements", 2, childDescriptors.length);
        assertEquals("Wibble comes first", "wibble", childDescriptors[0].getLocalName());
        assertEquals("Wobble comes last", "wobble", childDescriptors[1].getLocalName());
       
        reader = new StringReader(
                "<?xml version='1.0' ?>" +
                "<info>" +
                "    <element name='not-jelly'>" +
                "        <element name='no-wibble' property='alpha'/>" +
                "        <element name='no-wobble' property='beta'/>" +
                "    </element>" +
                "</info>");

        xmlBeanInfo = introspector.introspect(SimpleTestBean.class, new InputSource(reader));
       
        elementDescriptor = xmlBeanInfo.getElementDescriptor();
        assertEquals("Root is not-jelly", "not-jelly", elementDescriptor.getLocalName());
        childDescriptors = elementDescriptor.getElementDescriptors();
        assertEquals("Expected two child elements", 2, childDescriptors.length);
        assertEquals("No wibble comes first", "no-wibble", childDescriptors[0].getLocalName());
        assertEquals("No wobble comes last", "no-wobble", childDescriptors[1].getLocalName());
    }
View Full Code Here

                "</info>");
        XMLIntrospector introspector = new XMLIntrospector();
        introspector.register(SimpleTestBean.class, new InputSource(reader));
        XMLBeanInfo xmlBeanInfo = introspector.introspect(SimpleTestBean.class);
       
        ElementDescriptor elementDescriptor = xmlBeanInfo.getElementDescriptor();
        assertEquals("Root is jelly", "jelly", elementDescriptor.getLocalName());
        ElementDescriptor[] childDescriptors = elementDescriptor.getElementDescriptors();
        assertEquals("Expected two child elements", 2, childDescriptors.length);
        assertEquals("Wibble comes first", "wibble", childDescriptors[0].getLocalName());
        assertEquals("Wobble comes last", "wobble", childDescriptors[1].getLocalName());
    }
View Full Code Here

        //ElementRule.setLog(log);
       
        XMLIntrospector introspector = new XMLIntrospector();
        XMLBeanInfo beanInfo = introspector.introspect(ExampleBean.class);
        ElementDescriptor[] elementDescriptors = beanInfo.getElementDescriptor().getElementDescriptors();
        ElementDescriptor elementsElementDescriptor = null;
        for ( int i=0, size = elementDescriptors.length; i<size ; i++ ) {
            if ( "example".equals( elementDescriptors[i].getLocalName() ) ) {
                elementsElementDescriptor = elementDescriptors[i];
            }
        }
       
        assertNotNull("Element descriptor for elements not found", elementsElementDescriptor);
        assertEquals(
                    "Class property not set",
                    ExampleImpl.class,
                    elementsElementDescriptor.getImplementationClass());
    }
View Full Code Here

        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];
        assertEquals("Expected recorded to be bound as an attribute", "recorded", recordedAttribute.getLocalName());
       
        ElementDescriptor[] tuneBeanChildElements = tuneBeanDescriptor.getElementDescriptors();
        assertEquals("Expected three child elements", 3 , tuneBeanChildElements.length);
       
        int bits = 0;
        for (int i=0, size=tuneBeanChildElements.length; i<size; i++) {
            String localName = tuneBeanChildElements[i].getLocalName();
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.