Package org.apache.tapestry.ioc

Examples of org.apache.tapestry.ioc.MessageFormatter


    @SuppressWarnings("unchecked")
    @Test
    public void blank_value_skipped() throws Exception
    {
        Field field = mockField();
        MessageFormatter formatter = mockMessageFormatter();
        Validator validator = mockValidator();

        train_invokeIfBlank(validator, false);

        replay();
View Full Code Here


    @SuppressWarnings("unchecked")
    @Test
    public void nonmatching_value_type_skipped() throws Exception
    {
        Field field = mockField();
        MessageFormatter formatter = mockMessageFormatter();
        Validator validator = mockValidator();
        Integer value = 15;

        train_invokeIfBlank(validator, true);
        train_getValueType(validator, String.class);
View Full Code Here

    @SuppressWarnings("unchecked")
    @Test
    public void value_type_check_skipped_for_null_values() throws Exception
    {
        Field field = mockField();
        MessageFormatter formatter = mockMessageFormatter();
        Validator validator = mockValidator();

        train_invokeIfBlank(validator, true);

        validator.validate(field, null, formatter, null);
View Full Code Here

    @Test
    public void message_formatter()
    {
        Messages messages = _source.getValidationMessages(Locale.ENGLISH);

        MessageFormatter formatter = messages.getFormatter("required");

        assertEquals(formatter.format("My Field"), "You must provide a value for My Field.");
    }
View Full Code Here

        }

        Object coercedConstraintValue = coerceConstraintValue(finalConstraintValue, validator
                .getConstraintType());

        MessageFormatter formatter = findMessageFormatter(overrideId, overrideMessages, locale, validatorType,
                                                          validator);

        return new FieldValidatorImpl(field, coercedConstraintValue, formatter, validator, _formSupport);
    }
View Full Code Here

    }

    @Test
    public void get_formatter()
    {
        MessageFormatter mf = _messages.getFormatter("result");

        assertEquals(mf.format("great"), "The result is 'great'.");
    }
View Full Code Here

    }

    @Test
    public void formatters_are_cached()
    {
        MessageFormatter mf1 = _messages.getFormatter("result");
        // Throw in a case-insensitive check:
        MessageFormatter mf2 = _messages.getFormatter("Result");

        assertSame(mf2, mf1);
    }
View Full Code Here

{
    @Test
    public void matching_pattern() throws Exception
    {
        Field field = mockField();
        MessageFormatter formatter = mockMessageFormatter();
        Pattern constraint = Pattern.compile("\\d{4}");

        replay();

        Regexp validator = new Regexp();
View Full Code Here

    @Test
    public void input_mismatch() throws Exception
    {
        String label = "My Field";
        Field field = mockFieldWithLabel(label);
        MessageFormatter formatter = mockMessageFormatter();
        String message = "{message}";
        Pattern constraint = Pattern.compile("\\d{4}");
        String value = "abc";

        train_format(formatter, message, constraint.toString(), label);
View Full Code Here

{
    @Test
    public void null_value()
    {
        Field field = mockFieldWithLabel("My Field");
        MessageFormatter formatter = mockMessageFormatter();

        train_format(formatter, "{message}", "My Field");

        replay();
View Full Code Here

TOP

Related Classes of org.apache.tapestry.ioc.MessageFormatter

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.