Package com.volantis.xml.expression

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


     * @throws Exception
     */
    public void testFunction() throws Exception {
        final Function intersectFunction = new IntersectFunction();
        try {
            intersectFunction.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,
                intersectFunction.invoke(expressionContextMock, new Value[] {
                        Sequence.EMPTY, Sequence.EMPTY
                }));
        final Sequence firstSequence =
                expressionContextMock.getFactory().createSequence(
                        new Item[] {
View Full Code Here

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

     * arguments
     */
    public void testNoArguments() {
        final Function function = new CountFunction();
        try {
            function.invoke(expressionContextMock, new Value[]{});
            fail("Exception wasn't thrown when count 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 CountFunction();
        try {
            function.invoke(expressionContextMock, new Value[]{
                    factory.createStringValue("arg1"),
                    factory.createStringValue("arg2")});
            fail("Exception wasn't thrown when count was invoked with 2 arguments");
        } catch (ExpressionException e) {
            //do nothing, expected situation
View Full Code Here

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

    /**
     * Tests if 1 is returned for integer
     */
    public void testIntValue() throws ExpressionException {
        final Function function = new CountFunction();
        Value result = function.invoke(expressionContextMock,
                new Value[]{factory.createIntValue(3)});
        assertTrue(result instanceof IntValue);
        assertEquals(1, ((IntValue) result).asJavaInt());
    }
   
View Full Code Here

    /**
     * Tests if 1 is returned for string
     */
    public void testStringValue() throws ExpressionException {
        final Function function = new CountFunction();
        Value result = function.invoke(expressionContextMock,
                new Value[]{factory.createStringValue("abc")});
        assertTrue(result instanceof IntValue);
        assertEquals(1, ((IntValue) result).asJavaInt());
    }
   
View Full Code Here

    /**
     * Tests if function works correctly for sequences
     */
    public void testSequence() throws ExpressionException {
        final Function function = new CountFunction();
        Value result = function.invoke(expressionContextMock, new Value[]{
                factory.createSequence(new Item[]{
                        factory.createBooleanValue(true),
                        factory.createStringValue("abc"),
                        DoubleValue.NOT_A_NUMBER,
                        factory.createDurationValue(true, 2, 2, 3, 1, 0, 6, 100)
View Full Code Here

     * arguments
     */
    public void testNoArguments() {
        final Function function = new NormalizeSpaceFunction();
        try {
            function.invoke(expressionContextMock, new Value[]{});
            fail("Exception wasn't thrown when normalize-space was invoked with 0 arguments");
        } catch (ExpressionException e) {
            //do nothing, expected situation
        }
    }
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.