Resource implements IResource { @Override public String getContent(IResourceContext context) { Object getHandlerContent = context.getAttribute("get_handler_content"); Boolean goThroughHandler = Boolean.FALSE; if (getHandlerContent != null && getHandlerContent instanceof Boolean) { goThroughHandler = (Boolean) getHandlerContent; } if (goThroughHandler) { try { if (m_handler != null) { return m_handler.getContent(this, context); } } catch (Throwable e) { ResourceRuntimeContext .ctx() .getConfig() .getRegistry() .getErrorHandler() .handle( new ResourceException(ResourceErrConstants.HANDLER_CONTENT_ERR, String.format( "Error get content on resource(%s).", this.getUrn()), e), e); } } else { return getOriginalContent(); } return null; } Resource(IResourceUrn urn, URL physicalUrl, IResourceLocale locale, IResourceLibrary libraryInfo);  Resource(Resource resource); @Override boolean equals(Object obj); @Override byte[] getBinaryContent(IResourceContext context); @Override String getContent(IResourceContext context); @Override List<IResource> getDependencies(); @Override long getLastModified(); @Override IResourceLibrary getLibrary(); @Override IResourceLocale getLocale(); @Override byte[] getOriginalBinaryContent(); @Override byte[] getOriginalBinaryContent(ITemplateContext context); @Override String getOriginalContent(); @Override String getOriginalContent(ITemplateContext context); @Override URL getOriginalUrl(); @Override String getUrl(IResourceContext context); @Override IResourceUrn getUrn(); @Override int hashCode(); @Override void setDependencies(List<IResource> dependencies); void setHandler(IResourceHandler handler); @Override String toString();  }
@Test public void testGetContent() throws UnsupportedEncodingException { Resource resource = (Resource)ResourceFactory.createResource("/js/sample/sample.js"); resource.setHandler(new MockHandler()); String binaryContent = new String(resource.getBinaryContent(ResourceRuntimeContext.ctx().getResourceContext()), "utf-8"); Assert.assertEquals("document.write(\"this is sample.js<br>\");", binaryContent); }