You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by rd...@apache.org on 2002/11/19 21:13:19 UTC
cvs commit: jakarta-commons/betwixt/src/test/org/apache/commons/betwixt AddressBean.java CustomerBean.java PersonBean.java
rdonkin 2002/11/19 12:13:18
Modified: betwixt/src/test/org/apache/commons/betwixt AddressBean.java
CustomerBean.java PersonBean.java
Log:
Test case comparison improvements. Submitted by Michael Davey.
Revision Changes Path
1.2 +12 -1 jakarta-commons/betwixt/src/test/org/apache/commons/betwixt/AddressBean.java
Index: AddressBean.java
===================================================================
RCS file: /home/cvs/jakarta-commons/betwixt/src/test/org/apache/commons/betwixt/AddressBean.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- AddressBean.java 10 Jun 2002 17:53:32 -0000 1.1
+++ AddressBean.java 19 Nov 2002 20:13:18 -0000 1.2
@@ -66,6 +66,7 @@
/** <p><code>CustomerBean</code> is a sample bean for use by the test cases.</p>
*
* @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
+ * @author <a href="mailto:michael.davey@coderage.org">Michael Davey</a>
* @version $Revision$
*/
public class AddressBean implements Serializable {
@@ -111,6 +112,16 @@
}
public String toString() {
- return super.toString() + "[street=" + street + ", city=" + city+ ",country=" + country + "]";
+ return "[" + this.getClass().getName() + ": street=" + street + ", city="
+ + city+ ", country=" + country + "]";
+ }
+
+ public boolean equals( Object obj ) {
+ if ( obj == null ) return false;
+ return this.hashCode() == obj.hashCode();
+ }
+
+ public int hashCode() {
+ return toString().hashCode();
}
}
1.6 +12 -1 jakarta-commons/betwixt/src/test/org/apache/commons/betwixt/CustomerBean.java
Index: CustomerBean.java
===================================================================
RCS file: /home/cvs/jakarta-commons/betwixt/src/test/org/apache/commons/betwixt/CustomerBean.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- CustomerBean.java 7 Nov 2002 16:15:08 -0000 1.5
+++ CustomerBean.java 19 Nov 2002 20:13:18 -0000 1.6
@@ -82,6 +82,7 @@
/** <p><code>CustomerBean</code> is a sample bean for use by the test cases.</p>
*
* @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
+ * @author <a href="mailto:michael.davey@coderage.org">Michael Davey</a>
* @version $Revision$
*/
public class CustomerBean implements Serializable {
@@ -227,7 +228,17 @@
}
public String toString() {
- return super.toString() + "[ID=" + id + ", name=" + name + ",address=" + address + "]";
+ return "[" + this.getClass().getName() + ": ID=" + id + ", name=" + name
+ + ", address=" + address + "]";
+ }
+
+ public boolean equals( Object obj ) {
+ if ( obj == null ) return false;
+ return this.hashCode() == obj.hashCode();
+ }
+
+ public int hashCode() {
+ return toString().hashCode();
}
/**
* Returns the date.
1.2 +11 -1 jakarta-commons/betwixt/src/test/org/apache/commons/betwixt/PersonBean.java
Index: PersonBean.java
===================================================================
RCS file: /home/cvs/jakarta-commons/betwixt/src/test/org/apache/commons/betwixt/PersonBean.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- PersonBean.java 10 Jun 2002 17:53:32 -0000 1.1
+++ PersonBean.java 19 Nov 2002 20:13:18 -0000 1.2
@@ -64,6 +64,7 @@
/** <p><code>PersonBean</code> is a sample bean for use with the test cases.</p>
*
* @author <a href="mailto:rdonkin@apache.org">Robert Burrell Donkin</a>
+ * @author <a href="mailto:Michael.Davey@coderage.org">Michael Davey</a>
* @version $Revision$
*/
public class PersonBean {
@@ -97,6 +98,15 @@
}
public String toString() {
- return "[PersonBean] age=" + age + " name=" + name;
+ return "[" + this.getClass().getName() + ": age=" + age + " name=" + name + "]";
+ }
+
+ public boolean equals( Object obj ) {
+ if ( obj == null ) return false;
+ return this.hashCode() == obj.hashCode();
+ }
+
+ public int hashCode() {
+ return toString().hashCode();
}
}
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>