Package org.apache.commons.jelly

Examples of org.apache.commons.jelly.Script


    }

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

        // do it again, explicitly setting the validateXML variable
        setUp("invalidScript1.jelly");
        jelly.setValidateXML(false);
        script = jelly.compileScript();
        script.run(context,xmlOutput);
        assertTrue("should have set 'foo' variable to 'bar'",
                   context.getVariable("foo").equals("bar"));
    }
View Full Code Here


    public void testInvalidXML1Validation() throws Exception {
        // with validation
        setUp("invalidScript1.jelly");
        jelly.setValidateXML(true);
        try {
            Script script = jelly.compileScript();
            fail("Invalid scripts should throw JellyException on parse");
        } catch (JellyException e) {
        }
    }
View Full Code Here

    public void testValidXML1Validation()throws Exception {
        // with validation
        setUp("validScript1.jelly");
        jelly.setValidateXML(true);
        Script script = jelly.compileScript();
        script.run(context,xmlOutput);
        assertTrue("should have set 'foo' variable to 'bar'",
                   context.getVariable("foo").equals("bar"));
    }
View Full Code Here

    }

    public void testForEachTag() throws Exception
    {
        setUpScript("testForEachTag.jelly");
        Script script = getJelly().compileScript();

        getJellyContext().setVariable("myList",
              new Object[] {"0", "VOID", "1", "VOID", "2", "VOID",
                            "3", "VOID", "4", "VOID", "5"});
        getJellyContext().setVariable("testMyList", Boolean.TRUE);
        script.run(getJellyContext(), getXMLOutput());

        String resultOrdered =
                (String) getJellyContext().getVariable("result.ordered");
        System.err.println("raw result is '" + resultOrdered + "'");
        resultOrdered = StringUtils.replace(resultOrdered, " ", "");
View Full Code Here

    }
   
    public void testForEachTagNumList() throws Exception
    {
        setUpScript("testForEachTag.jelly");
        Script script = getJelly().compileScript();

        getJellyContext().setVariable("testNumList", Boolean.TRUE);
        script.run(getJellyContext(), getXMLOutput());

        String resultOrdered =
                (String) getJellyContext().getVariable("result.ordered");
        System.err.println("raw result is '" + resultOrdered + "'");
        resultOrdered = StringUtils.replace(resultOrdered, " ", "");
View Full Code Here

    public void testGetIntegerMaxValue() throws Exception {

        setUpScript( "testGetStaticTag.jelly" );

        Script script = getJelly().compileScript();

        getJellyContext().setVariable( "test.Integer.MAX_VALUE",
                                       Boolean.TRUE );

        script.run( getJellyContext(), getXMLOutput() );

        assertEquals( new Integer(java.lang.Integer.MAX_VALUE),
                      getJellyContext().getVariable("value" ) );
    }
View Full Code Here

    public void testInvalidGet() throws Exception {

        setUpScript( "testGetStaticTag.jelly" );

        Script script = getJelly().compileScript();

        getJellyContext().setVariable( "test.InvalidGet", Boolean.TRUE );

        try {
            script.run( getJellyContext(), getXMLOutput() );
        } catch(JellyTagException jte) {
            return;
        }

        fail("JellyTagException not thrown.");
View Full Code Here

     * Test a simple useBean tag works ok
     * @throws Exception
     */
    public void testSimple() throws Exception{
        setUpScript("testUseBeanTag.jelly");
        Script script = getJelly().compileScript();
        getJellyContext().setVariable("test.simple",Boolean.TRUE);
        script.run(getJellyContext(),getXMLOutput());
        assertNotNull(getJellyContext().getVariable("foo"));
        assertTrue(getJellyContext().getVariable("foo") instanceof Customer);
        Customer customer = (Customer)(getJellyContext().getVariable("foo"));
        assertEquals("name not set", "testing", customer.getName());
        assertEquals("city not set", "sydney", customer.getCity());
View Full Code Here

    /**
     * test extension
     */
    public void testExtension() throws Exception {
        setUpScript("testUseBeanTag.jelly");
        Script script = getJelly().compileScript();
        getJellyContext().setVariable("test.extension",Boolean.TRUE);
        script.run(getJellyContext(),getXMLOutput());
        assertNotNull(getJellyContext().getVariable("foo"));
        assertTrue(getJellyContext().getVariable("foo") instanceof Customer);
        Customer customer = (Customer)(getJellyContext().getVariable("foo"));
        assertNull("name set wrongly", customer.getName());
        assertEquals("city not set", "sydney", customer.getCity());
View Full Code Here

    /** Test set a bad property name on a bean, should fail.
     * @throws Exception
     */
    public void testBadProperty() throws Exception {
        setUpScript("testUseBeanTag.jelly");
        Script script = getJelly().compileScript();
        getJellyContext().setVariable("test.badProperty",Boolean.TRUE);
        script.run(getJellyContext(),getXMLOutput());
        Exception e = (Exception)getJellyContext().getVariable("ex");
        assertNotNull("Should have failed to set invalid bean property", e);
    }
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.