SWS-344
This commit is contained in:
@@ -20,6 +20,7 @@ import java.util.Set;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.ws.context.MessageContext;
|
||||
import org.springframework.ws.server.EndpointExceptionResolver;
|
||||
@@ -30,6 +31,7 @@ import org.springframework.ws.server.EndpointExceptionResolver;
|
||||
* <p>Provides a set of mapped endpoints that the resolver should map.
|
||||
*
|
||||
* @author Arjen Poutsma
|
||||
* @author Tareq Abed Rabbo
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public abstract class AbstractEndpointExceptionResolver implements EndpointExceptionResolver, Ordered {
|
||||
@@ -75,6 +77,9 @@ public abstract class AbstractEndpointExceptionResolver implements EndpointExcep
|
||||
* @see #resolveExceptionInternal(MessageContext,Object,Exception)
|
||||
*/
|
||||
public final boolean resolveException(MessageContext messageContext, Object endpoint, Exception ex) {
|
||||
if (endpoint instanceof MethodEndpoint) {
|
||||
endpoint = ((MethodEndpoint) endpoint).getBean();
|
||||
}
|
||||
if (mappedEndpoints != null && !mappedEndpoints.contains(endpoint)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
package org.springframework.ws.server.endpoint;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.springframework.ws.context.MessageContext;
|
||||
|
||||
/**
|
||||
* Test for AbstractEndpointExceptionResolver
|
||||
*
|
||||
* @author Tareq Abed Rabbo
|
||||
* @author Arjen Poutsma
|
||||
*/
|
||||
public class EndpointExceptionResolverTest extends TestCase {
|
||||
|
||||
private MethodEndpoint methodEndpoint;
|
||||
|
||||
private AbstractEndpointExceptionResolver exceptionResolver;
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
exceptionResolver = new AbstractEndpointExceptionResolver() {
|
||||
|
||||
protected boolean resolveExceptionInternal(MessageContext messageContext, Object endpoint, Exception ex) {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
Set mappedEndpoints = new HashSet();
|
||||
mappedEndpoints.add(this);
|
||||
exceptionResolver.setMappedEndpoints(mappedEndpoints);
|
||||
methodEndpoint = new MethodEndpoint(this, getClass().getMethod("emptyMethod", new Class[0]));
|
||||
}
|
||||
|
||||
public void testMatchMethodEndpoint() {
|
||||
boolean matched = exceptionResolver.resolveException(null, methodEndpoint, null);
|
||||
assertTrue("AbstractEndpointExceptionResolver did not match mapped MethodEndpoint", matched);
|
||||
}
|
||||
|
||||
public void emptyMethod() {
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user