Search in sources :

Example 16 with ComponentResources

use of org.apache.tapestry5.ComponentResources in project tapestry-5 by apache.

the class PropBindingFactoryTest method object_property.

@Test
public void object_property() {
    TargetBean bean = new TargetBean();
    ComponentResources resources = newComponentResources(bean);
    Location l = mockLocation();
    replay();
    Binding binding = factory.newBinding("test binding", resources, null, "objectValue", l);
    assertSame(binding.getBindingType(), String.class);
    bean.setObjectValue("first");
    assertEquals(binding.get(), "first");
    binding.set("second");
    assertEquals(bean.getObjectValue(), "second");
    assertEquals(InternalUtils.locationOf(binding), l);
    assertEquals(binding.toString(), "PropBinding[test binding foo.Bar:baz(objectValue)]");
    verify();
}
Also used : Binding(org.apache.tapestry5.Binding) ComponentResources(org.apache.tapestry5.ComponentResources) Location(org.apache.tapestry5.commons.Location) Test(org.testng.annotations.Test)

Example 17 with ComponentResources

use of org.apache.tapestry5.ComponentResources in project tapestry-5 by apache.

the class PropBindingFactoryTest method property_path_through_missing_property.

@Test
public void property_path_through_missing_property() {
    TargetBean bean = new TargetBean();
    ComponentResources resources = mockComponentResources();
    Location l = mockLocation();
    train_getComponent(resources, bean);
    replay();
    String propertyPath = "stringHolder.missingProperty.terminalProperty";
    try {
        factory.newBinding("test binding", resources, null, propertyPath, l);
        unreachable();
    } catch (RuntimeException ex) {
        assertMessageContains(ex, "Class org.apache.tapestry5.internal.bindings.StringHolder does not contain a property", "\'missingProperty\'");
    }
    verify();
}
Also used : ComponentResources(org.apache.tapestry5.ComponentResources) Location(org.apache.tapestry5.commons.Location) Test(org.testng.annotations.Test)

Example 18 with ComponentResources

use of org.apache.tapestry5.ComponentResources in project tapestry-5 by apache.

the class PropBindingFactoryTest method annotation_from_write_only_property.

@Test
public void annotation_from_write_only_property() {
    TargetBean bean = new TargetBean();
    ComponentResources resources = newComponentResources(bean);
    Location l = mockLocation();
    replay();
    Binding binding = factory.newBinding("test binding", resources, null, "writeOnly", l);
    assertEquals(binding.getAnnotation(Validate.class).value(), "writeonly");
    verify();
}
Also used : Binding(org.apache.tapestry5.Binding) ComponentResources(org.apache.tapestry5.ComponentResources) Location(org.apache.tapestry5.commons.Location) Test(org.testng.annotations.Test)

Example 19 with ComponentResources

use of org.apache.tapestry5.ComponentResources in project tapestry-5 by apache.

the class PropBindingFactoryTest method annotation_does_not_exist.

@Test
public void annotation_does_not_exist() {
    TargetBean bean = new TargetBean();
    ComponentResources resources = newComponentResources(bean);
    Location l = mockLocation();
    replay();
    Binding binding = factory.newBinding("test binding", resources, null, "intValue", l);
    assertNull(binding.getAnnotation(Validate.class));
    verify();
}
Also used : Binding(org.apache.tapestry5.Binding) Validate(org.apache.tapestry5.beaneditor.Validate) ComponentResources(org.apache.tapestry5.ComponentResources) Location(org.apache.tapestry5.commons.Location) Test(org.testng.annotations.Test)

Example 20 with ComponentResources

use of org.apache.tapestry5.ComponentResources in project tapestry-5 by apache.

the class PropBindingFactoryTest method unknown_property.

@Test
public void unknown_property() {
    TargetBean bean = new TargetBean();
    ComponentResources resources = mockComponentResources();
    Location l = mockLocation();
    train_getComponent(resources, bean);
    replay();
    try {
        factory.newBinding("test binding", resources, null, "missingProperty", l);
        unreachable();
    } catch (RuntimeException ex) {
        assertMessageContains(ex, "Class org.apache.tapestry5.internal.bindings.TargetBean does not contain a property", "\'missingProperty\'");
    }
    verify();
}
Also used : ComponentResources(org.apache.tapestry5.ComponentResources) Location(org.apache.tapestry5.commons.Location) Test(org.testng.annotations.Test)

Aggregations

ComponentResources (org.apache.tapestry5.ComponentResources)110 Test (org.testng.annotations.Test)99 Location (org.apache.tapestry5.commons.Location)34 Binding (org.apache.tapestry5.Binding)24 Messages (org.apache.tapestry5.commons.Messages)24 ComponentModel (org.apache.tapestry5.model.ComponentModel)17 FormSupport (org.apache.tapestry5.services.FormSupport)17 TapestryException (org.apache.tapestry5.commons.internal.util.TapestryException)16 Component (org.apache.tapestry5.runtime.Component)15 MarkupWriter (org.apache.tapestry5.MarkupWriter)14 FieldValidator (org.apache.tapestry5.FieldValidator)13 TypeCoercer (org.apache.tapestry5.commons.services.TypeCoercer)13 FieldValidatorSource (org.apache.tapestry5.services.FieldValidatorSource)13 Validator (org.apache.tapestry5.Validator)11 ValidatorMacro (org.apache.tapestry5.validator.ValidatorMacro)11 MessageFormatter (org.apache.tapestry5.commons.MessageFormatter)10 BindingFactory (org.apache.tapestry5.services.BindingFactory)10 PropertyOverrides (org.apache.tapestry5.PropertyOverrides)9 MetaDataLocator (org.apache.tapestry5.services.MetaDataLocator)9 Request (org.apache.tapestry5.http.services.Request)7