Search in sources :

Example 6 with TestCase

use of jp.ossc.nimbus.service.test.TestCase in project nimbus by nimbus-org.

the class TestCaseListPanel method setupTestCaseCompornents.

/**
 * テストケースコンポーネントのセットアップ
 * @throws Exception
 */
private void setupTestCaseCompornents() throws Exception {
    // 列間の余白
    int ROW_SPACE = 10;
    Font font = new Font("MS ゴシック", Font.BOLD, 16);
    int tmpX = 0;
    int tmpY = 0;
    String DATE_PATTERN = "yyyy/MM/dd HH:mm";
    SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_PATTERN);
    // 初期化
    this.removeAll();
    this.setLayout(null);
    int winWidth = this.getWidth();
    ROW_SPACE = (winWidth - (NO_WIDTH + START_DATE_WIDTH + END_DATE_WIDTH + STATE_WIDTH + STATE_WIDTH + START_BUTTON_WIDTH + END_BUTTON_WIDTH + DOWNLOAD_BUTTON_WIDTH + MARGIN + MARGIN)) / 2;
    ID_WIDTH = ROW_SPACE;
    TITLE_WIDTH = ROW_SPACE;
    // タイトル行のセットアップ
    JLabel label1 = new JLabel("No");
    JLabel label2 = new JLabel("テストケースID");
    JLabel label3 = new JLabel("テストケース名");
    JLabel label4 = new JLabel("開始日時");
    JLabel label5 = new JLabel("終了日時");
    JLabel label6 = new JLabel("エラー状態");
    JLabel label7 = new JLabel("状態");
    JLabel label8 = new JLabel(" ");
    JLabel label9 = new JLabel(" ");
    JLabel label10 = new JLabel(" ");
    label1.setFont(font);
    label2.setFont(font);
    label3.setFont(font);
    label4.setFont(font);
    label5.setFont(font);
    label6.setFont(font);
    label7.setFont(font);
    label8.setFont(font);
    label9.setFont(font);
    label10.setFont(font);
    tmpX += MARGIN;
    tmpY += MARGIN;
    label1.setBounds(tmpX, tmpY, NO_WIDTH, HEIGHT);
    tmpX += NO_WIDTH;
    label2.setBounds(tmpX, tmpY, ID_WIDTH, HEIGHT);
    tmpX += ID_WIDTH;
    label3.setBounds(tmpX, tmpY, TITLE_WIDTH, HEIGHT);
    tmpX += TITLE_WIDTH;
    label4.setBounds(tmpX, tmpY, START_DATE_WIDTH, HEIGHT);
    tmpX += START_DATE_WIDTH;
    label5.setBounds(tmpX, tmpY, END_DATE_WIDTH, HEIGHT);
    tmpX += END_DATE_WIDTH;
    label6.setBounds(tmpX, tmpY, STATE_WIDTH, HEIGHT);
    tmpX += STATE_WIDTH;
    label7.setBounds(tmpX, tmpY, STATE_WIDTH, HEIGHT);
    tmpX += STATE_WIDTH;
    label8.setBounds(tmpX, tmpY, START_BUTTON_WIDTH, HEIGHT);
    tmpX += START_BUTTON_WIDTH;
    label9.setBounds(tmpX, tmpY, END_BUTTON_WIDTH, HEIGHT);
    tmpX += END_BUTTON_WIDTH;
    label10.setBounds(tmpX, tmpY, DOWNLOAD_BUTTON_WIDTH, HEIGHT);
    this.add(label1);
    this.add(label2);
    this.add(label3);
    this.add(label4);
    this.add(label5);
    this.add(label6);
    this.add(label7);
    this.add(label8);
    this.add(label9);
    if (testCaseList != null) {
        boolean startTestCaseFlg = false;
        lineList = new ArrayList();
        for (int i = 0; i < testCaseList.size(); i++) {
            tmpX = MARGIN;
            tmpY += HEIGHT + MARGIN;
            TestCase testCase = (TestCase) testCaseList.get(i);
            label1 = new JLabel((new Integer(i + 1)).toString());
            label2 = new JLabel(testCase.getTestCaseId());
            label2.setToolTipText(testCase.getTestCaseId());
            label3 = new JLabel(testCase.getTestCaseResource().getTitle());
            label3.setToolTipText(testCase.getTestCaseResource().getTitle());
            label4 = new JLabel("");
            label5 = new JLabel("");
            label6 = new JLabel("");
            TestErrorStatusDispButton tmpErrorStatusButton = new TestErrorStatusDispButton(this.ownerFrame);
            Status status = null;
            try {
                status = testCase.getStatus();
            } catch (Exception e) {
            }
            label1.setFont(font);
            label2.setFont(font);
            label3.setFont(font);
            label4.setFont(font);
            label5.setFont(font);
            label6.setFont(font);
            Point xLinePoint = new Point(tmpX, tmpY - ((int) (MARGIN / 2)));
            label1.setBounds(tmpX, tmpY, NO_WIDTH, HEIGHT);
            tmpX += NO_WIDTH;
            label2.setBounds(tmpX, tmpY, ID_WIDTH, HEIGHT);
            tmpX += ID_WIDTH;
            label3.setBounds(tmpX, tmpY, TITLE_WIDTH, HEIGHT);
            tmpX += TITLE_WIDTH;
            label4.setBounds(tmpX, tmpY, START_DATE_WIDTH, HEIGHT);
            tmpX += START_DATE_WIDTH;
            label5.setBounds(tmpX, tmpY, END_DATE_WIDTH, HEIGHT);
            tmpX += END_DATE_WIDTH;
            tmpErrorStatusButton.setBounds(tmpX, tmpY, STATE_WIDTH, HEIGHT);
            tmpX += STATE_WIDTH;
            label6.setBounds(tmpX, tmpY, STATE_WIDTH, HEIGHT);
            tmpX += STATE_WIDTH;
            Point yLinePoint = new Point(tmpX, tmpY - ((int) (MARGIN / 2)));
            lineList.add(new Line(xLinePoint, yLinePoint));
            // 開始時間、終了時間、状態 を表示
            if (status != null) {
                if (status.getStartTime() != null)
                    label4.setText(dateFormat.format(status.getStartTime()));
                if (status.getEndTime() != null)
                    label5.setText(dateFormat.format(status.getEndTime()));
                label6.setText(status.getStateString());
            }
            tmpErrorStatusButton.change(status);
            JButton tmpButton1 = new JButton("開始");
            tmpButton1.addActionListener(new StartButtonActionListener(testCase));
            JButton tmpButton2 = new JButton("終了");
            tmpButton2.addActionListener(new EndButtonActionListener(testCase));
            JButton tmpButton3 = new JButton("結果DL");
            tmpButton3.addActionListener(new DownloadButtonActionListener(testCase));
            if (status != null && status.getState() == TestCase.Status.STARTED) {
                tmpButton1.setEnabled(false);
                tmpButton2.setEnabled(true);
                tmpButton3.setEnabled(false);
                startTestCaseFlg = true;
            } else if (status != null && (status.getState() == TestCase.Status.ERROR || !status.getResult())) {
                try {
                    testController.cancelTestCase(scenarioId, testCase.getTestCaseId());
                } catch (Exception e2) {
                    e2.printStackTrace();
                }
                tmpButton1.setEnabled(true);
                tmpButton2.setEnabled(false);
                tmpButton3.setEnabled(true);
            } else {
                if (!startTestCaseFlg) {
                    tmpButton1.setEnabled(true);
                } else {
                    tmpButton1.setEnabled(false);
                }
                tmpButton2.setEnabled(false);
                tmpButton3.setEnabled(false);
            }
            tmpButton1.setFont(font);
            tmpButton2.setFont(font);
            tmpButton3.setFont(font);
            tmpButton1.setBounds(tmpX, tmpY, START_BUTTON_WIDTH, HEIGHT);
            tmpX += START_BUTTON_WIDTH;
            tmpButton2.setBounds(tmpX, tmpY, END_BUTTON_WIDTH, HEIGHT);
            tmpX += END_BUTTON_WIDTH;
            tmpButton3.setBounds(tmpX, tmpY, DOWNLOAD_BUTTON_WIDTH, HEIGHT);
            this.add(label1);
            this.add(label2);
            this.add(label3);
            this.add(label4);
            this.add(label5);
            this.add(tmpErrorStatusButton);
            this.add(label6);
            this.add(tmpButton1);
            this.add(tmpButton2);
            this.add(tmpButton3);
        }
    }
    int tmpW = winWidth;
    int tmpH = tmpY + HEIGHT + MARGIN;
    this.setPreferredSize(new Dimension(tmpW, tmpH));
    this.repaint();
}
Also used : Status(jp.ossc.nimbus.service.test.TestCase.Status) ArrayList(java.util.ArrayList) JButton(javax.swing.JButton) JLabel(javax.swing.JLabel) Point(java.awt.Point) Dimension(java.awt.Dimension) Point(java.awt.Point) Font(java.awt.Font) TestCase(jp.ossc.nimbus.service.test.TestCase) SimpleDateFormat(java.text.SimpleDateFormat)

