use of com.enonic.xp.resource.ResourceKey in project xp by enonic.
the class AssetHandlerTest method testCacheHeader_FingerprintDoesntMatch.
@Test
public void testCacheHeader_FingerprintDoesntMatch() throws Exception {
addResource("demo:/assets/css/main.css");
this.request.setEndpointPath("/_/asset/demo:123/css/main.css");
final ResourceKey resourceKey = ResourceKey.from(ApplicationKey.from("demo"), "META-INF/MANIFEST.MF");
when(this.resourceService.getResource(resourceKey)).thenReturn(MockResource.empty(resourceKey, 1));
final WebResponse res = this.handler.handle(this.request, PortalResponse.create().build(), null);
assertNotNull(res);
assertEquals(HttpStatus.OK, res.getStatus());
assertNull(res.getHeaders().get("Cache-Control"));
}
use of com.enonic.xp.resource.ResourceKey in project xp by enonic.
the class AssetHandlerTest method addResource.
private Resource addResource(final String key) throws Exception {
final ResourceKey resourceKey = ResourceKey.from(key);
final Resource resource = Mockito.mock(Resource.class);
when(resource.exists()).thenReturn(true);
when(resource.getKey()).thenReturn(resourceKey);
this.resources.put(resourceKey, resource);
return resource;
}
use of com.enonic.xp.resource.ResourceKey in project xp by enonic.
the class ScriptRuntimeTest method testRequire_3rd.
@Test
public void testRequire_3rd() {
final ResourceKey script = ResourceKey.from("myapplication:/site/require/3rd/require-3rd-test.js");
final ScriptExports exports = runTestScript(script);
assertNotNull(exports);
}
use of com.enonic.xp.resource.ResourceKey in project xp by enonic.
the class ScriptRuntimeTest method testEmpty.
@Test
public void testEmpty() {
final ResourceKey script = ResourceKey.from("myapplication:/empty-test.js");
final ScriptExports exports = runTestScript(script);
assertNotNull(exports);
assertSame(script, exports.getScript());
assertFalse(exports.hasMethod("hello"));
}
use of com.enonic.xp.resource.ResourceKey in project xp by enonic.
the class ScriptRuntimeTest method testCache.
@Test
public void testCache() {
final ResourceKey script = ResourceKey.from("myapplication:/empty-test.js");
final ScriptExports exports1 = runTestScript(script);
final ScriptExports exports2 = runTestScript(script);
assertNotNull(exports2);
assertSame(exports1.getRawValue(), exports2.getRawValue());
this.scriptRuntime.invalidate(ApplicationKey.from("othermodule"));
final ScriptExports exports3 = runTestScript(script);
assertSame(exports1.getRawValue(), exports3.getRawValue());
this.scriptRuntime.invalidate(script.getApplicationKey());
final ScriptExports exports4 = runTestScript(script);
assertNotSame(exports1.getRawValue(), exports4.getRawValue());
}
Aggregations