Java Code Examples for org.apache.axiom.om.util.AXIOMUtil

The following examples show how to use org.apache.axiom.om.util.AXIOMUtil. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
@Test(groups = { "wso2.esb" }, description = "number of messages is equal to the minimum")
public void testEqualtoMinimum() throws IOException, XMLStreamException {
    int responseCount = 0;
    no_of_requests = 50;
    aggregatedRequestClient.setNoOfIterations(no_of_requests);
    String Response = aggregatedRequestClient.getResponse();
    Assert.assertNotNull(Response);
    OMElement Response2 = AXIOMUtil.stringToOM(Response);
    OMElement soapBody = Response2.getFirstElement();
    Iterator iterator = soapBody.getChildrenWithName(new QName("http://services.samples", "getQuoteResponse"));

    while (iterator.hasNext()) {
        responseCount++;
        OMElement getQuote = (OMElement) iterator.next();
        Assert.assertTrue(getQuote.toString().contains("IBM"));
    }

    Assert.assertEquals(responseCount, no_of_requests, "GetQuoteResponse Element count mismatched");

}
 
Example 2
Source Project: micro-integrator   Source File: JMSEndpointManager.java    License: Apache License 2.0 6 votes vote down vote up
public static OMElement setConfigurations(OMElement synapseConfig) throws XMLStreamException {

        if (true) {
            //return same configurations as for the ActiveMQ
            return synapseConfig;
        } else {
            //changing the configurations to work with WSO2 MB instead of ActiveMQ
            String config = synapseConfig.toString();
            config = config.replace("org.apache.activemq.jndi.ActiveMQInitialContextFactory",
                                    "org.wso2.andes.jndi.PropertiesFileInitialContextFactory");

            config = config.replace("tcp://127.0.0.1:61616", "repository/conf/jndi.properties");
            config = config.replace("tcp://localhost:61616", "repository/conf/jndi.properties");
            return AXIOMUtil.stringToOM(config);
        }
    }
 
Example 3
@Test(groups = { "wso2.esb" }, description = "less number of messages than minimum count")
public void testLessThanMinimum() throws IOException, XMLStreamException {
    int responseCount = 0;

    no_of_requests = 20;
    aggregatedRequestClient.setNoOfIterations(no_of_requests);
    String Response = aggregatedRequestClient.getResponse();
    Assert.assertNotNull(Response);
    OMElement Response2 = AXIOMUtil.stringToOM(Response);
    OMElement soapBody = Response2.getFirstElement();
    Iterator iterator = soapBody.getChildrenWithName(new QName("http://services.samples", "getQuoteResponse"));

    while (iterator.hasNext()) {
        responseCount++;
        OMElement getQuote = (OMElement) iterator.next();
        Assert.assertTrue(getQuote.toString().contains("IBM"));
    }

    Assert.assertEquals(responseCount, no_of_requests, "GetQuoteResponse Element count mismatched");

}
 
Example 4
private WSDataSourceMetaInfo getDataSourceInformation(String dataSourceName) throws XMLStreamException {
    WSDataSourceMetaInfo dataSourceInfo = new WSDataSourceMetaInfo();

    dataSourceInfo.setName(dataSourceName);

    WSDataSourceMetaInfo_WSDataSourceDefinition dataSourceDefinition = new WSDataSourceMetaInfo_WSDataSourceDefinition();

    dataSourceDefinition.setType("RDBMS");
    OMElement dsConfig = AXIOMUtil.stringToOM(
            "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" + "<configuration>\n"
                    + "<driverClassName>" + sqlDataSource.getDriver() + "</driverClassName>\n" + "<url>"
                    + sqlDataSource.getJdbcUrl() + "</url>\n" + "<username>" + sqlDataSource.getDatabaseUser()
                    + "</username>\n" + "<password encrypted=\"true\">" + sqlDataSource.getDatabasePassword()
                    + "</password>\n" + "</configuration>");

    dataSourceDefinition.setDsXMLConfiguration(dsConfig.toString());
    dataSourceInfo.setDefinition(dataSourceDefinition);

    return dataSourceInfo;
}
 
Example 5
@Test(groups = { "wso2.esb" }, description = "more number of messages than maximum count")
public void testMoreNumberThanMaximum() throws IOException, XMLStreamException {
    int responseCount = 0;
    no_of_requests = 15;
    aggregatedRequestClient.setNoOfIterations(no_of_requests);
    String Response = aggregatedRequestClient.getResponse();
    Assert.assertNotNull(Response);
    OMElement Response2 = AXIOMUtil.stringToOM(Response);
    OMElement soapBody = Response2.getFirstElement();
    Iterator iterator = soapBody.getChildrenWithName(new QName("http://services.samples", "getQuoteResponse"));

    while (iterator.hasNext()) {
        responseCount++;
        OMElement getQuote = (OMElement) iterator.next();
        Assert.assertTrue(getQuote.toString().contains("IBM"));
    }
    Assert.assertTrue(minMessageCount <= responseCount && responseCount <= maxMessageCount);

}
 
