Uploaded image for project: 'HBase'
  1. HBase
  2. HBASE-11019

incCount() method should be properly stubbed in HConnectionTestingUtility#getMockedConnectionAndDecorate()

    XMLWordPrintableJSON

Details

    • Test
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • None
    • 0.99.0
    • None
    • None
    • Reviewed

    Description

      From https://builds.apache.org/job/PreCommit-HBASE-Build/9306//testReport/org.apache.hadoop.hbase.master/TestAssignmentManager/testClosingFailureDuringRecovery/ :

      org.mockito.exceptions.base.MockitoException: 
      'incCount' is a *void method* and it *cannot* be stubbed with a *return value*!
      Voids are usually stubbed with Throwables:
          doThrow(exception).when(mock).someVoidMethod();
      ***
      If you're unsure why you're getting above error read on.
      Due to the nature of the syntax above problem might occur because:
      1. The method you are trying to stub is *overloaded*. Make sure you are calling the right overloaded version.
      2. Somewhere in your test you are stubbing *final methods*. Sorry, Mockito does not verify/stub final methods.
      3. A spy is stubbed using when(spy.foo()).then() syntax. It is safer to stub spies - 
         - with doReturn|Throw() family of methods. More in javadocs for Mockito.spy() method.
      
      	at org.apache.hadoop.hbase.client.HConnectionTestingUtility.getMockedConnectionAndDecorate(HConnectionTestingUtility.java:124)
      	at org.apache.hadoop.hbase.master.TestAssignmentManager.setUpMockedAssignmentManager(TestAssignmentManager.java:1141)
      	at org.apache.hadoop.hbase.master.TestAssignmentManager.testClosingFailureDuringRecovery(TestAssignmentManager.java:1027)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      	at java.lang.reflect.Method.invoke(Method.java:597)
      	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
      	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
      

      incCount() should be properly stubbed.

      Attachments

        1. 11019-v1.txt
          1 kB
          Ted Yu

        Activity

          People

            yuzhihong@gmail.com Ted Yu
            yuzhihong@gmail.com Ted Yu
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: