<#C02T98BKE2K> I am facing below issue when I writ...
# nextflow-plugins
u
#C02T98BKE2K I am facing below issue when I writing Mock object in spock.Specification test classes. Any idea why it is happening?
Copy code
def sessionMock(Session) {
    getConfig() >> [ [hello: 'test'] ]
}
Error
Copy code
java.lang.ExceptionInInitializerError
	at org.spockframework.mock.runtime.CglibMockFactory.createMock(CglibMockFactory.java:24)
	at org.spockframework.mock.runtime.ProxyBasedMockFactory.create(ProxyBasedMockFactory.java:45)
	at org.spockframework.mock.runtime.JavaMockFactory.createInternal(JavaMockFactory.java:58)
	at org.spockframework.mock.runtime.JavaMockFactory.create(JavaMockFactory.java:38)
	at org.spockframework.mock.runtime.CompositeMockFactory.create(CompositeMockFactory.java:44)
	at org.spockframework.lang.SpecInternals.createMock(SpecInternals.java:50)
	at org.spockframework.lang.SpecInternals.createMockImpl(SpecInternals.java:305)
	at org.spockframework.lang.SpecInternals.createMockImpl(SpecInternals.java:295)
	at org.spockframework.lang.SpecInternals.MockImpl(SpecInternals.java:108)
Caused by: net.sf.cglib.core.CodeGenerationException: java.lang.reflect.InaccessibleObjectException-->Unable to make protected final java.lang.Class java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain) throws java.lang.ClassFormatError accessible: module java.base does not "opens java.lang" to unnamed module @7549926c
	at app//net.sf.cglib.core.ReflectUtils.defineClass(ReflectUtils.java:464)
b
That code doesn't look right, mocking a function with
>>
should happen inside a mock constructor or under a Spock label like
when:
or
then:
For example:
Copy code
def session = Mock(Session) {
  getConfig() >> [ ... ]
}
u
sorry @Ben Sherman, you are right. this is my code
Copy code
import nextflow.Session
import spock.lang.Specification

class HelloTest extends Specification {

    def 'should test config' () {
        given:
        def a = 'hello'
        when:
        def session = Mock(Session) {
            getConfig() >> [test: a]
        }
        def cfg = session.getConfig()
        then:
        cfg.test == 'hello'
    }
}
u
tks @Ben Sherman for prompt reply. I found root cause. I was missing this in gradle. now it worked. https://github.com/nextflow-io/nextflow/blob/master/build.gradle#L140-L163