@Test public void testInvoke_soapClientMethodNoSuchmethodException() throws Throwable { Method indentityCallMethod = MockSoapClient.class.getMethod("identityCall", Object[].class); Object[] args = new String[] {"arg1", "arg2"}; when(soapClientHandler.getSoapClientMethod(soapClient, indentityCallMethod)) .thenThrow(new NoSuchMethodException()); thrown.expect(NoSuchMethodException.class); soapServiceClient.invoke(null, indentityCallMethod, args); }
@Test public void testInvoke_serviceClientMethod() throws Throwable { String endpointAddress = "http://test.com"; soapServiceClient.invoke(null, SoapServiceClient.class.getMethod("setEndpointAddress", String.class), new Object[] {endpointAddress}); verify(soapClientHandler).setEndpointAddress(soapClient, endpointAddress); }
@Test public void testInvoke_soapClientMethodAuthenticationException() throws Throwable { Method indentityCallMethod = MockSoapClient.class.getMethod("identityCall", Object[].class); Object[] args = new String[] {"arg1", "arg2"}; soapServiceClient.throwAuthException = true; thrown.expect(Matchers.<Exception>equalTo(TestSoapServiceClient.AUTH_EXCEPTION)); soapServiceClient.invoke(null, indentityCallMethod, args); }
@Test public void testInvoke_soapClientMethod() throws Throwable { Object returnValue = new Object(); RemoteCallReturn callReturn = new RemoteCallReturn.Builder().withReturnValue(returnValue).build(); Method identityCallMethod = MockSoapClient.class.getMethod("identityCall", Object[].class); Object[] arg = new String[] {"arg1", "arg2"}; Object[] args = new Object[] {arg}; SoapCall<Object> soapCall = new SoapCall<Object>(identityCallMethod, soapClient, args); when(soapClientHandler.getSoapClientMethod(soapClient, identityCallMethod)) .thenReturn(identityCallMethod); when(soapClientHandler.invokeSoapCall(soapCall)).thenReturn(callReturn); Object result = soapServiceClient.invoke(null, identityCallMethod, args); assertEquals(returnValue, result); }
@Test public void testInvoke_serviceClientSubclassMethod() throws Throwable { soapServiceClient.invoke(null, TestSoapServiceClient.class.getMethod("doSomething", Object.class), new Object[] {""}); }