Java Code Examples for org.wso2.carbon.automation.engine.annotations.SetEnvironment

The following examples show how to use org.wso2.carbon.automation.engine.annotations.SetEnvironment. 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.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 2
@SetEnvironment(executionEnvironments = { ExecutionEnvironment.STANDALONE })
@Test(groups = "wso2.esb", description = "Test sending request to Load balanced Endpoint")
public void testCallBlockingForLoadBalanceFailover() throws IOException, InterruptedException {

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

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

    axis2Server1.stop();
    Thread.sleep(1000); // Waiting for server2 to shut down

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

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

}
 
Example 3
@SetEnvironment(executionEnvironments = { ExecutionEnvironment.STANDALONE })
@Test(groups = { "wso2.esb" }, description = "Test whether FIX messages are stored from store mediator")
public void messageStoreFIXStoringTest() throws Exception {
    // The count should be 0 as soon as the message store is created
    Assert.assertTrue(messageStoreAdminClient.getMessageCount(MESSAGE_STORE_NAME) == 0,
            "Message store should be initially empty");
    // refer within a sequence through a store mediator, mediate messages
    // and verify the messages are stored correctly in the store.
    loadESBConfigurationFromClasspath("/artifacts/ESB/synapseconfig/messageStore/inmemory_message_store.xml");
    for (int i = 0; i < 5; i++) {
        axis2Client.sendSimpleQuoteRequest(getMainSequenceURL(), null, "WSO2");
    }
    Assert.assertTrue(Utils.waitForMessageCount(messageStoreAdminClient, MESSAGE_STORE_NAME, 5, 30000),
            "Messages are missing or repeated");
    serverConfigurationManager.restartGracefully();
    super.init();
    initVariables();
    messageStores = messageStoreAdminClient.getMessageStores();
    Assert.assertNotNull(messageStores);
    if (messageStores != null) {
        Assert.assertTrue(messageStoreAdminClient.getMessageCount(MESSAGE_STORE_NAME) == 0,
                "Messages have not cleaned");
    }
}
 
Example 4
Source Project: micro-integrator   Source File: VFSTransportTestCase.java    License: 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 5
Source Project: micro-integrator   Source File: SendIntegrationTestCase.java    License: 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 in Conf Registry while BuildMessage Disabled")
public void testSendingLoadBalancingEndpoint6() throws IOException {

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

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

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

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

}
 
Example 6
Source Project: micro-integrator   Source File: VFSTransportTestCase.java    License: 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 = - *\\.txt, " + "transport.PollInterval=1,"
        + " transport.vfs.ReplyFileName = out.txt ")
public void testVFSProxyReplyFileName_Normal() throws Exception {

    //Related proxy : VFSProxy9
    File sourceFile = new File(pathToVfsDir + File.separator + "test.txt");
    File targetFile = new File(proxyVFSRoots.get("VFSProxy9") + File.separator + "in" + File.separator + "test.txt");
    File outfile = new File(proxyVFSRoots.get("VFSProxy9") + 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 Project: micro-integrator   Source File: DBReportMediatorTestCase.java    License: 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')");

    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 8
Source Project: micro-integrator   Source File: VFSTransportTestCase.java    License: 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 = Linux Path, " + "transport.vfs.ContentType = text/xml, "
        + "transport.vfs.FileNamePattern = - *\\.xml " + "transport.vfs.ActionAfterFailure=DELETE")
public void testVFSProxyActionAfterFailure_DELETE() throws Exception {

    //Related proxy : VFSProxy13
    String proxyName = "VFSProxy13";
    File sourceFile = new File(pathToVfsDir + File.separator + "fail.xml");
    File targetFile = new File(proxyVFSRoots.get(proxyName) + File.separator + "in" + File.separator + "fail.xml");
    File outfile = new File(proxyVFSRoots.get(proxyName) + File.separator + "out" + File.separator + "out.xml");
    File originalFile = new File(proxyVFSRoots.get(proxyName) + File.separator + "failure" + File.separator + "fail.xml");

    FileUtils.copyFile(sourceFile, targetFile);
    Awaitility.await().pollInterval(50, TimeUnit.MILLISECONDS).atMost(60, TimeUnit.SECONDS)
            .until(isFileNotExist(targetFile));
    Awaitility.await().pollDelay(2, TimeUnit.SECONDS).atMost(60, TimeUnit.SECONDS)
            .until(isFileNotExist(outfile));
    Assert.assertFalse(originalFile.exists());
    Assert.assertFalse(
            new File(proxyVFSRoots.get(proxyName) + File.separator + "in" + File.separator + "fail.xml.lock").exists(),
            "lock file exists even after moving the failed file");
}
 
Example 9
@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 10
Source Project: micro-integrator   Source File: VFSTransportTestCase.java    License: 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 = Linux Path, " + "transport.vfs.ContentType = Not Specified, "
        + "transport.vfs.FileNamePattern = - *\\.xml " + "transport.vfs.FileURI = Invalid", enabled = false)
