Java Code Examples for org.wso2.carbon.automation.test.utils.axis2client.AxisServiceClient#sendRobust()

The following examples show how to use org.wso2.carbon.automation.test.utils.axis2client.AxisServiceClient#sendRobust() . 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: DeactivatedCappMPBehaviourOnRestartTestCase.java    From product-ei with Apache License 2.0 6 votes vote down vote up
@Test(groups = { "wso2.esb" },
      description = "Testing whether a deactivated Message Processor from a capp is deployed successfully upon ESB server restart")
public void testDeactivatedMPUponServerRestart() throws Exception {

    // Stopping the axis2 Server before sending the client request.
    axis2Server.stop();
    AxisServiceClient client = new AxisServiceClient();
    client.sendRobust(createPlaceOrderRequest(3.141593E0, 4, "IBM"), getProxyServiceURLHttp(PROXY_SERVICE_NAME),
            "placeOrder");

    // Wait till the MP deactivates successfully. MP will try sending the message 4 times before getting deactivated.
    Thread.sleep(15000);

    axis2Server.start();

    // Restart the ESB Server after the MP is deactivated.
    serverConfigurationManager.restartGracefully();

    super.init();
    logViewerClient = new LogViewerClient(contextUrls.getBackEndUrl(), getSessionCookie());

    Assert.assertFalse(Utils.checkForLog(logViewerClient, EXPECTED_ERROR_MESSAGE, 10),
            "Error occurred while deploying Carbon Application!");
    Assert.assertTrue(Utils.checkForLog(logViewerClient, SUCCESS_MESSAGE, 10),
            "Unable to deploy Carbon Application!");
}
 
Example 2
Source File: OutputMappingAsAttributeDataServiceTestCase.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
@Test(groups = { "wso2.dss" })
public void addOffice() throws AxisFault, XPathExpressionException {
    AxisServiceClient serviceClient = new AxisServiceClient();
    serviceClient.sendRobust(getPayloadAddOffice("25", "NY", "Boston", "EMEA"), getServiceUrlHttp(serviceName),
            "addOffice");
    serviceClient.sendRobust(getPayloadAddOffice("26", "NY", "Boston", null), getServiceUrlHttp(serviceName),
            "addOffice");
    serviceClient.sendRobust(getPayloadAddOffice("27", "NY", "Boston", "NULL"), getServiceUrlHttp(serviceName),
            "addOffice");
}
 
Example 3
Source File: FileServiceTestCase.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
@Test(groups = { "wso2.dss" }, dependsOnMethods = { "createNewFile" })
public void addRecord() throws IOException, XPathExpressionException {
    OMElement payload = fac.createOMElement("_postappenddatatofile", omNs);
    StringBuilder recordsExpected = new StringBuilder();

    OMElement fileName = fac.createOMElement("fileName", omNs);
    fileName.setText(txtFileName);
    payload.addChild(fileName);

    OMElement fileRecord = fac.createOMElement("data", omNs);
    AxisServiceClient axisClient = new AxisServiceClient();
    Base64 encoder = new Base64();
    //        encoder.e
    //        BASE64Decoder decoder = new BASE64Decoder();
    for (int i = 0; i < 5; i++) {
        String record = "TestFileRecord" + i;
        fileRecord.setText(new String(encoder.encode(record.getBytes())));
        payload.addChild(fileRecord);
        recordsExpected.append(record).append(";");
        axisClient.sendRobust(payload, getServiceUrlHttp(serviceName), "_postappenddatatofile");

    }
    log.info("Records Added");
    OMElement response = getRecord();
    Iterator file = response.getChildrenWithLocalName("File");
    StringBuilder recordData = new StringBuilder();
    while (file.hasNext()) {
        OMElement data = (OMElement) file.next();
        recordData.append(new String(encoder.decode(data.getFirstElement().getText().getBytes()))).append(";");

    }
    Assert.assertNotSame("", recordsExpected.toString(), "No Record added to file. add records to file");
    Assert.assertEquals(recordData.toString(), recordsExpected.toString(), "Record Data Mismatched");
}
 
