org.wso2.carbon.automation.engine.annotations.ExecutionEnvironment Java Examples

The following examples show how to use org.wso2.carbon.automation.engine.annotations.ExecutionEnvironment. 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
Source File: CloneLargeMessageTestCase.java    From product-ei with Apache License 2.0 6 votes vote down vote up
@SetEnvironment(executionEnvironments = {ExecutionEnvironment.STANDALONE})
@Test(groups = "wso2.esb", description = "Tests large message ~3MB")
public void testLargeMessage() throws Exception {

    String symbol = FixedSizeSymbolGenerator.generateMessageMB(3);
    String response = client.getResponse(getProxyServiceURLHttp("CloneAndAggregateTestProxy"), symbol);
    symbol = null;
    Assert.assertNotNull(response);
    OMElement envelope = client.toOMElement(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, 2, " Aggregated message should contain two chilled element"); // Aggregated message should contain two
    // return elements from each cloned endpoint
    response = null;
}
 
Example #2
Source File: FileInboundWithDynamicSequenceTestCase.java    From product-ei with Apache License 2.0 6 votes vote down vote up
@SetEnvironment(executionEnvironments = {ExecutionEnvironment.STANDALONE})
@Test(groups = "wso2.esb", description = "Tests sequences from  the governance registry with inbound endpoint")
public void testSequence() throws Exception {

    logViewerClient.clearLogs();

    //Copy file to source folder from which the inbound endpoint will pick up the message
    File sourceFile = new File(pathToDir + File.separator + "test.xml");
    File targetFile = new File(InboundFileFolder + File.separator + "test.xml");
    if (!sourceFile.exists()) {
        sourceFile.createNewFile();
    }
    log.info("Copying files to the target folder");
    FileUtils.copyFile(sourceFile, targetFile);

    //And file inbound endpoint
    addInboundEndpoint(createInboundEP());

    Assert.assertTrue(Utils.checkForLog(logViewerClient, "Proxy invoked by dynamic sequence in file inbound",
            10), "The XML file is not getting read");

}
 
Example #3
Source File: VFSTransportTestCase.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
@SetEnvironment(executionEnvironments = { ExecutionEnvironment.STANDALONE })
@Test(groups = { "wso2.esb" }, description = "Writing to a file the content of a xml with content in text element")
public void testVFSProxyPlainXMLWriter() throws Exception {

    File outfile = new File(proxyVFSRoots.get("salesforce_DAMAS_writeFile") + File.separator +
            "out" + File.separator + "out_reply.xml");

    String request =
            " <ns:text xmlns:ns=\"http://ws.apache.org/commons/ns/payload\"><test>request_value</test></ns:text>";
    Map<String, String> headers = new HashMap<>();
    headers.put("Content-type", "text/xml;charset=UTF-8");
    headers.put("Accept-Charset", "UTF-8");
    HttpRequestUtil.doPost(new URL(getProxyServiceURLHttp("salesforce_DAMAS_writeFile")), request, headers);

    Awaitility.await().pollInterval(50, TimeUnit.MILLISECONDS).atMost(60, TimeUnit.SECONDS).until(isFileExist(outfile));
    Assert.assertTrue(outfile.exists());
    Assert.assertTrue(doesFileContain(outfile, "request_value"), "Sent request body not found");
}
 
Example #4
Source File: LoadBalanceEndpointTestCase.java    From product-ei with Apache License 2.0 6 votes vote down vote up
@SetEnvironment(executionEnvironments = {ExecutionEnvironment.STANDALONE})
@Test(groups = {"wso2.esb"}, description = "Sending a Message to a loadbalancing endpoint in Config Reg")
public void testSendingToLoaBalancingEndpoint_ConfigReg()
        throws IOException, EndpointAdminEndpointAdminException,
               LoginAuthenticationExceptionException,
               XMLStreamException {

    String response = lbClient.sendLoadBalanceRequest(getProxyServiceURLHttp("loadbalancingEndPoint_Config_Reg"),
                                                      null);
    Assert.assertNotNull(response);
    Assert.assertTrue(response.toString().contains("Response from server: Server_1"));

    response = lbClient.sendLoadBalanceRequest(getProxyServiceURLHttp("loadbalancingEndPoint_Config_Reg"),
                                               null);
    Assert.assertNotNull(response);
    Assert.assertTrue(response.toString().contains("Response from server: Server_2"));

    response = lbClient.sendLoadBalanceRequest(getProxyServiceURLHttp("loadbalancingEndPoint_Config_Reg"),
                                               null);
    Assert.assertNotNull(response);
    Assert.assertTrue(response.toString().contains("Response from server: Server_3"));

}
 
