Skip to content
Advertisement

Tag: groovy

Spock throw exception test

I test Java code with Spock. I test this code: I wrote test: And it fails because AnotherCustomExceptio is thrown. But in the try{}catch block I catch this exception and throw a CustomException so I expected that my method will throw CustomException and not AnotherCustomExceptio. How do I test it? Answer I believe your then block needs to be fixed.

Converter from Json into groovy CODE?

It’s a kind of odd question for an odd situation. I have a large JSON structure which I would like to represent in running groovy code. I need groovy objects that mirror the same structure as the JSON objects. As to be expected a web search mostly returns results with groovy/json runtime conversion stuff, but nothing about things that output

Gradle does not find tools.jar

I am using javadoc doclets with gradle, so I need to use the package tools.jar, which is in the lib folder from the jdk (1.6.0_26 in my case). The point is that gradle does not take it automatically, so I was adding that tools package to my libs folder, and then adding it to dependencies.gradle . Now I want to

Why does this Java/Groovy code cause heap memory exceptions?

This 3rd party script keeps causing heap memory exceptions: That part of the script, which receives messages through TCP/IP after receiving the message, causes the following exception: Exception in thread “Thread-2” org.codehaus.groovy.runtime.InvokerInvocationException: java.lang.OutOfMemoryError: Java heap space at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:92) at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:234) at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:272) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:880) at groovy.lang.Closure.call(Closure.java:279) at groovy.lang.Closure.call(Closure.java:292) at org.codehaus.groovy.runtime.DefaultGroovyMethods$6.run(DefaultGroovyMethods.java:11563) at java.lang.Thread.run(Thread.java:636) Caused by: java.lang.OutOfMemoryError: Java heap space at java.util.Arrays.copyOf(Arrays.java:2746)

groovy call private method in Java super class

I have an abstract Java class MyAbstractClass with a private method. There is a concrete implementation MyConcreteClass. In my groovy test class I have I get an error that there is no such method signature for somePrivateMethod. I know groovy can call private methods but I’m guessing the problem is that the private method is in the super class, not

Advertisement