easymock / easymock

EasyMock, makes mocking easier since 2001
http://easymock.org
820 stars 313 forks source link

Linkage Error with FacesContext #594

Closed MMetz-OV closed 4 months ago

MMetz-OV commented 5 months ago

After updating from EasyMock 4.3 to 5.2.0 I am facing the follwing problem:

The single line:

EasyMock.createMock(jakarta.faces.context.FacesContext.class);

ends up in an exception, containing:

Caused by: java.lang.LinkageError: bad field type alias: class org.easymock.internal.ClassMockingData not visible from class jakarta.faces.context.FacesContext$$$EasyMock$1

but only within an Arquillian test, not within a normal JSE test.

I found similar issues but seems to be fixed with 5.2.0. Did I miss something? Or is there any option with --add-opens command to avoid this problem?

henri-tremblay commented 5 months ago

Yeah. You have similar issues mentioned. I fixed one but there are some other use cases. A full test to reproduce can help me. It's my next issue in line.

MMetz-OV commented 4 months ago

A complete Java file is easy. But defining all the dependencies for an Arquillian is another story. Unfortunately I do not work with Maven. Maybe someone else can deliver a POM file? If you really need it, I have to take care about, but at the moment I do not have a POM.

The complete minmal Java file is:

package de.packagename.test;

import jakarta.faces.context.FacesContext;

import org.easymock.EasyMock;

import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.EnterpriseArchive;
import org.jboss.shrinkwrap.api.spec.JavaArchive;

import org.junit.Test;
import org.junit.runner.RunWith;

@RunWith(Arquillian.class)
public class EasyMockProblem_JEE_Test {

    @Deployment
    public static Archive<?> createDeployment() {
        JavaArchive archive = ShrinkWrap.create(JavaArchive.class, "testcode.jar")
                .addPackages(true, "de.packagename.test");

        EnterpriseArchive ear=ShrinkWrap.create(EnterpriseArchive.class,"myEar.ear")
                .addAsLibrary(archive);
        return ear;
    }

    @Test
    public void testSomething() {
        FacesContext myMock=EasyMock.createMock(FacesContext.class);
        System.out.println("Mock: "+myMock);
    }

}
MMetz-OV commented 4 months ago

Just for the records: Same behaviour with version 5.3.0. I am looking forward to 5.4.0.

MMetz-OV commented 4 months ago

Thanks for fixing. Is there a kind of nightly build to test the fix? And do you have a rough idea of when version 5.4.0 will be released?

henri-tremblay commented 4 months ago

You can clone and build yourself. It's fairly easy with a simple mvn install. I should release this month. Please tell me if it works or not.

MMetz-OV commented 2 months ago

Just tested and works fine. I need now some more dependencies in JEE context but that's another story. Thanks for the fast fix!