Package java.lang.reflect

Examples of java.lang.reflect.Method


    //   Test explicit method names
    //  ===============================================================================================
    @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$
    }
View Full Code Here


    }

    @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$
    }
View Full Code Here

    }

    @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$
    }
View Full Code Here

    }

    @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$
    }
View Full Code Here

    }

    @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$
    }
View Full Code Here

    }

    @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$
    }
View Full Code Here

    }

    @Test public void testFindBestMethodWithSignature_ListAndMethodName() throws Exception {
        ReflectionHelper helper = new ReflectionHelper(FakeInterface.class);
        Class[] signatureSought = new Class[] {ArrayList.class};
        Method theMethod = helper.findBestMethodWithSignature("methodList", 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[] {List.class};
        assertEquals("Wrong class", theMethod.getDeclaringClass().getName(), FakeInterface.class.getName()); //$NON-NLS-1$
        helpAssertSameMethodSignature("Found wrong method signature", signatureExpected, signatureFound); //$NON-NLS-1$
    }
View Full Code Here

    }

    @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$
    }
View Full Code Here

    }

    @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$
    }
View Full Code Here

    }

    @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$
    }
View Full Code Here

TOP

Related Classes of java.lang.reflect.Method

Copyright © 2015 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.