use of org.apache.tapestry5.services.BeanBlockSource in project tapestry-5 by apache.
the class PropertyEditorTest method no_editor_block_available.
@Test
public void no_editor_block_available() {
PropertyModel model = mockPropertyModel();
PropertyOverrides overrides = mockPropertyOverrides();
ComponentResources resources = mockComponentResources();
BeanBlockSource source = newMock(BeanBlockSource.class);
RuntimeException exception = new RuntimeException("Simulated failure.");
Messages messages = mockMessages();
Location l = mockLocation();
String propertyId = "foo";
String dataType = "unk";
String propertyName = "fooProp";
Object object = "[OBJECT]";
String formattedMessage = "formatted-message";
expect(model.getId()).andReturn(propertyId);
train_getOverrideBlock(overrides, propertyId, null);
expect(model.getDataType()).andReturn(dataType);
expect(source.getEditBlock(dataType)).andThrow(exception);
expect(model.getPropertyName()).andReturn(propertyName);
train_getLocation(resources, l);
expect(messages.format("core-block-error", propertyName, dataType, object, exception)).andReturn(formattedMessage);
replay();
PropertyEditor pe = new PropertyEditor();
pe.inject(resources, overrides, model, source, messages, object);
try {
pe.beginRender();
unreachable();
} catch (TapestryException ex) {
assertEquals(ex.getMessage(), formattedMessage);
assertSame(ex.getLocation(), l);
}
}
use of org.apache.tapestry5.services.BeanBlockSource in project tapestry-5 by apache.
the class BeanBlockSourceImplTest method edit_block_not_found.
@Test
public void edit_block_not_found() {
RequestPageCache cache = mockRequestPageCache();
Collection<BeanBlockContribution> configuration = newList();
replay();
BeanBlockSource source = new BeanBlockSourceImpl(cache, createBeanBlockOverrideSource(cache), configuration);
try {
source.getEditBlock("MyData");
unreachable();
} catch (RuntimeException ex) {
assertEquals(ex.getMessage(), "There is no defined way to edit data of type \'MyData\'. Make a contribution to the BeanBlockSource service for this type.");
}
verify();
}
Aggregations