Search in sources :

Example 1 with URLConfiguration

use of org.xwiki.url.URLConfiguration 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);
}
Also used : Execution(org.xwiki.context.Execution) ExecutionContext(org.xwiki.context.ExecutionContext) URLConfiguration(org.xwiki.url.URLConfiguration) WikiDescriptorManager(org.xwiki.wiki.descriptor.WikiDescriptorManager) ModelConfiguration(org.xwiki.model.ModelConfiguration) EntityResourceActionLister(org.xwiki.resource.internal.entity.EntityResourceActionLister) BeforeComponent(org.xwiki.test.annotation.BeforeComponent)

Aggregations

Execution (org.xwiki.context.Execution)1 ExecutionContext (org.xwiki.context.ExecutionContext)1 ModelConfiguration (org.xwiki.model.ModelConfiguration)1 EntityResourceActionLister (org.xwiki.resource.internal.entity.EntityResourceActionLister)1 BeforeComponent (org.xwiki.test.annotation.BeforeComponent)1 URLConfiguration (org.xwiki.url.URLConfiguration)1 WikiDescriptorManager (org.xwiki.wiki.descriptor.WikiDescriptorManager)1