Search in sources :

Example 26 with ComponentPageElement

use of org.apache.tapestry5.internal.structure.ComponentPageElement 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 27 with ComponentPageElement

use of org.apache.tapestry5.internal.structure.ComponentPageElement 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)

Example 28 with ComponentPageElement

use of org.apache.tapestry5.internal.structure.ComponentPageElement in project tapestry-5 by apache.

the class PageImplTest method accessor_methods.

@Test
public void accessor_methods() {
    ComponentPageElement root = mockComponentPageElement();
    ComponentResourceSelector selector = new ComponentResourceSelector(Locale.ENGLISH);
    MetaDataLocator locator = newMetaDataLocator(LOGICAL_PAGE_NAME, true);
    replay();
    Page page = new PageImpl(LOGICAL_PAGE_NAME, selector, null, perThreadManager, locator);
    assertNull(page.getRootElement());
    page.setRootElement(root);
    assertSame(page.getSelector(), selector);
    assertSame(page.getRootElement(), root);
    assertSame(page.getName(), LOGICAL_PAGE_NAME);
    assertTrue(page.isExactParameterCountMatch());
    verify();
}
Also used : ComponentResourceSelector(org.apache.tapestry5.services.pageload.ComponentResourceSelector) MetaDataLocator(org.apache.tapestry5.services.MetaDataLocator) Test(org.testng.annotations.Test)

Example 29 with ComponentPageElement

use of org.apache.tapestry5.internal.structure.ComponentPageElement in project tapestry-5 by apache.

the class PageImplTest method get_by_nested_id_for_blank_value_returns_root_component.

@Test
public void get_by_nested_id_for_blank_value_returns_root_component() {
    ComponentPageElement root = mockComponentPageElement();
    MetaDataLocator locator = newMetaDataLocator(LOGICAL_PAGE_NAME, true);
    replay();
    Page page = new PageImpl(LOGICAL_PAGE_NAME, selector, null, perThreadManager, locator);
    page.setRootElement(root);
    assertSame(page.getComponentElementByNestedId(""), root);
    verify();
}
Also used : MetaDataLocator(org.apache.tapestry5.services.MetaDataLocator) Test(org.testng.annotations.Test)

Aggregations

Test (org.testng.annotations.Test)13 ComponentModel (org.apache.tapestry5.model.ComponentModel)11 ComponentPageElement (org.apache.tapestry5.internal.structure.ComponentPageElement)10 Page (org.apache.tapestry5.internal.structure.Page)10 InternalComponentResources (org.apache.tapestry5.internal.InternalComponentResources)8 Instantiator (org.apache.tapestry5.internal.services.Instantiator)8 Component (org.apache.tapestry5.runtime.Component)8 Binding (org.apache.tapestry5.Binding)7 TapestryException (org.apache.tapestry5.commons.internal.util.TapestryException)5 InternalPropBinding (org.apache.tapestry5.internal.bindings.InternalPropBinding)4 LiteralBinding (org.apache.tapestry5.internal.bindings.LiteralBinding)4 ComponentEventCallback (org.apache.tapestry5.ComponentEventCallback)3 ComponentResources (org.apache.tapestry5.ComponentResources)3 MarkupWriter (org.apache.tapestry5.MarkupWriter)3 UnknownValueException (org.apache.tapestry5.commons.util.UnknownValueException)3 EmbeddedComponentModel (org.apache.tapestry5.model.EmbeddedComponentModel)3 ComponentEventResultProcessor (org.apache.tapestry5.services.ComponentEventResultProcessor)3 MetaDataLocator (org.apache.tapestry5.services.MetaDataLocator)3 TrackableComponentEventCallback (org.apache.tapestry5.TrackableComponentEventCallback)2 Location (org.apache.tapestry5.commons.Location)2