Example 7 with TestCase

use of jp.ossc.nimbus.service.test.TestCase in project nimbus by nimbus-org.

the class CSVTestReporterService method report.

public void report(TestController controller) {
    CSVWriter writer = csvWriter == null ? new CSVWriter() : csvWriter.cloneWriter();
    if (writer.getNullValue() == null) {
        writer.setNullValue("");
    }
    List csv = new ArrayList();
    try {
        BufferedWriter bw = new BufferedWriter(encoding == null ? new FileWriter(outputFile) : new OutputStreamWriter(new FileOutputStream(outputFile), encoding));
        writer.setWriter(bw);
        Set scenarioGroupCategorySet = new TreeSet();
        Set scenarioCategorySet = new TreeSet();
        Set testcaseCategorySet = new TreeSet();
        TestScenarioGroup[] groups = controller.getScenarioGroups();
        for (int i = 0; i < groups.length; i++) {
            TestScenarioGroup.TestScenarioGroupResource sgr = groups[i].getTestScenarioGroupResource();
            if (sgr != null) {
                Map categoryMap = sgr.getCategoryMap();
                if (categoryMap.size() != 0) {
                    scenarioGroupCategorySet.addAll(categoryMap.keySet());
                }
            }
            TestScenario[] scenarios = controller.getScenarios(groups[i].getScenarioGroupId());
            for (int j = 0; j < scenarios.length; j++) {
                TestScenario.TestScenarioResource sr = scenarios[j].getTestScenarioResource();
                if (sr != null) {
                    Map categoryMap = sr.getCategoryMap();
                    if (categoryMap.size() != 0) {
                        scenarioCategorySet.addAll(categoryMap.keySet());
                    }
                }
                TestCase[] testcases = controller.getTestCases(groups[i].getScenarioGroupId(), scenarios[j].getScenarioId());
                for (int k = 0; k < testcases.length; k++) {
                    TestCase.TestCaseResource tr = testcases[k].getTestCaseResource();
                    if (tr != null) {
                        Map categoryMap = tr.getCategoryMap();
                        if (categoryMap.size() != 0) {
                            testcaseCategorySet.addAll(categoryMap.keySet());
                        }
                    }
                }
            }
        }
        csv.add("ScenarioGroupId");
        Iterator categories = scenarioGroupCategorySet.iterator();
        while (categories.hasNext()) {
            String categoryName = (String) categories.next();
            csv.add(categoryName);
        }
        csv.add("Title");
        csv.add("Description");
        csv.add("UserId");
        csv.add("StartTime");
        csv.add("EndTime");
        csv.add("State");
        csv.add("Result");
        csv.add("Exception");
        csv.add("ActionId");
        csv.add("Title");
        csv.add("Description");
        csv.add("ActionType");
        csv.add("Result");
        csv.add("Exception");
        csv.add("ScenarioId");
        categories = scenarioCategorySet.iterator();
        while (categories.hasNext()) {
            String categoryName = (String) categories.next();
            csv.add(categoryName);
        }
        csv.add("Title");
        csv.add("Description");
        csv.add("UserId");
        csv.add("StartTime");
        csv.add("EndTime");
        csv.add("State");
        csv.add("Result");
        csv.add("Exception");
        csv.add("ActionId");
        csv.add("Title");
        csv.add("Description");
        csv.add("ActionType");
        csv.add("Result");
        csv.add("Exception");
        csv.add("TestcaseId");
        categories = testcaseCategorySet.iterator();
        while (categories.hasNext()) {
            String categoryName = (String) categories.next();
            csv.add(categoryName);
        }
        csv.add("Title");
        csv.add("Description");
        csv.add("UserId");
        csv.add("StartTime");
        csv.add("EndTime");
        csv.add("State");
        csv.add("Result");
        csv.add("Exception");
        csv.add("ActionId");
        csv.add("Title");
        csv.add("Description");
        csv.add("ActionType");
        csv.add("Result");
        csv.add("Exception");
        writer.writeCSV(csv);
        for (int i = 0; i < groups.length; i++) {
            TestScenarioGroup.TestScenarioGroupResource sgr = groups[i].getTestScenarioGroupResource();
            csv.clear();
            addScenarioGroupElements(csv, groups[i], sgr, scenarioGroupCategorySet, null, null, true);
            addScenarioElements(csv, null, null, scenarioCategorySet, null, null, false);
            addTestCaseElements(csv, null, null, testcaseCategorySet, null, null, false);
            writer.writeCSV(csv);
            if (sgr != null) {
                String[] actionIds = sgr.getBeforeActionIds();
                if (actionIds != null) {
                    for (int j = 0; j < actionIds.length; j++) {
                        csv.clear();
                        addScenarioGroupElements(csv, groups[i], sgr, scenarioGroupCategorySet, actionIds[j], "before", false);
                        addScenarioElements(csv, null, null, scenarioCategorySet, null, null, false);
                        addTestCaseElements(csv, null, null, testcaseCategorySet, null, null, false);
                        writer.writeCSV(csv);
                    }
                }
                actionIds = sgr.getFinallyActionIds();
                if (actionIds != null) {
                    for (int j = 0; j < actionIds.length; j++) {
                        csv.clear();
                        addScenarioGroupElements(csv, groups[i], sgr, scenarioGroupCategorySet, actionIds[j], "finally", false);
                        addScenarioElements(csv, null, null, scenarioCategorySet, null, null, false);
                        addTestCaseElements(csv, null, null, testcaseCategorySet, null, null, false);
                        writer.writeCSV(csv);
                    }
                }
            }
            TestScenario[] scenarios = controller.getScenarios(groups[i].getScenarioGroupId());
            for (int j = 0; j < scenarios.length; j++) {
                TestScenario.TestScenarioResource sr = scenarios[j].getTestScenarioResource();
                csv.clear();
                addScenarioGroupElements(csv, groups[i], sgr, scenarioGroupCategorySet, null, null, false);
                addScenarioElements(csv, scenarios[j], sr, scenarioCategorySet, null, null, true);
                addTestCaseElements(csv, null, null, testcaseCategorySet, null, null, false);
                writer.writeCSV(csv);
                if (sr != null) {
                    String[] actionIds = sr.getBeforeActionIds();
                    if (actionIds != null) {
                        for (int k = 0; k < actionIds.length; k++) {
                            csv.clear();
                            addScenarioGroupElements(csv, groups[i], sgr, scenarioGroupCategorySet, null, null, false);
                            addScenarioElements(csv, scenarios[j], sr, scenarioCategorySet, actionIds[k], "before", false);
                            addTestCaseElements(csv, null, null, testcaseCategorySet, null, null, false);
                            writer.writeCSV(csv);
                        }
                    }
                    actionIds = sr.getAfterActionIds();
                    if (actionIds != null) {
                        for (int k = 0; k < actionIds.length; k++) {
                            csv.clear();
                            addScenarioGroupElements(csv, groups[i], sgr, scenarioGroupCategorySet, null, null, false);
                            addScenarioElements(csv, scenarios[j], sr, scenarioCategorySet, actionIds[k], "after", false);
                            addTestCaseElements(csv, null, null, testcaseCategorySet, null, null, false);
                            writer.writeCSV(csv);
                        }
                    }
                    actionIds = sr.getFinallyActionIds();
                    if (actionIds != null) {
                        for (int k = 0; k < actionIds.length; k++) {
                            csv.clear();
                            addScenarioGroupElements(csv, groups[i], sgr, scenarioGroupCategorySet, null, null, false);
                            addScenarioElements(csv, scenarios[j], sr, scenarioCategorySet, actionIds[k], "finally", false);
                            addTestCaseElements(csv, null, null, testcaseCategorySet, null, null, false);
                            writer.writeCSV(csv);
                        }
                    }
                }
                TestCase[] testcases = controller.getTestCases(groups[i].getScenarioGroupId(), scenarios[j].getScenarioId());
                for (int k = 0; k < testcases.length; k++) {
                    TestCase.TestCaseResource tr = testcases[k].getTestCaseResource();
                    csv.clear();
                    addScenarioGroupElements(csv, groups[i], sgr, scenarioGroupCategorySet, null, null, false);
                    addScenarioElements(csv, scenarios[j], sr, scenarioCategorySet, null, null, false);
                    addTestCaseElements(csv, testcases[k], tr, testcaseCategorySet, null, null, true);
                    writer.writeCSV(csv);
                    if (tr != null) {
                        String[] actionIds = tr.getBeforeActionIds();
                        if (actionIds != null) {
                            for (int l = 0; l < actionIds.length; l++) {
                                csv.clear();
                                addScenarioGroupElements(csv, groups[i], sgr, scenarioGroupCategorySet, null, null, false);
                                addScenarioElements(csv, scenarios[j], sr, scenarioCategorySet, null, null, false);
                                addTestCaseElements(csv, testcases[k], tr, testcaseCategorySet, actionIds[l], "before", false);
                                writer.writeCSV(csv);
                            }
                        }
                        actionIds = tr.getActionIds();
                        if (actionIds != null) {
                            for (int l = 0; l < actionIds.length; l++) {
                                csv.clear();
                                addScenarioGroupElements(csv, groups[i], sgr, scenarioGroupCategorySet, null, null, false);
                                addScenarioElements(csv, scenarios[j], sr, scenarioCategorySet, null, null, false);
                                addTestCaseElements(csv, testcases[k], tr, testcaseCategorySet, actionIds[l], "action", false);
                                writer.writeCSV(csv);
                            }
                        }
                        actionIds = tr.getAfterActionIds();
                        if (actionIds != null) {
                            for (int l = 0; l < actionIds.length; l++) {
                                csv.clear();
                                addScenarioGroupElements(csv, groups[i], sgr, scenarioGroupCategorySet, null, null, false);
                                addScenarioElements(csv, scenarios[j], sr, scenarioCategorySet, null, null, false);
                                addTestCaseElements(csv, testcases[k], tr, testcaseCategorySet, actionIds[l], "after", false);
                                writer.writeCSV(csv);
                            }
                        }
                        actionIds = tr.getFinallyActionIds();
                        if (actionIds != null) {
                            for (int l = 0; l < actionIds.length; l++) {
                                csv.clear();
                                addScenarioGroupElements(csv, groups[i], sgr, scenarioGroupCategorySet, null, null, false);
                                addScenarioElements(csv, scenarios[j], sr, scenarioCategorySet, null, null, false);
                                addTestCaseElements(csv, testcases[k], tr, testcaseCategorySet, actionIds[l], "finally", false);
                                writer.writeCSV(csv);
                            }
                        }
                    }
                }
            }
        }
    } catch (Exception e) {
        ServiceManagerFactory.getLogger().write("CTR__00001", e);
        return;
    } finally {
        try {
            writer.flush();
        } catch (IOException e) {
        }
        try {
            writer.close();
        } catch (IOException e) {
        }
    }
}
Also used : Set(java.util.Set) TreeSet(java.util.TreeSet) TestScenario(jp.ossc.nimbus.service.test.TestScenario) FileWriter(java.io.FileWriter) TestScenarioGroup(jp.ossc.nimbus.service.test.TestScenarioGroup) ArrayList(java.util.ArrayList) CSVWriter(jp.ossc.nimbus.io.CSVWriter) BufferedWriter(java.io.BufferedWriter) TreeSet(java.util.TreeSet) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) IOException(java.io.IOException) IOException(java.io.IOException) TestCase(jp.ossc.nimbus.service.test.TestCase) FileOutputStream(java.io.FileOutputStream) OutputStreamWriter(java.io.OutputStreamWriter) Map(java.util.Map)

