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
Related
I have two problems with log4j2:
I cannot figure out how to specify the log root level in the command line.
I execute runnable jar with log4j2.xml config file
java -Dlog4j.configurationFile=log4j2.xml -jar my.jar
The log4j2.xml has default loggers root log level set to INFO. But sometimes I need to specify DEBUG.
-Dlog4j.configurationFile=log4j2.xml does not work on Windows though it works fine on Mac and Linux. log4j2.xml does exist in current folder.
I get error when executing above mentioned command line with Windows PowerShell
Error: Could not find or load main class .configurationFile=log4j2.xml
I tried -Dlog4j.configurationFile=file://log4j2.xml or -Dlog4j.configurationFile=./log4j2.xml or -Dlog4j.configurationFile=file://<full_path_to_log4j2.xml> the same error
Define a property named "rootLevel" as
${sys:rootLevel:=INFO}
then on your root Logger specify
<Root level="${rootLevel}">
The root level will now default to Info and you can override it with -DrootLevel=DEBUG on the command line.
The problem is the dot in the property name. On Windows you need to put it in quotes.
I am trying to execute this
java -cp .\antlr-4.7.2-complete.jar org.antlr.v4.gui.TestRig CPP14 translationUnit -gui example.cc
command but it showing this error
Can't load CPP14 as lexer or parser
You should make sure that:
the classes CPP14Lexer.java and CPP14Parser.java are generated
the generated CPP14Lexer.java and CPP14Parser.java are compiled
the compiled CPP14Lexer and CPP14Parser classes are added to the classpath
So, assuming CPP14Lexer and CPP14Parser are in the default package (and reside in the same folder as the antlr-4.7.2-complete.jar file), then your command should look like this:
java -cp .\antlr-4.7.2-complete.jar;. org.antlr.v4.gui.TestRig CPP14 translationUnit -gui example.cc
Hello I get this error when I try the simple esample of the tutorial:
"grun Hello -r tree
Warning: TestRig moved to org.antlr.v4.gui.TestRig; calling automatically
Problems calling org.antlr.v4.gui.TestRig.main(args)
"
I cannot figure out what is going on.
Can you help me please.
It sounds like you have setup your 'grun' alias to use :
org.antlrv4.runtime.misc.TestRig
//and from antlr4 onwards they deprecated that and use this instead.
org.antlrv4.gui.TestRig
So you should try resetting your 'grun' alias either from terminal or batch file depending on how you set it up. If there are still errors comment here and i will try and help:
alias grun='java org.antlr.v4.gui.TestRig'
if you still have any errors after updating your setup alias then leave a comment and i will try to help further.
Setup TestRig - Added here so content is not lost after the documentation section is shut down.
ANTLR contains a testing tool in its runtime library, this tool can be used to display information detailing how the parsing is performed to match input against defined rules in your grammar file.
To use this tool contained within the ANTLR jar file you should setup your systems classpath to allow access to both the ANTLR tool and the runtime library :
export CLASSPATH=".:/usr/local/lib/antlr-4.5.3-complete.jar:$CLASSPATH"
Note: Ensure the Dot precedes any path to ensure the java virtual machine wont see classes in your current working directory.
Alises can be used on Linux/MAC/Unix to simplify commands used:
alias antlr4='java -jar /usr/local/lib/antlr-4.5.3-complete.jar'
//or any directory where your jar is located
Note setup on windows for aliases and classpath setup may be more complicated, see here for more comprehensive details.
Accessing TestRig
Once you have setup your alias you can setup TestRig in the following way, again using an alias is recommended as reduces the amount of time required to perform the action:
alias grun='java org.v4.runtime.misc.TestRig'
If you do not wish to setup an alias on windows you can access TestRig by running the following command in the same location as your ANTLR jar directory:
java -cp .;antlr.4.5.3-complete.jar org.antlrv4.runtime.misc.TestRig
//or
java -cp .;antlr.4.5.3-complete.jar org.antlrv4.gui.TestRig
To run TestRig on your grammar you can pass the parameters in for your grammar like this :
grun yourGrammar yourRule -tree //using the setup alias java -cp .;antlr.4.5.3-complete.jar org.antlrv4.gui.TestRig yourGrammar YourRule -tree //on windows with no alias java -cp .;antlr.4.5.3-complete.jar org.antlrv4.gui.TestRig yourGrammar Hello r -tree //Windows with the grammar Hello.g4 starting from the rule 'r'.
grun yourGrammar yourRule -tree //using the setup alias
java -cp .;antlr.4.5.3-complete.jar org.antlrv4.gui.TestRig yourGrammar YourRule -tree //on windows with no alias
java -cp .;antlr.4.5.3-complete.jar org.antlrv4.gui.TestRig yourGrammar Hello r -tree
//Windows with the grammar Hello.g4 starting from the rule 'r'.
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.
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.