Forum Discussion

shiva_kakarla's avatar
shiva_kakarla
Contributor
17 years ago

unable to load datasource steps using WsdlProject

Hi Ole,

Reposting in pro support forum
____________________________

Hi Ole
I am trying to load SOAPUI project and execute testsuite and testcases in a groovy script.

My requirement is to run certain testsuites or testcases from the SOAPUI project and do some backup of log files on a remote endpoint server. I cant modify the existing SOAPUI projects and want to execute testcases as it is.

When I create wsdlproject Like below to extract testsuite names and testcase names and use it in SoapUIProTestCaseRunner api, I see that datasource test steps are not created while creating WsdlProject class.

Is there any other way to get list of testsuites and testcases from a SOAPUI project file?

WsdlProject project = new WsdlProject("C:/soapuiE2Eprojects/soapui-project.xml");


Log show::

18:44:27,430 INFO  [WsdlProject] Load project from [file:/C:/soapuiE2Eprojects/soapui-project.xml]
18:44:27,664 ERROR [WsdlTestCase] Failed to create test step for [DataSource]
18:44:27,711 ERROR [WsdlTestCase] Failed to create test step for [DataSource Loop]
18:44:27,711 ERROR [WsdlTestCase] Failed to create test step for [DataSource]
18:44:27,711 ERROR [WsdlTestCase] Failed to create test step for [DataSource Loop]
18:44:27,727 ERROR [WsdlTestCase] Failed to create test step for [DataSource]
18:44:27,727 ERROR [WsdlTestCase] Failed to create test step for [DataSource Loop]
18:44:27,727 ERROR [WsdlTestCase] Failed to create test step for [DataSource]
18:44:27,727 ERROR [WsdlTestCase] Failed to create test step for [DataSource Loop]
18:44:27,727 ERROR [WsdlTestCase] Failed to create test step for [DataSource]
18:44:27,789 ERROR [WsdlTestCase] Failed to create test step for [DataSource]
18:44:27,789 ERROR [WsdlTestCase] Failed to create test step for [DataSource Loop]
18:44:27,789 ERROR [WsdlTestCase] Failed to create test step for [DataSource]
18:44:27,789 ERROR [WsdlTestCase] Failed to create test step for [DataSource Loop]
18:44:27,789 ERROR [WsdlTestCase] Failed to create test step for [DataSource]
18:44:27,789 ERROR [WsdlTestCase] Failed to create test step for [DataSource Loop]
18:44:27,789 ERROR [WsdlTestCase] Failed to create test step for [2.DataSource]
18:44:27,789 ERROR [WsdlTestCase] Failed to create test step for [2.DataSource Loop]

wsdlprojct created


___________________________

Hi!

these are teststeps created with soapUI Pro (DataSource), so you will need to  prepare the soapUI classes for use with these first. Please re-post this issue in the soapUI Pro support forum and I'll help you forward!

regards,

/Ole
eviware.com

9 Replies

  • omatzura's avatar
    omatzura
    Super Contributor
    Ok!

    Try running the following code before you create the WsdlProject:

    SoapUI.setSoapUICore( new SoapUIPro.SoapUIProCore( true, pathToSettingsFile ));


    the pathToSettingsFile can be null if you haven't set any global settings, otherwise specify the absolut path to this file (it's in your soapuipro\bin directory). Also remember to add the soapuipro jar to your classpath.

    Hope this helps!

    regards,

    /Ole
    eviware.com
  • Hi Ole,

    I have added the statement as you specified. Now wsdlproject object is created without any errors. I got the testsuite name too but when I call runSuite it fails. In the logs I see wsdloader loads all the wsdls and while loading shemautils I get below Linkage Error exception.  Am i missing anything to set?

    My groovy code is like below and I have copied all the SOAPUI jars into groovy lib folder and which is set in my CLASSPATH.


    def pathToSettingsFile='C:/soapui-pro-2.0.2-bin/soapui-pro-2.0.2/bin/soapui-settings.xml'
    SoapUI.setSoapUICore( new SoapUIPro.SoapUIProCore( true, pathToSettingsFile ));
    SoapUIProTestCaseRunner proTestcaseRunner= new SoapUIProTestCaseRunner()
    proTestcaseRunner.setProjectFile("C:/soapuiE2Eprojects/"+soapTestProj)
    proTestcaseRunner.setHost('host:8080')
    proTestcaseRunner.setJUnitReport(true)
    proTestcaseRunner.setOutputFolder("C:/soupui_reports"+soapTestProj)


    WsdlProject project = new WsdlProject("C:/soapuiE2Eprojects/"+soapTestProj);

    println("wsdlprojct created")

    //Get testsuite names
    Map testSuiteMap = project.getTestSuites();

    Iterator x = testSuiteMap.keySet().iterator();
    while( x.hasNext())
    {
    println("in while");
    String testsuiteName = (String) x.next()
    println("testsuite is::"+testsuiteName)

    //Create Testsuite
    WsdlTestSuite wsdlTestSuite= project.getTestSuiteByName(testsuiteName);

    try {
    proTestcaseRunner.setTestSuite(testsuiteName)

    proTestcaseRunner.runSuite(wsdlTestSuite);
    }
    catch(Exception ex)
    {
    println "in exp"+ex.getMessage()
    }

    }




    16:05:14,057 ERROR [WsdlTestCaseRunner] Exception during TestCase Execution
    java.lang.LinkageError: Class org/w3c/dom/DOMConfiguration violates loader constraints
    at java.lang.Class.getDeclaredMethods0(Native Method)
    at java.lang.Class.privateGetDeclaredMethods(Class.java:2395)
    at java.lang.Class.privateGetPublicMethods(Class.java:2519)
    at java.lang.Class.privateGetPublicMethods(Class.java:2529)
    at java.lang.Class.getMethods(Class.java:1406)
    at net.sf.saxon.dom.DocumentWrapper.(DocumentWrapper.java:42)
    at net.sf.saxon.dom.DOMObjectModel.wrapDocument(DOMObjectModel.java:296)
    at net.sf.saxon.value.Value.convertToBestFit(Value.java:964)
    at net.sf.saxon.value.Value.convertJavaObjectToXPath(Value.java:762)
    at net.sf.saxon.trans.Variable.setValue(Variable.java:123)
    at org.apache.xmlbeans.impl.xpath.saxon.XBeansXPath.selectNodes(XBeansXPath.java:105)
    at org.apache.xmlbeans.impl.xpath.saxon.XBeansXPath.selectPath(XBeansXPath.java:132)
    at org.apache.xmlbeans.impl.store.Path$SaxonPathImpl$SaxonPathEngine.next(Path.java:500)
    at org.apache.xmlbeans.impl.store.Cursor._toSelection(Cursor.java:931)
    at org.apache.xmlbeans.impl.store.Cursor._toNextSelection(Cursor.java:920)
    at org.apache.xmlbeans.impl.store.Cursor.toNextSelection(Cursor.java:2670)
    at com.eviware.soapui.impl.wsdl.teststeps.PropertyTransfer.transferStringToXml(PropertyTransfer.java:440)
    at com.eviware.soapui.impl.wsdl.teststeps.PropertyTransfer.transferProperties(PropertyTransfer.java:269)
    at com.eviware.soapui.impl.wsdl.teststeps.TransferResponseValuesTestStep.run(TransferResponseValuesTestStep.java:133)
    at com.eviware.soapui.impl.wsdl.teststeps.TransferResponseValuesTestStep.run(TransferResponseValuesTestStep.java:106)
    at com.eviware.soapui.impl.wsdl.testcase.WsdlTestCaseRunner.run(WsdlTestCaseRunner.java:185)
    at com.eviware.soapui.impl.wsdl.testcase.WsdlTestCaseRunner.start(WsdlTestCaseRunner.java:84)
    at com.eviware.soapui.impl.wsdl.testcase.WsdlTestCase.run(WsdlTestCase.java:513)
    at com.eviware.soapui.impl.wsdl.testcase.WsdlTestCase.run(WsdlTestCase.java:57)
    at com.eviware.soapui.tools.SoapUITestCaseRunner.runTestCase(SoapUITestCaseRunner.java:464)
    at com.eviware.soapui.tools.SoapUITestCaseRunner.runSuite(SoapUITestCaseRunner.java:423)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:585)
    at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:95)
    at org.codehaus.groovy.runtime.MetaClassHelper.doMethodInvoke(MetaClassHelper.java:599)
    at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:904)
    at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:740)
    at org.codehaus.groovy.runtime.InvokerHelper.invokePojoMethod(InvokerHelper.java:761)
    at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:749)
    at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(ScriptBytecodeAdapter.java:167)
    at IntegrationTest.run(IntegrationTest.groovy:142)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:585)
    at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:95)
    at org.codehaus.groovy.runtime.MetaClassHelper.doMethodInvoke(MetaClassHelper.java:599)
    at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:904)
    at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:740)
    at org.codehaus.groovy.runtime.InvokerHelper.invokePogoMethod(InvokerHelper.java:773)
    at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:753)
    at org.codehaus.groovy.runtime.InvokerHelper.runScript(InvokerHelper.java:402)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:585)
    at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:95)
    at org.codehaus.groovy.runtime.MetaClassHelper.doMethodInvoke(MetaClassHelper.java:599)
    at groovy.lang.MetaClassImpl.invokeStaticMethod(MetaClassImpl.java:1077)
    at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:744)
    at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(ScriptBytecodeAdapter.java:167)
    at IntegrationTest.main(IntegrationTest.groovy)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:585)
    at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:95)
    at org.codehaus.groovy.runtime.MetaClassHelper.doMethodInvoke(MetaClassHelper.java:599)
    at groovy.lang.MetaClassImpl.invokeStaticMethod(MetaClassImpl.java:1077)
    at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:744)
    at groovy.lang.GroovyShell.runMainOrTestOrRunnable(GroovyShell.java:244)
    at groovy.lang.GroovyShell.run(GroovyShell.java:218)
    at groovy.lang.GroovyShell.run(GroovyShell.java:147)
    at groovy.ui.GroovyMain.processOnce(GroovyMain.java:492)
    at groovy.ui.GroovyMain.run(GroovyMain.java:308)
    at groovy.ui.GroovyMain.process(GroovyMain.java:294)
    at groovy.ui.GroovyMain.processArgs(GroovyMain.java:111)
    at groovy.ui.GroovyMain.main(GroovyMain.java:92)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:585)
    at org.codehaus.groovy.tools.GroovyStarter.rootLoader(GroovyStarter.java:101)
    at org.codehaus.groovy.tools.GroovyStarter.main(GroovyStarter.java:130)
  • omatzura's avatar
    omatzura
    Super Contributor
    Hi,

    hmm.. this is a classloader related problem, please try removing the xerces jars from the dependencies.

    What environment/IDE are you running in?

    regards,

    /Ole
    eviware.com
  • I was getting heap space out of memory error in my eclipse IDE since the projects are of 25MB size. I am executing groovy script in dos command prompt.

    I see that testcases are getting executed and the response is logged in tcpmon tool but with some validation errors thrown from my application. I also removed Xerces jar from groovy lib folder and i still get the same exception.

    Actaully I have initialized SoapUIProTestCaseRunner and set the target host using proTestcaseRunner.setHost('host:8080')  but the requests are going to localhost and then tcpmon is port forwarding to host. Do the setHost() api has bug?

    How do I get the log of all testcase requests and responses like the commandline testcase runner option -a.

    Thanks
    Shiva
  • omatzura's avatar
    omatzura
    Super Contributor
    Hi!

    the setHost method will only work if you run TestSuites via the testCaseRunners.runRunner() method.

    You can set the setExportAll( true ) method on the testCaseRunner to export all results (together with setOutputFolder..)

    Regarding the LinkageError, this is because you are somehow including the specified classes in the ClassLoader hiearachy when you are running the tests, which results in it getting loaded from the "wrong" classLoader. I need more details on exactly how you are running this to solve this.. As a workaround you can try to just remove the DOMConfiguration class from the xerces jars (or wherever it is), to see if that helps.

    regards,

    /Ole
    eviware.com
  • Hi Ole,

    Thank you for the response. I have modified my code to use proTestcaseRunner.runRunner() to execute tests by setting testsuite string and host. Now it forwards the request to correct host.

    My test cases are failing because of below mentioned exceptions. All the XPath related validations/transfers are failing with these Exceptions. I have copied all SOAPUI jars to groovy library including soapui-pro.jar and I have deleted xerces jar file while executing so that DOMconfigurationimpl is not available in classpath but still i see the below exceptions.

    Also when I get testcase names using wsdlesuite using the below code snippet I do not get testcase names in order.

    Map testCaseMap=wsdlTestSuite.getTestCases();

    Iterator tcase = testCaseMap.keySet().iterator();
    //Iterate through testcases and execute one by one.
    while(tcase.hasNext())
    {
    String testCase=(String) tcase.next()
    println("Executing:"+testCase);
    proTestcaseRunner.setTestCase(testCase);
    boolean result=proTestcaseRunner.runRunner()
    }

    Exception::


    12:43:48,726 INFO  [SoapUIProTestCaseRunner] Assertion [SOAP Response] has status VALID
    12:43:48,726 INFO  [SoapUIProTestCaseRunner] Assertion [Not SOAP Fault] has status VALID
    12:43:48,726 INFO  [SoapUIProTestCaseRunner] running step [DataSource]
    12:43:48,726 INFO  [SoapUIProTestCaseRunner] running step [Transfer]
    12:43:49,195 ERROR [WsdlTestCaseRunner] Exception during TestCase Execution
    java.lang.LinkageError: Class org/w3c/dom/DOMConfiguration violates loader constraints
    at java.lang.Class.getDeclaredMethods0(Native Method)
    at java.lang.Class.privateGetDeclaredMethods(Class.java:2395)
    at java.lang.Class.privateGetPublicMethods(Class.java:2519)
    at java.lang.Class.privateGetPublicMethods(Class.java:2529)
    at java.lang.Class.getMethods(Class.java:1406)
    at net.sf.saxon.dom.DocumentWrapper.(DocumentWrapper.java:42)
    at net.sf.saxon.dom.DOMObjectModel.wrapDocument(DOMObjectModel.java:296)
    at net.sf.saxon.value.Value.convertToBestFit(Value.java:964)
    at net.sf.saxon.value.Value.convertJavaObjectToXPath(Value.java:762)
    at net.sf.saxon.trans.Variable.setValue(Variable.java:123)
    at org.apache.xmlbeans.impl.xpath.saxon.XBeansXPath.selectNodes(XBeansXPath.java:105)
    at org.apache.xmlbeans.impl.xpath.saxon.XBeansXPath.selectPath(XBeansXPath.java:132)
    at org.apache.xmlbeans.impl.store.Path$SaxonPathImpl$SaxonPathEngine.next(Path.java:500)
    at org.apache.xmlbeans.impl.store.Cursor._toSelection(Cursor.java:931)
    at org.apache.xmlbeans.impl.store.Cursor._toNextSelection(Cursor.java:920)
    at org.apache.xmlbeans.impl.store.Cursor.toNextSelection(Cursor.java:2670)
    at com.eviware.soapui.impl.wsdl.teststeps.PropertyTransfer.transferStringToXml(PropertyTransfer.java:440)
    at com.eviware.soapui.impl.wsdl.teststeps.PropertyTransfer.transferProperties(PropertyTransfer.java:269)
    at com.eviware.soapui.impl.wsdl.teststeps.TransferResponseValuesTestStep.run(TransferResponseValuesTestStep.java:133)
    at com.eviware.soapui.impl.wsdl.teststeps.TransferResponseValuesTestStep.run(TransferResponseValuesTestStep.java:106)
    at com.eviware.soapui.impl.wsdl.testcase.WsdlTestCaseRunner.run(WsdlTestCaseRunner.java:185)
    at com.eviware.soapui.impl.wsdl.testcase.WsdlTestCaseRunner.start(WsdlTestCaseRunner.java:84)
    at com.eviware.soapui.impl.wsdl.testcase.WsdlTestCase.run(WsdlTestCase.java:513)
    at com.eviware.soapui.impl.wsdl.testcase.WsdlTestCase.run(WsdlTestCase.java:57)
    at com.eviware.soapui.tools.SoapUITestCaseRunner.runTestCase(SoapUITestCaseRunner.java:464)
    at com.eviware.soapui.tools.SoapUITestCaseRunner.runSuite(SoapUITestCaseRunner.java:423)
    at com.eviware.soapui.tools.SoapUITestCaseRunner.runRunner(SoapUITestCaseRunner.java:318)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  • Hi Ole

    Regarding my other question executing testcases one by one. I am able to get testcase names in order but I see its skipping the execution untill the last testcase as listed below from the logs.

    15:08:32,208 INFO  [SoapUIProTestCaseRunner] Running soapUI suite [suite], runType = SEQUENTIAL
    15:08:32,208 INFO  [SoapUIProTestCaseRunner] Skipping testcase [1], filter is [12]
    15:08:32,208 INFO  [SoapUIProTestCaseRunner] Skipping testcase [2], filter is [12]
    15:08:32,208 INFO  [SoapUIProTestCaseRunner] Skipping testcase [3], filter is [12]
    15:08:32,208 INFO  [SoapUIProTestCaseRunner] Skipping testcase [4], filter is [12]
    15:08:32,208 INFO  [SoapUIProTestCaseRunner] Skipping testcase [5], filter is [12]
    15:08:32,208 INFO  [SoapUIProTestCaseRunner] Skipping testcase [5], filter is [12]
    15:08:32,208 INFO  [SoapUIProTestCaseRunner] Skipping testcase [5.3], filter is [12]
    15:08:32,208 INFO  [SoapUIProTestCaseRunner] Skipping testcase [5.4], filter is [12]
    15:08:32,208 INFO  [SoapUIProTestCaseRunner] Skipping testcase [5.5], filter is [12]
    15:08:32,208 INFO  [SoapUIProTestCaseRunner] Skipping testcase [5.6], filter is [12]
    15:08:32,208 INFO  [SoapUIProTestCaseRunner] Skipping testcase [6], filter is [12]
    15:08:32,208 INFO  [SoapUIProTestCaseRunner] Skipping testcase [7], filter is [12]
    15:08:32,208 INFO  [SoapUIProTestCaseRunner] Skipping testcase [8], filter is [12]
    15:08:32,208 INFO  [SoapUIProTestCaseRunner] Skipping testcase [9], filter is [12]
    15:08:32,208 INFO  [SoapUIProTestCaseRunner] Skipping testcase [10], filter is [12]
    15:08:32,208 INFO  [SoapUIProTestCaseRunner] Skipping testcase [11], filter is [12]
    15:08:32,223 INFO  [SoapUIProTestCaseRunner] Running soapUI testcase [12]
    15:08:32,239 INFO  [SoapUIProTestCaseRunner] running step [Default]
    15:08:32,254 INFO  [SoapUIProTestCaseRunner] running step [Properties]
    15:08:32,254 INFO  [SoapUIProTestCaseRunner] running step [1]
    15:08:33,395 INFO  [HttpClientSupport$Helper] Initializing SSL
  • omatzura's avatar
    omatzura
    Super Contributor
    Hi,

    this indicates that you have eiterh set a TestCase name filter with testCaseRunner.setTestCase(..) to "12", or that the other TestCases are disabled.. does that sound correct? If not, can you show the entire code you are using to run the tests?

    Regarding the LinkageError, exactly in which environment/IDE are you running this? Could the be some conflicting libraries in the system classpath or ext folder?

    regards,

    /Ole
    eviware.com
  • Hi Ole

    I load project from a directory and then create wsdleproject. I get testsuite names from the project and create wsdlsuite object.  Using it I get test case names and then try to execute each test case using testrunner. Here is the entire code snippet.

    I am not using any IDE to execute my project. I have set groovy classpath to run my groovy script. I have copied all the SOAPUI jars into the groovy classpath folder. I will check if there is clash in loading DOM libraries.

    def pathToSettingsFile='C:/soapui-pro-2.0.2/bin/soapui-settings.xml'
    SoapUI.setSoapUICore( new SoapUIPro.SoapUIProCore( true, pathToSettingsFile ));
    SoapUIProTestCaseRunner proTestcaseRunner= new SoapUIProTestCaseRunner()
    proTestcaseRunner.setProjectFile("C:/testsuite/soapuiE2Eprojects/"+soapTestProj)
    proTestcaseRunner.setHost('host:8080')
    proTestcaseRunner.setJUnitReport(true)
    proTestcaseRunner.setPrintReport(true)
    proTestcaseRunner.setExportAll(true)
    proTestcaseRunner.setOutputFolder("C:/testsuite/build/soupui_reports/"+soapTestProj)



    println" File :"+ soapTestProj;


    WsdlProject project = new WsdlProject("C:/testsuite/soapuiE2Eprojects/"+soapTestProj);

    println("wsdlprojct created")

    //Get testsuite names
    Map testSuiteMap = project.getTestSuites();

    Iterator x = testSuiteMap.keySet().iterator();

    while( x.hasNext())
    {
    String testsuiteName = (String) x.next()
    println("testsuite is::"+testsuiteName)

    //Create Testsuite
    WsdlTestSuite wsdlTestSuite= project.getTestSuiteByName(testsuiteName);

    //Get All testcases in the Testsuite
    Map testCaseMap=wsdlTestSuite.getTestCases();

    Iterator tcase = testCaseMap.keySet().iterator();
    //Iterate through testcases and execute one by one.
    while(tcase.hasNext())
    {
    String testCase=(String) tcase.next() //############## Run only the Testcase ##########
    println("Executing:"+testCase);
    proTestcaseRunner.setTestCase(testCase);
    boolean result=proTestcaseRunner.runRunner()

    }
    }