@Override /** * Figure out the real endpoint we proxy for, and make sure its initialized */ public void init(SynapseEnvironment synapseEnvironment) { ConfigurationContext cc = ((Axis2SynapseEnvironment) synapseEnvironment).getAxis2ConfigurationContext(); reLoadAndInitEndpoint(cc); }
@BeforeClass public static void init() throws NoSuchFieldException { rabbitMQStore = new RabbitMQStore(); //Accessing private variable using reflection connectionFactory = RabbitMQStore.class.getDeclaredField("connectionFactory"); connectionFactory.setAccessible(true); //Setting parameters of the RabbitMQStore Map<String, Object> temp = new HashMap<>(); temp.put(RabbitMQStore.USERNAME, USERNAME); temp.put(RabbitMQStore.PASSWORD, PASSWORD); temp.put(RabbitMQStore.HOST_NAME, HOST); temp.put(RabbitMQStore.HOST_PORT, PORT); temp.put(RabbitMQStore.VIRTUAL_HOST, VIRTUAL_HOST); temp.put(RabbitMQStore.QUEUE_NAME, QUEUE); rabbitMQStore.setParameters(temp); AxisConfiguration axisConfiguration = new AxisConfiguration(); configurationContext = new ConfigurationContext(axisConfiguration); SynapseConfiguration synapseConfiguration = new SynapseConfiguration(); Axis2SynapseEnvironment env = new Axis2SynapseEnvironment(configurationContext, synapseConfiguration); rabbitMQStore.init(env); }
public static void setupTestEnvironment() { synConfig = new SynapseConfiguration(); synEnv = new Axis2SynapseEnvironment(synConfig); synEnv.setDebugEnabled(true); dm = SynapseDebugManager.getInstance(); dm.init(synConfig, null, synEnv, false); synEnv.setDebugEnabled(false); synEnv.setSynapseDebugManager(dm); }
if (synCtx.isResponse()) { if (endpoint != null) { if (isTransportSwitching(synCtx, endpoint)) { buildMessage(synCtx); ProxyService proxyService = synapseConfig.getProxyService(proxyName); if (proxyService.isModuleEngaged()) { buildMessage(synCtx); if (endpoint == null || isTransportSwitching(synCtx, endpoint)) { buildMessage(synCtx);
if (!invokeHandlers(synCtx)) { return false; return mediateFromContinuationStateStack(synCtx); proxyService.registerFaultHandler(synCtx); Mediator outSequence = getProxyOutSequence(synCtx, proxyService); if (receivingSequence != null) { if (log.isDebugEnabled()) {
/** * this method is to set the debug mode is enabled and initializes the debug manager * debug mode is enabled is set for each time Synapse configuration is changed and Synapse * environment initializes */ public void setSeverDebugMode(ServerContextInformation contextInformation) { if (contextInformation.isServerDebugModeEnabled()) { setDebugEnabled(true); synapseDebugManager = contextInformation.getSynapseDebugManager(); contextInformation.getSynapseDebugManager() .init(synapseConfig, contextInformation.getSynapseDebugInterface(), this, true); } }
/** * Test on Sending messages to different members using RecipientListEndpoint */ @Test public void testSendMessageToMembers() throws Exception { //perform init Axis2SynapseEnvironment synapseEnvironment = getMockedSynapseEnvironment(); RecipientListEndpoint recipientListEndpoint = new RecipientListEndpoint(); recipientListEndpoint.init(synapseEnvironment); Mockito.when(synapseEnvironment.createMessageContext()).thenReturn(createMessageContext()); //set members Member member1 = new Member("localhost", 9000); Member member2 = new Member("localhost", 9001); ArrayList<Member> members = new ArrayList<>(2); members.add(member1); members.add(member2); recipientListEndpoint.setMembers(members); //test send message String samplePayload = "<test>value</test>"; Axis2MessageContext messageContext = getMessageContext(samplePayload); //message will be sent to EP using this env (which is mocked and do nothing) messageContext.setEnvironment(synapseEnvironment); messageContext.setTo(new EndpointReference("http://localhost:9000/services/SimpleStockQuoteService")); recipientListEndpoint.sendMessage(messageContext); }
Mediator outSequence = getProxyOutSequence(synCtx, proxyService); if (receivingSequence != null) { if (log.isDebugEnabled()) {
dm.processDebugCommand(debug_command); MessageContext synCtx = TestUtils.getTestContext("<empty/>"); synEnv.setDebugEnabled(false); temp.mediate(synCtx); assertTrue("T1.T2.T3".equals(result.toString()));
if (isTransportSwitching(synCtx, endpoint)) { buildMessage(synCtx); if (serviceModuleEngaged || isTransportSwitching(synCtx, null)) { buildMessage(synCtx); buildMessage(synCtx); if (endpoint == null || isTransportSwitching(synCtx, endpoint)) { buildMessage(synCtx);
/** * Create a RecipientListEndpoint by config and test sending a message * @throws Exception on an issue sending out the message */ @Test public void testSendToEndpointList() throws Exception { OMElement omBody = AXIOMUtil.stringToOM("<endpoint><recipientlist xmlns=\"http://ws.apache.org/ns/synapse\">\n" + " <endpoint xmlns=\"http://ws.apache.org/ns/synapse\">\n" + " <address uri=\"http://localhost:9000/services/SimpleStockQuoteService\"/>\n" + " </endpoint>\n" + " <endpoint xmlns=\"http://ws.apache.org/ns/synapse\">\n" + " <address uri=\"http://localhost:9001/services/SimpleStockQuoteService\"/>\n" + " </endpoint>\n" + "</recipientlist></endpoint>"); RecipientListEndpoint recipientListEndpoint = (RecipientListEndpoint) EndpointFactory. getEndpointFromElement(omBody,true, null); Axis2SynapseEnvironment synapseEnvironment = getMockedSynapseEnvironment(); Mockito.when(synapseEnvironment.createMessageContext()).thenReturn(createMessageContext()); //test send message String samplePayload = "<test><a>WSO2</a></test>"; Axis2MessageContext messageContext = getMessageContext(samplePayload); //message will be sent to EP using this env (which is mocked and do nothing) messageContext.setEnvironment(synapseEnvironment); recipientListEndpoint.init(synapseEnvironment); recipientListEndpoint.sendMessage(messageContext); }
@Override /** * Figure out the real endpoint we proxy for, and make sure its initialized */ public void init(SynapseEnvironment synapseEnvironment) { ConfigurationContext cc = ((Axis2SynapseEnvironment) synapseEnvironment).getAxis2ConfigurationContext(); reLoadAndInitEndpoint(cc); }
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)); }
"\"sequence-type\": \"named\",\"mediator-position\": \"1\"}}"; dm.processDebugCommand(debug_command); synEnv.setDebugEnabled(true); MessageContextCreatorForAxis2.setSynConfig(synConfig); MessageContextCreatorForAxis2.setSynEnv(synEnv); seq.mediate(synCtx); assertTrue("T3".equals(result.toString())); synEnv.setDebugEnabled(false);
/** * Test on Sending messages to a dynamic EP based on an expression * * @throws Exception on test failure */ @Test public void testSendToDynamicMembers() throws Exception { //perform init Axis2SynapseEnvironment synapseEnvironment = getMockedSynapseEnvironment(); RecipientListEndpoint recipientListEndpoint = new RecipientListEndpoint(2); recipientListEndpoint.init(synapseEnvironment); Mockito.when(synapseEnvironment.createMessageContext()).thenReturn(createMessageContext()); //add dynamic EPs Value dynamicEPs = new Value(new SynapseXPath("//endpoints")); recipientListEndpoint.setDynamicEnpointSet(dynamicEPs); //test send message String samplePayload = "<test><endpoints>http://localhost:9000/services/SimpleStockQuoteService," + "http://localhost:9001/services/SimpleStockQuoteService" + "</endpoints><body>wso2</body></test>"; Axis2MessageContext messageContext = getMessageContext(samplePayload); //message will be sent to EP using this env (which is mocked and do nothing) messageContext.setEnvironment(synapseEnvironment); //messageContext.setTo(new EndpointReference("http://localhost:9000/services/SimpleStockQuoteService")); recipientListEndpoint.sendMessage(messageContext); }
public org.apache.axis2.context.MessageContext newAxis2Mc() { return ((Axis2SynapseEnvironment) synapseEnvironment) .getAxis2ConfigurationContext().createMessageContext(); }
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)); }
"\"template\":{\"template-key\":\"test_sequence_template_5\",\"mediator-position\": \"1\"}}"; dm.processDebugCommand(debug_command); synEnv.setDebugEnabled(true); MessageContextCreatorForAxis2.setSynConfig(synConfig); MessageContextCreatorForAxis2.setSynEnv(synEnv); temp.mediate(synCtx); assertTrue("T3".equals(result.toString())); synEnv.setDebugEnabled(false);
public org.apache.axis2.context.MessageContext newAxis2Mc() { return ((Axis2SynapseEnvironment) synapseEnvironment) .getAxis2ConfigurationContext().createMessageContext(); }
public void testInitializationAndMedition() throws Exception { Mediator cm = MediatorFactoryFinder.getInstance().getMediator(createOMElement( "<class name='org.apache.synapse.mediators.ext.ClassMediatorTestMediator' " + "xmlns='http://ws.apache.org/ns/synapse'/>"), new Properties()); ((ManagedLifecycle) cm).init(new Axis2SynapseEnvironment(new SynapseConfiguration())); assertTrue(ClassMediatorTestMediator.initialized); TestMessageContext msgContext = new TestMessageContext(); msgContext.setEnvironment(new Axis2SynapseEnvironment(new SynapseConfiguration())); cm.mediate(msgContext); assertTrue(ClassMediatorTestMediator.invoked); }