package uk.co.littlemike.jextend.impl.jdk;

import org.junit.Test;

public class MethodLookupTest {

    private void privateMethod() {
    }

    @Test(expected = MethodLookupException.class)
    public void throwsExceptionWhenAttemptingToLookupPrivateMethod() throws Exception {
        MethodLookup lookup = new MethodLookup(Object.class);

        lookup.lookup(MethodLookupTest.class.getDeclaredMethod("privateMethod"));
    }
}

package uk.co.littlemike.jextend.impl.jdk;

import org.junit.Test;

public class MethodLookupTest {

    private void privateMethod() {
    }

    @Test(expected = MethodLookupException.class)
    public void throwsExceptionWhenAttemptingToLookupPrivateMethodOnDifferentClass() throws Exception {
        MethodLookup lookup = new MethodLookup(Object.class);

        lookup.lookup(MethodLookupTest.class.getDeclaredMethod("privateMethod"));
    }

    @Test(expected = MethodLookupException.class)
    public void throwsExceptionWhenAttemptingToLookupPrivateMethodOnDifferentClass_EvenIfPrivileged() throws Exception {
        PrivilegedMethodLookup lookup = new PrivilegedMethodLookup(Object.class);

        lookup.lookupDefault(MethodLookupTest.class.getDeclaredMethod("privateMethod"));
    }
}

Add test for privileged private method lookup failure
Add test for privileged private method lookup failure
