Search in sources :

Example 56 with ResourceKey

use of com.enonic.xp.resource.ResourceKey in project xp by enonic.

the class RequireResolverTest method resolve_relative.

@Test
public void resolve_relative() throws Exception {
    touchFile("a/b/dummy.js");
    final ResourceKey key2 = resolve("/a/b/c.js", "dummy");
    assertEquals("/a/b/dummy.js", key2.getPath());
}
Also used : ResourceKey(com.enonic.xp.resource.ResourceKey) Test(org.junit.jupiter.api.Test)

Example 57 with ResourceKey

use of com.enonic.xp.resource.ResourceKey in project xp by enonic.

the class ResourceResolverTest method resolve_relative.

@Test
public void resolve_relative() throws Exception {
    touchFile("dir1/dir2/dummy.txt");
    touchFile("dir1/dummy.txt");
    final ResourceKey key1 = resolve("/dir1/dir2/c.txt", "./dummy.txt");
    assertEquals("/dir1/dir2/dummy.txt", key1.getPath());
    final ResourceKey key2 = resolve("/dir1/dir2/c.txt", "../dummy.txt");
    assertEquals("/dir1/dummy.txt", key2.getPath());
    final ResourceKey key3 = resolve("/dir1/dir2/c.txt", "dummy.txt");
    assertEquals("/dir1/dir2/dummy.txt", key3.getPath());
}
Also used : ResourceKey(com.enonic.xp.resource.ResourceKey) Test(org.junit.jupiter.api.Test)

Example 58 with ResourceKey

use of com.enonic.xp.resource.ResourceKey in project xp by enonic.

the class ResourceResolverTest method resolve_absolute.

@Test
public void resolve_absolute() throws Exception {
    touchFile("dummy.txt");
    final ResourceKey key1 = resolve("/a/b/c.txt", "/dummy.txt");
    assertEquals("/dummy.txt", key1.getPath());
    touchFile("site/dummy.txt");
    final ResourceKey key2 = resolve("/a/b/c.txt", "/dummy.txt");
    assertEquals("/site/dummy.txt", key2.getPath());
}
Also used : ResourceKey(com.enonic.xp.resource.ResourceKey) Test(org.junit.jupiter.api.Test)

Example 59 with ResourceKey

use of com.enonic.xp.resource.ResourceKey in project xp by enonic.

the class ScriptRuntimeImplTest method executeAsync.

@Test
void executeAsync() {
    final ApplicationKey applicationKey = ApplicationKey.from("myApp");
    when(scriptExecutorFactory.apply(applicationKey)).thenReturn(scriptExecutor);
    final ScriptRuntimeImpl scriptRuntime = new ScriptRuntimeImpl(scriptExecutorFactory);
    final ResourceKey resourceKey = ResourceKey.from(applicationKey, "/main.js");
    scriptRuntime.executeAsync(resourceKey);
    verify(scriptExecutor, Mockito.times(1)).executeMainAsync(resourceKey);
}
Also used : ApplicationKey(com.enonic.xp.app.ApplicationKey) ResourceKey(com.enonic.xp.resource.ResourceKey) Test(org.junit.jupiter.api.Test)

Example 60 with ResourceKey

use of com.enonic.xp.resource.ResourceKey in project xp by enonic.

the class IOHandlerBean method getResource.

public Resource getResource(final Object key) {
    final ResourceKey resourceKey = toResourceKey(key);
    final ResourceService service = this.context.getService(ResourceService.class).get();
    return service.getResource(resourceKey);
}
Also used : ResourceService(com.enonic.xp.resource.ResourceService) ResourceKey(com.enonic.xp.resource.ResourceKey)

Aggregations

ResourceKey (com.enonic.xp.resource.ResourceKey)76 Test (org.junit.jupiter.api.Test)49 Resource (com.enonic.xp.resource.Resource)21 ApplicationKey (com.enonic.xp.app.ApplicationKey)12 ResourceService (com.enonic.xp.resource.ResourceService)12 ScriptExports (com.enonic.xp.script.ScriptExports)11 Application (com.enonic.xp.app.Application)9 UrlResource (com.enonic.xp.resource.UrlResource)9 URL (java.net.URL)9 BeforeEach (org.junit.jupiter.api.BeforeEach)9 PortalRequest (com.enonic.xp.portal.PortalRequest)8 HttpServletRequest (javax.servlet.http.HttpServletRequest)8 ApplicationService (com.enonic.xp.app.ApplicationService)7 AssetUrlParams (com.enonic.xp.portal.url.AssetUrlParams)7 ScriptAsyncService (com.enonic.xp.script.impl.async.ScriptAsyncService)7 ScriptRuntimeFactoryImpl (com.enonic.xp.script.impl.standard.ScriptRuntimeFactoryImpl)7 PortalResponse (com.enonic.xp.portal.PortalResponse)6 PortalScriptServiceImpl (com.enonic.xp.portal.impl.script.PortalScriptServiceImpl)6 Assertions.assertNotNull (org.junit.jupiter.api.Assertions.assertNotNull)6 PropertyTree (com.enonic.xp.data.PropertyTree)5