Example 4
Source File: ESBJAVA_4239_AccessHTTPSCAfterCallout.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
@Test(groups = { "wso2.esb" }, description = "Test whether an HTTP SC can be retrieved after the callout mediator.")
public void testFetchHTTP_SC_After_Callout_Mediator() throws RemoteException, InterruptedException {
    final String proxyUrl = getProxyServiceURLHttp(PROXY_SERVICE_NAME);
    AxisServiceClient client = new AxisServiceClient();
    client.sendRobust(createPlaceOrderRequest(3.141593E0, 4, "IBM"), proxyUrl, "placeOrder");

    boolean isScFound = carbonLogReader.checkForLog(EXPECTED_LOG_MESSAGE, DEFAULT_TIMEOUT);
    Assert.assertTrue(isScFound, "The HTTP Status Code was not found in the log.");
    carbonLogReader.stop();
}
 
Example 5
Source File: ESBJAVA3412EmptyStackExceptionTest.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
/**
 * Checks and verifies whether the EmptyStackException is NOT thrown when
 * <code>Iterate</code> and <code>Clone</code> mediators are used in
 * combination with the continueParent attribute set to <code>true</code>
 *
 * @throws InterruptedException
 * @throws RemoteException
 */
@Test(groups = "wso2.esb", description = "Checking for Empty Stack Exception when clone mediators are used with continue parent attribute set to true")
public void testForEmptyStackAfterCloned_With_ContinueParent() throws InterruptedException, RemoteException {
    final String expectedErrorMsg = "Unexpected error executing task/async inject";
    final String expectedStackTrace = "java.util.Stack.peek";

    boolean isEmptyStackError;
    OMElement request = getSecurityRequest();

    // invoking the service through the proxy service
    AxisServiceClient client = new AxisServiceClient();

    final String proxyUrl = contextUrls.getServiceUrl() + "/CloneMediatorEmptyStackProxy";

    try {
        client.sendRobust(request, proxyUrl, "mediate");
    } catch (Exception e) {
        // Ignore it.
    }
    isEmptyStackError = carbonLogReader.checkForLog(expectedErrorMsg, DEFAULT_TIMEOUT) && carbonLogReader.
            checkForLog(expectedStackTrace, DEFAULT_TIMEOUT);
    carbonLogReader.stop();
    /*
     * Asserting the results here. If there's an Empty stack error, then the
     * assertion should fail.
     */
    Assert.assertTrue(!isEmptyStackError, "Empty Stack ERROR message was found in the LOG stream.");
}
 
Example 6
Source File: DeactivatedCappMPBehaviourOnRestartTestCase.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
@Test(groups = {"wso2.esb"},
        description = "Testing whether a deactivated Message Processor from a capp is deployed successfully " +
                "upon ESB server restart")
public void testDeactivatedMPUponServerRestart() throws Exception {

    CarbonLogReader carbonLogReader = new CarbonLogReader();
    carbonLogReader.start();
    // Stopping the axis2 Server before sending the client request.
    axis2Server.stop();
    AxisServiceClient client = new AxisServiceClient();
    client.sendRobust(createPlaceOrderRequest(3.141593E0, 4, "IBM"), getProxyServiceURLHttp(PROXY_SERVICE_NAME),
            "placeOrder");

    // Wait till the MP deactivates successfully. MP will try sending the message 4 times before getting deactivated.
    Thread.sleep(15000);

    axis2Server.start();

    // Restart the ESB Server after the MP is deactivated.
    CarbonServerExtension.restartServer();

    super.init();

    Assert.assertFalse(Utils.logExists(carbonLogReader, EXPECTED_ERROR_MESSAGE, 10),
            "Error occurred while deploying Carbon Application!");
    Assert.assertTrue(Utils.logExists(carbonLogReader, SUCCESS_MESSAGE, 10),
            "Unable to deploy Carbon Application!");
}
 
Example 7
Source File: OutputMappingAsAttributeDataServiceTestCase.java    From product-ei with Apache License 2.0 5 votes vote down vote up
@Test(groups = {"wso2.dss"})
public void addOffice() throws AxisFault, XPathExpressionException {
    AxisServiceClient serviceClient = new AxisServiceClient();
    serviceClient.sendRobust(getPayloadAddOffice("25", "NY", "Boston", "EMEA"), getServiceUrlHttp(serviceName), "addOffice");
    serviceClient.sendRobust(getPayloadAddOffice("26", "NY", "Boston", null), getServiceUrlHttp(serviceName), "addOffice");
    serviceClient.sendRobust(getPayloadAddOffice("27", "NY", "Boston", "NULL"), getServiceUrlHttp(serviceName), "addOffice");
}
 
