You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by bu...@apache.org on 2004/10/19 20:45:37 UTC
DO NOT REPLY [Bug 31786] New: -
MockResultSet needs to handle equals and hashCode
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=31786>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND
INSERTED IN THE BUG DATABASE.
http://issues.apache.org/bugzilla/show_bug.cgi?id=31786
MockResultSet needs to handle equals and hashCode
Summary: MockResultSet needs to handle equals and hashCode
Product: Commons
Version: unspecified
Platform: Other
OS/Version: Other
Status: NEW
Severity: Normal
Priority: Other
Component: DbUtils
AssignedTo: commons-dev@jakarta.apache.org
ReportedBy: michael@schuerig.de
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
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org