Package com.volantis.xml.expression

Examples of com.volantis.xml.expression.Value


     * Test the concat function with arguments of various types
     * @throws Exception if an error occurs
     */
    public void testConcatDifferentTypes() throws Exception {

        Value one = factory.createIntValue(1);

        context.getCurrentScope().declareVariable(
                        new ImmutableExpandedName("", "myVar"),
                        one);

        context.getCurrentScope().declareVariable(
                        new ImmutableExpandedName("", "emptySeq"),
                        Sequence.EMPTY);

        context.getCurrentScope().declareVariable(
                        new ImmutableExpandedName("", "singleSeq"),
                        factory.createSequence(new Item[]
                        {factory.createStringValue("one")}));

        Expression exp = compileExpression(
                "concat(true(), 25.9, $emptySeq, $myVar, $singleSeq)");

        Value result = exp.evaluate(context);

        assertTrue("fn:concat should result in a String value",
                   result instanceof StringValue);

        assertEquals("fn:concat expression result should be 'true25.91one'",
View Full Code Here


     */
    public void testSimpleAndOperator() throws Exception {

        Expression exp = compileExpression("2 = 2 and 3 = 3");

        Value result = exp.evaluate(context);

        assertTrue("AND expression should result in a boolean value",
                   result instanceof BooleanValue);

        assertTrue("AND expression result should be true",
View Full Code Here

     * Another test for the AND operator
     * @throws Exception if an error occurs
     */
    public void testAndOperatorWithVariables() throws Exception {

        Value one = factory.createIntValue(1);

        context.getCurrentScope().declareVariable(
                new ImmutableExpandedName("", "myVar"),
                one);


        Expression exp = compileExpression("$myVar <= 1 and 4 > $myVar");

        Value result = exp.evaluate(context);

        assertTrue("AND expression should result in a boolean value",
                   result instanceof BooleanValue);

        assertTrue("AND expression result should be true",
View Full Code Here

     */
    public void testSimpleOrOperator() throws Exception {

        Expression exp = compileExpression("2 = 3 or 3 = 3");

        Value result = exp.evaluate(context);

        assertTrue("OR expression should result in a boolean value",
                   result instanceof BooleanValue);

        assertTrue("OR expression result should be true",
View Full Code Here

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

     * another test for the OR operator
     * @throws Exception if an error occurs
     */
    public void testOrOperatorWithVariables() throws Exception {

        Value one = factory.createIntValue(1);

        context.getCurrentScope().declareVariable(
                new ImmutableExpandedName("", "myVar"),
                one);


        Expression exp = compileExpression("$myVar <= 1 or 0 > $myVar");

        Value result = exp.evaluate(context);

        assertTrue("OR expression should result in a boolean value",
                   result instanceof BooleanValue);

        assertTrue("OR expression result should be true",
View Full Code Here

    /**
     * Tests max on sequence of integers and doubles
     */
    public void testSequenceOfNumbers() throws ExpressionException {
        final Function function = new MaxFunction();
        Value result = function.invoke(expressionContextMock, new Value[]{
                factory.createSequence(new Item[]{
                      factory.createIntValue(6),
                      factory.createIntValue(3),
                      factory.createDoubleValue(4.3)
                })});
View Full Code Here

     * Tests on sequence of strings. Values should be compared using
     * Unicode code point collation (http://www.w3.org/2005/xpath-functions/collation/codepoint).
     */
    public void testSequenceOfStrings() throws ExpressionException {
        final Function function = new MaxFunction();
        Value result = function.invoke(expressionContextMock, new Value[]{
                factory.createSequence(new Item[]{
                      factory.createStringValue("qwe"),
                      factory.createStringValue("rty"),
                      factory.createStringValue("asd")
                })});
        assertTrue(result instanceof StringValue);
        assertEquals("rty", result.stringValue().asJavaString());
    }
View Full Code Here

                result);

        Expression exp = compileExpression("$myVar != \"" +
                                           result.stringValue().
                                           asJavaString() + "\"");
        Value result = exp.evaluate(context);

        assertTrue("Inequality expression should result in a boolean value",
                   result instanceof BooleanValue);
        assertFalse("Inequality expression result should be false",
                    ((BooleanValue) result).asJavaBoolean());
View Full Code Here

                });

        Expression exp = compileExpression("function:test(((\"a\"),\"b\"), "
                          + "(\"c\",\"d\"), \"e\")");

        Value eval = exp.evaluate(context);
       
        assertTrue("Expression should result in a string value",
                   eval instanceof StringValue);

        assertEquals("Expression result not as",
                     "(a, b), (c, d), e",  eval.stringValue().asJavaString());
    }
View Full Code Here

TOP

Related Classes of com.volantis.xml.expression.Value

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.