Java Code Examples for org.wso2.carbon.automation.engine.annotations.ExecutionEnvironment#ALL

The following examples show how to use org.wso2.carbon.automation.engine.annotations.ExecutionEnvironment#ALL . 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: ESBJAVA_4572TestCase.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 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 2
Source File: WithInMemoryStoreTestCase.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
/**
 * Create a message processor which processes messages that are in a In memory message store
 * Test artifact: /artifacts/ESB/synapseconfig/processor/forwarding/InMemoryStoreSynapse1.xml
 *
 * @throws Exception
 */
@SetEnvironment(executionEnvironments = { ExecutionEnvironment.ALL })
@Test(groups = "wso2.esb")
public void testForwardingWithInMemoryStore() throws Exception {

    //Setting up Wire Monitor Server
    WireMonitorServer wireServer = new WireMonitorServer(9500);
    wireServer.start();

    try {
        axis2Client
                .sendSimpleStockQuoteRequest(getProxyServiceURLHttp("messageProcessorInMemoryStoreTestProxy"), null,
                        "WSO2");
        Assert.fail("Unexpected reply received !!!");
    } catch (Exception e) {
        // Axis Fault Expected
    }

    String serverResponse = wireServer.getCapturedMessage();

    Assert.assertTrue(serverResponse.contains("WSO2"),
            "'WSO2 Company' String not found at backend port listener! ");
    Assert.assertTrue(serverResponse.contains("request"),
            "'getQuoteResponse' String not found at backend port listener !");

}
 
