Package org.apache.commons.jelly

Examples of org.apache.commons.jelly.Script


        assertEquals("<html></html>x",bos.toString());
    }
   
    public void testOutputBad() throws Exception {
        setUpScript("outputBad.jelly");
        Script script = getJelly().compileScript();
       
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
       
        script.run(getJellyContext(),XMLOutput.createXMLOutput(bos));
        assertEquals("<html></html>",bos.toString());
    }
View Full Code Here


        assertEquals("<html></html>",bos.toString());
    }
   
    public void testOutputBadGood() throws Exception {
        setUpScript("outputBad.jelly");
        Script script = getJelly().compileScript();
       
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
       
        XMLOutput ouput = XMLOutput.createXMLOutput(bos);
       
        script.run(getJellyContext(),ouput);
        ouput.flush();
        assertEquals("<html></html>",bos.toString());
    }
View Full Code Here

        assertEquals("<html></html>",bos.toString());
    }
   
    public void testOutputData() throws Exception {
        setUpScript("outputData.jelly");
        Script script = getJelly().compileScript();

        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        XMLOutput ouput = XMLOutput.createXMLOutput(bos);

        script.run(getJellyContext(),ouput);
        ouput.flush();
        assertEquals("[string]",bos.toString().trim());
  }
View Full Code Here

    public void testParserCache1() throws Exception {
        // without validation, should
        // not fail because validation is disabled
        setUp("invalidScript1.jelly");
        jelly.setValidateXML(false);
        Script script = jelly.compileScript();
        script.run(context,xmlOutput);
        assertTrue("should have set 'foo' variable to 'bar'",
                   context.getVariable("foo").equals("bar"));

        // if I enable xml validation, the script should fail
        // despite the cache
View Full Code Here

    }

    public void testParserCache2() throws Exception {
        // no default namespace
        setUp("nsFilterTest.jelly");
        Script script = jelly.compileScript();
        script.run(context,xmlOutput);
        assertTrue("should have no var when default namspace is not set",
                   context.getVariable("usedDefaultNamespace") == null);

        // now we have a default namespace, so we
        // should see a variable, despite the XMLParser cache
        jelly.setDefaultNamespaceURI("jelly:core");
        script = jelly.compileScript();
        script.run(context,xmlOutput);
        assertTrue("should have var when default namspace is set",
                   context.getVariable("usedDefaultNamespace").equals("true"));
    }
View Full Code Here

        jelly.setUrl(url);
    }

    public void testNamespaceDefined() throws Exception {
        jelly.setDefaultNamespaceURI("jelly:core");
        Script script = jelly.compileScript();
        script.run(context,xmlOutput);
        assertTrue("should have set 'usedDefaultNamespace' variable",
                   context.getVariable("usedDefaultNamespace") != null);
    }
View Full Code Here

        assertTrue("should have set 'usedDefaultNamespace' variable",
                   context.getVariable("usedDefaultNamespace") != null);
    }

    public void testNamespaceNotDefined() throws Exception {
        Script script = jelly.compileScript();
        script.run(context,xmlOutput);
        assertTrue("should not have set 'usedDefaultNamespace' variable",
                   context.getVariable("usedDefaultNamespace") == null);
    }
View Full Code Here

     * @throws Exception
     */
    public void testCData() throws Exception {
        Jelly jelly = new Jelly();
        jelly.setScript("file:src/test/org/apache/commons/jelly/test/xml/testCData.jelly");
        Script script = jelly.compileScript();
        JellyContext context = new JellyContext();
        script.run(context, XMLOutput.createDummyXMLOutput());

        String output = (String) context.getVariable("foo");
        assertTrue("'foo' is not null", output != null);

        String golden = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
View Full Code Here

     * A script should fail to parse if it declares tags that don't exist.
     */
    public void testNonexistentTags() throws Exception {
        setUp("nonexistentTags1.jelly");
        try {
            Script script = jelly.compileScript();
            fail("Scripts should throw JellyException when it declares a nonexistent tag.");
        } catch (JellyException e) {
        }
    }
View Full Code Here

    }

    public void testDummyXMLOutput() throws Exception {
        // without validation
        setUp("producesOutput.jelly");
        Script script = this.jelly.compileScript();
        script.run(this.context,this.xmlOutput);
        assertTrue("should have set 'foo' variable to 'bar'",
                   this.context.getVariable("foo").equals("bar"));

    }
View Full Code Here

TOP

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

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.