You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by bh...@apache.org on 2017/07/22 09:36:26 UTC

[cloudstack] branch 4.9 updated: CLOUDSTACK-9830 Fix DST bug in QuotaAlertManagerTest

This is an automated email from the ASF dual-hosted git repository.

bhaisaab pushed a commit to branch 4.9
in repository https://gitbox.apache.org/repos/asf/cloudstack.git


The following commit(s) were added to refs/heads/4.9 by this push:
     new 047bb1c  CLOUDSTACK-9830 Fix DST bug in QuotaAlertManagerTest
047bb1c is described below

commit 047bb1c74a5c77a45bf9c5a918ce8a8cfbe558fb
Author: Nathan Johnson <nj...@ena.com>
AuthorDate: Sat Mar 11 19:17:22 2017 -0600

    CLOUDSTACK-9830 Fix DST bug in QuotaAlertManagerTest
    
    Replace the use of joda with Calendar, set explicitly to UTC when
    doing date manipulation.
---
 .../org/apache/cloudstack/quota/QuotaAlertManagerImplTest.java   | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/framework/quota/test/org/apache/cloudstack/quota/QuotaAlertManagerImplTest.java b/framework/quota/test/org/apache/cloudstack/quota/QuotaAlertManagerImplTest.java
index 14244fc..d898ef2 100644
--- a/framework/quota/test/org/apache/cloudstack/quota/QuotaAlertManagerImplTest.java
+++ b/framework/quota/test/org/apache/cloudstack/quota/QuotaAlertManagerImplTest.java
@@ -32,7 +32,6 @@ import org.apache.cloudstack.quota.dao.QuotaEmailTemplatesDao;
 import org.apache.cloudstack.quota.dao.QuotaUsageDao;
 import org.apache.cloudstack.quota.vo.QuotaAccountVO;
 import org.apache.cloudstack.quota.vo.QuotaEmailTemplatesVO;
-import org.joda.time.DateTime;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -47,8 +46,10 @@ import java.io.UnsupportedEncodingException;
 import java.lang.reflect.Field;
 import java.math.BigDecimal;
 import java.util.ArrayList;
+import java.util.Calendar;
 import java.util.Date;
 import java.util.List;
+import java.util.TimeZone;
 
 @RunWith(MockitoJUnitRunner.class)
 public class QuotaAlertManagerImplTest extends TestCase {
@@ -179,7 +180,11 @@ public class QuotaAlertManagerImplTest extends TestCase {
     public void testGetDifferenceDays() {
         Date now = new Date();
         assertTrue(QuotaAlertManagerImpl.getDifferenceDays(now, now) == 0L);
-        assertTrue(QuotaAlertManagerImpl.getDifferenceDays(now, new DateTime(now).plusDays(1).toDate()) == 1L);
+        Calendar c = Calendar.getInstance();
+        c.setTimeZone(TimeZone.getTimeZone("UTC"));
+        Calendar c2 = (Calendar) c.clone();
+        c2.add(Calendar.DATE, 1);
+        assertEquals(1L, QuotaAlertManagerImpl.getDifferenceDays(c.getTime(), c2.getTime()));
     }
 
     @Test

-- 
To stop receiving notification emails like this one, please contact
['"commits@cloudstack.apache.org" <co...@cloudstack.apache.org>'].