Ejemplo n.º 1
0
  public void processAction(HttpServletRequest request, HttpServletResponse response)
      throws IOException {

    System.out.println("processing test driver request ... ");

    processParams(request);
    boolean status = false;
    System.out.println("tc:" + tc);

    response.setContentType("text/plain");
    ServletOutputStream out = response.getOutputStream();
    out.println("TestCase: " + tc);

    if (tc != null) {

      try {
        Class<?> c = getClass();
        Object t = this;

        Method[] allMethods = c.getDeclaredMethods();
        for (Method m : allMethods) {
          String mname = m.getName();
          if (!mname.equals(tc.trim())) {
            continue;
          }

          System.out.println("Invoking : " + mname);
          try {
            m.setAccessible(true);
            Object o = m.invoke(t);
            System.out.println("Returned => " + (Boolean) o);
            status = new Boolean((Boolean) o).booleanValue();
            // Handle any methods thrown by method to be invoked
          } catch (InvocationTargetException x) {
            Throwable cause = x.getCause();

            System.err.format("invocation of %s failed: %s%n", mname, cause.getMessage());
          } catch (IllegalAccessException x) {
            x.printStackTrace();
          }
        }
      } catch (Exception ex) {
        ex.printStackTrace();
      }

      if (status) {
        out.println(tc + ":pass");
      } else {
        out.println(tc + ":fail");
      }
    }
  }
Ejemplo n.º 2
0
 private void putMethods(AnnotationInfo ai, Class c) {
   Method[] methods = c.getDeclaredMethods();
   for (Method method : methods) {
     //            logger.fine("method=" + method.getName());
     String methodName = method.getName();
     if (!methodName.startsWith("get")) continue;
     //            System.out.println("method=" + methodName);
     if (config.isGroovyBeans()
         && (methodName.equals("getProperty") || methodName.equals("getMetaClass"))) continue;
     Transient transientM = method.getAnnotation(Transient.class);
     if (transientM != null) continue; // we don't save this one
     ai.addGetter(method);
   }
 }
Ejemplo n.º 3
0
 public Object getAnnotadedWithId(Object object, Class clazz) {
   Field[] fields = clazz.getDeclaredFields();
   Method[] methods = clazz.getDeclaredMethods();
   try {
     for (Field field : fields) {
       if (field.isAnnotationPresent(Id.class)) {
         field.setAccessible(true);
         return field.get(object);
       }
     }
     for (Method method : methods) {
       if (method.isAnnotationPresent(Id.class)) {
         return method.invoke(object);
       }
     }
     if (clazz.getSuperclass() != null && !clazz.getSuperclass().equals(Object.class)) {
       return getAnnotadedWithId(object, clazz.getSuperclass());
     }
   } catch (Exception ex) {
     logger.log(Level.SEVERE, null, ex);
   }
   return null;
 }