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.Ignore;
40 import org.junit.Test;
41 import static org.junit.Assert.*;
42
43
44
45
46
47 public class PduEncoderTest {
48
49 public PduEncoderTest() {
50 }
51
52 @BeforeClass
53 public static void setUpClass() throws Exception {
54 }
55
56 @AfterClass
57 public static void tearDownClass() throws Exception {
58 }
59
60 @Before
61 public void setUp() {
62 }
63
64 @After
65 public void tearDown() {
66 }
67
68
69
70
71 @Test
72 public void testSingle7BitASCII() {
73 System.out.println("testSingle7BitASCII");
74 PduEncoder instance = new PduEncoder();
75 instance.setReceiverPhonenumber("491234567890");
76
77 instance.setMessageText("A|A|AAA");
78
79 String[] pdus = instance.encodePdus();
80 assertEquals(1, pdus.length);
81 PduDecoder d = new PduDecoder();
82 assertEquals("A|A|AAA", d.decodeFromOctets(pdus[0]).getText());
83 assertEquals("0011000C919421436587090000AA09C10D30B801068341", pdus[0]);
84 }
85
86
87
88
89 @Test
90 public void testMulti7BitASCII() {
91 System.out.println("testSingle7BitASCII");
92 PduEncoder instance = new PduEncoder();
93 instance.setReceiverPhonenumber("491234567890");
94 StringBuilder sb = new StringBuilder();
95 for (int i = 0; i < 153; i++) {
96 sb.append('A');
97 }
98 for (int i = 0; i < 153; i++) {
99 sb.append('B');
100 }
101 sb.append('C');
102 instance.setMessageText(sb.toString());
103 String[] pdus = instance.encodePdus();
104
105 PduDecoder d = new PduDecoder();
106 PduSubmit p = (PduSubmit)d.decodeFromOctets(pdus[0]);
107 assertEquals(3, pdus.length);
108 assertEquals("+491234567890", p.getDestinationAddress());
109 assertEquals(153, p.getText().length());
110 assertEquals("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", p.getText());
111 assertEquals(
112 "0051000C919421436587090000AAA005000300030182C16030180C0683C16030180C0683C16030180C0683C16030180C0683C16030180C0683C16030180C0683C16030180C0683C16030180C0683C16030180C0683C16030180C0683C16030180C0683C16030180C0683C16030180C0683C16030180C0683C16030180C0683C16030180C0683C16030180C0683C16030180C0683C16030180C0683",
113 pdus[0]);
114 assertEquals(
115 "0051000C919421436587090000AAA00500030103028442A15028140A8542A15028140A8542A15028140A8542A15028140A8542A15028140A8542A15028140A8542A15028140A8542A15028140A8542A15028140A8542A15028140A8542A15028140A8542A15028140A8542A15028140A8542A15028140A8542A15028140A8542A15028140A8542A15028140A8542A15028140A8542A15028140A85",
116 pdus[1]);
117 assertEquals(
118 "0051000C919421436587090000AA0805000302030386", pdus[2]);
119 }
120 @Test
121 public void testMulti7BitASCII_1() {
122 System.out.println("testSingle7BitASCII_1");
123 PduEncoder instance = new PduEncoder();
124 instance.setReceiverPhonenumber("491234567890");
125 String text = "Abacabacabacabacabac abacabacabacabacabac effeeffeeffeeffeeffe effeeffeeffeeffeeffe highhighhighhighhigh highhighhighhighhigh llllllllllllllllllll llllllllllllllllllll mommmommmommmommmomm mommmommmommmommmomm pppppppppppppppppppp pppppppppppppppppppp tuttuttuttuttuttuttu tuttuttuttuttuttuttu wwwwwwwwwwwwwwwwwwzw wwwwwwwwwwwwwwwwwwzw abacabacabacabacabac effeeffeeffee mommmommmommnon ";
126 instance.setMessageText(text);
127 String[] pdus = instance.encodePdus();
128 assertEquals(
129 "0051000C919421436587090000AAA005000300030182E2F0382C0E8FC3E2F0382C0E8FC3E2F018141687C76171781C1687C76171781C1687C7A0B2D95C2E9BCDE5B2D95C2E9BCDE5B2D95C0695CDE672D96C2E97CDE672D96C2E97CDE632089D3EA3D1E9331A9D3EA3D1E9331A9D3EA341E8F4198D4E9FD1E8F4198D4E9FD1E8F4190D62B3D96C369BCD66B3D96C369BCD66B3D96C109BCD66B3D9",
130 pdus[0]);
131 assertEquals(
132 "0051000C919421436587090000AAA0050003010302D86C369BCD66B3D96C369BCD06B5DFED76FBDD6EB7DFED76FBDD6EB7DFED36A8FD6EB7DBEF76BBFD6EB7DBEF76BBFD6EB74170381C0E87C3E170381C0E87C3E170381C0E82C3E170381C0E87C3E170381C0E87C3E17010BD4EA7D7E9F43A9D5EA7D3EB747A9D4EAF83E8753ABD4EA7D7E9F43A9D5EA7D3EB747A1D74BFDFEFF7FBFD7EBFDFEF",
133 pdus[1]);
134 assertEquals(
135 "0051000C919421436587090000AA6D050003020303EEF7FBFD7ED7DF41F7FBFD7EBFDFEFF7FBFD7EBFDFEFF7BBFE0E02814020100804028140201008040281402050581C1E87C5E171581C1E87C5E171581C1E83CA6673B96C3697CB6673B90C6ABFDBEDF6BBDD6EBFDB6DF7DB0D02", pdus[2]);
136 }
137
138
139
140
141
142 @Ignore
143 @Test
144 public void testGetMessageText() {
145 System.out.println("getMessageText");
146 PduEncoder instance = new PduEncoder();
147 String expResult = "";
148 String result = instance.getMessageText();
149 assertEquals(expResult, result);
150
151 fail("The test case is a prototype.");
152 }
153
154
155
156
157 @Ignore
158 @Test
159 public void testSetMessageText() {
160 System.out.println("setMessageText");
161 String messageText = "";
162 PduEncoder instance = new PduEncoder();
163 instance.setMessageText(messageText);
164
165 fail("The test case is a prototype.");
166 }
167
168
169
170
171 @Ignore
172 @Test
173 public void testGetReceiverPhonenumber() {
174 System.out.println("getReceiverPhonenumber");
175 PduEncoder instance = new PduEncoder();
176 String expResult = "";
177 String result = instance.getReceiverPhonenumber();
178 assertEquals(expResult, result);
179
180 fail("The test case is a prototype.");
181 }
182
183
184
185
186 @Ignore
187 @Test
188 public void testSetReceiverPhonenumber() {
189 System.out.println("setReceiverPhonenumber");
190 String receiverPhonenumber = "";
191 PduEncoder instance = new PduEncoder();
192 instance.setReceiverPhonenumber(receiverPhonenumber);
193
194 fail("The test case is a prototype.");
195 }
196
197 private String get7BitText(int i) {
198 StringBuilder sb = new StringBuilder(i);
199 for (int j = 0; j < i; j++) {
200 sb.append(Entry7BitEncoding.table[j % Entry7BitEncoding.table.length].c);
201 }
202 return sb.toString();
203 }
204
205 }