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

The following examples show how to use org.wso2.carbon.automation.engine.annotations.ExecutionEnvironment#STANDALONE . 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: Sample254TestCase.java    From product-ei with Apache License 2.0 6 votes vote down vote up
@SetEnvironment(executionEnvironments = { ExecutionEnvironment.STANDALONE })
@Test(groups = { "wso2.esb" }, description = "Testing VFS transport")
public void testVfsTransport() throws Exception {
    File sourceFile = new File(pathToVfsDir + "test.xml");
    File targetFile = new File(inFolder.getAbsolutePath() + File.separator + "test.xml");
    outfile = new File(outFolder.getAbsolutePath() + File.separator + "out.xml");
    try {
        FileUtils.copyFile(sourceFile, targetFile);
        boolean isOutFileExist = isOutFileExist();
        assertTrue(isOutFileExist, "out.xml file not found");
        String vfsOut = FileUtils.readFileToString(outfile);
        assertTrue(vfsOut.contains("WSO2 Company"), "WSO2 Company string not found");
    } finally {
        deleteFolder(targetFile);
        deleteFolder(outfile);
    }
}
 
Example 2
Source File: IterateNamedEndpointsTest.java    From product-ei with Apache License 2.0 6 votes vote down vote up
@SetEnvironment(executionEnvironments = {ExecutionEnvironment.STANDALONE
})
	@Test(groups = "wso2.esb", description = "Tests 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 3
Source File: TCPSessionPersistenceSplitBySpecialCharacterTestCase.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
@SetEnvironment(executionEnvironments = { ExecutionEnvironment.STANDALONE })
@Test(groups = "wso2.esb", description = "Tcp proxy service configured to split by a special character")
public void tcpTransportSplitBySpecialCharacterProxy() throws Exception {
    int messageCount = 3;
    Character aByte = 0x03;
    NativeTCPClient tcpClient = new NativeTCPClient(NativeTCPClient.DelimiterTypeEnum.BYTE.getDelimiterType(),
            messageCount, 6791);
    String message = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap"
            + ".org/soap/envelope/\"><soapenv:Header/><soapenv:Body/></soapenv:Envelope>";
    tcpClient.setMessage(message);
    tcpClient.setByteDelimiter(aByte);
    tcpClient.sendToServer();
    String[] responses = tcpClient.receiveCharactorTypeDelimiterResonse();
    Assert.assertEquals(messageCount, responses.length);
    for (String response : responses) {
        Assert.assertNotNull(response, "Received a null response from the server");
        Assert.assertNotEquals(StringUtils.EMPTY, response, "Received an empty response from the server");
    }
}
 
Example 4
Source File: SpringMediationTestCase.java    From product-ei with Apache License 2.0 6 votes vote down vote up
@SetEnvironment(executionEnvironments = {ExecutionEnvironment.STANDALONE
})
    @Test(groups = {"wso2.esb", "localOnly"}, description = "Spring Mediator " +
                                                            "-Added Simple bean into lib -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 5
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 6
Source File: ESBJAVA1897HttpHeadMethodTestCase.java    From product-ei with Apache License 2.0 6 votes vote down vote up
@SetEnvironment(executionEnvironments = {ExecutionEnvironment.STANDALONE})
    @BeforeClass(alwaysRun = true)
    public void init() throws Exception {
    	// start the axis2 server and deploy the Student Service

//    	if (FrameworkFactory.getFrameworkProperties(ProductConstant.ESB_SERVER_NAME).getEnvironmentSettings().is_builderEnabled()) {
    		axis2Server1 = new SampleAxis2Server("test_axis2_server_9009.xml");
    		axis2Server1.start();
    		axis2Server1.deployService(ESBTestConstant.SIMPLE_AXIS2_SERVICE);
    		axis2Server1.deployService(ESBTestConstant.STUDENT_REST_SERVICE);
//    	}
        super.init();
        // load the proxy config
        String relativePath = "artifacts" + File.separator + "ESB" +
                File.separator + "synapseconfig" + File.separator + "rest" +
                File.separator + "rest-service-proxy.xml";
        ESBTestCaseUtils util = new ESBTestCaseUtils();
        relativePath = relativePath.replaceAll("[\\\\/]", File.separator);
        OMElement proxyConfig = util.loadResource(relativePath);
        addProxyService(proxyConfig);

        Awaitility.await()
                  .pollInterval(50, TimeUnit.MILLISECONDS)
                  .atMost(60, TimeUnit.SECONDS)
                  .until(isDeployed(proxyConfig));
    }
 
Example 7
Source File: FaultyDataServiceTestCase.java    From product-ei with Apache License 2.0 6 votes vote down vote up
@Test(groups = "wso2.dss", dependsOnMethods = {"serviceReDeployment"},
      description = "send requests to redeployed service")
@SetEnvironment(executionEnvironments = {ExecutionEnvironment.STANDALONE})
public void serviceInvocation()
        throws RemoteException, ServiceAdminException, XPathExpressionException {
    OMElement response;
    String serviceEndPoint = getServiceUrlHttp(serviceName) +"/";
    AxisServiceClient axisServiceClient = new AxisServiceClient();
    for (int i = 0; i < 5; i++) {
        response = axisServiceClient.sendReceive(getPayload(), serviceEndPoint, "showAllOffices");
        Assert.assertTrue(response.toString().contains("<Office>"), "Expected Result not Found");
        Assert.assertTrue(response.toString().contains("<officeCode>"), "Expected Result not Found");
        Assert.assertTrue(response.toString().contains("<city>"), "Expected Result not Found");
        Assert.assertTrue(response.toString().contains("<phone>"), "Expected Result not Found");
        Assert.assertTrue(response.toString().contains("</Office>"), "Expected Result not Found");
    }
    log.info("service invocation success");
}
 
Example 8
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")
public void testSendingFailOverEndpoint_Receiving_Sequence_GovReg() throws IOException, InterruptedException {
    OMElement response = axis2Client
            .sendSimpleStockQuoteRequest(getProxyServiceURLHttp("failOverEndPoint_Receiving_Sequence_GovReg"), null,
                    "WSO2");
    Assert.assertTrue(response.toString().contains("WSO2 Company"));

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

    }
}
 
Example 9
Source File: SetPathTestCase.java    From product-ei with Apache License 2.0 5 votes vote down vote up
@SetEnvironment(executionEnvironments = {ExecutionEnvironment.STANDALONE})
@Test(groups = {"wso2.esb"}, description = "Setting path",
      dataProvider = "addressingUrl")
public void setPath(String addUrl) throws AxisFault {
    OMElement response;

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

}
 
Example 10
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 Dynamic Build Message")
public void testSendingFailOverEndpoint_Receiving_Sequence_Dynamic_BM() throws IOException, InterruptedException {
    OMElement response = axis2Client
            .sendSimpleStockQuoteRequest(getProxyServiceURLHttp("failOverEndPoint_Receiving_Sequence_Dynamic_BM"),
                    null, "WSO2");
    Assert.assertTrue(response.toString().contains("WSO2 Company"));

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

    }
}
 
Example 11
Source File: GroovyScriptSupportTestCase.java    From product-ei with Apache License 2.0 5 votes vote down vote up
@SetEnvironment(executionEnvironments = {ExecutionEnvironment.STANDALONE
})
    @Test(groups = {"wso2.esb", "localOnly"}, description = "Script Mediator -Run a Groovy script with setPayloadJson",enabled =false)
    public void testGroovySetPayloadJson() throws Exception {

        String query = "{\"key\":\"value\"}";
        String addUrl = getProxyServiceURLHttps("scriptMediatorGroovySetJsonPayloadTestProxy");
        String expectedResult = "{\"fileID\":\"89265\",\"mySiteID\":\"54571\"}";

        String actualResult = jsonclient.sendUserDefineRequest(addUrl, query).toString();

        assertEquals(actualResult, expectedResult, "Fault: value 'symbol' mismatched");
    }
 
Example 12
Source File: DynamicSSLProfilesPTTListenerTestCase.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
@SetEnvironment(executionEnvironments = { ExecutionEnvironment.STANDALONE })
@AfterClass(alwaysRun = true)
public void destroy() throws Exception {
    super.reloadSessionCookie();
    deleteProxyService(proxyService);
    super.cleanup();
    if (serverManager != null) {
        serverManager.restoreToLastMIConfiguration();
    }
}
 
Example 13
Source File: SetPathTestCase.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
@SetEnvironment(executionEnvironments = { ExecutionEnvironment.STANDALONE })
@Test(groups = { "wso2.esb" }, description = "Setting path", dataProvider = "addressingUrl")
public void setPath(String addUrl) throws AxisFault {
    OMElement response;

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

}
 