public void testVFSProxyContentType_NotSpecified() throws Exception {

    String proxyName = "VFSProxy17";
    File sourceFile = new File(pathToVfsDir + File.separator + "test.xml");
    File targetFile = new File(proxyVFSRoots.get(proxyName) + File.separator + "in" + File.separator + "test.xml");
    File outfile = new File(proxyVFSRoots.get(proxyName) + File.separator + "out" + File.separator + "out.xml");

    FileUtils.copyFile(sourceFile, targetFile);
    Awaitility.await().pollDelay(2, TimeUnit.SECONDS).pollInterval(50, TimeUnit.MILLISECONDS).
            atMost(60, TimeUnit.SECONDS).until(isFileNotExist(outfile));

    Assert.assertFalse(outfile.exists());
}
 
Example 11
Source Project: micro-integrator   Source File: VFSTransportTestCase.java    License: 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 = Linux Path, " + "transport.vfs.ContentType = text/xml, "
        + "transport.vfs.FileNamePattern = - *\\.xml " + "transport.vfs.ActionAfterProcess = Invalid")
public void testVFSProxyActionAfterProcess_Invalid() throws Exception {

    String proxyName = "VFSProxy19";
    File sourceFile = new File(pathToVfsDir + File.separator + "test.xml");
    File targetFile = new File(proxyVFSRoots.get(proxyName) + File.separator + "in" + File.separator + "test.xml");
    File outfile = new File(proxyVFSRoots.get(proxyName) + File.separator + "out" + File.separator + "out.xml");
    File originalFile = new File(proxyVFSRoots.get(proxyName) + File.separator + "original" + File.separator + "test.xml");

    FileUtils.copyFile(sourceFile, targetFile);
    Awaitility.await().pollInterval(50, TimeUnit.MILLISECONDS).atMost(60, TimeUnit.SECONDS)
            .until(isFileNotExist(targetFile));
    Awaitility.await().pollDelay(2, TimeUnit.SECONDS).pollInterval(50, TimeUnit.MILLISECONDS)
            .atMost(60, TimeUnit.SECONDS).until(isFileExist(outfile));
    Assert.assertTrue(outfile.exists());
    Assert.assertTrue(doesFileContain(outfile, "WSO2 Company"));
    Assert.assertFalse(originalFile.exists());
    Assert.assertFalse(targetFile.exists());
}
 
Example 12
Source Project: micro-integrator   Source File: VFSTransportTestCase.java    License: 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 = Linux Path, " + "transport.vfs.ContentType = text/xml, "
        + "transport.vfs.FileNamePattern = - *\\.xml " + "transport.vfs.ActionAfterFailure = Invalid")
public void testVFSProxyActionAfterFailure_Invalid() throws Exception {

    String proxyName = "VFSProxy20";

    File sourceFile = new File(pathToVfsDir + File.separator + "fail.xml");
    File targetFile = new File(proxyVFSRoots.get(proxyName) + File.separator + "in" + File.separator + "fail.xml");
    File outfile = new File(proxyVFSRoots.get(proxyName) + File.separator + "out" + File.separator + "out.xml");
    File originalFile = new File(proxyVFSRoots.get(proxyName) + File.separator + "failure" + File.separator + "fail.xml");

    FileUtils.copyFile(sourceFile, targetFile);
    Awaitility.await().pollInterval(50, TimeUnit.MILLISECONDS).atMost(60, TimeUnit.SECONDS)
            .until(isFileNotExist(targetFile));
    Awaitility.await().pollDelay(2, TimeUnit.SECONDS).until(isFileNotExist(outfile));
    Awaitility.await().pollDelay(2, TimeUnit.SECONDS).until(isFileNotExist(originalFile));
    Assert.assertFalse(outfile.exists());
    Assert.assertFalse(originalFile.exists());
    Assert.assertFalse(targetFile.exists());
    Assert.assertFalse(
            new File(proxyVFSRoots.get(proxyName) + File.separator + "in" + File.separator + "fail.xml.lock").exists(),
            "lock file exists even after moving the failed file");
}
 
