Search in sources :

Example 1 with BeanBlockSource

use of org.apache.tapestry5.services.BeanBlockSource in project tapestry-5 by apache.

the class BeanBlockSourceImplTest method found_display_block_in_override.

@Test
public void found_display_block_in_override() {
    Block block = mockBlock();
    RequestPageCache cache = mockRequestPageCache();
    BeanBlockOverrideSource overrideSource = mockBeanBlockOverrideSource();
    String datatype = "MyData";
    expect(overrideSource.hasDisplayBlock(datatype)).andReturn(true);
    expect(overrideSource.getDisplayBlock(datatype)).andReturn(block);
    replay();
    BeanBlockSource source = new BeanBlockSourceImpl(cache, overrideSource, EMPTY_CONFIGURATION);
    // Check case insensitivity while we are at it.
    assertTrue(source.hasDisplayBlock(datatype));
    Block actual = source.getDisplayBlock(datatype);
    assertSame(actual, block);
    verify();
}
Also used : BeanBlockSource(org.apache.tapestry5.services.BeanBlockSource) BeanBlockOverrideSource(org.apache.tapestry5.services.BeanBlockOverrideSource) Block(org.apache.tapestry5.Block) Test(org.testng.annotations.Test)

Example 2 with BeanBlockSource

use of org.apache.tapestry5.services.BeanBlockSource in project tapestry-5 by apache.

the class BeanBlockSourceImplTest method found_edit_block_in_override.

@Test
public void found_edit_block_in_override() {
    Block block = mockBlock();
    RequestPageCache cache = mockRequestPageCache();
    BeanBlockOverrideSource overrideSource = mockBeanBlockOverrideSource();
    String datatype = "MyData";
    expect(overrideSource.getEditBlock(datatype)).andReturn(block);
    replay();
    BeanBlockSource source = new BeanBlockSourceImpl(cache, overrideSource, EMPTY_CONFIGURATION);
    Block actual = source.getEditBlock(datatype);
    assertSame(actual, block);
    verify();
}
Also used : BeanBlockSource(org.apache.tapestry5.services.BeanBlockSource) BeanBlockOverrideSource(org.apache.tapestry5.services.BeanBlockOverrideSource) Block(org.apache.tapestry5.Block) Test(org.testng.annotations.Test)

Example 3 with BeanBlockSource

use of org.apache.tapestry5.services.BeanBlockSource in project tapestry-5 by apache.

the class BeanBlockSourceImplTest method display_block_not_found.

@Test
public void display_block_not_found() {
    RequestPageCache cache = mockRequestPageCache();
    Collection<BeanBlockContribution> configuration = newList();
    replay();
    BeanBlockSource source = new BeanBlockSourceImpl(cache, createBeanBlockOverrideSource(cache), configuration);
    try {
        assertFalse(source.hasDisplayBlock("MyData"));
        source.getDisplayBlock("MyData");
        unreachable();
    } catch (RuntimeException ex) {
        assertEquals(ex.getMessage(), "There is no defined way to display data of type \'MyData\'. Make a contribution to the BeanBlockSource service for this type.");
    }
    verify();
}
Also used : BeanBlockSource(org.apache.tapestry5.services.BeanBlockSource) BeanBlockContribution(org.apache.tapestry5.services.BeanBlockContribution) Test(org.testng.annotations.Test)

Example 4 with BeanBlockSource

use of org.apache.tapestry5.services.BeanBlockSource in project tapestry-5 by apache.

the class BeanBlockSourceImplTest method found_edit_block.

@Test
public void found_edit_block() {
    Block block = mockBlock();
    RequestPageCache cache = mockRequestPageCache();
    Page page = mockPage();
    BeanBlockContribution contribution = new EditBlockContribution("mydata", "MyPage", "mydisplay");
    Collection<BeanBlockContribution> configuration = newList(contribution);
    train_get(cache, "MyPage", page);
    train_getBlock(page, "mydisplay", block);
    replay();
    BeanBlockSource source = new BeanBlockSourceImpl(cache, createBeanBlockOverrideSource(cache), configuration);
    // Check case insensitivity while we are at it.
    Block actual = source.getEditBlock("MyData");
    assertSame(actual, block);
    verify();
}
Also used : BeanBlockSource(org.apache.tapestry5.services.BeanBlockSource) Block(org.apache.tapestry5.Block) Page(org.apache.tapestry5.internal.structure.Page) BeanBlockContribution(org.apache.tapestry5.services.BeanBlockContribution) EditBlockContribution(org.apache.tapestry5.services.EditBlockContribution) Test(org.testng.annotations.Test)

Example 5 with BeanBlockSource

use of org.apache.tapestry5.services.BeanBlockSource in project tapestry-5 by apache.

the class BeanBlockSourceImplTest method found_display_block.

@Test
public void found_display_block() {
    Block block = mockBlock();
    RequestPageCache cache = mockRequestPageCache();
    Page page = mockPage();
    BeanBlockContribution contribution = new DisplayBlockContribution("mydata", "MyPage", "mydisplay");
    Collection<BeanBlockContribution> configuration = newList(contribution);
    train_get(cache, "MyPage", page);
    train_getBlock(page, "mydisplay", block);
    replay();
    BeanBlockSource source = new BeanBlockSourceImpl(cache, createBeanBlockOverrideSource(cache), configuration);
    // Check case insensitivity while we are at it.
    assertTrue(source.hasDisplayBlock("MyData"));
    Block actual = source.getDisplayBlock("MyData");
    assertSame(actual, block);
    verify();
}
Also used : DisplayBlockContribution(org.apache.tapestry5.services.DisplayBlockContribution) BeanBlockSource(org.apache.tapestry5.services.BeanBlockSource) Block(org.apache.tapestry5.Block) Page(org.apache.tapestry5.internal.structure.Page) BeanBlockContribution(org.apache.tapestry5.services.BeanBlockContribution) Test(org.testng.annotations.Test)

Aggregations

BeanBlockSource (org.apache.tapestry5.services.BeanBlockSource)7 Test (org.testng.annotations.Test)7 Block (org.apache.tapestry5.Block)4 BeanBlockContribution (org.apache.tapestry5.services.BeanBlockContribution)4 Page (org.apache.tapestry5.internal.structure.Page)2 BeanBlockOverrideSource (org.apache.tapestry5.services.BeanBlockOverrideSource)2 ComponentResources (org.apache.tapestry5.ComponentResources)1 PropertyOverrides (org.apache.tapestry5.PropertyOverrides)1 PropertyModel (org.apache.tapestry5.beanmodel.PropertyModel)1 Location (org.apache.tapestry5.commons.Location)1 Messages (org.apache.tapestry5.commons.Messages)1 TapestryException (org.apache.tapestry5.commons.internal.util.TapestryException)1 DisplayBlockContribution (org.apache.tapestry5.services.DisplayBlockContribution)1 EditBlockContribution (org.apache.tapestry5.services.EditBlockContribution)1