Example #5
Source File: SendIntegrationTestCase.java    From product-ei with Apache License 2.0 6 votes vote down vote up
@SetEnvironment(executionEnvironments = {ExecutionEnvironment.STANDALONE
})
    @Test(groups = "wso2.esb", description = "Test sending request to Load Balancing Endpoint With the RoundRobin Algorithm")
    public void testSendingLoadBalancingEndpoint2() throws IOException {

        String response = lbClient.sendLoadBalanceRequest(getProxyServiceURLHttp("loadBalancingEndPoint2"),
                                                          "http://localhost:9001/services/LBService1");
        Assert.assertNotNull(response);
        Assert.assertTrue(response.toString().contains("Response from server: Server_1"));

        response = lbClient.sendLoadBalanceRequest(getProxyServiceURLHttp("loadBalancingEndPoint2"),
                                                   "http://localhost:9002/services/LBService1");
        Assert.assertNotNull(response);
        Assert.assertTrue(response.toString().contains("Response from server: Server_2"));

        response = lbClient.sendLoadBalanceRequest(getProxyServiceURLHttp("loadBalancingEndPoint2"),
                                                   "http://localhost:9003/services/LBService1");
        Assert.assertNotNull(response);
        Assert.assertTrue(response.toString().contains("Response from server: Server_3"));

        response = lbClient.sendLoadBalanceRequest(getProxyServiceURLHttp("loadBalancingEndPoint2"),
                                                   "http://localhost:9001/services/LBService1");
        Assert.assertNotNull(response);
        Assert.assertTrue(response.toString().contains("Response from server: Server_1"));

    }
 
Example #6
Source File: VFSTransportTestCase.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
@SetEnvironment(executionEnvironments = { ExecutionEnvironment.STANDALONE })
@Test(groups = { "wso2.esb" }, description = "Sending a file through VFS Transport : " + "transport.vfs.FileURI = "
        + "/home/someuser/somedir " + "transport.vfs.ContentType = text/plain, "
        + "transport.vfs.FileNamePattern = *")
public void testVFSProxyFileURI_LinuxPath_SelectAll_FileNamePattern() throws Exception {

    //Related proxy : VFSProxy3
    File sourceFile = new File(pathToVfsDir + File.separator + "test.txt");
    File targetFile = new File(proxyVFSRoots.get("VFSProxy3") + File.separator + "in" + File.separator + "test.txt");
    File outfile = new File(proxyVFSRoots.get("VFSProxy3") + File.separator + "out" + File.separator + "out.txt");

    FileUtils.copyFile(sourceFile, targetFile);
    Awaitility.await().pollInterval(50, TimeUnit.MILLISECONDS).atMost(60, TimeUnit.SECONDS)
            .until(isFileExist(outfile));
    Assert.assertTrue(outfile.exists());
    Assert.assertTrue(doesFileContain(outfile,"[email protected]"));
}
 
Example #7
Source File: CacheControlHeadersTestCase.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
/**
 * This test case checks whether an Age header is returned with the response.
 */
@SetEnvironment(executionEnvironments = { ExecutionEnvironment.STANDALONE })
@Test(groups = { "wso2.esb" }, description = "Testing with a large cache time out value for cache mediator")
public void testAgeHeader() throws Exception {
    String apiName = "includeAge";

    Map<String, String> headers = new HashMap<>();

    headers.put("Content-Type", "text/xml;charset=UTF-8");
    headers.put("SOAPAction", "urn:getQuote");

    //will not be a cache hit
    HttpRequestUtil.doPost(new URL(getApiInvocationURL(apiName)), messagePayload, headers);

    //will be a cache hit
    HttpResponse response2 = HttpRequestUtil.doPost(new URL(getApiInvocationURL(apiName)), messagePayload, headers);

    assertNotNull(response2.getHeaders().get("Age"), "Age header is not included");
}
 
