我试图在了SoapUI Groovy脚本调用java类
我的Java类
public class LogTest {
public void sayHello (){
System.out.println("Hello");
}
}
Groovy脚本
import LogTest;
new LogTest().sayHello()
我会将LogTest.class在...SmartBear\SoapUI-4.6.1\bin\ext
路径,并重新启动了SoapUI
不过还是我得到在了SoapUI以下错误
:ERROR:org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
Script5.groovy: 1: unable to resolve class LogTest
@ line 1, column 1.
import LogTest;
^
org.codehaus.groovy.syntax.SyntaxException: unable to resolve class LogTest
@ line 1, column 1.
at org.codehaus.groovy.ast.ClassCodeVisitorSupport.addError(ClassCodeVisitorSupport.java:148)
at org.codehaus.groovy.control.ResolveVisitor.visitClass(ResolveVisitor.java:1240)
at org.codehaus.groovy.control.ResolveVisitor.startResolving(ResolveVisitor.java:148)
at org.codehaus.groovy.control.CompilationUnit$8.call(CompilationUnit.java:601)
at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:839)
at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:544)
at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:493)
at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:306)
at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:287)
at groovy.lang.GroovyShell.parseClass(GroovyShell.java:731)
at groovy.lang.GroovyShell.parse(GroovyShell.java:743)
at groovy.lang.GroovyShell.parse(GroovyShell.java:770)
at groovy.lang.GroovyShell.parse(GroovyShell.java:761)
at com.eviware.soapui.support.scripting.groovy.SoapUIGroovyScriptEngine.compile(SoapUIGroovyScriptEngine.java:148)
at com.eviware.soapui.support.scripting.groovy.SoapUIGroovyScriptEngine.run(SoapUIGroovyScriptEngine.java:93)
at com.eviware.soapui.impl.wsdl.teststeps.WsdlGroovyScriptTestStep.run(WsdlGroovyScriptTestStep.java:149)
at com.eviware.soapui.impl.wsdl.support.AbstractTestCaseRunner.runTestStep(AbstractTestCaseRunner.java:239)
at com.eviware.soapui.impl.wsdl.testcase.WsdlTestCaseRunner.runCurrentTestStep(WsdlTestCaseRunner.java:48)
at com.eviware.soapui.impl.wsdl.support.AbstractTestCaseRunner.internalRun(AbstractTestCaseRunner.java:148)
at com.eviware.soapui.impl.wsdl.support.AbstractTestCaseRunner.internalRun(AbstractTestCaseRunner.java:43)
at com.eviware.soapui.impl.wsdl.support.AbstractTestRunner.run(AbstractTestRunner.java:135)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
可能是什么可能的根本原因
干杯
这将允许您从一个Groovy脚本中调用你的代码。
是你能解决这个问题?如果不是我遇到了相同的情况下,这里是我如何固定它。
我有以下信息的jar文件(HelloWorldTest.jar):
package helloworldtest;
public class HWT {
public static String Testing() {
return "Hello World!";
}
}
请注意,我的文件名和包名是不同的。导入到Groovy中,当您使用的软件包名称确认。
我用了:
import helloworldtest.HWT;
log.info HWT.Testing();
结果将是:
Thu Mar 06 16:26:01 PST 2014:INFO:Hello World!