Example 6
Source Project: micro-integrator   Source File: DBUtils.java    License: Apache License 2.0 6 votes vote down vote up
public static String getConnectionURL4XADataSource(Config config) throws XMLStreamException {
    String connectionURL = null;
    String connectionProperty = config.getProperty(DBConstants.RDBMS.DATASOURCE_PROPS);
    if (connectionProperty != null) {
        OMElement payload = AXIOMUtil.stringToOM(connectionProperty);
        Map<String, String> properties = extractProperties(payload);
        Collection<String> propValues = properties.values();
        for (String propValue : propValues) {
            if (propValue.startsWith("jdbc:")) {
                connectionURL = propValue;
                break;
            }
        }
    }
    return connectionURL;
}
 
Example 7
Source Project: micro-integrator   Source File: VFSTransportTestCase.java    License: Apache License 2.0 6 votes vote down vote up
private void addVFSProxy1() throws Exception {

        String proxyName = "VFSProxy1";

        OMElement proxy = AXIOMUtil.stringToOM("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
                + "<proxy xmlns=\"http://ws.apache.org/ns/synapse\" name=\"VFSProxy1\" transports=\"vfs\">\n"
                + "                <parameter name=\"transport.vfs.FileURI\">file://" + pathToVfsDir + "test"
                + File.separator + proxyName + File.separator + "in" + File.separator + "</parameter> <!--CHANGE-->\n"
                + "                <parameter name=\"transport.vfs.ContentType\">text/xml</parameter>\n"
                + "                <parameter name=\"transport.vfs.FileNamePattern\">.*\\.xml</parameter>\n"
                + "                <parameter name=\"transport.PollInterval\">1</parameter>\n"
                + "                <target>\n" + "                        <endpoint>\n"
                + "                                <address format=\"soap12\" uri=\"http://localhost:9000/services/SimpleStockQuoteService\"/>\n"
                + "                        </endpoint>\n" + "                        <outSequence>\n"
                + "                           <log level=\"full\"/>\n"
                + "                                <property action=\"set\" name=\"OUT_ONLY\" value=\"true\"/>\n"
                + "                                <send>\n" + "                                        <endpoint>\n"
                + "                                                <address uri=\"vfs:file://" + pathToVfsDir + "test"
                + File.separator + proxyName + File.separator + "out" + File.separator + "out.xml\"/> <!--CHANGE-->\n"
                + "                                        </endpoint>\n" + "                                </send>\n"
                + "                        </outSequence>\n" + "                </target>\n" + "        </proxy>");
        addProxy(proxy, proxyName);
    }
 
Example 8
@Test(groups = { "wso2.esb" }, description = "higher number of messages than minimum count")
public void testMoreNumberThanMinimum() throws IOException, XMLStreamException {
    int responseCount = 0;
    no_of_requests = 8;
    aggregatedRequestClient.setNoOfIterations(no_of_requests);
    String Response = aggregatedRequestClient.getResponse();
    Assert.assertNotNull(Response);
    OMElement Response2 = AXIOMUtil.stringToOM(Response);
    OMElement soapBody = Response2.getFirstElement();
    Iterator iterator = soapBody.getChildrenWithName(new QName("http://services.samples", "getQuoteResponse"));

    while (iterator.hasNext()) {
        responseCount++;
        OMElement getQuote = (OMElement) iterator.next();
        Assert.assertTrue(getQuote.toString().contains("IBM"));
    }
    Assert.assertTrue(minMessageCount <= responseCount && responseCount <= no_of_requests);

}
 
Example 9
Source Project: micro-integrator   Source File: VFSTransportTestCase.java    License: Apache License 2.0 6 votes vote down vote up
private void addVFSProxy6() throws Exception {

        String proxyName = "VFSProxy6";
        OMElement proxy = AXIOMUtil.stringToOM("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
                + "<proxy xmlns=\"http://ws.apache.org/ns/synapse\" name=\"VFSProxy6\" transports=\"vfs\">\n"
                + "                <parameter name=\"transport.vfs.FileURI\">" + pathToVfsDir + "test"
                + File.separator + proxyName + File.separator + "in" + File.separator + "</parameter> <!--CHANGE-->\n"
                + "                <parameter name=\"transport.vfs.ContentType\">text/plain</parameter>\n"
                + "                <parameter name=\"transport.vfs.FileNamePattern\">.*.txt</parameter>"
                + "                <parameter name=\"transport.PollInterval\">30</parameter>\n"
                + "                <target>\n" + "                        <inSequence>\n"
                + "                           <property action=\"set\" name=\"OUT_ONLY\" value=\"true\"/>\n"
                + "                           <log level=\"full\"/>\n" + "                           <send>\n"
                + "                               <endpoint name=\"FileEpr\">\n"
                + "                                   <address uri=\"vfs:file://" + pathToVfsDir + "test"
                + File.separator + proxyName + File.separator + "out" + File.separator + "out.txt\"/>\n"
                + "                               </endpoint>\n" + "                           </send>"
                + "                        </inSequence>" + "                </target>\n" + "        </proxy>");
        addProxy(proxy, proxyName);
    }
 
