예제 #1
0
 void addIfTestMethod(Method m) {
   if (m.getAnnotation(Test.class) == null) return;
   if (!(m.getReturnType().equals(boolean.class) || m.getReturnType().equals(void.class)))
     throw new RuntimeException("@Test method" + " must return boolean or void");
   m.setAccessible(true); // In case it's private, etc.
   add(m);
 }
예제 #2
0
 private static Method checkForCreatorMethod(Method m) {
   if (m.getAnnotation(TestObjectCreate.class) == null) return null;
   if (!m.getReturnType().equals(testClass))
     throw new RuntimeException(
         "@TestObjectCreate " + "must return instance of Class to be tested");
   if ((m.getModifiers() & java.lang.reflect.Modifier.STATIC) < 1)
     throw new RuntimeException("@TestObjectCreate " + "must be static.");
   m.setAccessible(true);
   return m;
 }
예제 #3
0
 private static Method checkForCleanupMethod(Method m) {
   if (m.getAnnotation(TestObjectCleanup.class) == null) return null;
   if (!m.getReturnType().equals(void.class))
     throw new RuntimeException("@TestObjectCleanup " + "must return void");
   if ((m.getModifiers() & java.lang.reflect.Modifier.STATIC) < 1)
     throw new RuntimeException("@TestObjectCleanup " + "must be static.");
   if (m.getParameterTypes().length == 0 || m.getParameterTypes()[0] != testClass)
     throw new RuntimeException(
         "@TestObjectCleanup " + "must take an argument of the tested type.");
   m.setAccessible(true);
   return m;
 }