chukwa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ey...@apache.org
Subject svn commit: r766745 - in /hadoop/chukwa: branches/chukwa-0.1/src/test/org/apache/hadoop/chukwa/database/TestMacro.java trunk/src/test/org/apache/hadoop/chukwa/database/TestMacro.java
Date Mon, 20 Apr 2009 16:39:11 GMT
Author: eyang
Date: Mon Apr 20 16:39:11 2009
New Revision: 766745

URL: http://svn.apache.org/viewvc?rev=766745&view=rev
Log:
CHUKWA-156. Test Macro testcase changed to use timestamp check for the generated macros. (Eric
Yang)

Modified:
    hadoop/chukwa/branches/chukwa-0.1/src/test/org/apache/hadoop/chukwa/database/TestMacro.java
    hadoop/chukwa/trunk/src/test/org/apache/hadoop/chukwa/database/TestMacro.java

Modified: hadoop/chukwa/branches/chukwa-0.1/src/test/org/apache/hadoop/chukwa/database/TestMacro.java
URL: http://svn.apache.org/viewvc/hadoop/chukwa/branches/chukwa-0.1/src/test/org/apache/hadoop/chukwa/database/TestMacro.java?rev=766745&r1=766744&r2=766745&view=diff
==============================================================================
--- hadoop/chukwa/branches/chukwa-0.1/src/test/org/apache/hadoop/chukwa/database/TestMacro.java
(original)
+++ hadoop/chukwa/branches/chukwa-0.1/src/test/org/apache/hadoop/chukwa/database/TestMacro.java
Mon Apr 20 16:39:11 2009
@@ -20,19 +20,29 @@
 import junit.framework.TestCase;
 import java.util.TreeMap;
 import java.util.ArrayList;
+import java.util.Date;
+import java.text.ParseException;
+import java.text.ParsePosition;
+import java.text.SimpleDateFormat;
 
 public class TestMacro extends TestCase {
 
   public void testPastXIntervals() {
     Macro m = new Macro(1234567890000L, "select '[past_5_minutes]';");
-    System.out.println(m.toString());
-    assertTrue(m.toString().intern()=="select '2009-02-13 15:25:00';".intern());
+    SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+    long time = 0;
+    Date result = null;
+    result = format.parse(m.toString(), new ParsePosition(8));
+    time = result.getTime()+300000L;
+    assertTrue(time<=1234567890000L);
     m = new Macro(1234567890000L, "select '[past_hour]';");
-    System.out.println(m.toString());
-    assertTrue(m.toString().intern()=="select '2009-02-13 14:31:30';".intern());
+    result = format.parse(m.toString(), new ParsePosition(8));
+    time = result.getTime()+3600000L;
+    assertTrue(time<=1234567890000L);
     m = new Macro(1234567890000L, "select '[start]';");
-    System.out.println(m.toString());
-    assertTrue(m.toString().intern()=="select '2009-02-13 15:31:30';".intern());
+    result = format.parse(m.toString(), new ParsePosition(8));
+    time = result.getTime();
+    assertTrue(time==1234567890000L);
   }
 
   public void testPartitions() {

Modified: hadoop/chukwa/trunk/src/test/org/apache/hadoop/chukwa/database/TestMacro.java
URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/test/org/apache/hadoop/chukwa/database/TestMacro.java?rev=766745&r1=766744&r2=766745&view=diff
==============================================================================
--- hadoop/chukwa/trunk/src/test/org/apache/hadoop/chukwa/database/TestMacro.java (original)
+++ hadoop/chukwa/trunk/src/test/org/apache/hadoop/chukwa/database/TestMacro.java Mon Apr
20 16:39:11 2009
@@ -20,19 +20,29 @@
 import junit.framework.TestCase;
 import java.util.TreeMap;
 import java.util.ArrayList;
+import java.util.Date;
+import java.text.ParseException;
+import java.text.ParsePosition;
+import java.text.SimpleDateFormat;
 
 public class TestMacro extends TestCase {
 
   public void testPastXIntervals() {
     Macro m = new Macro(1234567890000L, "select '[past_5_minutes]';");
-    System.out.println(m.toString());
-    assertTrue(m.toString().intern()=="select '2009-02-13 15:25:00';".intern());
+    SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+    long time = 0;
+    Date result = null;
+    result = format.parse(m.toString(), new ParsePosition(8));
+    time = result.getTime()+300000L;
+    assertTrue(time<=1234567890000L);
     m = new Macro(1234567890000L, "select '[past_hour]';");
-    System.out.println(m.toString());
-    assertTrue(m.toString().intern()=="select '2009-02-13 14:31:30';".intern());
+    result = format.parse(m.toString(), new ParsePosition(8));
+    time = result.getTime()+3600000L;
+    assertTrue(time<=1234567890000L);
     m = new Macro(1234567890000L, "select '[start]';");
-    System.out.println(m.toString());
-    assertTrue(m.toString().intern()=="select '2009-02-13 15:31:30';".intern());
+    result = format.parse(m.toString(), new ParsePosition(8));
+    time = result.getTime();
+    assertTrue(time==1234567890000L);
   }
 
   public void testPartitions() {



Mime
View raw message