Example 10
Source Project: micro-integrator   Source File: NestedAggregatesTestCase.java    License: Apache License 2.0 6 votes vote down vote up
@Test(groups = { "wso2.esb" }, description = "sending nested aggregate request > request iterator count 2500")
public void testNestedAggregateWithLargeMessage() throws IOException, XMLStreamException {
    int messageItr = 15;
    String response = aggregatedRequestClient.getResponse(createNestedQuoteRequestBody("WSO2", messageItr));
    OMElement response2 = AXIOMUtil.stringToOM(response);
    OMElement soapBody = response2.getFirstElement();
    Iterator iterator = soapBody.getChildrenWithName(new QName("http://services.samples", "getQuoteResponse"));

    int responseCount = 0;
    while (iterator.hasNext()) {
        responseCount++;
        OMElement getQuote = (OMElement) iterator.next();
        Assert.assertTrue(getQuote.toString().contains("WSO2 Company"));
    }

    Assert.assertEquals(responseCount, messageItr * messageItr, "Response count Mismatched");
}
 
Example 11
Source Project: micro-integrator   Source File: VFSTransportTestCase.java    License: Apache License 2.0 6 votes vote down vote up
private void addVFSProxy8() throws Exception {

        String proxyName = "VFSProxy8";
        OMElement proxy = AXIOMUtil.stringToOM("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
                + "<proxy xmlns=\"http://ws.apache.org/ns/synapse\" name=\"VFSProxy8\" transports=\"vfs\">\n"
                + "                <parameter name=\"transport.vfs.FileURI\">" + pathToVfsDir + "test"
                + File.separator + proxyName + File.separator + "in" + File.separator + "</parameter> <!--CHANGE-->\n"
                + "                <parameter name=\"transport.vfs.ContentType\">text/plain</parameter>\n"
                + "                <parameter name=\"transport.vfs.FileNamePattern\">.*.txt</parameter>"
                + "                <parameter name=\"transport.PollInterval\">1</parameter>\n"
                + "                <parameter name=\"transport.vfs.ActionAfterProcess\">DELETE</parameter>\n"
                + "                <target>\n" + "                        <inSequence>\n"
                + "                           <property action=\"set\" name=\"OUT_ONLY\" value=\"true\"/>\n"
                + "                           <log level=\"full\"/>\n" + "                           <send>\n"
                + "                               <endpoint name=\"FileEpr\">\n"
                + "                                   <address uri=\"vfs:file://" + pathToVfsDir + "test"
                + File.separator + proxyName + File.separator + "out" + File.separator + "out.txt\"/>\n"
                + "                               </endpoint>\n" + "                           </send>"
                + "                        </inSequence>" + "                </target>\n" + "        </proxy>");
        addProxy(proxy, proxyName);
    }
 
Example 12
@Test(groups = { "wso2.esb" }, description = "less number of messages than minimum count")
public void testLessThanMinimum() throws IOException, XMLStreamException {
    int responseCount = 0;
    no_of_requests = 3;
    aggregatedRequestClient.setNoOfIterations(no_of_requests);
    String Response = aggregatedRequestClient.getResponse();
    Assert.assertNotNull(Response);
    OMElement Response2 = AXIOMUtil.stringToOM(Response);
    OMElement soapBody = Response2.getFirstElement();
    Iterator iterator = soapBody.getChildrenWithName(new QName("http://services.samples", "getQuoteResponse"));

    while (iterator.hasNext()) {
        responseCount++;
        OMElement getQuote = (OMElement) iterator.next();
        Assert.assertTrue(getQuote.toString().contains("IBM"));
    }
    Assert.assertEquals(responseCount, no_of_requests, "GetQuoteResponse Element count mismatched");

}
 
Example 13
Source Project: micro-integrator   Source File: JMSUtilsTest.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Test convertXMLtoJMSMap
 *
 * @throws Exception
 */
