// Path: test-automation-framework/org.wso2.carbon.automation.engine/src/main/java/org/wso2/carbon/automation/engine/exceptions/AutomationFrameworkException.java
// public class AutomationFrameworkException extends Exception {
//     public AutomationFrameworkException(String message) {
//         super(message);
//     }
// 
//     public AutomationFrameworkException(String message, Throwable e) {
//         super(message, e);
//     }
// 
//     public AutomationFrameworkException(Throwable e) {
//         super(e);
//     }
// }


import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMFactory;
import org.apache.axiom.om.OMNamespace;
import org.apache.axiom.om.util.AXIOMUtil;
import org.apache.axis2.AxisFault;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.Options;
import org.apache.axis2.client.ServiceClient;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.automation.engine.exceptions.AutomationFrameworkException;
import javax.xml.stream.XMLStreamException;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.nio.charset.Charset;
import java.util.List;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.fail;
        }
    }

    public static void sendRequest(String eprUrl, String operation, String payload,
                                   int numberOfInstances, List<String> expectedStrings,
                                   boolean twoWay) throws  AutomationFrameworkException {
        try {
            waitForServiceDeployment(eprUrl);
            assertFalse(!AxisServiceClientUtils.isServiceAvailable(eprUrl));
        } catch (IOException e) {
            log.error(e);
            throw new AutomationFrameworkException("Service not available " , e);
        }

        for (int i = 0; i < numberOfInstances; i++) {
            try {
                EndpointReference epr = new EndpointReference(eprUrl + "/" + operation);
                if (twoWay) {
                    OMElement result = AxisServiceClientUtils.sendRequest(payload, epr);
                    if (expectedStrings != null) {
                        for (String expectedString : expectedStrings) {
                            assertFalse(!result.toString()
                                    .contains(expectedString));
                        }
                    }
                } else {
                    AxisServiceClientUtils.sendRequestOneWay(payload, epr);
                }
            } catch (XMLStreamException e) {
                log.error(e);
// Path: test-automation-framework/org.wso2.carbon.automation.engine/src/main/java/org/wso2/carbon/automation/engine/exceptions/AutomationFrameworkException.java
// public class AutomationFrameworkException extends Exception {
//     public AutomationFrameworkException(String message) {
//         super(message);
//     }
// 
//     public AutomationFrameworkException(String message, Throwable e) {
//         super(message, e);
//     }
// 
//     public AutomationFrameworkException(Throwable e) {
//         super(e);
//     }
// }


// Path: test-automation-framework/org.wso2.carbon.automation.test.utils/src/main/java/org/wso2/carbon/automation/test/utils/axis2client/AxisServiceClientUtils.java
import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMFactory;
import org.apache.axiom.om.OMNamespace;
import org.apache.axiom.om.util.AXIOMUtil;
import org.apache.axis2.AxisFault;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.Options;
import org.apache.axis2.client.ServiceClient;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.automation.engine.exceptions.AutomationFrameworkException;
import javax.xml.stream.XMLStreamException;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.nio.charset.Charset;
import java.util.List;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.fail;

        }
    }

    public static void sendRequest(String eprUrl, String operation, String payload,
                                   int numberOfInstances, List<String> expectedStrings,
                                   boolean twoWay) throws  AutomationFrameworkException {
        try {
            waitForServiceDeployment(eprUrl);
            assertFalse(!AxisServiceClientUtils.isServiceAvailable(eprUrl));
        } catch (IOException e) {
            log.error(e);
            throw new AutomationFrameworkException("Service not available " , e);
        }

        for (int i = 0; i < numberOfInstances; i++) {
            try {
                EndpointReference epr = new EndpointReference(eprUrl + "/" + operation);
                if (twoWay) {
                    OMElement result = AxisServiceClientUtils.sendRequest(payload, epr);
                    if (expectedStrings != null) {
                        for (String expectedString : expectedStrings) {
                            assertFalse(!result.toString()
                                    .contains(expectedString));
                        }
                    }
                } else {
                    AxisServiceClientUtils.sendRequestOneWay(payload, epr);
                }
            } catch (XMLStreamException e) {
                log.error(e);
                throw new AutomationFrameworkException("cannot read xml stream " , e);