Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

SoapUI TestSuite issue  RSS feed

 
santhosh kumar vk
Ranch Hand
Posts: 152
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,


I am trying to invoke the soapui testsuite project from my java client .I am sucessfully running sopuitestSuite from java client,But issue is how to print testcase response values in java console.


package com.vodafone.read.Test;

import com.eviware.soapui.impl.WsdlInterfaceFactory;
import com.eviware.soapui.impl.wsdl.WsdlInterface;
import com.eviware.soapui.impl.wsdl.WsdlOperation;
import com.eviware.soapui.impl.wsdl.WsdlProject;
import com.eviware.soapui.impl.wsdl.testcase.WsdlTestCase;
import com.eviware.soapui.impl.wsdl.testcase.WsdlTestCaseRunner;
import com.eviware.soapui.impl.wsdl.testcase.WsdlTestRunContext;
import com.eviware.soapui.model.testsuite.LoadTest;
import com.eviware.soapui.model.testsuite.TestCase;
import com.eviware.soapui.model.testsuite.TestStep;
import com.eviware.soapui.model.testsuite.TestStepResult;
import com.eviware.soapui.model.testsuite.TestSuite;
import com.eviware.soapui.support.types.StringToObjectMap;
import flex.messaging.messages.Message;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import javax.wsdl.Definition;
import javax.wsdl.WSDLException;
import javax.wsdl.factory.WSDLFactory;
import javax.wsdl.xml.WSDLReader;

/**
*
* @author shaikmv
*/
public class ReadTest {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
String projectFile = "C:\\Users\\shaikmv\\Documents\\NetBeansProjects\\WebServiceTestReadProject\\soapui-project.xml";
String userName = "xxxxxx";
String passWord = "xxxxxxx";
String localHost = "151.235.41.10";
String port = "9080";



try {

WsdlProject project = new WsdlProject(projectFile);
for (TestSuite testSuite : project.getTestSuiteList()) {

System.out.println("TestSuiteProject size......" + project.getTestSuiteList().size());
System.out.println("TestSuiteProject......" + testSuite.getName());

for (TestCase testCase : testSuite.getTestCaseList()) {

System.out.println("TestCases........." + testCase.getName());
testCase.setPropertyValue("UserName", userName);
testCase.setPropertyValue("Password", passWord);

// PropertiesMap properties = new PropertiesMap();

StringToObjectMap properties = new StringToObjectMap();
properties.put("username", userName);
properties.put("password", passWord);
properties.put("localhost", localHost);
properties.put("HttpDefaultPort", port);
List<TestStep> testSteps = testCase.getTestStepList();


// TestRunner runner = testCase.run(properties, false);
WsdlTestCaseRunner wsdlTestCaseRunner = new WsdlTestCaseRunner((WsdlTestCase) testCase, properties);
WsdlTestRunContext wsdlTestRunContext = wsdlTestCaseRunner.createContext(properties);
wsdlTestCaseRunner.run();





/* WsdlProjectRunner wsdlProjectRunner = new WsdlProjectRunner(project, properties);

WsdlProjectRunContext wsdlProjectRunContext = new WsdlProjectRunContext(wsdlProjectRunner, properties);
ProjectRunner projectRunner = wsdlProjectRunContext.getProjectRunner();
for (TestSuiteRunner testSuiteRunner : projectRunner.getResults()) {
for (TestCaseRunner testCaseRunner : testSuiteRunner.getResults()) {
for (TestStepResult testStepResult : testCaseRunner.getResults()) {
System.out.println("Test step next eleemnet ..... " + testStepResult.toString());
System.out.println("Test step size..... " + testStepResult.getSize());
System.out.println("Test step Staus..... " + testStepResult.getStatus());
}
}

}*/




/* TestCaseRunner testCaseRunner = wsdlTestRunContext.getTestRunner();
TestStep testStep = wsdlTestRunContext.getCurrentStep();
System.out.println("Result........... " + testCaseRunner.getResults().size());*/




/* WsdlTestRunContext wsdlTestRunContext = wsdlTestCaseRunner.getRunContext();
TestStep testStep = wsdlTestRunContext.getCurrentStep();
TestCaseRunner testCaseRunner = wsdlTestRunContext.getTestRunner();*/


WsdlTestCase wsdlTestCase = wsdlTestCaseRunner.getTestRunnable();
System.out.println("Load test case " + wsdlTestCase);
List<TestStepResult> testStepResult = (List<TestStepResult>) wsdlTestCaseRunner.getResults();
System.out.println("Test stepResults............." + testStepResult);
System.out.println("Test stepResultsn size ............." + testStepResult.size());
// System.out.println("Test stepResultsn size ............." + testStepResult.);
Iterator<TestStepResult> testIterator = testStepResult.iterator();
while (testIterator.hasNext()) {
TestStepResult tsestStepResult = testIterator.next();
System.out.println("Test step next eleemnet ..... " + tsestStepResult.toString());
System.out.println("Test step size..... " + tsestStepResult.getSize());
System.out.println("Test step Staus..... " + tsestStepResult.getStatus());
}



List<LoadTest> loadtest = wsdlTestCase.getLoadTestList();
System.out.println("Load test cases " + loadtest);
Iterator<LoadTest> loadIterator = loadtest.iterator();
System.out.println("Load test size...." + loadtest.size());

while (loadIterator.hasNext()) {
LoadTest loadTest = loadIterator.next();

System.out.println("Load Test " + loadTest);

}



/* WsdlLoadTest wsdlLoadTest = (WsdlLoadTest) wsdlTestCase.getLoadTestAt(0);
System.out.println("Wsdl load " + wsdlLoadTest);
List<LoadTestAssertion> loadTestAssertions = wsdlLoadTest.getAssertionList();
Iterator<LoadTestAssertion> loadIterators = loadTestAssertions.iterator();
while (loadIterators.hasNext()) {
LoadTestAssertion loadTestAssertion = loadIterators.next();
XMLObject xMLObject = (XMLObject) loadTestAssertion .getConfiguration();
System.out.println("List ........." + xMLObject.getContent());
}*/





break;
}

System.exit(1);
}

} catch (Exception e) {
e.printStackTrace();
}




}
}

