public org.apache.synapse.MessageContext newSynapseMc( org.apache.axis2.context.MessageContext msgCtx) { SynapseConfiguration configuration = synapseEnvironment.getSynapseConfiguration(); return new Axis2MessageContext(msgCtx, configuration, synapseEnvironment); }
private org.apache.synapse.MessageContext newSynapseMc( org.apache.axis2.context.MessageContext msgCtx) { SynapseConfiguration configuration = synapseEnvironment.getSynapseConfiguration(); return new Axis2MessageContext(msgCtx, configuration, synapseEnvironment); }
public org.apache.synapse.MessageContext newSynapseMc( org.apache.axis2.context.MessageContext msgCtx) { SynapseConfiguration configuration = synapseEnvironment.getSynapseConfiguration(); return new Axis2MessageContext(msgCtx, configuration, synapseEnvironment); }
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); } }
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 String getTenantDomain(SynapseEnvironment synapseEnvironment) { TenantInfoConfigurator configurator = synapseEnvironment.getTenantInfoConfigurator(); if (configurator != null) { org.apache.axis2.context.MessageContext axisMessageContext = new org.apache.axis2.context.MessageContext(); MessageContext messageContext = new Axis2MessageContext(axisMessageContext, this, synapseEnvironment); configurator.extractTenantInfo(messageContext); if (messageContext.getProperty("tenant.info.domain") != null) { return (String) messageContext.getProperty("tenant.info.domain"); } } return null; }
private MessageContext createMessageContext() { org.apache.axis2.context.MessageContext axisMessageContext = new org.apache.axis2.context.MessageContext(); MessageContext synapseMessageContext = new Axis2MessageContext(axisMessageContext, null, null); axisMessageContext.setProperty("OPEN_CONNNECTIONS_MAP", createMap()); return synapseMessageContext; }
public static MessageContext createLightweightSynapseMessageContext( String payload, SynapseConfiguration config) throws Exception { org.apache.axis2.context.MessageContext mc = new org.apache.axis2.context.MessageContext(); SynapseEnvironment env = new Axis2SynapseEnvironment(config); MessageContext synMc = new Axis2MessageContext(mc, config, env); SOAPEnvelope envelope = OMAbstractFactory.getSOAP11Factory().getDefaultEnvelope(); OMDocument omDoc = OMAbstractFactory.getSOAP11Factory().createOMDocument(); omDoc.addChild(envelope); envelope.getBody().addChild(createOMElement(payload)); synMc.setEnvelope(envelope); return synMc; }
/** * Testing whether jms producer is storing the message to the store * @throws Exception */ @Test public void testProducer() throws Exception{ JmsStore jmsStore = new JmsStore(); Map<String, Object> parameters = new HashMap<>(); parameters.put("java.naming.factory.initial", "org.apache.activemq.jndi.ActiveMQInitialContextFactory"); parameters.put("java.naming.provider.url", "tcp://127.0.0.1:61616"); jmsStore.setParameters(parameters); jmsStore.setName("TestJmsStore"); SynapseConfiguration synapseConfiguration = new SynapseConfiguration(); synapseConfiguration.addMessageStore("JMSStore", jmsStore); SynapseEnvironment synapseEnvironment = new Axis2SynapseEnvironment(synapseConfiguration); Axis2MessageContext axis2MessageContext = new Axis2MessageContext(new org.apache.axis2.context.MessageContext(), synapseConfiguration, synapseEnvironment); MessageContext messageContext = axis2MessageContext; SOAP11Factory factory = new SOAP11Factory(); SOAPEnvelope envelope = factory.createSOAPEnvelope(); messageContext.setEnvelope(envelope); jmsStore.init(synapseEnvironment); JmsProducer jmsProducer = (JmsProducer) jmsStore.getProducer(); boolean response = jmsProducer.storeMessage(messageContext); Assert.assertTrue("Message not stored!", response); }
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)); }
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)); }
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); }
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); }
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); }
/** * Test updating session with session id * * @throws Exception */ @Test public void testUpdateWithId() throws Exception { BasicConfigurator.configure(); SynapseConfiguration synapseConfiguration = new SynapseConfiguration(); AxisConfiguration axisConfiguration = synapseConfiguration.getAxisConfiguration(); ConfigurationContext cfgCtx = new ConfigurationContext(axisConfiguration); SynapseEnvironment synapseEnvironment = new Axis2SynapseEnvironment(cfgCtx, synapseConfiguration); Axis2MessageContext axis2MessageContext = new Axis2MessageContext(new org.apache.axis2.context.MessageContext(), synapseConfiguration, synapseEnvironment); MessageContext messageContext = axis2MessageContext; Endpoint endpoint = new AddressEndpoint(); List<Endpoint> endpoints = new ArrayList<>(); endpoints.add(endpoint); messageContext.setProperty(SynapseConstants.PROP_SAL_ENDPOINT_ENDPOINT_LIST, endpoints); SALSessions salSessions = SALSessions.getInstance(); salSessions.initialize(false, cfgCtx); salSessions.updateSession(messageContext, "testSession"); SessionInformation sessionInformation = salSessions.getSession("testSession"); Assert.assertEquals("Session not updated!", "testSession", sessionInformation.getId()); }
/** * Test updating session with session id and old session * * @throws Exception */ @Test public void testUpdateWithOldSession() throws Exception { BasicConfigurator.configure(); SynapseConfiguration synapseConfiguration = new SynapseConfiguration(); AxisConfiguration axisConfiguration = synapseConfiguration.getAxisConfiguration(); ConfigurationContext cfgCtx = new ConfigurationContext(axisConfiguration); SynapseEnvironment synapseEnvironment = new Axis2SynapseEnvironment(cfgCtx, synapseConfiguration); Axis2MessageContext axis2MessageContext = new Axis2MessageContext(new org.apache.axis2.context.MessageContext(), synapseConfiguration, synapseEnvironment); MessageContext messageContext = axis2MessageContext; Endpoint endpoint = new AddressEndpoint(); List<Endpoint> endpoints = new ArrayList<>(); endpoints.add(endpoint); SALSessions salSessions = SALSessions.getInstance(); salSessions.initialize(false, cfgCtx); SessionInformation oldSessionInfo = new SessionInformation("oldTestSession", endpoints, 30000); messageContext.setProperty(SynapseConstants.PROP_SAL_CURRENT_SESSION_INFORMATION, oldSessionInfo); salSessions.updateSession(messageContext, "testSession2"); SessionInformation sessionInformation = salSessions.getSession("testSession2"); Assert.assertEquals("Session not updated!", "testSession2", sessionInformation.getId()); }
public static MessageContext createSynapseMessageContext( String payload, SynapseConfiguration config) throws Exception { org.apache.axis2.context.MessageContext mc = new org.apache.axis2.context.MessageContext(); AxisConfiguration axisConfig = config.getAxisConfiguration(); if (axisConfig == null) { axisConfig = new AxisConfiguration(); config.setAxisConfiguration(axisConfig); } ConfigurationContext cfgCtx = new ConfigurationContext(axisConfig); SynapseEnvironment env = new Axis2SynapseEnvironment(cfgCtx, config); MessageContext synMc = new Axis2MessageContext(mc, config, env); SOAPEnvelope envelope = OMAbstractFactory.getSOAP11Factory().getDefaultEnvelope(); OMDocument omDoc = OMAbstractFactory.getSOAP11Factory().createOMDocument(); omDoc.addChild(envelope); envelope.getBody().addChild(createOMElement(payload)); synMc.setEnvelope(envelope); return synMc; }
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()); }
/** * Create a empty message context. * * @return A context with empty message * @throws AxisFault on an error creating a context */ private MessageContext createMessageContext() throws AxisFault { Axis2SynapseEnvironment synapseEnvironment = new Axis2SynapseEnvironment(new SynapseConfiguration()); org.apache.axis2.context.MessageContext axis2MC = new org.apache.axis2.context.MessageContext(); axis2MC.setConfigurationContext(new ConfigurationContext(new AxisConfiguration())); ServiceContext svcCtx = new ServiceContext(); OperationContext opCtx = new OperationContext(new InOutAxisOperation(), svcCtx); axis2MC.setServiceContext(svcCtx); axis2MC.setOperationContext(opCtx); MessageContext mc = new Axis2MessageContext(axis2MC, new SynapseConfiguration(), synapseEnvironment); mc.setMessageID(UIDGenerator.generateURNString()); mc.setEnvelope(OMAbstractFactory.getSOAP12Factory().createSOAPEnvelope()); mc.getEnvelope().addChild(OMAbstractFactory.getSOAP12Factory().createSOAPBody()); return mc; } }
/** * Create a empty message context * * @return A context with empty message * @throws AxisFault on an error creating a context */ private MessageContext createMessageContext() throws AxisFault { Axis2SynapseEnvironment synapseEnvironment = new Axis2SynapseEnvironment(new SynapseConfiguration()); org.apache.axis2.context.MessageContext axis2MC = new org.apache.axis2.context.MessageContext(); axis2MC.setConfigurationContext(new ConfigurationContext(new AxisConfiguration())); ServiceContext svcCtx = new ServiceContext(); OperationContext opCtx = new OperationContext(new InOutAxisOperation(), svcCtx); axis2MC.setServiceContext(svcCtx); axis2MC.setOperationContext(opCtx); MessageContext mc = new Axis2MessageContext(axis2MC, new SynapseConfiguration(), synapseEnvironment); mc.setMessageID(UIDGenerator.generateURNString()); mc.setEnvelope(OMAbstractFactory.getSOAP12Factory().createSOAPEnvelope()); mc.getEnvelope().addChild(OMAbstractFactory.getSOAP12Factory().createSOAPBody()); return mc; }