Package org.apache.commons.beanutils

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


     * Test Conversion to Character
     */
    public void testConvertToCharacter() {
        Converter converter = new CharacterConverter();
        assertEquals("Character Test", new Character('N'), converter.convert(Character.class, new Character('N')));
        assertEquals("String Test",    new Character('F'), converter.convert(Character.class, "FOO"));
        assertEquals("Integer Test",   new Character('3'), converter.convert(Character.class, new Integer(321)));
        try {
            converter.convert(Character.class, null);
            fail("Expected a ConversionException for null value");
        } catch (Exception e) {
View Full Code Here


     */
    public void testConvertToCharacter() {
        Converter converter = new CharacterConverter();
        assertEquals("Character Test", new Character('N'), converter.convert(Character.class, new Character('N')));
        assertEquals("String Test",    new Character('F'), converter.convert(Character.class, "FOO"));
        assertEquals("Integer Test",   new Character('3'), converter.convert(Character.class, new Integer(321)));
        try {
            converter.convert(Character.class, null);
            fail("Expected a ConversionException for null value");
        } catch (Exception e) {
            // expected result
View Full Code Here

        Converter converter = new CharacterConverter();
        assertEquals("Character Test", new Character('N'), converter.convert(Character.class, new Character('N')));
        assertEquals("String Test",    new Character('F'), converter.convert(Character.class, "FOO"));
        assertEquals("Integer Test",   new Character('3'), converter.convert(Character.class, new Integer(321)));
        try {
            converter.convert(Character.class, null);
            fail("Expected a ConversionException for null value");
        } catch (Exception e) {
            // expected result
        }
    }
View Full Code Here

    /**
     * Test Conversion to Character (with default)
     */
    public void testDefault() {
        Converter converter = new CharacterConverter("C");
        assertEquals("Default Test",   new Character('C'), converter.convert(Character.class, null));
    }
}
View Full Code Here

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

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

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

        // Too Small
View Full Code Here

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

        // Maximum
        assertEquals("Maximum", new Byte(Byte.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

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

        // Too Small
        try {
            assertEquals("Minimum - 1", null, converter.convert(clazz, minMinusOne));
            fail("Less than minimum, expected ConversionException");
        } catch (Exception e) {
            // expected result
        }
View Full Code Here

            // expected result
        }

        // Too Large
        try {
            assertEquals("Maximum + 1", null, converter.convert(clazz, maxPlusOne));
            fail("More than maximum, expected ConversionException");
        } catch (Exception e) {
            // expected result
        }
    }
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

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.