Package org.apache.commons.beanutils

Examples of org.apache.commons.beanutils.Converter.convert()


    public void testConvertToClassDefaultNull() {

        Converter converter = new ClassConverter(null);

        assertEquals("Invalid Test", null, converter.convert(Class.class, new Integer(6)));
        assertEquals("Null Test",    null, converter.convert(Class.class, null));
    }

    /**
     * Test Array Conversion
     */
 
View Full Code Here


     */
    public void testArray() {
        Converter converter = new ClassConverter();

        // Test Array Class to String
        assertEquals("Array to String", "[Ljava.lang.Boolean;", converter.convert(String.class, Boolean[].class));

        // *** N.B. for some reason the following works on m1, but not m2
        // Test String to Array Class
        // assertEquals("String to Array", Boolean[].class, converter.convert(Class.class, "[Ljava.lang.Boolean;"));
    }
View Full Code Here

    public void testInvalid() {
        Converter converter = new ClassConverter();

        // Test invalid class name
        try {
            converter.convert(Class.class, "foo.bar");
            fail("Invalid class name, expected ConversionException");
        } catch (ConversionException e) {
            // expected result
        }
    }
View Full Code Here

            {
                throw new UnsupportedOperationException("cant deal with " + destType);
            }

            // setting type to null, in fact the documentation is wrong here and this type is never used
            convertedValue = converter.convert(null, convertedValue);
        }
       
       
        return convertedValue;
    }
View Full Code Here

            Converter converter = (Converter)(converterMap.get(klass));
            if(null == converter) {
                throw new JellyTagException("Can't convert " + value + " to " + klass);
            } else {
                try {
                    return converter.convert(klass,value);
                } catch(ConversionException e) {
                    throw new JellyTagException("Can't convert " + value + " to " + klass + " (" + e.toString() + ")",e);
                }
            }
        } else {
View Full Code Here

            {
                throw new UnsupportedOperationException("cant deal with " + destType);
            }

            // setting type to null, in fact the documentation is wrong here and this type is never used
            convertedValue = converter.convert(null, convertedValue);
        }
       
       
        return convertedValue;
    }
View Full Code Here

        Double max     = new Double(Float.MAX_VALUE);
        Double tooBig  = new Double(Double.MAX_VALUE);

        // Maximum
        assertEquals("Maximum", new Float(Float.MAX_VALUE), converter.convert(clazz, max));

        // Too Large
        try {
            assertEquals("Too Big", null, converter.convert(clazz, tooBig));
            fail("More than maximum, expected ConversionException");
View Full Code Here

        // Maximum
        assertEquals("Maximum", new Float(Float.MAX_VALUE), converter.convert(clazz, max));

        // Too Large
        try {
            assertEquals("Too Big", null, converter.convert(clazz, tooBig));
            fail("More than maximum, expected ConversionException");
        } catch (Exception e) {
            // expected result
        }
    }
View Full Code Here

        Long max         = new Long(Short.MAX_VALUE);
        Long minMinusOne = new Long(min.longValue() - 1);
        Long maxPlusOne  = new Long(max.longValue() + 1);

        // Minimum
        assertEquals("Minimum", new Short(Short.MIN_VALUE), converter.convert(clazz, min));

        // Maximum
        assertEquals("Maximum", new Short(Short.MAX_VALUE), converter.convert(clazz, max));

        // Too Small
View Full Code Here

        // Minimum
        assertEquals("Minimum", new Short(Short.MIN_VALUE), converter.convert(clazz, min));

        // Maximum
        assertEquals("Maximum", new Short(Short.MAX_VALUE), converter.convert(clazz, max));

        // Too Small
        try {
            assertEquals("Minimum - 1", null, converter.convert(clazz, minMinusOne));
            fail("Less than minimum, expected ConversionException");
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.