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

📄 staxmonitorutil.java

📁 Software Testing Automation Framework (STAF)的开发代码
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
    }            public static void updateRowHeights(JTable table, int multiLineColumn,                                        String fontName)    {               int numLines = 1;        for (int i = 0 ; i < table.getRowCount() ; i++)        {            JTextArea textarea = new JTextArea(                (String)table.getValueAt(i, multiLineColumn));                        textarea.setFont(new Font(fontName, Font.PLAIN, 12));            int height = textarea.getPreferredSize().height + 5;                        table.setRowHeight(i, height);        }    }            public static Calendar getCalendar(String result)    {                int index = result.indexOf("Start Date");        index = result.indexOf(":", index);         String startDate = result.substring(index + 2, index + 10);                index = result.indexOf("Start Time");        index = result.indexOf(":", index);                 String startTime = result.substring(index + 2, index + 10);                                int year = (new Integer(startDate.substring(0, 4))).intValue();        int month = (new Integer(startDate.substring(4, 6))).intValue();        int date = (new Integer(startDate.substring(6, 8))).intValue();                    int hours = (new Integer(startTime.substring(0, 2))).intValue();        int minutes = (new Integer(startTime.substring(3, 5))).intValue();        int seconds = (new Integer(startTime.substring(6, 8))).intValue();                   Calendar startCalendar = Calendar.getInstance();        startCalendar.set(year, month - 1, date, hours, minutes, seconds);                return startCalendar;    }        public static Calendar getCalendar2(String startDate, String startTime)    {        int year = (new Integer(startDate.substring(0, 4))).intValue();        int month = (new Integer(startDate.substring(4, 6))).intValue();        int date = (new Integer(startDate.substring(6, 8))).intValue();                    int hours = (new Integer(startTime.substring(0, 2))).intValue();        int minutes = (new Integer(startTime.substring(3, 5))).intValue();        int seconds = (new Integer(startTime.substring(6, 8))).intValue();                   Calendar startCalendar = Calendar.getInstance();        startCalendar.set(year, month - 1, date, hours, minutes, seconds);                return startCalendar;    }        // This method checks gets the current monitor message, if any, for    // the process machine/handle.  It supports process machines that are    // running STAF V3.x or STAF V2.x.    public static String getMonitorMessage(String location, String handle)    {        String message = new String("");        // Submit the monitor query request specifying the machine nickname        String request = "QUERY MACHINE {STAF/Config/MachineNickname} " +            "HANDLE " + handle;        STAFResult result = mainMonitorHandle.submit2(            location, "MONITOR", request);        if (result.rc != 0)        {            if (result.rc == STAFResult.VariableDoesNotExist)            {                if (result.result.indexOf("MachineNickname") != -1)                {                    // Process machine must be running STAF 2.x.                    // Try again, this time specifying the effective machine                    request = "QUERY MACHINE {STAF/Config/EffectiveMachine} " +                        "HANDLE " + handle;                    result = mainMonitorHandle.submit2(                        location, "MONITOR", request);                }                if (result.rc == STAFResult.VariableDoesNotExist)                {                    System.out.println(                        "STAXMonitorUtil::getMonitorMessage: " +                        "STAF " + location + " MONITOR " + request +                        " failed with RC=" + result.rc + " Result=" +                        result.result);                }            }            if (result.rc != 0)            {                if (debug)                    System.out.println(                        "RC:" + result.rc + " " + result.result);                return message;            }        }        if (STAFMarshallingContext.isMarshalledData(result.result))        {            // STAF 3.x - Unmarshall the result            STAFMarshallingContext mc = STAFMarshallingContext.unmarshall(                result.result);            Map resultsMap = (Map)mc.getRootObject();            message = (String)resultsMap.get("message");        }        else        {            // STAF V2.x results are not marshalled            message = result.result.substring(result.result.indexOf(" ") + 1);        }        return message;    }    public static void assignProcessInfo(Map processMap, Vector procDataVector)    {        // Input parameters        //   processMap    :  Contains the process information        // Output parameters        //   procDataVector:  Gets assigned the process information as it        //                    should be viewed in the STAX Monitor        addRow(procDataVector, "Location",               (String)processMap.get("location"));        addRow(procDataVector, "Handle",               (String)processMap.get("handle"));        addRow(procDataVector, "Command",               (String)processMap.get("command"));                // Assign command mode        String commandMode = (String)processMap.get("commandMode");        addRow(procDataVector, "Command Mode", commandMode);                // Assign command shell        String commandShell = (String)processMap.get("commandShell");        if (commandShell != null && !commandShell.equals(""))            addRow(procDataVector, "Command Shell", commandShell);                // Assign title        String processTitle = (String)processMap.get("title");        if (processTitle != null && !processTitle.equals(""))            addRow(procDataVector, "Title", processTitle);        // Assign parameters        String parms = (String)processMap.get("parms");        if (parms != null && !parms.equals(""))            addRow(procDataVector, "Parms", parms);        // Assign working directory        String workdir = (String)processMap.get("workdir");        if (workdir != null && !workdir.equals(""))            addRow(procDataVector, "Workdir", workdir);        // Assign workload        String workload = (String)processMap.get("workload");        if (workload != null && !workload.equals(""))            addRow(procDataVector, "Workload", workload);        // Assign variable list        if (processMap.get("varList") instanceof java.util.List)        {            java.util.List varList = (java.util.List)processMap.get("varList");            for (int i = 0; i < varList.size(); i++)            {                addRow(procDataVector, "Var #" + (i + 1),                       (String)varList.get(i));            }        }        // Assign environment variable list        if (processMap.get("envList") instanceof java.util.List)        {            java.util.List envList = (java.util.List)processMap.get("envList");            for (int i = 0; i < envList.size(); i++)            {                addRow(procDataVector, "Env #" + (i + 1),                       (String)envList.get(i));            }        }        // Assign useProcessVars        String useProcessVars = (String)processMap.get("useProcessVars");        if (useProcessVars != null)            addRow(procDataVector, "UseProcessVars", "");        // Assign stop using method        String stopusing = (String)processMap.get("stopUsing");        if (stopusing != null && !stopusing.equals(""))            addRow(procDataVector, "StopUsing", stopusing);        // Assign same/new console        String console = (String)processMap.get("console");        if (console != null)        {            if (console.equals("same"))                addRow(procDataVector, "SameConsole", "");            else if (console.equals("new"))                addRow(procDataVector, "NewConsole", "");        }        // Assign focus        String focus = (String)processMap.get("focus");        if (focus != null)        {            addRow(procDataVector, "Focus", focus);        }        // Assign user name        String username = (String)processMap.get("userName");        if (username != null && !username.equals(""))            addRow(procDataVector, "Username", username);        // Assign password        String password = (String)processMap.get("password");        if (password != null && !password.equals(""))            addRow(procDataVector, "Password", password);        // Assign disabled authentication action        String disabledauth = (String)processMap.get("disabledAuth");        if (disabledauth != null)        {            if (disabledauth.equalsIgnoreCase("error"))                addRow(procDataVector, "DisabledAuthIsError", "");            else if (disabledauth.equalsIgnoreCase("ignore"))                addRow(procDataVector, "IgnoreDisabledAuth", "");        }        // Assign stdint        String stdin = (String)processMap.get("stdin");        if (stdin != null && !stdin.equals(""))            addRow(procDataVector, "Stdin", stdin);                // Assign stdout file name        String stdout = (String)processMap.get("stdoutFile");        if (stdout != null && !stdout.equals(""))            addRow(procDataVector, "Stdout", stdout);                // Assign stdout mode        String stdoutMode = (String)processMap.get("stdoutMode");        if (stdoutMode != null && stdoutMode.equalsIgnoreCase("append"))            addRow(procDataVector, "StdoutAppend", "");        // Assign stderr file name and mode        String stderr = (String)processMap.get("stderrFile");        if (stderr != null && !stderr.equals(""))            addRow(procDataVector, "Stderr", stderr);        // Assign stderr mode        String stderrMode = (String)processMap.get("stderrMode");        if (stderrMode != null)        {            if (stderrMode.equalsIgnoreCase("stdout"))                addRow(procDataVector, "StderrToStdout", "");            else if (stderrMode.equalsIgnoreCase("append"))                addRow(procDataVector, "StderrAppend", "");        }        // Assign return stdout        String returnstdout = (String)processMap.get("returnStdout");        if (returnstdout != null)            addRow(procDataVector, "ReturnStdout", "");                // Assign return stderr        String returnstderr = (String)processMap.get("returnStderr");        if (returnstderr != null)            addRow(procDataVector, "ReturnStderr", "");                // Assign return file list        if (processMap.get("returnFileList") instanceof java.util.List)        {            java.util.List returnFileList = (java.util.List)processMap.get(                "returnFileList");            for (int i = 0; i < returnFileList.size(); i++)            {                addRow(procDataVector, "ReturnFile #" + (i + 1),                       (String)returnFileList.get(i));            }        }        // Assign static handle name        String statichandlename = (String)processMap.get("staticHandleName");        if (statichandlename != null)            addRow(procDataVector, "StaticHandleName", statichandlename);        // Assign other        String other = (String)processMap.get("other");        if (other != null && !other.equals(""))            addRow(procDataVector, "Other", other);                // Assign start date and time        String startTimestamp = (String)processMap.get("startTimestamp");        if (startTimestamp != null && !startTimestamp.equals(""))        {            String startDate = startTimestamp.substring(0, 8);            String startTime = startTimestamp.substring(9);            addRow(procDataVector, "Started", startDate + "-" + startTime);        }    }    private static void addRow(Vector vector, String name, String value)    {        Vector newRow = new Vector(2);        newRow.add(name);        newRow.add(value);        vector.add(newRow);    }}

⌨️ 快捷键说明

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