Package org.apache.tapestry5.ioc.services

Examples of org.apache.tapestry5.ioc.services.TypeCoercer.coerce()


            Coercion c = getCoercion(sourceType);

            try
            {
                return type.cast(c.coerce(input));
            } catch (Exception ex)
            {
                throw new RuntimeException(ServiceMessages.failedCoercion(input, type, c, ex), ex);
            }
        }
View Full Code Here


        Object result;

        try
        {
            result = coercion.coerce(input);
        }
        catch (Exception ex)
        {
            throw new RuntimeException(ServiceMessages.failedCoercion(
                    input,
View Full Code Here

        assertSame(coercer.coerce(input, Number.class), input);

        Coercion coercion = coercer.getCoercion(int.class, Number.class);

        assertSame(coercion.coerce(input), input);
    }

    @Test
    public void explain_to_same_type()
    {
View Full Code Here

        assertEquals(actual, expected);

        Coercion c = coercer.getCoercion(input == null ? void.class : input.getClass(), targetType);

        assertEquals(c.coerce(input), expected);
    }

    @SuppressWarnings("unchecked")
    @DataProvider
    public Object[][] coercions_inputs()
View Full Code Here

            Coercion c = getCoercion(sourceType);

            try
            {
                return type.cast(c.coerce(input));
            }
            catch (Exception ex)
            {
                throw new RuntimeException(ServiceMessages.failedCoercion(input, type, c, ex), ex);
            }
View Full Code Here

            Coercion c = getCoercion(sourceType);

            try
            {
                return type.cast(c.coerce(input));
            } catch (Exception ex)
            {
                throw new RuntimeException(ServiceMessages.failedCoercion(input, type, c, ex), ex);
            }
        }
View Full Code Here

        // Force the state of a few services.

        TypeCoercer tc = r.getService("TypeCoercer", TypeCoercer.class);

        tc.coerce("123", Integer.class);

        r.getService("BlueGreeter", Greeter.class);

        // Now get the activity list and poke around.
View Full Code Here

    @Test
    public void string_to_select_model_type_coercion_integration()
    {
        TypeCoercer coercer = getService(TypeCoercer.class);

        SelectModel selectModel = coercer.coerce(" UK , USA , DE=Germany ", SelectModel.class);

        assertNull(selectModel.getOptionGroups());
        assertEquals(selectModel.getOptions().size(), 3);

        // Waste of effort to re-test each individual option model.
View Full Code Here

    {
        TypeCoercer coercer = getObject(TypeCoercer.class, null);

        String input = "\\s+";

        Pattern pattern = coercer.coerce(input, Pattern.class);

        assertEquals(pattern.toString(), input);
    }

    @Test
View Full Code Here

        TypeCoercer coercer = getObject(TypeCoercer.class, null);

        replay();

        ComponentResources actual = coercer.coerce(input, ComponentResources.class);

        assertSame(actual, resources);

        verify();
    }
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.