db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kahat...@apache.org
Subject svn commit: r946079 - /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/TimestampArithTest.java
Date Wed, 19 May 2010 07:56:53 GMT
Author: kahatlen
Date: Wed May 19 07:56:53 2010
New Revision: 946079

URL: http://svn.apache.org/viewvc?rev=946079&view=rev
Log:
DERBY-4624: Broken logic for avoiding testing across midnight in TimestampArithTest

Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/TimestampArithTest.java

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/TimestampArithTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/TimestampArithTest.java?rev=946079&r1=946078&r2=946079&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/TimestampArithTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/TimestampArithTest.java
Wed May 19 07:56:53 2010
@@ -26,8 +26,6 @@ import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.sql.Statement;
 import java.sql.Types;
-import java.util.Calendar;
-import java.util.GregorianCalendar;
 
 import junit.framework.Test;
 import junit.framework.TestSuite;
@@ -375,15 +373,6 @@ public class TimestampArithTest extends 
 	private static final int QUARTER_INTERVAL = 7;
 	private static final int YEAR_INTERVAL = 8;
 	
-	private static final int ONE_BILLION = 1000000000;
-	 
-	private static String TODAY;
-	private static String TOMORROW;
-	private static String YEAR_FROM_TOMORROW;
-	private static String YEAR_FROM_TODAY;
-	private static String YESTERDAY;
-	private static String WEEK_FROM_TODAY;
-		
 	/**
 	 * Basic constructor.
 	 */
@@ -400,36 +389,8 @@ public class TimestampArithTest extends 
 				"TimestampArithTest")) {
 
 			protected void setUp() throws Exception {
-				Calendar calendar = Calendar.getInstance();
-
 				super.setUp();
 
-				/*
-				 * Make sure that we are not so close to midnight that TODAY
-				 * might be yesterday before we are finished using it.
-				 */
-				while (calendar.get(Calendar.HOUR) == 23
-						&& calendar.get(Calendar.MINUTE) >= 58) {
-					try {
-						Thread.sleep((60 - calendar.get(Calendar.SECOND)) * 1000);
-					} catch (InterruptedException ie) {
-						// ignore it
-					}
-				}
-
-				TODAY = isoFormatDate(calendar);
-				calendar.add(Calendar.DATE, -1);
-				YESTERDAY = isoFormatDate(calendar);
-				calendar.add(Calendar.DATE, 2);
-				TOMORROW = isoFormatDate(calendar);
-				calendar.add(Calendar.YEAR, 1);
-				YEAR_FROM_TOMORROW = isoFormatDate(calendar);
-				calendar.add(Calendar.DATE, -1);
-				YEAR_FROM_TODAY = isoFormatDate(calendar);
-				calendar.add(Calendar.YEAR, -1); // today
-				calendar.add(Calendar.DATE, 7);
-				WEEK_FROM_TODAY = isoFormatDate(calendar);
-
 				for (int i = 0; i < intervalJdbcNames.length; i++) {
 					tsAddPS[i] = getConnection().prepareStatement(
 							composeSqlStr("ADD", i, "?", "?"));
@@ -576,28 +537,6 @@ public class TimestampArithTest extends 
 		}
 	}
 
-	private static String isoFormatDate(Calendar cal) {
-		StringBuffer sb = new StringBuffer();
-		String s = String.valueOf(cal.get(Calendar.YEAR));
-		for (int i = s.length(); i < 4; i++)
-			sb.append('0');
-		sb.append(s);
-		sb.append('-');
-
-		s = String.valueOf(cal.get(Calendar.MONTH) + 1);
-		for (int i = s.length(); i < 2; i++)
-			sb.append('0');
-		sb.append(s);
-		sb.append('-');
-
-		s = String.valueOf(cal.get(Calendar.DAY_OF_MONTH));
-		for (int i = s.length(); i < 2; i++)
-			sb.append('0');
-		sb.append(s);
-
-		return sb.toString();
-	}
-	
 	private static String dateTimeToLiteral(Object ts) {
 		if (ts instanceof java.sql.Timestamp)
 			return "{ts '" + ((java.sql.Timestamp) ts).toString() + "'}";



Mime
View raw message