use of com.eviware.soapui.model.testsuite.TestSuite in project iesi by metadew.
the class SOAPUIIntegration method main.
public static void main(String[] args) {
try {
getTestSuite();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.exit(0);
// https://www.soapui.org/test-automation/junit/junit-integration.html#_ga=2.157007227.1117033134.1563254348-690893157.1557407813
// out-app-analytics-provider-5.5.0.jar causes issues in eclipse on the build
// path
SoapUITestCaseRunner runner = new SoapUITestCaseRunner();
runner.setProjectFile("c:/Data/ApiCase-soapui-project.xml");
try {
runner.run();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
WsdlProject project;
try {
project = new WsdlProject("c:/Data/ApiCase-soapui-project.xml");
TestSuite testSuite = project.getTestSuiteByName("https://sandbox.api.belfius.be:8443 TestSuite");
// TestCase testCase = testSuite.getTestCaseByName( "Test Conversions" );
// create empty properties and run synchronously
TestRunner runner2 = testSuite.run(new PropertiesMap(), false);
System.out.println(runner2.getStatus());
} catch (XmlException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SoapUIException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
use of com.eviware.soapui.model.testsuite.TestSuite in project iesi by metadew.
the class SOAPUIIntegration method getTestSuite.
public static void getTestSuite() throws Exception {
String suiteName = "";
String reportStr = "";
// variables for getting duration
long startTime = 0;
long duration = 0;
TestRunner runner = null;
List<TestSuite> suiteList = new ArrayList<TestSuite>();
List<TestCase> caseList = new ArrayList<TestCase>();
SoapUI.setSoapUICore(new StandaloneSoapUICore(true));
// specified soapUI project
WsdlProject project = new WsdlProject("c:/Data/ApiCase-soapui-project.xml");
// get a list of all test suites on the project
suiteList = project.getTestSuiteList();
// you can use for each loop
for (int i = 0; i < suiteList.size(); i++) {
// get name of the "i" element in the list of a test suites
suiteName = suiteList.get(i).getName();
reportStr = reportStr + "\nTest Suite: " + suiteName;
// get a list of all test cases on the "i"-test suite
caseList = suiteList.get(i).getTestCaseList();
for (int k = 0; k < caseList.size(); k++) {
startTime = System.currentTimeMillis();
// run "k"-test case in the "i"-test suite
TestCaseRunner tcr = null;
// runner =
// project.getTestSuiteByName(suiteName).getTestCaseByName(caseList.get(k).getName()).run(new
// PropertiesMap(), false);
tcr = project.getTestSuiteByName(suiteName).getTestCaseByName(caseList.get(k).getName()).run(new PropertiesMap(), false);
duration = System.currentTimeMillis() - startTime;
// reportStr = reportStr + "\n\tTestCase: " + caseList.get(k).getName() +
// "\tStatus: " + runner.getStatus() + "\tReason: " + runner.getReason() +
// "\tDuration: " + duration;
reportStr = reportStr + "\n\tTestCase: " + caseList.get(k).getName() + "\tStatus: " + tcr.getStatus() + "\tReason: " + tcr.getReason() + "\tDuration: " + tcr.getTimeTaken();
for (TestStepResult tsr : tcr.getResults()) {
String request = ((MessageExchange) tsr).getRequestContent();
String response = ((MessageExchange) tsr).getResponseContent();
System.out.println(response);
}
}
}
// string of the results
System.out.println(reportStr);
}
use of com.eviware.soapui.model.testsuite.TestSuite in project microcks by microcks.
the class SoapUIProjectImporter method collectRestTestRequests.
/**
* Collect and filter by operation all the WsldTestrequest from the current project.
*/
private Map<String, RestTestRequest> collectRestTestRequests(Operation operation) {
Map<String, RestTestRequest> result = new HashMap<String, RestTestRequest>();
for (TestSuite testsuite : project.getTestSuiteList()) {
for (TestCase testcase : testsuite.getTestCaseList()) {
for (TestStep teststep : testcase.getTestStepList()) {
if (teststep instanceof RestTestRequestStep) {
RestTestRequestStep rs = (RestTestRequestStep) teststep;
RestTestRequest rr = rs.getTestRequest();
if (rs.getResourcePath().equals(operation.getName())) {
result.put(rr.getName(), rr);
}
}
}
}
}
return result;
}
use of com.eviware.soapui.model.testsuite.TestSuite in project microcks by microcks.
the class SoapUIProjectImporter method collectWsdlTestRequests.
/**
* Collect and filter by operation all the WsldTestrequest from the current project.
*/
private Map<String, WsdlTestRequest> collectWsdlTestRequests(Operation operation) {
Map<String, WsdlTestRequest> result = new HashMap<>();
for (TestSuite testsuite : project.getTestSuiteList()) {
for (TestCase testcase : testsuite.getTestCaseList()) {
for (TestStep teststep : testcase.getTestStepList()) {
if (teststep instanceof WsdlTestRequestStep) {
WsdlTestRequestStep ws = (WsdlTestRequestStep) teststep;
WsdlTestRequest wr = ws.getHttpRequest();
if (wr.getOperationName().equals(operation.getName())) {
result.put(wr.getName(), wr);
}
}
}
}
}
return result;
}
use of com.eviware.soapui.model.testsuite.TestSuite in project iesi by metadew.
the class SoapUiExecution method execute.
public void execute() {
try {
String suiteName = "";
String reportStr = "";
// variables for getting duration
long startTime = 0;
long duration = 0;
List<TestSuite> suiteList = new ArrayList<TestSuite>();
List<TestCase> caseList = new ArrayList<TestCase>();
SoapUI.setSoapUICore(new StandaloneSoapUICore(true));
// specified soapUI project
WsdlProject wsdlProject = new WsdlProject(this.getProject());
// Define test suite scope
if (this.getTestSuite().isEmpty()) {
suiteList = wsdlProject.getTestSuiteList();
} else {
suiteList.add(wsdlProject.getTestSuiteByName(this.getTestSuite()));
}
// Loop test suites
for (int i = 0; i < suiteList.size(); i++) {
// get name of the "i" element in the list of a test suites
suiteName = suiteList.get(i).getName();
reportStr = reportStr + "\nTest Suite: " + suiteName;
// get a list of all test cases on the "i"-test suite
caseList = suiteList.get(i).getTestCaseList();
for (int k = 0; k < caseList.size(); k++) {
startTime = System.currentTimeMillis();
// run "k"-test case in the "i"-test suite
TestCaseRunner testCaseRunner = wsdlProject.getTestSuiteByName(suiteName).getTestCaseByName(caseList.get(k).getName()).run(new PropertiesMap(), false);
duration = System.currentTimeMillis() - startTime;
reportStr = reportStr + "\n\tTestCase: " + caseList.get(k).getName() + "\tStatus: " + testCaseRunner.getStatus() + "\tReason: " + testCaseRunner.getReason() + "\tDuration: " + testCaseRunner.getTimeTaken() + "\tCalculated Duration: " + duration;
;
int l = 1;
for (TestStepResult tsr : testCaseRunner.getResults()) {
String request = ((MessageExchange) tsr).getRequestContent();
this.writeToFile("request." + k + "." + l + ".out", request);
String response = ((MessageExchange) tsr).getResponseContent();
this.writeToFile("response." + k + "." + l + ".out", response);
l++;
}
}
}
// string of the results
// System.out.println(reportStr);
this.writeToFile("project.out", reportStr);
} catch (Exception e) {
e.printStackTrace();
}
}
Aggregations