Example 8 with TestCase

use of jp.ossc.nimbus.service.test.TestCase in project nimbus by nimbus-org.

the class CSVTestReporterService method addTestCaseElements.

protected void addTestCaseElements(List csv, TestCase testCase, TestCase.TestCaseResource resource, Set categoryNameSet, String actionId, String actionType, boolean isOutputStatus) throws Exception {
    if (testCase == null) {
        csv.add(null);
    } else {
        csv.add(testCase.getTestCaseId());
    }
    Iterator categories = categoryNameSet.iterator();
    Map categoryMap = resource == null ? null : resource.getCategoryMap();
    while (categories.hasNext()) {
        String categoryName = (String) categories.next();
        csv.add(categoryMap == null ? null : categoryMap.get(categoryName));
    }
    if (resource != null) {
        csv.add(resource.getTitle());
        csv.add(resource.getDescription());
    } else {
        csv.add(null);
        csv.add(null);
    }
    TestCase.Status status = resource == null ? null : testCase.getStatus();
    final boolean isNotRun = status == null || status.getState() == TestCase.Status.INITIAL;
    if (status == null || !isOutputStatus) {
        csv.add(null);
        csv.add(null);
        csv.add(null);
        csv.add(null);
        csv.add(null);
        csv.add(null);
    } else {
        SimpleDateFormat format = new SimpleDateFormat(dateFormat);
        csv.add(status.getUserId());
        csv.add(status.getStartTime() == null ? null : format.format(status.getStartTime()));
        csv.add(status.getEndTime() == null ? null : format.format(status.getEndTime()));
        csv.add(status.getStateString());
        if (isNotRun) {
            csv.add(null);
            csv.add(null);
        } else {
            boolean result = status.getResult();
            if (result) {
                csv.add("OK");
                csv.add(null);
            } else {
                if (status.getThrowable() == null) {
                    csv.add("NG");
                    csv.add(null);
                } else {
                    csv.add("ERROR");
                    csv.add(toStackTraceString(status.getThrowable()));
                }
            }
        }
    }
    csv.add(actionId);
    if (resource == null || actionId == null) {
        csv.add(null);
        csv.add(null);
    } else {
        csv.add(resource.getActionTitle(actionId));
        csv.add(resource.getActionDescription(actionId));
    }
    csv.add(actionType);
    if (status == null || isNotRun) {
        csv.add(null);
        csv.add(null);
    } else {
        if (actionId == null) {
            csv.add(null);
            csv.add(toStackTraceString(status.getThrowable()));
        } else {
            boolean actionResult = status.getActionResult(actionId);
            if (actionResult) {
                csv.add("OK");
                csv.add(null);
            } else {
                if (status.getThrowable() == null) {
                    csv.add("NG");
                    csv.add(null);
                } else {
                    if (actionId.equals(status.getCurrentActionId())) {
                        csv.add("ERROR");
                        csv.add(toStackTraceString(status.getThrowable()));
                    } else {
                        csv.add(null);
                        csv.add(null);
                    }
                }
            }
        }
    }
}
Also used : TestCase(jp.ossc.nimbus.service.test.TestCase) Iterator(java.util.Iterator) Map(java.util.Map) SimpleDateFormat(java.text.SimpleDateFormat)

