summaryrefslogtreecommitdiffstats
path: root/src/test/java/org
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/java/org')
-rw-r--r--src/test/java/org/bukkit/BukkitMirrorTest.java68
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()));
}
}