Package org.apache.commons.jelly

Examples of org.apache.commons.jelly.Script


    }

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

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

        String varNotBroken = (String) getJellyContext().getVariable("varNotBroken");

        assertEquals("varNotBroken", "false", varNotBroken);
    }
View Full Code Here


     *  Gets the System property 'java.runtime.version' and compares it with,
     *  well, the same system property
     */
     public void testSimpleSystemInvoke() throws Exception {
        setUpScript( "testInvokeStaticTag.jelly" );
        Script script = getJelly().compileScript();

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

        getJellyContext().setVariable( "propertyName", "java.runtime.version" );
        script.run( getJellyContext(),getXMLOutput() );

        assertTrue( System.getProperty( "java.runtime.version" ).equals( getJellyContext().getVariable("propertyName" ) ) );
    }
View Full Code Here

     *  Sets the System property 'TEST PROPERTY' to the value 'Jelly is cool' and compares it with,
     *  well, the same system property
     */
    public void testSystemInvoke() throws Exception {
        setUpScript( "testInvokeStaticTag.jelly" );
        Script script = getJelly().compileScript();

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

        getJellyContext().setVariable( "propertyName", "TEST PROPERTY" );
        getJellyContext().setVariable( "propertyValue", "Jelly is cool" );
        script.run( getJellyContext(),getXMLOutput() );

        assertTrue( System.getProperty( "TEST PROPERTY" ).equals( "Jelly is cool" ) );

    }
View Full Code Here

     *  with 3 arguments.
     */
    public void testMessageFormatInvoke() throws Exception {
        System.out.println( System.getProperties() );
        setUpScript( "testInvokeStaticTag.jelly" );
        Script script = getJelly().compileScript();

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

        Object[] args = new Object[3];
        args[0] = "Jelly";
        args[1] = "coolest";
        args[2] = "used";

        getJellyContext().setVariable( "args", args );
        getJellyContext().setVariable( "message", "Is not {0} the {1} thing you have ever {2}?" );
        script.run( getJellyContext(),getXMLOutput() );

        assertNotNull( getJellyContext().getVariable("message") );
        assertTrue( getJellyContext().getVariable("message").equals("Is not Jelly the coolest thing you have ever used?") );

    }
View Full Code Here

    }

    public void testInvokeThatThrowsException() throws Exception {
        setUpScript( "testInvokeStaticTag.jelly" );
        Script script = getJelly().compileScript();
        getJellyContext().setVariable("test.invokeThatThrowsException",Boolean.TRUE);
        script.run(getJellyContext(),getXMLOutput());
        String exceptionMessage = (String) getJellyContext().getVariable("exceptionMessage");
        assertNotNull( exceptionMessage );
        Exception jellyException = (Exception) getJellyContext().getVariable("jellyException");
        assertNull( jellyException );
        Exception exception = (Exception) getJellyContext().getVariable("exceptionThrown");
View Full Code Here

        assertEquals( exceptionMessage, exception.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()) );
View Full Code Here

    }

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

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

        String resultTrue = (String) getJellyContext().getVariable("result.true");
        String resultFalse = (String) getJellyContext().getVariable("result.false");

        assertEquals("result.true", "AC", resultTrue);
View Full Code Here

        super.tearDown();
    }

    public void testSimpleInvoke() throws Exception {
        setUpScript("testInvokeTag.jelly");
        Script script = getJelly().compileScript();
        getJellyContext().setVariable("test.simpleInvoke",Boolean.TRUE);
        script.run(getJellyContext(),getXMLOutput());
        assertNotNull(getJellyContext().getVariable("foo"));
        assertTrue(getJellyContext().getVariable("foo") instanceof Customer);
        Customer customer = (Customer)(getJellyContext().getVariable("foo"));
        assertEquals("Jane Doe",customer.getName());
        assertEquals("Chicago",customer.getCity());
View Full Code Here

        assertNotNull(customer.getOrders().get(0));
    }

    public void testInvokeWithVar() throws Exception {
        setUpScript("testInvokeTag.jelly");
        Script script = getJelly().compileScript();
        getJellyContext().setVariable("test.invokeWithVar",Boolean.TRUE);
        script.run(getJellyContext(),getXMLOutput());
        assertNotNull(getJellyContext().getVariable("size"));
        assertTrue(getJellyContext().getVariable("size") instanceof Integer);
        Integer size = (Integer)(getJellyContext().getVariable("size"));
        assertEquals(3,size.intValue());
    }
View Full Code Here

        assertEquals(3,size.intValue());
    }

    public void testInvokeWithReturnedValueAsArg() throws Exception {
        setUpScript("testInvokeTag.jelly");
        Script script = getJelly().compileScript();
        getJellyContext().setVariable("test.invokeWithReturnedValueAsArg",Boolean.TRUE);
        script.run(getJellyContext(),getXMLOutput());
        assertNotNull(getJellyContext().getVariable("customer"));
        assertTrue(getJellyContext().getVariable("customer") instanceof Customer);
        Customer customer = (Customer)(getJellyContext().getVariable("customer"));
        assertEquals("Jane Doe",customer.getName());
        assertEquals("Chicago",customer.getCity());
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.