Package com.volantis.xml.expression

Examples of com.volantis.xml.expression.Function


     * Test for xs:years-from-duration() function.
     *
     * @throws Exception thrown by tested function
     */
    public void testYearsFromDuration() throws Exception {
        final Function function = new YearsFromDurationFunction();
        DurationValue duration;
        Value result;

        duration =
                factory.createDurationValue(true, 20, 15, 0, 0, 0, 0, 0);
        result = function.invoke(
                expressionContextMock,
                new Value[] { duration });
        assertEquals(result, factory.createIntValue(21));

        duration =
                factory.createDurationValue(false, 0, 15, 0, 0, 0, 0, 0);
        result = function.invoke(
                expressionContextMock,
                new Value[] { duration });
        assertEquals(result, factory.createIntValue(-1));

        duration =
                factory.createDurationValue(false, 0, 0, 2, 15, 0, 0, 0);
        result = function.invoke(
                expressionContextMock,
                new Value[] { duration });
        assertEquals(result, factory.createIntValue(0));
    }
View Full Code Here


     * Tests the empty sequence input gives an empty sequence result.
     */
    public void testEmptySequenceInput() throws Exception {
        ExpressionContext context = createExpressionContext();
        ExpressionFactory factory = context.getFactory();
        Function tokenize = new TokenizeFunction();
        Sequence sequence = Sequence.EMPTY;
        Value search = factory.createStringValue("a");
        Value retVal = tokenize.invoke(context, new Value[]{sequence, search});

        final Sequence retSeq = retVal.getSequence();

        // Should have returned ()
        assertSame(retSeq, Sequence.EMPTY);
View Full Code Here

     * Tests the empty string input gives an empty sequence result.
     */
    public void testEmptyStringInput() throws Exception {
        ExpressionContext context = createExpressionContext();
        ExpressionFactory factory = context.getFactory();
        Function tokenize = new TokenizeFunction();
        Sequence sequence = createSequence(factory,
                new String[]{""});
        Value search = factory.createStringValue("a");
        Value retVal = tokenize.invoke(context, new Value[]{sequence, search});

        final Sequence retSeq = retVal.getSequence();

        // Should have returned ()
        assertSame(retSeq, Sequence.EMPTY);
View Full Code Here

     * Tests that the empty pattern throws an ExpressionException.
     */
    public void testEmptyPattern() throws Exception {
        ExpressionContext context = createExpressionContext();
        ExpressionFactory factory = context.getFactory();
        Function tokenize = new TokenizeFunction();
        Sequence sequence = createSequence(factory,
                new String[]{"my search string"});
        Value pattern = factory.createStringValue("");
        try {
            Value retVal = tokenize.invoke(context,
                    new Value[]{sequence, pattern});
            fail("An empty pattern should result in an ExpressionException");
        } catch (ExpressionException ee) {
            // This exception is expected
        }
View Full Code Here

     * Tests that pattern at start gives an empty string token at start.
     */
    public void testStartsWithPattern() throws Exception {
        ExpressionContext context = createExpressionContext();
        ExpressionFactory factory = context.getFactory();
        Function tokenize = new TokenizeFunction();
        Sequence sequence = createSequence(factory,
                new String[]{"abcdefghicat"});
        Value pattern = factory.createStringValue("abc");
        Value retVal = tokenize.invoke(context,
                new Value[]{sequence, pattern});

        final Sequence retSeq = retVal.getSequence();

        doSequenceEquality(retSeq, new String[]{"", "defghicat"});
View Full Code Here

     * Tests that pattern at end gives an empty string token at end.
     */
    public void testEndsWithPattern() throws Exception {
        ExpressionContext context = createExpressionContext();
        ExpressionFactory factory = context.getFactory();
        Function tokenize = new TokenizeFunction();
        Sequence sequence = createSequence(factory,
                new String[]{"abcdefghicat"});
        Value pattern = factory.createStringValue("cat");
        Value retVal = tokenize.invoke(context,
                new Value[]{sequence, pattern});

        final Sequence retSeq = retVal.getSequence();

        doSequenceEquality(retSeq, new String[]{"abcdefghi", ""});
View Full Code Here

     * Tests a regexp whitespace pattern.
     */
    public void testWhitespacePattern() throws Exception {
        ExpressionContext context = createExpressionContext();
        ExpressionFactory factory = context.getFactory();
        Function tokenize = new TokenizeFunction();
        Sequence sequence = createSequence(factory,
                new String[]{"the cat  sat   on    the     mat"});
        Value pattern = factory.createStringValue("\\s+");
        Value retVal = tokenize.invoke(context,
                new Value[]{sequence, pattern});

        final Sequence retSeq = retVal.getSequence();

        doSequenceEquality(retSeq,
View Full Code Here

     * Tests a 'comma x' pattern.
     */
    public void testCommaPattern() throws Exception {
        ExpressionContext context = createExpressionContext();
        ExpressionFactory factory = context.getFactory();
        Function tokenize = new TokenizeFunction();
        Sequence sequence = createSequence(factory,
                new String[]{"thexcat,x,xxxsatxxxxon,thexxxxxmat"});
        Value pattern = factory.createStringValue(",x");
        Value retVal = tokenize.invoke(context,
                new Value[]{sequence, pattern});

        final Sequence retSeq = retVal.getSequence();

        doSequenceEquality(retSeq,
View Full Code Here

     * results.
     */
    public void testStringEqualsPattern() throws Exception {
        ExpressionContext context = createExpressionContext();
        ExpressionFactory factory = context.getFactory();
        Function tokenize = new TokenizeFunction();
        Sequence sequence = createSequence(factory,
                new String[]{"one big long missspelt sentence"});
        Value pattern =
                factory.createStringValue("one big long missspelt sentence");
        Value retVal = tokenize.invoke(context,
                new Value[]{sequence, pattern});

        final Sequence retSeq = retVal.getSequence();

        doSequenceEquality(retSeq, new String[]{""});
View Full Code Here

     */
    public void testStringEqualsMultipleSingleLetterPattern()
            throws Exception {
        ExpressionContext context = createExpressionContext();
        ExpressionFactory factory = context.getFactory();
        Function tokenize = new TokenizeFunction();
        Sequence sequence = createSequence(factory,
                new String[]{"xxxxxxxxxx"});
        Value pattern = factory.createStringValue("x");
        Value retVal = tokenize.invoke(context,
                new Value[]{sequence, pattern});

        final Sequence retSeq = retVal.getSequence();

        doSequenceEquality(retSeq,
View Full Code Here

TOP

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

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.