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

The following examples show how to use org.wso2.carbon.automation.engine.annotations.SetEnvironment. 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: Sample381TestCase.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 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 #2
Source File: DBReportMediatorTestCase.java    From micro-integrator 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')");

    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 #3
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 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 #4
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 #5
Source File: MessageStoreMessageCleaningTestCase.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 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 #6
Source File: ESBJAVA3336HostHeaderValuePortCheckTestCase.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
@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 #7
Source File: FaultyDataServiceTestCase.java    From micro-integrator 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 #8
Source File: CallMediatorBlockingLoadBalanceFailoverTest.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 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 #9
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 = - *\\.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 #10
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 #11
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 = 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 #12
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 = 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 #13
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 = 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 #14
Source File: Sample265TestCase.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 = *", 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 #15
Source File: MessageProcessorPersistenceTestCase.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
/**
 * 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 #16
Source File: IterateNamedEndpointsTest.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
@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 #17
Source File: TcpTransportProxyServiceTestCase.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
@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 #18
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 = 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 #19
Source File: NewInstanceTestCase.java    From micro-integrator with 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 #20
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 = 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 #21
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 = 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 #22
Source File: CloneLargeMessageTestCase.java    From micro-integrator 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 #23
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"); // fail

}
 
Example #24
Source File: SOAP11ToJSONConversion.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
@SetEnvironment(executionEnvironments = { ExecutionEnvironment.STANDALONE })
@Test(groups = "wso2.esb", description = "JSon to SOAP11 Conversion")
public void testJsonToSOAP11() throws Exception {

    URL endpoint = new URL(getProxyServiceURLHttp("jsonToSoap11"));

    Map<String, String> header = new HashMap<String, String>();
    header.put("Content-Type", "application/json");
    String inputPayload = "{\"Hello\":\"World\"}";

    HttpResponse response = HttpRequestUtil.doPost(endpoint, inputPayload, header);
    Assert.assertEquals(inputPayload, response.getData(), "Expected payload not received.");
}
 
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 Default Endpoint Receiving Sequence in Local Registry")
public void testSendingDefaultEndpoint_Receiving_Sequence_LocalReg() throws Exception {
    OMElement response = axis2Client
            .sendSimpleStockQuoteRequest(getProxyServiceURLHttp("defaultEndPoint_Receiving_Sequence_LocalReg"),
                    getBackEndServiceUrl(ESBTestConstant.SIMPLE_STOCK_QUOTE_SERVICE), "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 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 #27
Source File: ESBJAVA_4572TestCase.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
@SetEnvironment(executionEnvironments = { ExecutionEnvironment.ALL })
@Test(groups = "wso2.esb", description = "disabling auto primitive option in synapse properties ", enabled = false)
public void testDisablingAutoConversionToScientificNotationInJsonStreamFormatter() throws Exception {
    String payload = "{\"state\":[{\"path\":\"user_programs_progress\",\"entry\":"
            + "[{\"value\":\"false\",\"key\":\"testJson14\"}]}]}";

    HttpResponse response = httpClient
            .doPost("http://localhost:8280/ESBJAVA4572abc/dd", null, payload, "application/json");
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    response.getEntity().writeTo(bos);
    String exPayload = new String(bos.toByteArray());
    String val = "{\"state\":[{\"path\":\"user_programs_progress\",\"entry\":"
            + "[{\"value\":\"false\",\"key\":\"testJson14\"}]}]}";
    Assert.assertEquals(val, exPayload);
}
 
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 Fail Over Endpoint Receiving Sequence in Local Registry while BuildMessage enabled")
public void testSendingFailOverEndpoint_Receiving_Sequence_LocalReg_BuildMessage()
        throws IOException, InterruptedException {
    OMElement response = axis2Client
            .sendSimpleStockQuoteRequest(getProxyServiceURLHttp("failOverEndPoint_Receiving_Sequence_LocalRegBM"),
                    null, "WSO2");
    Assert.assertTrue(response.toString().contains("WSO2 Company"));

    axis2Server1.stop();
    response = axis2Client
            .sendSimpleStockQuoteRequest(getProxyServiceURLHttp("failOverEndPoint_Receiving_Sequence_LocalRegBM"),
                    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("failOverEndPoint_Receiving_Sequence_LocalRegBM"), null, "WSO2");
        Assert.assertTrue(response.toString().contains("WSO2 Company"));

    }
}
 
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 Fail Over Endpoint Receiving Sequence in Gov Registry while BuildMessage enabled")
public void testSendingFailOverEndpoint_Receiving_Sequence_GovReg_BuildMessage()
        throws IOException, InterruptedException {
    OMElement response = axis2Client
            .sendSimpleStockQuoteRequest(getProxyServiceURLHttp("failOverEndPoint_Receiving_Sequence_GovRegBM"),
                    null, "WSO2");
    Assert.assertTrue(response.toString().contains("WSO2 Company"));

    axis2Server1.stop();
    response = axis2Client
            .sendSimpleStockQuoteRequest(getProxyServiceURLHttp("failOverEndPoint_Receiving_Sequence_GovRegBM"),
                    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("failOverEndPoint_Receiving_Sequence_GovRegBM"),
                        null, "WSO2");
        Assert.assertTrue(response.toString().contains("WSO2 Company"));

    }
}
 
Example #30
Source File: IndirectEndpointTestCase.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
@SetEnvironment(executionEnvironments = {ExecutionEnvironment.STANDALONE})
@Test(groups = {"wso2.esb"}, description = "Sending a Message to a Indirect endpoint")
public void testSendingToIndirectEndpoint() throws Exception {
    OMElement response = axis2Client
            .sendSimpleStockQuoteRequest(getProxyServiceURLHttp("indirectEndpointTestProxy"), null, "WSO2");
    Assert.assertNotNull(response);
    Assert.assertTrue(response.toString().contains("WSO2 Company"));
}