Example 13
Source Project: micro-integrator   Source File: VFSTransportTestCase.java    License: 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 = Linux Path," + " transport.vfs.ContentType = text/xml, "
        + "transport.vfs.FileNamePattern = - *\\.xml " + "transport.vfs.MoveAfterProcess = processed")
public void testVFSProxyMoveAfterProcessInvalidFile() throws Exception {

    String proxyName = "VFSProxy21";

    File sourceFile = new File(pathToVfsDir + File.separator + "fail.xml");
    File outfile = new File(proxyVFSRoots.get(proxyName) + File.separator + "out" + File.separator + "out.xml");
    File targetFile = new File(proxyVFSRoots.get(proxyName) + File.separator + "in" + File.separator + "fail.xml");
    File originalFile = new File(proxyVFSRoots.get(proxyName) + File.separator + "processed" + File.separator + "test.xml");

    FileUtils.copyFile(sourceFile, targetFile);
    Awaitility.await().pollInterval(50, TimeUnit.MILLISECONDS).atMost(60, TimeUnit.SECONDS)
            .until(isFileNotExist(targetFile));
    Awaitility.await().pollDelay(2, TimeUnit.SECONDS).pollInterval(50, TimeUnit.MILLISECONDS)
            .atMost(60, TimeUnit.SECONDS).until(isFileNotExist(outfile));

    Assert.assertFalse(outfile.exists(), "Out put file found");
    Assert.assertFalse(originalFile.exists(), "Input file moved even if file processing is failed");
    Assert.assertFalse(targetFile.exists(), "Input file found after reading the file");
}
 
Example 14
Source Project: micro-integrator   Source File: VFSTransportTestCase.java    License: 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 = Linux Path, " + "transport.vfs.ContentType = text/xml, "
        + "transport.vfs.FileNamePattern = - *\\.xml, " + "transport.vfs.ReplyFileURI  = Invalid")
public void testVFSProxyReplyFileURI_Invalid() throws Exception {

    String proxyName = "VFSProxy23";

    File sourceFile = new File(pathToVfsDir + File.separator + "test.xml");
    File targetFile = new File(proxyVFSRoots.get(proxyName) + File.separator + "in" + File.separator + "test.xml");
    File outfile = new File(proxyVFSRoots.get(proxyName) + File.separator + "invalid" + File.separator + "out.xml");
    deleteFile(outfile); //delete outfile dir if exists
    FileUtils.cleanDirectory(new File(proxyVFSRoots.get(proxyName) + File.separator + "in"));

    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, "WSO2 Company"));
}
 
Example 15
@SetEnvironment(executionEnvironments = { ExecutionEnvironment.STANDALONE })
@Test(groups = "wso2.esb", description = "Proxy service with Tcp transport")
public void tcpTransportProxy() throws Exception {
    TcpClient tcpClient = new TcpClient();
    OMElement response;
    String tcpProxyUrl;
    if (isRunningOnStratos()) {
        tcpProxyUrl = "tcp://localhost:8290/services/t/" + context.getContextTenant().getDomain()
                + "/tcpProxy/tcpProxy?contentType=application/soap+xml";
    } else {
        tcpProxyUrl = "tcp://localhost:8290/services/tcpProxy/tcpProxy?contentType=application/soap+xml";
    }
    response = tcpClient
            .sendSimpleStockQuote12(tcpProxyUrl, "TCPPROXY", tcpClient.CONTENT_TYPE_APPLICATIONS_SOAP_XML);
    Assert.assertTrue(response.toString().contains("TCPPROXY"), "Symbol not found in response message");
}
 
Example 16
@SetEnvironment(executionEnvironments = { ExecutionEnvironment.ALL })
@Test(groups = "wso2.esb", description = "<property name=\"RETRY_ON_SOAPFAULT\" value=\"true\"/>", enabled = false)
public void testRetryOnSOAPFaultWithInOutTrue() throws Exception {

    AxisServiceClient serviceClient = new AxisServiceClient();
    serviceClient.fireAndForget(clearCountRequest(), getBackEndServiceUrl(), "clearRequestCount");
    OMElement requestCount = serviceClient
            .sendReceive(getCountRequest(), getBackEndServiceUrl(), "getRequestCount");
    Assert.assertEquals(requestCount.getFirstElement().getText(), "0", "Request Cunt not clear");

    serviceClient.sendRobust(getThrowAxisFaultRequest(),
            getProxyServiceURLHttp("messageProcessorRetryOnSOAPFaultTrueTestProxy"), "throwAxisFault");
    Thread.sleep(5000);
    requestCount = serviceClient.sendReceive(getCountRequest(), getBackEndServiceUrl(), "getRequestCount");
    Assert.assertEquals(requestCount.getFirstElement().getText(), "5",
            "Request Count mismatched. Not sent all request");

}
 
