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