output console
------------------
run:
19:50:32,413 WARN [DefaultSoapUICore] Missing folder [C:\Users\shaikmv\Documents\NetBeansProjects\SoapUITestProject\.\ext] for external libraries
19:50:33,003 INFO [DefaultSoapUICore] initialized soapui-settings from [C:\Users\shaikmv\soapui-settings.xml]
19:50:33,614 INFO [WsdlProject] Loaded project from [file:C:/Users/shaikmv/Documents/NetBeansProjects/WebServiceTestReadProject/soapui-project.xml]
TestSuiteProject size......1
TestSuiteProject......ReadTestSuite
TestCases.........gdspReadTransactionDetails TestCase
Test Step Names .........com.eviware.soapui.impl.settings.XmlBeansSettingsImpl@1fa5e5e
Test Staus....OK
Test Size....432
Test Action....gdspReadTransactionDetails
Java Result: 1
BUILD SUCCESSFUL (total time: 7 seconds)

 
Anurag Verma
Ranch Hand
Posts: 170
Hibernate Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
not related to the solution but can you please put your code in code block. it is much readable there.
 
santhosh kumar vk
Ranch Hand
Posts: 152
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,


I am trying to invoke the soapui testsuite project from my java client .I am sucessfully running sopuitestSuite from java client,But issue is how to print testcase response values in java console.


package com.vodafone.read.Test;

import com.eviware.soapui.impl.WsdlInterfaceFactory;
import com.eviware.soapui.impl.wsdl.WsdlInterface;
import com.eviware.soapui.impl.wsdl.WsdlOperation;
import com.eviware.soapui.impl.wsdl.WsdlProject;
import com.eviware.soapui.impl.wsdl.testcase.WsdlTestCase;
import com.eviware.soapui.impl.wsdl.testcase.WsdlTestCaseRunner;
import com.eviware.soapui.impl.wsdl.testcase.WsdlTestRunContext;
import com.eviware.soapui.model.testsuite.LoadTest;
import com.eviware.soapui.model.testsuite.TestCase;
import com.eviware.soapui.model.testsuite.TestStep;
import com.eviware.soapui.model.testsuite.TestStepResult;
import com.eviware.soapui.model.testsuite.TestSuite;
import com.eviware.soapui.support.types.StringToObjectMap;
import flex.messaging.messages.Message;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import javax.wsdl.Definition;
import javax.wsdl.WSDLException;
import javax.wsdl.factory.WSDLFactory;
import javax.wsdl.xml.WSDLReader;

