/protocols/smpp/src/test/java/org/mobicents/protocols/smpp/util/RelativeSMPPDateTest.java

http://mobicents.googlecode.com/ · Java · 68 lines · 39 code · 8 blank · 21 comment · 1 complexity · f86c5f230fdbffa4ab88940d3df44760 MD5 · raw file

  1. /*
  2. * JBoss, Home of Professional Open Source
  3. * Copyright 2011, Red Hat, Inc. and individual contributors
  4. * by the @authors tag. See the copyright.txt in the distribution for a
  5. * full listing of individual contributors.
  6. *
  7. * This is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU Lesser General Public License as
  9. * published by the Free Software Foundation; either version 2.1 of
  10. * the License, or (at your option) any later version.
  11. *
  12. * This software is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with this software; if not, write to the Free
  19. * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  20. * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  21. */
  22. package org.mobicents.protocols.smpp.util;
  23. import static org.testng.Assert.assertEquals;
  24. import static org.testng.Assert.assertFalse;
  25. import static org.testng.Assert.assertNull;
  26. import static org.testng.Assert.assertTrue;
  27. import org.mobicents.protocols.smpp.util.SMPPDate;
  28. import org.testng.annotations.Test;
  29. @Test
  30. public class RelativeSMPPDateTest {
  31. public void testRelativeDate() {
  32. SMPPDate d = SMPPDate.getRelativeInstance(2, 5, 12, 9, 55, 3);
  33. assertTrue(d.isRelative());
  34. assertFalse(d.isAbsolute());
  35. assertEquals(d.getSign(), 'R');
  36. assertEquals(d.getYear(), 2);
  37. assertEquals(d.getMonth(), 5);
  38. assertEquals(d.getDay(), 12);
  39. assertEquals(d.getHour(), 9);
  40. assertEquals(d.getMinute(), 55);
  41. assertEquals(d.getSecond(), 3);
  42. assertEquals(d.getTenth(), 0);
  43. assertEquals(d.getUtcOffset(), 0);
  44. assertNull(d.getTimeZone());
  45. }
  46. public void testEqualsAndHashCode() {
  47. SMPPDate date1 = SMPPDate.getRelativeInstance(2, 2, 2, 2, 2, 2);
  48. SMPPDate date2 = SMPPDate.getRelativeInstance(2, 2, 2, 2, 2, 2);
  49. SMPPDate date3 = SMPPDate.getRelativeInstance(3, 3, 3, 3, 3, 3);
  50. assertEquals(date1, date1);
  51. assertEquals(date2, date2);
  52. assertEquals(date3, date3);
  53. assertEquals(date2, date1);
  54. assertEquals(date1, date2);
  55. assertFalse(date1.equals(date3));
  56. assertFalse(date3.equals(date1));
  57. assertEquals(date2.hashCode(), date1.hashCode());
  58. assertFalse(date1.hashCode() == date3.hashCode());
  59. }
  60. }