⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 stax.java

📁 Software Testing Automation Framework (STAF)的开发代码
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
            {                resolvedValue = STAFUtil.resolveRequestVar(                    parseResult.optionValue("FILE"),                    fHandle, info.requestNumber);                                if (resolvedValue.rc != 0)                    return new STAXSubmitResult(resolvedValue);                fileName = resolvedValue.result;                STAFResult copyResult = fHandle.submit2(                    machName, "FS", "GET FILE " + fileName);                if (copyResult.rc != 0)                {                    // There was an error in the FS service submission                    return new STAXSubmitResult(new STAFResult(                        copyResult.rc, "Error getting XML file " + fileName +                        " from machine " + machName + "\n\n" + copyResult.result));                }                job = parser.parse(new InputSource(                                   new StringReader(copyResult.result)));            }            // Parse an XML document provided in a String            if (parseResult.optionTimes("DATA") > 0)            {                job = parser.parse(new InputSource(                          new StringReader(parseResult.optionValue("DATA"))));                fileName = INLINE_DATA;            }            job.setXmlFile(fileName);            job.setXmlMachine(machName);            job.setSourceMachine(info.endpoint);            job.setSourceHandleName(info.handleName);            job.setSourceHandle(info.handle);            if (parseResult.optionTimes("JOBNAME") > 0)            {                resolvedValue = STAFUtil.resolveRequestVar(                    parseResult.optionValue("JOBNAME"),                    fHandle, info.requestNumber);                if (resolvedValue.rc != 0)                    return new STAXSubmitResult(resolvedValue);                job.setJobName(resolvedValue.result);            }            if (parseResult.optionTimes("FUNCTION") > 0)            {                resolvedValue = STAFUtil.resolveRequestVar(                    parseResult.optionValue("FUNCTION"),                    fHandle, info.requestNumber);                if (resolvedValue.rc != 0)                    return new STAXSubmitResult(resolvedValue);                job.setStartFunction(resolvedValue.result);                // Make sure that the start function specified is valid                if (!job.functionExists(resolvedValue.result))                {                    throw new STAXInvalidStartFunctionException(                        resolvedValue.result);                }            }            if (parseResult.optionTimes("ARGS") > 0)            {                // Not resolving STAF variables for ARGS to support Python                // dictionaries which use { } symbols as well.                // Parse and compile starting function's arguments                String args = STAXUtil.parseAndCompileForPython(                    parseResult.optionValue("ARGS"), "\n  ARGS option");                job.setStartFuncArgs(args);            }            if (parseResult.optionTimes("HOLD") > 0)            {                job.setExecuteAndHold();            }            String scriptMachName = "";            if (parseResult.optionTimes("SCRIPTFILEMACHINE") > 0)            {                resolvedValue = STAFUtil.resolveRequestVar(                    parseResult.optionValue("SCRIPTFILEMACHINE"),                    fHandle, info.requestNumber);                if (resolvedValue.rc != 0)                    return new STAXSubmitResult(resolvedValue);                scriptMachName = resolvedValue.result;                job.setScriptFileMachine(resolvedValue.result);            }            else if (parseResult.optionTimes("SCRIPTFILE") > 0)            {                scriptMachName = machName;                job.setScriptFileMachine(machName);            }            for (int i = 1; i <= parseResult.optionTimes("SCRIPTFILE"); i++)            {                resolvedValue = STAFUtil.resolveRequestVar(                    parseResult.optionValue("SCRIPTFILE", i),                    fHandle, info.requestNumber);                if (resolvedValue.rc != 0)                    return new STAXSubmitResult(resolvedValue);                job.setScriptFile(resolvedValue.result);                STAFResult copyResult = fHandle.submit2(                    scriptMachName, "FS", "GET FILE " + resolvedValue.result);                if (copyResult.rc != 0)                {                    // There was an error in the FS service submission                    return new STAXSubmitResult(new STAFResult(                        copyResult.rc, "Error getting Script file " +                        resolvedValue.result + " from machine " +                        scriptMachName + "\n\n" + copyResult.result));                }                // Parse and compile SCRIPTFILE contents containing Python code                String code = STAXUtil.parseAndCompileForPython(                    copyResult.result,                    "\n  Contents of SCRIPTFILE " + resolvedValue.result);                job.addDefaultAction(new STAXScriptAction(code));            }            for (int i = 1; i <= parseResult.optionTimes("SCRIPT"); i++)            {                // Parse and compile SCRIPT value containing Python code                String code = STAXUtil.parseAndCompileForPython(                    parseResult.optionValue("SCRIPT", i), "\n  SCRIPT option");                job.addDefaultAction(new STAXScriptAction(code));                // Store the scripts with private data masked since only used                // for display by a QUERY JOB <JobID> request                job.setScript(STAFUtil.maskPrivateData(code));            }            if (parseResult.optionTimes("CLEARLOGS") > 0)            {                // Resolve the value specified for CLEARLOGS                resolvedValue = STAFUtil.resolveRequestVar(                    parseResult.optionValue("CLEARLOGS"),                    fHandle, info.requestNumber);                if (resolvedValue.rc != 0)                    return new STAXSubmitResult(resolvedValue);                if (resolvedValue.result.equalsIgnoreCase("ENABLED") ||                    resolvedValue.result.equals(""))                {                    job.setClearlogs(true);                }                else if (resolvedValue.result.equalsIgnoreCase("DISABLED"))                {                    job.setClearlogs(false);                }                else                {                    return new STAXSubmitResult(new STAFResult(                        STAFResult.InvalidValue,                        "CLEARLOGS value must be ENABLED or DISABLED.  " +                        "Invalid value: " + resolvedValue.result));                }            }            // Handle LOGTCELAPSEDTIME setting            if (parseResult.optionTimes("LOGTCELAPSEDTIME") > 0)            {                // Resolve the value specified for LOGTCELAPSEDTIME                resolvedValue = STAFUtil.resolveRequestVar(                    parseResult.optionValue("LOGTCELAPSEDTIME"),                    fHandle, info.requestNumber);                if (resolvedValue.rc != 0)                    return new STAXSubmitResult(resolvedValue);                if (resolvedValue.result.equalsIgnoreCase("ENABLED"))                {                    job.setLogTCElapsedTime(true);                }                else if (resolvedValue.result.equalsIgnoreCase("DISABLED"))                {                    job.setLogTCElapsedTime(false);                }                else                {                    return new STAXSubmitResult(new STAFResult(                        STAFResult.InvalidValue,                        "LOGTCELAPSEDTIME value must be ENABLED or DISABLED.  " +                        "Invalid value: " + resolvedValue.result));                }            }            // Handle LOGTCNUMSTARTS setting            if (parseResult.optionTimes("LOGTCNUMSTARTS") > 0)            {                // Resolve the value specified for LOGTCNUMSTARTS                resolvedValue = STAFUtil.resolveRequestVar(                    parseResult.optionValue("LOGTCNUMSTARTS"),                    fHandle, info.requestNumber);                if (resolvedValue.rc != 0)                    return new STAXSubmitResult(resolvedValue);                if (resolvedValue.result.equalsIgnoreCase("ENABLED"))                {                    job.setLogTCNumStarts(true);                }                else if (resolvedValue.result.equalsIgnoreCase("DISABLED"))                {                    job.setLogTCNumStarts(false);                }                else                {                    return new STAXSubmitResult(new STAFResult(                        STAFResult.InvalidValue,                        "LOGTCNUMSTARTS value must be ENABLED or DISABLED.  " +                        "Invalid value: " + resolvedValue.result));                }            }            // Handle LOGTCSTARTSTOP setting            if (parseResult.optionTimes("LOGTCSTARTSTOP") > 0)            {                // Resolve the value specified for LOGTCSTARTSTOP                resolvedValue = STAFUtil.resolveRequestVar(                    parseResult.optionValue("LOGTCSTARTSTOP"),                    fHandle, info.requestNumber);                if (resolvedValue.rc != 0)                    return new STAXSubmitResult(resolvedValue);                if (resolvedValue.result.equalsIgnoreCase("ENABLED"))                {                    job.setLogTCStartStop(true);                }                else if (resolvedValue.result.equalsIgnoreCase("DISABLED"))                {                    job.setLogTCStartStop(false);                }                else                {                    return new STAXSubmitResult(new STAFResult(                        STAFResult.InvalidValue,                        "LOGTCSTARTSTOP value must be ENABLED or DISABLED.  " +                        "Invalid value: " + resolvedValue.result));                }            }            if (parseResult.optionTimes("TEST") > 0)            {                if (parseResult.optionTimes("RETURNDETAILS") > 0)                {                    // Get a list of functions to return                    HashMap functionMap = job.getFunctionMap();                    java.util.Collection functionColl = functionMap.keySet();                    TreeSet sortedFunctions = new TreeSet(functionColl);                    Iterator iter = sortedFunctions.iterator();                    // Create the marshalling context and set the map class                    // definitions                    STAFMarshallingContext mc = new STAFMarshallingContext();                    mc.setMapClassDefinition(fJobDetailsMapClass);                    mc.setMapClassDefinition(fFunctionInfoMapClass);                    mc.setMapClassDefinition(fArgInfoMapClass);                    mc.setMapClassDefinition(fArgPropertyInfoMapClass);                    mc.setMapClassDefinition(fArgPropertyDataInfoMapClass);                    List functionList = new ArrayList();                    Map jobDetailsMap = fJobDetailsMapClass.createInstance();                    jobDetailsMap.put("defaultCall", job.getStartFunction());                    while (iter.hasNext())                    {                        String functionName = (String)iter.next();                        STAXFunctionAction function =                            (STAXFunctionAction)functionMap.get(functionName);                        functionList.add(function.getArgumentInfo(                            fFunctionInfoMapClass, fArgInfoMapClass,                            fArgPropertyInfoMapClass,                            fArgPropertyDataInfoMapClass));                    }                    jobDetailsMap.put("functionList", functionList);                    mc.setRootObject(jobDetailsMap);                    return new STAXSubmitResult(                            new STAFResult(STAFResult.Ok, mc.marshall())

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -