Forum Discussion

IBM_-_PA_Suppor's avatar
IBM_-_PA_Suppor
Occasional Contributor
11 years ago

[Resolved]GroovyUtils.projectPath returns empty string

I have searched the forums and although this http://forum.loadui.org/viewtopic.php?f=2&t=17719 comes the closest - there was no resolution. But I have a similar problem.

I have a groovy script which when I execute in SOAPUI Pro (v4.6.4) it works perfectly fine. However, when I run it on the command-line using the maven plugin (pro version 4.6.1) the GroovyUtils.projectPath returns an empty string. Can you kindly help?

Here is the code:


groovyUtils = new com.eviware.soapui.support.GroovyUtils(context)
projectPath = groovyUtils.projectPath
log.info ("Project Path is =" + projectPath )


Here is my pom.xml:


<?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.smartbear.soapui</groupId>
<artifactId>bws-smoke-suite</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>Maven 2 soapUI Test</name>
<url>http://maven.apache.org</url>
<pluginRepositories>
<pluginRepository>
<id>SmartBear Sweden Plugin Repository</id>
<url>http://www.soapui.org/repository/maven2/</url>
</pluginRepository>
</pluginRepositories>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>com.smartbear.soapui</groupId>
<artifactId>soapui-pro-maven-plugin</artifactId>
<version>4.6.1</version>
<configuration>
<projectFile>./testScripts/BWS_Regression_Suite_Master_soapui.xml</projectFile>
<outputFolder>./testReports</outputFolder>
<junitReport>true</junitReport>
<printReport>true</printReport>
<soapuiProperties>
<property>
<name>soapui.logroot</name>
<value>./logging/</value>
</property>
</soapuiProperties>
<projectProperties>
<projectProperty>projName=BWS_Regression_Suite_Master_soapui</projectProperty>
</projectProperties>
</configuration>
<executions>
<execution>
<id>test1</id>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>


Here is the screenshot from within SOAPUI:



Here is the maven command with the results. I have X'd out sensitive information and in red you can see the empty string.

mvn -X -f com.smartbear.soapui:soapui-pro-maven-plugin:4.6.1:test

SoapUI Pro 4.6.1 Maven2 TestCase Runner
Setting soapui.logroot value ./logging/
10:10:52,562 WARN [SoapUI] Missing folder [C:\Users\IBM_ADMIN\workspace\2xAutomation\BWS\.\ext] for external libraries
10:10:52,733 INFO [DefaultSoapUICore] initialized soapui-settings from [C:\Users\IBM_ADMIN\soapui-settings.xml]
10:10:52,893 INFO [SoapUIProGroovyScriptEngineFactory] Setting Script Library to [C:\Program Files (x86)\SmartBear\soapUI-Pro-4.6.0\bin\scripts]
10:10:54,090 INFO [WsdlProject] Loaded project from [file:/C:/Users/IBM_ADMIN/workspace/2xAutomation/BWS/./testScripts/BWS_Regression_Suite_Master_soapui.xml]
10:10:54,335 INFO [SoapUIProGroovyScriptEngineFactory] Setting Script Library to [C:\Program Files (x86)\SmartBear\soapUI-Pro-4.6.0\bin\scripts]
10:10:56,936 INFO [SoapUIProTestCaseRunner] Setting project property [projName] to [BWS_Regression_Suite_Master_soapui]
10:10:56,939 INFO [SoapUIProTestCaseRunner] Running SoapUI tests in project [BWS_Regression_Suite_Master_soapui]
10:10:56,943 INFO [SoapUIProTestCaseRunner] Running Project [BWS_Regression_Suite_Master_soapui], runType = SEQUENTIAL
10:10:56,963 INFO [SoapUIProTestCaseRunner] Running SoapUI testcase [64617 POST /save with Strings]
10:10:56,970 INFO [SoapUIProTestCaseRunner] running step [Get Token autoUser31]
10:10:57,066 DEBUG [HttpClientSupport$SoapUIHttpClient] Attempt 1 to execute request
10:10:57,068 DEBUG [SoapUIMultiThreadedHttpConnectionManager$SoapUIDefaultClientConnection] Sending request: POST /api/oauth/token?client_id=2xApp&grant_type=password&username=XXX&password=XXX%23&client_secret=XXX&user_oauth_approval=true HTTP/1.1
10:10:57,179 DEBUG [SoapUIMultiThreadedHttpConnectionManager$SoapUIDefaultClientConnection] Receiving response: HTTP/1.1 200 OK
10:10:57,184 DEBUG [HttpClientSupport$SoapUIHttpClient] Connection can be kept alive indefinitely
10:10:57,474 INFO [SoapUIProTestCaseRunner] Assertion [XPath Match] has status VALID
10:10:57,476 INFO [SoapUIProTestCaseRunner] Assertion [Invalid HTTP Status Codes] has status VALID
10:10:57,480 INFO [SoapUIProTestCaseRunner] running step [oauthToken to TestCase]
10:10:57,530 INFO [SoapUIProTestCaseRunner] running step [GET /count]
10:10:57,537 DEBUG [HttpClientSupport$SoapUIHttpClient] Attempt 1 to execute request
10:10:57,538 DEBUG [SoapUIMultiThreadedHttpConnectionManager$SoapUIDefaultClientConnection] Sending request: GET /api/onboard/v1/tasks/onboarding/count HTTP/1.1
10:10:58,209 DEBUG [SoapUIMultiThreadedHttpConnectionManager$SoapUIDefaultClientConnection] Receiving response: HTTP/1.1 200 OK
10:10:58,212 DEBUG [HttpClientSupport$SoapUIHttpClient] Connection can be kept alive indefinitely
10:10:58,217 INFO [SoapUIProTestCaseRunner] Assertion [Invalid HTTP Status Codes] has status VALID
10:10:58,220 INFO [SoapUIProTestCaseRunner] Assertion [XPath Match] has status VALID
10:10:58,223 INFO [SoapUIProTestCaseRunner] running step [count]
10:10:58,227 INFO [SoapUIProTestCaseRunner] running step [check count]
10:10:58,514 INFO [SoapUIProTestCaseRunner] running step [Run TestCase 1]
10:10:58,566 INFO [log] Project Path is =
10:10:58,570 INFO [SoapUIProTestCaseRunner] Finished running SoapUI testcase [64617 POST /save with Strings], time taken: 1231ms, status: FINISHED
10:10:58,572 INFO [SoapUIProTestCaseRunner] Project [BWS_Regression_Suite_Master_soapui] finished with status [FINISHED] in 1625ms