Example #8
Source File: DefaultRequestContentTypeTestCase.java    From product-ei with Apache License 2.0 6 votes vote down vote up
@SetEnvironment(executionEnvironments = {ExecutionEnvironment.STANDALONE})
@Test(groups = {"wso2.esb"}, description = "Test for DEFAULT_REQUEST_TYPE for nhttp transport")
public void testReturnContentType() throws Exception {
    try {
        String url = getApiInvocationURL("defaultRequestContentTypeApi").concat("?symbol=wso2");
        HttpUriRequest request = new HttpPut(url);
        DefaultHttpClient client = new DefaultHttpClient();

        ((HttpPut)request).setEntity(new StringEntity("<request/>"));

        HttpResponse response = client.execute(request);
        Assert.assertNotNull(response);
        Assert.assertTrue(getResponse(response).toString().contains("WSO2"));
    } catch (IOException e) {
        log.error("Error while sending the request to the endpoint. ", e);
    }

}
 
Example #9
Source File: SpringMediationTestCase.java    From product-ei with Apache License 2.0 6 votes vote down vote up
@SetEnvironment(executionEnvironments = {ExecutionEnvironment.STANDALONE
})
    @Test(groups = {"wso2.esb", "localOnly"}, description = "Spring Mediator " +
                                                            "-Added Simple bean into lib " +
                                                            "-Different bean ids in spring xml")
    public void providingNonExistingBeanNamesTest() throws Exception {
        loadESBConfigurationFromClasspath("/artifacts/ESB/mediatorconfig/spring/spring_mediation_different_bean_id.xml");
        try {
            axis2Client.sendSimpleStockQuoteRequest
                    (getMainSequenceURL(), null, "IBM");
            fail("Request must throw a axisFault since sequence refers a non existing bean id");
        } catch (AxisFault axisFault) {
            assertEquals(axisFault.getMessage(), "No bean named 'springtestNonExisting' is defined", "Fault: Error message mismatched");
        }

    }
 
Example #10
Source File: DBReportMediatorTestCase.java    From product-ei with Apache License 2.0 6 votes vote down vote up
@SetEnvironment(executionEnvironments = {ExecutionEnvironment.STANDALONE})
@Test(groups = "wso2.esb", description = "Insert or update DB table using message contents."
)
public void DBReportUseMessageContentTestCase() throws Exception {
    double price = 200.0;
    OMElement response;
    String priceMessageContent;
    h2DataBaseManager.executeUpdate("INSERT INTO company VALUES(100.0,'ABC')");
    h2DataBaseManager.executeUpdate("INSERT INTO company VALUES(2000.0,'XYZ')");
    h2DataBaseManager.executeUpdate("INSERT INTO company VALUES(" + price + ",'WSO2')");
    h2DataBaseManager.executeUpdate("INSERT INTO company VALUES(300.0,'MNO')");

    File synapseFile = new File(getClass().getResource("/artifacts/ESB/mediatorconfig/dbreport/" +
            "dbReportMediatorUsingMessageContentTestProxy.xml").getPath());
    addProxyService(updateSynapseConfiguration(synapseFile));
    priceMessageContent = getPrice();
    assertEquals(priceMessageContent, Double.toString(price), "Fault, invalid response");
    response = axis2Client.sendSimpleStockQuoteRequest(getProxyServiceURLHttp
            ("dbReportMediatorUsingMessageContentTestProxy"), null, "WSO2");
    priceMessageContent = getPrice();
    OMElement returnElement = response.getFirstElement();
    OMElement lastElement = returnElement.getFirstChildWithName(new QName("http://services.samples/xsd", "last"));
    assertEquals(priceMessageContent, lastElement.getText(), "Fault, invalid response");
}
 
Example #11
Source File: InboundTransportTest.java    From product-ei with Apache License 2.0 6 votes vote down vote up
@SetEnvironment(executionEnvironments = { ExecutionEnvironment.STANDALONE })
@Test(groups = { "wso2.esb" },
      dependsOnMethods = "testInboundEndpointContentTypeInvalid",
      description = "Inbound Endpoint Content type not specified Test case")
public void testInboundEndpointContentTypeNotSpecified() throws Exception {

    File sourceFile = new File(pathToFtpDir + File.separator + TEST_XML_FILE_NAME);
    File targetFolder = new File(inboundFileListeningFolder + File.separator + "in");
    File targetFile = new File(targetFolder + File.separator + "in.xml");
    try {
        FileUtils.copyFile(sourceFile, targetFile);
        addInboundEndpoint(addEndpoint7());
        Awaitility.await()
                  .pollInterval(50, TimeUnit.MILLISECONDS)
                  .atMost(60, TimeUnit.SECONDS)
                  .until(isFileNotExist(targetFile));
        Assert.assertTrue(!targetFile.exists(), "File not processed");
    } finally {
        deleteFile(targetFile);
    }
}
 