Example 14
Source File: Sample60TestCase.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
@SetEnvironment(executionEnvironments = { ExecutionEnvironment.STANDALONE })
@Test(groups = { "wso2.esb" }, description = "Routing a Message to a Static List of Recipients", enabled = false)
public void testStaticListOfRecipients() throws Exception {

    axis2Client.sendPlaceOrderRequest(getMainSequenceURL(), null, "WSO2");
    Thread.sleep(5000);

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

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

    listener1.clear();
    listener2.clear();
    listener3.clear();

    axis2Server1.stop();

    axis2Client.sendPlaceOrderRequest(getMainSequenceURL(), null, "WSO2");
    Thread.sleep(5000);

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

    Assert.assertFalse(is9001Called, "Service 9001 called");
    Assert.assertTrue(is9002Called, "Service 9002 not called");
    Assert.assertTrue(is9003Called, "Service 9003 not called");
}
 
Example 15
Source File: SendIntegrationTestCase.java    From product-ei with Apache License 2.0 5 votes vote down vote up
@SetEnvironment(executionEnvironments = {ExecutionEnvironment.STANDALONE
})
    @Test(groups = "wso2.esb", description = "Test sending request to Default Endpoint")
    public void testSendingDefaultEndpoint() throws Exception {
        OMElement response = axis2Client.sendSimpleStockQuoteRequest(getProxyServiceURLHttp("defaultEndPoint"),
                                                                     getBackEndServiceUrl(ESBTestConstant.SIMPLE_STOCK_QUOTE_SERVICE), "WSO2");
        Assert.assertNotNull(response);
        Assert.assertTrue(response.toString().contains("WSO2 Company"));
    }
 
Example 16
Source File: Sample60TestCase.java    From product-ei with Apache License 2.0 5 votes vote down vote up
@SetEnvironment(executionEnvironments = { ExecutionEnvironment.STANDALONE })
@Test(groups = { "wso2.esb" }, description = "Routing a Message to a Static List of Recipients", enabled = false)
public void testStaticListOfRecipients() throws Exception {

    axis2Client.sendPlaceOrderRequest(getMainSequenceURL(), null, "WSO2");
    Thread.sleep(5000);

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

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

    listener1.clear();
    listener2.clear();
    listener3.clear();

    axis2Server1.stop();

    axis2Client.sendPlaceOrderRequest(getMainSequenceURL(), null, "WSO2");
    Thread.sleep(5000);

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

    Assert.assertFalse(is9001Called, "Service 9001 called");
    Assert.assertTrue(is9002Called, "Service 9002 not called");
    Assert.assertTrue(is9003Called, "Service 9003 not called");
}
 
Example 17
Source File: Sample420TestCase.java    From product-ei with Apache License 2.0 5 votes vote down vote up
@SetEnvironment(executionEnvironments = {ExecutionEnvironment.STANDALONE})
@Test(groups = {"wso2.esb"}, description = "Creating simple cache sample 420 Test Case")
public void testSimpleCachingNotExists() throws AxisFault, XPathExpressionException, InterruptedException {
    OMElement response;

    long currTime = System.currentTimeMillis();
    long timeDiff = 0;

    response = axis2Client.sendSimpleStockQuoteRequest(getMainSequenceURL(), "", "IBM");
    String firstResponse = response.getFirstElement().toString();

    while (timeDiff < 20000) {

        response = axis2Client.sendSimpleStockQuoteRequest(getMainSequenceURL(), "", "IBM");

        assertEquals(firstResponse, response.getFirstElement().toString(), "Caching is less than 20 seconds");

        /*The timeout I have set in the Sample is 20s. The test here within the while loop is to ensure the
         cache is not evicted before 20s. Hence a thread sleep is used.*/
        Thread.sleep(2000);
        timeDiff = System.currentTimeMillis() - currTime;
    }

    response = axis2Client.sendSimpleStockQuoteRequest(getMainSequenceURL(), "", "IBM");

    assertNotEquals(firstResponse, response.getFirstElement().toString());
}
 
