You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by gg...@apache.org on 2004/02/17 00:39:03 UTC
cvs commit: jakarta-commons/lang/src/test/org/apache/commons/lang ObjectUtilsTest.java
ggregory 2004/02/16 15:39:03
Modified: lang/src/test/org/apache/commons/lang ObjectUtilsTest.java
Log:
PR: http://nagoya.apache.org/bugzilla/show_bug.cgi?id=26922
[lang] public static boolean DateUtils.equals(Date dt1, Date dt2) ?
Record a test for future reference when having this chat.
Revision Changes Path
1.10 +18 -2 jakarta-commons/lang/src/test/org/apache/commons/lang/ObjectUtilsTest.java
Index: ObjectUtilsTest.java
===================================================================
RCS file: /home/cvs/jakarta-commons/lang/src/test/org/apache/commons/lang/ObjectUtilsTest.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- ObjectUtilsTest.java 18 Aug 2003 02:22:25 -0000 1.9
+++ ObjectUtilsTest.java 16 Feb 2004 23:39:03 -0000 1.10
@@ -1,7 +1,7 @@
/* ====================================================================
* The Apache Software License, Version 1.1
*
- * Copyright (c) 2002-2003 The Apache Software Foundation. All rights
+ * Copyright (c) 2002-2004 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -60,6 +60,7 @@
import junit.framework.TestCase;
import junit.framework.TestSuite;
import junit.textui.TestRunner;
+import org.apache.commons.lang.time.DateUtils;
/**
* Unit tests {@link org.apache.commons.lang.ObjectUtils}.
@@ -122,6 +123,21 @@
assertTrue("ObjectUtils.equals(\"foo\", \"foo\") returned false", ObjectUtils.equals(FOO, FOO));
}
+ /**
+ * Show that java.util.Date and java.sql.Timestamp are apples and oranges.
+ * Prompted by an email discussion.
+ */
+ public void testDateEquals() {
+ long now = 1076957313284L; // Feb 16, 2004 10:49... PST
+ java.util.Date date = new java.util.Date(now);
+ java.util.Date timestamp = new java.sql.Timestamp(now);
+ // sanity check:
+ assertFalse(date.getTime() == timestamp.getTime());
+ assertFalse(timestamp.equals(date));
+ // real test:
+ assertFalse(ObjectUtils.equals(date, timestamp));
+ }
+
public void testIdentityToString() {
assertEquals(null, ObjectUtils.identityToString(null));
assertEquals(
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org