Example 17
/**
 * To check the persistence of configuration with message processor, after restarting ESB
 * Test Artifacts: /artifacts/ESB/messageProcessorConfig/Message_Processor_Persistence_After_Restart_Synapse.xml
 *
 * @throws Exception
 */
@SetEnvironment(executionEnvironments = { ExecutionEnvironment.ALL })
@Test(groups = "wso2.esb")
public void testMessagePersistenceAfterRestart() throws Exception {

    // Configuration which contains a message store and a message processor  - did this way to stop dropping XML tags.

    loadESBConfigurationFromClasspath(
            separator + "artifacts" + separator + "ESB" + separator + "messageProcessorConfig" + separator
                    + "Message_Processor_Persistence_After_Restart_Synapse.xml");
    // Waits until the config get sets
    Thread.sleep(5000);
    serverConfigurationManager.restartGracefully();
    // Creating new variables for new environment
    super.init();
    synapseConfigAdminClient = new SynapseConfigAdminClient(contextUrls.getBackEndUrl(), getSessionCookie());
    // Get configuration after restart
    String afterConfig = synapseConfigAdminClient.getConfiguration();

    Assert.assertTrue(afterConfig.contains("storeForTestMessagePersistenceAfterRestart"),
            "Synapse Configuration doesn't contain message-store after restart");
    Assert.assertTrue(afterConfig.contains("SamplingProcessor"),
            "Synapse Configuration doesn't contain message-processor after restart");

}
 
Example 18
Source Project: micro-integrator   Source File: Sample265TestCase.java    License: 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 = *", enabled = false)
public void testVFSProxyFileURI_LinuxPath_SelectAll_FileNamePattern() throws Exception {

    addVFSProxy();

    File sourceFile = new File(pathToVfsDir + File.separator + "test.txt");
    File targetFile = new File(pathToVfsDir + "test" + File.separator + "in" + File.separator + "test.txt");
    File outfile = new File(pathToVfsDir + "test" + File.separator + "out" + File.separator + "out.txt");
    try {
        FileUtils.copyFile(sourceFile, targetFile);
        Thread.sleep(2000);

        Assert.assertTrue(outfile.exists());
    } finally {
        deleteFile(targetFile);
        deleteFile(outfile);
        removeProxy("VFSProxy1");
    }
}
 
Example 19
Source Project: micro-integrator   Source File: Sample381TestCase.java    License: Apache License 2.0 6 votes vote down vote up
@SetEnvironment(executionEnvironments = { ExecutionEnvironment.STANDALONE })
@Test(groups = { "wso2.esb" }, description = "Test JMS broker with topic")
public void JMSBrokerTopicTest() throws Exception {

    int numberOfMsgToExpect = 5;

    CarbonLogReader carbonLogReader = new CarbonLogReader();
    carbonLogReader.start();

    MDDProducer mddProducerMSTF = new MDDProducer();

    for (int i = 0; i < numberOfMsgToExpect; i++) {
        mddProducerMSTF.sendMessage("MSTF", "dynamicQueues/JMSBinaryProxy");
    }
    Thread.sleep(5000);
    Assert.assertTrue(carbonLogReader.checkForLog("MSTF", DEFAULT_TIMEOUT), "Request log not found");
    carbonLogReader.stop();
}
 
Example 20
@SetEnvironment(executionEnvironments = { ExecutionEnvironment.STANDALONE })
@Test(groups = "wso2.esb", description = "Tests for named endpoints")
public void testNamedEndpoints() throws Exception {

    IterateClient client = new IterateClient();
    String response = client
            .getMultipleResponse(getProxyServiceURLHttp("iterateNamedEndpointsTestProxy"), "WSO2", 2);
    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, "Child Element count mismatched");
}
 