Example #12
Source File: SendIntegrationTestCase.java    From product-ei with Apache License 2.0 6 votes vote down vote up
@SetEnvironment(executionEnvironments = {ExecutionEnvironment.STANDALONE
})
    @Test(groups = "wso2.esb", description = "Test sending request to Load Balancing Endpoint With the RoundRobin Algorithm BuildMessage Enabled")
    public void testSendingLoadBalancingEndpoint4() throws IOException {

        String response = lbClient.sendLoadBalanceRequest(getProxyServiceURLHttp("loadBalancingEndPoint4"),
                                                          "http://localhost:9001/services/LBService1");
        Assert.assertNotNull(response);
        Assert.assertTrue(response.toString().contains("Response from server: Server_1"));

        response = lbClient.sendLoadBalanceRequest(getProxyServiceURLHttp("loadBalancingEndPoint4"),
                                                   "http://localhost:9002/services/LBService1");
        Assert.assertNotNull(response);
        Assert.assertTrue(response.toString().contains("Response from server: Server_2"));

        response = lbClient.sendLoadBalanceRequest(getProxyServiceURLHttp("loadBalancingEndPoint4"),
                                                   "http://localhost:9003/services/LBService1");
        Assert.assertNotNull(response);
        Assert.assertTrue(response.toString().contains("Response from server: Server_3"));

        response = lbClient.sendLoadBalanceRequest(getProxyServiceURLHttp("loadBalancingEndPoint4"),
                                                   "http://localhost:9001/services/LBService1");
        Assert.assertNotNull(response);
        Assert.assertTrue(response.toString().contains("Response from server: Server_1"));

    }
 
Example #13
Source File: SpringMediationTestCase.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
@SetEnvironment(executionEnvironments = { ExecutionEnvironment.STANDALONE })
@Test(groups = { "wso2.esb", "localOnly" }, description = "Spring Mediator "
        + "-Added Simple bean into lib -referring to an invalid spring xml")
public void uploadSequenceHavingInvalidSpringXMLTest() throws Exception {

    loadESBConfigurationFromClasspath(
            "/artifacts/ESB/mediatorconfig/spring/spring_mediation_invalid_spring_bean.xml");
    try {
        axis2Client.sendSimpleStockQuoteRequest(getMainSequenceURL(), null, "WSO2");
        Assert.fail("Request must failed since it refers invalid spring bean");
    } catch (Exception expected) {
        assertEquals(expected.getMessage(),
                "Cannot reference application context with key : conf:/spring/invalidSpringbeammmn.xml",
                "Error Message Mismatched when referring invalid springbean in sequence");

    }
}
 
Example #14
Source File: EnrichIntegrationAddSiblingInOutMessageTestCase.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
@SetEnvironment(executionEnvironments = { ExecutionEnvironment.STANDALONE })
@Test(groups = { "wso2.esb" }, description = "Enrich mediator:Add as a sibling to message body")
public void addAsSiblingToMessageBody() throws Exception {
    wireMonitorServer.start();
    String payload =
            "<m:getQuote xmlns:m=\"http://services.samples\">" + "<m:request>" + "</m:request>" + "</m:getQuote>";
    OMElement payloadOM = AXIOMUtil.stringToOM(payload);
    try {
        OMElement response = axis2Client
                .sendSimpleStockQuoteRequest(getProxyServiceURLHttp("enrichAddSiblingInOutMessageTestProxy"), null,
                        payloadOM);
    } catch (Exception e) {

    }
    String wireResponse = wireMonitorServer.getCapturedMessage();
    String expectedSoapBody = "<soapenv:Body>" + "<m:symbol1 xmlns:m=\"http://services.samples\">IBM</m:symbol1>"
            + "<m:symbol2 xmlns:m=\"http://services.samples\">WSO2</m:symbol2>" + "</soapenv:Body>";
    assertTrue(wireResponse.contains(expectedSoapBody), "Invalid soap body");

}
 
