Package com.volantis.xml.expression

Examples of com.volantis.xml.expression.Function.invoke()


     * @throws Exception
     */
    public void testFunction() throws Exception {
        final Function unionFunction = new UnionFunction();
        try {
            unionFunction.invoke(expressionContextMock, new Value[0]);
            fail("Exception wasn't thrown when empty arguments passed" +
                    " to function");
        } catch (Exception e) {
            // ignore it, expected situation
        }
View Full Code Here


            // ignore it, expected situation
        }
        assertSame("Function invoked with the empty sequences didn't" +
                " return the empty sequence",
                Sequence.EMPTY,
                unionFunction.invoke(expressionContextMock, new Value[] {
                        Sequence.EMPTY, Sequence.EMPTY
                }));
        final Sequence firstSequence =
                expressionContextMock.getFactory().createSequence(
                        new Item[] {
View Full Code Here

                                    .createStringValue("value0"),
                            expressionContextMock.getFactory()
                                    .createStringValue("value1"),
                            expressionContextMock.getFactory()
                                    .createBooleanValue(false)});
        final Sequence result = (Sequence) unionFunction.invoke(
                expressionContextMock, new Value[] {firstSequence,
                        secondSequence});
        assertEquals("number of elements in returned sequence is incorrect",
                5, result.getLength());
        assertEquals("incorrect element in returned sequence",
View Full Code Here

     * arguments
     */
    public void testNoArguments() {
        final Function function = new StringLengthFunction();
        try {
            function.invoke(expressionContextMock, new Value[]{});
            fail("Exception wasn't thrown when string-length was invoked with 0 arguments");
        } catch (ExpressionException e) {
            //do nothing, expected situation
        }
    }
View Full Code Here

     * with two arguments
     */
    public void testTwoArguments() {
        final Function function = new StringLengthFunction();
        try {
            function.invoke(expressionContextMock, new Value[]{
                    factory.createStringValue("arg1"),
                    factory.createStringValue("arg2")});
            fail("Exception wasn't thrown when string-length was invoked with 2 arguments");
        } catch (ExpressionException e) {
            //do nothing, expected situation
View Full Code Here

    /**
     * Tests if function works correctly for string
     */
    public void testString() throws ExpressionException {
        final Function function = new StringLengthFunction();
        Value result = function.invoke(expressionContextMock,
                new Value[]{factory.createStringValue("qwerty")});
        assertTrue(result instanceof IntValue);
        assertEquals(6, ((IntValue) result).asJavaInt());
    }
   
View Full Code Here

    /**
     * Tests if function returns 0 for empty sequence
     */
    public void testEmptySequence() throws ExpressionException {
        final Function function = new StringLengthFunction();
        Value result = function.invoke(expressionContextMock,
                new Value[]{factory.createSequence(new Item[]{})});
        assertTrue(result instanceof IntValue);
        assertEquals(0, ((IntValue) result).asJavaInt());
    }
}
View Full Code Here

     * arguments
     */
    public void testNoArguments() {
        final Function function = new CeilingFunction();
        try {
            function.invoke(expressionContextMock, new Value[]{});
            fail("Exception wasn't thrown when ceiling was invoked with 0 arguments");
        } catch (ExpressionException e) {
            //do nothing, expected situation
        }
    }
View Full Code Here

     * with two arguments
     */
    public void testTwoArguments() {
        final Function function = new CeilingFunction();
        try {
            function.invoke(expressionContextMock, new Value[]{
                    factory.createDoubleValue(10.0),
                    factory.createDoubleValue(20.0)});
            fail("Exception wasn't thrown when ceiling was invoked with 2 arguments");
        } catch (ExpressionException e) {
            //do nothing, expected situation
View Full Code Here

    /**
     * Tests if empty sequence is returned for empty sequence
     */
    public void testEmptySequence() throws ExpressionException {
        final Function function = new CeilingFunction();
        Value result = function.invoke(expressionContextMock,
                new Value[]{factory.createSequence(new Item[]{})});
        assertTrue(result instanceof Sequence);
        assertEquals(0, result.getSequence().getLength());
    }
   
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.