This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Re: [patch] mauve testsuite sql Timestamp
Andreas Tobler wrote:
Ok, as found last night, this only works for people like Michael and me
who sit in the same timezone.
To make it work for everyone I tried to set a default timezone in the
test, but I fail. I get it to work in a standalone test without mauve.
But not in this one.
What do I miss/what do I do wrong?
I do this just before I create a new timestamp:
// Set a common timezone to get the same result everywhere.
SimpleTimeZone stz = new SimpleTimeZone(0 * 3600, "GMT");
TimeZone.setDefault(stz);
I think I found it.
with the attached patch it seems to werk and hopefully also for all
people not sitting in my timezone :)
ANdreas
Index: gnu/testlet/java/sql/Timestamp/TimestampTest.java
===================================================================
RCS file: /cvs/mauve/mauve/gnu/testlet/java/sql/Timestamp/TimestampTest.java,v
retrieving revision 1.2
diff -u -r1.2 TimestampTest.java
--- gnu/testlet/java/sql/Timestamp/TimestampTest.java 15 Jul 2004 20:58:41 -0000 1.2
+++ gnu/testlet/java/sql/Timestamp/TimestampTest.java 10 Oct 2004 16:20:00 -0000
@@ -27,11 +27,18 @@
import java.sql.*;
+import java.util.SimpleTimeZone;
+import java.util.TimeZone;
+
public class TimestampTest implements Testlet
{
public void
test(TestHarness harness)
{
+ // Set a common timezone to get the same result everywhere.
+ SimpleTimeZone stz = new SimpleTimeZone(-5 * 1000 * 3600, "GMT");
+ TimeZone.setDefault(stz);
+
try {
Timestamp.valueOf("NoSuchTime");
harness.check(false, "valueOf");
@@ -40,24 +47,35 @@
harness.check(true, "valueOf");
}
+
Timestamp ts = new Timestamp(1099999999333L);
harness.check(ts.getNanos() == 333000000, "getNanos");
harness.check(ts.toString().equals("2004-11-09 06:33:19.333"),
"toString");
+ harness.debug(ts.toString());
ts.setNanos(42);
harness.check(ts.getNanos() == 42, "getNanos");
harness.check(ts.toString().equals("2004-11-09 06:33:19.000000042"),
"toString");
+ harness.debug(ts.toString());
+
ts.setNanos(0);
harness.check(ts.getNanos() == 0, "getNanos");
harness.check(ts.toString().equals("2004-11-09 06:33:19.0"),
"toString");
-
+
+ harness.debug(ts.toString());
+
Timestamp ts2 = new Timestamp(1099999999999L);
harness.check(ts.equals(ts2) == false, "equals");
ts.setNanos(999000000);
harness.check(ts.equals(ts2), "equals");
+
+ harness.debug(ts.toString());
+
+ // Restore Timezone
+ TimeZone.setDefault(null);
}
}