Package com.eviware.soapui.model.testsuite

Examples of com.eviware.soapui.model.testsuite.TestCase


            Project project = findProject(projectFilePath, workspace);

            project = openProject(projectFilePath, workspace, project);

            TestSuite testSuite = project.getTestSuiteByName(testSuiteName);
            TestCase testCase = testSuite.getTestCaseByName(testCaseName);

            showModelItem(testCase);
            bringToFront();
        } catch (Exception e) {
            SoapUI.logError(e);
View Full Code Here


        @Override
        public void afterTestStep(LoadTestRunner loadTestRunner, LoadTestRunContext context, TestCaseRunner testRunner,
                                  TestCaseRunContext runContext, TestStepResult testStepResult) {
            if (loadTest.getUpdateStatisticsPerTestStep()) {
                TestCase testCase = testRunner.getTestCase();

                if (testStepResult == null) {
                    log.warn("Result is null in TestCase [" + testCase.getName() + "]");
                    return;
                }

                long[] samples = new long[testCase.getTestStepCount()];
                long[] sizes = new long[samples.length];
                long[] sampleCounts = new long[samples.length];

                int index = testCase.getIndexOfTestStep(testStepResult.getTestStep());
                sampleCounts[index]++;

                samples[index] += testStepResult.getTimeTaken();
                sizes[index] += testStepResult.getSize();
View Full Code Here

                    && testRunner.getReason().equals(NO_STATS_TESTCASE_CANCEL_REASON)) {
                return;
            }

            List<TestStepResult> results = testRunner.getResults();
            TestCase testCase = testRunner.getTestCase();

            long[] samples = new long[testCase.getTestStepCount()];
            long[] sizes = new long[samples.length];
            long[] sampleCounts = new long[samples.length];

            for (int c = 0; c < results.size(); c++) {
                TestStepResult testStepResult = results.get(c);
                if (testStepResult == null) {
                    log.warn("Result [" + c + "] is null in TestCase [" + testCase.getName() + "]");
                    continue;
                }

                int index = testCase.getIndexOfTestStep(testStepResult.getTestStep());
                if (index >= 0) {
                    sampleCounts[index]++;

                    samples[index] += testStepResult.getTimeTaken();
                    sizes[index] += testStepResult.getSize();
View Full Code Here

                    if (entitize) {
                        propertyValue = XmlUtils.entitize(propertyValue);
                    }

                    TestCase testCase = ModelSupport.getModelItemTestCase(context.getModelItem());
                    if (debuggingMode && testCase != null) {
                        StringToStringMap props = debuggingExpandedProperties.get(testCase.getId());
                        if (props == null) {
                            props = new StringToStringMap();
                        }
                        props.put(propertyName, propertyValue);
                        debuggingExpandedProperties.put(testCase.getId(), props);
                    }
                    buf.append(propertyValue);
                } else {
                    // if( log.isEnabledFor( Priority.WARN ))
                    // log.warn( "Missing property value for [" + propertyName + "]"
View Full Code Here

            return items;
        }

        Project project = securityScan.getTestStep().getTestCase().getTestSuite().getProject();
        TestSuite targetTestSuite = project.getTestSuiteByName(targetTestSuiteName);
        TestCase targetTestCase = targetTestSuite.getTestCaseByName(targetTestCaseName);
        SecurityTest targetSecurityTest = targetTestCase.getSecurityTestByName(targetSecurityTestName);
        TestStep targetTestStep = targetTestCase.getTestStepByName(targetSecurityTestStepName);

        boolean overwrite = dialog.getBooleanValue(CloneParameterDialog.OVERWRITE);

        for (String scanName : targetSecurityScans) {
            AbstractSecurityScanWithProperties targetSecurityScan = (AbstractSecurityScanWithProperties) targetSecurityTest
View Full Code Here

        okAction.setDialog(dialog);
        cancelAction.setDialog(dialog);
        applyAction.setDialog(dialog);

        final TestCase testCase = securityScan.getTestStep().getTestCase();
        final Project project = testCase.getTestSuite().getProject();

        dialog.getFormField(CloneParameterDialog.TARGET_TESTSUITE).addFormFieldListener(new XFormFieldListener() {
            public void valueChanged(XFormField sourceField, String newValue, String oldValue) {
                TestSuite testSuite = project.getTestSuiteByName(newValue);
                String[] testCaseNames = ModelSupport.getNames(testSuite.getTestCaseList());
                dialog.setOptions(CloneParameterDialog.TARGET_TESTCASE, testCaseNames);

                if (testCaseNames.length > 0) {
                    dialog.setValue(CloneParameterDialog.TARGET_TESTCASE, testCaseNames[0]);
                    TestCase testCase = testSuite.getTestCaseByName(testCaseNames[0]);

                    String[] testStepNames = new String[0];
                    String[] securityTestNames = ModelSupport.getNames(testCase.getSecurityTestList());
                    dialog.setOptions(CloneParameterDialog.TARGET_SECURITYTEST, securityTestNames);
                    if (securityTestNames.length > 0) {
                        testStepNames = getSecurableTestStepsNames(testCase);
                    }
                    dialog.setOptions(CloneParameterDialog.TARGET_TESTSTEP, testStepNames);

                    if (securityTestNames.length > 0) {
                        dialog.setValue(CloneParameterDialog.TARGET_SECURITYTEST, securityTestNames[0]);
                        if (testStepNames.length > 0) {
                            dialog.setValue(CloneParameterDialog.TARGET_TESTSTEP, testStepNames[0]);
                        } else {
                            dialog.setOptions(CloneParameterDialog.TARGET_TESTSTEP, new String[0]);
                        }

                        String securityTestName = dialog.getValue(CloneParameterDialog.TARGET_SECURITYTEST);
                        SecurityTest securityTest = testCase.getSecurityTestByName(securityTestName);
                        String testStepName = dialog.getValue(CloneParameterDialog.TARGET_TESTSTEP);
                        TestStep testStep = testCase.getTestStepByName(testStepName);
                        String[] securityScanNames = ModelSupport.getNames(securityTest.getTestStepSecurityScanByType(
                                testStep.getId(), AbstractSecurityScanWithProperties.class));
                        dialog.setOptions(CloneParameterDialog.TARGET_SECURITYSCAN, securityScanNames);
                    } else {
                        dialog.setOptions(CloneParameterDialog.TARGET_SECURITYTEST, new String[0]);
                        dialog.setOptions(CloneParameterDialog.TARGET_TESTSTEP, new String[0]);
                        dialog.setOptions(CloneParameterDialog.TARGET_SECURITYSCAN, new String[0]);
                    }
                } else {
                    dialog.setOptions(CloneParameterDialog.TARGET_SECURITYTEST, new String[0]);
                    dialog.setOptions(CloneParameterDialog.TARGET_TESTSTEP, new String[0]);
                }
            }
        });
        dialog.getFormField(CloneParameterDialog.TARGET_TESTCASE).addFormFieldListener(new XFormFieldListener() {
            public void valueChanged(XFormField sourceField, String newValue, String oldValue) {
                String testSuiteName = dialog.getValue(CloneParameterDialog.TARGET_TESTSUITE);
                TestSuite testSuite = project.getTestSuiteByName(testSuiteName);
                TestCase testCase = testSuite.getTestCaseByName(newValue);

                String[] testStepNames = new String[0];
                String[] securityTestNames = ModelSupport.getNames(testCase.getSecurityTestList());
                dialog.setOptions(CloneParameterDialog.TARGET_SECURITYTEST, securityTestNames);
                if (securityTestNames.length > 0) {
                    testStepNames = getSecurableTestStepsNames(testCase);
                }
                dialog.setOptions(CloneParameterDialog.TARGET_TESTSTEP, testStepNames);

                if (securityTestNames.length > 0) {
                    dialog.setValue(CloneParameterDialog.TARGET_SECURITYTEST, securityTestNames[0]);
                    if (testStepNames.length > 0) {
                        dialog.setValue(CloneParameterDialog.TARGET_TESTSTEP, testStepNames[0]);
                    } else {
                        dialog.setOptions(CloneParameterDialog.TARGET_TESTSTEP, new String[0]);
                    }

                    String securityTestName = dialog.getValue(CloneParameterDialog.TARGET_SECURITYTEST);
                    SecurityTest securityTest = testCase.getSecurityTestByName(securityTestName);
                    String testStepName = dialog.getValue(CloneParameterDialog.TARGET_TESTSTEP);
                    TestStep testStep = testCase.getTestStepByName(testStepName);
                    String[] securityScanNames = ModelSupport.getNames(securityTest.getTestStepSecurityScanByType(
                            testStep.getId(), AbstractSecurityScanWithProperties.class));
                    dialog.setOptions(CloneParameterDialog.TARGET_SECURITYSCAN, securityScanNames);
                } else {
                    dialog.setOptions(CloneParameterDialog.TARGET_SECURITYTEST, new String[0]);
                    dialog.setOptions(CloneParameterDialog.TARGET_TESTSTEP, new String[0]);
                    dialog.setOptions(CloneParameterDialog.TARGET_SECURITYSCAN, new String[0]);
                }
            }
        });
        dialog.getFormField(CloneParameterDialog.TARGET_TESTSTEP).addFormFieldListener(new XFormFieldListener() {
            public void valueChanged(XFormField sourceField, String newValue, String oldValue) {
                String testSuiteName = dialog.getValue(CloneParameterDialog.TARGET_TESTSUITE);
                TestSuite testSuite = project.getTestSuiteByName(testSuiteName);
                String testCaseName = dialog.getValue(CloneParameterDialog.TARGET_TESTCASE);
                TestCase testCase = testSuite.getTestCaseByName(testCaseName);
                String securityTestName = dialog.getValue(CloneParameterDialog.TARGET_SECURITYTEST);
                SecurityTest securityTest = testCase.getSecurityTestByName(securityTestName);
                TestStep testStep = testCase.getTestStepByName(newValue);

                String[] securityScanNames = ModelSupport.getNames(securityTest.getTestStepSecurityScanByType(
                        testStep.getId(), AbstractSecurityScanWithProperties.class));
                dialog.setOptions(CloneParameterDialog.TARGET_SECURITYSCAN, securityScanNames);
            }
        });
        dialog.getFormField(CloneParameterDialog.TARGET_SECURITYTEST).addFormFieldListener(new XFormFieldListener() {
            public void valueChanged(XFormField sourceField, String newValue, String oldValue) {
                String testSuiteName = dialog.getValue(CloneParameterDialog.TARGET_TESTSUITE);
                TestSuite testSuite = project.getTestSuiteByName(testSuiteName);
                String testCaseName = dialog.getValue(CloneParameterDialog.TARGET_TESTCASE);
                TestCase testCase = testSuite.getTestCaseByName(testCaseName);
                SecurityTest securityTest = testCase.getSecurityTestByName(newValue);
                String testStepName = dialog.getValue(CloneParameterDialog.TARGET_TESTSTEP);
                TestStep testStep = testCase.getTestStepByName(testStepName);

                String[] securityScanNames = ModelSupport.getNames(securityTest.getTestStepSecurityScanByType(
                        testStep.getId(), AbstractSecurityScanWithProperties.class));
                dialog.setOptions(CloneParameterDialog.TARGET_SECURITYSCAN, securityScanNames);
            }
View Full Code Here

        // start by listening to all testcases.. (since one testcase can call
        // another)
        for (int c = 0; c < project.getTestSuiteCount(); c++) {
            TestSuite suite = project.getTestSuiteAt(c);
            for (int i = 0; i < suite.getTestCaseCount(); i++) {
                TestCase tc = suite.getTestCaseAt(i);
                if ((testSuite == null || suite.getName().equals(testSuite)) && testCase != null
                        && tc.getName().equals(testCase)) {
                    testCasesToRun.add(tc);
                }

                addListeners(tc);
            }
        }

        try {
            // validate testSuite argument
            if (testCase != null && testCasesToRun.size() == 0) {
                if (testSuite == null) {
                    throw new Exception("TestCase with name [" + testCase + "] is missing in Project [" + project.getName()
                            + "]");
                } else {
                    throw new Exception("TestCase with name [" + testCase + "] in TestSuite [" + testSuite
                            + "] is missing in Project [" + project.getName() + "]");
                }
            }

            // decide what to run
            if (testCasesToRun.size() > 0) {
                for (TestCase testCase : testCasesToRun) {
                    runTestCase((WsdlTestCase) testCase);
                }
            } else if (testSuite != null) {
                WsdlTestSuite ts = project.getTestSuiteByName(testSuite);
                if (ts == null) {
                    throw new Exception("TestSuite with name [" + testSuite + "] not found in project");
                } else {
                    runSuite(ts);
                }
            } else {
                runProject(project);
            }

            long timeTaken = (System.nanoTime() - startTime) / 1000000;

            if (printReport) {
                printReport(timeTaken);
            }

            exportReports(project);

            if (saveAfterRun && !project.isRemote()) {
                try {
                    project.save();
                } catch (Throwable t) {
                    log.error("Failed to save project", t);
                }
            }

            if ((assertions.size() > 0 || failedTests.size() > 0) && !ignoreErrors) {
                throwFailureException();
            }

            return true;
        } finally {
            for (int c = 0; c < project.getTestSuiteCount(); c++) {
                TestSuite suite = project.getTestSuiteAt(c);
                for (int i = 0; i < suite.getTestCaseCount(); i++) {
                    TestCase tc = suite.getTestCaseAt(i);
                    removeListeners(tc);
                }
            }
        }
    }
View Full Code Here

        if (result.getStatus() == TestStepStatus.FAILED || exportAll) {
            try {
                String exportSeparator = System.getProperty(SOAPUI_EXPORT_SEPARATOR, "-");

                TestCase tc = currentStep.getTestCase();
                String nameBase = StringUtils.createFileName(tc.getTestSuite().getName(), '_') + exportSeparator
                        + StringUtils.createFileName(tc.getName(), '_') + exportSeparator
                        + StringUtils.createFileName(currentStep.getName(), '_') + "-" + count.longValue() + "-"
                        + result.getStatus();

                WsdlTestCaseRunner callingTestCaseRunner = (WsdlTestCaseRunner) runContext
                        .getProperty("#CallingTestCaseRunner#");

                if (callingTestCaseRunner != null) {
                    WsdlTestCase ctc = callingTestCaseRunner.getTestCase();
                    WsdlRunTestCaseTestStep runTestCaseTestStep = (WsdlRunTestCaseTestStep) runContext
                            .getProperty("#CallingRunTestCaseStep#");

                    nameBase = StringUtils.createFileName(ctc.getTestSuite().getName(), '_') + exportSeparator
                            + StringUtils.createFileName(ctc.getName(), '_') + exportSeparator
                            + StringUtils.createFileName(runTestCaseTestStep.getName(), '_') + exportSeparator
                            + StringUtils.createFileName(tc.getTestSuite().getName(), '_') + exportSeparator
                            + StringUtils.createFileName(tc.getName(), '_') + exportSeparator
                            + StringUtils.createFileName(currentStep.getName(), '_') + "-" + count.longValue() + "-"
                            + result.getStatus();
                }

                String absoluteOutputFolder = getAbsoluteOutputFolder(ModelSupport.getModelItemProject(tc));
View Full Code Here

    private String getScopedProperty(PropertyExpansionContext context, String pe, boolean globalOverride) {
        ModelItem modelItem = context.getModelItem();

        TestStep testStep = null;
        TestCase testCase = null;
        TestSuite testSuite = null;
        Project project = null;
        MockService mockService = null;
        AbstractMockResponse mockResponse = null;
        SecurityTest securityTest = null;

        if (modelItem instanceof WsdlTestStep) {
            testStep = (WsdlTestStep) modelItem;
            testCase = testStep.getTestCase();
            testSuite = testCase.getTestSuite();
            project = testSuite.getProject();
        } else if (modelItem instanceof WsdlTestCase) {
            testCase = (WsdlTestCase) modelItem;
            testSuite = testCase.getTestSuite();
            project = testSuite.getProject();
        } else if (modelItem instanceof WsdlLoadTest) {
            testCase = ((WsdlLoadTest) modelItem).getTestCase();
            testSuite = testCase.getTestSuite();
            project = testSuite.getProject();
        } else if (modelItem instanceof WsdlTestSuite) {
            testSuite = (WsdlTestSuite) modelItem;
            project = testSuite.getProject();
        } else if (modelItem instanceof WsdlInterface) {
            project = ((WsdlInterface) modelItem).getProject();
        } else if (modelItem instanceof WsdlProject) {
            project = (WsdlProject) modelItem;
        } else if (modelItem instanceof WsdlMockService) {
            mockService = (WsdlMockService) modelItem;
            project = mockService.getProject();
        } else if (modelItem instanceof TestRequest) {
            testStep = ((TestRequest) modelItem).getTestStep();
            testCase = testStep.getTestCase();
            testSuite = testCase.getTestSuite();
            project = testSuite.getProject();
        } else if (modelItem instanceof AbstractHttpRequestInterface<?>) {
            project = ((AbstractHttpRequest<?>) modelItem).getOperation().getInterface().getProject();
        } else if (modelItem instanceof RestResource) {
            project = modelItem.getProject();
        } else if (modelItem instanceof WsdlMockOperation) {
            mockService = ((WsdlMockOperation) modelItem).getMockService();
            project = mockService.getProject();
        } else if (modelItem instanceof AbstractMockResponse) {
            mockResponse = (AbstractMockResponse) modelItem;
            mockService = mockResponse.getMockOperation().getMockService();
            project = mockService.getProject();
        } else if (modelItem instanceof SecurityTest) {
            securityTest = (SecurityTest) modelItem;
            testCase = ((SecurityTest) modelItem).getTestCase();
            testSuite = testCase.getTestSuite();
            project = testSuite.getProject();
        } else if (modelItem instanceof OAuth2Profile) {
            project = ((WsdlProject) modelItem.getParent());
        }
View Full Code Here

                                        }
                                    }
                                }
                            }
                        } else {
                            TestCase testCase = null;
                            try {
                                testCase = getModelItem().getTestSuiteByName(mainForm.getComponentValue(TESTSUITE))
                                        .getTestCaseByName(mainForm.getComponentValue(TESTCASE));
                            } catch (NullPointerException npe) {
                            }
                            if (testCase != null) {
                                securityTests.addAll(Arrays.asList(ModelSupport.getNames(testCase.getSecurityTestList())));
                            }
                        }

                        securityTests.add(0, ALL_VALUE);
                        mainForm.setOptions(SECURITYTEST, securityTests.toArray());
View Full Code Here

TOP

Related Classes of com.eviware.soapui.model.testsuite.TestCase

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.