use of org.apache.tapestry5.ioc.annotations.Value in project tapestry-5 by apache.
the class AbstractBeanModelSourceImplTest method array_type_bean.
@Test
public void array_type_bean() {
Messages messages = mockMessages();
stub_contains(messages, false);
replay();
BeanModel model = source.create(StringArrayBean.class, true, messages);
// There's not editor for string arrays yet, so it won't show up normally.
PropertyModel propertyModel = model.add("array");
assertSame(propertyModel.getPropertyType(), String[].class);
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();
}
use of org.apache.tapestry5.ioc.annotations.Value in project tapestry-5 by apache.
the class AbstractBeanModelSourceImplTest method filtering_out_read_only_properties.
@Test
public void filtering_out_read_only_properties() {
Messages messages = mockMessages();
stub_contains(messages, false);
replay();
BeanModel model = source.create(ReadOnlyBean.class, true, messages);
assertEquals(model.getPropertyNames(), Arrays.asList("value"));
model = source.create(ReadOnlyBean.class, false, messages);
assertEquals(model.getPropertyNames(), Arrays.asList("value", "readOnly"));
verify();
}
use of org.apache.tapestry5.ioc.annotations.Value in project tapestry-5 by apache.
the class ClientPersistentFieldStorageImplTest method store_and_restore_a_change.
@SuppressWarnings("unchecked")
@Test
public void store_and_restore_a_change() {
Request request = mockRequest(null);
Link link = mockLink();
String pageName = "Foo";
String componentId = "bar.baz";
String fieldName = "biff";
Object value = 99;
final Holder<String> holder = captureLinkModification(link);
replay();
ClientPersistentFieldStorage storage1 = new ClientPersistentFieldStorageImpl(request, clientDataEncoder, analyzer);
storage1.postChange(pageName, componentId, fieldName, value);
List<PersistentFieldChange> changes1 = newList(storage1.gatherFieldChanges(pageName));
storage1.updateLink(link);
verify();
assertEquals(changes1.size(), 1);
PersistentFieldChange change1 = changes1.get(0);
assertEquals(change1.getComponentId(), componentId);
assertEquals(change1.getFieldName(), fieldName);
assertEquals(change1.getValue(), value);
// Now more training ...
train_getParameter(request, ClientPersistentFieldStorageImpl.PARAMETER_NAME, holder.get());
replay();
ClientPersistentFieldStorage storage2 = new ClientPersistentFieldStorageImpl(request, clientDataEncoder, analyzer);
List<PersistentFieldChange> changes2 = newList(storage2.gatherFieldChanges(pageName));
verify();
assertEquals(changes2.size(), 1);
PersistentFieldChange change2 = changes2.get(0);
assertEquals(change2.getComponentId(), componentId);
assertEquals(change2.getFieldName(), fieldName);
assertEquals(change2.getValue(), value);
assertNotSame(change1, change2);
}
use of org.apache.tapestry5.ioc.annotations.Value in project tapestry-5 by apache.
the class PropBindingFactoryTest method void_method_in_preamble.
@Test
public void void_method_in_preamble() {
TargetBean bean = new TargetBean();
ComponentResources resources = mockComponentResources();
Location l = mockLocation();
train_getComponent(resources, bean);
replay();
try {
factory.newBinding("test binding", resources, null, "voidMethod().value", l);
unreachable();
} catch (RuntimeException ex) {
assertMessageContains(ex, "Method org.apache.tapestry5.internal.bindings.TargetBean.voidMethod() returns void");
}
verify();
}
use of org.apache.tapestry5.ioc.annotations.Value 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();
}
Aggregations