use of com.enonic.xp.resource.MockResource in project xp by enonic.
the class WebAppHandlerTest method mockResource.
private Resource mockResource(final String uri, final byte[] data) {
final ResourceKey key = ResourceKey.from(uri);
final Resource resource = new MockResource(key, data, System.currentTimeMillis());
Mockito.when(this.resourceService.getResource(key)).thenReturn(resource);
return resource;
}
use of com.enonic.xp.resource.MockResource in project xp by enonic.
the class WebAppHandlerTest method handle_serveAsset.
@Test
public void handle_serveAsset() throws Exception {
final Resource resource = mockResource("myapp:/assets/a/b.txt", "hello".getBytes());
this.request.setRawPath("/webapp/myapp/a/b.txt");
this.request.setMethod(HttpMethod.GET);
final WebResponse response = this.handler.doHandle(this.request, null, this.chain);
assertEquals(HttpStatus.OK, response.getStatus());
assertSame(resource, response.getBody());
}
Aggregations