DefaultResourceHandler implements IResourceHandler { protected byte[] processResourceContent(IResource resource, IResourceContext context) { IResourceUrn urn = resource.getUrn(); IResourceOptimizer optimizer = context.getConfig().getRegistry().getResourceOptimizer(urn.getType()); if (optimizer != null) { Object value = optimizer.optimize(resource, context.getOptimizationCommand(urn.getType())); if (value instanceof String) { try { return ((String) value).getBytes("utf-8"); } catch (UnsupportedEncodingException e) { return ((String) value).getBytes(); } } else { return (byte[]) value; } } else { return resource.getOriginalBinaryContent(); } }  @Override byte[] getBinaryContent(IResource resource, IResourceContext context); @Override String getContent(IResource resource, IResourceContext context); @Override String getUrl(IResource resource, IResourceContext context);  }
@Test public void testProcessResourceContent() { IResource resource = ResourceFactory.createResource("/js/sample/sample.js"); IResourceContext context = ResourceRuntimeContext.ctx().getResourceContext(); String actualContent = new String(m_handler.processResourceContent(resource, context)); Assert.assertEquals("document.write(\"this is sample.js<br>\");", actualContent); }