Package org.apache.commons.jelly

Examples of org.apache.commons.jelly.JellyContext


    public static TestSuite suite() throws Exception {
        return new TestSuite(TestDefaultNamespaceFilter.class);
    }

    public void setUp() throws Exception {
        context = new JellyContext();
        xmlOutput = XMLOutput.createXMLOutput(new StringWriter());

        jelly = new Jelly();

        String script = "nsFilterTest.jelly";
View Full Code Here


    public static TestSuite suite() throws Exception {
        return new TestSuite(TestNonexistentTags.class);
    }

    public void setUp(String scriptName) throws Exception {
        context = new JellyContext();
        xmlOutput = XMLOutput.createDummyXMLOutput();

        jelly = new Jelly();

        String script = scriptName;
View Full Code Here

    public static TestSuite suite() throws Exception {
        return new TestSuite(TestDummyXMLOutput.class);
    }

    public void setUp(String scriptName) throws Exception {
        this.context = new JellyContext();
        this.xmlOutput = XMLOutput.createDummyXMLOutput();

        this.jelly = new Jelly();

        String script = scriptName;
View Full Code Here

    public static TestSuite suite() throws Exception {
        return new TestSuite(TestXMLValidation.class);
    }

    public void setUp(String scriptName) throws Exception {
        context = new JellyContext();
        xmlOutput = XMLOutput.createXMLOutput(new StringWriter());

        jelly = new Jelly();

        String script = scriptName;
View Full Code Here

     * @throws JellyException
     */
    public long runScriptManyTimes(String scriptName, int count)
            throws IOException, SAXException, JellyException {
        Runtime rt = Runtime.getRuntime();
        JellyContext jc = new JellyContext();
        jc.setClassLoader(getClass().getClassLoader());

        XMLOutput output = XMLOutput.createDummyXMLOutput();
       
        URL url = this.getClass().getResource(scriptName);

        String exturl = url.toExternalForm();
        int lastSlash = exturl.lastIndexOf("/");
        String extBase = exturl.substring(0,lastSlash+1);
        URL baseurl = new URL(extBase);
        jc.setCurrentURL(baseurl);
       
        InputStream is = url.openStream();
        byte[] bytes = new byte[is.available()];
        is.read(bytes);

        InputStream scriptIStream = new ByteArrayInputStream(bytes);
        InputSource scriptISource = new InputSource(scriptIStream);

        is.close();
        is = null;
        bytes = null;

        rt.runFinalization();
        rt.gc();

        long start = rt.totalMemory() - rt.freeMemory();
        log.info("Starting memory test with used memory of " + start);

        XMLParser parser;
        Script script;

        int outputEveryXIterations = outputEveryXIterations();

        for (int i = 0; i < count; i++) {
            scriptIStream.reset();
            parser = new XMLParser();

            script = parser.parse(scriptISource);
            script.run(jc, output);
            // PL: I don't see why but removing the clear here
            //     does make the test fail!
            //     As if the WeakHashMap wasn't weak enough...
           
            //Hans: The structure of the relationship
            //  between TagScript and Tag prevents WeakHashMap
            //  from working in this case, which is why I removed it.
            jc.clear();

            if (outputEveryXIterations != 0 && i % outputEveryXIterations == 0) {
                parser = null;
                script = null;
               
View Full Code Here

     *
     * @param script is the URL to the script which should create a TestSuite
     * @return a newly created TestSuite
     */
    public static TestSuite createTestSuite(URL script) throws Exception {
        JellyContext context = new JellyContext(script);
        XMLOutput output = XMLOutput.createXMLOutput(System.out);
        context = context.runScript(script, output);
        TestSuite answer = (TestSuite) context.getVariable("org.apache.commons.jelly.junit.suite");
        if ( answer == null ) {
            log.warn( "Could not find a TestSuite created by Jelly for the script:" + script );
            // return an empty test suite
            return new TestSuite();
        }
View Full Code Here

     * @throws IOException
     */
    protected void doRequest(HttpServletRequest req, HttpServletResponse res)
        throws ServletException, IOException {

        JellyContext context = createContext(req, res);
        try {
            URL script = getScript(req);
            runScript(script, context, req, res);
        }
        catch (Exception e) {
View Full Code Here

     */
    protected JellyContext createContext(
        HttpServletRequest req,
        HttpServletResponse res) {

        JellyContext ctx = new JellyServletContext(getServletContext());
        ctx.setVariable(REQUEST, req);
        ctx.setVariable(RESPONSE, res);
        return ctx;
    }
View Full Code Here

            throw new MissingAttributeException(message);

        try {
            Class type     = ClassLoaderUtils.getClassLoader(getClass()).loadClass(className);
            Object result  = type.getField(field).get(null);
            JellyContext context = getContext();

            context.setVariable(var, result);

        } catch(Throwable t) {
            throw
                new JellyTagException("Could not access " + className + "." +
                                      var + ".  Original exception message: " +
View Full Code Here

public class ScopeTag extends TagSupport {

    // Tag interface
    //-------------------------------------------------------------------------
    public void doTag(XMLOutput output) throws JellyTagException {
        JellyContext newContext = context.newJellyContext();
        getBody().run(newContext, output);
    }
View Full Code Here

TOP

Related Classes of org.apache.commons.jelly.JellyContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.