Example 3
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 4
Source File: VFSTransportTestCase.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
@SetEnvironment(executionEnvironments = { ExecutionEnvironment.ALL })
@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")
public void testVFSProxyFileURI_LinuxPath_ContentType_XML() throws Exception {

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

    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 5
Source File: HttpEpTemplateWithSystemPropsTestCase.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
@SetEnvironment(executionEnvironments = { ExecutionEnvironment.ALL })
@Test(groups = { "wso2.esb" }, enabled = true)
public void testHttpEpTemplateWithSystemProps() throws AxisFault {
    StockQuoteClient axis2Client = new StockQuoteClient();
    OMElement response = axis2Client.sendSimpleStockQuoteRequestREST(API_URL, null, "WSO2");
    // (API_URL, null, "WSO2");
    Assert.assertNotNull(response);
    Assert.assertTrue(response.toString().contains("WSO2 Company"));
}
 
Example 6
Source File: MessageWithoutContentTypeTestCase.java    From product-ei with Apache License 2.0 5 votes vote down vote up
/**
 * Sending a message without mentioning Content Type and check the body part at the listening port
 * <p/>
 * Public JIRA:    WSO2 Carbon/CARBON-6029
 * Responses With No Content-Type Header not handled properly
 * <p/>
 * Test Artifacts: ESB Sample 0
 *
 * @throws Exception   - if the scenario fail
 */
@SetEnvironment(executionEnvironments = {ExecutionEnvironment.ALL})
@Test(groups = "wso2.esb")
public void testMessageWithoutContentType() throws Exception {

    // Get target URL
    String strURL = getMainSequenceURL();
    // Get SOAP action
    String strSoapAction = "getQuote";
    // Get file to be posted
    String strXMLFilename = FrameworkPathUtil.getSystemResourceLocation() + "artifacts" + File.separator +
            "ESB" + File.separator + "synapseconfig" + File.separator + "messagewithoutcontent" +
            File.separator + "request.xml";

    File input = new File(strXMLFilename);
    // Prepare HTTP post
    PostMethod post = new PostMethod(strURL);
    // Request content will be retrieved directly
    // from the input stream
    RequestEntity entity = new FileRequestEntity(input, "text/xml");
    post.setRequestEntity(entity);
    // consult documentation for your web service
    post.setRequestHeader("SOAPAction", strSoapAction);
    // Get HTTP client
    HttpClient httpclient = new HttpClient();
    // Execute request
    try {
        int result = httpclient.executeMethod(post);
        // Display status code
        log.info("Response status code: " + result);
        // Display response
        log.info("Response body: ");
        log.info(post.getResponseBodyAsString());
    } finally {
        // Release current connection to the connection pool once you are done
        post.releaseConnection();
    }
}
 
Example 7
Source File: ConfiguringNhttpAccessLogLocationTestCase.java    From product-ei with Apache License 2.0 5 votes vote down vote up
/**
 * To check the functionality of  ESB after enabling Nhttp transport
 * <p/>
 * Test Artifacts: /artifacts/ESB/synapseconfig/nhttp_transport/nhttp.properties
 *
 * @throws Exception
 */
@SetEnvironment(executionEnvironments = {ExecutionEnvironment.ALL})
@Test(groups = "wso2.esb")
public void testNhttpAccessLogLocation() throws Exception {

    axis2Client.sendSimpleStockQuoteRequest(getProxyServiceURLHttp("NhttpLogsTestProxy"),
            getBackEndServiceUrl(ESBTestConstant.SIMPLE_STOCK_QUOTE_SERVICE), "WSO2");
    Assert.assertTrue(new File(nhttpLogDir).listFiles().length > 0,
            "nhttp access logs were not written to the configured directory " + nhttpLogDir);
}
 
Example 8
Source File: NhttpMaximumOpenConnections.java    From product-ei with Apache License 2.0 5 votes vote down vote up
@SetEnvironment(executionEnvironments = {ExecutionEnvironment.ALL})
    @Test(groups = "wso2.esb", description = "NHTTP Test Maximum Open Connections")
    public void testMaximumConnections() throws InterruptedException {
	initClients();         //initialising Axis2Clients
	startClients();
	int aliveCount = 0;
	Calendar startTime = Calendar.getInstance();
	while (aliveCount < CONCURRENT_CLIENTS) {
	    if ((Calendar.getInstance().getTimeInMillis() - startTime.getTimeInMillis()) > 120000) {
		break;
	    }
	    if (clients[aliveCount].isAlive()) {
		aliveCount = 0;
		continue;
	    }
	    aliveCount++;
	}

//    int refusedCount = 0;
//    for(MaximumOpenConnectionsClient client: maxOpenConnectionClients) {
//        if(client.getConnectionRefused()) {
//            refusedCount += 1;
//        }
//    }
//        System.out.println("Refused count is: " + refusedCount);
//	  System.out.println("COUNT: " + MaximumOpenConnectionsClient.getDeniedRequests());
    	assertTrue(MaximumOpenConnectionsClient.getDeniedRequests() >= 1, "(NHTTP) No Connections Rejected by max_open_connection limit - max_open_connections limit will not be exact.");
        //assertTrue(refusedCount >= 1, "(NHTTP) No Connections Rejected by max_open_connection limit - max_open_connections limit will not be exact.");

    }
 
Example 9
Source File: VFSTransportTestCase.java    From product-ei with Apache License 2.0 5 votes vote down vote up
@SetEnvironment(executionEnvironments = {ExecutionEnvironment.ALL})
@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")
public void testVFSProxyFileURI_LinuxPath_ContentType_XML()
        throws Exception {

    addVFSProxy1();

    File sourceFile = new File(pathToVfsDir + File.separator + "test.xml");
    File targetFile = new File(pathToVfsDir + "test" + File.separator + "in" + File.separator + "test.xml");
    File outfile = new File(pathToVfsDir + "test" + File.separator + "out" + File.separator + "out.xml");
    try {
        FileUtils.copyFile(sourceFile, targetFile);
        Awaitility.await()
                  .pollInterval(50, TimeUnit.MILLISECONDS)
                  .atMost(60, TimeUnit.SECONDS)
                  .until(isFileExist(outfile));
        Assert.assertTrue(outfile.exists());
        String vfsOut = FileUtils.readFileToString(outfile);
        Assert.assertTrue(vfsOut.contains("WSO2 Company"));
    } finally {
        deleteFile(targetFile);
        deleteFile(outfile);
        removeProxy("VFSProxy1");
    }
}
 
Example 10
Source File: HttpEpTemplateWithSystemPropsTestCase.java    From product-ei with Apache License 2.0 5 votes vote down vote up
@SetEnvironment(executionEnvironments = { ExecutionEnvironment.ALL })
@Test(groups = { "wso2.esb" } , enabled = true)
public void testHttpEpTemplateWithSystemProps() throws AxisFault {
	StockQuoteClient axis2Client = new StockQuoteClient();
	OMElement response = axis2Client.sendSimpleStockQuoteRequestREST(API_URL, null, "WSO2");
	// (API_URL, null, "WSO2");
	Assert.assertNotNull(response);
	Assert.assertTrue(response.toString().contains("WSO2 Company"));
}
 
Example 11
Source File: EI2757MalformedJSONPayloadFaultyTestCase.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
@SetEnvironment(executionEnvironments = { ExecutionEnvironment.ALL })
@Test(groups = "wso2.esb", description = "test malformed json in faulty sequence", enabled = true)
public void testMalformedJSONPayloadInFaultySequence() throws Exception {
    String payload = "{\"Symbol\": \"IBM}";
    HttpResponse response = httpClient
            .doPost(getApiInvocationURL("malformedJson"), null, payload, "application/json");
    assertEquals(response.getStatusLine().getStatusCode(), 500,
            "The status code set in the faulty sequence is not received");
}
 
Example 12
Source File: ResponseAfterNttpEnabledTestCase.java    From product-ei with Apache License 2.0 5 votes vote down vote up
/**
 * To check the functionality of  ESB after enabling Nhttp transport
 * <p/>
 * Test Artifacts: /artifacts/ESB/synapseconfig/nhttp_transport/nhttp.properties
 *
 * @throws Exception
 */
@SetEnvironment(executionEnvironments = {ExecutionEnvironment.ALL})
@Test(groups = "wso2.esb")
public void testMessageMediationAfterEnablingNhttp() throws Exception {
    OMElement response = axis2Client.sendSimpleStockQuoteRequest(getMainSequenceURL(), toUrl, "WSO2");

    Assert.assertTrue(response.toString().contains("WSO2 Company"), "'WSO2 Company' String " +
                                                                    "not found when nhttp enabled! ");
    Assert.assertTrue(response.toString().contains("getQuoteResponse"), "'getQuoteResponse'" +
                                                                        " String not found when nhttp enabled !");
}
 
Example 13
Source File: MessageWithoutContentTypeTestCase.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
/**
 * Sending a message without mentioning Content Type and check the body part at the listening port
 * <p/>
 * Public JIRA:    WSO2 Carbon/CARBON-6029
 * Responses With No Content-Type Header not handled properly
 * <p/>
 * Test Artifacts: ESB Sample 0
 *
 * @throws Exception - if the scenario fail
 */
@SetEnvironment(executionEnvironments = { ExecutionEnvironment.ALL })
@Test(groups = "wso2.esb")
public void testMessageWithoutContentType() throws Exception {

    // Get target URL
    String strURL = getMainSequenceURL();
    // Get SOAP action
    String strSoapAction = "getQuote";
    // Get file to be posted
    String strXMLFilename =
            FrameworkPathUtil.getSystemResourceLocation() + "artifacts" + File.separator + "ESB" + File.separator
                    + "synapseconfig" + File.separator + "messagewithoutcontent" + File.separator + "request.xml";

    File input = new File(strXMLFilename);
    // Prepare HTTP post
    PostMethod post = new PostMethod(strURL);
    // Request content will be retrieved directly
    // from the input stream
    RequestEntity entity = new FileRequestEntity(input, "text/xml");
    post.setRequestEntity(entity);
    // consult documentation for your web service
    post.setRequestHeader("SOAPAction", strSoapAction);
    // Get HTTP client
    HttpClient httpclient = new HttpClient();
    // Execute request
    try {
        int result = httpclient.executeMethod(post);
        // Display status code
        log.info("Response status code: " + result);
        // Display response
        log.info("Response body: ");
        log.info(post.getResponseBodyAsString());
    } finally {
        // Release current connection to the connection pool once you are done
        post.releaseConnection();
    }
}
 
Example 14
Source File: HttpEpTemplateWithSystemPropsTestCase.java    From micro-integrator with Apache License 2.0 4 votes vote down vote up
@SetEnvironment(executionEnvironments = { ExecutionEnvironment.ALL })
@AfterClass
public void clean() throws Exception {
    server2.stopServer();
}
 
Example 15
Source File: Sample654TestCase.java    From product-ei with Apache License 2.0 4 votes vote down vote up
@SetEnvironment(executionEnvironments = {ExecutionEnvironment.ALL})
@Test(groups = {"wso2.esb", "local only"}, description = "Smooks configuration refer from" +
        " configuration registry", enabled = false)
public void testSmookConfigFromConfigRegistry() throws Exception {
    multiMessageReceiver = new MultiMessageReceiver(PORT);

    multiMessageReceiver.startServer();
    try {
        File afile = new File(getClass().getResource(COMMON_FILE_LOCATION + File.separator
                + "edi.txt").getPath());
        File bfile = new File(getClass().getResource(COMMON_FILE_LOCATION).getPath() + "test"
                + File.separator + "in" + File.separator + "edi.txt");

        FileUtils.copyFile(afile, bfile);
        new File(getClass().getResource(COMMON_FILE_LOCATION).getPath() + "test"
                + File.separator + "out" + File.separator).mkdir();

        Thread.sleep(30000);
    } catch (Exception e) {
        e.printStackTrace();
    }

    addVFSProxy();

    long currentTime = System.currentTimeMillis();

    List<String> response = null;
    while (multiMessageReceiver.getMessageQueueSize() < MSG_COUNT) {
        log.info("Waiting for fill up the list");
        Thread.sleep(1000);

        if ( (System.currentTimeMillis() - currentTime) > 100000) {
            break;
        }
    }

    response = multiMessageReceiver.getIncomingMessages();

    assertTrue(response.size() != 0, "Response is null");

    multiMessageReceiver.stopServer();
    String totalResponse = "";
    for (String temp : response) {
        totalResponse += temp;
    }

    assertTrue(response.size() >= MSG_COUNT, "Message count is mis matching");
    assertTrue(totalResponse.contains("IBM"), "IBM is not in the response");
    assertTrue(totalResponse.contains("MSFT"), "MSFT is not in the response");
    assertTrue(totalResponse.contains("SUN"), "SUN is not in the response");
}
 
Example 16
Source File: ESBJAVA3470.java    From micro-integrator with Apache License 2.0 4 votes vote down vote up
@Test(groups = "wso2.esb", description = "VFS absolute path test for sftp")
@SetEnvironment(executionEnvironments = {ExecutionEnvironment.ALL})
public void test()
        throws XMLStreamException, ProxyServiceAdminProxyAdminException, IOException, InterruptedException {

    String baseDir;
    ClassLoader classLoader = getClass().getClassLoader();
    String identityFile = classLoader.getResource("sftp/id_rsa").getFile();
    String sentMessageFile = "getQuote.xml";
    File sourceMessage = new File(classLoader.getResource("sftp/" + sentMessageFile).getFile());
    File destinationMessage = new File(inputFolder + File.separator + sentMessageFile);
    copyFile(sourceMessage, destinationMessage);

    String proxy = "<proxy xmlns=\"http://ws.apache.org/ns/synapse\"\n" + "       name=\"SFTPTestCaseProxy\"\n"
            + "       transports=\"vfs\"\n" + "       statistics=\"disable\"\n" + "       trace=\"disable\"\n"
            + "       startOnLoad=\"true\">\n" + "   <target>\n" + "      <inSequence>\n" + "           <send>\n"
            + "               <endpoint>\n" + "                   <address uri=\"" + STOCK_QUOTE + "\"/>\n"
            + "               </endpoint>\n" + "           </send>" + "      </inSequence>\n"
            + "      <outSequence/>\n" + "   </target>\n"
            + "   <parameter name=\"transport.vfs.ActionAfterProcess\">MOVE</parameter>\n"
            + "   <parameter name=\"transport.PollInterval\">5</parameter>\n"
            + "   <parameter name=\"transport.vfs.MoveAfterProcess\">vfs:sftp://" + SFTP_USER_NAME + "@localhost:"
            + FTP_PORT + "/" + OUTPUT_FOLDER_NAME + "?transport.vfs.AvoidPermissionCheck=true</parameter>\n"
            + "   <parameter name=\"transport.vfs.FileURI\">vfs:sftp://" + SFTP_USER_NAME + "@localhost:" + FTP_PORT
            + "/" + INPUT_FOLDER_NAME + "?transport.vfs.AvoidPermissionCheck=true</parameter>\n"
            + "   <parameter name=\"transport.vfs.MoveAfterFailure\">vfs:sftp://" + SFTP_USER_NAME + "@localhost:"
            + FTP_PORT + "/" + MOVE_FOLDER_NAME + "?transport.vfs.AvoidPermissionCheck=true</parameter>\n"
            + "   <parameter name=\"transport.vfs.FileNamePattern\">.*\\.xml</parameter>\n"
            + "   <parameter name=\"transport.vfs.ContentType\">text/xml</parameter>\n"
            + "   <parameter name=\"transport.vfs.ActionAfterFailure\">MOVE</parameter>\n"
            + "   <parameter name=\"transport.vfs.SFTPIdentityPassPhrase\">" + IDENTITY_PASSPHRASE
            + "</parameter>\n" + "   <parameter name=\"transport.vfs.SFTPIdentities\">" + identityFile
            + "</parameter>\n" + "   <description/>\n" + "</proxy>\n" + "                                ";
    OMElement proxyOM = AXIOMUtil.stringToOM(proxy);

    //create VFS transport listener proxy
    try {
        Utils.deploySynapseConfiguration(proxyOM, "SFTPTestCaseProxy", "proxy-services", true);
    } catch (Exception e) {
        log.error("Error while updating the Synapse config", e);
    }
    log.info("Synapse config updated");
    Thread.sleep(30000);

    //check whether the added message was moved to the original folder
    final File[] files = outputFolder.listFiles();
    Assert.assertNotNull(files);
    Assert.assertTrue(files.length > 0);
}
 
Example 17
Source File: Sample654TestCase.java    From micro-integrator with Apache License 2.0 4 votes vote down vote up
@SetEnvironment(executionEnvironments = { ExecutionEnvironment.ALL })
@Test(groups = { "wso2.esb", "local only" }, description = "Smooks configuration refer from"
        + " configuration registry", enabled = false)
public void testSmookConfigFromConfigRegistry() throws Exception {
    multiMessageReceiver = new MultiMessageReceiver(PORT);

    multiMessageReceiver.startServer();
    try {
        File afile = new File(getClass().getResource(COMMON_FILE_LOCATION + File.separator + "edi.txt").getPath());
        File bfile = new File(
                getClass().getResource(COMMON_FILE_LOCATION).getPath() + "test" + File.separator + "in"
                        + File.separator + "edi.txt");

        FileUtils.copyFile(afile, bfile);
        new File(getClass().getResource(COMMON_FILE_LOCATION).getPath() + "test" + File.separator + "out"
                + File.separator).mkdir();

        Thread.sleep(30000);
    } catch (Exception e) {
        e.printStackTrace();
    }

    addVFSProxy();

    long currentTime = System.currentTimeMillis();

    List<String> response = null;
    while (multiMessageReceiver.getMessageQueueSize() < MSG_COUNT) {
        log.info("Waiting for fill up the list");
        Thread.sleep(1000);

        if ((System.currentTimeMillis() - currentTime) > 100000) {
            break;
        }
    }

    response = multiMessageReceiver.getIncomingMessages();

    assertTrue(response.size() != 0, "Response is null");

    multiMessageReceiver.stopServer();
    String totalResponse = "";
    for (String temp : response) {
        totalResponse += temp;
    }

    assertTrue(response.size() >= MSG_COUNT, "Message count is mis matching");
    assertTrue(totalResponse.contains("IBM"), "IBM is not in the response");
    assertTrue(totalResponse.contains("MSFT"), "MSFT is not in the response");
    assertTrue(totalResponse.contains("SUN"), "SUN is not in the response");
}
 
Example 18
Source File: HttpEpTemplateWithSystemPropsTestCase.java    From product-ei with Apache License 2.0 4 votes vote down vote up
@SetEnvironment(executionEnvironments = { ExecutionEnvironment.ALL })
@AfterClass
public void clean() throws Exception {
	server2.stopServer();
}