hbase-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ted Yu (JIRA)" <j...@apache.org>
Subject [jira] [Created] (HBASE-8673) Make code involving class.getMethod() more amenable to mocking
Date Sun, 02 Jun 2013 01:37:03 GMT
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:
  private static boolean isInSafeMode(DistributedFileSystem dfs) throws IOException {
    boolean inSafeMode = false;
    try {
      Method m = DistributedFileSystem.class.getMethod("setSafeMode", new Class<?> []{
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:
    Mockito.verify(dfs, Mockito.times(1)).setSafeMode();

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

View raw message