Example #15
Source File: DBlookupMediatorTestCase.java    From product-ei with Apache License 2.0 6 votes vote down vote up
@SetEnvironment(executionEnvironments = {ExecutionEnvironment.STANDALONE})
@Test(groups = "wso2.esb", description = "Test dblookup mediator with multiple SQL statements")
public void dbLookupMediatorTestMultipleStatements() throws Exception {
    h2DatabaseManager.executeUpdate("INSERT INTO company VALUES(100.0,'IBM')");
    h2DatabaseManager.executeUpdate("INSERT INTO company VALUES(2000.0,'XYZ')");
    h2DatabaseManager.executeUpdate("INSERT INTO company VALUES(" + WSO2_PRICE + ",'WSO2')");
    h2DatabaseManager.executeUpdate("INSERT INTO company VALUES(300.0,'MNO')");
    URL fileLocation = getClass().getResource("/artifacts/ESB/mediatorconfig/dblookup/" +
            "dbLookupMediatorMultipleSQLStatementsTestProxy.xml");
    String proxyContent = FileUtils.readFileToString(new File(fileLocation.toURI()));
    proxyContent = updateDatabaseInfo(proxyContent);
    addProxyService(AXIOMUtil.stringToOM(proxyContent));
    OMElement response = axis2Client.sendSimpleStockQuoteRequest(getProxyServiceURLHttp
            ("dbLookupMediatorMultipleSQLStatementsTestProxy"), null, "WSO2");
    Assert.assertTrue(response.toString().contains("WSO2"));
}
 
Example #16
Source File: SendIntegrationTestCase.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
@SetEnvironment(executionEnvironments = {ExecutionEnvironment.STANDALONE})
@Test(groups = "wso2.esb", description = "Test sending request to Load Balancing Endpoint With the RoundRobin Algorithm Receiving Sequence Dynamic BuildMessage Enabled")
public void testSendingLoadBalancingEndpoint16() throws IOException {

    String response = lbClient.sendLoadBalanceRequest(getProxyServiceURLHttp("loadBalancingEndPoint16"),
            "http://localhost:9001/services/LBService1");
    Assert.assertNotNull(response);
    Assert.assertTrue(response.toString().contains("Response from server: Server_1"));

    response = lbClient.sendLoadBalanceRequest(getProxyServiceURLHttp("loadBalancingEndPoint16"),
            "http://localhost:9002/services/LBService1");
    Assert.assertNotNull(response);
    Assert.assertTrue(response.toString().contains("Response from server: Server_2"));

    response = lbClient.sendLoadBalanceRequest(getProxyServiceURLHttp("loadBalancingEndPoint16"),
            "http://localhost:9003/services/LBService1");
    Assert.assertNotNull(response);
    Assert.assertTrue(response.toString().contains("Response from server: Server_3"));

    response = lbClient.sendLoadBalanceRequest(getProxyServiceURLHttp("loadBalancingEndPoint16"),
            "http://localhost:9001/services/LBService1");
    Assert.assertNotNull(response);
    Assert.assertTrue(response.toString().contains("Response from server: Server_1"));

}
 
Example #17
Source File: GroovyScriptSupportTestCase.java    From product-ei with Apache License 2.0 6 votes vote down vote up
@SetEnvironment(executionEnvironments = {ExecutionEnvironment.STANDALONE
})
    @Test(groups = {"wso2.esb", "localOnly"}, description = "Script Mediator -Run a Groovy script with the mediator",enabled =false)
    public void testGroovyScriptMediation() throws Exception {
        OMElement response = axis2Client.sendSimpleStockQuoteRequest(
                getProxyServiceURLHttp("scriptMediatorGroovyBasicTestProxy"), null,
                "IBM");

        String lastPrice = response.getFirstElement().getFirstChildWithName(new QName("http://services.samples/xsd", "last"))
                .getText();
        assertNotNull(lastPrice, "Fault: response message 'last' price null");

        String symbol = response.getFirstElement().getFirstChildWithName(new QName("http://services.samples/xsd", "symbol"))
                .getText();
        assertEquals(symbol, "IBM", "Fault: value 'symbol' mismatched");
    }
 
Example #18
Source File: JSONDisableAutoPrimitiveNumericTestCase.java    From product-ei with Apache License 2.0 6 votes vote down vote up
@SetEnvironment(executionEnvironments = {ExecutionEnvironment.ALL})
@Test(groups = "wso2.esb", description = "disabling auto primitive option with a given regex pattern in synapse "
                                         + "properties  ")
public void testDisablingAutoConversionToScientificNotationInJsonStreamFormatter() throws Exception {
    String payload = "<coordinates>\n"
                     + "   <location>\n"
                     + "       <name>Bermuda Triangle</name>\n"
                     + "       <n>25e1</n>\n"
                     + "       <w>7.1e1</w>\n"
                     + "   </location>\n"
                     + "   <location>\n"
                     + "       <name>Eiffel Tower</name>\n"
                     + "       <n>4.8e3</n>\n"
                     + "       <e>1.8e2</e>\n"
                     + "   </location>\n"
                     + "</coordinates>";
    HttpResponse response = httpClient.doPost(getProxyServiceURLHttp("JSONDisableAutoPrimitiveNumericTestProxy"),
            null, payload, "application/xml");
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    response.getEntity().writeTo(bos);
    String actualResult = new String(bos.toByteArray());
    String expectedPayload = "{\"coordinates\":{\"location\":[{\"name\":\"Bermuda Triangle\",\"n\":\"25e1\""
                             + ",\"w\":\"7.1e1\"},{\"name\":\"Eiffel Tower\",\"n\":\"4.8e3\",\"e\":\"1.8e2\"}]}}";
    Assert.assertEquals(actualResult, expectedPayload);
}
 
Example #19
Source File: Sample62TestCase.java    From product-ei with Apache License 2.0 6 votes vote down vote up
@SetEnvironment(executionEnvironments = { ExecutionEnvironment.STANDALONE })
@Test(groups = { "wso2.esb" },
      description = "Routing a Message to a Dynamic List of Recipients and Aggregating Responses")
public void testRoutingMessagesAndAggregatingResponses() throws Exception {

	OMElement response = axis2Client.sendSimpleQuoteRequest("http://localhost:8480/", null, "WSO2");
	System.out.println(response.toString());

	Assert.assertTrue(response.toString().contains("getSimpleQuoteResponse"),
	                  "GetSimpleQuoteResponse not found");
	Assert.assertTrue(response.toString().contains("WSO2 Company"), "WSO2 Company not found");

	Thread.sleep(3000);

	boolean is9001Called = isAxisServiceCalled(listener1);
	boolean is9002Called = isAxisServiceCalled(listener2);
	boolean is9003Called = isAxisServiceCalled(listener3);

	Assert.assertTrue(is9001Called, "Service 9001 not called");
	Assert.assertTrue(is9002Called, "Service 9002 not called");
	Assert.assertTrue(is9003Called, "Service 9003 not called");

	listener1.clear();
	listener2.clear();
	listener3.clear();
}
 
Example #20
Source File: FaultyDataServiceTestCase.java    From product-ei with Apache License 2.0 6 votes vote down vote up
@Test(groups = "wso2.dss", dependsOnMethods = {"serviceReDeployment"},
      description = "send requests to redeployed service")
@SetEnvironment(executionEnvironments = {ExecutionEnvironment.STANDALONE})
public void serviceInvocation()
        throws RemoteException, ServiceAdminException, XPathExpressionException {
    OMElement response;
    String serviceEndPoint = getServiceUrlHttp(serviceName) +"/";
    AxisServiceClient axisServiceClient = new AxisServiceClient();
    for (int i = 0; i < 5; i++) {
        response = axisServiceClient.sendReceive(getPayload(), serviceEndPoint, "showAllOffices");
        Assert.assertTrue(response.toString().contains("<Office>"), "Expected Result not Found");
        Assert.assertTrue(response.toString().contains("<officeCode>"), "Expected Result not Found");
        Assert.assertTrue(response.toString().contains("<city>"), "Expected Result not Found");
        Assert.assertTrue(response.toString().contains("<phone>"), "Expected Result not Found");
        Assert.assertTrue(response.toString().contains("</Office>"), "Expected Result not Found");
    }
    log.info("service invocation success");
}
 
Example #21
Source File: PrependPathTestCase.java    From product-ei with Apache License 2.0 5 votes vote down vote up
@SetEnvironment(executionEnvironments = {ExecutionEnvironment.STANDALONE})
@Test(groups = {"wso2.esb"}, description = "Prepend text to the path",
      dataProvider = "addressingUrl")
public void prependPath(String addUrl) throws AxisFault {
    OMElement response;

    response = axis2Client.sendSimpleStockQuoteRequest(
            getProxyServiceURLHttp("urlRewritePrependPathTestProxy"),
            addUrl,
            "IBM");
    assertTrue(response.toString().contains("IBM"));

}
 
