diff options
author | Wesley Wolfe <wesley.d.wolfe+git@gmail.com> | 2014-06-03 15:06:47 -0500 |
---|---|---|
committer | Wesley Wolfe <wesley.d.wolfe+git@gmail.com> | 2014-06-03 16:09:47 -0500 |
commit | 9869166c2ee9ec6911eae1934a2e048ea624565e (patch) | |
tree | 1987f2efa14e7fdaee0ccb50db1476b641c7cd19 /src/test/java/org | |
parent | 827610aec2e61da466defe556efb1a18bc740147 (diff) | |
download | bukkit-9869166c2ee9ec6911eae1934a2e048ea624565e.tar bukkit-9869166c2ee9ec6911eae1934a2e048ea624565e.tar.gz bukkit-9869166c2ee9ec6911eae1934a2e048ea624565e.tar.lz bukkit-9869166c2ee9ec6911eae1934a2e048ea624565e.tar.xz bukkit-9869166c2ee9ec6911eae1934a2e048ea624565e.zip |
Rewrite BukkitMirrorTest
Diffstat (limited to 'src/test/java/org')
-rw-r--r-- | src/test/java/org/bukkit/BukkitMirrorTest.java | 68 |
1 files changed, 62 insertions, 6 deletions
diff --git a/src/test/java/org/bukkit/BukkitMirrorTest.java b/src/test/java/org/bukkit/BukkitMirrorTest.java index 5728e429..219788fb 100644 --- a/src/test/java/org/bukkit/BukkitMirrorTest.java +++ b/src/test/java/org/bukkit/BukkitMirrorTest.java @@ -1,19 +1,75 @@ package org.bukkit; +import static org.hamcrest.Matchers.*; import static org.junit.Assert.*; import java.lang.reflect.Method; import java.lang.reflect.Modifier; +import java.util.Arrays; +import java.util.List; +import org.junit.Before; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import org.junit.runners.Parameterized.Parameter; +import org.junit.runners.Parameterized.Parameters; +import com.google.common.base.Function; +import com.google.common.collect.Lists; + +@RunWith(Parameterized.class) public class BukkitMirrorTest { + + @Parameters(name="{index}: {1}") + public static List<Object[]> data() { + return Lists.transform(Arrays.asList(Server.class.getDeclaredMethods()), new Function<Method, Object[]>() { + @Override + public Object[] apply(Method input) { + return new Object[] { + input, + input.toGenericString().substring("public abstract ".length()).replace("(", "{").replace(")", "}") + }; + } + }); + } + + @Parameter(0) + public Method server; + + @Parameter(1) + public String name; + + private Method bukkit; + + @Before + public void makeBukkit() throws Throwable { + bukkit = Bukkit.class.getDeclaredMethod(server.getName(), server.getParameterTypes()); + } + + @Test + public void isStatic() throws Throwable { + assertThat(Modifier.isStatic(bukkit.getModifiers()), is(true)); + } + + @Test + public void isDeprecated() throws Throwable { + assertThat(bukkit.isAnnotationPresent(Deprecated.class), is(server.isAnnotationPresent(Deprecated.class))); + } + + @Test + public void returnType() throws Throwable { + assertThat(bukkit.getReturnType(), is((Object) server.getReturnType())); + assertThat(bukkit.getGenericReturnType(), is(server.getGenericReturnType())); + } + + @Test + public void parameterTypes() throws Throwable { + assertThat(bukkit.getGenericParameterTypes(), is(server.getGenericParameterTypes())); + } + @Test - public final void test() throws NoSuchMethodException { - Method[] serverMethods = Server.class.getDeclaredMethods(); - for(Method method : serverMethods) { - Method mirrorMethod = Bukkit.class.getDeclaredMethod(method.getName(), method.getParameterTypes()); - assertTrue("Bukkit." + method.getName() + " must be static!", Modifier.isStatic(mirrorMethod.getModifiers())); - } + public void declaredException() throws Throwable { + assertThat(bukkit.getGenericExceptionTypes(), is(server.getGenericExceptionTypes())); } } |