use of org.xwiki.test.annotation.BeforeComponent in project xwiki-platform by xwiki.
the class JavaIntegrationTest method registerConfiguration.
@BeforeComponent
public void registerConfiguration() throws Exception {
this.configuration = new TestMailSenderConfiguration(this.mail.getSmtp().getPort(), null, null, new Properties());
this.componentManager.registerComponent(MailSenderConfiguration.class, this.configuration);
// Set the current wiki in the Context
ModelContext modelContext = this.componentManager.registerMockComponent(ModelContext.class);
when(modelContext.getCurrentEntityReference()).thenReturn(new WikiReference("wiki"));
XWikiContext xcontext = mock(XWikiContext.class);
when(xcontext.getWikiId()).thenReturn("wiki");
Provider<XWikiContext> xwikiContextProvider = this.componentManager.registerMockComponent(XWikiContext.TYPE_PROVIDER);
when(xwikiContextProvider.get()).thenReturn(xcontext);
this.componentManager.registerMockComponent(ExecutionContextManager.class);
this.componentManager.registerMockComponent(Execution.class);
this.componentManager.registerMockComponent(new DefaultParameterizedType(null, Copier.class, ExecutionContext.class));
EnvironmentConfiguration environmentConfiguration = this.componentManager.registerMockComponent(EnvironmentConfiguration.class);
when(environmentConfiguration.getPermanentDirectoryPath()).thenReturn(System.getProperty("java.io.tmpdir"));
}
use of org.xwiki.test.annotation.BeforeComponent in project xwiki-platform by xwiki.
the class FileSystemMailContentStoreTest method registerMockComponents.
@BeforeComponent
public void registerMockComponents() throws Exception {
Environment environment = this.mocker.registerMockComponent(Environment.class);
when(environment.getPermanentDirectory()).thenReturn(new File(TEMPORARY_DIRECTORY));
}
use of org.xwiki.test.annotation.BeforeComponent in project xwiki-platform by xwiki.
the class XWikiServletURLFactoryTest method beforeComponent.
@BeforeComponent
public void beforeComponent() throws Exception {
EntityResourceActionLister actionLister = this.oldcore.getMocker().registerMockComponent(EntityResourceActionLister.class);
when(actionLister.listActions()).thenReturn(Arrays.asList("view"));
}
use of org.xwiki.test.annotation.BeforeComponent in project xwiki-platform by xwiki.
the class PageTest method setUpComponentsForPageTest.
/**
* Set up components before Components declared in {@link org.xwiki.test.annotation.ComponentList} are handled.
*
* @throws Exception in case of errors
*/
@BeforeComponent
public void setUpComponentsForPageTest() throws Exception {
mocker.registerMockComponent(JMXBeanRegistration.class);
mocker.registerMockComponent(Environment.class);
mocker.registerMockComponent(JobProgressManager.class);
mocker.registerMockComponent(RenderingCache.class);
mocker.registerMockComponent(EntityResourceActionLister.class);
CacheManager cacheManager = mocker.registerMockComponent(CacheManager.class);
when(cacheManager.createNewCache(any(CacheConfiguration.class))).thenReturn(mock(Cache.class));
}
use of org.xwiki.test.annotation.BeforeComponent in project xwiki-platform by xwiki.
the class DefaultAuthorizationManagerIntegrationTest method initializeMocks.
@BeforeComponent
public void initializeMocks() throws Exception {
cache = new TestCache<Object>();
final CacheManager cacheManager = componentManager.registerMockComponent(CacheManager.class);
when(cacheManager.createNewCache(any(CacheConfiguration.class))).thenReturn(cache);
xWikiBridge = componentManager.registerMockComponent(XWikiBridge.class);
userBridge = componentManager.registerMockComponent(UserBridge.class);
securityEntryReader = componentManager.registerMockComponent(SecurityEntryReader.class);
securityCacheRulesInvalidator = componentManager.registerMockComponent(SecurityCacheRulesInvalidator.class);
}
Aggregations