/** * Creates the {@link SoapCall} from the {@code soapClientMethod} and its * {@code args}. */ protected SoapCall<T> createSoapCall(Method soapClientMethod, Object[] args) { return new SoapCall<T>(soapClientMethod, soapClient, args); }
/** * Creates the {@link SoapCall} from the {@code soapClientMethod} and its * {@code args}. */ protected SoapCall<T> createSoapCall(Method soapClientMethod, Object[] args) { return new SoapCall<T>(soapClientMethod, soapClient, args); }
@Test public void testCreateSoapCall() throws SecurityException, NoSuchMethodException { Method indentityCallMethod = MockSoapClient.class.getMethod("identityCall", Object[].class); Object[] args = new String[] {"arg1", "arg2"}; SoapCall<Object> expectedSoapCall = new SoapCall<Object>(indentityCallMethod, soapClient, args); SoapCall<Object> soapCall = soapServiceClient.createSoapCall(indentityCallMethod, args); assertEquals(expectedSoapCall, soapCall); }
@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 testEquals() throws Exception { Method method1 = Object.class.getDeclaredMethod("equals", Object.class); Method method2 = Object.class.getDeclaredMethod("toString"); Object object1 = new Object(); Object[] objectArray = new Object[] {new Object()}; SoapCall<Object> soapCall1 = new SoapCall<Object>(method1, object1, objectArray); SoapCall<Object> soapCall2 = new SoapCall<Object>(method1, object1, objectArray); assertTrue(soapCall1.equals(soapCall2)); assertTrue(soapCall2.equals(soapCall1)); SoapCall<Object> soapCall3 = new SoapCall<Object>(method1, new Object(), objectArray); assertFalse(soapCall1.equals(soapCall3)); assertFalse(soapCall3.equals(soapCall1)); SoapCall<Object> soapCall4 = new SoapCall<Object>(method1, object1, new Object[] {}); assertFalse(soapCall1.equals(soapCall4)); assertFalse(soapCall4.equals(soapCall1)); SoapCall<Object> soapCall5 = new SoapCall<Object>(method2, object1, objectArray); assertFalse(soapCall1.equals(soapCall5)); assertFalse(soapCall5.equals(soapCall1)); }
@Test public void testHashCode() throws Exception { Method method1 = Object.class.getDeclaredMethod("equals", Object.class); Method method2 = Object.class.getDeclaredMethod("toString"); Object commonObject = new Object(); SoapCall<Object> soapCall1 = new SoapCall<Object>(method1, commonObject, new Integer[] {5}); SoapCall<Object> soapCall2 = new SoapCall<Object>(method2, commonObject, new Integer[] {5}); SoapCall<Object> soapCall3 = new SoapCall<Object>(method1, commonObject, new Integer[] {42}); SoapCall<Object> soapCall4 = new SoapCall<Object>(method1, new Object(), new Integer[] {42}); assertTrue("Hash code is not stable", soapCall1.hashCode() == soapCall1.hashCode()); assertFalse( "Hash code unaffected by method change", soapCall1.hashCode() == soapCall2.hashCode()); assertFalse( "Hash code unaffected by array change", soapCall1.hashCode() == soapCall3.hashCode()); assertFalse( "Hash code unaffected by array change", soapCall1.hashCode() == soapCall3.hashCode()); assertFalse( "Hash code unaffected by client change", soapCall1.hashCode() == soapCall4.hashCode()); } }