Uploaded image for project: 'Maven'
  1. Maven
  2. MNG-6472

Mockito cannot mock this class: interface org.eclipse.aether.impl.RepositoryEventDispatcher

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 3.5.4
    • 3.6.0
    • None
    • None
    • Java 11

    Description

      Failed org.apache.maven.repository.internal.DefaultArtifactDescriptorReaderTest test under Java 11 with error:

      109970 [ERROR] org.apache.maven.plugin.surefire.SurefirePlugin - Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 2.208 s <<< FAILURE! - in org.apache.maven.repository.internal.DefaultArtifactDescriptorReaderTest
      110004 [ERROR] org.apache.maven.plugin.surefire.SurefirePlugin - testMng5459(org.apache.maven.repository.internal.DefaultArtifactDescriptorReaderTest) Time elapsed: 2.118 s <<< ERROR!
      org.mockito.exceptions.base.MockitoException:
      Mockito cannot mock this class: interface org.eclipse.aether.impl.RepositoryEventDispatcher.
      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 : Azul Systems, Inc.
      JVM vendor version : 11-ea+22
      JVM name : OpenJDK 64-Bit Server VM
      JVM version : 11-ea+22
      JVM info : mixed mode
      OS name : Windows 10
      OS version : 10.0
      
      Underlying exception : java.lang.UnsupportedOperationException: Cannot define class using reflection
      at org.apache.maven.repository.internal.DefaultArtifactDescriptorReaderTest.testMng5459(DefaultArtifactDescriptorReaderTest.java:43)
      Caused by: java.lang.UnsupportedOperationException: Cannot define class using reflection
      at org.apache.maven.repository.internal.DefaultArtifactDescriptorReaderTest.testMng5459(DefaultArtifactDescriptorReaderTest.java:43)
      Caused by: java.lang.IllegalStateException: Could not find sun.misc.Unsafe
      at org.apache.maven.repository.internal.DefaultArtifactDescriptorReaderTest.testMng5459(DefaultArtifactDescriptorReaderTest.java:43)
      Caused by: java.lang.NoSuchMethodException: sun.misc.Unsafe.defineClass(java.lang.String, [B, int, int, java.lang.ClassLoader, java.security.ProtectionDomain)
      at org.apache.maven.repository.internal.DefaultArtifactDescriptorReaderTest.testMng5459(DefaultArtifactDescriptorReaderTest.java:43)
      

       

      Update the Mockito to latest version 2.21.0 can solve the issue.

      Attachments

        Issue Links

          Activity

            People

              slachiewicz Sylwester Lachiewicz
              slachiewicz Sylwester Lachiewicz
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: