Uploaded image for project: 'Commons DbUtils'
  1. Commons DbUtils
  2. DBUTILS-9

[dbutils] MockResultSet needs to handle equals and hashCode

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.0
    • 1.1
    • None
    • Operating System: other
      Platform: Other

    • 31786

    Description

      Please amend MockResultSet#invoke like this in order to handel equals,
      hashCode, and toString

      public Object invoke(Object proxy, Method method, Object[] args)
      throws Throwable {

      String methodName = method.getName();

      if (methodName.equals("getMetaData"))

      { //... }

      else if (methodName.equals("equals"))

      { return Boolean.valueOf(proxy == args[0]); }

      else if (methodName.equals("hashCode"))

      { return Integer.valueOf(System.identityHashCode(proxy)); }

      else if (methodName.equals("toString"))

      { return proxy.toString(); }

      return null;
      }

      This addition makes proxies generated by MockResultSet usable in Maps. That
      might not look like a big deal, but it is. Among other things, EasyMock keeps
      arguments and return values in Maps. With the addition, MockResultSet proxies
      can be used with mock objects created by EasyMock.

      Michael

      Attachments

        Activity

          People

            Unassigned Unassigned
            mschuerig Michael Schuerig
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: