Package org.apache.tapestry5

Examples of org.apache.tapestry5.PropertyConduit


        return false;
    }

    Object readPropertyForObject()
    {
        PropertyConduit conduit = model.getConduit();

        try
        {
            return conduit == null ? null : conduit.get(object);
        }
        catch (final NullPointerException ex)
        {
            throw new NullPointerException(BaseMessages.nullValueInPath(model.getPropertyName()));
        }
View Full Code Here


        assertEquals(firstName.getPropertyType(), String.class);
        assertEquals(firstName.getDataType(), "text");

        assertEquals(model.get("lastName").getLabel(), "Last Name");

        PropertyConduit conduit = model.get("lastName").getConduit();

        SimpleBean instance = new SimpleBean();

        instance.setLastName("Lewis Ship");

        assertEquals(conduit.get(instance), "Lewis Ship");

        conduit.set(instance, "TapestryDude");

        assertEquals(instance.getLastName(), "TapestryDude");

        // Now, one with some type coercion.
View Full Code Here

    @Test
    public void add_before()
    {
        Messages messages = mockMessages();
        PropertyConduit conduit = mockPropertyConduit();

        Class propertyType = String.class;

        stub_contains(messages, false);

        expect(conduit.getPropertyType()).andReturn(propertyType).atLeastOnce();
        expect(conduit.getAnnotation(EasyMock.isA(Class.class))).andStubReturn(null);

        replay();

        BeanModel model = source.create(SimpleBean.class, true, messages);
View Full Code Here

    @Test
    public void add_after()
    {
        Messages messages = mockMessages();
        PropertyConduit conduit = mockPropertyConduit();

        Class propertyType = String.class;

        stub_contains(messages, false);

        expect(conduit.getPropertyType()).andReturn(propertyType).atLeastOnce();

        expect(conduit.getAnnotation(EasyMock.isA(Class.class))).andStubReturn(null);

        replay();

        BeanModel model = source.create(SimpleBean.class, true, messages);
View Full Code Here

        String[] value =
                {"foo", "bar"};

        StringArrayBean bean = new StringArrayBean();

        PropertyConduit conduit = propertyModel.getConduit();

        conduit.set(bean, value);

        assertSame(bean.getArray(), value);

        assertSame(conduit.get(bean), value);

        verify();
    }
View Full Code Here

    }

    @Test
    public void literal_conduits_have_invariant_annotation()
    {
        PropertyConduit pc = source.create(CompositeBean.class, "12345");

        Invariant annotation = pc.getAnnotation(Invariant.class);

        assertNotNull(annotation);

        assertSame(annotation.annotationType(), Invariant.class);
    }
View Full Code Here

    }

    @Test
    public void range_variable_to()
    {
        PropertyConduit pc = source.create(IntegerHolder.class, "10..value");
        IntegerHolder h = new IntegerHolder();

        h.setValue(5);

        IntegerRange ir = (IntegerRange) pc.get(h);

        assertEquals(ir, new IntegerRange(10, 5));
    }
View Full Code Here

    }

    @Test
    public void range_variable_from()
    {
        PropertyConduit pc = source.create(IntegerHolder.class, "value..99");
        IntegerHolder h = new IntegerHolder();

        h.setValue(72);

        IntegerRange ir = (IntegerRange) pc.get(h);

        assertEquals(ir, new IntegerRange(72, 99));
    }
View Full Code Here

    }

    @Test
    public void literal_conduits_are_not_updateable()
    {
        PropertyConduit pc = source.create(CompositeBean.class, "12345");
        CompositeBean bean = new CompositeBean();

        try
        {
            pc.set(bean, 42);
            unreachable();
        } catch (RuntimeException ex)
        {
            assertEquals(ex.getMessage(), "Literal values are not updateable.");
        }
View Full Code Here

    }

    @Test
    public void this_literal_conduit_is_not_updateable()
    {
        PropertyConduit normal = source.create(CompositeBean.class, "this");
        CompositeBean bean = new CompositeBean();

        try
        {
            normal.set(bean, 42);
            unreachable();
        } catch (RuntimeException ex)
        {
            assertEquals(ex.getMessage(), "Literal values are not updateable.");
        }
View Full Code Here

TOP

Related Classes of org.apache.tapestry5.PropertyConduit

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.