### Question:
DynamicLoadbalanceEndpoint extends LoadbalanceEndpoint { public void send(MessageContext synCtx) { if (RuntimeStatisticCollector.isStatisticsEnabled()) { Integer currentIndex = null; boolean retry = (synCtx.getProperty(SynapseConstants.LAST_ENDPOINT) != null); if ((getDefinition() != null) && !retry) { currentIndex = OpenEventCollector.reportChildEntryEvent(synCtx, getReportingName(), ComponentType.ENDPOINT, getDefinition().getAspectConfiguration(), true); } try { sendMessage(synCtx); } finally { if (currentIndex != null) { CloseEventCollector.closeEntryEvent(synCtx, getReportingName(), ComponentType.MEDIATOR, currentIndex, false); } } } else { sendMessage(synCtx); } } DynamicLoadbalanceEndpoint(); @Override void init(SynapseEnvironment synapseEnvironment); void setLoadBalanceMembershipHandler(LoadBalanceMembershipHandler lbMembershipHandler); LoadBalanceMembershipHandler getLbMembershipHandler(); void send(MessageContext synCtx); void setName(String name); Dispatcher getDispatcher(); void setDispatcher(Dispatcher dispatcher); long getSessionTimeout(); void setSessionTimeout(long sessionTimeout); void setSessionAffinity(boolean sessionAffinity); boolean isSessionAffinityBasedLB();  }### Answer:
@Test public void testSend() throws AxisFault { DynamicLoadbalanceEndpoint dynamicLoadbalanceEndpoint = new DynamicLoadbalanceEndpoint(); SynapseEnvironment synapseEnvironment = getMockedSynapseEnvironment(); dynamicLoadbalanceEndpoint.init(synapseEnvironment); MessageContext messageContext = createMessageContext(); LoadBalanceMembershipHandler loadBalanceMembershipHandler = PowerMockito. mock(LoadBalanceMembershipHandler.class); Member member1 = new Member("localhost", 9000); Mockito.when(loadBalanceMembershipHandler. getNextApplicationMember(any(AlgorithmContext.class))).thenReturn(member1); dynamicLoadbalanceEndpoint.setLoadBalanceMembershipHandler(loadBalanceMembershipHandler); ((Axis2MessageContext)messageContext).getAxis2MessageContext(). getConfigurationContext().getAxisConfiguration(). addParameter(SynapseConstants.SYNAPSE_ENV, synapseEnvironment); messageContext.setEnvironment(synapseEnvironment); dynamicLoadbalanceEndpoint.send(messageContext); Assert.assertNotNull("SynapseConstants.LAST_ENDPOINT should return a not null value", messageContext.getProperty(SynapseConstants.LAST_ENDPOINT)); }