Example #22
Source File: PropertyIntegrationTRANSPORT_HEADERSPropertyTest.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
@SetEnvironment(executionEnvironments = { ExecutionEnvironment.STANDALONE })
@Test(groups = "wso2.esb", description = "Test-Without TRANSPORT_HEADERS Property")
public void testTRANSPORT_HEADERSPropertTest() throws Exception {

    wireServer.start();
    try {
        axis2Client.addHttpHeader("Test-TRANSPORT_HEADERS", "test");
        axis2Client
                .sendSimpleStockQuoteRequest(getProxyServiceURLHttp("TRANSPORT_HEADERS_TestProxy"), null, "WSO2");
    } catch (Exception e) {

    }
    String response = wireServer.getCapturedMessage();
    assertFalse(response.contains("Test-TRANSPORT_HEADERS: test"), "Property not set");
}
 
Example #23
Source File: IterateLargeMessageTestCase.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
@SetEnvironment(executionEnvironments = { ExecutionEnvironment.STANDALONE, ExecutionEnvironment.PLATFORM })
@Test(groups = "wso2.esb", description = "Tests large message in small number 5")
public void testSmallNumbers() throws Exception {
    OMElement response;
    for (int i = 0; i < 5; i++) {
        response = axis2Client
                .sendSimpleStockQuoteRequest(getProxyServiceURLHttp("iterateWithHttpEndPointTestProxy"), null,
                        symbol);
        Assert.assertNotNull(response);
        Assert.assertTrue(response.toString().contains("WSO2"));
    }
}
 
Example #24
Source File: JsonFormat_IncomingJson_ArgsJsonExpression_WithStream_TestCase.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
@SetEnvironment(executionEnvironments = { ExecutionEnvironment.STANDALONE })
@Test(groups = {
        "wso2.esb" }, description = "With Stream B&F, json format, json evaluators, incoming json, outgoing json ")
public void incomingJsontransformJsonPayloadByArgsJsonExpressions() throws Exception {

    loadESBConfigurationFromClasspath(
            "/artifacts/ESB/mediatorconfig/payload/factory/jsonFormat_JsonExpressiosns.xml");
    postRequestWithJsonPayload(JSON_PAYLOAD, JSON_TYPE);
    assertTrue(responsePayload.contains("wso2"), "Symbol wso2 not found in response message");

}
 
Example #25
Source File: SendIntegrationTestCase.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
@SetEnvironment(executionEnvironments = {ExecutionEnvironment.STANDALONE})
@Test(groups = "wso2.esb", description = "Test sending request to Address Endpoint while Receiving Sequence in Governance  Registry")
public void testSendingAddressEndpoint_Receiving_Sequence_GovReg() throws Exception {
    OMElement response = axis2Client
            .sendSimpleStockQuoteRequest(getProxyServiceURLHttp("addressEndPoint_Receiving_Sequence_GovReg"), null,
                    "WSO2");
    Assert.assertNotNull(response);
    Assert.assertTrue(response.toString().contains("WSO2 Company"));

}
 
Example #26
Source File: SendIntegrationTestCase.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
@SetEnvironment(executionEnvironments = {ExecutionEnvironment.STANDALONE})
@Test(groups = "wso2.esb", description = "Test sending request to Default Endpoint")
public void testSendingDefaultEndpoint() throws Exception {
    OMElement response = axis2Client.sendSimpleStockQuoteRequest(getProxyServiceURLHttp("defaultEndPoint"),
            getBackEndServiceUrl(ESBTestConstant.SIMPLE_STOCK_QUOTE_SERVICE), "WSO2");
    Assert.assertNotNull(response);
    Assert.assertTrue(response.toString().contains("WSO2 Company"));
}
 
