@Test public void testFindBestMethodWithSignature_SerializableAndMethodName() throws Exception { ReflectionHelper helper = new ReflectionHelper(FakeInterface.class); Class[] signatureSought = new Class[] {NullPointerException.class}; Method theMethod = helper.findBestMethodWithSignature("methodSerializable", signatureSought ); //$NON-NLS-1$ assertNotNull("Failed to find method for args: " + signatureSought, theMethod); //$NON-NLS-1$ // make sure we got the method we expected Class[] signatureFound = theMethod.getParameterTypes(); Class[] signatureExpected = new Class[] {Serializable.class}; assertEquals("Wrong class", theMethod.getDeclaringClass().getName(), FakeInterface.class.getName()); //$NON-NLS-1$ helpAssertSameMethodSignature("Found wrong method signature", signatureExpected, signatureFound); //$NON-NLS-1$ }
@Test public void testFindBestMethodWithSignature_String() throws Exception { ReflectionHelper helper = new ReflectionHelper(FakeInterface.class); Class[] signatureSought = new Class[] {String.class}; Method theMethod = helper.findBestMethodWithSignature("method", signatureSought ); //$NON-NLS-1$ assertNotNull("Failed to find method for args: " + signatureSought, theMethod); //$NON-NLS-1$ // make sure we got the method we expected Class[] signatureFound = theMethod.getParameterTypes(); Class[] signatureExpected = signatureSought; assertEquals("Wrong class", theMethod.getDeclaringClass().getName(), FakeInterface.class.getName()); //$NON-NLS-1$ helpAssertSameMethodSignature("Found wrong method signature", signatureExpected, signatureFound); //$NON-NLS-1$ }
@Test public void testFindBestMethodWithSignature_longAndMethodName() throws Exception { ReflectionHelper helper = new ReflectionHelper(FakeInterface.class); Class[] signatureSought = new Class[] {Long.TYPE}; Method theMethod = helper.findBestMethodWithSignature("method_long", signatureSought ); //$NON-NLS-1$ assertNotNull("Failed to find method for args: " + signatureSought, theMethod); //$NON-NLS-1$ // make sure we got the method we expected Class[] signatureFound = theMethod.getParameterTypes(); Class[] signatureExpected = signatureSought; assertEquals("Wrong class", theMethod.getDeclaringClass().getName(), FakeInterface.class.getName()); //$NON-NLS-1$ helpAssertSameMethodSignature("Found wrong method signature", signatureExpected, signatureFound); //$NON-NLS-1$ }
@Test public void testFindBestMethodWithSignature_2ArgIntegerObjectAndMethodName() throws Exception { ReflectionHelper helper = new ReflectionHelper(FakeInterface.class); Class[] signatureSought = new Class[] {Integer.class, Integer.class}; Method theMethod = helper.findBestMethodWithSignature("twoArgMethod_Object_Object", signatureSought ); //$NON-NLS-1$ assertNotNull("Failed to find method for args: " + signatureSought, theMethod); //$NON-NLS-1$ // make sure we got the method we expected Class[] signatureFound = theMethod.getParameterTypes(); Class[] signatureExpected = new Class[] {Object.class, Object.class}; assertEquals("Wrong class", theMethod.getDeclaringClass().getName(), FakeInterface.class.getName()); //$NON-NLS-1$ helpAssertSameMethodSignature("Found wrong method signature", signatureExpected, signatureFound); //$NON-NLS-1$ }
@Test public void testFindBestMethodWithSignature_2ArgSerializableNumberAndMethodName() throws Exception { ReflectionHelper helper = new ReflectionHelper(FakeInterface.class); Class[] signatureSought = new Class[] {Long.class, Long.class}; Method theMethod = helper.findBestMethodWithSignature("twoArgMethod_Serializable_Number", signatureSought ); //$NON-NLS-1$ assertNotNull("Failed to find method for args: " + signatureSought, theMethod); //$NON-NLS-1$ // make sure we got the method we expected Class[] signatureFound = theMethod.getParameterTypes(); Class[] signatureExpected = new Class[] {Serializable.class, Number.class}; assertEquals("Wrong class", theMethod.getDeclaringClass().getName(), FakeInterface.class.getName()); //$NON-NLS-1$ helpAssertSameMethodSignature("Found wrong method signature", signatureExpected, signatureFound); //$NON-NLS-1$ }
@Test public void testFindBestMethodWithSignature_long() throws Exception { ReflectionHelper helper = new ReflectionHelper(FakeInterface.class); Class[] signatureSought = new Class[] {Long.TYPE}; Method theMethod = helper.findBestMethodWithSignature("method", signatureSought ); //$NON-NLS-1$ assertNotNull("Failed to find method for args: " + signatureSought, theMethod); //$NON-NLS-1$ // make sure we got the method we expected Class[] signatureFound = theMethod.getParameterTypes(); Class[] signatureExpected = signatureSought; assertEquals("Wrong class", theMethod.getDeclaringClass().getName(), FakeInterface.class.getName()); //$NON-NLS-1$ helpAssertSameMethodSignature("Found wrong method signature", signatureExpected, signatureFound); //$NON-NLS-1$ }
@Test public void testFindBestMethodWithSignature_StringArrayAndMethodName() throws Exception { ReflectionHelper helper = new ReflectionHelper(FakeInterface.class); Class[] signatureSought = new Class[] {String[].class}; Method theMethod = helper.findBestMethodWithSignature("methodStringArray", signatureSought ); //$NON-NLS-1$ assertNotNull("Failed to find method for args: " + signatureSought, theMethod); //$NON-NLS-1$ // make sure we got the method we expected Class[] signatureFound = theMethod.getParameterTypes(); Class[] signatureExpected = signatureSought; assertEquals("Wrong class", theMethod.getDeclaringClass().getName(), FakeInterface.class.getName()); //$NON-NLS-1$ helpAssertSameMethodSignature("Found wrong method signature", signatureExpected, signatureFound); //$NON-NLS-1$ }
@Test public void testFindBestMethodWithSignature_SubInterface_2ArgSerializableAndNumber() throws Exception { ReflectionHelper helper = new ReflectionHelper(FakeSubInterface.class); Class[] signatureSought = new Class[] {Serializable.class, Number.class}; Method theMethod = helper.findBestMethodWithSignature("method", signatureSought ); //$NON-NLS-1$ assertNotNull("Failed to find method for args: " + signatureSought, theMethod); //$NON-NLS-1$ // make sure we got the method we expected Class[] signatureFound = theMethod.getParameterTypes(); Class[] signatureExpected = signatureSought; assertEquals("Wrong class", theMethod.getDeclaringClass().getName(), FakeSubInterface.class.getName()); //$NON-NLS-1$ helpAssertSameMethodSignature("Found wrong method signature", signatureExpected, signatureFound); //$NON-NLS-1$ }
@Test public void testFindBestMethodWithSignature_StringAndMethodName() throws Exception { ReflectionHelper helper = new ReflectionHelper(FakeInterface.class); Class[] signatureSought = new Class[] {String.class}; Method theMethod = helper.findBestMethodWithSignature("methodString", signatureSought ); //$NON-NLS-1$ assertNotNull("Failed to find method for args: " + signatureSought, theMethod); //$NON-NLS-1$ // make sure we got the method we expected Class[] signatureFound = theMethod.getParameterTypes(); Class[] signatureExpected = signatureSought; assertEquals("Wrong class", theMethod.getDeclaringClass().getName(), FakeInterface.class.getName()); //$NON-NLS-1$ helpAssertSameMethodSignature("Found wrong method signature", signatureExpected, signatureFound); //$NON-NLS-1$ }
@Test public void testFindBestMethodWithSignature_ObjectAndMethodName() throws Exception { ReflectionHelper helper = new ReflectionHelper(FakeInterface.class); Class[] signatureSought = new Class[] {NullPointerException.class}; Method theMethod = helper.findBestMethodWithSignature("methodObject", signatureSought ); //$NON-NLS-1$ assertNotNull("Failed to find method for args: " + signatureSought, theMethod); //$NON-NLS-1$ // make sure we got the method we expected Class[] signatureFound = theMethod.getParameterTypes(); Class[] signatureExpected = new Class[] {Object.class}; assertEquals("Wrong class", theMethod.getDeclaringClass().getName(), FakeInterface.class.getName()); //$NON-NLS-1$ helpAssertSameMethodSignature("Found wrong method signature", signatureExpected, signatureFound); //$NON-NLS-1$ }
@Test public void testFindBestMethodWithSignature_ObjectSerializableAndMethodName() throws Exception { ReflectionHelper helper = new ReflectionHelper(FakeInterface.class); Class[] signatureSought = new Class[] {NullPointerException.class}; Method theMethod = helper.findBestMethodWithSignature("methodSerializable", signatureSought ); //$NON-NLS-1$ assertNotNull("Failed to find method for args: " + signatureSought, theMethod); //$NON-NLS-1$ // make sure we got the method we expected Class[] signatureFound = theMethod.getParameterTypes(); Class[] signatureExpected = new Class[] {Serializable.class}; assertEquals("Wrong class", theMethod.getDeclaringClass().getName(), FakeInterface.class.getName()); //$NON-NLS-1$ helpAssertSameMethodSignature("Found wrong method signature", signatureExpected, signatureFound); //$NON-NLS-1$ }
@Test public void testFindBestMethodWithSignature_IntegerSerializableAndMethodName() throws Exception { ReflectionHelper helper = new ReflectionHelper(FakeInterface.class); Class[] signatureSought = new Class[] {Integer.class}; Method theMethod = helper.findBestMethodWithSignature("methodSerializable", signatureSought ); //$NON-NLS-1$ assertNotNull("Failed to find method for args: " + signatureSought, theMethod); //$NON-NLS-1$ // make sure we got the method we expected Class[] signatureFound = theMethod.getParameterTypes(); Class[] signatureExpected = new Class[] {Serializable.class}; assertEquals("Wrong class", theMethod.getDeclaringClass().getName(), FakeInterface.class.getName()); //$NON-NLS-1$ helpAssertSameMethodSignature("Found wrong method signature", signatureExpected, signatureFound); //$NON-NLS-1$ }
@Test public void testFindBestMethodWithSignature_IntegerAndMethodName() throws Exception { ReflectionHelper helper = new ReflectionHelper(FakeInterface.class); Class[] signatureSought = new Class[] {Integer.class}; Method theMethod = helper.findBestMethodWithSignature("methodInteger", signatureSought ); //$NON-NLS-1$ assertNotNull("Failed to find method for args: " + signatureSought, theMethod); //$NON-NLS-1$ // make sure we got the method we expected Class[] signatureFound = theMethod.getParameterTypes(); Class[] signatureExpected = signatureSought; assertEquals("Wrong class", theMethod.getDeclaringClass().getName(), FakeInterface.class.getName()); //$NON-NLS-1$ helpAssertSameMethodSignature("Found wrong method signature", signatureExpected, signatureFound); //$NON-NLS-1$ }
@Test public void testFindBestMethodWithSignature_2ArgLongObjectAndMethodName() throws Exception { ReflectionHelper helper = new ReflectionHelper(FakeInterface.class); Class[] signatureSought = new Class[] {Long.class, Long.class}; Method theMethod = helper.findBestMethodWithSignature("twoArgMethod_Object_Object", signatureSought ); //$NON-NLS-1$ assertNotNull("Failed to find method for args: " + signatureSought, theMethod); //$NON-NLS-1$ // make sure we got the method we expected Class[] signatureFound = theMethod.getParameterTypes(); Class[] signatureExpected = new Class[] {Object.class, Object.class}; assertEquals("Wrong class", theMethod.getDeclaringClass().getName(), FakeInterface.class.getName()); //$NON-NLS-1$ helpAssertSameMethodSignature("Found wrong method signature", signatureExpected, signatureFound); //$NON-NLS-1$ }
@Test public void testFindBestMethodWithSignature_Serializable() throws Exception { ReflectionHelper helper = new ReflectionHelper(FakeInterface.class); Class[] signatureSought = new Class[] {Serializable.class}; Method theMethod = helper.findBestMethodWithSignature("method", signatureSought ); //$NON-NLS-1$ assertNotNull("Failed to find method for args: " + signatureSought, theMethod); //$NON-NLS-1$ // make sure we got the method we expected Class[] signatureFound = theMethod.getParameterTypes(); Class[] signatureExpected = new Class[] {Serializable.class}; assertEquals("Wrong class", theMethod.getDeclaringClass().getName(), FakeInterface.class.getName()); //$NON-NLS-1$ helpAssertSameMethodSignature("Found wrong method signature", signatureExpected, signatureFound); //$NON-NLS-1$ }
@Test public void testFindBestMethodWithSignature_StringArray() throws Exception { ReflectionHelper helper = new ReflectionHelper(FakeInterface.class); Class[] signatureSought = new Class[] {String[].class}; Method theMethod = helper.findBestMethodWithSignature("method", signatureSought ); //$NON-NLS-1$ assertNotNull("Failed to find method for args: " + signatureSought, theMethod); //$NON-NLS-1$ // make sure we got the method we expected Class[] signatureFound = theMethod.getParameterTypes(); Class[] signatureExpected = signatureSought; assertEquals("Wrong class", theMethod.getDeclaringClass().getName(), FakeInterface.class.getName()); //$NON-NLS-1$ helpAssertSameMethodSignature("Found wrong method signature", signatureExpected, signatureFound); //$NON-NLS-1$ }
@Test public void testFindBestMethodWithSignature_Integer() throws Exception { ReflectionHelper helper = new ReflectionHelper(FakeInterface.class); Class[] signatureSought = new Class[] {Integer.class}; Method theMethod = helper.findBestMethodWithSignature("method", signatureSought ); //$NON-NLS-1$ assertNotNull("Failed to find method for args: " + signatureSought, theMethod); //$NON-NLS-1$ // make sure we got the method we expected Class[] signatureFound = theMethod.getParameterTypes(); Class[] signatureExpected = signatureSought; assertEquals("Wrong class", theMethod.getDeclaringClass().getName(), FakeInterface.class.getName()); //$NON-NLS-1$ helpAssertSameMethodSignature("Found wrong method signature", signatureExpected, signatureFound); //$NON-NLS-1$ }
@Test public void testFindBestMethodWithSignature_IntegerObjectAndMethodName() throws Exception { ReflectionHelper helper = new ReflectionHelper(FakeInterface.class); Class[] signatureSought = new Class[] {Integer.class}; Method theMethod = helper.findBestMethodWithSignature("methodObject", signatureSought ); //$NON-NLS-1$ assertNotNull("Failed to find method for args: " + signatureSought, theMethod); //$NON-NLS-1$ // make sure we got the method we expected Class[] signatureFound = theMethod.getParameterTypes(); Class[] signatureExpected = new Class[] {Object.class}; assertEquals("Wrong class", theMethod.getDeclaringClass().getName(), FakeInterface.class.getName()); //$NON-NLS-1$ helpAssertSameMethodSignature("Found wrong method signature", signatureExpected, signatureFound); //$NON-NLS-1$ }
@Test public void testFindBestMethodWithSignature_LongObjectAndMethodName() throws Exception { ReflectionHelper helper = new ReflectionHelper(FakeInterface.class); Class[] signatureSought = new Class[] {Long.class}; Method theMethod = helper.findBestMethodWithSignature("methodObject", signatureSought ); //$NON-NLS-1$ assertNotNull("Failed to find method for args: " + signatureSought, theMethod); //$NON-NLS-1$ // make sure we got the method we expected Class[] signatureFound = theMethod.getParameterTypes(); Class[] signatureExpected = new Class[] {Object.class}; assertEquals("Wrong class", theMethod.getDeclaringClass().getName(), FakeInterface.class.getName()); //$NON-NLS-1$ helpAssertSameMethodSignature("Found wrong method signature", signatureExpected, signatureFound); //$NON-NLS-1$ }
@Test public void testFindBestMethodWithSignature_Object() throws Exception { ReflectionHelper helper = new ReflectionHelper(FakeInterface.class); Class[] signatureSought = new Class[] {NullPointerException.class}; try { helper.findBestMethodWithSignature("method", signatureSought ); //$NON-NLS-1$ fail("exception expected"); //$NON-NLS-1$ } catch (NoSuchMethodException e) { assertEquals("method Args: [class java.lang.NullPointerException] has multiple possible signatures.", e.getMessage()); //$NON-NLS-1$ } }