Пример #1
0
  private static List<Map<Object, Object>> getListMapsFromXmlFile(String XmlFilePath) {
    List<Map<Object, Object>> listMaps = FastList.newInstance();
    InputStream ins = null;
    URL xmlFileUrl = null;
    Document xmlDocument = null;
    try {
      if (UtilValidate.isNotEmpty(XmlFilePath)) {
        xmlFileUrl = UtilURL.fromFilename(XmlFilePath);
        if (xmlFileUrl != null) ins = xmlFileUrl.openStream();
        if (ins != null) {
          xmlDocument = UtilXml.readXmlDocument(ins, xmlFileUrl.toString());
          List<? extends Node> nodeList =
              UtilXml.childNodeList(xmlDocument.getDocumentElement().getFirstChild());
          for (Node node : nodeList) {
            if (node.getNodeType() == Node.ELEMENT_NODE) {
              Map<Object, Object> fields = FastMap.newInstance();
              fields.put(node.getNodeName(), UtilXml.elementValue((Element) node));
              Map<Object, Object> attrFields = getAttributeNameValueMap(node);
              Set<Object> keys = attrFields.keySet();
              Iterator<Object> attrFieldsIter = keys.iterator();
              while (attrFieldsIter.hasNext()) {
                Object key = attrFieldsIter.next();
                fields.put(key, attrFields.get(key));
              }

              List<? extends Node> childNodeList = UtilXml.childNodeList(node.getFirstChild());
              for (Node childNode : childNodeList) {
                fields.put(childNode.getNodeName(), UtilXml.elementValue((Element) childNode));
                attrFields = getAttributeNameValueMap(childNode);
                keys = attrFields.keySet();
                attrFieldsIter = keys.iterator();
                while (attrFieldsIter.hasNext()) {
                  Object key = attrFieldsIter.next();
                  fields.put(key, attrFields.get(key));
                }
              }
              listMaps.add(fields);
            }
          }
        }
      }
    } catch (Exception exc) {
      Debug.logError(exc, "Error reading xml file", module);
    } finally {
      try {
        if (ins != null) ins.close();
      } catch (Exception exc) {
        Debug.logError(exc, "Error reading xml file", module);
      }
    }
    return listMaps;
  }
 public static List<ComponentDef> getRootComponents(String configFile) throws ComponentException {
   if (componentsToLoad == null) {
     synchronized (ComponentLoaderConfig.class) {
       if (componentsToLoad == null) {
         if (configFile == null) {
           configFile = COMPONENT_LOAD_XML_FILENAME;
         }
         URL xmlUrl = UtilURL.fromResource(configFile);
         ComponentLoaderConfig.componentsToLoad =
             ComponentLoaderConfig.getComponentsFromConfig(xmlUrl);
       }
     }
   }
   return componentsToLoad;
 }
Пример #3
0
  /* call run test suite from webtool selenium */
  public static String runTestSuite(HttpServletRequest request, HttpServletResponse response) {
    Map parameters = UtilHttp.getParameterMap(request);
    String para = (String) parameters.get("testSuitePath");
    if (para == null) {
      System.out.println("Error message : Test suite Path  is null");
      return "success";
    }
    if (para.length() == 0) {
      System.out.println("Error message : Test suite Path  is null");
      return "success";
    }
    try {
      URL url = UtilURL.fromResource("seleniumXml.properties");
      if (props == null) {
        props = new Properties();
        initConfig(url);
      }
      SeleniumXml sel = new SeleniumXml();
      File testFile = new File(para.trim());
      if (testFile.exists()) {
        System.err.println(" Argument : " + para.trim());
        System.err.println(" Full absolute path of file : " + testFile.getAbsolutePath());
        System.err.println(" Full canonical path of file : " + testFile.getCanonicalPath());

        sel.testCaseDirectory = sel.getFileDirectory(testFile.getAbsolutePath());
        System.err.println(" testCaseDirectory: " + sel.testCaseDirectory);
        sel.runTest(testFile.getAbsolutePath());
      } else {
        System.err.println("Test File is not exist :" + para.trim());
      }
    } catch (JDOMException jdome) {
      System.out.println(jdome.getMessage());
    } catch (IOException ioe) {
      System.out.println("Error message : " + ioe.getMessage());
    } finally {
      return "success";
    }
  }