Example 9 with TestCase

use of jp.ossc.nimbus.service.test.TestCase in project nimbus by nimbus-org.

the class ConsoleTestReporterService method report.

public void report(TestController controller) {
    TestResult result = new TestResult();
    try {
        TestScenarioGroup[] groups = controller.getScenarioGroups();
        for (int i = 0; i < groups.length; i++) {
            TestScenarioGroup.Status groupStatus = groups[i].getStatus();
            if (groupStatus == null) {
                continue;
            }
            Date startTime = groupStatus.getStartTime();
            if (startTime == null) {
                continue;
            }
            ScenarioGroupResult scenarioGroupResult = new ScenarioGroupResult(groups[i]);
            result.add(scenarioGroupResult);
            TestScenario[] scenarios = controller.getScenarios(groups[i].getScenarioGroupId());
            for (int j = 0; j < scenarios.length; j++) {
                TestScenario.Status scenarioStatus = scenarios[j].getStatus();
                if (scenarioStatus == null) {
                    continue;
                }
                startTime = scenarioStatus.getStartTime();
                if (startTime == null) {
                    continue;
                }
                ScenarioResult scenarioResult = new ScenarioResult(scenarios[j]);
                scenarioGroupResult.add(scenarioResult);
                TestCase[] testcases = controller.getTestCases(groups[i].getScenarioGroupId(), scenarios[j].getScenarioId());
                for (int k = 0; k < testcases.length; k++) {
                    TestCase.Status testcaseStatus = testcases[k].getStatus();
                    if (testcaseStatus == null) {
                        continue;
                    }
                    startTime = testcaseStatus.getStartTime();
                    if (startTime == null) {
                        continue;
                    }
                    TestCaseResult testCaseResult = new TestCaseResult(testcases[k]);
                    scenarioResult.add(testCaseResult);
                }
            }
        }
    } catch (Exception e) {
        ServiceManagerFactory.getLogger().write("CTR__00001", e);
        return;
    }
    System.out.println(result);
    Iterator groupItr = result.scenarioGroupResultMap.values().iterator();
    while (groupItr.hasNext()) {
        ScenarioGroupResult group = (ScenarioGroupResult) groupItr.next();
        System.out.println();
        System.out.println(group.toString());
        System.out.println(group.toSummuryString());
        Iterator scenarios = group.scenarioResultMap.values().iterator();
        while (scenarios.hasNext()) {
            ScenarioResult scenario = (ScenarioResult) scenarios.next();
            System.out.println();
            System.out.println("\t" + scenario.toString());
            System.out.println("\t" + scenario.toSummuryString());
            Iterator testcases = scenario.testcaseResultMap.values().iterator();
            while (testcases.hasNext()) {
                TestCaseResult testcase = (TestCaseResult) testcases.next();
                System.out.println();
                System.out.println("\t\t" + testcase.toString());
            }
        }
    }
}
Also used : TestScenario(jp.ossc.nimbus.service.test.TestScenario) TestScenarioGroup(jp.ossc.nimbus.service.test.TestScenarioGroup) Date(java.util.Date) TestCase(jp.ossc.nimbus.service.test.TestCase) Iterator(java.util.Iterator)