@Test
public void testConvertXMLtoJMSMap() throws Exception {
    String queueName = "testHandler1";
    Properties jmsProperties = JMSTestsUtils.getJMSPropertiesForDestination(queueName, PROVIDER_URL, false);
    JMSBrokerController brokerController = new JMSBrokerController(PROVIDER_URL, jmsProperties);
    try {
        brokerController.startProcess();
        brokerController.connect(queueName, true);
        MapMessage mapMessage = brokerController.createMapMessage();
        OMElement omElement = AXIOMUtil.stringToOM(
                "<JMSMap xmlns=\"http://axis.apache.org/axis2/java/transports/jms/map-payload\">"
                        + "<PRICE>12.0</PRICE>" + "<COUNT>10</COUNT>" + "<NAME>" + queueName + "</NAME>"
                        + "</JMSMap>");
        JMSUtils.convertXMLtoJMSMap(omElement, mapMessage);
        Assert.assertEquals("The converted JMS Map is not correct", "12.0", ((ActiveMQMapMessage) mapMessage).
                getContentMap().get("PRICE"));
        Assert.assertEquals("The converted JMS Map is not correct", queueName, ((ActiveMQMapMessage) mapMessage).
                getContentMap().get("NAME"));
    } finally {
        brokerController.stopProcess();
    }
}
 
Example 14
private void addSmooksProxy() throws Exception {

        Utils.deploySynapseConfiguration(AXIOMUtil.stringToOM("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
                + "<proxy xmlns=\"http://ws.apache.org/ns/synapse\" name=\"SmooksProxy\" transports=\"vfs\" "
                + "startOnLoad=\"true\">\n" + "    <target>\n" + "    <inSequence>\n" + "    <log level=\"full\"/>\n"
                + "    <smooks config-key=\"conf:/smooks_config.xml\">\n" + "        <input type=\"text\"/>\n"
                + "        <output type=\"xml\"/>\n" + "    </smooks>\n"
                + "    <property name=\"OUT_ONLY\" value=\"true\"/>\n" + "    <send>\n"
                + "        <endpoint name=\"FileEpr\">\n" + "            <address uri=\"vfs:file://" + getClass()
                .getResource("/artifacts/ESB/synapseconfig/smooks/").getPath()
                + "test/out/Out.xml\" format=\"soap11\"/>\n" + "        </endpoint>\n" + "    </send>\n"
                + "    <log level=\"full\"/>\n" + "    </inSequence>\n" + "    </target>\n"
                + "    <parameter name=\"transport.PollInterval\">1</parameter>\n"
                + "    <parameter name=\"transport.vfs.FileURI\">file://" + getClass()
                .getResource("/artifacts/ESB/synapseconfig/smooks/").getPath() + "test/in/</parameter>\n"
                + "    <parameter name=\"transport.vfs.FileNamePattern\">.*\\.csv</parameter>\n"
                + "    <parameter name=\"transport.vfs.ContentType\">text/plain</parameter>\n" + "</proxy>"), "SmooksProxy", "proxy-services", true);
    }
 
Example 15
@Test(groups = "wso2.esb", description = "Tests sequential='true' property")
public void testSequentialProperty() throws Exception {
    AxisOperationClient operationClient = new AxisOperationClient();
    String response = operationClient.send(getProxyServiceURLHttp("iterateSequentialTestProxy"), null,
            createMultipleQuoteRequestBody("WSO2", 10), "urn:getQuote").toString();
    operationClient.destroy();
    Assert.assertNotNull(response);
    OMElement envelope = AXIOMUtil.stringToOM(response);
    OMElement soapBody = envelope.getFirstElement();
    Iterator iterator = soapBody.getChildrenWithName(new QName("http://services.samples", "getQuoteResponse"));
    int i = 0;
    while (iterator.hasNext()) {
        i++;
        OMElement getQuote = (OMElement) iterator.next();
        Assert.assertTrue(getQuote.toString().contains("WSO2"));
    }
    Assert.assertEquals(i, 10, "Chile Element mismatched");
}
 
