GZoltar / gzoltar

GZoltar - Java Library for Automatic Debugging http://www.gzoltar.com
Other
77 stars 34 forks source link

Unexpected failing tests on D4J v2.0.0 #71

Open jose opened 1 year ago

jose commented 1 year ago

GZoltar v1.7.4-SNAPSHOT (<= 14f7d65) reports a few extra non-expecting-triggering test cases on 102 bugs out of the 835 in D4J v2.0.0 (<= b8954f0). Here's the breakdown.

Compress-36

Wanted but not invoked:
inflater.end();
-> at org.apache.commons.compress.archivers.sevenz.SevenZNativeHeapTest.testEndInflaterOnCloseStream(SevenZNativeHeapTest.java:62)
Actually, there were zero interactions with this mock.
  at org.apache.commons.compress.archivers.sevenz.SevenZNativeHeapTest.testEndInflaterOnCloseStream(SevenZNativeHeapTest.java:62)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.lang.reflect.Method.invoke(Method.java:498)
  at org.junit.internal.runners.TestMethod.invoke(TestMethod.java:68)
  at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$PowerMockJUnit44MethodRunner.runTestMethod(PowerMockJUnit44RunnerDelegateImpl.java:310)
  at org.junit.internal.runners.MethodRoadie$2.run(MethodRoadie.java:88)
  at org.junit.internal.runners.MethodRoadie.runBeforesThenTestThenAfters(MethodRoadie.java:96)
  at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$PowerMockJUnit44MethodRunner.executeTest(PowerMockJUnit44RunnerDelegateImpl.java:294)
  at org.powermock.modules.junit4.internal.impl.PowerMockJUnit47RunnerDelegateImpl$PowerMockJUnit47MethodRunner.executeTestInSuper(PowerMockJUnit47RunnerDelegateImpl.java:127)
  at org.powermock.modules.junit4.internal.impl.PowerMockJUnit47RunnerDelegateImpl$PowerMockJUnit47MethodRunner.executeTest(PowerMockJUnit47RunnerDelegateImpl.java:82)
  at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$PowerMockJUnit44MethodRunner.runBeforesThenTestThenAfters(PowerMockJUnit44RunnerDelegateImpl.java:282)
  at org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie.java:86)
  at org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:49)
  at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.invokeTestMethod(PowerMockJUnit44RunnerDelegateImpl.java:207)
  at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.runMethods(PowerMockJUnit44RunnerDelegateImpl.java:146)
  at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$1.run(PowerMockJUnit44RunnerDelegateImpl.java:120)
  at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:33)
  at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:45)
  at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.run(PowerMockJUnit44RunnerDelegateImpl.java:122)
  at org.powermock.modules.junit4.common.internal.impl.JUnit4TestSuiteChunkerImpl.run(JUnit4TestSuiteChunkerImpl.java:106)
  at org.powermock.modules.junit4.common.internal.impl.AbstractCommonPowerMockRunner.run(AbstractCommonPowerMockRunner.java:53)
  at org.powermock.modules.junit4.PowerMockRunner.run(PowerMockRunner.java:59)
  at org.junit.runner.JUnitCore.run(JUnitCore.java:160)
  at org.junit.runner.JUnitCore.run(JUnitCore.java:138)
  at com.gzoltar.internal.core.test.junit.JUnitTestTask.call(JUnitTestTask.java:57)
  at com.gzoltar.internal.core.test.junit.JUnitTestTask.call(JUnitTestTask.java:25)
  at java.util.concurrent.FutureTask.run(FutureTask.java:266)
  at java.lang.Thread.run(Thread.java:748)

JacksonDatabind-{23,24,25,26,27,28,29,30,31,32,33,34,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57}

org.mockito.exceptions.base.MockitoException:
Cannot mock/spy class com.fasterxml.jackson.databind.type.TypeFactory
Mockito cannot mock/spy following:
  - final classes
  - anonymous classes
  - primitive types
    at com.fasterxml.jackson.databind.type.TestTypeFactoryWithClassLoader.testUsesCorrectClassLoaderWhenThreadClassLoaderIsNull(TestTypeFactoryWithClassLoader.java:51)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.junit.internal.runners.TestMethod.invoke(TestMethod.java:68)
    at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$PowerMockJUnit44MethodRunner.runTestMethod(PowerMockJUnit44RunnerDelegateImpl.java:310)
    at org.junit.internal.runners.MethodRoadie$2.run(MethodRoadie.java:88)
    at org.junit.internal.runners.MethodRoadie.runBeforesThenTestThenAfters(MethodRoadie.java:96)
    at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$PowerMockJUnit44MethodRunner.executeTest(PowerMockJUnit44RunnerDelegateImpl.java:294)
    at org.powermock.modules.junit4.internal.impl.PowerMockJUnit47RunnerDelegateImpl$PowerMockJUnit47MethodRunner.executeTestInSuper(PowerMockJUnit47RunnerDelegateImpl.java:127)
    at org.powermock.modules.junit4.internal.impl.PowerMockJUnit47RunnerDelegateImpl$PowerMockJUnit47MethodRunner.executeTest(PowerMockJUnit47RunnerDelegateImpl.java:82)
    at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$PowerMockJUnit44MethodRunner.runBeforesThenTestThenAfters(PowerMockJUnit44RunnerDelegateImpl.java:282)
    at org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie.java:86)
    at org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:49)
    at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.invokeTestMethod(PowerMockJUnit44RunnerDelegateImpl.java:207)
    at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.runMethods(PowerMockJUnit44RunnerDelegateImpl.java:146)
    at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$1.run(PowerMockJUnit44RunnerDelegateImpl.java:120)
    at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:33)
    at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:45)
    at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.run(PowerMockJUnit44RunnerDelegateImpl.java:122)
    at org.powermock.modules.junit4.common.internal.impl.JUnit4TestSuiteChunkerImpl.run(JUnit4TestSuiteChunkerImpl.java:106)
    at org.powermock.modules.junit4.common.internal.impl.AbstractCommonPowerMockRunner.run(AbstractCommonPowerMockRunner.java:53)
    at org.powermock.modules.junit4.PowerMockRunner.run(PowerMockRunner.java:59)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:160)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:138)
    at com.gzoltar.internal.core.test.junit.JUnitTestTask.call(JUnitTestTask.java:57)
    at com.gzoltar.internal.core.test.junit.JUnitTestTask.call(JUnitTestTask.java:25)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.lang.Thread.run(Thread.java:748)

