Package org.apache.commons.beanutils

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


    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


     * Tries a conversion to an unsupported target type.
     */
    public void testUnsupportedTargetType() {
        Converter converter = new ClassConverter();
        try {
            converter.convert(Integer.class, getClass().getName());
            fail("Invalid target class not detected!");
        } catch (ConversionException cex) {
            // expected result
        }
    }
View Full Code Here

     */
    public void testConvertToString() {

        Converter converter = new CharacterConverter();

        assertEquals("Character Test", "N", converter.convert(String.class, new Character('N')));
        assertEquals("String Test",    "F", converter.convert(String.class, "FOO"));
        assertEquals("Integer Test",   "3", converter.convert(String.class, new Integer(321)));
        assertEquals("Null Test",     null, converter.convert(String.class, null));
    }

View Full Code Here

    public void testConvertToString() {

        Converter converter = new CharacterConverter();

        assertEquals("Character Test", "N", converter.convert(String.class, new Character('N')));
        assertEquals("String Test",    "F", converter.convert(String.class, "FOO"));
        assertEquals("Integer Test",   "3", converter.convert(String.class, new Integer(321)));
        assertEquals("Null Test",     null, converter.convert(String.class, null));
    }

    /**
 
View Full Code Here

        Converter converter = new CharacterConverter();

        assertEquals("Character Test", "N", converter.convert(String.class, new Character('N')));
        assertEquals("String Test",    "F", converter.convert(String.class, "FOO"));
        assertEquals("Integer Test",   "3", converter.convert(String.class, new Integer(321)));
        assertEquals("Null Test",     null, converter.convert(String.class, null));
    }

    /**
     * Test Conversion to Character
View Full Code Here

        Converter converter = new CharacterConverter();

        assertEquals("Character Test", "N", converter.convert(String.class, new Character('N')));
        assertEquals("String Test",    "F", converter.convert(String.class, "FOO"));
        assertEquals("Integer Test",   "3", converter.convert(String.class, new Integer(321)));
        assertEquals("Null Test",     null, converter.convert(String.class, null));
    }

    /**
     * Test Conversion to Character
     */
 
View Full Code Here

    /**
     * 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)));
    }

    /**
 
View Full Code Here

     * 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)));
    }

    /**
     * Tests whether the primitive char class can be passed as target type.
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)));
    }

    /**
     * Tests whether the primitive char class can be passed as target type.
     */
 
View Full Code Here

    /**
     * Tests whether the primitive char class can be passed as target type.
     */
    public void testConvertToChar() {
        Converter converter = new CharacterConverter();
        assertEquals("Wrong result", new Character('F'), converter.convert(Character.TYPE, "FOO"));
    }

    /**
     * Tests a conversion to character for null input if no default value is
     * provided.
 
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.