1
2
3
4
5 package net.sf.atmodem4j.core.gsm;
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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
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
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
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
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
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 }