SoapUI Groovy script not running in Testcase - groovy

I'm trying to run a Groovy script in a soapUI Test case.
The script does nothing but take the response, extract a value and use it in the next request. The extracting works when I run my script standalone. But, as soon as I try to run my test case I get following error:
ERROR:
java.lang.ClassCastException: java.lang.String cannot be cast to org.apache.log4j.Logger
at com.eviware.soapui.impl.wsdl.teststeps.WsdlGroovyScriptTestStep.run(WsdlGroovyScriptTestStep.java:125)
at com.eviware.soapui.impl.wsdl.support.AbstractTestCaseRunner.runTestStep(AbstractTestCaseRunner.java:211)
at com.eviware.soapui.impl.wsdl.testcase.WsdlTestCaseRunner.runCurrentTestStep(WsdlTestCaseRunner.java:47)
at com.eviware.soapui.impl.wsdl.support.AbstractTestCaseRunner.internalRun(AbstractTestCaseRunner.java:138)
at com.eviware.soapui.impl.wsdl.support.AbstractTestCaseRunner.internalRun(AbstractTestCaseRunner.java:46)
at com.eviware.soapui.impl.wsdl.support.AbstractTestRunner.run(AbstractTestRunner.java:128)
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)
Even when I remove all code from my script I get the error. If I remove the whole script the test case runs without a problem. Anyone has an idea?

The syntax of your assert statement isn't correct. If you're testing for null, something like the following will work:
assert !context.response: "Response Empty or Null"
It's also looks like you're using the assertion to control your script logic, but this is not a good practice. An if-then-else clause would make your intent clearer.

Related

Strange error running a simple groovy script using Micronaut DI and Vertx

I have a project which is using Vertx and Micronaut DI
however something in this process breaks a simple capability in groovy of coercing a map to an interface
I have created a simple script like this. The same script in a simple groovy only project works just fine.
Has anyone else seen anything like this and what if anything needs to be fixed. I don't understand the error as the script itself isn't using DI or Vertx. I am assuming its something going wrong with Micronaut pre processors ?
package ioc
def map
map = [
i: 10,
hasNext: { map.i > 0 },
next: { map.i-- },
]
def iter = map as Iterator
iter.each {println it}
Which when i run it generates the following error.
Caught: java.lang.NoClassDefFoundError: io/vertx/codegen/annotations/DataObject
java.lang.NoClassDefFoundError: io/vertx/codegen/annotations/DataObject
at io.vertx.lang.groovy.VertxExtensionModule.asType(VertxExtensionModule.java:32)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at ioc.coerce.run(coerce.groovy:9)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
Caused by: java.lang.ClassNotFoundException: io.vertx.codegen.annotations.DataObject
... 8 more
Process finished with exit code 1
Has any one seen anything like this and were able to fix it? Its a bit weird by itself.

getRowCount() method on viewPanel control & database full text index error

I have simple code to count the rows in view panel control:
getComponent("viewPanel1").getRowCount()
Error calling method 'getRowCount()' on java class 'com.ibm.xsp.component.xp.XspViewPanel'
Stack trace shows the details as below:
Caused by: com.ibm.jscript.InterpretException: Script interpreter error, line=1, col=64: Error calling method 'getRowCount()' on java class 'com.ibm.xsp.component.xp.XspViewPanel'
Caused by: com.ibm.xsp.FacesExceptionEx: Notes error: The full text index for this database is in use
Caused by: NotesException: Notes error: The full text index for this database is in use
at lotus.domino.local.View.FTSearchSorted(Unknown Source)
Any quick solution to avoid these errors on server?
This is, in fact, a server issue. Take a look here or google it to fine-tune your server.

Getting StackTraceElement in groovy application

I have a piece of code that prints the current java file for logging purposes.
final StackTraceElement stackTraceElement = new Throwable().fillInStackTrace().getStackTrace()[2];
final String parentClassName = stackTraceElement.getFileName().replaceAll(".java", "");
final int lineNumber = stackTraceElement.getLineNumber();
I wrote something in groovy that uses the above code to print logs, it works, most of the time, however after couple of runs I'm starting to get NPE
java.lang.NullPointerException
at com.bla.general.util.log.LogUtils.generateLogMessage(LogUtils.java:140)
at com.bla.general.util.log.LogUtils.info(LogUtils.java:67)
at sun.reflect.GeneratedMethodAccessor831.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:324)
at org.codehaus.groovy.runtime.callsite.StaticMetaMethodSite.invoke(StaticMetaMethodSite.java:43)
at org.codehaus.groovy.runtime.callsite.StaticMetaMethodSite.call(StaticMetaMethodSite.java:88)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
at com.bla.AppVersionServiceImpl.getAppVersion(AppVersionServiceImpl.groovy:47)
When the following line is the originator:
LogUtils.info("Trying to get details for device hash ${deviceHash}");
I'm using tomcat and java 1.7 as my stack. After restarting Tomcat things get back to normal.
It's my first endeavor to the dynamic world of JVM. I'll appreciate if you can enlighten me

IllegalArgumentException during ImageIO.read()

I have an IllegalArgumentException and have no Idea how to fix it.
Exception in thread "Display" java.lang.ExceptionInInitializerError
at com.cube.zambezi.graphics.Sprite.<clinit>(Sprite.java:16)
at com.cube.zambezi.level.tile.Tile.<clinit>(Tile.java:15)
at com.cube.zambezi.level.Level.getTile(Level.java:95)
at com.cube.zambezi.level.Level.render(Level.java:71)
at com.cube.zambezi.Game.render(Game.java:172)
at com.cube.zambezi.Game.run(Game.java:142)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.IllegalArgumentException: input == null!
at javax.imageio.ImageIO.read(Unknown Source)
at com.cube.zambezi.graphics.SpriteSheet.load(SpriteSheet.java:34)
at com.cube.zambezi.graphics.SpriteSheet.<init>(SpriteSheet.java:29)
at com.cube.zambezi.graphics.SpriteSheet.<clinit>(SpriteSheet.java:19)
... 7 more
If you need more information, tell me.
You are trying to read an image, but your input is null.
Make sure you have a valid input, either from a stream, a file or a URL, and the problem is solved.
If you don't know in advance, a simple if (input != null) around the ImageIO.read will fix it.

groovy.lang$run.call(Unknown Source)

What is the meaning of groovy.lang$run.call(Unknown Source) and on what circumstances it will throw, this is the error what i'm getting in my groovy program
at groovy.lang$run.call(Unknown Source)
at groovy.lang.run(groovy.lang.Two_Script:6)
...................................................
...................................................
at groovy.lang.run(groovy.lang.Two_Script:6)
at groovy.lang$run.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:40)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:117)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:121)
at one_script.run(level_one_script.groovy:5)
why it has not thrown at the compile time only # runtime it has thrown any Idea ?
attached the sample groovy these are very simple recursive calls;
level_one_script.groovy
new Two_Script(binding).run()
Two_Script.groovy
new Three_Script().run()
Three_Script.groovy
println "Anish"
the exception was thrown while evaluating Three_Script.groovy , it give me recurive call on Two_Script.groovy
Exception occurred while executing the script [level_one_script.groovy] - [java.lang.StackOverflowError].
try
{
compiledScript.eval(bindings)
//compiledScript is the type of CompiledScript
}
Surprising part is if i remove the call new Three_Script().run() from "Two_Script.groovy"
it shows me correct result
Surprising
If the Groovy scripts are all defined in a package, the error is not thrown.
If the scripts are moved to the default package (no package), the error is thrown.
What is the actual exception thrown (first few lines)
Looks like there's problem in your file level_one_script.groovy at line 5

Resources