/** * Returns the Axis2 message context from the Synapse message context. * @param messageContext * @return Axis2 message context. */ @SuppressWarnings("unused") private org.apache.axis2.context.MessageContext getAxis2MessageContext(MessageContext messageContext){ return ((Axis2MessageContext) messageContext).getAxis2MessageContext(); }
public org.apache.synapse.MessageContext newSynapseMc( org.apache.axis2.context.MessageContext msgCtx) { SynapseConfiguration configuration = synapseEnvironment.getSynapseConfiguration(); return new Axis2MessageContext(msgCtx, configuration, synapseEnvironment); }
/** * Return the service level Log for this message context or null * @return the service level Log for the message */ public Log getServiceLog() { if (serviceLog != null) { return serviceLog; } else { String serviceName = (String) getProperty(SynapseConstants.PROXY_SERVICE); if (serviceName != null && synCfg.getProxyService(serviceName) != null) { serviceLog = LogFactory.getLog( SynapseConstants.SERVICE_LOGGER_PREFIX + serviceName); return serviceLog; } else { serviceLog = LogFactory.getLog( SynapseConstants.SERVICE_LOGGER_PREFIX.substring(0, SynapseConstants.SERVICE_LOGGER_PREFIX.length()-1)); return serviceLog; } } }
protected void setUp() throws Exception { super.setUp(); SynapseConfiguration synCfg = new SynapseConfiguration(); AxisConfiguration config = new AxisConfiguration(); testCtx = new Axis2MessageContext(new org.apache.axis2.context.MessageContext(), synCfg, new Axis2SynapseEnvironment(new ConfigurationContext(config), synCfg)); ((Axis2MessageContext) testCtx).getAxis2MessageContext().setConfigurationContext(new ConfigurationContext(config)); }
/** * Test collectAggregatedParents method by validating aggregated parent IDs. */ @Test public void testCollectAggregatedParents() { PowerMockito.mockStatic(RuntimeStatisticCollector.class); PowerMockito.when(RuntimeStatisticCollector.isStatisticsEnabled()).thenReturn(true); PowerMockito.when(RuntimeStatisticCollector.shouldReportStatistic(any(MessageContext.class))).thenReturn(true); messageContextOld.setProperty(StatisticsConstants.MEDIATION_FLOW_STATISTICS_PARENT_INDEX, 1); messageContextNew.setProperty(StatisticsConstants.MEDIATION_FLOW_STATISTICS_PARENT_INDEX, 2); List<MessageContext> messageList = new ArrayList<>(); messageList.add(messageContextOld); StatisticDataCollectionHelper.collectAggregatedParents(messageList, messageContextNew); List<Integer> parentList = Arrays.asList(1); Assert.assertEquals("should return all the parent indices in message list", parentList, messageContextNew .getProperty(StatisticsConstants.MEDIATION_FLOW_STATISTICS_PARENT_LIST)); }
/** * Test CollectPayload for valid message context. * * @throws Exception */ @Test public void testCollectPayload() throws Exception { String payload = TracingDataCollectionHelper.collectPayload(messageContext); Assert.assertEquals("should return envelope for a valid messageContext", messageContext.getEnvelope().toString(), payload); }
protected void setUp() throws Exception { super.setUp(); SynapseConfiguration synCfg = new SynapseConfiguration(); AxisConfiguration config = new AxisConfiguration(); testCtx = new Axis2MessageContext(new org.apache.axis2.context.MessageContext(), synCfg, new Axis2SynapseEnvironment(new ConfigurationContext(config), synCfg)); ((Axis2MessageContext) testCtx).getAxis2MessageContext().setConfigurationContext(new ConfigurationContext(config)); }
/** * Test getParentFlowPosition method for default and inserted parent ids. */ @Test public void testGetParentFlowPosition() { int position = StatisticDataCollectionHelper.getParentFlowPosition(messageContext, 0); Assert.assertNotNull("should set a new parent index property", messageContext.getProperty(StatisticsConstants.MEDIATION_FLOW_STATISTICS_PARENT_INDEX)); Assert.assertEquals("should return the default parent index", StatisticsConstants.DEFAULT_PARENT_INDEX, position); messageContext.setProperty(StatisticsConstants.MEDIATION_FLOW_STATISTICS_PARENT_INDEX, 1); Assert.assertEquals("should return the inserted value to the parent index property", 1, StatisticDataCollectionHelper.getParentFlowPosition(messageContext, 0)); }
protected org.apache.axis2.context.MessageContext getAxis2MessageContext(Axis2MessageContext messageContext) { return messageContext. getAxis2MessageContext(); }
protected void setUp() throws Exception { super.setUp(); SynapseConfiguration synCfg = new SynapseConfiguration(); AxisConfiguration config = new AxisConfiguration(); testCtx = new Axis2MessageContext(new org.apache.axis2.context.MessageContext(), synCfg, new Axis2SynapseEnvironment(new ConfigurationContext(config), synCfg)); ((Axis2MessageContext) testCtx).getAxis2MessageContext().setConfigurationContext(new ConfigurationContext(config)); SOAPEnvelope envelope = OMAbstractFactory.getSOAP11Factory().getDefaultEnvelope(); envelope.getBody().addChild(createOMElement("<describeSObjects/>")); testCtx.setEnvelope(envelope); }
private org.apache.synapse.MessageContext newSynapseMc( org.apache.axis2.context.MessageContext msgCtx) { SynapseConfiguration configuration = synapseEnvironment.getSynapseConfiguration(); return new Axis2MessageContext(msgCtx, configuration, synapseEnvironment); }
/** * Test getFlowPosition method for start and increment. */ @Test public void testGetFlowPosition() { int currentIndex = StatisticDataCollectionHelper.getFlowPosition(messageContext); Assert.assertEquals("index should start from 0", 0, currentIndex); Assert.assertNotNull("indexing object must be set by the method", messageContext.getProperty (StatisticsConstants.MEDIATION_FLOW_STATISTICS_INDEXING_OBJECT)); currentIndex = StatisticDataCollectionHelper.getFlowPosition(messageContext); Assert.assertEquals("index should be incremented to 1", 1, currentIndex); }
private Map getTransportHeaderMap(MessageContext synCtx) { org.apache.axis2.context.MessageContext axis2MessageContext = ((Axis2MessageContext) synCtx).getAxis2MessageContext(); Object o = axis2MessageContext.getProperty("TRANSPORT_HEADERS"); if (o != null && o instanceof Map) { return (Map) o; } return null; }
protected void setUp() throws Exception { super.setUp(); SynapseConfiguration synCfg = new SynapseConfiguration(); AxisConfiguration config = new AxisConfiguration(); testCtx = new Axis2MessageContext(new org.apache.axis2.context.MessageContext(), synCfg, new Axis2SynapseEnvironment(new ConfigurationContext(config), synCfg)); ((Axis2MessageContext) testCtx).getAxis2MessageContext().setConfigurationContext(new ConfigurationContext(config)); SOAPEnvelope envelope = OMAbstractFactory.getSOAP11Factory().getDefaultEnvelope(); envelope.getBody().addChild(createOMElement("<sendEmail/>")); testCtx.setEnvelope(envelope); }
public org.apache.synapse.MessageContext newSynapseMc( org.apache.axis2.context.MessageContext msgCtx) { SynapseConfiguration configuration = synapseEnvironment.getSynapseConfiguration(); return new Axis2MessageContext(msgCtx, configuration, synapseEnvironment); }
private Map getTransportHeaderMap(MessageContext synCtx) { org.apache.axis2.context.MessageContext axis2MessageContext = ((Axis2MessageContext) synCtx).getAxis2MessageContext(); Object o = axis2MessageContext.getProperty(org.apache.axis2.context.MessageContext.TRANSPORT_HEADERS); if (o != null && o instanceof Map) { return (Map) o; } return null; } }
protected void setUp() throws Exception { super.setUp(); SynapseConfiguration synCfg = new SynapseConfiguration(); AxisConfiguration config = new AxisConfiguration(); testCtx = new Axis2MessageContext(new org.apache.axis2.context.MessageContext(), synCfg, new Axis2SynapseEnvironment(new ConfigurationContext(config), synCfg)); ((Axis2MessageContext) testCtx).getAxis2MessageContext().setConfigurationContext(new ConfigurationContext(config)); SOAPEnvelope envelope = OMAbstractFactory.getSOAP11Factory().getDefaultEnvelope(); envelope.getBody().addChild(createOMElement("<queryResponse>" + "<result>" + "<done>false</done><queryLocator>01g9000000MVzggAAD-200</queryLocator>" + "<size>370</size>" + "</result>" + "</queryResponse>")); testCtx.setEnvelope(envelope); }
public static MessageContext getSynapseMessageContext( org.apache.axis2.context.MessageContext axisMsgCtx) throws AxisFault { if (synCfg == null || synEnv == null) { String msg = "Synapse environment has not initialized properly.."; log.fatal(msg); throw new SynapseException(msg); } // we should try to get the synapse configuration and environment from // the axis2 configuration. SynapseEnvironment synapseEnvironment = getSynapseEnvironment(axisMsgCtx); SynapseConfiguration synapseConfiguration = getSynapseConfiguration(axisMsgCtx); if (synapseConfiguration != null && synapseEnvironment != null) { return new Axis2MessageContext(axisMsgCtx, synapseConfiguration, synapseEnvironment); } else { return new Axis2MessageContext(axisMsgCtx, synCfg, synEnv); } }
private Map getTransportHeaderMap(MessageContext synCtx) { org.apache.axis2.context.MessageContext axis2MessageContext = ((Axis2MessageContext) synCtx).getAxis2MessageContext(); Object o = axis2MessageContext.getProperty(org.apache.axis2.context.MessageContext.TRANSPORT_HEADERS); if (o != null && o instanceof Map) { return (Map) o; } return null; }
protected void setUp() throws Exception { super.setUp(); SynapseConfiguration synCfg = new SynapseConfiguration(); AxisConfiguration config = new AxisConfiguration(); testCtx = new Axis2MessageContext(new org.apache.axis2.context.MessageContext(), synCfg, new Axis2SynapseEnvironment(new ConfigurationContext(config), synCfg)); ((Axis2MessageContext)testCtx).getAxis2MessageContext().setConfigurationContext(new ConfigurationContext(config)); SOAPEnvelope envelope = OMAbstractFactory.getSOAP11Factory().getDefaultEnvelope(); envelope.getBody().addChild(createOMElement("<original>test-split-context</original>")); testCtx.setEnvelope(envelope); testCtx.setSoapAction("urn:test"); SequenceMediator seqMed = new SequenceMediator(); helperMediator = new SplitTestHelperMediator(); helperMediator.init(testCtx.getEnvironment()); seqMed.addChild(helperMediator); testCtx.getConfiguration().addSequence("seqRef", seqMed); testCtx.getConfiguration().addSequence("main", new SequenceMediator()); testCtx.getConfiguration().addSequence("fault", new SequenceMediator()); }