Package com.googlecode.gwt.test.exceptions

Examples of com.googlecode.gwt.test.exceptions.ReflectionException


      Class<?> rewrittenOverlayType = null;
      try {
         rewrittenOverlayType = Class.forName(overlayOriginalType + "$");
      } catch (ClassNotFoundException e) {
         throw new ReflectionException("Error while calling overlay rewritten method "
                  + overlayOriginalType + "$." + methodName + "$(..) :", e);
      }

      Object[] newArgs = new Object[args.length + 1];
      newArgs[0] = target;
View Full Code Here


         if (GwtTestException.class.isInstance(e.getCause())) {
            throw (GwtTestException) e.getCause();
         } else if (AssertionError.class.isInstance(e.getCause())) {
            throw (AssertionError) e.getCause();
         } else if (UmbrellaException.class.isInstance(e.getCause())) {
            throw new ReflectionException("Error while calling method '" + method.toString() + "'",
                     e.getCause().getCause());
         }
         throw new ReflectionException("Error while calling method '" + method.toString() + "'",
                  e.getCause());
      } catch (Exception e) {
         throw new ReflectionException("Unable to call method '"
                  + target.getClass().getSimpleName() + "." + method.getName() + "(..)'", e);
      }
   }
View Full Code Here

                  "Cannot call instance method on Overlay types without specifying its base type");
      }

      Method method = findMethod(target.getClass(), methodName, args);
      if (method == null) {
         throw new ReflectionException("Cannot find method '" + target.getClass().getName() + "."
                  + methodName + "(..)'");
      }
      return (T) callPrivateMethod(target, method, args);

   }
View Full Code Here

   public static <T> T callStaticMethod(Class<?> clazz, String methodName, Object... args) {

      Method m = findMethod(clazz, methodName, args);
      if (m == null) {
         throw new ReflectionException("Cannot find method '" + clazz.getName() + "." + methodName
                  + "(..)'");
      }
      try {
         m.setAccessible(true);
         Object res = m.invoke(null, args);
         return (T) res;
      } catch (Exception e) {
         throw new ReflectionException("Unable to call static method '" + m.toString() + "'", e);
      }
   }
View Full Code Here

   public static <T> T getPrivateFieldValue(Object target, Field field) {
      try {
         makeAccessible(field);
         return (T) field.get(target);
      } catch (Exception e) {
         throw new ReflectionException("Unable to get field '" + target.getClass().getSimpleName()
                  + "." + field.getName() + "'", e);
      }
   }
View Full Code Here

      Field field = getUniqueFieldByName(clazz, fieldName);
      try {
         return (T) field.get(null);
      } catch (Exception e) {
         e.printStackTrace();
         throw new ReflectionException(e.getMessage() + " Unable to get static field, class "
                  + fieldName + ", fieldClass " + clazz);
      }
   }
View Full Code Here

   public static <T> T instantiateClass(Class<T> clazz) {
      if (clazz == null) {
         throw new IllegalArgumentException("Class must not be null");
      }
      if (clazz.isInterface()) {
         throw new ReflectionException("Error during instanciation of '" + clazz.getName()
                  + "'. Specified class is an interface");
      }
      try {
         return instantiateClass(clazz.getDeclaredConstructor());
      } catch (NoSuchMethodException ex) {
         throw new ReflectionException("Error during instanciation of '" + clazz.getName()
                  + "'. No default constructor found", ex);
      }
   }
View Full Code Here

      try {
         makeAccessible(ctor);
         return ctor.newInstance(args);
      } catch (InstantiationException ex) {
         throw new ReflectionException("Error during instanciation of '"
                  + ctor.getDeclaringClass().getName() + "'. Is it an abstract class?", ex);
      } catch (IllegalAccessException ex) {
         throw new ReflectionException("Error during instanciation of '"
                  + ctor.getDeclaringClass().getName()
                  + "'. Has the class definition changed? Is the constructor accessible?", ex);
      } catch (IllegalArgumentException ex) {
         throw new ReflectionException("Error during instanciation of '"
                  + ctor.getDeclaringClass().getName() + "'. Illegal arguments for constructor", ex);
      } catch (InvocationTargetException ex) {
         if (GwtTestException.class.isInstance(ex.getTargetException())) {
            throw (GwtTestException) ex.getTargetException();
         } else if (GwtTestException.class.isInstance(ex.getTargetException().getCause())) {
            throw (GwtTestException) ex.getTargetException().getCause();
         } else {
            throw new ReflectionException("Error during instanciation of '"
                     + ctor.getDeclaringClass().getName() + "'. Constructor threw exception",
                     ex.getTargetException());
         }
      }
View Full Code Here

   public static void setPrivateFieldValue(Object target, String fieldName, Object value) {
      Field field = getUniqueFieldByName(target.getClass(), fieldName);
      try {
         field.set(target, value);
      } catch (Exception e) {
         throw new ReflectionException(e);
      }
   }
View Full Code Here

      Field field = getUniqueFieldByName(clazz, fieldName);
      try {
         field.set(null, value);
      } catch (Exception e) {
         e.printStackTrace();
         throw new ReflectionException(e);
      }
   }
View Full Code Here

TOP

Related Classes of com.googlecode.gwt.test.exceptions.ReflectionException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.