Example 16
Source Project: micro-integrator   Source File: VFSTransportTestCase.java    License: Apache License 2.0 6 votes vote down vote up
private void addVFSProxy14() throws Exception {

        String proxyName = "VFSProxy14";
        OMElement proxy = AXIOMUtil.stringToOM("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
                + "<proxy xmlns=\"http://ws.apache.org/ns/synapse\" name=\"VFSProxy14\" transports=\"vfs\">\n"
                + "                <parameter name=\"transport.vfs.FileURI\">file://" + pathToVfsDir + "test"
                + File.separator + proxyName + File.separator + "in" + File.separator + "</parameter> <!--CHANGE-->\n"
                + "                <parameter name=\"transport.vfs.ContentType\">text/xml</parameter>\n"
                + "                <parameter name=\"transport.vfs.FileNamePattern\">.*\\.xml</parameter>\n"
                + "                <parameter name=\"transport.PollInterval\">1</parameter>\n"
                + "                <target>\n" + "                        <endpoint>\n"
                + "                                <address format=\"soap12\" uri=\"http://localhost:9000/services/SimpleStockQuoteService\"/>\n"
                + "                        </endpoint>\n" + "                        <outSequence>\n"
                + "                                <property action=\"set\" name=\"OUT_ONLY\" value=\"true\"/>\n"
                + "                                <send>\n" + "                                        <endpoint>\n"
                + "                                                <address uri=\"vfs:file://" + pathToVfsDir + "test"
                + File.separator + proxyName + File.separator + "out" + File.separator + "out.xml\"/> <!--CHANGE-->\n"
                + "                                        </endpoint>\n" + "                                </send>\n"
                + "                        </outSequence>\n" + "                </target>\n" + "        </proxy>");
        addProxy(proxy, proxyName);
    }
 
Example 17
Source Project: micro-integrator   Source File: VFSTransportTestCase.java    License: Apache License 2.0 6 votes vote down vote up
private void addVFSProxy15() throws Exception {

        String proxyName = "VFSProxy15";
        OMElement proxy = AXIOMUtil.stringToOM("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
                + "<proxy xmlns=\"http://ws.apache.org/ns/synapse\" name=\"VFSProxy15\" transports=\"vfs\">\n"
                + "                <parameter name=\"transport.vfs.FileURI\">file://" + pathToVfsDir + "test"
                + File.separator + proxyName + File.separator + "invalid" + File.separator + "</parameter>"
                + "                <parameter name=\"transport.vfs.ContentType\">text/xml</parameter>\n"
                + "                <parameter name=\"transport.vfs.FileNamePattern\">.*\\.xml</parameter>\n"
                + "                <parameter name=\"transport.PollInterval\">1</parameter>\n"
                + "                <target>\n" + "                        <endpoint>\n"
                + "                                <address format=\"soap12\" uri=\"http://localhost:9000/services/SimpleStockQuoteService\"/>\n"
                + "                        </endpoint>\n" + "                        <outSequence>\n"
                + "                                <property action=\"set\" name=\"OUT_ONLY\" value=\"true\"/>\n"
                + "                                <send>\n" + "                                        <endpoint>\n"
                + "                                                <address uri=\"vfs:file://" + pathToVfsDir + "test"
                + File.separator + proxyName + File.separator + "out" + File.separator + "out.xml\"/> <!--CHANGE-->\n"
                + "                                        </endpoint>\n" + "                                </send>\n"
                + "                        </outSequence>\n" + "                </target>\n" + "        </proxy>");
        addProxy(proxy, proxyName);
    }
 
Example 18
@Test(groups = { "wso2.esb" }, description = "number of messages is equal to the maximum")
public void testEqualtoMaximum() throws IOException, XMLStreamException {
    int responseCount = 0;

    no_of_requests = 100;
    aggregatedRequestClient.setNoOfIterations(no_of_requests);
    String Response = aggregatedRequestClient.getResponse();
    Assert.assertNotNull(Response);
    OMElement Response2 = AXIOMUtil.stringToOM(Response);
    OMElement soapBody = Response2.getFirstElement();
    Iterator iterator = soapBody.getChildrenWithName(new QName("http://services.samples", "getQuoteResponse"));

    while (iterator.hasNext()) {
        responseCount++;
        OMElement getQuote = (OMElement) iterator.next();
        Assert.assertTrue(getQuote.toString().contains("IBM"));
    }

    Assert.assertTrue(2 <= responseCount && responseCount <= no_of_requests);

}
 
Example 19
@Test(groups = { "wso2.esb" }, description = "more number of messages than maximum count")
public void testMoreNumberThanMaximum() throws IOException, XMLStreamException {
    int responseCount = 0;

    no_of_requests = 110;
    aggregatedRequestClient.setNoOfIterations(no_of_requests);
    String Response = aggregatedRequestClient.getResponse();
    Assert.assertNotNull(Response);
    OMElement Response2 = AXIOMUtil.stringToOM(Response);
    OMElement soapBody = Response2.getFirstElement();
    Iterator iterator = soapBody.getChildrenWithName(new QName("http://services.samples", "getQuoteResponse"));

    while (iterator.hasNext()) {
        responseCount++;
        OMElement getQuote = (OMElement) iterator.next();
        Assert.assertTrue(getQuote.toString().contains("IBM"));
    }

    Assert.assertTrue(2 <= responseCount && responseCount <= 100);

}
 
