Package org.apache.hivemind.schema

Examples of org.apache.hivemind.schema.Translator


        assertEquals(new Integer(-37), result);
    }

    public void testNullInput()
    {
        Translator t = new SmartTranslator();

        assertNull(t.translate(null, int.class, null, null));
    }
View Full Code Here


        assertNull(t.translate(null, int.class, null, null));
    }

    public void testBlankInput()
    {
        Translator t = new SmartTranslator();

        assertEquals("", t.translate(null, String.class, "", null));
    }
View Full Code Here

        assertEquals("", t.translate(null, String.class, "", null));
    }

    public void testDefault()
    {
        Translator t = new SmartTranslator("default=100");

        Object result = t.translate(null, int.class, null, null);

        assertEquals(new Integer(100), result);
    }
View Full Code Here

    /**
     * Test a wrapper type (Double).
     */
    public void testDouble()
    {
        Translator t = new SmartTranslator();

        Object result = t.translate(null, Double.class, "3.14", null);

        assertEquals(new Double("3.14"), result);
    }
View Full Code Here

    /**
     * Test with a String value (apparently, this doesn't always work, see bug HIVEMIND-15).
     */
    public void testString()
    {
        Translator t = new SmartTranslator();

        Object result = t.translate(null, String.class, "Fluffy Puppies", null);

        assertEquals("Fluffy Puppies", result);
    }
View Full Code Here

     * The input value should be returned as is (i.e. as a String) when the property type is Object
     * (see HIVEMIND-15).
     */
    public void testObjectAsString()
    {
        Translator t = new SmartTranslator();

        Object result = t.translate(null, Object.class, "Fluffy Puppies", null);

        assertEquals("Fluffy Puppies", result);
    }
View Full Code Here

    public void testStringWithNoEditor()
    {
        PropertyEditorManager.setEditorSearchPath(new String[]
        { "bogus.package" });
        Translator t = new SmartTranslator();

        Object result = t.translate(null, String.class, "Fluffy Puppies", null);

        assertEquals("Fluffy Puppies", result);
    }
View Full Code Here

        assertEquals("Fluffy Puppies", result);
    }

    public void testNoEditor()
    {
        Translator t = new SmartTranslator();
        Location l = fabricateLocation(22);

        try
        {
            t.translate(null, Registry.class, "fred", l);

            unreachable();
        }
        catch (ApplicationRuntimeException ex)
        {
View Full Code Here

    private String _literalValue;

    public Object getFacetValue(ServiceImplementationFactoryParameters factoryParameters,
            Class targetType)
    {
        Translator translator = factoryParameters.getInvokingModule()
                .getTranslator(_translatorName);

        return translator.translate(
                factoryParameters.getInvokingModule(),
                targetType,
                _literalValue,
                getLocation());
    }
View Full Code Here

        m.expandSymbols("${flintstone}", null);
        control.setReturnValue("flintstone");

        MockControl tControl = newControl(Translator.class);
        Translator t = (Translator) tControl.getMock();

        m.getTranslator("cartoon");
        control.setReturnValue(t);

        Object flintstoneKey = new Object();
        t.translate(m, Object.class, "flintstone", element.getLocation());
        tControl.setReturnValue(flintstoneKey);

        replayControls();

        p.process(elements, m);
View Full Code Here

TOP

Related Classes of org.apache.hivemind.schema.Translator

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.