Java Code Examples for org.apache.axiom.soap.SOAPFactory#createSOAPBody()
The following examples show how to use
org.apache.axiom.soap.SOAPFactory#createSOAPBody() .
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: LoadbalanceFailoverClient.java From micro-integrator with Apache License 2.0 | 6 votes |
private SOAPEnvelope buildSoapEnvelope(String clientID, String value) { SOAPFactory soapFactory = OMAbstractFactory.getSOAP12Factory(); SOAPEnvelope envelope = soapFactory.createSOAPEnvelope(); SOAPHeader header = soapFactory.createSOAPHeader(); envelope.addChild(header); OMNamespace synNamespace = soapFactory. createOMNamespace("http://ws.apache.org/ns/synapse", "syn"); OMElement clientIDElement = soapFactory.createOMElement("ClientID", synNamespace); clientIDElement.setText(clientID); header.addChild(clientIDElement); SOAPBody body = soapFactory.createSOAPBody(); envelope.addChild(body); OMElement valueElement = soapFactory.createOMElement("Value", null); valueElement.setText(value); body.addChild(valueElement); return envelope; }
Example 2
Source File: LoadbalanceFailoverClient.java From micro-integrator with Apache License 2.0 | 6 votes |
private SOAPEnvelope buildSoapEnvelope(String clientID, String value) { SOAPFactory soapFactory = OMAbstractFactory.getSOAP12Factory(); SOAPEnvelope envelope = soapFactory.createSOAPEnvelope(); SOAPHeader header = soapFactory.createSOAPHeader(); envelope.addChild(header); OMNamespace synNamespace = soapFactory. createOMNamespace("http://ws.apache.org/ns/synapse", "syn"); OMElement clientIDElement = soapFactory.createOMElement("ClientID", synNamespace); clientIDElement.setText(clientID); header.addChild(clientIDElement); SOAPBody body = soapFactory.createSOAPBody(); envelope.addChild(body); OMElement valueElement = soapFactory.createOMElement("Value", null); valueElement.setText(value); body.addChild(valueElement); return envelope; }
Example 3
Source File: LoadbalanceFailoverClient.java From micro-integrator with Apache License 2.0 | 6 votes |
private SOAPEnvelope buildSoapEnvelope(String clientID, String value) { SOAPFactory soapFactory = OMAbstractFactory.getSOAP12Factory(); SOAPEnvelope envelope = soapFactory.createSOAPEnvelope(); SOAPHeader header = soapFactory.createSOAPHeader(); envelope.addChild(header); OMNamespace synNamespace = soapFactory. createOMNamespace("http://ws.apache.org/ns/synapse", "syn"); OMElement clientIDElement = soapFactory.createOMElement("ClientID", synNamespace); clientIDElement.setText(clientID); header.addChild(clientIDElement); SOAPBody body = soapFactory.createSOAPBody(); envelope.addChild(body); OMElement valueElement = soapFactory.createOMElement("Value", null); valueElement.setText(value); body.addChild(valueElement); return envelope; }
Example 4
Source File: LoadBalanceSessionFullClient.java From micro-integrator with Apache License 2.0 | 6 votes |
private SOAPEnvelope buildSoapEnvelope(String clientID, String value) { SOAPFactory soapFactory = OMAbstractFactory.getSOAP12Factory(); SOAPEnvelope envelope = soapFactory.createSOAPEnvelope(); SOAPHeader header = soapFactory.createSOAPHeader(); envelope.addChild(header); OMNamespace synNamespace = soapFactory.createOMNamespace("http://ws.apache.org/ns/synapse", "syn"); OMElement clientIDElement = soapFactory.createOMElement("ClientID", synNamespace); clientIDElement.setText(clientID); header.addChild(clientIDElement); SOAPBody body = soapFactory.createSOAPBody(); envelope.addChild(body); OMElement valueElement = soapFactory.createOMElement("Value", null); valueElement.setText(value); body.addChild(valueElement); return envelope; }
Example 5
Source File: RegularExpressionProtectorTest.java From carbon-apimgt with Apache License 2.0 | 6 votes |
/** * This is the test case to check the return value of the isContentAware method. */ @Test public void testIsContentAware() { log.info("Running the test case to check the return status of the isContentAware method."); SOAPFactory fac = OMAbstractFactory.getSOAP12Factory(); SOAPEnvelope env = fac.createSOAPEnvelope(); fac.createSOAPBody(env); env.getBody().addChild(fac.createOMElement("test", "Content aware", "MessageBody")); Mockito.when(((Axis2MessageContext) messageContext).getAxis2MessageContext()).thenReturn(axis2MsgContext); Mockito.doReturn(env).when(axis2MsgContext).getEnvelope(); Mockito.when(messageContext.getProperty(APIMgtGatewayConstants.ENABLED_CHECK_BODY)).thenReturn (String.valueOf(enabledStatus)); Mockito.when(messageContext.getProperty(APIMgtGatewayConstants.ENABLED_CHECK_HEADERS)).thenReturn (String.valueOf("false")); Mockito.when(messageContext.getProperty(APIMgtGatewayConstants.ENABLED_CHECK_PATHPARAM)).thenReturn (String.valueOf("false")); regularExpressionProtector = new RegularExpressionProtector(); regularExpressionProtector.mediate(messageContext); String enabledBuild = String.valueOf(regularExpressionProtector.isContentAware()); Assert.assertEquals(enabledStatus, enabledBuild); log.info("Successfully completed testIsContentAware test case."); }
Example 6
Source File: RegularExpressionProtectorTest.java From carbon-apimgt with Apache License 2.0 | 6 votes |
/** * This is the test case to validate the request body against sql injection attack. */ @Test public void testSqlInjectionInBody() throws AxisFault { log.info(" Running the test case to validate the request body from sql injection attacks."); SOAPFactory fac = OMAbstractFactory.getSOAP12Factory(); SOAPEnvelope env = fac.createSOAPEnvelope(); fac.createSOAPBody(env); env.getBody().addChild(fac.createOMElement("test", "Drop database", "testBody")); Mockito.when(messageContext.getProperty(APIMgtGatewayConstants.ENABLED_CHECK_BODY)).thenReturn (String.valueOf(enabledStatus)); Mockito.when(messageContext.getProperty(APIMgtGatewayConstants.ENABLED_CHECK_HEADERS)).thenReturn (String.valueOf("false")); Mockito.when(messageContext.getProperty(APIMgtGatewayConstants.ENABLED_CHECK_PATHPARAM)).thenReturn (String.valueOf("false")); Mockito.when(((Axis2MessageContext) messageContext).getAxis2MessageContext()).thenReturn(axis2MsgContext); Mockito.doReturn(env).when(axis2MsgContext).getEnvelope(); regularExpressionProtector = new RegularExpressionProtector(); regularExpressionProtector.mediate(messageContext); }
Example 7
Source File: LoadbalanceFailoverClient.java From product-ei with Apache License 2.0 | 6 votes |
private SOAPEnvelope buildSoapEnvelope(String clientID, String value) { SOAPFactory soapFactory = OMAbstractFactory.getSOAP12Factory(); SOAPEnvelope envelope = soapFactory.createSOAPEnvelope(); SOAPHeader header = soapFactory.createSOAPHeader(); envelope.addChild(header); OMNamespace synNamespace = soapFactory. createOMNamespace("http://ws.apache.org/ns/synapse", "syn"); OMElement clientIDElement = soapFactory.createOMElement("ClientID", synNamespace); clientIDElement.setText(clientID); header.addChild(clientIDElement); SOAPBody body = soapFactory.createSOAPBody(); envelope.addChild(body); OMElement valueElement = soapFactory.createOMElement("Value", null); valueElement.setText(value); body.addChild(valueElement); return envelope; }
Example 8
Source File: LoadbalanceFailoverClient.java From product-ei with Apache License 2.0 | 6 votes |
private SOAPEnvelope buildSoapEnvelope(String clientID, String value) { SOAPFactory soapFactory = OMAbstractFactory.getSOAP12Factory(); SOAPEnvelope envelope = soapFactory.createSOAPEnvelope(); SOAPHeader header = soapFactory.createSOAPHeader(); envelope.addChild(header); OMNamespace synNamespace = soapFactory. createOMNamespace("http://ws.apache.org/ns/synapse", "syn"); OMElement clientIDElement = soapFactory.createOMElement("ClientID", synNamespace); clientIDElement.setText(clientID); header.addChild(clientIDElement); SOAPBody body = soapFactory.createSOAPBody(); envelope.addChild(body); OMElement valueElement = soapFactory.createOMElement("Value", null); valueElement.setText(value); body.addChild(valueElement); return envelope; }
Example 9
Source File: LoadBalanceSessionFullClient.java From product-ei with Apache License 2.0 | 6 votes |
private SOAPEnvelope buildSoapEnvelope(String clientID, String value) { SOAPFactory soapFactory = OMAbstractFactory.getSOAP12Factory(); SOAPEnvelope envelope = soapFactory.createSOAPEnvelope(); SOAPHeader header = soapFactory.createSOAPHeader(); envelope.addChild(header); OMNamespace synNamespace = soapFactory.createOMNamespace( "http://ws.apache.org/ns/synapse", "syn"); OMElement clientIDElement = soapFactory.createOMElement("ClientID", synNamespace); clientIDElement.setText(clientID); header.addChild(clientIDElement); SOAPBody body = soapFactory.createSOAPBody(); envelope.addChild(body); OMElement valueElement = soapFactory.createOMElement("Value", null); valueElement.setText(value); body.addChild(valueElement); return envelope; }
Example 10
Source File: DataProcessAndPublishingAgentTest.java From carbon-apimgt with Apache License 2.0 | 5 votes |
@Test public void testContentAwareTierPresentAndContentLengthNotPresent() throws Exception { ThrottleProperties throttleProperties = new ThrottleProperties(); throttleProperties.setEnabled(true); DataProcessAndPublishingAgent dataProcessAndPublishingAgent = new DataProcessAndPublishingAgentWrapper (throttleProperties); AuthenticationContext authenticationContext = new AuthenticationContext(); authenticationContext.setIsContentAware(true); MessageContext messageContext = Mockito.mock(Axis2MessageContext.class); SOAPFactory fac = OMAbstractFactory.getSOAP12Factory(); SOAPEnvelope env = fac.createSOAPEnvelope(); fac.createSOAPBody(env); env.getBody().addChild(fac.createOMElement("test", "http://t", "t")); org.apache.axis2.context.MessageContext axis2MsgCntxt = Mockito.mock(org.apache.axis2.context.MessageContext .class); Mockito.when(messageContext.getEnvelope()).thenReturn(env); Mockito.when(((Axis2MessageContext) messageContext).getAxis2MessageContext()).thenReturn(axis2MsgCntxt); Mockito.when(messageContext.getProperty(RESTConstants.SYNAPSE_REST_API)).thenReturn("admin--PizzaShackAPI"); TreeMap headers = new TreeMap(); Mockito.when(axis2MsgCntxt.getProperty(org.apache.axis2.context.MessageContext.TRANSPORT_HEADERS)) .thenReturn(headers); VerbInfoDTO verbInfoDTO = new VerbInfoDTO(); verbInfoDTO.setContentAware(false); ArrayList<VerbInfoDTO> list = new ArrayList<VerbInfoDTO>(); list.add(verbInfoDTO); Mockito.when(messageContext.getProperty(APIConstants.VERB_INFO_DTO)).thenReturn(list); dataProcessAndPublishingAgent.setDataReference(applicationLevelThrottleKey, applicationLevelTier, apiLevelThrottleKey, null, subscriptionLevelThrottleKey, subscriptionLevelTier, resourceLevelThrottleKey, resourceLevelTier, authorizedUser, apiContext, apiVersion, appTenant, apiTenant, appId, messageContext, authenticationContext); dataProcessAndPublishingAgent.run(); }
Example 11
Source File: TestSchemaValidator.java From carbon-apimgt with Apache License 2.0 | 5 votes |
private void setMockedRequest(String httpMethod, String resourcePath, String xmlMessage) throws XMLStreamException, IOException { SOAPFactory fac = OMAbstractFactory.getSOAP12Factory(); SOAPEnvelope env = fac.createSOAPEnvelope(); fac.createSOAPBody(env); OMElement messageStore = AXIOMUtil.stringToOM(xmlMessage); env.getBody().addChild(messageStore); log.info(" Running the test case to validate the request content against the defined schemas."); String contentType = "application/json"; String ApiId = "admin-SwaggerPetstore-1.0.0"; File swaggerJsonFile = new File(Thread.currentThread().getContextClassLoader(). getResource("swaggerEntry/swagger.json").getFile()); String swaggerValue = FileUtils.readFileToString(swaggerJsonFile); Mockito.doReturn(env).when(messageContext).getEnvelope(); // Mockito.when() Mockito.when(((Axis2MessageContext) messageContext).getAxis2MessageContext()).thenReturn(axis2MsgContext); Mockito.when((String) axis2MsgContext.getProperty(APIMgtGatewayConstants.REST_CONTENT_TYPE)) .thenReturn(contentType); Mockito.when((String) axis2MsgContext.getProperty(APIMgtGatewayConstants.HTTP_REQUEST_METHOD)). thenReturn(httpMethod); Mockito.when(messageContext.getConfiguration()).thenReturn(synapseConfiguration); Mockito.when(synapseConfiguration.getLocalRegistry()).thenReturn(map); Mockito.when(map.get(uuid)).thenReturn(entry); Mockito.when(messageContext.getConfiguration()).thenReturn(synapseConfiguration); Mockito.when((String) messageContext.getProperty((APIMgtGatewayConstants.API_ELECTED_RESOURCE))). thenReturn(resourcePath); Mockito.when(synapseConfiguration.getLocalRegistry()).thenReturn(map); Mockito.when(map.get(ApiId)).thenReturn(entry); Mockito.when((String) entry.getValue()).thenReturn(swaggerValue); Mockito.when((String) messageContext.getProperty(APIMgtGatewayConstants.ELECTED_REQUEST_METHOD)). thenReturn(httpMethod); Mockito.when((String) axis2MsgContext.getProperty(APIMgtGatewayConstants.HTTP_REQUEST_METHOD)). thenReturn(httpMethod); Mockito.when((String) messageContext.getProperty(APIMgtGatewayConstants.OPEN_API_STRING)) .thenReturn(swaggerValue); }
Example 12
Source File: SOAPEventHandler.java From scipio-erp with Apache License 2.0 | 5 votes |
private void sendError(HttpServletResponse res, Object object, String serviceName) throws EventHandlerException { try { // setup the response res.setContentType("text/xml"); String xmlResults= SoapSerializer.serialize(object); XMLStreamReader xmlReader = XMLInputFactory.newInstance().createXMLStreamReader(new StringReader(xmlResults)); StAXOMBuilder resultsBuilder = (StAXOMBuilder) OMXMLBuilderFactory.createStAXOMBuilder(OMAbstractFactory.getOMFactory(), xmlReader); OMElement resultSer = resultsBuilder.getDocumentElement(); // create the response soap SOAPFactory factory = OMAbstractFactory.getSOAP11Factory(); SOAPEnvelope resEnv = factory.createSOAPEnvelope(); SOAPBody resBody = factory.createSOAPBody(); OMElement errMsg = factory.createOMElement(new QName((serviceName != null ? serviceName : "") + "Response")); errMsg.addChild(resultSer.getFirstElement()); resBody.addChild(errMsg); resEnv.addChild(resBody); // The declareDefaultNamespace method doesn't work see (https://issues.apache.org/jira/browse/AXIS2-3156) // so the following doesn't work: // resService.declareDefaultNamespace(ModelService.TNS); // instead, create the xmlns attribute directly: OMAttribute defaultNS = factory.createOMAttribute("xmlns", null, ModelService.TNS); errMsg.addAttribute(defaultNS); // log the response message if (Debug.verboseOn()) { try { Debug.logInfo("Response Message:\n" + resEnv + "\n", module); } catch (Throwable t) { } } resEnv.serialize(res.getOutputStream()); res.getOutputStream().flush(); } catch (Exception e) { throw new EventHandlerException(e.getMessage(), e); } }
Example 13
Source File: JMSReplySenderTest.java From micro-integrator with Apache License 2.0 | 5 votes |
private void setSOAPEnvelopWithoutTypeByteMessageBody(MessageContext messageContext, BytesMessage message) throws AxisFault { SOAPFactory fac = OMAbstractFactory.getSOAP11Factory(); SOAPEnvelope env = fac.createSOAPEnvelope(); fac.createSOAPBody(env); OMElement firstEle = fac.createOMElement(new QName("Binary")); DataHandler dataHandler = new DataHandler(new BytesMessageDataSource(message)); OMText textEle = fac.createOMText(dataHandler, true); firstEle.addChild(textEle); env.getBody().addChild(firstEle); messageContext.setEnvelope(env); }
Example 14
Source File: JMSReplySenderTest.java From micro-integrator with Apache License 2.0 | 5 votes |
private void setSOAPEnvelopWithoutTypeTextMessageBody(MessageContext messageContext) throws AxisFault, XMLStreamException { SOAPFactory fac = OMAbstractFactory.getSOAP11Factory(); SOAPEnvelope env = fac.createSOAPEnvelope(); fac.createSOAPBody(env); OMElement mapElement1 = fac.createOMElement(new QName("Price")); mapElement1.setText("10"); OMElement firstEle = fac.createOMElement(new QName("First")); firstEle.addChild(mapElement1); env.getBody().addChild(firstEle); messageContext.setEnvelope(env); }
Example 15
Source File: JMSReplySenderTest.java From micro-integrator with Apache License 2.0 | 5 votes |
private void setSOAPEnvelopWithMapMessageBody(MessageContext messageContext) throws AxisFault, XMLStreamException { SOAPFactory fac = OMAbstractFactory.getSOAP11Factory(); SOAPEnvelope env = fac.createSOAPEnvelope(); fac.createSOAPBody(env); OMElement mapElement1 = fac.createOMElement(new QName("Price")); mapElement1.setText("10"); OMElement mapElement2 = fac.createOMElement(new QName("Name")); mapElement2.setText("Queue"); OMElement firstEle = fac.createOMElement(JMSConstants.JMS_MAP_QNAME); firstEle.addChild(mapElement1); firstEle.addChild(mapElement2); env.getBody().addChild(firstEle); messageContext.setEnvelope(env); }
Example 16
Source File: JMSReplySenderTest.java From micro-integrator with Apache License 2.0 | 5 votes |
private void setSOAPEnvelopWithBinaryBody(MessageContext messageContext, BytesMessage message) throws AxisFault { SOAPFactory fac = OMAbstractFactory.getSOAP11Factory(); SOAPEnvelope env = fac.createSOAPEnvelope(); fac.createSOAPBody(env); OMElement firstEle = fac.createOMElement(BaseConstants.DEFAULT_BINARY_WRAPPER); DataHandler dataHandler = new DataHandler(new BytesMessageDataSource(message)); OMText textEle = fac.createOMText(dataHandler, true); firstEle.addChild(textEle); env.getBody().addChild(firstEle); messageContext.setEnvelope(env); }
Example 17
Source File: JMSReplySenderTest.java From micro-integrator with Apache License 2.0 | 5 votes |
private void setSOAPEnvelopWithTextBody(MessageContext messageContext) throws AxisFault { SOAPFactory fac = OMAbstractFactory.getSOAP11Factory(); SOAPEnvelope env = fac.createSOAPEnvelope(); fac.createSOAPBody(env); OMElement firstEle = fac.createOMElement(BaseConstants.DEFAULT_TEXT_WRAPPER); firstEle.setText("TestSendBack"); env.getBody().addChild(firstEle); messageContext.setEnvelope(env); }
Example 18
Source File: SOAPEventHandler.java From scipio-erp with Apache License 2.0 | 4 votes |
private void createAndSendSOAPResponse(Map<String, Object> serviceResults, String serviceName, HttpServletResponse response) throws EventHandlerException { try { // setup the response if (Debug.verboseOn()) Debug.logVerbose("[EventHandler] : Setting up response message", module); String xmlResults = SoapSerializer.serialize(serviceResults); //Debug.logInfo("xmlResults ==================" + xmlResults, module); XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(new StringReader(xmlResults)); StAXOMBuilder resultsBuilder = (StAXOMBuilder) OMXMLBuilderFactory.createStAXOMBuilder(OMAbstractFactory.getOMFactory(), reader); OMElement resultSer = resultsBuilder.getDocumentElement(); // create the response soap SOAPFactory factory = OMAbstractFactory.getSOAP11Factory(); SOAPEnvelope resEnv = factory.createSOAPEnvelope(); SOAPBody resBody = factory.createSOAPBody(); OMElement resService = factory.createOMElement(new QName(serviceName + "Response")); resService.addChild(resultSer.getFirstElement()); resBody.addChild(resService); resEnv.addChild(resBody); // The declareDefaultNamespace method doesn't work see (https://issues.apache.org/jira/browse/AXIS2-3156) // so the following doesn't work: // resService.declareDefaultNamespace(ModelService.TNS); // instead, create the xmlns attribute directly: OMAttribute defaultNS = factory.createOMAttribute("xmlns", null, ModelService.TNS); resService.addAttribute(defaultNS); // log the response message if (Debug.verboseOn()) { try { Debug.logInfo("Response Message:\n" + resEnv + "\n", module); } catch (Throwable t) { } } resEnv.serialize(response.getOutputStream()); response.getOutputStream().flush(); } catch (Exception e) { Debug.logError(e, module); throw new EventHandlerException(e.getMessage(), e); } }
Example 19
Source File: APIMgtResponseHandlerTest.java From carbon-apimgt with Apache License 2.0 | 4 votes |
@Test public void mediateWithChunkEnable() throws Exception { APIMgtUsageDataPublisher apiMgtUsageDataPublisher = Mockito.mock(APIMgtUsageDataPublisher.class); APIManagerAnalyticsConfiguration apiManagerAnalyticsConfiguration = Mockito.mock (APIManagerAnalyticsConfiguration.class); Mockito.when(apiManagerAnalyticsConfiguration.isBuildMsg()).thenReturn(true); APIMgtResponseHandler apiMgtResponseHandler = new APIMgtResponseHandlerWrapper(apiMgtUsageDataPublisher, true, false, apiManagerAnalyticsConfiguration); MessageContext messageContext = Mockito.mock(Axis2MessageContext.class); org.apache.axis2.context.MessageContext axis2MsgCntxt = Mockito.mock(org.apache.axis2.context.MessageContext .class); Mockito.when(((Axis2MessageContext) messageContext).getAxis2MessageContext()).thenReturn(axis2MsgCntxt); Mockito.when(axis2MsgCntxt.getProperty(SynapseConstants.HTTP_SC)).thenReturn(200); Map headers = new HashMap(); Mockito.when(axis2MsgCntxt.getProperty(org.apache.axis2.context.MessageContext.TRANSPORT_HEADERS)).thenReturn (headers); SOAPFactory fac = OMAbstractFactory.getSOAP12Factory(); SOAPEnvelope env = fac.createSOAPEnvelope(); fac.createSOAPBody(env); env.getBody().addChild(fac.createOMElement("test", "http://t", "t")); Mockito.when(messageContext.getEnvelope()).thenReturn(env); Mockito.when(messageContext.getProperty("REST_FULL_REQUEST_PATH")).thenReturn("/abc/1.0.0/a"); Mockito.when(messageContext.getProperty(APIMgtGatewayConstants.REQUEST_START_TIME)).thenReturn("12345678"); Mockito.when(messageContext.getProperty(APIMgtGatewayConstants.CONSUMER_KEY)).thenReturn("abc-def-ghi"); Mockito.when(messageContext.getProperty(APIMgtGatewayConstants.CONTEXT)).thenReturn("/abc/1.0.0"); Mockito.when(messageContext.getProperty(APIMgtGatewayConstants.API_VERSION)).thenReturn("1.0.0"); Mockito.when(messageContext.getProperty(APIMgtGatewayConstants.API)).thenReturn("api1"); Mockito.when(messageContext.getProperty(APIMgtGatewayConstants.RESOURCE)).thenReturn("/a"); Mockito.when(messageContext.getProperty(APIMgtGatewayConstants.HTTP_METHOD)).thenReturn("GET"); Mockito.when(messageContext.getProperty(APIMgtGatewayConstants.VERSION)).thenReturn("1.0.0"); Mockito.when((messageContext.getProperty(SynapseConstants.ERROR_CODE))).thenReturn("404"); Mockito.when(messageContext.getProperty(SynapseConstants.ERROR_MESSAGE)).thenReturn("not found"); Mockito.when(messageContext.getProperty(APIMgtGatewayConstants.USER_ID)).thenReturn("admin"); Mockito.when(messageContext.getProperty(APIMgtGatewayConstants.HOST_NAME)).thenReturn("127.0.0.1"); Mockito.when(messageContext.getProperty(APIMgtGatewayConstants.API_PUBLISHER)).thenReturn("admin"); Mockito.when(messageContext.getProperty(APIMgtGatewayConstants.APPLICATION_NAME)).thenReturn("App1"); Mockito.when(messageContext.getProperty(APIMgtGatewayConstants.APPLICATION_ID)).thenReturn("1"); Mockito.when(messageContext.getProperty(SynapseConstants.TRANSPORT_IN_NAME)).thenReturn("https"); Mockito.when(messageContext.getProperty(RESTConstants.SYNAPSE_REST_API)).thenReturn("admin--api1-1.0.0"); Mockito.when(messageContext.getProperty(RESTConstants.REST_URL_PREFIX)).thenReturn("https://localhost"); apiMgtResponseHandler.mediate(messageContext); }