Example 20
Source Project: micro-integrator   Source File: VFSTransportTestCase.java    License: Apache License 2.0 6 votes vote down vote up
private void addVFSProxy20() throws Exception {

        String proxyName = "VFSProxy20";
        OMElement proxy = AXIOMUtil.stringToOM("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
                + "<proxy xmlns=\"http://ws.apache.org/ns/synapse\" name=\"VFSProxy20\" transports=\"vfs\">\n"
                + "                <parameter name=\"transport.vfs.FileURI\">file://" + pathToVfsDir + "test"
                + File.separator + proxyName + File.separator + "in" + File.separator + "</parameter> <!--CHANGE-->\n"
                + "                <parameter name=\"transport.vfs.ContentType\">text/xml</parameter>\n"
                + "                <parameter name=\"transport.vfs.FileNamePattern\">.*\\.xml</parameter>\n"
                + "                <parameter name=\"transport.PollInterval\">1</parameter>\n"
                + "                <parameter name=\"transport.vfs.MoveAfterFailure\">file://" + pathToVfsDir + "test"
                + File.separator + proxyName + File.separator + "failure" + File.separator + "</parameter>\n"
                + "                <parameter name=\"transport.vfs.ActionAfterFailure\">MOVEDD</parameter>"
                + "                <target>\n" + "                        <endpoint>\n"
                + "                                <address format=\"soap12\" uri=\"http://localhost:9000/services/SimpleStockQuoteService\"/>\n"
                + "                        </endpoint>\n" + "                        <outSequence>\n"
                + "                                <property action=\"set\" name=\"OUT_ONLY\" value=\"true\"/>\n"
                + "                                <send>\n" + "                                        <endpoint>\n"
                + "                                                <address uri=\"vfs:file://" + pathToVfsDir + "test"
                + File.separator + proxyName + File.separator + "out" + File.separator + "out.xml\"/> <!--CHANGE-->\n"
                + "                                        </endpoint>\n" + "                                </send>\n"
                + "                        </outSequence>\n" + "                </target>\n" + "        </proxy>");
        addProxy(proxy, proxyName);
    }
 
Example 21
Source Project: micro-integrator   Source File: VFSTransportTestCase.java    License: Apache License 2.0 6 votes vote down vote up
private void addVFSProxy21() throws Exception {

        String proxyName = "VFSProxy21";
        OMElement proxy = AXIOMUtil.stringToOM("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
                + "<proxy xmlns=\"http://ws.apache.org/ns/synapse\" name=\"VFSProxy21\" transports=\"vfs\">\n"
                + "                <parameter name=\"transport.vfs.FileURI\">file://" + pathToVfsDir + "test"
                + File.separator + proxyName + File.separator + "in" + File.separator + "</parameter> <!--CHANGE-->\n"
                + "                <parameter name=\"transport.vfs.ContentType\">text/xml</parameter>\n"
                + "                <parameter name=\"transport.vfs.FileNamePattern\">.*\\.xml</parameter>\n"
                + "                <parameter name=\"transport.PollInterval\">1</parameter>\n"
                + "                <parameter name=\"transport.vfs.ActionAfterProcess\">MOVE</parameter>\n"
                + "                <parameter name=\"transport.vfs.MoveAfterProcess\">file://" + pathToVfsDir + "test"
                + File.separator + proxyName + File.separator + "processed" + File.separator + "</parameter>"
                + "                <parameter name=\"transport.vfs.CreateFolder\">true</parameter>"
                + "                <target>\n" + "                        <endpoint>\n"
                + "                                <address format=\"soap12\" uri=\"http://localhost:9000/services/SimpleStockQuoteService\"/>\n"
                + "                        </endpoint>\n" + "                        <outSequence>\n"
                + "                        <log level=\"full\"/>"
                + "                                <property action=\"set\" name=\"OUT_ONLY\" value=\"true\"/>\n"
                + "                                <send>\n" + "                                        <endpoint>\n"
                + "                                                <address uri=\"vfs:file://" + pathToVfsDir + "test"
                + File.separator + proxyName + File.separator + "out" + File.separator + "out.xml\"/> <!--CHANGE-->\n"
                + "                                        </endpoint>\n" + "                                </send>\n"
                + "                        </outSequence>\n" + "                </target>\n" + "        </proxy>");
        addProxy(proxy, proxyName);
    }
 
Example 22
@Test(groups = { "wso2.esb" }, description = "number of messages is equal to the minimum")
public void testEqualtoMinimum() throws IOException, XMLStreamException {
    int responseCount = 0;
    no_of_requests = minMessageCount;
    aggregatedRequestClient.setNoOfIterations(no_of_requests);
    String Response = aggregatedRequestClient.getResponse();
    Assert.assertNotNull(Response);
    OMElement Response2 = AXIOMUtil.stringToOM(Response);
    OMElement soapBody = Response2.getFirstElement();
    Iterator iterator = soapBody.getChildrenWithName(new QName("http://services.samples", "getQuoteResponse"));

    while (iterator.hasNext()) {
        responseCount++;
        OMElement getQuote = (OMElement) iterator.next();
        Assert.assertTrue(getQuote.toString().contains("IBM"));
    }
    Assert.assertEquals(responseCount, no_of_requests, "GetQuoteResponse Element count mismatched");

}
 
