use of org.xwiki.test.annotation.BeforeComponent in project xwiki-platform by xwiki.
the class IntegrationTest method setUpComponents.
@BeforeComponent
public void setUpComponents() throws Exception {
// Isolate from xwiki configuration file
URLConfiguration urlConfiguration = this.componentManager.registerMockComponent(URLConfiguration.class);
when(urlConfiguration.getURLFormatId()).thenReturn("standard");
// Isolate from xwiki configuration file
StandardURLConfiguration standardURLConfiguration = this.componentManager.registerMockComponent(StandardURLConfiguration.class);
when(standardURLConfiguration.getEntityPathPrefix()).thenReturn("bin");
when(standardURLConfiguration.getWikiPathPrefix()).thenReturn("wiki");
when(standardURLConfiguration.isViewActionHidden()).thenReturn(false);
// Isolate from xwiki configuration file
ModelConfiguration modelConfiguration = this.componentManager.registerMockComponent(ModelConfiguration.class);
when(modelConfiguration.getDefaultReferenceValue(EntityType.WIKI)).thenReturn("xwiki");
// Isolate from xwiki's model
WikiDescriptorManager wikiDescriptorManager = this.componentManager.registerMockComponent(WikiDescriptorManager.class);
when(wikiDescriptorManager.getMainWikiId()).thenReturn("xwiki");
// Isolate from Environment
EntityResourceActionLister actionLister = this.componentManager.registerMockComponent(EntityResourceActionLister.class);
when(actionLister.listActions()).thenReturn(Arrays.asList("view"));
// Simulate a configured Execution Context
Execution execution = this.componentManager.registerMockComponent(Execution.class);
when(execution.getContext()).thenReturn(new ExecutionContext());
// For test simplicity consider that Context CM == CM
this.componentManager.registerComponent(ComponentManager.class, "context", this.componentManager);
}
use of org.xwiki.test.annotation.BeforeComponent in project xwiki-platform by xwiki.
the class CascadingVfsPermissionCheckerTest method beforeComponent.
@BeforeComponent
public void beforeComponent() throws Exception {
Provider<XWikiContext> provider = this.mocker.registerMockComponent(XWikiContext.TYPE_PROVIDER);
XWikiContext xcontext = mock(XWikiContext.class);
when(provider.get()).thenReturn(xcontext);
when(xcontext.getUserReference()).thenReturn(contextUser);
}
use of org.xwiki.test.annotation.BeforeComponent in project xwiki-platform by xwiki.
the class AuthenticatingIntegrationTest method registerConfiguration.
@BeforeComponent
public void registerConfiguration() throws Exception {
Properties properties = new Properties();
properties.setProperty("mail.smtp.starttls.enable", "true");
// Required by GreenMail. When using XWiki with Gmail for example this is not required.
properties.setProperty("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
this.configuration = new TestMailSenderConfiguration(this.mail.getSmtps().getPort(), "peter", "password", 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"));
Provider<XWikiContext> xwikiContextProvider = this.componentManager.registerMockComponent(XWikiContext.TYPE_PROVIDER);
when(xwikiContextProvider.get()).thenReturn(Mockito.mock(XWikiContext.class));
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 ScriptingIntegrationTest method registerConfiguration.
@BeforeComponent
public void registerConfiguration() throws Exception {
MailSenderConfiguration configuration = new TestMailSenderConfiguration(this.mail.getSmtp().getPort(), null, null, new Properties());
this.componentManager.registerComponent(MailSenderConfiguration.class, configuration);
// Register a test Permission Checker that allows sending mails
ScriptServicePermissionChecker checker = mock(ScriptServicePermissionChecker.class);
this.componentManager.registerComponent(ScriptServicePermissionChecker.class, "test", checker);
// Set the current wiki in the Context
ModelContext modelContext = this.componentManager.registerMockComponent(ModelContext.class);
Mockito.when(modelContext.getCurrentEntityReference()).thenReturn(new WikiReference("wiki"));
Provider<XWikiContext> xwikiContextProvider = this.componentManager.registerMockComponent(XWikiContext.TYPE_PROVIDER);
when(xwikiContextProvider.get()).thenReturn(Mockito.mock(XWikiContext.class));
this.componentManager.registerMockComponent(ExecutionContextManager.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"));
this.componentManager.registerMockComponent(ConverterManager.class);
}
use of org.xwiki.test.annotation.BeforeComponent in project xwiki-platform by xwiki.
the class SolrReferenceResolverTest method registerComponents.
@BeforeComponent
public void registerComponents() throws Exception {
this.mocker.registerMockComponent(XWikiContext.TYPE_PROVIDER);
this.mocker.registerMockComponent(QueryManager.class);
WikiDescriptorManager wikiDescriptorManager = this.mocker.registerMockComponent(WikiDescriptorManager.class);
when(wikiDescriptorManager.getAllIds()).thenReturn(Arrays.asList(wikiReference1.getName(), wikiReference2.getName()));
}
Aggregations