MessageDispatcher implements WebServiceMessageReceiver, BeanNameAware, ApplicationContextAware { protected EndpointInvocationChain getEndpoint(MessageContext messageContext) throws Exception { for (EndpointMapping endpointMapping : getEndpointMappings()) { EndpointInvocationChain endpoint = endpointMapping.getEndpoint(messageContext); if (endpoint != null) { if (logger.isDebugEnabled()) { logger.debug( "Endpoint mapping [" + endpointMapping + "] maps request to endpoint [" + endpoint.getEndpoint() + "]"); } return endpoint; } else if (logger.isDebugEnabled()) { logger.debug("Endpoint mapping [" + endpointMapping + "] has no mapping for request"); } } return null; } MessageDispatcher(); List<EndpointAdapter> getEndpointAdapters(); void setEndpointAdapters(List<EndpointAdapter> endpointAdapters); List<EndpointExceptionResolver> getEndpointExceptionResolvers(); void setEndpointExceptionResolvers(List<EndpointExceptionResolver> endpointExceptionResolvers); List<EndpointMapping> getEndpointMappings(); void setEndpointMappings(List<EndpointMapping> endpointMappings); @Override final void setBeanName(String beanName); @Override void setApplicationContext(ApplicationContext applicationContext); @Override void receive(MessageContext messageContext); static final String ENDPOINT_NOT_FOUND_LOG_CATEGORY; static final String MESSAGE_TRACING_LOG_CATEGORY; }
@Test public void testGetEndpoint() throws Exception { EndpointMapping mappingMock = createMock(EndpointMapping.class); dispatcher.setEndpointMappings(Collections.singletonList(mappingMock)); EndpointInvocationChain chain = new EndpointInvocationChain(new Object()); expect(mappingMock.getEndpoint(messageContext)).andReturn(chain); replay(mappingMock, factoryMock); EndpointInvocationChain result = dispatcher.getEndpoint(messageContext); verify(mappingMock, factoryMock); Assert.assertEquals("getEndpoint returns invalid EndpointInvocationChain", chain, result); }