Package org.apache.tapestry

Examples of org.apache.tapestry.Translator


    }

    @Test
    public void unknown_translator_is_failure()
    {
        Translator fred = mockTranslator();
        Translator barney = mockTranslator();

        train_getType(fred, Long.class);
        train_getType(barney, String.class);

        Map<String, Translator> configuration = CollectionFactory.newMap();
View Full Code Here


    }

    @Test(dataProvider = "to_client_data")
    public void to_client(Class type, Object value, String expected)
    {
        Translator t = _source.getByType(type);

        String actual = t.toClient(value);

        assertEquals(actual, expected);
    }
View Full Code Here

    }

    @Test(dataProvider = "parse_client_success_data")
    public void parse_client(Class type, String input, Object expected) throws Exception
    {
        Translator t = _source.getByType(type);

        Object actual = t.parseClient(input, _messagesSource.getValidationMessages(Locale.ENGLISH));

        assertEquals(actual, expected);
    }
View Full Code Here

    @Test(dataProvider = "parse_client_failure_data")
    public void parse_client_failure(Class type, String input, String expectedMessage)
    {

        Translator t = _source.getByType(type);

        try
        {
            t.parseClient(input, _messagesSource.getValidationMessages(Locale.ENGLISH));
            unreachable();
        }
        catch (ValidationException ex)
        {
            assertEquals(ex.getMessage(), expectedMessage);
View Full Code Here

    }

    @Test
    public void find_by_type()
    {
        Translator t = mockTranslator();
        Map<String, Translator> configuration = CollectionFactory.newMap();

        configuration.put("string", t);

        train_getType(t, String.class);
View Full Code Here

    }

    @Test
    public void get_by_type_not_found()
    {
        Translator string = mockTranslator();
        Translator bool = mockTranslator();

        Map<String, Translator> configuration = CollectionFactory.newMap();

        configuration.put("string", string);
        configuration.put("boolean", bool);
View Full Code Here

    }

    @Test
    public void translate_binding()
    {
        Translator translator = newTranslator();
        TranslatorSource source = newMock(TranslatorSource.class);
        ComponentResources resources = newComponentResources();
        Location l = newLocation();

        String description = "foo bar";
View Full Code Here

public class TranslatorSourceImplTest extends InternalBaseTestCase
{
    @Test
    public void found_translator_by_name()
    {
        Translator translator = newTranslator();

        Map<String, Translator> configuration = Collections.singletonMap("mock", translator);

        replay();
View Full Code Here

    }

    @Test
    public void unknown_translator_is_failure()
    {
        Translator fred = newTranslator();
        Translator barney = newTranslator();

        Map<String, Translator> configuration = CollectionFactory.newMap();

        configuration.put("fred", fred);
        configuration.put("barney", barney);
View Full Code Here

    }

    public Translator get(String name)
    {

        Translator result = _translators.get(name);

        if (result == null)
            throw new RuntimeException(ServicesMessages.unknownTranslatorType(name, InternalUtils
                    .sortedKeys(_translators)));
View Full Code Here

TOP

Related Classes of org.apache.tapestry.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.