public void testImportResourcesFromUncompiledScript() throws JellyException, UnsupportedEncodingException, IOException, SAXException { JellyContext context = new JellyContext(); URL url = TestImport.class.getResource("/resources/import.jelly"); StringWriter writer = new StringWriter(); XMLOutput out = XMLOutput.createXMLOutput(writer); Script script = new XMLParser().parse(url); script.run(context, out); out.close(); assertEquals(expected, writer.toString()); }
// Tag interface // ------------------------------------------------------------------------- public void doTag(XMLOutput output) throws JellyTagException { try { output.startElement(uri, localName, qname, attributes); invokeBody(output); output.endElement(uri, localName, qname); } catch (SAXException e) { throw new JellyTagException(e); } finally { attributes.clear(); context = null; } }
public void testImportResources() throws JellyException, UnsupportedEncodingException, IOException { JellyContext context = new JellyContext(); URL url = TestImport.class.getResource("/resources/import.jelly"); StringWriter writer = new StringWriter(); XMLOutput out = XMLOutput.createXMLOutput(writer); // this works because of the created child context that has knowledge // of the URL context.runScript(url, out); out.close(); assertEquals(expected, writer.toString()); }
/** * Overwrite or implement method processTag() * * @see * com.cyclopsgroup.waterview.utils.TagSupportBase#processTag(org.apache.commons.jelly.XMLOutput) */ protected void processTag(XMLOutput output) throws Exception { requireAttribute("script"); invokeBody(XMLOutput.createDummyXMLOutput()); if (formTag == null) { throw new JellyTagException("Form tag must be defined"); } JellyEngine je = (JellyEngine) getServiceManager().lookup(JellyEngine.ROLE); Script script = je.getScript(getScript()); JellyContext jc = new JellyContext(getContext()); jc.setVariable("formTag", formTag); jc.setVariable("form", formTag.getForm()); script.run(jc, output); }
/** * Writes the annotated log to the given output. * * @since 1.350 */ public void writeLogTo(XMLOutput out) throws IOException { new AnnotatedLargeText<GitHubWebHookPollingAction>( getLogFile(), Charset.defaultCharset(), true, this) .writeHtmlTo(0, out.asWriter()); }
/** Used from <tt>polling.jelly</tt> to write annotated polling log to the given output. */ public void writePollingLogTo(long offset, XMLOutput out) throws IOException { // TODO: resurrect compressed log file support getPollingLogText().writeHtmlTo(offset, out.asWriter()); }
/** * Evaluate a Jelly script and return output as a String. * * @since 1.267 */ public static String runScript(Script script) throws JellyTagException { StringWriter out = new StringWriter(); script.run(getCurrentJellyContext(), XMLOutput.createXMLOutput(out)); return out.toString(); }