/** * Set the input script * @param scriptAsString */ public void setScript(String scriptAsString) { try { URL url = resolveURL(scriptAsString); m_inputStream = url.openStream(); } catch (MalformedURLException e) { //Encapsulate the string within m_inputStream = new ByteArrayInputStream(scriptAsString.getBytes()); } catch (IOException e) { //Error reading from the URL m_inputStream = null; } compileScriptAndKeep(); }
/** * Set the input stream * @param scriptAsInputStream */ public void setScript(InputStream scriptAsInputStream) { m_inputStream = scriptAsInputStream; compileScriptAndKeep(); }
if (log.isErrorEnabled()) log.error(m_scriptCompilationException.getMessage()); setErrorMsg(m_scriptCompilationException.getMessage()); return false; if (log.isErrorEnabled()) log.error("[Error] Input script-resource NOT accessible"); setErrorMsg("[Error] Input script-resource NOT accessible"); return false; if (log.isErrorEnabled()) log.error(e.getMessage()); setErrorMsg(e.getMessage()); return false;
/** * test Script input as a InputStream */ public void testInputStreamAsScript() { Embedded embedded = new Embedded(); String jellyScript = "<?xml version=\"1.0\"?>" + " <j:jelly xmlns:j=\"jelly:core\">" + "jelly-test-case" + " </j:jelly>"; embedded.setScript(new ByteArrayInputStream(jellyScript.getBytes())); ByteArrayOutputStream baos = new ByteArrayOutputStream(); embedded.setOutputStream(baos); boolean status = embedded.execute(); //executed properly without script errors assertEquals(status, true); //check that the output confirms the expected assertEquals("jelly-test-case", new String(baos.toByteArray())); }
/** * Set the input stream * @param scriptAsInputStream */ public void setScript(InputStream scriptAsInputStream) { m_inputStream = scriptAsInputStream; compileScriptAndKeep(); }
if (log.isErrorEnabled()) log.error(m_scriptCompilationException.getMessage()); setErrorMsg(m_scriptCompilationException.getMessage()); return false; if (log.isErrorEnabled()) log.error("[Error] Input script-resource NOT accessible"); setErrorMsg("[Error] Input script-resource NOT accessible"); return false; if (log.isErrorEnabled()) log.error(e.getMessage()); setErrorMsg(e.getMessage()); return false;
/** * test Script input as a java.lang.String object */ public void testStringAsScript() { Embedded embedded = new Embedded(); String jellyScript = "<?xml version=\"1.0\"?>" + " <j:jelly xmlns:j=\"jelly:core\">" + "jelly-test-case" + " </j:jelly>"; embedded.setScript(jellyScript); ByteArrayOutputStream baos = new ByteArrayOutputStream(); embedded.setOutputStream(baos); boolean status = embedded.execute(); //executed properly without script errors assertTrue("Emebedded execution failed", status); //check that the output confirms the exepected assertEquals("jelly-test-case", new String(baos.toByteArray())); //test generation of error embedded.setScript(jellyScript + "obnoxious-part"); status = embedded.execute(); //test failure of execution assertFalse("A script with bad XML was executed successfully", status); //Asserting the parser generated a errorMsg assertNotNull("A script with bad XML didn't generate an error message", embedded.getErrorMsg()); }
/** * Set the input script * @param scriptAsString */ public void setScript(String scriptAsString) { try { URL url = resolveURL(scriptAsString); m_inputStream = url.openStream(); } catch (MalformedURLException e) { //Encapsulate the string within m_inputStream = new ByteArrayInputStream(scriptAsString.getBytes()); } catch (IOException e) { //Error reading from the URL m_inputStream = null; } compileScriptAndKeep(); }
/** * Set the input stream * @param scriptAsInputStream */ public void setScript(InputStream scriptAsInputStream) { m_inputStream = scriptAsInputStream; compileScriptAndKeep(); }
if (log.isErrorEnabled()) log.error(m_scriptCompilationException.getMessage()); setErrorMsg(m_scriptCompilationException.getMessage()); return false; if (log.isErrorEnabled()) log.error("[Error] Input script-resource NOT accessible"); setErrorMsg("[Error] Input script-resource NOT accessible"); return false; if (log.isErrorEnabled()) log.error(e.getMessage()); setErrorMsg(e.getMessage()); return false;
/** * Set the input script * @param scriptAsString */ public void setScript(String scriptAsString) { try { URL url = resolveURL(scriptAsString); m_inputStream = url.openStream(); } catch (MalformedURLException e) { //Encapsulate the string within m_inputStream = new ByteArrayInputStream(scriptAsString.getBytes()); } catch (IOException e) { //Error reading from the URL m_inputStream = null; } compileScriptAndKeep(); }
/** * Set the input stream * @param scriptAsInputStream */ public void setScript(InputStream scriptAsInputStream) { m_inputStream = scriptAsInputStream; compileScriptAndKeep(); }
if (log.isErrorEnabled()) log.error(m_scriptCompilationException.getMessage()); setErrorMsg(m_scriptCompilationException.getMessage()); return false; if (log.isErrorEnabled()) log.error("[Error] Input script-resource NOT accessible"); setErrorMsg("[Error] Input script-resource NOT accessible"); return false; if (log.isErrorEnabled()) log.error(e.getMessage()); setErrorMsg(e.getMessage()); return false;
/** * Set the input script * @param scriptAsString */ public void setScript(String scriptAsString) { try { URL url = resolveURL(scriptAsString); m_inputStream = url.openStream(); } catch (MalformedURLException e) { //Encapsulate the string within m_inputStream = new ByteArrayInputStream(scriptAsString.getBytes()); } catch (IOException e) { //Error reading from the URL m_inputStream = null; } compileScriptAndKeep(); }