Hello Community,
I need to provide a number of test objects for a unit test. (MOrder, MOrderLine, ...)
I thought the easiest would be to just serialize the objects from my test case to Json, then deserialize these into objects when setting up the tests.
Unfortunately I can't get it to work. Any attempt to serialization runs into a java.lang.reflect.InaccessibleObjectException.
Has anybody successfully integrated a library that uses reflection within iDempiere?
Is there an easy way to do it?
I already tired java serialization, but that is nor really usable in that context. I am afraid the test will break beyond repair if the serialized classes are modified later on.
Also I need the test data to be editable which is not possible with the java byte format.
If json serialization should not be an option what else could I do to generate POs that look and behave like the real thing? Note: I can not read my test data from the database because then the test would not be reproducible within the constraints of the test environment.
Stack Trace:
java.lang.reflect.InaccessibleObjectException: Unable to make private java.lang.module.Configuration() accessible: module java.base does not "opens java.lang.module" to unnamed module @4702aecf
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:340)
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:280)
at java.base/java.lang.reflect.Constructor.checkCanSetAccessible(Constructor.java:189)
at java.base/java.lang.reflect.Constructor.setAccessible(Constructor.java:182)
at com.google.gson.internal.ConstructorConstructor.newDefaultConstructor(ConstructorConstructor.java:101)
at com.google.gson.internal.ConstructorConstructor.get(ConstructorConstructor.java:83)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:99)
at com.google.gson.Gson.getAdapter(Gson.java:423)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.createBoundField(ReflectiveTypeAdapterFactory.java:115)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:164)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:100)