/**
*
* @author shaikmv
*/
public class ReadTest {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
String projectFile = "C:\\Users\\shaikmv\\Documents\\NetBeansProjects\\WebServiceTestReadProject\\soapui-project.xml";
String userName = "xxxxxx";
String passWord = "xxxxxxx";
String localHost = "151.235.41.10";
String port = "9080";



try {

WsdlProject project = new WsdlProject(projectFile);
for (TestSuite testSuite : project.getTestSuiteList()) {

System.out.println("TestSuiteProject size......" + project.getTestSuiteList().size());
System.out.println("TestSuiteProject......" + testSuite.getName());

for (TestCase testCase : testSuite.getTestCaseList()) {

System.out.println("TestCases........." + testCase.getName());
testCase.setPropertyValue("UserName", userName);
testCase.setPropertyValue("Password", passWord);

// PropertiesMap properties = new PropertiesMap();

StringToObjectMap properties = new StringToObjectMap();
properties.put("username", userName);
properties.put("password", passWord);
properties.put("localhost", localHost);
properties.put("HttpDefaultPort", port);
List<TestStep> testSteps = testCase.getTestStepList();


// TestRunner runner = testCase.run(properties, false);
WsdlTestCaseRunner wsdlTestCaseRunner = new WsdlTestCaseRunner((WsdlTestCase) testCase, properties);
WsdlTestRunContext wsdlTestRunContext = wsdlTestCaseRunner.createContext(properties);
wsdlTestCaseRunner.run();





/* WsdlProjectRunner wsdlProjectRunner = new WsdlProjectRunner(project, properties);

WsdlProjectRunContext wsdlProjectRunContext = new WsdlProjectRunContext(wsdlProjectRunner, properties);
ProjectRunner projectRunner = wsdlProjectRunContext.getProjectRunner();
for (TestSuiteRunner testSuiteRunner : projectRunner.getResults()) {
for (TestCaseRunner testCaseRunner : testSuiteRunner.getResults()) {
for (TestStepResult testStepResult : testCaseRunner.getResults()) {
System.out.println("Test step next eleemnet ..... " + testStepResult.toString());
System.out.println("Test step size..... " + testStepResult.getSize());
System.out.println("Test step Staus..... " + testStepResult.getStatus());
}
}

}*/




/* TestCaseRunner testCaseRunner = wsdlTestRunContext.getTestRunner();
TestStep testStep = wsdlTestRunContext.getCurrentStep();
System.out.println("Result........... " + testCaseRunner.getResults().size());*/




/* WsdlTestRunContext wsdlTestRunContext = wsdlTestCaseRunner.getRunContext();
TestStep testStep = wsdlTestRunContext.getCurrentStep();
TestCaseRunner testCaseRunner = wsdlTestRunContext.getTestRunner();*/


WsdlTestCase wsdlTestCase = wsdlTestCaseRunner.getTestRunnable();
System.out.println("Load test case " + wsdlTestCase);
List<TestStepResult> testStepResult = (List<TestStepResult>) wsdlTestCaseRunner.getResults();
System.out.println("Test stepResults............." + testStepResult);
System.out.println("Test stepResultsn size ............." + testStepResult.size());
// System.out.println("Test stepResultsn size ............." + testStepResult.);
Iterator<TestStepResult> testIterator = testStepResult.iterator();
while (testIterator.hasNext()) {
TestStepResult tsestStepResult = testIterator.next();
System.out.println("Test step next eleemnet ..... " + tsestStepResult.toString());
System.out.println("Test step size..... " + tsestStepResult.getSize());
System.out.println("Test step Staus..... " + tsestStepResult.getStatus());
}



List<LoadTest> loadtest = wsdlTestCase.getLoadTestList();
System.out.println("Load test cases " + loadtest);
Iterator<LoadTest> loadIterator = loadtest.iterator();
System.out.println("Load test size...." + loadtest.size());

while (loadIterator.hasNext()) {
LoadTest loadTest = loadIterator.next();

System.out.println("Load Test " + loadTest);

}



/* WsdlLoadTest wsdlLoadTest = (WsdlLoadTest) wsdlTestCase.getLoadTestAt(0);
System.out.println("Wsdl load " + wsdlLoadTest);
List<LoadTestAssertion> loadTestAssertions = wsdlLoadTest.getAssertionList();
Iterator<LoadTestAssertion> loadIterators = loadTestAssertions.iterator();
while (loadIterators.hasNext()) {
LoadTestAssertion loadTestAssertion = loadIterators.next();
XMLObject xMLObject = (XMLObject) loadTestAssertion .getConfiguration();
System.out.println("List ........." + xMLObject.getContent());
}*/





break;
}

System.exit(1);
}

} catch (Exception e) {
e.printStackTrace();
}




}
}

output console
------------------
run:
19:50:32,413 WARN [DefaultSoapUICore] Missing folder [C:\Users\shaikmv\Documents\NetBeansProjects\SoapUITestProject\.\ext] for external libraries
19:50:33,003 INFO [DefaultSoapUICore] initialized soapui-settings from [C:\Users\shaikmv\soapui-settings.xml]
19:50:33,614 INFO [WsdlProject] Loaded project from [file:C:/Users/shaikmv/Documents/NetBeansProjects/WebServiceTestReadProject/soapui-project.xml]
TestSuiteProject size......1
TestSuiteProject......ReadTestSuite
TestCases.........gdspReadTransactionDetails TestCase
Test Step Names .........com.eviware.soapui.impl.settings.XmlBeansSettingsImpl@1fa5e5e
Test Staus....OK
Test Size....432
Test Action....gdspReadTransactionDetails
Java Result: 1
BUILD SUCCESSFUL (total time: 7 seconds)
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!