Example 8
Source File: FileServiceTestCase.java    From product-ei with Apache License 2.0 5 votes vote down vote up
@Test(groups = {"wso2.dss"}, dependsOnMethods = {"createNewFile"})
    public void addRecord() throws IOException, XPathExpressionException {
        OMElement payload = fac.createOMElement("_postappenddatatofile", omNs);
        String recordsExpected = "";

        OMElement fileName = fac.createOMElement("fileName", omNs);
        fileName.setText(txtFileName);
        payload.addChild(fileName);

        OMElement fileRecord = fac.createOMElement("data", omNs);
        AxisServiceClient axisClient = new AxisServiceClient();
        Base64 encoder = new Base64();
//        encoder.e
//        BASE64Decoder decoder = new BASE64Decoder();
        for (int i = 0; i < 5; i++) {
            String record = "TestFileRecord" + i;
            fileRecord.setText(new String(encoder.encode(record.getBytes())));
            payload.addChild(fileRecord);
            recordsExpected = recordsExpected + record + ";";
            axisClient.sendRobust(payload, getServiceUrlHttp(serviceName), "_postappenddatatofile");

        }
        log.info("Records Added");
        OMElement response = getRecord();
        Iterator file = response.getChildrenWithLocalName("File");
        String recordData = "";
        while (file.hasNext()) {
            OMElement data = (OMElement) file.next();
            recordData = recordData + new String(encoder.decode(data.getFirstElement().getText().getBytes())) + ";";

        }
        Assert.assertNotSame("", recordsExpected, "No Record added to file. add records to file");
        Assert.assertEquals(recordData, recordsExpected, "Record Data Mismatched");
    }
 
Example 9
Source File: ESBJAVA_4239_AccessHTTPSCAfterCallout.java    From product-ei with Apache License 2.0 5 votes vote down vote up
@Test(groups = { "wso2.esb" }, description = "Test whether an HTTP SC can be retrieved after the callout mediator.")
public void testFetchHTTP_SC_After_Callout_Mediator() throws RemoteException,
        InterruptedException {
    final String proxyUrl = getProxyServiceURLHttp(PROXY_SERVICE_NAME);
    AxisServiceClient client = new AxisServiceClient();
    client.sendRobust(createPlaceOrderRequest(3.141593E0, 4, "IBM"), proxyUrl, "placeOrder");

    logViewerClient = new LogViewerClient(contextUrls.getBackEndUrl(), getSessionCookie());
    boolean isScFound = Utils.checkForLog(logViewerClient, EXPECTED_LOG_MESSAGE, 20);
    Assert.assertTrue(isScFound, "The HTTP Status Code was not found in the log.");
}
 
Example 10
Source File: ESBJAVA3412EmptyStackExceptionTest.java    From product-ei with Apache License 2.0 4 votes vote down vote up
/**
 * Checks and verifies whether the EmptyStackException is NOT thrown when
 * <code>Iterate</code> and <code>Clone</code> mediators are used in
 * combination with the continueParent attribute set to <code>true</code>
 * 
 * @throws InterruptedException
 * @throws RemoteException
 */
@Test(groups = "wso2.esb", description = "Checking for Empty Stack Exception when clone mediators are used with continue parent attribute set to true")
public void testForEmptyStackAfterCloned_With_ContinueParent()
		throws InterruptedException, RemoteException {
	final String expectedErrorMsg = "Unexpected error executing task/async inject";
	final String expectedStackTrace = "java.util.Stack.peek";

	boolean isEmptyStackError = false;
	OMElement request = getSecurityRequest();

	// invoking the service through the proxy service
	AxisServiceClient client = new AxisServiceClient();

	final String proxyUrl = contextUrls.getServiceUrl() + "/CloneMediatorEmptyStackProxy";

	try {
		client.sendRobust(request, proxyUrl, "mediate");
	} catch (Exception e) {
		// Ignore it.
	}

	Thread.sleep(2000);

	LogEvent[] logs = logViewerClient.getAllRemoteSystemLogs();

	// Asserting both the ERROR message and the stack trace.

	for (LogEvent logEvent : logs) {
		String message = logEvent.getMessage();
		String stackTrace = logEvent.getStacktrace();
		if (message.contains(expectedErrorMsg)
				&& stackTrace.contains(expectedStackTrace)) {
			isEmptyStackError = true;
			break;
		}
	}

	/*
	 * Asserting the results here. If there's an Empty stack error, then the
	 * assertion should fail.
	 */
	Assert.assertTrue(!isEmptyStackError,
			"Empty Stack ERROR message was found in the LOG stream.");
}