MarshallingMethodEndpointAdapter extends AbstractMethodEndpointAdapter implements InitializingBean { @Override protected boolean supportsInternal(MethodEndpoint methodEndpoint) { Method method = methodEndpoint.getMethod(); return supportsReturnType(method) && supportsParameters(method); } MarshallingMethodEndpointAdapter();  MarshallingMethodEndpointAdapter(Marshaller marshaller);  MarshallingMethodEndpointAdapter(Marshaller marshaller, Unmarshaller unmarshaller); Marshaller getMarshaller(); final void setMarshaller(Marshaller marshaller); Unmarshaller getUnmarshaller(); final void setUnmarshaller(Unmarshaller unmarshaller); @Override void afterPropertiesSet();  }
@Test public void testSupportedNoResponse() throws NoSuchMethodException { Method noResponse = getClass().getMethod("noResponse", new Class[] { MyType.class }); MethodEndpoint methodEndpoint = new MethodEndpoint(this, noResponse); expect(unmarshallerMock.supports(MyType.class)).andReturn(true); replay(marshallerMock, unmarshallerMock); Assert.assertTrue("Method unsupported", adapter.supportsInternal(methodEndpoint)); verify(marshallerMock, unmarshallerMock); }
@Test public void testSupportedResponse() throws NoSuchMethodException { Method response = getClass().getMethod("response", new Class[] { MyType.class }); MethodEndpoint methodEndpoint = new MethodEndpoint(this, response); expect(unmarshallerMock.supports(MyType.class)).andReturn(true); expect(marshallerMock.supports(MyType.class)).andReturn(true); replay(marshallerMock, unmarshallerMock); Assert.assertTrue("Method unsupported", adapter.supportsInternal(methodEndpoint)); verify(marshallerMock, unmarshallerMock); }
@Test public void testUnsupportedMethodMultipleParams() throws NoSuchMethodException { Method unsupported = getClass().getMethod("unsupportedMultipleParams", new Class[] { String.class, String.class }); replay(marshallerMock, unmarshallerMock); Assert.assertFalse("Method supported", adapter.supportsInternal(new MethodEndpoint(this, unsupported))); verify(marshallerMock, unmarshallerMock); }
@Test public void testUnsupportedMethodWrongParam() throws NoSuchMethodException { Method unsupported = getClass().getMethod("unsupportedWrongParam", new Class[] { String.class }); expect(unmarshallerMock.supports(String.class)).andReturn(false); expect(marshallerMock.supports(String.class)).andReturn(true); replay(marshallerMock, unmarshallerMock); Assert.assertFalse("Method supported", adapter.supportsInternal(new MethodEndpoint(this, unsupported))); verify(marshallerMock, unmarshallerMock); }
@Test public void testUnsupportedMethodWrongReturnType() throws NoSuchMethodException { Method unsupported = getClass().getMethod("unsupportedWrongParam", new Class[] { String.class }); expect(marshallerMock.supports(String.class)).andReturn(false); replay(marshallerMock, unmarshallerMock); Assert.assertFalse("Method supported", adapter.supportsInternal(new MethodEndpoint(this, unsupported))); verify(marshallerMock, unmarshallerMock); }