Example 10 with TestCase

use of jp.ossc.nimbus.service.test.TestCase in project nimbus by nimbus-org.

the class HtmlTestCaseProgressReporterService method reportScenarioGroup.

private void reportScenarioGroup(PrintWriter pw, TestController controller, TestScenarioGroup group) throws Exception {
    TestScenario[] scenarios = controller.getScenarios(group.getScenarioGroupId());
    Map scenarioTestcaseMap = new TreeMap();
    int testCaseCount = 0;
    for (int index = 0; index < scenarios.length; index++) {
        TestCase[] cases = controller.getTestCases(group.getScenarioGroupId(), scenarios[index].getScenarioId());
        if (cases.length == 0) {
            testCaseCount++;
        } else {
            testCaseCount += cases.length;
        }
        scenarioTestcaseMap.put(scenarios[index].getScenarioId(), cases);
    }
    TestScenarioGroupResource groupResource = group.getTestScenarioGroupResource();
    pw.println("<tr>");
    printResource(pw, groupResource, group.getScenarioGroupId(), "rowgroup", testCaseCount);
    Iterator ite = scenarioTestcaseMap.keySet().iterator();
    boolean isFirst = true;
    while (ite.hasNext()) {
        String scenarioId = (String) ite.next();
        TestScenario testScenario = controller.getScenario(group.getScenarioGroupId(), scenarioId);
        TestScenario.TestScenarioResource testScenarioResource = testScenario.getTestScenarioResource();
        if (testScenarioResource == null) {
            continue;
        }
        TestCase[] cases = (TestCase[]) scenarioTestcaseMap.get(scenarioId);
        int count = cases.length;
        if (count == 0) {
            count = 1;
        }
        if (!isFirst) {
            pw.println("<tr>");
        }
        isFirst = false;
        printResource(pw, testScenarioResource, scenarioId, "rowgroup", count);
        if (cases.length == 0) {
            pw.println("</tr>");
        } else {
            printResource(pw, cases[0].getTestCaseResource(), cases[0].getTestCaseId(), "row", 0);
            pw.println("</tr>");
            for (int index = 1; index < cases.length; index++) {
                pw.println("<tr>");
                printResource(pw, cases[index].getTestCaseResource(), cases[index].getTestCaseId(), "row", 0);
                pw.println("</tr>");
            }
        }
    }
}
Also used : TestScenarioGroupResource(jp.ossc.nimbus.service.test.TestScenarioGroup.TestScenarioGroupResource) TestCase(jp.ossc.nimbus.service.test.TestCase) TestScenario(jp.ossc.nimbus.service.test.TestScenario) Iterator(java.util.Iterator) TreeMap(java.util.TreeMap) TreeMap(java.util.TreeMap) Map(java.util.Map)

Aggregations

TestCase (jp.ossc.nimbus.service.test.TestCase)10 TestScenario (jp.ossc.nimbus.service.test.TestScenario)7 Iterator (java.util.Iterator)5 Map (java.util.Map)5 TestScenarioGroup (jp.ossc.nimbus.service.test.TestScenarioGroup)5 ArrayList (java.util.ArrayList)4 SimpleDateFormat (java.text.SimpleDateFormat)3 List (java.util.List)3 FileOutputStream (java.io.FileOutputStream)2 IOException (java.io.IOException)2 TreeMap (java.util.TreeMap)2 Dimension (java.awt.Dimension)1 Font (java.awt.Font)1 Point (java.awt.Point)1 BufferedWriter (java.io.BufferedWriter)1 FileWriter (java.io.FileWriter)1 OutputStreamWriter (java.io.OutputStreamWriter)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 Set (java.util.Set)1