Search in sources :

Example 1 with BeanBlockOverrideSource

use of org.apache.tapestry5.services.BeanBlockOverrideSource 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 BeanBlockOverrideSource

use of org.apache.tapestry5.services.BeanBlockOverrideSource 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 BeanBlockOverrideSource

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

the class BeanBlockSourceImplTest method conflicting_bean_block_overrides.

@Test
public // TAP5-2506
void conflicting_bean_block_overrides() {
    RequestPageCache cache = mockRequestPageCache();
    Collection<BeanBlockContribution> configuration = CollectionFactory.newList();
    configuration.add(new DisplayBlockContribution("foo", "page1", "bar"));
    configuration.add(new DisplayBlockContribution("foo", "page2", "baz"));
    try {
        new BeanBlockOverrideSourceImpl(cache, configuration);
        unreachable();
    } catch (IllegalArgumentException ex) {
        assertEquals(ex.getMessage(), "The BeanBlockOverrideSource configuration contains multiple display block overrides for data type 'foo'.");
    }
}
Also used : DisplayBlockContribution(org.apache.tapestry5.services.DisplayBlockContribution) BeanBlockContribution(org.apache.tapestry5.services.BeanBlockContribution) Test(org.testng.annotations.Test)

Aggregations

Test (org.testng.annotations.Test)3 Block (org.apache.tapestry5.Block)2 BeanBlockOverrideSource (org.apache.tapestry5.services.BeanBlockOverrideSource)2 BeanBlockSource (org.apache.tapestry5.services.BeanBlockSource)2 BeanBlockContribution (org.apache.tapestry5.services.BeanBlockContribution)1 DisplayBlockContribution (org.apache.tapestry5.services.DisplayBlockContribution)1