Package com.volantis.xml.expression

Examples of com.volantis.xml.expression.Expression


    /**
     * Test invoke with a missing entity and no default.
     * @throws Exception
     */
    public void testInvokeMissing() throws Exception {
        Expression expression = parser.parse(getFunctionQName() + "('name')");

        addSingleValueExpectations("name", null);

        Value result = expression.evaluate(expressionContext);

        assertTrue("Result not a sequence",
                   result instanceof Sequence);
        assertTrue("Result sequence not empty",
                   ((Sequence)result).getLength() == 0);
View Full Code Here


    /**
     * Test invoke with a missing entity and a String default.
     * @throws Exception
     */
    public void testInvokeMissingStringDefault() throws Exception {
        Expression expression = parser.parse(getFunctionQName() +
            "('name', 'value')");

        addSingleValueExpectations("name", null);

        Value result = expression.evaluate(expressionContext);

        assertEquals("Result not as",
                     "value",
                     result.stringValue().asJavaString());
    }
View Full Code Here

    /**
     * Test invoke with a missing entity and a numeric default.
     * @throws Exception
     */
    public void testInvokeMissingNumericDefault() throws Exception {
        Expression expression = parser.parse(getFunctionQName() +
            "('name', 2)");

        addSingleValueExpectations("name", null);

        Value result = expression.evaluate(expressionContext);

        assertEquals("Result not as",
                     "2", // Numerics represent as floating
                     result.stringValue().asJavaString());
    }
View Full Code Here

     * Sub-classes must perform additional setup for this test
     * by overriding setUpInvokeHeaderIgnoreDefault.
     * @throws Exception
     */
    public void testInvokeIgnoreDefault() throws Exception {
        Expression expression = parser.parse(getFunctionQName() +
            "('name', 'fred')");

        addSingleValueExpectations("name", "value");

        Value result = expression.evaluate(expressionContext);

        assertEquals("Result not as",
                     "value",
                     result.stringValue().asJavaString());
    }
View Full Code Here

     * Test that the function can be evaluated with a [1] predicate
     * @throws Exception if an error occurs
     */
    public void testInvokeWithNumericPredicate() throws Exception {
        // parse the expression
        Expression expression = parser.parse(getFunctionQName() +
            "('name', 'default')[1]");

        // register the name value pair with the request
        addSingleValueExpectations("name", "value");

        // evaluate the expression
        Value result = expression.evaluate(expressionContext);

        // ensure that the correct value was returned
        assertEquals("Unexpected value returned",
                     "value",
                     result.stringValue().asJavaString());
View Full Code Here

     * is specified and no name value pair has been added to the request
     * @throws Exception if an error occurs
     */
    public void testInvokeWithNumericPredicateDefaUlt() throws Exception {
        // parse the expression
        Expression expression = parser.parse(getFunctionQName() +
            "('name', 'default')[1]");

        addSingleValueExpectations("name", null);

        // evaluate the expression
        Value result = expression.evaluate(expressionContext);

        // ensure that the correct value was returned
        assertEquals("Unexpected value returned",
                     "default",
                     result.stringValue().asJavaString());
View Full Code Here

     * is specified
     * @throws Exception if an error occurs
     */
    public void testInvokeWithNumericPredicateOutOfBounds() throws Exception {
        // parse the expression
        Expression expression = parser.parse(getFunctionQName() +
            "('name', 'default')[2]");

        addSingleValueExpectations("name", null);

        // evaluate the expression
        Value result = expression.evaluate(expressionContext);

        assertTrue("Result was not a Sequence instance",
                   result instanceof Sequence);

        Sequence sequence = (Sequence)result;
View Full Code Here

     * is specified and default is provided via constructor
     * @throws Exception if an error occurs
     */
    public void testDefaultInvokeWithNumericPredicateOutOfBounds() throws Exception {
        // parse the expression
        Expression expression = parser.parse(getFunctionQName() +
            "('name', 'default')[2]");

        // register the name value pair with the request
        addSingleValueExpectations("name", "value");

        // evaluate the expression
        Value result = expression.evaluate(expressionContext);

        assertTrue("Result was not a Sequence instance",
                   result instanceof Sequence);

        Sequence sequence = (Sequence)result;
View Full Code Here

     * @return the Value resulting from evaluating the expression
     * @throws ExpressionException if an error occurs
     */
    protected Value evaluateExpression() throws ExpressionException  {
        // create an expression
        Expression expression = parser.parse(getFunctionQName() +
                                             "('TestDevice')");

        // evalute the expression
        return expression.evaluate(expressionContext);
    }
View Full Code Here

     * Test invoke with a missing entity and no default.
     *
     * @throws Exception
     */
    public void testInvokeMissing() throws Exception {
        Expression expression = parser.parse(getFunctionQName() + "('name')");

        formatReferenceFinderMock.expects
                .getFormatReference("name", new int[]{})
                .returns(formatReferenceMock);

View Full Code Here

TOP

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

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.