Search in sources :

Example 16 with Instantiator

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();
}
Also used : Binding(org.apache.tapestry5.Binding) InternalPropBinding(org.apache.tapestry5.internal.bindings.InternalPropBinding) InternalComponentResources(org.apache.tapestry5.internal.InternalComponentResources) ComponentModel(org.apache.tapestry5.model.ComponentModel) Instantiator(org.apache.tapestry5.internal.services.Instantiator) Component(org.apache.tapestry5.runtime.Component) MarkupWriter(org.apache.tapestry5.MarkupWriter) Test(org.testng.annotations.Test)

Example 17 with Instantiator

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();
}
Also used : ComponentModel(org.apache.tapestry5.model.ComponentModel) Instantiator(org.apache.tapestry5.internal.services.Instantiator) Component(org.apache.tapestry5.runtime.Component) InternalComponentResources(org.apache.tapestry5.internal.InternalComponentResources) ComponentResources(org.apache.tapestry5.ComponentResources) Test(org.testng.annotations.Test)

Example 18 with Instantiator

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();
}
Also used : ComponentModel(org.apache.tapestry5.model.ComponentModel) Instantiator(org.apache.tapestry5.internal.services.Instantiator) Component(org.apache.tapestry5.runtime.Component) InternalComponentResources(org.apache.tapestry5.internal.InternalComponentResources) ComponentResources(org.apache.tapestry5.ComponentResources) Test(org.testng.annotations.Test)

Example 19 with Instantiator

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();
}
Also used : InternalPropBinding(org.apache.tapestry5.internal.bindings.InternalPropBinding) InternalComponentResources(org.apache.tapestry5.internal.InternalComponentResources) ComponentModel(org.apache.tapestry5.model.ComponentModel) Instantiator(org.apache.tapestry5.internal.services.Instantiator) Component(org.apache.tapestry5.runtime.Component) Test(org.testng.annotations.Test)

Aggregations

Instantiator (org.apache.tapestry5.internal.services.Instantiator)15 InternalComponentResources (org.apache.tapestry5.internal.InternalComponentResources)11 ComponentModel (org.apache.tapestry5.model.ComponentModel)11 Component (org.apache.tapestry5.runtime.Component)10 Test (org.testng.annotations.Test)9 InternalPropBinding (org.apache.tapestry5.internal.bindings.InternalPropBinding)4 Method (java.lang.reflect.Method)3 Binding (org.apache.tapestry5.Binding)3 MarkupWriter (org.apache.tapestry5.MarkupWriter)3 Map (java.util.Map)2 ComponentResources (org.apache.tapestry5.ComponentResources)2 TapestryException (org.apache.tapestry5.commons.internal.util.TapestryException)2 EmbeddedComponentModel (org.apache.tapestry5.model.EmbeddedComponentModel)2 PlasticClass (org.apache.tapestry5.plastic.PlasticClass)2 PlasticClassTransformer (org.apache.tapestry5.plastic.PlasticClassTransformer)2 PlasticField (org.apache.tapestry5.plastic.PlasticField)2 IFn (clojure.lang.IFn)1 Symbol (clojure.lang.Symbol)1 Namespace (org.apache.tapestry5.clojure.Namespace)1 TypeCoercer (org.apache.tapestry5.commons.services.TypeCoercer)1