Example 21
Source Project: micro-integrator   Source File: NewInstanceTestCase.java    License: Apache License 2.0 6 votes vote down vote up
@SetEnvironment(executionEnvironments = { ExecutionEnvironment.STANDALONE })
@BeforeClass(groups = { "esb.multi.server" })
public void testStartServers() throws Exception {
    context = new AutomationContext();
    startupParameterMap1.put("-DportOffset", "10");
    startupParameterMap1.put("startupScript", "integrator");

    CarbonTestServerManager server1 = new CarbonTestServerManager(context, System.getProperty("carbon.zip"),
            startupParameterMap1);
    startupParameterMap2.put("-DportOffset", "20");
    startupParameterMap2.put("startupScript", "integrator");

    CarbonTestServerManager server2 = new CarbonTestServerManager(context, System.getProperty("carbon.zip"),
            startupParameterMap2);
    manager.startServers(server1, server2);
}
 
Example 22
Source Project: micro-integrator   Source File: SpringMediationTestCase.java    License: 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 23
@SetEnvironment(executionEnvironments = { ExecutionEnvironment.ALL })
@Test(groups = "wso2.esb",
        description = "Test wrong port(80) attached with the HOST_HEADERS for https backend")
public void testHOST_HEADERPropertyTest() throws Exception {

    carbonLogReader.start();
    try {
        axis2Client.sendSimpleStockQuoteRequest(getProxyServiceURLHttp("ESBJAVA3336httpsBackendProxyService"), null,
                                                "WSO2");
    } catch (Exception e) {

    }
    boolean errorLogFound = false;
    if (!carbonLogReader.checkForLog("Host: google.com", DEFAULT_TIMEOUT) || carbonLogReader
            .checkForLog("Host: google.com:80", 1)) {
        errorLogFound = true;
    }
    assertFalse(errorLogFound, "Port 80 should not append to the Host header");
}
 
Example 24
Source Project: micro-integrator   Source File: CollectorTypeTestCase.java    License: Apache License 2.0 5 votes vote down vote up
@SetEnvironment(executionEnvironments = { ExecutionEnvironment.STANDALONE })
@Test(groups = { "wso2.esb" }, description = "Creating Collector Type Mediator Test Case")
public void testCollectorTypeMediator() throws AxisFault, XPathExpressionException {
    OMElement response;
    try {
        response = axis2Client.sendSimpleStockQuoteRequest(getProxyServiceURLHttp(PROXY_NAME),
                getBackEndServiceUrl(ESBTestConstant.SIMPLE_STOCK_QUOTE_SERVICE), "WSO2");
        //            String changeValue = response.getFirstElement().getFirstChildWithName(new QName
        //                                                                                  ("http://services.samples/xsd", "change")).getText();

        response = axis2Client.sendSimpleStockQuoteRequest(getProxyServiceURLHttp(PROXY_NAME),
                getBackEndServiceUrl(ESBTestConstant.SIMPLE_STOCK_QUOTE_SERVICE), "WSO2");
        //            String change1Value = response.getFirstElement().getFirstChildWithName(new QName
        //                                                                                   ("http://services.samples/xsd", "change")).getText();

        response = axis2Client.sendSimpleStockQuoteRequest(getProxyServiceURLHttp(PROXY_NAME),
                getBackEndServiceUrl(ESBTestConstant.SIMPLE_STOCK_QUOTE_SERVICE), "WSO2");
        //            String change2Value = response.getFirstElement().getFirstChildWithName(new QName
        //                                                                                   ("http://services.samples/xsd", "change")).getText();

        /*if (changeValue.equals(change1Value)) {
            assertFalse(false, "Response caching worked even with the controller cache in 'in' sequence");
        }

        if (change1Value.equals(change2Value)) {
            assertFalse(false, "Response caching worked even with the controller cache in 'in' sequence");
        }
        if (change2Value.equals(changeValue)) {
            assertFalse(false, "Response caching worked even with the controller cache in 'in' sequence");
        }*/
        fail("Response caching worked even with the controller cache in 'in' sequence");
    } catch (AxisFault message) {
        assertEquals(message.getReason(), ESBTestConstant.INCOMING_MESSAGE_IS_NULL,
                "CacheMediator Request messages cannot be handled in a collector cache");
    }
}
 
Example 25
@SetEnvironment(executionEnvironments = { ExecutionEnvironment.STANDALONE })
@BeforeClass(alwaysRun = true)
public void uploadSynapseConfig() throws Exception {
    super.init();
    serverManager = new ServerConfigurationManager(context);
    //        serverManager.applyConfiguration(new File(getClass().getResource("/artifacts/ESB/mediatorconfig/payload/factory/axis2/axis2.xml").getPath()));
    super.init();
}
 