SoapUI 4.6.1 TestCaseRunner Summary
-----------------------------
Time Taken: 1632ms
Total TestSuites: 1
Total TestCases: 1 (0 failed)
Total TestSteps: 6
Total Request Assertions: 4
Total Failed Assertions: 0
Total Exported Results: 0

10:10:58,952 INFO [SoapUIProTestCaseRunner] Created report at file:/C:/Users/IBM_ADMIN/workspace/2xAutomation/BWS/testReports/index.html
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 7.925s
[INFO] Finished at: Wed Feb 12 10:10:58 EST 2014
[INFO] Final Memory: 259M/700M
[INFO] ------------------------------------------------------------------------

7 Replies

  • IBM_-_PA_Suppor's avatar
    IBM_-_PA_Suppor
    Occasional Contributor
    I think I finally figured out why I was getting an empty string when calling the GroovyUtils.projectPath on the command-line. This was after doing a bit of digging around but I think I learned something that hopefully should be useful to the community. IMHO a JIRA should be raised to handle the exception thrown by the code that follows.

    The code for the GroovyUtils.getProjectPath() method reads like this:

    Project project = ModelSupport.getModelItemProject( context.getModelItem() )
    String path = project.getPath()
    int ix = path.lastIndexOf( File.separatorChar.toString() )
    log.path ==> this is my code
    .....(some more code that isn't important to this discussion)


    when I am running this within SOAPUI I get the following path being logged:
    C:\Users\....\<project.xml>

    but when I run it on the commandline it is reading the path to the project xml from my pom.xml (since I am not using the default).

     
    <configuration>
    <projectFile>./testScripts/project.xml</projectFile>


    The code above puked with an java.lang.StringIndexOutOfBoundsException- which obviously was not caught (the code does a check for -1 but does not do anything else) and hence I was seeing the blank result returned.

    However, I updated the pom to read like this:
     
    <configuration>
    <projectFile>.${file.separator}testScripts${file.separator}project.xml</projectFile>


    and that returned the results I wanted.
    So if you ever have the requirement of running your tests on jenkins (our jenkins master slaves are all linux based) you don't have to worry about it not working!

    Hope that helps!
  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Hi,

    I can't reproduce this problem. I'm using SoapUI Pro 4.6.4 with 4.6.4 pro maven plugin.

    Running com.mycompany.app.AppTest
    Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0 sec

    Results :

    Tests run: 1, Failures: 0, Errors: 0, Skipped: 0

    [INFO]
    [INFO] --- soapui-pro-maven-plugin:4.6.4:test (default) @ my-app ---
    SoapUI Pro 4.6.4 Maven2 TestCase Runner
    Setting soapui.home value C:\Program Files\SmartBear\SoapUI-Pro-4.6.4\bin
    11:08:16,571 INFO [SoapUI] Adding [C:\Program Files\SmartBear\SoapUI-Pro-4.6.4\
    bin\ext\postgresql-8.3-604.jdbc3.jar] to extensions classpath
    11:08:16,571 INFO [SoapUI] Adding [C:\Program Files\SmartBear\SoapUI-Pro-4.6.4\
    bin\ext\postgresql-8.3-604.jdbc4.jar] to extensions classpath
    11:08:16,571 INFO [SoapUI] Adding [C:\Program Files\SmartBear\SoapUI-Pro-4.6.4\
    bin\ext\sqljdbc.jar] to extensions classpath
    11:08:17,691 INFO [DefaultSoapUICore] initialized soapui-settings from [C:\User
    s\Marcus.James\soapui-settings.xml]
    11:08:18,511 INFO [SoapUIProGroovyScriptEngineFactory] Setting Script Library t
    o [C:\Program Files\SmartBear\SoapUI-Pro-4.6.2\bin\scripts]
    11:08:18,511 INFO [DefaultSoapUICore] Adding listeners from [C:\Program Files\S
    martBear\SoapUI-Pro-4.6.4\bin\listeners\demo-listeners.xml]
    11:08:21,551 INFO [WsdlProject] Loaded project from [file:/C:/SoapUI/Support/Gr
    oovyTest-soapui-project.xml]
    11:08:21,981 INFO [SoapUIProGroovyScriptEngineFactory] Setting Script Library t
    o [C:\Program Files\SmartBear\SoapUI-Pro-4.6.2\bin\scripts]
    11:08:22,941 INFO [SoapUIProTestCaseRunner] Running SoapUI tests in project [Gr
    oovyTest]
    11:08:23,031 INFO [SoapUIProTestCaseRunner] Running TestCase [TestCase 1]
    11:08:23,051 INFO [SoapUIProTestCaseRunner] Running SoapUI testcase [TestCase 1
    ]
    11:08:23,091 INFO [SoapUIProTestCaseRunner] running step [Groovy Script]
    11:08:23,911 INFO [log] Project Path is =C:\SoapUI\Support
    11:08:23,941 INFO [SoapUIProTestCaseRunner] Finished running SoapUI testcase [T
    estCase 1], time taken: 754ms, status: FINISHED
    11:08:23,941 INFO [SoapUIProTestCaseRunner] TestCase [TestCase 1] finished with
    status [FINISHED] in 754ms

    SoapUI 4.6.4 TestCaseRunner Summary
    -----------------------------
    Time Taken: 1268ms
    Total TestSuites: 0
    Total TestCases: 1 (0 failed)
    Total TestSteps: 1
    Total Request Assertions: 0
    Total Failed Assertions: 0
    Total Exported Results: 1
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD SUCCESS
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: 17.770s
    [INFO] Finished at: Wed Feb 12 11:08:24 EST 2014
    [INFO] Final Memory: 18M/160M
    [INFO] ------------------------------------------------------------------------

    I'm attaching my POM.xml and project file. I would advise you to try SoapUI Pro 4.6.4 with the 4.6.4 pro maven plugin.


    Regards,
    Marcus
    SmartBear Support
  • redfish4ktc2's avatar
    redfish4ktc2
    Super Contributor
    Hi, I have noticed that "IBM - PA Support" uses different version when running the gui and maven
    I have seen users complaining on the forums about problem when running with maven and the root cause was they did not use the same version than the GUI.

    About groovy, the library version has been upgraded in SoapUI 4.6.2 (swith from 1.8.5 to Groovy 2.1.7) and may also explain the different behaviour.
  • IBM_-_PA_Suppor's avatar
    IBM_-_PA_Suppor
    Occasional Contributor
    redfish4ktc2 wrote:
    Hi, I have noticed that "IBM - PA Support" uses different version when running the gui and maven
    I have seen users complaining on the forums about problem when running with maven and the root cause was they did not use the same version than the GUI.

    About groovy, the library version has been upgraded in SoapUI 4.6.2 (swith from 1.8.5 to Groovy 2.1.7) and may also explain the different behaviour.


    I upped the versions to 4.6.4 (both gui and maven) but that did not help either.
  • redfish4ktc2's avatar
    redfish4ktc2
    Super Contributor
    "IBM - PA Support", you mean you don't have the issue on windows but on linux? (SmartBear support was unable to reproduce the issue on windows)
  • IBM_-_PA_Suppor's avatar
    IBM_-_PA_Suppor
    Occasional Contributor
    No - I got the same results on both Linux and Windows. I think when you are using the relative path to the project xml this happens.
  • redfish4ktc2's avatar
    redfish4ktc2
    Super Contributor
    "IBM - PA Support" sorry to come back so late
    I have noticed that you use a relative path to the soapui project file in your maven plugin configuration. SmartBear support uses an absolute one
    do you reproduce the issue when using an absolute path?