Search in sources :

Example 1 with VfsManager

use of org.xwiki.vfs.VfsManager in project xwiki-platform by xwiki.

the class VfsScriptServiceTest method urlError.

@Test
public void urlError() throws Exception {
    VfsResourceReference reference = new VfsResourceReference(URI.create("attach:xwiki:space.page@attachment"), "path1/path2/test.txt");
    VfsManager manager = this.mocker.getInstance(VfsManager.class);
    when(manager.getURL(reference)).thenThrow(new VfsException("error"));
    assertNull(this.mocker.getComponentUnderTest().url(new VfsResourceReference(URI.create("attach:xwiki:space.page@attachment"), "path1/path2/test.txt")));
}
Also used : VfsException(org.xwiki.vfs.VfsException) VfsManager(org.xwiki.vfs.VfsManager) VfsResourceReference(org.xwiki.vfs.VfsResourceReference) Test(org.junit.Test)

Example 2 with VfsManager

use of org.xwiki.vfs.VfsManager in project xwiki-platform by xwiki.

the class VfsScriptServiceTest method url.

@Test
public void url() throws Exception {
    VfsResourceReference reference = new VfsResourceReference(URI.create("attach:xwiki:space.page@attachment"), "path1/path2/test.txt");
    VfsManager manager = this.mocker.getInstance(VfsManager.class);
    when(manager.getURL(reference)).thenReturn("/generated/url");
    assertEquals("/generated/url", this.mocker.getComponentUnderTest().url(new VfsResourceReference(URI.create("attach:xwiki:space.page@attachment"), "path1/path2/test.txt")));
}
Also used : VfsManager(org.xwiki.vfs.VfsManager) VfsResourceReference(org.xwiki.vfs.VfsResourceReference) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 VfsManager (org.xwiki.vfs.VfsManager)2 VfsResourceReference (org.xwiki.vfs.VfsResourceReference)2 VfsException (org.xwiki.vfs.VfsException)1