private void syncProperties() { for (String name : propertyHolderSupport.getPropertyNames()) { if (!targetTestCase.hasProperty(name)) propertyHolderSupport.removeProperty(name); } for (String name : targetTestCase.getPropertyNames()) { if (!propertyHolderSupport.hasProperty(name)) propertyHolderSupport.addProperty(name); } }
public TestStepResult run(TestCaseRunner testRunner, TestCaseRunContext testRunContext) { WsdlMessageExchangeTestStepResult result = new WsdlMessageExchangeTestStepResult(this); testCaseRunner = null; if (targetTestCase != null) { Enum runMode = getRunMode(); if (runMode == RunTestCaseRunModeTypeConfig.PARALLELL) { runningTestCase = createTestCase(targetTestCase); } else { runningTestCase = targetTestCase; TestCaseRunner targetTestRunner = SoapUI.getTestMonitor().getTestRunner(targetTestCase); if (targetTestRunner != null && targetTestRunner.getStatus() == TestRunner.Status.RUNNING) { if (runMode == RunTestCaseRunModeTypeConfig.SINGLETON_AND_FAIL) { result.setStatus(TestStepStatus.FAILED); result.addMessage("Target TestCase is already running"); result.stopTimer(); runningTestCase = null; } else { targetTestRunner.waitUntilFinished(); } } } if (runningTestCase != null) { synchronized (runningTestCase) { for (TestRunListener listener : testRunListeners) runningTestCase.addTestRunListener(listener); StringList returnProperties = getReturnProperties(); Map<String, TestProperty> props = getProperties(); for (String key : props.keySet()) { if (runningTestCase.hasProperty(key) && !returnProperties.contains(key)) { String value = props.get(key).getValue(); runningTestCase.setPropertyValue( key, PropertyExpander.expandProperties(testRunContext, value)); } } currentLabel = getLabel(); runningTestCase.addTestRunListener(testRunListener); // StringToObjectMap properties = new StringToObjectMap(); // for( String name : testRunContext.getPropertyNames() ) // properties.put( name, testRunContext.getProperty( name )); result.startTimer(); testCaseRunner = runningTestCase.run(new StringToObjectMap(), true); testCaseRunner.waitUntilFinished(); result.stopTimer(); for (String key : returnProperties) { if (runningTestCase.hasProperty(key)) setPropertyValue(key, runningTestCase.getPropertyValue(key)); } // aggregate results for (TestStepResult testStepResult : testCaseRunner.getResults()) { result.addMessage( testStepResult.getTestStep().getName() + " - " + testStepResult.getStatus() + " - " + testStepResult.getTimeTaken()); for (String msg : testStepResult.getMessages()) { result.addMessage("- " + msg); } if (testStepResult instanceof MessageExchangeTestStepResult) { result.addMessages( ((MessageExchangeTestStepResult) testStepResult).getMessageExchanges()); } } switch (testCaseRunner.getStatus()) { case CANCELED: result.setStatus(TestStepStatus.CANCELED); break; case FAILED: result.setStatus(TestStepStatus.FAILED); break; case FINISHED: result.setStatus(TestStepStatus.OK); break; default: result.setStatus(TestStepStatus.UNKNOWN); break; } for (TestRunListener listener : testRunListeners) runningTestCase.removeTestRunListener(listener); if (runMode == RunTestCaseRunModeTypeConfig.PARALLELL) runningTestCase.release(); runningTestCase = null; testCaseRunner = null; } } } else { result.setStatus(TestStepStatus.FAILED); result.addMessage("Missing testCase in project"); result.stopTimer(); } return result; }