View Javadoc
1   /*
2    * To change this template, choose Tools | Templates
3    * and open the template in the editor.
4    */
5   package net.sf.atmodem4j.core.gsm;
6   
7   /*
8    * #%L
9    * ATModem4J Core
10   * %%
11   * Copyright (C) 2009 - 2014 atmodem4j
12   * %%
13   * atmodem4j - Drivers for the AT modem - http://atmodem4j.sourceforge.net/
14   * Copyright (C) 2009-2014, atmodem4j.sf.net, and individual contributors as indicated
15   * by the @authors tag. See the copyright.txt in the distribution for a
16   * full listing of individual contributors.
17   * 
18   * This is free software; you can redistribute it and/or modify it
19   * under the terms of the GNU General Public License as
20   * published by the Free Software Foundation; either version 3 of
21   * the License, or (at your option) any later version.
22   * 
23   * This software is distributed in the hope that it will be useful,
24   * but WITHOUT ANY WARRANTY; without even the implied warranty of
25   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
26   * Lesser General Public License for more details.
27   * 
28   * You should have received a copy of the GNU Lesser General Public
29   * License along with this software; if not, write to the Free
30   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
31   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
32   * #L%
33   */
34  
35  import org.junit.After;
36  import org.junit.AfterClass;
37  import org.junit.Before;
38  import org.junit.BeforeClass;
39  import org.junit.Test;
40  import static org.junit.Assert.*;
41  
42  /**
43   *
44   * @author aploese
45   */
46  public class PduDecoderTest {
47  
48      public PduDecoderTest() {
49      }
50  
51      @BeforeClass
52      public static void setUpClass() throws Exception {
53      }
54  
55      @AfterClass
56      public static void tearDownClass() throws Exception {
57      }
58  
59      @Before
60      public void setUp() {
61      }
62  
63      @After
64      public void tearDown() {
65      }
66  
67      @Test
68      public void testDecodeDeliverMultiPartSMS() {
69          System.out.println("Decode multi part SMS");
70          PduDecoder pduDecoder = PduDecoder.getPduDecoder();
71          PduDeliver pdu = (PduDeliver)pduDecoder.decodeFromOctets(
72                "0791942143658709440C91949078563412000080212261834340A0050003DA030182E2F0382C0E8FC3E2F0382C0E8FC3E2F018141687C76171781C1687C76171781C1687C7A0B2D95C2E9BCDE5B2D95C2E9BCDE5B2D95C0695CDE672D96C2E97CDE672D96C2E97CDE632089D3EA3D1E9331A9D3EA3D1E9331A9D3EA341E8F4198D4E9FD1E8F4198D4E9FD1E8F4190D62B3D96C369BCD66B3D96C369BCD66B3D96C109BCD66B3D9");
73          assertEquals("+491234567890", pdu.getSmscAddress());
74          assertEquals("+490987654321", pdu.getOrginatorAddress());
75          assertEquals(false, pdu.isCompressed());
76          assertEquals(Pdu.Encoding.TEXT_7BIT, pdu.getEncoding());
77  //TODO plattform specific        assertEquals("Mon Dec 22 16:38:34 CET 2008", pdu.getSmscTimestamp().toString());
78          assertEquals(3, pdu.getPartCount());
79          assertEquals(1, pdu.getPartIndex());
80          assertEquals(0xDA, pdu.getMsgId());
81          assertEquals(153, pdu.getText().length());
82          assertEquals("Abacabacabacabacabac abacabacabacabacabac effeeffeeffeeffeeffe effeeffeeffeeffeeffe highhighhighhighhigh highhighhighhighhigh llllllllllllllllllll llllll", pdu.getText());
83  
84          pdu = (PduDeliver)pduDecoder.decodeFromOctets(
85                  "0791942143658709400C91949078563412000080212261830440A0050003DA0302D86C369BCD66B3D96C369BCD06B5DFED76FBDD6EB7DFED76FBDD6EB7DFED36A8FD6EB7DBEF76BBFD6EB7DBEF76BBFD6EB74170381C0E87C3E170381C0E87C3E170381C0E82C3E170381C0E87C3E170381C0E87C3E17010BD4EA7D7E9F43A9D5EA7D3EB747A9D4EAF83E8753ABD4EA7D7E9F43A9D5EA7D3EB747A1D74BFDFEFF7FBFD7EBFDFEF");
86          assertEquals("+491234567890", pdu.getSmscAddress());
87          assertEquals("+490987654321", pdu.getOrginatorAddress());
88          assertEquals(false, pdu.isCompressed());
89          assertEquals(Pdu.Encoding.TEXT_7BIT, pdu.getEncoding());
90  //TODO plattform specific        assertEquals("Mon Dec 22 16:38:40 CET 2008", pdu.getSmscTimestamp().toString());
91          assertEquals(3, pdu.getPartCount());
92          assertEquals(2, pdu.getPartIndex());
93          assertEquals(0xDA, pdu.getMsgId());
94          assertEquals(153, pdu.getText().length());
95          assertEquals("llllllllllllll mommmommmommmommmomm mommmommmommmommmomm pppppppppppppppppppp pppppppppppppppppppp tuttuttuttuttuttuttu tuttuttuttuttuttuttu wwwwwwwwwwww", pdu.getText());
96  
97          pdu = (PduDeliver)pduDecoder.decodeFromOctets(
98                  "0791942143658709440C919490785634120000802122618364406D050003DA0303EEF7FBFD7ED7DF41F7FBFD7EBFDFEFF7FBFD7EBFDFEFF7BBFE0E02814020100804028140201008040281402050581C1E87C5E171581C1E87C5E171581C1E83CA6673B96C3697CB6673B90C6ABFDBEDF6BBDD6EBFDB6DF7DB0D02");
99          assertEquals("+491234567890", pdu.getSmscAddress());
100         assertEquals("+490987654321", pdu.getOrginatorAddress());
101         assertEquals(false, pdu.isCompressed());
102         assertEquals(Pdu.Encoding.TEXT_7BIT, pdu.getEncoding());
103 //TODO plattform specific        assertEquals("Mon Dec 22 16:38:46 CET 2008", pdu.getSmscTimestamp().toString());
104         assertEquals(3, pdu.getPartCount());
105         assertEquals(3, pdu.getPartIndex());
106         assertEquals(0xDA, pdu.getMsgId());
107         assertEquals(102, pdu.getText().length());
108         assertEquals("wwwwwwzw wwwwwwwwwwwwwwwwwwzw                      abacabacabacabacabac effeeffeeffee mommmommmommnon ", pdu.getText());
109 
110     }
111 
112         @Test
113     public void testDecodeDeliver7CharSMS() {
114 System.out.println("Decode multi part SMS");
115         PduDecoder pduDecoder = PduDecoder.getPduDecoder();
116         PduDeliver pdu = (PduDeliver)pduDecoder.decodeFromOctets("0791942143658709040C919490785634120000901002112381400731D98C56B3DD00");
117         assertEquals("+491234567890", pdu.getSmscAddress());
118         assertEquals("+490987654321", pdu.getOrginatorAddress());
119         assertEquals(false, pdu.isCompressed());
120         assertEquals(Pdu.Encoding.TEXT_7BIT, pdu.getEncoding());
121 //TODO plattform specific        assertEquals("Tue Jan 20 11:32:18 CET 2009", pdu.getSmscTimestamp().toString());
122         assertEquals(0, pdu.getPartCount());
123         assertEquals(0, pdu.getPartIndex());
124         assertEquals(0, pdu.getMsgId());
125         assertEquals(7, pdu.getText().length());
126         assertEquals("1234567", pdu.getText());
127         }
128 
129 }