Using groovy-wslite in SoapUI - groovy

I'm using SoapUI version 4.5.1 on a Windows 7 box to create a mock webservice. It includes a Groovy script that is fired at an OnRequest event which attempts to create and send a second response.
The issue is to do with the installation of the groovy-wslite library, which I'm trying to use in order to instantiate a SoapClient object which sends the additional response.
If I include the following at the top of the script (as per the wslite github site at https://github.com/jwagenleitner/groovy-wslite):
#Grab(group='com.github.groovy-wslite', module='groovy-wslite', version='0.7.1')
... I get the following error:
java.lang.NoClassDefFoundError: org/apache/ivy/core/settings/IvySettings
If I remove it from the script, I get the following error:
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: Script6.groovy: 23: unable to resolve class SOAPClient # line 23, column 18.
def client = new SOAPClient(clientURL)
^
org.codehaus.groovy.syntax.SyntaxException: unable to resolve class SOAPClient # line 23, column 18.
Can anyone suggest what I'm doing wrong, please? Do I need to install groovy-wslite separately within SoapUI?
Thanks in advance for any advice.

I have downloaded the groovy-wslite jar and added it to my SoapUI installation's bin/ext directory.

Related

How to check if the environment variable "PROJ_LIB" is defined and how to unset it ? (PyQGIS Standalone Script Executer)

I just tried the standalone PyQGIS application by running the custom script "Proximity.py"* in a VS Code project without the need of a GUI (such as QGIS).
But, when I run the python-program I get the following message:
proj_create_from_database: C:\Program Files\PostgreSQL\14\share\contrib\postgis-3.2\proj\proj.db contains DATABASE.LAYOUT.VERSION.MINOR = 0 whereas a number >= 2 is expected. It comes from another PROJ installation. (see also: Error Message after launching the configuration (launch.json) from VS Code (when pressing F5))
I'm trying this online example with the following installations:
PostgreSQL 14
Python39
.vscode\extensions\ms-python.python-2022.4.1\pythonFiles\lib\python\debugpy\launcher
osgeo4w-setup.exe (including QGIS LTR)
I read that there is a solution by undefining [PROJ_LIB] before importing pyproj or osgeo: del os.environ ['PROJ_LIB'] as described under this link. If this is also supposed to be the correct solution in this case, can someone help me with step-by-step instructions (for dummies)?
. * The "Proximity.py" script is a pyqgis standalone example from "https://github.com/MarByteBeep/pyqgis-standalone"
Finally, I got a solution to be able to run the "standalone PyQGIS"* example "Proximity" (provided by MarByteBeep).
This solution was possible without needing to launch the configuration file "launch.json" as above described. And so, avoiding the need to make any configuration to the environment variable "PROJ_LIB" by trying to circumvent the above issue.
I just first added the following two code-lines (see here line 2 and 3) in the python file "main.py" so as to be able to use the plugin "PROCESSING" (initially line 8 of the "main.py" file), then I store it and finally I ran it.
Line 1: from qgis.core import
Line 2: import sys
Line 3: sys.path.append('C:\Program Files\QGIS 3.24.1\apps\qgis\python\plugins')
Line 4: qgs = QgsApplication([], False)
Line 5: ...
The Proximity example is based on the answer of "Mar Tjin" to the following Question: "Looking for manual on how to properly setup standalone PyQGIS without GUI"
. * By "Standalone PyQGIS" I refer to code/scripts that can be run outside the QGIS-GUI (=> QGIS-Desktop/Server Application). In my case under the external Editor VS Code

Getting unexpected token by running code in JSR223 Sampler(groovy) in jmeter

While running the below code in JSR223 SAMPLER, i am getting this error
Response code:500
Response message:javax.script.ScriptException: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
Script989.groovy: 1: unexpected token: < # line 1, column 1.
<HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy"
The code starts like this:
< HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy"
testname="Checkout Payment Info/Place Order${__property(activeAdminThread)}(${testLabel})" enabled="true">
< boolProp name="HTTPSampler.postBodyRaw">true
Error appearing for the very first line itself..what wrong in it ,plz help?
This is not a valid Groovy code, it seems to be a part of JMeter .jmx test plan (pure XML file)
This HTTPSamplerProxy is what's being used under the hood of the normal HTTP Request sampler so I would recommend going to where did you get this code, downloading it adding .jmx extension and opening it in JMeter GUI.
To solve the above issue you have to upgrade your JDK and JRE.
Download the JDK and JRE and setup the Environment variable path
JAVA_HOME - JDK/bin
path - JRE/bin

How add dependencies into groovy script?

I try to add HttpBuilder into groovy script, but can do it only manually (Alt+Ctrl+Shift+S add dependencie). But when I start script I have error in line of creating new httpbuilder instance java.lang.ClassNotFoundException: org.apache.http.client.HttpClient. I manualy add HttpClient, butClassNotFoundException: net.sf.json.JSONObject and so on. But when I add Ini library it works fine.
I also tried to use #Grab
main()
def main() {
#Grab(group='org.codehaus.groovy.modules.http-builder', module='http-builder', version='0.7' )
def http = new groovyx.net.http.HTTPBuilder('http://www.codehaus.org')
And have compilation error
Error:Groovyc: While compiling GroovyTests: java.lang.RuntimeException: Error grabbing Grapes -- [download failed: net.sf.json-lib#json-lib;2.3!json-lib.jar]
And net in def http = new groovyx.net.http.HTTPBuilder('http://www.codehaus.org') is red and Cannot resolve a symbol 'net' error
will be glad to any help
Since you have now installed the groovy executables as per the comments, the following code:
#Grab('org.codehaus.groovy.modules.http-builder:http-builder:0.7')
import groovyx.net.http.HTTPBuilder
def http = new HTTPBuilder('https://jsonplaceholder.typicode.com')
def res = http.get(path: '/users')
println "Number of users: ${res.size()}"
should now run and print:
─➤ groovy solution.groovy
Number of users: 10
─➤
(tested on Groovy Version: 2.5.8 JVM: 1.8.0_232 Vendor: AdoptOpenJDK OS: Linux)
One thing that might be disrupting the artifact resolution is if you have a custom grapeConfig.xml file. This file (if it exists) should be under <user home dir>/.groovy/grapeConfig.xml and the default text that groovy uses if no grapeConfig.xml file is present can be found here:
https://github.com/apache/groovy/blob/master/src/resources/groovy/grape/defaultGrapeConfig.xml
In addition, if you need to debug grapes downloads, you should try the following flags (again as mentioned in the comments):
─➤ groovy -Dgroovy.grape.report.downloads=true -Divy.message.logger.level=4 yourGroovyScript.groovy
which should print information on what grapes are actually doing when the resolution fails.
What does your groovy -v look like? i.e. what version of groovy and what jdk are you on?

How to run spock test from command line?

I have checked this link:
https://gist.github.com/ysb33r/5825457
It seems like that it can be run like this:
groovyc *.groovy
java -cp ~/.grapes/org.spockframework/spock-core/jars/spock-core-0.7-groovy-2.0.jar:$GROOVY_HOME/embeddable/groovy-all-2.1.4.jar:$GROOVY_HOME/lib/junit-4.11.jar:$GROOVY_HOME/lib/hamcrest-core-1.3.jar:.org.junit.runner.JUnitCore ExampleSpec
And I have added all third part jars to CLASSPATH,so all imports from these libs found.But all my own classes can't be found,and error message like this:
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
LoginTest.groovy: 11: unable to resolve class com.vsi.icareos.client.home.HomePage
# line 11, column 1.
import com.vsi.icareos.client.home.HomePage
^
LoginTest.groovy: 22: unable to resolve class LoginByPwdPage
# line 22, column 2.
LoginByPwdPage loginPage
^
LoginTest.groovy: 35: unable to resolve class LoginByPwdPage
# line 35, column 13.
loginPage=new LoginByPwdPage(browser,Consts.PAGE_ID)
^
3 errors
I guess that the option like:--sourcepath is needed,but I found this command option deprecated,so How to slove this problem?
I was able to run the tests described in the gist, but with modification of the groovyc to add the -cp flag with spock jar to it, also if you have the sources in sub-directories you should use **/*.groovy instead of *.groovy
Looking at the way you run the java command, it seams to be missing a space between . and org.junit.runner.JUnitCore
So instead of
java -cp ~/.grapes/org.spockframework/spock-core/jars/spock-core-0.7-groovy-2.0.jar:$GROOVY_HOME/embeddable/groovy-all-2.1.4.jar:$GROOVY_HOME/lib/junit-4.11.jar:$GROOVY_HOME/lib/hamcrest-core-1.3.jar:.org.junit.runner.JUnitCore ExampleSpec
I should be
java -cp ~/.grapes/org.spockframework/spock-core/jars/spock-core-0.7-groovy-2.0.jar:$GROOVY_HOME/embeddable/groovy-all-2.1.4.jar:$GROOVY_HOME/lib/junit-4.11.jar:$GROOVY_HOME/lib/hamcrest-core-1.3.jar:. org.junit.runner.JUnitCore ExampleSpec
Please note the space in the second.
The . is the current directory added to the classpath
hope this helps

"Unrecognized option: --format=COBERTURAXML" in trying to convert JSCover report to cobertura xml

I'm trying to convert JSCover to cobertura xml.
Based on what i've read the command is as follows:
java -cp JSCover-all.jar jscover.report.Main --format=COBERTURAXML REPORT-DIR SRC-DIRECTORY
But I get an error
"Error: Could not find or load main class jscover.report.Main"
Even if I set the fully qualified path of there the JSCover-all.jar is located.
So I tried including the JSCover-al.jar into the classpath and run the following command instead:
java -cp jscover.report.Main --format=COBERTURAXML target/local-storage-proxy target/local-storage-proxy/original-src
I no longer get the first error but i'm now getting the following error:
Unrecognized option: --format=COBERTURAXML
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
I hope someone could help me with it. Many thanks!
The first attempt is the correct approach. The error means that JSCover-all.jar is not in the same directory that you are executing the command from. An absolute path to is not needed - a relative one will do.
In the second approach, you have passed 'jscover.report.Main' as the class-path to the JVM and '--format=COBERTURAXML' as parameter to the 'java' command.

Resources