camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cmuel...@apache.org
Subject svn commit: r1184884 - in /camel/trunk/components/camel-smpp/src/test/java/org/apache/camel/component/smpp: SmppReplaceSmCommandTest.java SmppSubmitMultiCommandTest.java SmppSubmitSmCommandTest.java SmppUtilsTest.java
Date Sun, 16 Oct 2011 17:46:36 GMT
Author: cmueller
Date: Sun Oct 16 17:46:35 2011
New Revision: 1184884

URL: http://svn.apache.org/viewvc?rev=1184884&view=rev
Log:
fixed the TimeZone dependend test failure from CAMEL-4086

Modified:
    camel/trunk/components/camel-smpp/src/test/java/org/apache/camel/component/smpp/SmppReplaceSmCommandTest.java
    camel/trunk/components/camel-smpp/src/test/java/org/apache/camel/component/smpp/SmppSubmitMultiCommandTest.java
    camel/trunk/components/camel-smpp/src/test/java/org/apache/camel/component/smpp/SmppSubmitSmCommandTest.java
    camel/trunk/components/camel-smpp/src/test/java/org/apache/camel/component/smpp/SmppUtilsTest.java

Modified: camel/trunk/components/camel-smpp/src/test/java/org/apache/camel/component/smpp/SmppReplaceSmCommandTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-smpp/src/test/java/org/apache/camel/component/smpp/SmppReplaceSmCommandTest.java?rev=1184884&r1=1184883&r2=1184884&view=diff
==============================================================================
--- camel/trunk/components/camel-smpp/src/test/java/org/apache/camel/component/smpp/SmppReplaceSmCommandTest.java
(original)
+++ camel/trunk/components/camel-smpp/src/test/java/org/apache/camel/component/smpp/SmppReplaceSmCommandTest.java
Sun Oct 16 17:46:35 2011
@@ -17,6 +17,7 @@
 package org.apache.camel.component.smpp;
 
 import java.util.Date;
+import java.util.TimeZone;
 
 import org.apache.camel.Exchange;
 import org.apache.camel.ExchangePattern;
@@ -27,7 +28,9 @@ import org.jsmpp.bean.RegisteredDelivery
 import org.jsmpp.bean.SMSCDeliveryReceipt;
 import org.jsmpp.bean.TypeOfNumber;
 import org.jsmpp.session.SMPPSession;
+import org.junit.AfterClass;
 import org.junit.Before;
+import org.junit.BeforeClass;
 import org.junit.Test;
 
 import static org.easymock.EasyMock.aryEq;