Example 23
Source Project: micro-integrator   Source File: VFSTransportTestCase.java    License: Apache License 2.0 6 votes vote down vote up
private void addVFSProxy24() throws Exception {

        String proxyName = "VFSProxy24";
        OMElement proxy = AXIOMUtil.stringToOM("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
                + "<proxy xmlns=\"http://ws.apache.org/ns/synapse\" name=\"VFSProxy24\" transports=\"vfs\">\n"
                + "                <parameter name=\"transport.vfs.FileURI\">file://" + pathToVfsDir + "test"
                + File.separator + proxyName + File.separator + "in" + File.separator + "</parameter> <!--CHANGE-->\n"
                + "                <parameter name=\"transport.vfs.ContentType\">text/xml</parameter>\n"
                + "                <parameter name=\"transport.vfs.FileNamePattern\">.*\\.xml</parameter>\n"
                + "                <parameter name=\"transport.PollInterval\">1</parameter>\n"
                + "                <target>\n" + "                        <endpoint>\n"
                + "                                <address format=\"soap12\" uri=\"http://localhost:9000/services/SimpleStockQuoteService\"/>\n"
                + "                        </endpoint>\n" + "                        <outSequence>\n"
                + "                                <property name=\"transport.vfs.ReplyFileName\" value=\"out.xml\" scope=\"transport\"/>"
                + "                                <property action=\"set\" name=\"OUT_ONLY\" value=\"true\"/>\n"
                + "                                <send>\n" + "                                        <endpoint>\n"
                + "                                                <address uri=\"vfs:ftpd://" + pathToVfsDir + "test"
                + File.separator + proxyName + File.separator + "out" + File.separator + "\"/> <!--CHANGE-->\n"
                + "                                        </endpoint>\n" + "                                </send>\n"
                + "                        </outSequence>\n" + "                </target>\n" + "        </proxy>");
        addProxy(proxy, proxyName);
    }
 
Example 24
@Test(groups = { "wso2.esb" }, description = "less number of messages than minimum count")
public void testLessThanMinimum() throws IOException, XMLStreamException {
    int responseCount = 0;

    no_of_requests = 1;
    aggregatedRequestClient.setNoOfIterations(no_of_requests);
    String Response = aggregatedRequestClient.getResponse();
    Assert.assertNotNull(Response);
    OMElement Response2 = AXIOMUtil.stringToOM(Response);
    OMElement soapBody = Response2.getFirstElement();
    Iterator iterator = soapBody.getChildrenWithName(new QName("http://services.samples", "getQuoteResponse"));

    while (iterator.hasNext()) {
        responseCount++;
        OMElement getQuote = (OMElement) iterator.next();
        Assert.assertTrue(getQuote.toString().contains("IBM"));
    }

    Assert.assertEquals(responseCount, no_of_requests, "GetQuoteResponse Element count mismatched");

}
 
Example 25
/**
 * Verify aggregate mediator return expected exception and expected error message
 *
 * @throws IOException
 * @throws XMLStreamException
 */
@Test(groups = {
        "wso2.esb" }, description = "verify proxy service return exception evaluating the on complete", expectedExceptions = org.apache.axis2.AxisFault.class, expectedExceptionsMessageRegExp = ".*Error evaluating expression.*")
public void testAggregatorOnCompleteConditionError() throws IOException, XMLStreamException {
    OMElement payload = AXIOMUtil.stringToOM(
            "<soapenv:Envelope\n" + "    xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\"\n"
                    + "    xmlns:ser=\"http://services.samples\"\n"
                    + "    xmlns:xsd=\"http://services.samples/xsd\">\n" + "    <soapenv:Header/>\n"
                    + "    <soapenv:Body>\n" + "        <ser:getQuotes>\n" + "            <ser:getQuote>\n"
                    + "                <ser:request>\n" + "                    <xsd:symbol>IBM</xsd:symbol>\n"
                    + "                </ser:request>\n" + "            </ser:getQuote>\n"
                    + "            <ser:getQuote>\n" + "                <ser:request>\n"
                    + "                    <xsd:symbol>WSO2</xsd:symbol>\n" + "                </ser:request>\n"
                    + "            </ser:getQuote>\n" + "        </ser:getQuotes>\n" + "    </soapenv:Body>\n"
                    + "</soapenv:Envelope>");
    axis2Client.send(getProxyServiceURLHttp("aggregateMediatorOnCompleteErrorTestProxy"), null, "urn:getQuote",
            payload);
}
 
