extensions.singleton("catalog", catalog, Catalog.class);
replay(eoCatalog); this.catalog = eoCatalog; extensions.singleton("catalog", eoCatalog, Catalog.class);
@Test public void testHeaderContribution() throws Exception { HeaderContribution testHeaderContribution = new HeaderContribution(); testHeaderContribution.setCSSFilename("testHeaderContribution.css"); testHeaderContribution.setScope(getClass()); extensions.singleton( "testHeaderContribution", testHeaderContribution, HeaderContribution.class); tester.startPage(SRSListPage.class); tester.clickLink( "srsListPanel:table:listContainer:items:1:itemProperties:0:component:link"); tester.assertRenderedPage(SRSDescriptionPage.class); assertTrue(tester.getLastResponse().getDocument().contains("testHeaderContribution.css")); } }
@Test public void testResolveWithProperty() { CacheProvider testCacheProvider1 = addMockProvider("testCacheProvider1"); CacheProvider testCacheProvider2 = addMockProvider("testCacheProvider2"); // Test that the bean specified in the property is used extensions.property(DefaultCacheProvider.BEAN_NAME_PROPERTY, "testCacheProvider1"); replay(testCacheProvider1, testCacheProvider2); CacheProvider provider = DefaultCacheProvider.findProvider(); assertThat(provider, sameInstance(testCacheProvider1)); verify(testCacheProvider1, testCacheProvider2); // Retry with the property changed to ensure we weren't jsut lucky before reset(testCacheProvider1, testCacheProvider2); extensions.property(DefaultCacheProvider.BEAN_NAME_PROPERTY, "testCacheProvider2"); replay(testCacheProvider1, testCacheProvider2); provider = DefaultCacheProvider.findProvider(); assertThat(provider, sameInstance(testCacheProvider2)); verify(testCacheProvider1, testCacheProvider2); }
public Statement apply(Statement base, Description description) { return statement(base); }
@Test public void testPropertyPriority() { CacheProvider testCacheProvider3 = addMockProvider("testCacheProvider3"); CacheProvider testCacheProvider2 = addMockProvider("testCacheProvider2"); // Test that the bean specified in the property is used extensions.property( DefaultCacheProvider.BEAN_NAME_PROPERTY, "testCacheProvider1,testCacheProvider2,testCacheProvider3"); replay(testCacheProvider3, testCacheProvider2); CacheProvider provider = DefaultCacheProvider.findProvider(); assertThat(provider, sameInstance(testCacheProvider2)); verify(testCacheProvider3, testCacheProvider2); } }
private CacheProvider addMockProvider(String name) { CacheProvider provider = EasyMock.createMock(name, CacheProvider.class); extensions.singleton(name, provider, CacheProvider.class); return provider; }