示例#1
0
文件: Json.java 项目: SAFSDEV/Core
 /**
  * Convert 'json object' to a certain type.
  *
  * @param clazz Class<T>, the expected type to which the json object will be converted.
  * @param jsonData Object, the json data object.
  * @return T, the converted 'json object'; null if something wrong happened.
  */
 public static <T> T convert(Class<T> clazz, Object jsonData) {
   try {
     if (clazz == null || jsonData == null) {
       IndependantLog.error(StringUtils.debugmsg(false) + " converted-clazz or jsonData is null.");
       return null;
     }
     JsonToBeanConverter converter = new JsonToBeanConverter();
     return converter.convert(clazz, jsonData);
   } catch (JsonException e) {
     IndependantLog.error(
         StringUtils.debugmsg(false) + "Fail to get convert JSON data to " + clazz.getSimpleName(),
         e);
     throw null;
   }
 }
示例#2
0
文件: Json.java 项目: SAFSDEV/Core
 /**
  * Read a JSON data file, and convert the data into a Java Map and return it.<br>
  *
  * @param file String, the absolute JSON file.
  * @param encoding String, the JSON file encoding.
  * @return Map, the JSON data as a Map; null if something wrong happened.
  */
 public static Map<?, ?> readJSONFile(String file, String encoding) {
   try {
     return convert(Map.class, FileUtilities.readStringFromEncodingFile(file, encoding));
   } catch (Exception e) {
     IndependantLog.error("Fail to get JSON data as a Map.", e);
     return null;
   }
 }
示例#3
0
  protected boolean performHoverMouse(Point point, int milliseconds) throws SAFSException {
    String debugmsg = StringUtils.debugmsg(false);

    try {
      // TODO handle the point
      String locator = component().getLocator();
      IndependantLog.debug(debugmsg + " hover on element '" + locator + "'");
      selenium.mouseOver(locator);
      StringUtilities.sleep(milliseconds);
      selenium.mouseOut(locator);

    } catch (Exception e) {
      IndependantLog.error(debugmsg + " fail to hover, due to " + StringUtils.debugmsg(e));
      return false;
    }
    return true;
  }