예제 #1
0
  /**
   * setArgStringValue purpose.
   *
   * <p>Stores a human friendly version. If this is a new Argument, then the type is String.
   *
   * @param name
   * @param value
   * @return
   */
  public boolean setArgStringValue(String name, String value) {
    ArgumentConfig ac = (ArgumentConfig) args.get(name);

    if ((value == null) || value.equals("")) {
      args.remove(name);

      return true;
    }

    if (ac == null) {
      return addArgStringValue(name, value);
    } else {
      if (ac.isFinal()) {
        throw new IllegalArgumentException("Cannot include final arguments as part of a test.");
      }

      StringReader sr = new StringReader(value);

      try {
        ac.setValue(ArgHelper.getArgumentInstance(ArgHelper.getArgumentType(ac.getValue()), value));

        return true;
      } catch (Exception e) {
        e.printStackTrace();

        // error, log it
        return false;
      }
    }
  }
예제 #2
0
  /**
   * setArgStringValue purpose.
   *
   * <p>Stores a human friendly version.
   *
   * @param name
   * @param value
   * @return
   */
  public boolean addArgStringValue(String name, String value) {
    PropertyDescriptor pd = getPropertyDescriptor(name);

    if (pd == null) {
      return false;
    }

    if ((value == null) || value.equals("")) {
      args.remove(name);

      return false;
    }

    Class cl = pd.getPropertyType();
    ArgumentConfig ac = new ArgumentConfig();
    ac.setName(name);

    try {
      String argType = ArgHelper.getArgumentType(cl);
      ac.setValue(ArgHelper.getArgumentInstance(argType, value));
    } catch (ValidationException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();

      return false;
    }

    args.put(name, ac);

    return true;
  }
예제 #3
0
  /**
   * getArgValue purpose.
   *
   * <p>Returns an Object version
   *
   * @param name
   * @return
   */
  public Object getArgValue(String name) {
    ArgumentConfig ac = (ArgumentConfig) args.get(name);

    if (ac == null) {
      return null;
    }

    return ac.getValue();
  }
예제 #4
0
  /**
   * getArgStringValue purpose.
   *
   * <p>Returns a human friendly version
   *
   * @param name
   * @return
   */
  public String getArgStringValue(String name) {
    ArgumentConfig ac = (ArgumentConfig) args.get(name);

    if (ac == null) {
      return null;
    }

    return ArgHelper.getArgumentStringEncoding(ac.getValue());
  }
예제 #5
0
  /**
   * setArgStringValue purpose.
   *
   * <p>Stores a human friendly version
   *
   * @param name
   * @param value
   * @return
   */
  public boolean setArgValue(String name, Object value) {
    if ((value == null) || value.equals("")) {
      args.remove(name);

      return true;
    }

    ArgumentConfig ac = (ArgumentConfig) args.get(name);

    if (ac == null) {
      ac = new ArgumentConfig();
      ac.setName(name);
      args.put(name, ac);
    }

    if (ac.isFinal()) {
      throw new IllegalArgumentException("Cannot include final arguments as part of a test.");
    }

    ac.setValue(value);

    return true;
  }
  public static synchronized void loadPropertyLists(
      TestConfig testConfig,
      Locale lc,
      List attributeKeys,
      List attributeHelps,
      List attributeValues) {
    if (!lc.equals(Locale.getDefault())) {
      Locale.setDefault(lc);
      Introspector.flushCaches();
    }

    PropertyDescriptor[] pd = testConfig.getPropertyDescriptors();

    for (int i = 0; i < pd.length; i++) {
      PropertyDescriptor property = pd[i];
      String propertyName = property.getName();
      String displayName = ArgumentConfig.getDisplayName(property);
      String description = ArgumentConfig.getDescription(property);

      attributeKeys.add(propertyName);
      attributeHelps.add(description);
      attributeValues.add(testConfig.getArgStringValue(propertyName));
    }
  }
  public boolean equals(Object obj) {
    boolean r = true;

    if ((obj == null) || !(obj instanceof ArgumentConfig)) {
      return false;
    }

    ArgumentConfig dto = (ArgumentConfig) obj;
    r = r && (dto.isFinal() == _final);

    if (name != null) {
      r = r && (name.equals(dto.getName()));
    } else if (dto.getName() != null) {
      return false;
    }

    if (value != null) {
      r = r && (value.equals(dto.getValue()));
    } else if (dto.getValue() != null) {
      return false;
    }

    return r;
  }
 public ArgumentConfig(ArgumentConfig dto) {
   name = dto.getName();
   _final = isFinal();
   value = dto.getValue();
 }