PageRenderTime 29ms CodeModel.GetById 17ms app.highlight 8ms RepoModel.GetById 1ms app.codeStats 0ms

/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
23package org.mobicents.protocols.smpp.util;
24
25import static org.testng.Assert.assertEquals;
26import static org.testng.Assert.assertFalse;
27import static org.testng.Assert.assertNull;
28import static org.testng.Assert.assertTrue;
29
30import org.mobicents.protocols.smpp.util.SMPPDate;
31import org.testng.annotations.Test;
32
33@Test
34public class RelativeSMPPDateTest {
35
36    public void testRelativeDate() {
37        SMPPDate d = SMPPDate.getRelativeInstance(2, 5, 12, 9, 55, 3);
38        assertTrue(d.isRelative());
39        assertFalse(d.isAbsolute());
40        assertEquals(d.getSign(), 'R');
41        assertEquals(d.getYear(), 2);
42        assertEquals(d.getMonth(), 5);
43        assertEquals(d.getDay(), 12);
44        assertEquals(d.getHour(), 9);
45        assertEquals(d.getMinute(), 55);
46        assertEquals(d.getSecond(), 3);
47        assertEquals(d.getTenth(), 0);
48        assertEquals(d.getUtcOffset(), 0);
49        assertNull(d.getTimeZone());
50    }
51
52    public void testEqualsAndHashCode() {
53        SMPPDate date1 = SMPPDate.getRelativeInstance(2, 2, 2, 2, 2, 2);
54        SMPPDate date2 = SMPPDate.getRelativeInstance(2, 2, 2, 2, 2, 2);
55        SMPPDate date3 = SMPPDate.getRelativeInstance(3, 3, 3, 3, 3, 3);
56
57        assertEquals(date1, date1);
58        assertEquals(date2, date2);
59        assertEquals(date3, date3);
60        assertEquals(date2, date1);
61        assertEquals(date1, date2);
62        assertFalse(date1.equals(date3));
63        assertFalse(date3.equals(date1));
64        
65        assertEquals(date2.hashCode(), date1.hashCode());
66        assertFalse(date1.hashCode() == date3.hashCode());
67    }
68}