Created
February 23, 2018 11:27
-
-
Save sergeijakovlev/315c3a87788bfbd31a81cb4a91dd84ee to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.util.HashSet; | |
| import java.util.Set; | |
| import org.glassfish.jersey.server.model.AnnotatedMethod; | |
| import org.glassfish.jersey.server.model.MethodList; | |
| import org.junit.Test; | |
| import static org.junit.Assert.assertTrue; | |
| public class MethodListTest { | |
| public class PublicSuper { | |
| public void a() {} | |
| } | |
| public class PublicSub extends PublicSuper { | |
| public void b() {} | |
| } | |
| @Test | |
| public void testPublic() { | |
| final MethodList annotatedMethods = new MethodList(PublicSub.class); | |
| checkMethods(annotatedMethods); | |
| } | |
| protected class ProtectedSuper { | |
| public void a() {} | |
| } | |
| public class ProtectedSub extends ProtectedSuper { | |
| public void b() {} | |
| } | |
| @Test | |
| public void testProtected() { | |
| final MethodList annotatedMethods = new MethodList(ProtectedSub.class); | |
| checkMethods(annotatedMethods); | |
| } | |
| class DefaultSuper { | |
| void a() {} | |
| } | |
| public class DefaultSub extends DefaultSuper { | |
| public void b() {} | |
| } | |
| @Test | |
| public void testDefault() { | |
| final MethodList annotatedMethods = new MethodList(DefaultSub.class); | |
| checkMethods(annotatedMethods); | |
| } | |
| private class PrivateSuper { | |
| void a() {} | |
| } | |
| public class PrivateSub extends PrivateSuper { | |
| public void b() {} | |
| } | |
| @Test | |
| public void testPrivate() { | |
| final MethodList annotatedMethods = new MethodList(PrivateSub.class); | |
| checkMethods(annotatedMethods); | |
| } | |
| private static void checkMethods(MethodList annotatedMethods) { | |
| Set<String> s = new HashSet<>(); | |
| for (AnnotatedMethod am : annotatedMethods) { | |
| s.add(am.getMethod().getName()); | |
| } | |
| assertTrue(s.contains("a")); | |
| assertTrue(s.contains("b")); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment