Examples of SynapseXPath


Examples of org.apache.synapse.util.xpath.SynapseXPath

        MessageContext ctx =  TestUtils.getTestContext("<test>" + message + "</test>");
        assertEquals(message, xpath.stringValueOf(ctx));
    }

    public void testBodyRelativeXPath() throws Exception {
        SynapseXPath xpath = new SynapseXPath("$body/test");
        MessageContext ctx =  TestUtils.getTestContext("<test>" + message + "</test>");
        assertEquals(message, xpath.stringValueOf(ctx));
        Object node = xpath.selectSingleNode(ctx);
        assertTrue(node instanceof OMElement);
        assertEquals(message, ((OMElement)node).getText());
    }
View Full Code Here

Examples of org.apache.synapse.util.xpath.SynapseXPath

        OMFactory fac = ctx.getEnvelope().getOMFactory();
        OMNamespace ns = fac.createOMNamespace("http://test", "t");
        ctx.getEnvelope().getHeader().addHeaderBlock("test", ns).setText(message);
        ctx.getEnvelope().getHeader().addHeaderBlock("test2", ns);
       
        SynapseXPath xpath = new SynapseXPath("$header/t:test");
        xpath.addNamespace(ns);
        assertEquals(message, xpath.stringValueOf(ctx));
       
        xpath = new SynapseXPath("$header/*");
        assertEquals(2, xpath.selectNodes(ctx).size());
    }
View Full Code Here

Examples of org.apache.synapse.util.xpath.SynapseXPath

        xpath = new SynapseXPath("$header/*");
        assertEquals(2, xpath.selectNodes(ctx).size());
    }

    public void testContextProperties() throws Exception {
        SynapseXPath xpath = new SynapseXPath("$ctx:test");
        MessageContext synCtx = new TestMessageContext();
        synCtx.setProperty("test", message);
        assertEquals(xpath.evaluate(synCtx), message);
    }
View Full Code Here

Examples of org.apache.synapse.util.xpath.SynapseXPath

    public void testAxis2ContextProperties() throws Exception {
        Axis2MessageContext synCtx = TestUtils.getAxis2MessageContext("<test/>", null);
        synCtx.getAxis2MessageContext().setProperty("test", message);
        synCtx.getAxis2MessageContext().setProperty("test2", "1234");
        assertEquals(message, new SynapseXPath("$axis2:test").evaluate(synCtx));
        assertEquals(1234, new SynapseXPath("$axis2:test2").numberValueOf(synCtx).intValue());
        assertTrue(new SynapseXPath("$axis2:test2 = 1234").booleanValueOf(synCtx));
    }
View Full Code Here

Examples of org.apache.synapse.util.xpath.SynapseXPath

        assertTrue(new SynapseXPath("$axis2:test2 = 1234").booleanValueOf(synCtx));
    }
   
    public void testStandardXPathFunctions() throws Exception {
        MessageContext ctx = TestUtils.getTestContext("<test>123456</test>");
        assertEquals(6, new SynapseXPath("string-length(//test)").numberValueOf(ctx).intValue());
    }
View Full Code Here

Examples of org.apache.synapse.util.xpath.SynapseXPath

        MessageContext ctx = TestUtils.getTestContext("<test>123456</test>");
        assertEquals(6, new SynapseXPath("string-length(//test)").numberValueOf(ctx).intValue());
    }
   
    public void testCustomVariables() throws Exception {
        SynapseXPath xpath = new SynapseXPath("$myvar");
        SimpleVariableContext variableContext = new SimpleVariableContext();
        variableContext.setVariableValue("myvar", "myvalue");
        xpath.setVariableContext(variableContext);
        assertEquals("myvalue", xpath.evaluate(TestUtils.getTestContext("<test/>")));
    }
View Full Code Here

Examples of org.apache.synapse.util.xpath.SynapseXPath

        // create a new filter mediator
        FilterMediator filter = new FilterMediator();

        // set xpath condition to IBM
        SynapseXPath xpath = new SynapseXPath("//*[wsx:symbol='IBM']");
        xpath.addNamespace("wsx", "http://www.webserviceX.NET/");
        filter.setXpath(xpath);

        // set dummy mediator to be called on success
        filter.addChild(testMediator);

View Full Code Here

Examples of org.apache.synapse.util.xpath.SynapseXPath

        // create a new filter mediator
        FilterMediator filter = new FilterMediator();

        // set xpath condition to MSFT
        SynapseXPath xpath = new SynapseXPath("//*[wsx:symbol='MSFT']");
        xpath.addNamespace("wsx", "http://www.webserviceX.NET/");
        filter.setXpath(xpath);

        // set dummy mediator to be called on success
        filter.addChild(testMediator);

View Full Code Here

Examples of org.apache.synapse.util.xpath.SynapseXPath

        // create a new filter mediator
        FilterMediator filter = new FilterMediator();

        // set source xpath condition to //symbol
        SynapseXPath source = new SynapseXPath("//wsx:symbol");
        source.addNamespace("wsx", "http://www.webserviceX.NET/");
        filter.setSource(source);

        // set regex to IBM
        Pattern regex = Pattern.compile("IBM");
        filter.setRegex(regex);
View Full Code Here

Examples of org.apache.synapse.util.xpath.SynapseXPath

        // create a new filter mediator
        FilterMediator filter = new FilterMediator();

        // set source xpath condition to //symbol
        SynapseXPath source = new SynapseXPath("//wsx:symbol");
        source.addNamespace("wsx", "http://www.webserviceX.NET/");
        filter.setSource(source);

        // set regex to MSFT
        Pattern regex = Pattern.compile("MSFT");
        filter.setRegex(regex);
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.