/** * Test on init of RecipientListEndpoint */ @Test public void testRecipientListEndpointInit() throws Exception { Axis2SynapseEnvironment synapseEnvironment = getMockedSynapseEnvironment(); RecipientListEndpoint recipientListEndpoint = new RecipientListEndpoint(); recipientListEndpoint.init(synapseEnvironment); }
RecipientListEndpoint recipientListEndpoint = new RecipientListEndpoint(); maxCache = Integer.parseInt(maxCacheStr); recipientListEndpoint = new RecipientListEndpoint(maxCache); if (name != null) { recipientListEndpoint.setName(name.getAttributeValue());
RecipientListEndpoint recipientListEndpoint = new RecipientListEndpoint(); recipientListEndpoint = new RecipientListEndpoint(maxCache < 0 ? RecipientListEndpoint.DEFAULT_MAX_POOL : maxCache);
/** * 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); }
/** * 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); }