@@ -39,11 +42,27 @@ import static org.easymock.classextensio
 import static org.junit.Assert.assertEquals;
 
 public class SmppReplaceSmCommandTest {
+    
+    private static TimeZone defaultTimeZone;
 
     private SMPPSession session;
     private SmppConfiguration config;
     private SmppReplaceSmCommand command;
     
+    @BeforeClass
+    public static void setUpBeforeClass() {
+        defaultTimeZone = TimeZone.getDefault();
+        
+        TimeZone.setDefault(TimeZone.getTimeZone("GMT"));
+    }
+    
+    @AfterClass
+    public static void tearDownAfterClass() {
+        if (defaultTimeZone != null) {
+            TimeZone.setDefault(defaultTimeZone);            
+        }
+    }
+    
     @Before
     public void setUp() {
         session = createMock(SMPPSession.class);
@@ -82,7 +101,7 @@ public class SmppReplaceSmCommandTest {
         exchange.getIn().setHeader(SmppConstants.VALIDITY_PERIOD, new Date(2222222));
         exchange.getIn().setHeader(SmppConstants.REGISTERED_DELIVERY, new RegisteredDelivery(SMSCDeliveryReceipt.SUCCESS).value());
         exchange.getIn().setBody("new short message body");
-        session.replaceShortMessage(eq("1"), eq(TypeOfNumber.NATIONAL), eq(NumberingPlanIndicator.NATIONAL),
eq("1818"), eq("-300101011831104+"), eq("-300101013702204+"),
+        session.replaceShortMessage(eq("1"), eq(TypeOfNumber.NATIONAL), eq(NumberingPlanIndicator.NATIONAL),
eq("1818"), eq("-300101001831100-"), eq("-300101003702200-"),
                 eq(new RegisteredDelivery(SMSCDeliveryReceipt.SUCCESS)), eq((byte) 0), aryEq("new
short message body".getBytes()));
         
         replay(session);

Modified: camel/trunk/components/camel-smpp/src/test/java/org/apache/camel/component/smpp/SmppSubmitMultiCommandTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-smpp/src/test/java/org/apache/camel/component/smpp/SmppSubmitMultiCommandTest.java?rev=1184884&r1=1184883&r2=1184884&view=diff
==============================================================================
--- camel/trunk/components/camel-smpp/src/test/java/org/apache/camel/component/smpp/SmppSubmitMultiCommandTest.java
(original)
+++ camel/trunk/components/camel-smpp/src/test/java/org/apache/camel/component/smpp/SmppSubmitMultiCommandTest.java
Sun Oct 16 17:46:35 2011
@@ -18,6 +18,7 @@ package org.apache.camel.component.smpp;
 
 import java.util.Arrays;
 import java.util.Date;
+import java.util.TimeZone;
 
 import org.apache.camel.Exchange;
 import org.apache.camel.ExchangePattern;
@@ -37,7 +38,9 @@ import org.jsmpp.bean.SubmitMultiResult;
 import org.jsmpp.bean.TypeOfNumber;
 import org.jsmpp.bean.UnsuccessDelivery;
 import org.jsmpp.session.SMPPSession;
+import org.junit.AfterClass;
 import org.junit.Before;
+import org.junit.BeforeClass;
 import org.junit.Test;
 
 import static org.easymock.EasyMock.aryEq;
@@ -52,11 +55,27 @@ import static org.junit.Assert.assertNot
 import static org.junit.Assert.assertNull;
 
 public class SmppSubmitMultiCommandTest {
+    
+    private static TimeZone defaultTimeZone;
 
     private SMPPSession session;
     private SmppConfiguration config;
     private SmppSubmitMultiCommand command;
     
+    @BeforeClass
+    public static void setUpBeforeClass() {
+        defaultTimeZone = TimeZone.getDefault();
+        
+        TimeZone.setDefault(TimeZone.getTimeZone("GMT"));
+    }
+    
+    @AfterClass
+    public static void tearDownAfterClass() {
+        if (defaultTimeZone != null) {
+            TimeZone.setDefault(defaultTimeZone);            
+        }
+    }
+    
     @Before
     public void setUp() {
         session = createMock(SMPPSession.class);
@@ -109,7 +128,7 @@ public class SmppSubmitMultiCommandTest 
         exchange.getIn().setBody("short message body");
         expect(session.submitMultiple(eq("CMT"), eq(TypeOfNumber.NATIONAL), eq(NumberingPlanIndicator.NATIONAL),
eq("1818"),
                 aryEq(new Address[]{new Address(TypeOfNumber.INTERNATIONAL, NumberingPlanIndicator.INTERNET,
"1919")}),
-                eq(new ESMClass()), eq((byte) 1), eq((byte) 2), eq("-300101011831104+"),
eq("-300101013702204+"), eq(new RegisteredDelivery(SMSCDeliveryReceipt.SUCCESS)),
+                eq(new ESMClass()), eq((byte) 1), eq((byte) 2), eq("-300101001831100-"),
eq("-300101003702200-"), eq(new RegisteredDelivery(SMSCDeliveryReceipt.SUCCESS)),
                 eq(ReplaceIfPresentFlag.REPLACE), eq(new GeneralDataCoding(false, true, MessageClass.CLASS1,
Alphabet.ALPHA_DEFAULT)), eq((byte) 0), aryEq("short message body".getBytes()),
                 aryEq(new OptionalParameter[0])))
                 .andReturn(new SubmitMultiResult("1"));

Modified: camel/trunk/components/camel-smpp/src/test/java/org/apache/camel/component/smpp/SmppSubmitSmCommandTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-smpp/src/test/java/org/apache/camel/component/smpp/SmppSubmitSmCommandTest.java?rev=1184884&r1=1184883&r2=1184884&view=diff
==============================================================================
--- camel/trunk/components/camel-smpp/src/test/java/org/apache/camel/component/smpp/SmppSubmitSmCommandTest.java
(original)
+++ camel/trunk/components/camel-smpp/src/test/java/org/apache/camel/component/smpp/SmppSubmitSmCommandTest.java
Sun Oct 16 17:46:35 2011
@@ -18,6 +18,7 @@ package org.apache.camel.component.smpp;
 
 import java.util.Arrays;
 import java.util.Date;
+import java.util.TimeZone;
 
 import org.apache.camel.Exchange;
 import org.apache.camel.ExchangePattern;
@@ -34,7 +35,9 @@ import org.jsmpp.bean.ReplaceIfPresentFl
 import org.jsmpp.bean.SMSCDeliveryReceipt;
 import org.jsmpp.bean.TypeOfNumber;
 import org.jsmpp.session.SMPPSession;
+import org.junit.AfterClass;
 import org.junit.Before;
+import org.junit.BeforeClass;
 import org.junit.Ignore;
 import org.junit.Test;
 
@@ -48,11 +51,27 @@ import static org.easymock.classextensio
 import static org.junit.Assert.assertEquals;
 
 public class SmppSubmitSmCommandTest {
+    
+    private static TimeZone defaultTimeZone;
 
     private SMPPSession session;
     private SmppConfiguration config;
     private SmppSubmitSmCommand command;
     
+    @BeforeClass
+    public static void setUpBeforeClass() {
+        defaultTimeZone = TimeZone.getDefault();
+        
+        TimeZone.setDefault(TimeZone.getTimeZone("GMT"));
+    }
+    
+    @AfterClass
+    public static void tearDownAfterClass() {
+        if (defaultTimeZone != null) {
+            TimeZone.setDefault(defaultTimeZone);            
+        }
+    }
+    
     @Before
     public void setUp() {
         session = createMock(SMPPSession.class);
@@ -139,7 +158,7 @@ public class SmppSubmitSmCommandTest {
         exchange.getIn().setBody("short message body");
         expect(session.submitShortMessage(eq("CMT"), eq(TypeOfNumber.NATIONAL), eq(NumberingPlanIndicator.NATIONAL),
eq("1818"),
                 eq(TypeOfNumber.INTERNATIONAL), eq(NumberingPlanIndicator.INTERNET), eq("1919"),
-                eq(new ESMClass()), eq((byte) 1), eq((byte) 2), eq("-300101011831104+"),
eq("-300101013702204+"), eq(new RegisteredDelivery(SMSCDeliveryReceipt.SUCCESS)),
+                eq(new ESMClass()), eq((byte) 1), eq((byte) 2), eq("-300101001831100-"),
eq("-300101003702200-"), eq(new RegisteredDelivery(SMSCDeliveryReceipt.SUCCESS)),
                 eq(ReplaceIfPresentFlag.REPLACE.value()), eq(new GeneralDataCoding(false,
true, MessageClass.CLASS1, Alphabet.ALPHA_DEFAULT)), eq((byte) 0), aryEq("short message body".getBytes()),
                 (OptionalParameter[]) isNull()))
                 .andReturn("1");

Modified: camel/trunk/components/camel-smpp/src/test/java/org/apache/camel/component/smpp/SmppUtilsTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-smpp/src/test/java/org/apache/camel/component/smpp/SmppUtilsTest.java?rev=1184884&r1=1184883&r2=1184884&view=diff
==============================================================================
--- camel/trunk/components/camel-smpp/src/test/java/org/apache/camel/component/smpp/SmppUtilsTest.java
(original)
+++ camel/trunk/components/camel-smpp/src/test/java/org/apache/camel/component/smpp/SmppUtilsTest.java
Sun Oct 16 17:46:35 2011
@@ -18,18 +18,37 @@ package org.apache.camel.component.smpp;
 
 import java.util.Calendar;
 import java.util.Date;
+import java.util.TimeZone;
 
 import org.jsmpp.bean.Alphabet;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
 import org.junit.Test;
 
 import static org.junit.Assert.assertEquals;
 
 public class SmppUtilsTest {
+    
+    private static TimeZone defaultTimeZone;
+    
+    @BeforeClass
+    public static void setUpBeforeClass() {
+        defaultTimeZone = TimeZone.getDefault();
+        
+        TimeZone.setDefault(TimeZone.getTimeZone("GMT"));
+    }
+    
+    @AfterClass
+    public static void tearDownAfterClass() {
+        if (defaultTimeZone != null) {
+            TimeZone.setDefault(defaultTimeZone);            
+        }
+    }
 
     @Test
     public void formatTime() {
-        assertEquals("-300101010000004+", SmppUtils.formatTime(new Date(0L)));
-        assertEquals("-300101034640004+", SmppUtils.formatTime(new Date(10000000L)));
+        assertEquals("-300101000000000-", SmppUtils.formatTime(new Date(0L)));
+        assertEquals("-300101024640000-", SmppUtils.formatTime(new Date(10000000L)));
     }
     
     @Test



Mime
View raw message