Package com.googlecode.gwt.test.exceptions

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


         return v;
      } else if (returnType == Map.class) {
         DefaultStringMapValue a = getCheckedAnnotation(method, DefaultStringMapValue.class);
         String[] v = a.value();
         if (v.length % 2 != 0) {
            throw new GwtTestI18NException("@" + DefaultStringMapValue.class.getSimpleName()
                     + " value incorrect for method " + method.getDeclaringClass().getName() + "."
                     + method.getName() + "() : the array value (key/value pair) should be even");
         }
         Map<String, String> result = new HashMap<String, String>();
         for (int i = 0; i < v.length; i++) {
            result.put(v[i], treatLine(v[++i]));
         }
         return result;

      } else if (returnType == Integer.class || returnType == Integer.TYPE) {
         DefaultIntValue a = getCheckedAnnotation(method, DefaultIntValue.class);
         return a.value();
      } else if (returnType == Double.class || returnType == Double.TYPE) {
         DefaultDoubleValue a = getCheckedAnnotation(method, DefaultDoubleValue.class);
         return a.value();
      } else if (returnType == Float.class || returnType == Float.TYPE) {
         DefaultFloatValue a = getCheckedAnnotation(method, DefaultFloatValue.class);
         return a.value();
      } else if (returnType == Boolean.class || returnType == Boolean.TYPE) {
         DefaultBooleanValue a = getCheckedAnnotation(method, DefaultBooleanValue.class);
         return a.value();
      }

      throw new GwtTestI18NException("The return type (" + returnType.getSimpleName()
               + ") of i18n '" + getProxiedClass().getSimpleName() + "." + method.getName()
               + "()' is not managed");

   }
View Full Code Here


         return Float.parseFloat(line);
      } else if (returnType == Boolean.class || returnType == Boolean.TYPE) {
         return Boolean.parseBoolean(line);
      }

      throw new GwtTestI18NException("The return type (" + returnType.getSimpleName()
               + ") of i18n '" + method.getDeclaringClass().getSimpleName() + "."
               + method.getName() + "()' is not managed");

   }
View Full Code Here

   }

   private <T extends Annotation> T getCheckedAnnotation(Method method, Class<T> defaultAnnotation) {
      T v = method.getAnnotation(defaultAnnotation);
      if (v == null) {
         throw new GwtTestI18NException("No matching property \"" + method.getName()
                  + "\" for Constants class [" + getProxiedClass().getCanonicalName()
                  + "]. Please check the corresponding properties files or use @"
                  + defaultAnnotation.getSimpleName());
      }
View Full Code Here

   @SuppressWarnings("unchecked")
   public Object create(Class<?> classLiteral) throws Exception {
      if (LocalizableResource.class.isAssignableFrom(classLiteral)) {

         if (!classLiteral.isInterface()) {
            throw new GwtTestI18NException(classLiteral.getSimpleName() + " must be an interface");
         }
         return LocalizableResourceProxyFactory.getFactory(
                  (Class<? extends LocalizableResource>) classLiteral).createProxy();
      } else if (CldrImpl.class == classLiteral) {
         return getLocalizedClassImpl(CldrImpl.class, CldrImpl.class);
View Full Code Here

         if (Constants.class.isAssignableFrom(clazz)) {
            return new ConstantsInvocationHandler(clazz);
         } else if (Messages.class.isAssignableFrom(clazz)) {
            return new MessagesInvocationHandler(clazz);
         } else {
            throw new GwtTestI18NException("Not managed GWT i18n interface for testing : "
                     + clazz.getSimpleName());
         }
      }
View Full Code Here

                  sb.append(ruleInstance.pluralForms()[ruleInstance.select(count)].getName()).append(
                           "|");

               } catch (ClassNotFoundException e) {
                  throw new GwtTestI18NException("Cannot find PluralRule for method '"
                           + method.getDeclaringClass().getSimpleName() + "." + method.getName()
                           + "()'. Expected PluralRule : '" + pluralRuleClassName + "'");
               } catch (InstantiationException e) {
                  throw new GwtTestI18NException("Error during instanciation of class '"
                           + pluralRuleClassName + "'", e);
               } catch (IllegalAccessException e) {
                  throw new GwtTestI18NException("Error during instanciation of class '"
                           + pluralRuleClassName + "'", e);
               }
            } else if (Select.class.isAssignableFrom(childArray[j].getClass())) {
               sb.append(args[i]).append("|");
            }
         }
      }

      if (sb.length() == 0) {
         throw new GwtTestI18NException("Bad configuration of '" + method.getDeclaringClass() + "."
                  + method.getName() + "' : a @" + messageAnnotation.getClass().getSimpleName()
                  + " is declared but no @" + PluralCount.class.getSimpleName() + " or @"
                  + Select.class.getSimpleName() + " set on any method parameter'");
      } else {
         return sb.substring(0, sb.length() - 1);
View Full Code Here

      if (result != null) {
         return result;
      }

      throw new GwtTestI18NException(
               "Unable to find a Locale specific resource file to bind with i18n interface '"
                        + proxiedClass.getName()
                        + "' and there is no @DefaultXXXValue annotation on '" + method.getName()
                        + "' called method");
   }
View Full Code Here

            case 1:
               return new Locale(localeCodes[0]);
            case 2:
               return new Locale(localeCodes[0], localeCodes[1]);
            default:
               throw new GwtTestI18NException("Cannot parse Locale value in annoted class ["
                        + proxiedClass.getSimpleName() + "] : @"
                        + DefaultLocale.class.getSimpleName() + "(" + annotation.value() + ")");
         }
      } else {
         return null;
View Full Code Here

         InputStreamReader inputStreamReader = new InputStreamReader(inputStream, "UTF-8");
         load(properties, inputStreamReader);
         cachedProperties.put(path, properties);
         return properties;
      } catch (Exception e) {
         throw new GwtTestI18NException("Unable to load property file [" + path + "]", e);
      }
   }
View Full Code Here

TOP

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

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.