package com.md_5.fondue.protocol;

import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.util.Arrays;
import org.junit.Test;
import static org.junit.Assert.*;

public class HandlerTest {

    /**
     * Method to test each handler type defines everything it requires
     */
    @Test
    public void doTest() throws NoSuchMethodException {
        checkImplements(new ServerHandler());
    }

    /**
     * Checks that the specified handler DOES implement the required methods
     */
    public void checkImplements(PacketHandler handler) throws NoSuchMethodException {
        for (Method m : PacketHandler.class.getDeclaredMethods()) {
            if (m.isAnnotationPresent(handler.getType())) {
                getOther(m, handler.getClass());
            }
        }
    }

    private Method getOther(Method method, Class other) throws NoSuchMethodException {
        return other.getDeclaredMethod(method.getName(), method.getParameterTypes());
    }
}

@@ -49,95 +49,37 @@
 ang.
-annotation.Annotation;%0Aimport java.lang.reflect.Method;%0Aimport java.util.Arrays;%0Aimport
+reflect.Method;%0Aimport static
  org
@@ -85,20 +85,24 @@
 g.junit.
-Test
+Assert.*
 ;%0Aimport
@@ -94,39 +94,32 @@
 ssert.*;%0Aimport 
-static 
 org.junit.Assert
@@ -112,24 +112,20 @@
 g.junit.
-Assert.*
+Test
 ;%0A%0Apubli
@@ -313,26 +313,16 @@
    check
-Implements
 (new Ser
@@ -339,24 +339,174 @@
 ());%0A    %7D%0A%0A
+    private void check(PacketHandler handler) throws NoSuchMethodException %7B%0A        checkImplements(handler);%0A        checkExcludes(handler);%0A    %7D%0A%0A
     /**%0A    
@@ -872,32 +872,597 @@
        %7D%0A    %7D%0A%0A
+    /**%0A     * Checks that the specified handler DOES NOT implement methods from other%0A     * handler types%0A     */%0A    public void checkExcludes(PacketHandler handler) throws NoSuchMethodException %7B%0A        for (Method m : handler.getClass().getDeclaredMethods()) %7B%0A            Method parent = getOther(m, PacketHandler.class);%0A            if (parent.getAnnotations().length %3E 0) %7B%0A                assertTrue(m + %22 includes type not suitable for %22 + handler.getType().getSimpleName(), parent.isAnnotationPresent(handler.getType()));%0A            %7D%0A        %7D%0A    %7D%0A%0A
     private Meth

Add additional test to ensure the wrong methods are not implemented.