Example #27
Source File: SendIntegrationTestCase.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
@SetEnvironment(executionEnvironments = {ExecutionEnvironment.STANDALONE})
@Test(groups = "wso2.esb", description = "Test sending request to Fail Over Endpoint Build Message Before Sending")
public void testSendingFailOverEndpoint_BuildMessage() throws IOException, InterruptedException {
    OMElement response = axis2Client
            .sendSimpleStockQuoteRequest(getProxyServiceURLHttp("failoverEndPointBM"), null, "WSO2");
    Assert.assertTrue(response.toString().contains("WSO2 Company"));

    axis2Server1.stop();
    response = axis2Client.sendSimpleStockQuoteRequest(getProxyServiceURLHttp("failoverEndPointBM"), null, "WSO2");
    Assert.assertTrue(response.toString().contains("WSO2 Company"));

    axis2Server1.start();
    axis2Server2.stop();

    Thread.sleep(2000);

    int counter = 0;
    while (!AxisServiceClientUtils.isServiceAvailable("http://localhost:9001/services/SimpleStockQuoteService")) {
        if (counter > 100) {
            break;
        }
        counter++;
    }

    if (counter > 100) {
        throw new AssertionError("Axis2 Server didn't started with in expected time period.");
    } else {

        response = axis2Client
                .sendSimpleStockQuoteRequest(getProxyServiceURLHttp("failoverEndPointBM"), null, "WSO2");
        Assert.assertTrue(response.toString().contains("WSO2 Company"));

    }
}
 
Example #28
Source File: SendIntegrationTestCase.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
@SetEnvironment(executionEnvironments = {ExecutionEnvironment.STANDALONE})
@Test(groups = "wso2.esb", description = "Test sending request to Load Balancing Endpoint With the WeightedRoundRobin Algorithm Receiving Sequence in Conf Registry while BuildMessage Enabled")
public void testSendingLoadBalancingEndpoint7() throws IOException {

    String response = lbClient.sendLoadBalanceRequest(getProxyServiceURLHttp("loadBalancingEndPoint7"),
            "http://localhost:9001/services/LBService1");
    Assert.assertNotNull(response);
    Assert.assertTrue(response.toString().contains("Response from server: Server_1"));

    response = lbClient.sendLoadBalanceRequest(getProxyServiceURLHttp("loadBalancingEndPoint7"),
            "http://localhost:9002/services/LBService1");
    Assert.assertNotNull(response);
    Assert.assertTrue(response.toString().contains("Response from server: Server_2"));

    response = lbClient.sendLoadBalanceRequest(getProxyServiceURLHttp("loadBalancingEndPoint7"),
            "http://localhost:9002/services/LBService1");
    Assert.assertNotNull(response);
    Assert.assertTrue(response.toString().contains("Response from server: Server_2"));

    response = lbClient.sendLoadBalanceRequest(getProxyServiceURLHttp("loadBalancingEndPoint7"),
            "http://localhost:9003/services/LBService1");
    Assert.assertNotNull(response);
    Assert.assertTrue(response.toString().contains("Response from server: Server_3"));

    response = lbClient.sendLoadBalanceRequest(getProxyServiceURLHttp("loadBalancingEndPoint7"),
            "http://localhost:9001/services/LBService1");
    Assert.assertNotNull(response);
    Assert.assertTrue(response.toString().contains("Response from server: Server_1"));
}
 
Example #29
Source File: SendIntegrationTestCase.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
@SetEnvironment(executionEnvironments = {ExecutionEnvironment.STANDALONE})
@Test(groups = "wso2.esb", description = "Test sending request to WSDL Endpoint Build Message Before Sending")
public void testSendingWSDLEndpoint_BuildMessage() throws Exception {
    OMElement response = axis2Client
            .sendSimpleStockQuoteRequest(getProxyServiceURLHttp("wsdlEndPointBM"),
                    getBackEndServiceUrl(ESBTestConstant.SIMPLE_STOCK_QUOTE_SERVICE) + "?wsdl", "WSO2");
    Assert.assertNotNull(response);
    Assert.assertTrue(response.toString().contains("WSO2 Company"));
}
 
Example #30
Source File: ESBJAVA4973BindAddressFeatureTestCase.java    From product-ei with Apache License 2.0 5 votes vote down vote up
@BeforeClass(alwaysRun = true)
@SetEnvironment(executionEnvironments = {ExecutionEnvironment.STANDALONE})
public void setEnvironment() throws Exception {
    super.init();
    serverConfigurationManager = new ServerConfigurationManager(context);
    File file = new File(
            FrameworkPathUtil.getSystemResourceLocation() + "artifacts" + File.separator + "ESB" + File.separator +
                    "passthru" + File.separator + "transport" + File.separator + "ESBJAVA4973" + File.separator +
                    "axis2.xml");
    serverConfigurationManager.applyConfiguration(file);
    super.init();
    logViewerClient = new LogViewerClient(contextUrls.getBackEndUrl(), getSessionCookie());
}