Open ka2ddo opened 3 years ago
I stand corrected. On the same platform as above, but using mockito 4.0.0, I received a different failure:
[1018 11:23:37,483] INFO - CommunicationManager - BitTorrent client signing off. [1018 11:23:37,484] INFO - rent.tracker.Tracker - BitTorrent tracker closed. [1018 11:23:37,484] INFO - rent.tracker.Tracker - Peer collection terminated. [1018 11:23:37,486] INFO - rent.tracker.Tracker - Starting BitTorrent tracker on http://192.168.68.73:6969/announce... [1018 11:23:37,487] INFO - rent.tracker.Tracker - Started torrent tracker on /0.0.0.0:6969 [1018 11:27:22,807] INFO - rent.tracker.Tracker - BitTorrent tracker closed. [1018 11:27:22,807] INFO - rent.tracker.Tracker - Peer collection terminated. [1018 11:27:27,810] INFO - rent.tracker.Tracker - Starting BitTorrent tracker on http://192.168.68.73:6969/announce... [1018 11:27:27,811] INFO - rent.tracker.Tracker - Started torrent tracker on /0.0.0.0:6969 [1018 11:27:27,834] INFO - CommunicationManager - BitTorrent client [..363966] started and listening at 0.0.0.0:6882... [1018 11:27:27,835] INFO - nt.announce.Announce - Starting announce loop... [1018 11:27:28,342] INFO - nt.announce.Announce - Exited announce loop. [1018 11:27:28,342] INFO - CommunicationManager - BitTorrent client signing off. [1018 11:27:28,343] INFO - rent.tracker.Tracker - BitTorrent tracker closed. [1018 11:27:28,343] INFO - rent.tracker.Tracker - Peer collection terminated. [1018 11:27:28,344] INFO - rent.tracker.Tracker - Starting BitTorrent tracker on http://192.168.68.73:6969/announce... [1018 11:27:28,345] INFO - rent.tracker.Tracker - Started torrent tracker on /0.0.0.0:6969 [1018 11:27:28,368] INFO - CommunicationManager - BitTorrent client [..303939] started and listening at 0.0.0.0:6882... [1018 11:27:28,368] INFO - nt.announce.Announce - Starting announce loop... [1018 11:27:28,871] INFO - nt.announce.Announce - Exited announce loop. [1018 11:27:28,871] INFO - CommunicationManager - BitTorrent client signing off. [1018 11:27:28,872] INFO - rent.tracker.Tracker - BitTorrent tracker closed. [1018 11:27:28,872] INFO - rent.tracker.Tracker - Peer collection terminated. [1018 11:27:28,872] INFO - rent.tracker.Tracker - Starting BitTorrent tracker on http://192.168.68.73:6969/announce... [1018 11:27:28,873] INFO - rent.tracker.Tracker - Started torrent tracker on /0.0.0.0:6969 [1018 11:27:28,919] INFO - CommunicationManager - BitTorrent client [..313634] started and listening at 0.0.0.0:6882... [1018 11:27:28,920] INFO - nt.announce.Announce - Starting announce loop... [1018 11:27:28,920] INFO - CommunicationManager - BitTorrent client [..386265] started and listening at 0.0.0.0:6883... [1018 11:27:28,920] INFO - nt.announce.Announce - Starting announce loop... [1018 11:27:28,925] INFO - client.SharedTorrent - Running end-game mode, currently available 17/35 pieces [1018 11:27:28,926] INFO - client.SharedTorrent - all pieces are received for torrent SharedTorrent{[file1.jar]}. Validating... [1018 11:27:28,951] INFO - CommunicationManager - Download of file1.jar complete. [1018 11:27:29,425] INFO - nt.announce.Announce - Exited announce loop. [1018 11:27:29,425] INFO - CommunicationManager - BitTorrent client signing off. [1018 11:27:29,427] INFO - nt.announce.Announce - Exited announce loop. [1018 11:27:29,428] INFO - CommunicationManager - BitTorrent client signing off. [1018 11:27:29,429] INFO - rent.tracker.Tracker - BitTorrent tracker closed. [1018 11:27:29,429] INFO - rent.tracker.Tracker - Peer collection terminated. [1018 11:27:29,431] INFO - rent.tracker.Tracker - Starting BitTorrent tracker on http://192.168.68.73:6969/announce... [1018 11:27:29,432] INFO - rent.tracker.Tracker - Started torrent tracker on /0.0.0.0:6969 [1018 11:27:29,432] INFO - CommunicationManager - BitTorrent client [..653563] started and listening at 0.0.0.0:6882... [1018 11:27:29,432] INFO - nt.announce.Announce - Starting announce loop... [1018 11:27:29,458] INFO - CommunicationManager - BitTorrent client [..323739] started and listening at 0.0.0.0:6883... [1018 11:27:29,458] INFO - nt.announce.Announce - Starting announce loop... [1018 11:27:29,485] INFO - nt.announce.Announce - Exited announce loop. [1018 11:27:29,485] INFO - CommunicationManager - BitTorrent client signing off. [1018 11:27:29,487] INFO - nt.announce.Announce - Exited announce loop. [1018 11:27:29,488] INFO - CommunicationManager - BitTorrent client signing off. [1018 11:27:29,488] INFO - rent.tracker.Tracker - BitTorrent tracker closed. [1018 11:27:29,488] INFO - rent.tracker.Tracker - Peer collection terminated. [1018 11:27:29,488] INFO - rent.tracker.Tracker - Starting BitTorrent tracker on http://192.168.68.73:6969/announce... [1018 11:27:29,489] INFO - rent.tracker.Tracker - Started torrent tracker on /0.0.0.0:6969 [1018 11:27:29,489] INFO - rent.tracker.Tracker - BitTorrent tracker closed. [1018 11:27:29,489] INFO - rent.tracker.Tracker - Peer collection terminated. [1018 11:27:29,490] INFO - rent.tracker.Tracker - Starting BitTorrent tracker on http://192.168.68.73:6969/announce... [1018 11:27:29,490] INFO - rent.tracker.Tracker - Started torrent tracker on /0.0.0.0:6969 [1018 11:27:29,515] INFO - CommunicationManager - BitTorrent client [..653733] started and listening at 0.0.0.0:6882... [1018 11:27:29,515] INFO - nt.announce.Announce - Starting announce loop... [1018 11:27:39,622] INFO - nt.announce.Announce - Exited announce loop. [1018 11:27:39,623] INFO - CommunicationManager - BitTorrent client signing off. [1018 11:27:39,623] INFO - rent.tracker.Tracker - BitTorrent tracker closed. [1018 11:27:39,623] INFO - rent.tracker.Tracker - Peer collection terminated. Tests run: 39, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 447.068 sec <<< FAILURE! testThatTorrentsHaveLazyInitAndRemovingAfterDownload(com.turn.ttorrent.client.CommunicationManagerTest) Time elapsed: 10879 sec <<< FAILURE! java.lang.AssertionError: Torrent was not successfully initialized expected [true] but found [false] at org.testng.Assert.fail(Assert.java:94) at org.testng.Assert.failNotEquals(Assert.java:494) at org.testng.Assert.assertTrue(Assert.java:42) at com.turn.ttorrent.client.CommunicationManagerTest.testThatTorrentsHaveLazyInitAndRemovingAfterDownload(CommunicationManagerTest.java:692)
Results :
Failed tests: testThatTorrentsHaveLazyInitAndRemovingAfterDownload(com.turn.ttorrent.client.CommunicationManagerTest): Torrent was not successfully initialized expected [true] but found [false]
Note the timestamps, indicating that the last test took almost 4 minutes to run without any output until it started flooding output again.
When compiling ttorrent on Mac OS X with Java 11, the build fails at the default-test phase with the following error:
setUp(com.turn.ttorrent.network.keyProcessors.CleanupKeyProcessorTest) Time elapsed: 482 sec <<< FAILURE! org.mockito.exceptions.base.MockitoException: Mockito cannot mock this class: interface com.turn.ttorrent.network.ConnectionListener. Mockito can only mock non-private & non-final classes. If you're not sure why you're getting this error, please report to the mailing list. Java : 11 JVM vendor name : Oracle Corporation JVM vendor version : 11.0.11+9-LTS-194 JVM name : Java HotSpot(TM) 64-Bit Server VM JVM version : 11.0.11+9-LTS-194 JVM info : mixed mode OS name : Mac OS X OS version : 10.15.7 Underlying exception : java.lang.UnsupportedOperationException: Cannot define class using reflection at com.turn.ttorrent.network.keyProcessors.CleanupKeyProcessorTest.setUp(CleanupKeyProcessorTest.java:30) Caused by: java.lang.UnsupportedOperationException: Cannot define class using reflection at net.bytebuddy.dynamic.loading.ClassInjector$UsingReflection$Dispatcher$Unavailable.defineClass(ClassInjector.java:821) at net.bytebuddy.dynamic.loading.ClassInjector$UsingReflection.inject(ClassInjector.java:185) at net.bytebuddy.dynamic.loading.ClassLoadingStrategy$Default$InjectionDispatcher.load(ClassLoadingStrategy.java:187) at net.bytebuddy.dynamic.TypeResolutionStrategy$Passive.initialize(TypeResolutionStrategy.java:79) at net.bytebuddy.dynamic.DynamicType$Default$Unloaded.load(DynamicType.java:4456) at org.mockito.internal.creation.bytebuddy.SubclassBytecodeGenerator.mockClass(SubclassBytecodeGenerator.java:121) at org.mockito.internal.creation.bytebuddy.TypeCachingBytecodeGenerator$1.call(TypeCachingBytecodeGenerator.java:37) at org.mockito.internal.creation.bytebuddy.TypeCachingBytecodeGenerator$1.call(TypeCachingBytecodeGenerator.java:34) at net.bytebuddy.TypeCache.findOrInsert(TypeCache.java:138) at net.bytebuddy.TypeCache$WithInlineExpunction.findOrInsert(TypeCache.java:346) at net.bytebuddy.TypeCache.findOrInsert(TypeCache.java:161) at net.bytebuddy.TypeCache$WithInlineExpunction.findOrInsert(TypeCache.java:355) at org.mockito.internal.creation.bytebuddy.TypeCachingBytecodeGenerator.mockClass(TypeCachingBytecodeGenerator.java:32) at org.mockito.internal.creation.bytebuddy.SubclassByteBuddyMockMaker.createMockType(SubclassByteBuddyMockMaker.java:71) at org.mockito.internal.creation.bytebuddy.SubclassByteBuddyMockMaker.createMock(SubclassByteBuddyMockMaker.java:42) at org.mockito.internal.creation.bytebuddy.ByteBuddyMockMaker.createMock(ByteBuddyMockMaker.java:25) at org.mockito.internal.util.MockUtil.createMock(MockUtil.java:35) at org.mockito.internal.MockitoCore.mock(MockitoCore.java:65) at org.mockito.Mockito.mock(Mockito.java:1821) at org.mockito.Mockito.mock(Mockito.java:1734) ... 37 more Caused by: java.lang.IllegalStateException: Could not find sun.misc.Unsafe at net.bytebuddy.dynamic.loading.ClassInjector$UsingUnsafe$Dispatcher$Disabled.initialize(ClassInjector.java:1357) at net.bytebuddy.dynamic.loading.ClassInjector$UsingUnsafe.inject(ClassInjector.java:1193) at net.bytebuddy.dynamic.loading.ClassLoadingStrategy$ForUnsafeInjection.load(ClassLoadingStrategy.java:458) at net.bytebuddy.dynamic.TypeResolutionStrategy$Passive.initialize(TypeResolutionStrategy.java:79) at net.bytebuddy.dynamic.DynamicType$Default$Unloaded.load(DynamicType.java:4456) at net.bytebuddy.dynamic.loading.ClassInjector$UsingReflection$Dispatcher$Indirect.make(ClassInjector.java:684) at net.bytebuddy.dynamic.loading.ClassInjector$UsingReflection$Dispatcher$CreationAction.run(ClassInjector.java:302) at net.bytebuddy.dynamic.loading.ClassInjector$UsingReflection$Dispatcher$CreationAction.run(ClassInjector.java:290) at java.base/java.security.AccessController.doPrivileged(Native Method) at net.bytebuddy.dynamic.loading.ClassInjector$UsingReflection.(ClassInjector.java:70)
at net.bytebuddy.dynamic.loading.ClassLoadingStrategy$Default$InjectionDispatcher.load(ClassLoadingStrategy.java:184)
... 54 more
Caused by: java.lang.NoSuchMethodException: sun.misc.Unsafe.defineClass(java.lang.String, [B, int, int, java.lang.ClassLoader, java.security.ProtectionDomain)
at java.base/java.lang.Class.getMethod(Class.java:2108)
at net.bytebuddy.dynamic.loading.ClassInjector$UsingUnsafe$Dispatcher$CreationAction.run(ClassInjector.java:1260)
at net.bytebuddy.dynamic.loading.ClassInjector$UsingUnsafe$Dispatcher$CreationAction.run(ClassInjector.java:1248)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at net.bytebuddy.dynamic.loading.ClassInjector$UsingUnsafe.(ClassInjector.java:1127)
... 63 more
Presumably, this is due to the module feature introduced in Java 9 to make it harder to probe other module's code that is not officially exposed as an API. Are there plans to upgrade to a newer version of mockito that can deal with this issue? I tried hacking the pom.xml file to use mockito 4.0.0 and the build succeeded.