You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hbase.apache.org by "Ted Yu (JIRA)" <ji...@apache.org> on 2013/06/02 03:37:03 UTC

[jira] [Created] (HBASE-8673) Make code involving class.getMethod() more amenable to mocking

Ted Yu created HBASE-8673:
-----------------------------

             Summary: Make code involving class.getMethod() more amenable to mocking
                 Key: HBASE-8673
                 URL: https://issues.apache.org/jira/browse/HBASE-8673
             Project: HBase
          Issue Type: Test
            Reporter: Ted Yu
            Priority: Minor


In some place, such as the following (FSUtils#isInSafeMode), we retrieve method using getMethod() with hardcoded class name:
{code}
  private static boolean isInSafeMode(DistributedFileSystem dfs) throws IOException {
    boolean inSafeMode = false;
    try {
      Method m = DistributedFileSystem.class.getMethod("setSafeMode", new Class<?> []{
{code}
The above code is not friendly to mocking.
The test class may define its own DistributedFileSystem descendent class and pass an instance to FSUtils#isInSafeMode(). In that case, assertion similar to the following would fail:
{code}
    Mockito.verify(dfs, Mockito.times(1)).setSafeMode();
{code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira