Package org.apache.hivemind.schema

Examples of org.apache.hivemind.schema.Translator


    {
        MockControl moduleControl = newControl(Module.class);
        Module module = (Module) moduleControl.getMock();
       
        MockControl translatorControl = newControl(Translator.class);
        Translator translator = (Translator) translatorControl.getMock();

        MockControl paramsControl = newControl(ServiceImplementationFactoryParameters.class);
        ServiceImplementationFactoryParameters params = (ServiceImplementationFactoryParameters) paramsControl
                .getMock();
       
        MockControl tmControl = newControl(TranslatorManager.class);
        TranslatorManager tm = (TranslatorManager) tmControl.getMock();

        BuilderPropertyFacet facet = new BuilderPropertyFacet();

        facet.setTranslator("foo");
        facet.setValue("bar");

        params.getInvokingModule();
        paramsControl.setDefaultReturnValue(module);

        module.getService(TranslatorManager.class);
        moduleControl.setReturnValue(tm);

        tm.getTranslator("foo");
        tmControl.setReturnValue(translator);

        translator.translate(module, Object.class, "bar", null);
        ApplicationRuntimeException exception = new ApplicationRuntimeException("");
        translatorControl.setThrowable(exception);

        replayControls();
View Full Code Here


     * Uses the translator to convert the specified attribute into an object and pushes
     * that object onto the processor stack.
     */
    public void begin(SchemaProcessor processor, Element element)
    {
        Translator t = processor.getAttributeTranslator(_attributeName);

        String attributeValue = element.getAttributeValue(_attributeName);

        Object finalValue =
            t.translate(
                processor.getContributingModule(),
                Object.class,
                attributeValue,
                element.getLocation());

View Full Code Here

        m.getServicePoint("Fred");
        control.setReturnValue(sp);

        replayControls();

        Translator t = new ServicePointTranslator();

        ServicePoint result = (ServicePoint) t.translate(m, null, "Fred", null);

        assertSame(sp, result);

        verifyControls();
    }
View Full Code Here

    /**
     * Test a primitive type (int).
     */
    public void testInt()
    {
        Translator t = new SmartTranslator();

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

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

        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

     * 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

    }

    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

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.