use of org.apache.tapestry5.internal.services.Instantiator in project tapestry-5 by apache.
the class InternalComponentResourcesImplTest method render_an_informal_parameter.
@Test
public void render_an_informal_parameter() {
ComponentPageElement element = mockComponentPageElement();
Component component = mockComponent();
Instantiator ins = mockInstantiator(component);
MarkupWriter writer = mockMarkupWriter();
ComponentModel model = mockComponentModel();
Binding binding = mockBinding();
Object rawValue = new Long(97);
train_getModel(ins, model);
train_getParameterModel(model, "fred", null);
train_get(binding, rawValue);
writer.attributes("fred", "97");
replay();
InternalComponentResources resources = new InternalComponentResourcesImpl(null, element, null, elementResources, "Foo.bar", null, ins, false);
resources.bindParameter("fred", binding);
resources.renderInformalParameters(writer);
verify();
}
use of org.apache.tapestry5.internal.services.Instantiator in project tapestry-5 by apache.
the class InternalComponentResourcesImplTest method get_render_variable_exists.
@Test
public void get_render_variable_exists() {
Component component = mockComponent();
Instantiator ins = mockInstantiator(component);
ComponentModel model = mockComponentModel();
Object value = new Object();
train_getModel(ins, model);
replay();
ComponentResources resources = new InternalComponentResourcesImpl(null, null, null, elementResources, "id", null, ins, false);
resources.storeRenderVariable("myRenderVar", value);
assertSame(resources.getRenderVariable("myrendervar"), value);
verify();
}
use of org.apache.tapestry5.internal.services.Instantiator in project tapestry-5 by apache.
the class InternalComponentResourcesImplTest method get_render_variable_missing.
@Test
public void get_render_variable_missing() {
Component component = mockComponent();
Instantiator ins = mockInstantiator(component);
ComponentModel model = mockComponentModel();
train_getModel(ins, model);
replay();
ComponentResources resources = new InternalComponentResourcesImpl(null, null, null, elementResources, "Foo.bar", null, ins, false);
resources.storeRenderVariable("fred", "FRED");
resources.storeRenderVariable("barney", "BARNEY");
try {
resources.getRenderVariable("wilma");
unreachable();
} catch (IllegalArgumentException ex) {
assertEquals(ex.getMessage(), "Component Foo.bar does not contain a stored render variable with name 'wilma'. Stored render variables: barney, fred.");
}
verify();
}
use of org.apache.tapestry5.internal.services.Instantiator in project tapestry-5 by apache.
the class InternalComponentResourcesImplTest method get_property_name_internal_prop_binding.
@Test
public void get_property_name_internal_prop_binding() {
Component component = mockComponent();
Instantiator ins = mockInstantiator(component);
ComponentModel model = mockComponentModel();
ComponentPageElement element = mockComponentPageElement();
Page page = mockPage();
InternalPropBinding binding = newMock(InternalPropBinding.class);
train_getModel(ins, model);
expect(binding.getPropertyName()).andReturn("foo");
replay();
InternalComponentResources resources = new InternalComponentResourcesImpl(page, element, null, null, null, null, ins, false);
resources.bindParameter("bar", binding);
assertEquals(resources.getPropertyName("bar"), "foo");
verify();
}
Aggregations