GenericMarshallingMethodEndpointAdapter extends MarshallingMethodEndpointAdapter { @Override protected boolean supportsInternal(MethodEndpoint methodEndpoint) { Method method = methodEndpoint.getMethod(); return supportsReturnType(method) && supportsParameters(method); } GenericMarshallingMethodEndpointAdapter();  GenericMarshallingMethodEndpointAdapter(Marshaller marshaller);  GenericMarshallingMethodEndpointAdapter(Marshaller marshaller, Unmarshaller unmarshaller);   }
@Test public void testSupportedNoResponse() throws NoSuchMethodException { Method noResponse = getClass().getMethod("noResponse", MyGenericType.class); MethodEndpoint methodEndpoint = new MethodEndpoint(this, noResponse); expect(unmarshallerMock.supports(noResponse.getGenericParameterTypes()[0])).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", MyGenericType.class); MethodEndpoint methodEndpoint = new MethodEndpoint(this, response); expect(unmarshallerMock.supports(response.getGenericParameterTypes()[0])).andReturn(true); expect(marshallerMock.supports(response.getGenericReturnType())).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", 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", String.class); expect(unmarshallerMock.supports(unsupported.getGenericParameterTypes()[0])).andReturn(false); expect(marshallerMock.supports(unsupported.getGenericReturnType())).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", String.class); expect(marshallerMock.supports(unsupported.getGenericReturnType())).andReturn(false); replay(marshallerMock, unmarshallerMock); Assert.assertFalse("Method supported", adapter.supportsInternal(new MethodEndpoint(this, unsupported))); verify(marshallerMock, unmarshallerMock); }