Search in sources :

Example 1 with BeforeComponent

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"));
}
Also used : ModelContext(org.xwiki.model.ModelContext) ExecutionContext(org.xwiki.context.ExecutionContext) EnvironmentConfiguration(org.xwiki.environment.internal.EnvironmentConfiguration) Copier(org.xwiki.mail.internal.thread.context.Copier) XWikiContext(com.xpn.xwiki.XWikiContext) Properties(java.util.Properties) WikiReference(org.xwiki.model.reference.WikiReference) DefaultParameterizedType(org.xwiki.component.util.DefaultParameterizedType) BeforeComponent(org.xwiki.test.annotation.BeforeComponent)

Example 2 with BeforeComponent

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));
}
Also used : Environment(org.xwiki.environment.Environment) File(java.io.File) BeforeComponent(org.xwiki.test.annotation.BeforeComponent)

Example 3 with BeforeComponent

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"));
}
Also used : EntityResourceActionLister(org.xwiki.resource.internal.entity.EntityResourceActionLister) BeforeComponent(org.xwiki.test.annotation.BeforeComponent)

Example 4 with BeforeComponent

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));
}
Also used : CacheManager(org.xwiki.cache.CacheManager) CacheConfiguration(org.xwiki.cache.config.CacheConfiguration) RenderingCache(com.xpn.xwiki.internal.cache.rendering.RenderingCache) Cache(org.xwiki.cache.Cache) BeforeComponent(org.xwiki.test.annotation.BeforeComponent)

Example 5 with BeforeComponent

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);
}
Also used : UserBridge(org.xwiki.security.internal.UserBridge) CacheManager(org.xwiki.cache.CacheManager) XWikiBridge(org.xwiki.security.internal.XWikiBridge) CacheConfiguration(org.xwiki.cache.config.CacheConfiguration) SecurityCacheRulesInvalidator(org.xwiki.security.authorization.cache.SecurityCacheRulesInvalidator) BeforeComponent(org.xwiki.test.annotation.BeforeComponent)

Aggregations

BeforeComponent (org.xwiki.test.annotation.BeforeComponent)10 XWikiContext (com.xpn.xwiki.XWikiContext)4 ExecutionContext (org.xwiki.context.ExecutionContext)4 Properties (java.util.Properties)3 DefaultParameterizedType (org.xwiki.component.util.DefaultParameterizedType)3 EnvironmentConfiguration (org.xwiki.environment.internal.EnvironmentConfiguration)3 Copier (org.xwiki.mail.internal.thread.context.Copier)3 ModelContext (org.xwiki.model.ModelContext)3 WikiReference (org.xwiki.model.reference.WikiReference)3 CacheManager (org.xwiki.cache.CacheManager)2 CacheConfiguration (org.xwiki.cache.config.CacheConfiguration)2 EntityResourceActionLister (org.xwiki.resource.internal.entity.EntityResourceActionLister)2 WikiDescriptorManager (org.xwiki.wiki.descriptor.WikiDescriptorManager)2 RenderingCache (com.xpn.xwiki.internal.cache.rendering.RenderingCache)1 File (java.io.File)1 Cache (org.xwiki.cache.Cache)1 Execution (org.xwiki.context.Execution)1 Environment (org.xwiki.environment.Environment)1 MailSenderConfiguration (org.xwiki.mail.MailSenderConfiguration)1 ScriptServicePermissionChecker (org.xwiki.mail.script.ScriptServicePermissionChecker)1