/** * Usage: jelly [scriptFile] [-script scriptFile -o outputFile -Dsysprop=syspropval] */ public static void main(String[] args) throws Exception { try { if (args.length <= 0) { System.out.println("Usage: jelly [scriptFile] [-script scriptFile -o outputFile -Dsysprop=syspropval]"); return; } // parse the command line options using CLI // using a separate class to avoid unnecessary // dependencies CommandLineParser.getInstance().invokeCommandLineJelly(args); } catch (JellyException e) { Throwable cause = e.getCause(); if (cause == null) { e.printStackTrace(); } else { cause.printStackTrace(); } } }
/** * Usage: jelly [scriptFile] [-script scriptFile -o outputFile -Dsysprop=syspropval] */ public static void main(String[] args) throws Exception { try { if (args.length <= 0) { System.out.println("Usage: jelly [scriptFile] [-script scriptFile -o outputFile -Dsysprop=syspropval]"); return; } // parse the command line options using CLI // using a separate class to avoid unnecessary // dependencies CommandLineParser.getInstance().invokeCommandLineJelly(args); } catch (JellyException e) { Throwable cause = e.getCause(); if (cause == null) { e.printStackTrace(); } else { cause.printStackTrace(); } } }
/** * Usage: jelly [scriptFile] [-script scriptFile -o outputFile -Dsysprop=syspropval] */ public static void main(String[] args) throws Exception { try { if (args.length <= 0) { System.out.println("Usage: jelly [scriptFile] [-script scriptFile -o outputFile -Dsysprop=syspropval]"); return; } // parse the command line options using CLI // using a separate class to avoid unnecessary // dependencies CommandLineParser.getInstance().invokeCommandLineJelly(args); } catch (JellyException e) { Throwable cause = e.getCause(); if (cause == null) { e.printStackTrace(); } else { cause.printStackTrace(); } } }
/** * Usage: jelly [scriptFile] [-script scriptFile -o outputFile -Dsysprop=syspropval] */ public static void main(String[] args) throws Exception { try { if (args.length <= 0) { System.out.println("Usage: jelly [scriptFile] [-script scriptFile -o outputFile -Dsysprop=syspropval]"); return; } // parse the command line options using CLI // using a separate class to avoid unnecessary // dependencies CommandLineParser.getInstance().invokeCommandLineJelly(args); } catch (JellyException e) { Throwable cause = e.getCause(); if (cause == null) { e.printStackTrace(); } else { cause.printStackTrace(); } } }
if ( jellyEx.getCause() == null )
public void doTag(XMLOutput output) throws JellyTagException { Class throwableClass = null; try { throwableClass = getThrowableClass(); invokeBody(output); } catch (Throwable t) { if (t instanceof JellyException) { // unwrap Jelly exceptions which wrap other exceptions JellyException je = (JellyException) t; if (je.getCause() != null) { t = je.getCause(); } } if (var != null) { context.setVariable(var, t); } if (throwableClass != null && !throwableClass.isAssignableFrom(t.getClass())) { fail("Unexpected exception: " + t); } else { return; } } fail("No exception was thrown."); }
public void testDoctypeDefinitionXXEDefaultMode() throws JellyException { JellyContext context = new JellyContext(); URL url = this.getClass().getResource("doctypeDefinitionXXE.jelly"); try { context.runScript(url, null); } catch (JellyException e) { Throwable cause = e.getCause(); if (cause instanceof java.net.ConnectException) { fail("doctypeDefinitionXXE.jelly attempted to connect to http://127.0.0.1:4444"); } else if (cause instanceof org.xml.sax.SAXParseException) { // Success. } else { fail("Unknown exception: " + e.getMessage()); } } }
public void testDoctypeDefinitionXXEAllowDTDCalls() throws JellyException { JellyContext context = new JellyContext(); context.setAllowDtdToCallExternalEntities(true); URL url = this.getClass().getResource("doctypeDefinitionXXE.jelly"); try { context.runScript(url, null); } catch (JellyException e) { Throwable cause = e.getCause(); if (cause instanceof java.net.ConnectException) { //success } else if (cause instanceof org.xml.sax.SAXParseException) { fail("doctypeDefinitionXXE.jelly did not attempt to connect to http://127.0.0.1:4444"); } else { fail("Unknown exception: " + e.getMessage()); } } } }
public void testInvokeThatDoesNotHandleException() throws Exception { setUpScript( "testInvokeStaticTag.jelly" ); Script script = getJelly().compileScript(); getJellyContext().setVariable("test.invokeThatDoesNotHandleException",Boolean.TRUE); script.run(getJellyContext(),getXMLOutput()); String exceptionMessage = (String) getJellyContext().getVariable("exceptionMessage"); assertNotNull( exceptionMessage ); JellyException jellyException = (JellyException) getJellyContext().getVariable("jellyException"); assertNotNull( jellyException ); assertTrue( "messages are the same", ! exceptionMessage.equals(jellyException.getMessage()) ); assertTrue( "exception '" + jellyException.getMessage() + "' does not ends with '" + exceptionMessage+"'", jellyException.getMessage().endsWith(exceptionMessage) ); assertNotNull( jellyException.getCause() ); assertEquals( exceptionMessage, jellyException.getCause().getMessage() ); }
public void testInvokeThatDoesNotHandleException() throws Exception { setUpScript("testInvokeTag.jelly"); Script script = getJelly().compileScript(); getJellyContext().setVariable("test.invokeThatDoesNotHandleException",Boolean.TRUE); script.run(getJellyContext(),getXMLOutput()); String exceptionMessage = (String) getJellyContext().getVariable("exceptionMessage"); assertNotNull( exceptionMessage ); assertNotNull( getJellyContext().getVariable("exceptionBean")); JellyException jellyException = (JellyException) getJellyContext().getVariable("jellyException"); assertNotNull( jellyException ); assertTrue( "messages are the same", ! exceptionMessage.equals(jellyException.getMessage()) ); assertTrue( "exception '" + jellyException.getMessage() + "' does not ends with '" + exceptionMessage+"'", jellyException.getMessage().endsWith(exceptionMessage) ); assertNotNull( jellyException.getCause() ); assertEquals( exceptionMessage, jellyException.getCause().getMessage() ); }