public abstract class ConnectorIntegrationTestBase
extends org.wso2.esb.integration.common.utils.ESBIntegrationTest
| Modifier and Type | Class and Description |
|---|---|
protected class |
ConnectorIntegrationTestBase.MultipartFormdataProcessor
Inner class to handle Multipart data
|
| Modifier and Type | Field and Description |
|---|---|
protected Properties |
connectorProperties |
protected static int |
MULTIPART_TYPE_RELATED |
protected String |
pathToResourcesDirectory |
protected String |
proxyUrl |
| Constructor and Description |
|---|
ConnectorIntegrationTestBase() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
cleanup() |
void |
cleanUpEsb()
Clean up the ESB.
|
String |
getValueByExpression(String xPathExpression,
org.apache.axiom.om.OMElement element)
Gets the element value by xpath expression.
|
protected void |
init(String connectorName)
Set up the integration test environment.
|
protected Object |
loadObjectFromFile(String fileName)
Overloaded method for
loadObjectFromFile without parameter
map. |
protected Object |
loadObjectFromFile(String fileName,
Map<String,String> paramMap)
This method de-serialize XML object graph.
|
protected InputStream |
processForInputStream(String endPoint,
String httpMethod,
Map<String,String> headersMap,
String requestFileName,
Map<String,String> parametersMap)
Send HTTP request using
HttpURLConnection in JSON format to return InputStream. |
protected InputStream |
processForInputStreamHTTPS(String endPoint,
String httpMethod,
Map<String,String> headersMap,
String requestFileName,
Map<String,String> parametersMap)
Overloaded method for
processForInputStreamHTTPS, where parameter replacement is not necessary. |
protected InputStream |
processForInputStreamHTTPS(String endPoint,
String httpMethod,
Map<String,String> headersMap,
String requestFileName,
Map<String,String> parametersMap,
boolean isIgnoreHostVerification)
Send HTTP request using
HttpURLConnection in JSON format to return InputStream. |
protected RestResponse<org.json.JSONObject> |
sendBinaryContentForJsonResponse(String endPoint,
String httpMethod,
Map<String,String> headersMap,
String fileName)
Send HTTP request using
HttpURLConnection in JSON format. |
protected RestResponse<org.json.JSONObject> |
sendBinaryContentForJsonResponseHTTPS(String endPoint,
String httpMethod,
Map<String,String> headersMap,
String fileName)
Send HTTPS request using
HttpsURLConnection in JSON format. |
protected RestResponse<org.apache.axiom.om.OMElement> |
sendBinaryContentForXmlResponse(String endPoint,
String httpMethod,
Map<String,String> headersMap,
String fileName)
Send HTTP request using
HttpURLConnection in XML format. |
protected RestResponse<org.apache.axiom.om.OMElement> |
sendBinaryContentForXmlResponseHTTPS(String endPoint,
String httpMethod,
Map<String,String> headersMap,
String fileName)
Send HTTPS request using
HttpsURLConnection in XML format. |
protected RestResponse<org.json.JSONObject> |
sendJsonRestRequest(String endPoint,
String httpMethod,
Map<String,String> headersMap)
Overloaded method for
sendJsonRestRequest, where the request file is not necessary. |
protected RestResponse<org.json.JSONObject> |
sendJsonRestRequest(String endPoint,
String httpMethod,
Map<String,String> headersMap,
String requestFileName)
Overloaded method for
sendJsonRestRequest, where parameter replacement is not necessary. |
protected RestResponse<org.json.JSONObject> |
sendJsonRestRequest(String endPoint,
String httpMethod,
Map<String,String> headersMap,
String requestFileName,
Map<String,String> parametersMap)
Send HTTP request using
HttpURLConnection in JSON format. |
protected RestResponse<org.json.JSONObject> |
sendJsonRestRequestHTTPS(String endPoint,
String httpMethod,
Map<String,String> headersMap,
String requestFileName,
Map<String,String> parametersMap)
Overloaded method for
sendJsonRestRequestHTTPS, where parameter replacement is not necessary. |
protected RestResponse<org.json.JSONObject> |
sendJsonRestRequestHTTPS(String endPoint,
String httpMethod,
Map<String,String> headersMap,
String requestFileName,
Map<String,String> parametersMap,
boolean isIgnoreHostVerification)
Send HTTP request to using
HttpsURLConnection in JSON format. |
protected org.apache.axiom.soap.SOAPEnvelope |
sendSOAPRequest(String endpoint,
String soapRequestFileName)
Send a SOAP request via a MEPClient without attachments and parameters.
|
protected org.apache.axiom.soap.SOAPEnvelope |
sendSOAPRequest(String endpoint,
String soapRequestFileName,
Map<String,String> parametersMap)
Deprecated.
|
protected org.apache.axiom.soap.SOAPEnvelope |
sendSOAPRequest(String endpoint,
String soapRequestFileName,
Map<String,String> parametersMap,
Map<String,String> attachmentMap)
Deprecated.
Please use
sendSOAPRequest(String, String, Map, Map, String, String, String)
instead. |
protected org.apache.axiom.soap.SOAPEnvelope |
sendSOAPRequest(String endpoint,
String soapRequestFileName,
Map<String,String> parametersMap,
Map<String,String> attachmentMap,
String action,
String xpathHeaderExp,
String xpathBodyExp)
Send a SOAP request via a MEPClient with attachments, taking a SOAP action.
|
protected org.apache.axiom.soap.SOAPEnvelope |
sendSOAPRequest(String endpoint,
String soapRequestFileName,
Map<String,String> parametersMap,
String action,
String xpathHeaderExp,
String xpathBodyExp)
Send a SOAP request via a MEPClient without attachments, taking a SOAP action.
|
protected RestResponse<org.apache.axiom.om.OMElement> |
sendXmlRestRequest(String endPoint,
String httpMethod,
Map<String,String> headersMap)
Overloaded method for
sendXmlRestRequest
, where the request file is not necessary. |
protected RestResponse<org.apache.axiom.om.OMElement> |
sendXmlRestRequest(String endPoint,
String httpMethod,
Map<String,String> headersMap,
String requestFileName)
Overloaded method for
sendXmlRestRequest
, where parameter replacement is not necessary. |
protected RestResponse<org.apache.axiom.om.OMElement> |
sendXmlRestRequest(String endPoint,
String httpMethod,
Map<String,String> headersMap,
String requestFileName,
Map<String,String> parametersMap)
Send HTTP request using
HttpURLConnection in XML format. |
protected RestResponse<org.apache.axiom.om.OMElement> |
sendXmlRestRequestHTTPS(String endPoint,
String httpMethod,
Map<String,String> headersMap,
String requestFileName,
Map<String,String> parametersMap)
Overloaded method for
sendXmlRestRequestHTTPS, where parameter replacement is not necessary. |
protected RestResponse<org.apache.axiom.om.OMElement> |
sendXmlRestRequestHTTPS(String endPoint,
String httpMethod,
Map<String,String> headersMap,
String requestFileName,
Map<String,String> parametersMap,
boolean isIgnoreHostVerification)
Send HTTP request using
HttpsURLConnection in XML format. |
void |
uploadSequences()
Method to upload sequences if required from a given path.
|
protected Object |
xPathEvaluate(org.apache.axiom.om.OMElement element,
String xPathExp,
Map<String,String> nameSpaceMap)
Execute xPath expression and return value as object.
|
addApi, addEndpoint, addInboundEndpoint, addLocalEntry, addMessageProcessor, addMessageStore, addPriorityExecutor, addProxyService, addScheduledTask, addSequence, addSequenceTemplate, applySecurity, deleteInboundEndpointFromName, deleteInboundEndpoints, deleteLibrary, deleteProxyService, deleteSequence, getAllImports, getApiInvocationURL, getBackEndServiceUrl, getESBResourceLocation, getMainSequenceURL, getProxyServiceURLHttp, getProxyServiceURLHttps, getSessionCookie, getSynapseAppData, getUserRole, init, init, isInboundUndeployed, isProxyDeployed, isProxyNotDeployed, isRunningOnStratos, loadESBConfigurationFromClasspath, loadSampleESBConfiguration, loadSampleESBConfigurationWithoutApply, login, reloadSessionCookie, replaceEndpoints, restoreSynapseConfig, setEndpoints, setEndpoints, updateConnectorStatus, updateESBConfiguration, updateESBRegistry, updateInboundEndpoint, uploadCapp, uploadConnectorprotected Properties connectorProperties
protected String proxyUrl
protected String pathToResourcesDirectory
protected static final int MULTIPART_TYPE_RELATED
protected void init(String connectorName) throws Exception
connectorName - String Name of the connector.Exceptionpublic void uploadSequences()
throws MalformedURLException,
org.wso2.carbon.sequences.stub.types.SequenceEditorException,
IOException,
XMLStreamException
XMLStreamExceptionIOExceptionorg.wso2.carbon.sequences.stub.types.SequenceEditorExceptionMalformedURLExceptionprotected RestResponse<org.json.JSONObject> sendJsonRestRequest(String endPoint, String httpMethod, Map<String,String> headersMap) throws IOException, org.json.JSONException
sendJsonRestRequest, where the request file is not necessary.endPoint - String End point URL.httpMethod - String HTTP method type (GET, POST, PUT etc.).headersMap - Maporg.json.JSONExceptionIOExceptionprotected RestResponse<org.apache.axiom.om.OMElement> sendXmlRestRequest(String endPoint, String httpMethod, Map<String,String> headersMap) throws IOException, XMLStreamException
sendXmlRestRequest
, where the request file is not necessary.endPoint - String End point URL.httpMethod - String HTTP method type (GET, POST, PUT etc.).headersMap - MapXMLStreamExceptionIOExceptionprotected RestResponse<org.json.JSONObject> sendJsonRestRequest(String endPoint, String httpMethod, Map<String,String> headersMap, String requestFileName) throws IOException, org.json.JSONException
sendJsonRestRequest, where parameter replacement is not necessary.endPoint - String End point URL.httpMethod - String HTTP method type (GET, POST, PUT etc.)headersMap - MaprequestFileName - String File name of the file which contains request body data.org.json.JSONExceptionIOExceptionprotected RestResponse<org.apache.axiom.om.OMElement> sendXmlRestRequest(String endPoint, String httpMethod, Map<String,String> headersMap, String requestFileName) throws IOException, XMLStreamException
sendXmlRestRequest
, where parameter replacement is not necessary.endPoint - String End point URL.httpMethod - String HTTP method type (GET, POST, PUT etc.)headersMap - MaprequestFileName - String File name of the file which contains request body data.XMLStreamExceptionIOExceptionprotected RestResponse<org.json.JSONObject> sendJsonRestRequestHTTPS(String endPoint, String httpMethod, Map<String,String> headersMap, String requestFileName, Map<String,String> parametersMap) throws IOException, org.json.JSONException
sendJsonRestRequestHTTPS, where parameter replacement is not necessary.endPoint - String End point URL.httpMethod - String HTTP method type (GET, POST, PUT etc.)headersMap - MaprequestFileName - String File name of the file which contains request body data.parametersMap - Maporg.json.JSONExceptionIOExceptionprotected RestResponse<org.apache.axiom.om.OMElement> sendXmlRestRequestHTTPS(String endPoint, String httpMethod, Map<String,String> headersMap, String requestFileName, Map<String,String> parametersMap) throws IOException, XMLStreamException
sendXmlRestRequestHTTPS, where parameter replacement is not necessary.endPoint - String End point URL.httpMethod - String HTTP method type (GET, POST, PUT etc.)headersMap - MaprequestFileName - String File name of the file which contains request body data.parametersMap - MapXMLStreamExceptionIOExceptionprotected RestResponse<org.json.JSONObject> sendJsonRestRequest(String endPoint, String httpMethod, Map<String,String> headersMap, String requestFileName, Map<String,String> parametersMap) throws IOException, org.json.JSONException
HttpURLConnection in JSON format.endPoint - String End point URL.httpMethod - String HTTP method type (GET, POST, PUT etc.)headersMap - MaprequestFileName - String File name of the file which contains request body data.parametersMap - Maporg.json.JSONExceptionIOExceptionprotected RestResponse<org.json.JSONObject> sendJsonRestRequestHTTPS(String endPoint, String httpMethod, Map<String,String> headersMap, String requestFileName, Map<String,String> parametersMap, boolean isIgnoreHostVerification) throws IOException, org.json.JSONException
HttpsURLConnection in JSON format.endPoint - String End point URL.httpMethod - String HTTP method type (GET, POST, PUT etc.)headersMap - MaprequestFileName - String File name of the file which contains request body data.parametersMap - MapisIgnoreHostVerification - boolean flag to ignore host verification.org.json.JSONExceptionIOExceptionprotected RestResponse<org.apache.axiom.om.OMElement> sendXmlRestRequest(String endPoint, String httpMethod, Map<String,String> headersMap, String requestFileName, Map<String,String> parametersMap) throws IOException, XMLStreamException
HttpURLConnection in XML format.endPoint - String End point URL.httpMethod - String HTTP method type (GET, POST, PUT etc.)headersMap - MaprequestFileName - String File name of the file which contains request body data.parametersMap - MapIOExceptionXMLStreamExceptionprotected RestResponse<org.apache.axiom.om.OMElement> sendXmlRestRequestHTTPS(String endPoint, String httpMethod, Map<String,String> headersMap, String requestFileName, Map<String,String> parametersMap, boolean isIgnoreHostVerification) throws IOException, XMLStreamException
HttpsURLConnection in XML format.endPoint - String End point URL.httpMethod - String HTTP method type (GET, POST, PUT etc.)headersMap - MaprequestFileName - String File name of the file which contains request body data.parametersMap - MapisIgnoreHostVerification - boolean flag to ignore host verification.IOExceptionXMLStreamExceptionprotected org.apache.axiom.soap.SOAPEnvelope sendSOAPRequest(String endpoint, String soapRequestFileName) throws XMLStreamException, IOException
endpoint - The URL of the endpoint to send the request to.soapRequestFileName - Path to the SOAP request fileXMLStreamException - Thrown on failure to build OM Element from the file's contents.IOException - Thrown on failure to send the request.@Deprecated protected org.apache.axiom.soap.SOAPEnvelope sendSOAPRequest(String endpoint, String soapRequestFileName, Map<String,String> parametersMap) throws XMLStreamException, IOException
sendSOAPRequest(String, String, Map, String, String, String)endpoint - The URL of the endpoint to send the request to.soapRequestFileName - Path to the SOAP request fileparametersMap - A map containing key value pairs to be parameterized in the request.XMLStreamException - Thrown on failure to build OM Element from the file's contents.IOException - Thrown on failure to send the request.@Deprecated protected org.apache.axiom.soap.SOAPEnvelope sendSOAPRequest(String endpoint, String soapRequestFileName, Map<String,String> parametersMap, Map<String,String> attachmentMap) throws XMLStreamException, IOException
sendSOAPRequest(String, String, Map, Map, String, String, String)
instead.endpoint - The URL of the end point to send the request to.soapRequestFileName - Path to the SOAP request fileparametersMap - A map containing key value pairs to be parameterized in the request.attachmentMap - A map containing content IDs and paths to files which needed to be added to the
SOAP request as attachments.XMLStreamException - Thrown on failure to build OM Element from the file's contents.IOException - Thrown on failure to send the request.protected org.apache.axiom.soap.SOAPEnvelope sendSOAPRequest(String endpoint, String soapRequestFileName, Map<String,String> parametersMap, String action, String xpathHeaderExp, String xpathBodyExp) throws XMLStreamException, IOException, org.jaxen.JaxenException
endpoint - The URL of the end point to send the request to.soapRequestFileName - Path to the SOAP request fileparametersMap - A map containing key value pairs to be parameterized in the request.action - String describing the SOAP action.xpathHeaderExp - XPath expression to evaluate the SOAP header.xpathBodyExp - XPath expression to evaluate the SOAP body.XMLStreamException - Thrown on failure to build OM Element from the file's contents.IOException - Thrown on failure to send the request.org.jaxen.JaxenException - Thrown on failure to evaluate XPath expression.protected org.apache.axiom.soap.SOAPEnvelope sendSOAPRequest(String endpoint, String soapRequestFileName, Map<String,String> parametersMap, Map<String,String> attachmentMap, String action, String xpathHeaderExp, String xpathBodyExp) throws XMLStreamException, IOException, org.jaxen.JaxenException
endpoint - The URL of the end point to send the request to.soapRequestFileName - Path to the SOAP request fileparametersMap - A map containing key value pairs to be parameterized in the request.attachmentMap - A map containing content IDs and paths to files which needed to be added to the
SOAP request as attachments.action - The SOAP Action as a string.xpathHeaderExp - XPath expression to evaluate the SOAP header.xpathBodyExp - XPath expression to evaluate the SOAP body.XMLStreamException - Thrown on failure to build OM Element from the file's contents.IOException - Thrown on failure to send the request.org.jaxen.JaxenException - Thrown on failure to evaluate XPath expression.protected InputStream processForInputStream(String endPoint, String httpMethod, Map<String,String> headersMap, String requestFileName, Map<String,String> parametersMap) throws IOException, org.json.JSONException
HttpURLConnection in JSON format to return InputStream.endPoint - String End point URL.httpMethod - String HTTP method type (GET, POST, PUT etc.)headersMap - MaprequestFileName - String File name of the file which contains request body data.parametersMap - MapIOExceptionXMLStreamExceptionorg.json.JSONExceptionprotected InputStream processForInputStreamHTTPS(String endPoint, String httpMethod, Map<String,String> headersMap, String requestFileName, Map<String,String> parametersMap) throws IOException, org.json.JSONException
processForInputStreamHTTPS, where parameter replacement is not necessary.endPoint - String End point URL.httpMethod - String HTTP method type (GET, POST, PUT etc.)headersMap - MaprequestFileName - String File name of the file which contains request body data.parametersMap - MapIOExceptionXMLStreamExceptionorg.json.JSONExceptionprotected InputStream processForInputStreamHTTPS(String endPoint, String httpMethod, Map<String,String> headersMap, String requestFileName, Map<String,String> parametersMap, boolean isIgnoreHostVerification) throws IOException, org.json.JSONException
HttpURLConnection in JSON format to return InputStream.endPoint - String End point URL.httpMethod - String HTTP method type (GET, POST, PUT etc.)headersMap - MaprequestFileName - String File name of the file which contains request body data.parametersMap - MapIOExceptionXMLStreamExceptionorg.json.JSONExceptionprotected Object loadObjectFromFile(String fileName) throws IOException
loadObjectFromFile without parameter
map.fileName - file name including path to the XML serialized file.IOException - if file path is null or empty as well as if there's any exception while reading the
XML file.loadObjectFromFile(String, Map)protected Object loadObjectFromFile(String fileName, Map<String,String> paramMap) throws IOException
%s(accessToken) in the XML file, those will be parsed and and replace with the values
specified in the Connection Properties resource file or the parameter map passed in to this method.
<?xml version="1.0" encoding="UTF-8"?>
<java class="java.beans.XMLDecoder">
<object class="test.base.Person">
<void property="address">
<object class="test.base.Address">
<void property="city">
<string>Test City</string>
</void>
<void property="country">
<string>Test Country</string>
</void>
<void property="street">
<string>Test street</string>
</void>
</object>
</void>
<void property="age">
<int>20</int>
</void>
<void property="name">
<string>Test Person Name</string>
</void>
</object>
</java>
fileName - file name including path to the XML serialized file.paramMap - map containing key value pairs where key being the parameter specified in the XML file
if parameter in XML is %s(accessToken), the key should be just
accessToken.IOException - if file path is null or empty as well as if there's any exception while reading the
XML file.protected void cleanup()
cleanup in class org.wso2.esb.integration.common.utils.ESBIntegrationTestpublic String getValueByExpression(String xPathExpression, org.apache.axiom.om.OMElement element) throws XMLStreamException, SAXException, IOException, ParserConfigurationException, XPathExpressionException
xPathExpression - the x path expressionelement - the elementXMLStreamException - the xML stream exceptionSAXException - the sAX exceptionIOException - Signals that an I/O exception has occurred.ParserConfigurationException - the parser configuration exceptionXPathExpressionException - the x path expression exceptionprotected Object xPathEvaluate(org.apache.axiom.om.OMElement element, String xPathExp, Map<String,String> nameSpaceMap) throws org.jaxen.JaxenException
element - OMElement which requires to evaluatexPathExp - String xPath expressionnameSpaceMap - name value pair containing namespace and prefixesorg.jaxen.JaxenException - when having an issue with xPath expressionprotected RestResponse<org.json.JSONObject> sendBinaryContentForJsonResponse(String endPoint, String httpMethod, Map<String,String> headersMap, String fileName) throws IOException, org.json.JSONException
HttpURLConnection in JSON format.endPoint - String End point URL.httpMethod - String HTTP method type (POST, PUT)headersMap - MapfileName - File name of the attachment to set as binary content.org.json.JSONExceptionIOExceptionprotected RestResponse<org.apache.axiom.om.OMElement> sendBinaryContentForXmlResponse(String endPoint, String httpMethod, Map<String,String> headersMap, String fileName) throws IOException, XMLStreamException
HttpURLConnection in XML format.endPoint - String End point URL.httpMethod - String HTTP method type (POST, PUT)headersMap - MapfileName - File name of the attachment to set as binary content.IOExceptionXMLStreamExceptionprotected RestResponse<org.json.JSONObject> sendBinaryContentForJsonResponseHTTPS(String endPoint, String httpMethod, Map<String,String> headersMap, String fileName) throws IOException, org.json.JSONException
HttpsURLConnection in JSON format.endPoint - String End point URL.httpMethod - String HTTP method type (POST, PUT)headersMap - MapfileName - File name of the attachment to set as binary content.org.json.JSONExceptionIOExceptionprotected RestResponse<org.apache.axiom.om.OMElement> sendBinaryContentForXmlResponseHTTPS(String endPoint, String httpMethod, Map<String,String> headersMap, String fileName) throws IOException, XMLStreamException
HttpsURLConnection in XML format.endPoint - String End point URL.httpMethod - String HTTPS method type (POST, PUT)headersMap - MapfileName - File name of the attachment to set as binary content.IOExceptionXMLStreamExceptionCopyright © 2017 WSO2. All rights reserved.