Example 26
@SetEnvironment(executionEnvironments = { ExecutionEnvironment.STANDALONE })
@Test(groups = { "wso2.esb" }, description = "With Stream B&F, json format, json evaluators, incoming json, "
        + "outgoing json ")
public void incomingJsontransformJsonPayloadByArgsJsonXmlExpressionsValues() throws Exception {

    loadESBConfigurationFromClasspath(
            "artifacts/ESB/mediatorconfig/payload/factory/jsonFormat_JsonXmlExpressions_values.xml");
    postRequestWithJsonPayload(JSON_PAYLOAD, JSON_TYPE);
    assertTrue(responsePayload.contains("wso2"), "Symbol wso2 not found in response message");
}
 
Example 27
/**
 * 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 testMaxAge() throws Exception {
    String apiName = "maxAge";
    OMElement response;
    response = axis2Client.sendSimpleStockQuoteRequest(null, getApiInvocationURL(apiName), "");

    String changeValue = response.getFirstElement()
            .getFirstChildWithName(new QName("http://services.samples/xsd", "change")).getText();

    Thread.sleep(30000);
    response = axis2Client.sendSimpleStockQuoteRequest(null, getApiInvocationURL(apiName), "");

    String newChangeValue = response.getFirstElement()
            .getFirstChildWithName(new QName("http://services.samples/xsd", "change")).getText();

    Thread.sleep(35000);
    response = axis2Client.sendSimpleStockQuoteRequest(null, getApiInvocationURL(apiName), "");

    String newChangeValue1 = response.getFirstElement()
            .getFirstChildWithName(new QName("http://services.samples/xsd", "change")).getText();

    //newChangeValue1 should not be equal to initial value as the max-age is 60s. Since max-age is less than cache
    // expiry time, cache should be invalidate after 60s even though the cache expiry time is 120s.
    assertTrue(changeValue.equals(newChangeValue) && !changeValue.equals(newChangeValue1));
}
 
Example 28
Source Project: micro-integrator   Source File: SendIntegrationTestCase.java    License: 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 Gov Registry while BuildMessage Enabled")
public void testSendingLoadBalancingEndpoint11() throws IOException {

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

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

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

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

    response = lbClient.sendLoadBalanceRequest(getProxyServiceURLHttp("loadBalancingEndPoint11"),
            "http://localhost:9001/services/LBService1");
    Assert.assertNotNull(response);
    Assert.assertTrue(response.toString().contains("Response from server: Server_1"));
}
 
Example 29
@SetEnvironment(executionEnvironments = { ExecutionEnvironment.STANDALONE })
@Test(groups = "wso2.esb", description = "Verify a header can be excluded when hasing")
public void testExcludingHeaders() throws AxisFault {
    OMElement stockResponse;

    // Sending a request to SimpleStockQuote Service
    stockResponse = axis2Client
            .sendSimpleStockQuoteRequest(getApiInvocationURL("excludeHeaders"), "", "ExcludeHeaders");
    assertNotNull(stockResponse, "Response is null");
    String change = stockResponse.getFirstElement()
            .getFirstChildWithName(new QName("http://services.samples/xsd", "change")).getText();

    // Sending a request to SimpleStockQuote Service with 'user' header
    axis2Client.addHttpHeader("user", "Peter");
    stockResponse = axis2Client
            .sendSimpleStockQuoteRequest(getApiInvocationURL("excludeHeaders"), "", "ExcludeHeaders");
    assertNotNull(stockResponse, "Response is null");
    String change1 = stockResponse.getFirstElement()
            .getFirstChildWithName(new QName("http://services.samples/xsd", "change")).getText();

    assertEquals(change, change1, "Response caching did not exclude the given header value");

    // Sending a request to SimpleStockQuote Service with 'user' and 'country' headers
    axis2Client.addHttpHeader("user", "Peter");
    axis2Client.addHttpHeader("country", "UK");
    stockResponse = axis2Client
            .sendSimpleStockQuoteRequest(getApiInvocationURL("excludeHeaders"), "", "ExcludeHeaders");
    assertNotNull(stockResponse, "Response is null");
    String change2 = stockResponse.getFirstElement()
            .getFirstChildWithName(new QName("http://services.samples/xsd", "change")).getText();

    assertNotEquals(change, change2, "Response caching works with the undefined exclude header");
}
 
Example 30
Source Project: micro-integrator   Source File: SendIntegrationTestCase.java    License: 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")
public void testSendingLoadBalancingEndpoint1() throws IOException {

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

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

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

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

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