Excluding com.fasterxml.jackson.databind.type.TypeFactory from being instrumented by GZoltar addresses this issue. 🤷‍♂️ Thus, I would suggest one to first investigate the bytecode produced by GZoltar for that particular class.

Mockito-{6,7,8,9,10,11,21,22,23,24}

org.mockito.exceptions.base.MockitoException:
ClassCastException occurred while creating the mockito proxy :
  class to mock : 'test.Interface1', loaded by classloader : 'org.mockitoutil.ClassLoaders$InMemoryClassLoader@109d5023'
  created class : 'test.Interface1$$EnhancerByMockitoWithCGLIB$$65e49476', loaded by classloader : 'org.mockito.internal.creation.util.SearchingClassLoader@1d9508e1'
  proxy instance class : null
  instance creation by : ObjenesisInstantiator

You might experience classloading issues, disabling the Objenesis cache *might* help (see MockitoConfiguration)
  at org.mockito.internal.creation.cglib.ClassImposterizer.imposterise(ClassImposterizer.java:61)
  at org.mockito.internal.creation.cglib.ClassImposterizer.imposterise(ClassImposterizer.java:49)
  at org.mockito.internal.creation.cglib.CglibMockMaker.createMock(CglibMockMaker.java:24)
  at org.mockito.internal.util.MockUtil.createMock(MockUtil.java:33)
  at org.mockito.internal.MockitoCore.mock(MockitoCore.java:59)
  at org.mockito.Mockito.mock(Mockito.java:1285)
  at org.mockitousage.basicapi.MockingMultipleInterfacesTest.should_mock_class_with_interfaces_of_different_class_loader_AND_different_classpaths(MockingMultipleInterfacesTest.java:108)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.lang.reflect.Method.invoke(Method.java:498)
  at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
  at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
  at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
  at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
  at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
  at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
  at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
  at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
  at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
  at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
  at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
  at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
  at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
  at org.junit.runner.JUnitCore.run(JUnitCore.java:160)
  at org.junit.runner.JUnitCore.run(JUnitCore.java:138)
  at com.gzoltar.internal.core.test.junit.JUnitTestTask.call(JUnitTestTask.java:57)
  at com.gzoltar.internal.core.test.junit.JUnitTestTask.call(JUnitTestTask.java:25)
  at java.util.concurrent.FutureTask.run(FutureTask.java:266)
  at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.ClassCastException: test.Interface1$$EnhancerByMockitoWithCGLIB$$65e49476 cannot be cast to org.mockito.cglib.proxy.Factory
  at org.mockito.internal.creation.cglib.ClassImposterizer.createProxy(ClassImposterizer.java:143)
  at org.mockito.internal.creation.cglib.ClassImposterizer.imposterise(ClassImposterizer.java:58)
  ... 29 more

JxPath-{1,2,3}

java.lang.NoSuchMethodError: javax.xml.parsers.DocumentBuilderFactory.setIgnoringElementContentWhitespace(Z)V
        at org.apache.commons.jxpath.xml.DOMParser.parseXML(DOMParser.java:40)
        at org.apache.commons.jxpath.xml.DocumentContainer.parseXML(DocumentContainer.java:143)
        at org.apache.commons.jxpath.xml.DocumentContainer.getValue(DocumentContainer.java:111)
        at org.apache.commons.jxpath.ri.axes.TestBeanWithNode.createTestBeanWithDOM(TestBeanWithNode.java:58)
        at org.apache.commons.jxpath.ri.axes.SimplePathInterpreterTest.setUp(SimplePathInterpreterTest.java:60)
        at junit.framework.TestCase.runBare(TestCase.java:139)
        at junit.framework.TestResult$1.protect(TestResult.java:122)
        at junit.framework.TestResult.runProtected(TestResult.java:142)
        at junit.framework.TestResult.run(TestResult.java:125)
        at junit.framework.TestCase.run(TestCase.java:129)
        at junit.framework.TestSuite.runTest(TestSuite.java:255)
        at junit.framework.TestSuite.run(TestSuite.java:250)
        at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:84)
        at org.junit.runner.JUnitCore.run(JUnitCore.java:160)
        at org.junit.runner.JUnitCore.run(JUnitCore.java:138)
        at com.gzoltar.internal.core.test.junit.JUnitTestTask.call(JUnitTestTask.java:57)
        at com.gzoltar.internal.core.test.junit.JUnitTestTask.call(JUnitTestTask.java:25)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.lang.Thread.run(Thread.java:748)

As far I understood, the javax.xml.parsers.DocumentBuilderFactory class is present in two jar files (target/lib/xml-apis-2.0.2.jar and target/lib/xerces-1.2.3.jar) and GZoltar's classloader ends up picking the incorrect one. 🤷‍♂️