Example 26
Source Project: micro-integrator   Source File: RestEndpointSetter.java    License: Apache License 2.0 6 votes vote down vote up
public static OMElement setEndpoint(String relativePath)
        throws XMLStreamException, FileNotFoundException, XPathExpressionException {
    ESBTestCaseUtils util = new ESBTestCaseUtils();
    relativePath = relativePath.replaceAll("[\\\\/]", File.separator);
    OMElement synapse = util.loadResource(relativePath);
    //if builder is enable, keep current configuration
    if (TestConfigurationProvider.isIntegration()) {
        return synapse;
    }

    String config = synapse.toString();
    String secureStockQuoteService = EndpointGenerator.getBackEndServiceEndpointUrl("");

    config = config.replace("http://localhost:9009/services/", secureStockQuoteService);
    config = config.replace("http://127.0.0.1:9009/services/", secureStockQuoteService);
    return AXIOMUtil.stringToOM(config);
}
 
Example 27
@Test(groups = { "wso2.esb" }, description = "number of messages is equal to the maximum", enabled = false)
public void testEqualtoMaximum() throws IOException, XMLStreamException {
    int responseCount = 0;

    no_of_requests = 100;
    aggregatedRequestClient.setNoOfIterations(no_of_requests);
    String Response = aggregatedRequestClient.getResponse();
    Assert.assertNotNull(Response);
    OMElement Response2 = AXIOMUtil.stringToOM(Response);
    OMElement soapBody = Response2.getFirstElement();
    Iterator iterator = soapBody.getChildrenWithName(new QName("http://services.samples", "getQuoteResponse"));

    while (iterator.hasNext()) {
        responseCount++;
        OMElement getQuote = (OMElement) iterator.next();
        Assert.assertTrue(getQuote.toString().contains("IBM"));
    }

    Assert.assertEquals(responseCount, no_of_requests, "GetQuoteResponse Element count mismatched");

}
 
Example 28
@BeforeClass(alwaysRun = true)
public void initialize() throws Exception {
    super.init();
    OMElement mailToProxyOMElement = AXIOMUtil.stringToOM(FileUtils.readFileToString(new File(
            getESBResourceLocation() + File.separator + "mailTransport" + File.separator
                    + "mailTransportReceiver" + File.separator + "mail_transport_folder.xml")));
    Utils.deploySynapseConfiguration(mailToProxyOMElement,
            "MailTransportFolder","proxy-services",
            true);
    carbonLogReader = new CarbonLogReader();
    greenMailUser = GreenMailServer.getPrimaryUser();
    greenMailClient = new GreenMailClient(greenMailUser);
    carbonLogReader.start();

    // Since ESB reads all unread emails one by one, we have to delete
    // the all unread emails before run the test
    GreenMailServer.deleteAllEmails("imap");
}
 
Example 29
@BeforeClass(alwaysRun = true)
public void initialize() throws Exception {
    super.init();
    OMElement mailToProxyOMElement = AXIOMUtil.stringToOM(FileUtils.readFileToString(new File(
            getESBResourceLocation() + File.separator + "mailTransport" + File.separator +
                    "mailTransportReceiver" + File.separator + "mail_transport_actionafter_failure_move.xml")));
    Utils.deploySynapseConfiguration(mailToProxyOMElement,
            "MailToTransportActionAfterFailureMoveTestCase","proxy-services",
            true);
    carbonLogReader = new CarbonLogReader();
    carbonLogReader.start();
    greenMailUser = GreenMailServer.getPrimaryUser();
    greenMailClient = new GreenMailClient(greenMailUser);

    // Since ESB reads all unread emails one by one, we have to
    // delete the all unread emails before run the test
    GreenMailServer.deleteAllEmails("imap");
}
 
Example 30
@BeforeClass(alwaysRun = true)
public void initialize() throws Exception {
    super.init();
    OMElement mailToProxyOMElement = AXIOMUtil.stringToOM(FileUtils.readFileToString(new File(
            getESBResourceLocation() + File.separator + "mailTransport" + File.separator +
                    "mailTransportReceiver" + File.separator + "mail_transport_remove_header.xml")));
    Utils.deploySynapseConfiguration(mailToProxyOMElement,
            "MailTransportRemoveHeader","proxy-services",
            true);
    carbonLogReader = new CarbonLogReader();
    greenMailUser = GreenMailServer.getPrimaryUser();
    greenMailClient = new GreenMailClient(greenMailUser);
    carbonLogReader.start();

    // Since ESB reads all unread emails one by one, we have to delete
    // the all unread emails before run the test
    GreenMailServer.deleteAllEmails("imap");
}