Example 18
Source File: VFSHidePasswordLogESBJAVA3419.java    From product-ei with Apache License 2.0 4 votes vote down vote up
@SetEnvironment(executionEnvironments = { ExecutionEnvironment.STANDALONE })
@Test(groups = { "wso2.esb" }, description = "Checking VFSTransportListener not logs the clear password on error")
public void testVFSListenerHidePasswordInLog() throws Exception {

	addProxyService(AXIOMUtil
			.stringToOM("<proxy xmlns=\"http://ws.apache.org/ns/synapse\"\n"
					+ "       name=\"HidePasswordListenerProxy\"\n"
					+ "       transports=\"vfs\"\n"
					+ "       statistics=\"disable\"\n"
					+ "       trace=\"disable\"\n"
					+ "       startOnLoad=\"true\">\n"
					+ "   <target>\n"
					+ "      <outSequence>\n"
					+ "         <property name=\"transport.vfs.ReplyFileName\"\n"
					+ "                   expression=\"fn:concat(fn:substring-after(get-property('MessageID'), 'urn:uuid:'), '.xml')\"\n"
					+ "                   scope=\"transport\"/>\n"
					+ "         <property name=\"OUT_ONLY\" value=\"true\"/>\n"
					+ "         <send>\n"
					+ "            <endpoint>\n"
					+ "               <address uri=\"vfs:smb://username:ClearPassword@localhost/test/out\"/>\n"
					+ "            </endpoint>\n"
					+ "         </send>\n"
					+ "      </outSequence>\n"
					+ "      <endpoint>\n"
					+ "         <address uri=\"http://localhost:9000/services/SimpleStockQuoteService\"\n"
					+ "                  format=\"soap12\"/>\n"
					+ "      </endpoint>\n"
					+ "   </target>\n"
					+ "   <publishWSDL uri=\"file:samples/service-bus/resources/proxy/sample_proxy_1.wsdl\"/>\n"
					+ "   <parameter name=\"transport.vfs.ActionAfterProcess\">MOVE</parameter>\n"
					+ "   <parameter name=\"transport.PollInterval\">1</parameter>\n"
					+ "   <parameter name=\"transport.vfs.MoveAfterProcess\">vfs:smb://username:ClearPassword@localhost/test/original</parameter>\n"
					+ "   <parameter name=\"transport.vfs.FileURI\">vfs:smb://username:ClearPassword@localhost/test/out</parameter>\n"
					+ "   <parameter name=\"transport.vfs.MoveAfterFailure\">vfs:smb://username:ClearPassword@localhost/test/original</parameter>\n"
					+ "   <parameter name=\"transport.vfs.FileNamePattern\">.*\\.text</parameter>\n"
					+ "   <parameter name=\"transport.vfs.ContentType\">text/xml</parameter>\n"
					+ "   <parameter name=\"transport.vfs.ActionAfterFailure\">MOVE</parameter>\n"
					+ "   <parameter name=\"ScenarioID\">scenario1</parameter>\n"
					+ "   <description/>\n" + "</proxy>"));

	Thread.sleep(3000);

	Assert.assertFalse(isClearPassword(),
			" The password is getting printed in the log in the VFSTransportListener.");

}
 
Example 19
Source File: PropertyIntegrationNO_ENTITY_BODY_PropertyTest.java    From product-ei with Apache License 2.0 4 votes vote down vote up
@SetEnvironment(executionEnvironments = {ExecutionEnvironment.STANDALONE})
@Test(groups = "wso2.esb", expectedExceptions = OMException.class, description = "Test-With NO_ENTITY_BODY")
public void testWithNoEntityBodyPropertTest() throws Exception {
    client.getWithContentType(getProxyServiceURLHttp("Axis2ProxyService2") + "/echoString",
            "in=IBM", MediaType.APPLICATION_FORM_URLENCODED);
}
 
Example 20
Source File: ValidPathAxis2RepoTestCase.java    From product-ei with Apache License 2.0 3 votes vote down vote up
@SetEnvironment(executionEnvironments = {ExecutionEnvironment.STANDALONE})
@Test(groups = "wso2.esb", enabled = false)
public void TestPath() throws AxisFault {

    OMElement response = axis2Client.sendSimpleStockQuoteRequest(getMainSequenceURL(), null, "IBM");    // send the simplestockquote request. service url is set at the synapse

    boolean ResponseContainsIBM = response.getFirstElement().toString().contains("IBM");      //checks whether the  response contains IBM

    assertTrue(ResponseContainsIBM, "Symbol name mismatched");
}