title: Unit testing annotations?
body: <p>I'm asking myself how deep should I go in (unit) testing my classes.
  As example, I have following simple class .</p>
  
  <pre><code>import javax.annotation.security.PermitAll;
  import javax.ejb.Singleton;
  import javax.ws.rs.GET;
  import javax.ws.rs.Path;
  import javax.ws.rs.Produces;
  import javax.ws.rs.core.MediaType;
  
  
  @Path(value = "ping")
  @Singleton
  @PermitAll
  public class PingRestService {
  
      @GET
      @Produces(MediaType.TEXT_PLAIN)
      public String pingMethod(){
          return "pong";
      }
  
  }
  </code></pre>
  
  <p>I wrote following unit test:</p>
  
  <pre><code>import static org.junit.Assert.*;
  import java.lang.reflect.Method;
  import javax.annotation.security.PermitAll;
  import javax.ejb.Singleton;
  import javax.ws.rs.GET;
  import javax.ws.rs.Path;
  import javax.ws.rs.Produces;
  import javax.ws.rs.core.MediaType;
  
  import org.junit.Test;
  
  
  public class PingRestServiceTest {
  
      PingRestService prs = new PingRestService();
  
      @Test
      public void testClassAnnotations(){
          assertEquals(3, prs.getClass().getAnnotations().length);
  
          assertTrue(prs.getClass().isAnnotationPresent(PermitAll.class));
          assertTrue(prs.getClass().isAnnotationPresent(Singleton.class));
          assertTrue(prs.getClass().isAnnotationPresent(Path.class));
  
          assertEquals("ping", prs.getClass().getAnnotation(Path.class).value());
  
      }
  
      @Test
      public void testPingMethodAnnotations() throws SecurityException, NoSuchMethodException{
  
          Method method = prs.getClass().getDeclaredMethod("pingMethod");
          assertEquals(2, method.getAnnotations().length);
  
          assertTrue(method.isAnnotationPresent(GET.class));
          assertTrue(method.isAnnotationPresent(Produces.class));
  
          assertEquals(1, method.getAnnotation(Produces.class).value().length);
          assertEquals(MediaType.TEXT_PLAIN, method.getAnnotation(Produces.class).value()[0]);
      }
  
      @Test
      public void testPingMethod() {
          assertEquals("pong", prs.pingMethod());
      }
  
  }
  </code></pre>
  
  <p>does it make sense? 
  Or should I only test the returning string ("pong", testPingMethod), skipping all annotations tests (testClassAnnotations,testPingMethodAnnotations) ?</p>
  
  <p>I think some annotations are part of a business logic (e.g. PermitAll), and therefore should be tested.</p>