Search in sources :

Example 11 with FilesystemExportContext

use of org.xwiki.url.filesystem.FilesystemExportContext in project xwiki-platform by xwiki.

the class FilesystemExportContextProviderTest method getWhenExportContextAlreadyInEC.

@Test
public void getWhenExportContextAlreadyInEC() throws Exception {
    ExecutionContext ec = new ExecutionContext();
    FilesystemExportContext fec = new FilesystemExportContext();
    ec.setProperty("filesystemExportContext", fec);
    Execution execution = this.mocker.getInstance(Execution.class);
    when(execution.getContext()).thenReturn(ec);
    FilesystemExportContext newfec = this.mocker.getComponentUnderTest().get();
    assertSame(newfec, ec.getProperty("filesystemExportContext"));
    assertSame(newfec, fec);
}
Also used : ExecutionContext(org.xwiki.context.ExecutionContext) Execution(org.xwiki.context.Execution) FilesystemExportContext(org.xwiki.url.filesystem.FilesystemExportContext) Test(org.junit.Test)

Example 12 with FilesystemExportContext

use of org.xwiki.url.filesystem.FilesystemExportContext in project xwiki-platform by xwiki.

the class FilesystemExportContextProviderTest method getWhenExportContextNotInEC.

@Test
public void getWhenExportContextNotInEC() throws Exception {
    ExecutionContext ec = new ExecutionContext();
    Execution execution = this.mocker.getInstance(Execution.class);
    when(execution.getContext()).thenReturn(ec);
    FilesystemExportContext fec = this.mocker.getComponentUnderTest().get();
    assertSame(fec, ec.getProperty("filesystemExportContext"));
}
Also used : ExecutionContext(org.xwiki.context.ExecutionContext) Execution(org.xwiki.context.Execution) FilesystemExportContext(org.xwiki.url.filesystem.FilesystemExportContext) Test(org.junit.Test)

Example 13 with FilesystemExportContext

use of org.xwiki.url.filesystem.FilesystemExportContext in project xwiki-platform by xwiki.

the class FilesystemExportContextTest method getSetDocParentLevels.

@Test
public void getSetDocParentLevels() {
    FilesystemExportContext context = new FilesystemExportContext();
    context.setDocParentLevels(5);
    assertEquals(5, context.getDocParentLevel());
}
Also used : FilesystemExportContext(org.xwiki.url.filesystem.FilesystemExportContext) Test(org.junit.Test)

Example 14 with FilesystemExportContext

use of org.xwiki.url.filesystem.FilesystemExportContext in project xwiki-platform by xwiki.

the class ExportURLFactoryTest method setUp.

@Before
public void setUp() throws Exception {
    this.urlFactory = new ExportURLFactory();
    this.tmpDir = this.tmpDirRule.newFolder("xwikitests");
    new File(this.tmpDir, "attachment").mkdir();
    Provider<FilesystemExportContext> exportContextProvider = this.oldcoreRule.getMocker().getInstance(new DefaultParameterizedType(null, Provider.class, FilesystemExportContext.class));
    this.exportContext = exportContextProvider.get();
    doReturn("/xwiki").when(this.oldcoreRule.getSpyXWiki()).getWebAppPath(any(XWikiContext.class));
    XWikiContext context = this.oldcoreRule.getXWikiContext();
    XWikiRequest request = mock(XWikiRequest.class);
    context.setRequest(request);
    context.setURL(new URL("http://www.xwiki.org/"));
    this.urlFactory.init(null, this.tmpDir, this.exportContext, context);
}
Also used : XWikiContext(com.xpn.xwiki.XWikiContext) DefaultParameterizedType(org.xwiki.component.util.DefaultParameterizedType) File(java.io.File) FilesystemExportContext(org.xwiki.url.filesystem.FilesystemExportContext) URL(java.net.URL) Provider(javax.inject.Provider) Before(org.junit.Before)

Aggregations

FilesystemExportContext (org.xwiki.url.filesystem.FilesystemExportContext)14 Test (org.junit.Test)9 Provider (javax.inject.Provider)7 DefaultParameterizedType (org.xwiki.component.util.DefaultParameterizedType)7 File (java.io.File)6 URL (java.net.URL)3 ExecutionContext (org.xwiki.context.ExecutionContext)3 DocumentReference (org.xwiki.model.reference.DocumentReference)3 ArrayList (java.util.ArrayList)2 Execution (org.xwiki.context.Execution)2 EntityReference (org.xwiki.model.reference.EntityReference)2 XWikiContext (com.xpn.xwiki.XWikiContext)1 ExportURLFactory (com.xpn.xwiki.web.ExportURLFactory)1 ZipOutputStream (java.util.zip.ZipOutputStream)1 Before (org.junit.Before)1 SerializeResourceReferenceException (org.xwiki.resource.SerializeResourceReferenceException)1 UnsupportedResourceReferenceException (org.xwiki.resource.UnsupportedResourceReferenceException)1 RelativeExtendedURL (org.xwiki.url.internal.RelativeExtendedURL)1