4646import org .restcomm .connect .commons .annotations .WithInSecsTests ;
4747import org .restcomm .connect .sms .smpp .SmppInboundMessageEntity ;
4848
49+ import com .cloudhopper .commons .charset .Charset ;
4950import com .cloudhopper .commons .charset .CharsetUtil ;
5051import com .cloudhopper .smpp .type .SmppChannelException ;
5152import com .cloudhopper .smpp .type .SmppInvalidArgumentException ;
@@ -66,9 +67,9 @@ public class SmppTest {
6667 private static String to = "7777" ;
6768 private static String toPureSipProviderNumber = "7007" ;
6869 private static String from = "9999" ;
69- private static String msgBody = "Message from SMPP Server to Restcomm" ;
70- private static String msgBodyResp = "Response from Restcomm to SMPP server" ;
71- private static String msgBodyRespUCS2 = "Response from Restcomm to SMPP serverПППРРр " ;
70+ private static String msgBody = "か~!@#$%^&*()-= \u263a \u00a1 \u00a2 \u00a3 \u00a4 \u00a5 Message from SMPP Server to Restcomm" ;
71+ private static String msgBodyResp = "か~!@#$%^&*()-= \u263a \u00a1 \u00a2 \u00a3 \u00a4 \u00a5 Response from Restcomm to SMPP server" ;
72+ private static String msgBodyRespUCS2 = "か~!@#$%^&*()-= \u263a \u00a1 \u00a2 \u00a3 \u00a4 \u00a5 Response from Restcomm to SMPP server " ;
7273
7374 @ Rule
7475 public WireMockRule wireMockRule = new WireMockRule (8090 ); // No-args constructor defaults to port 8080
@@ -190,27 +191,39 @@ public void after() throws InterruptedException {
190191 Thread .sleep (2000 );
191192 }
192193
193- private String smsEchoRcml = "<Response><Sms to=\" " +from +"\" from=\" " +to +"\" >" +msgBodyResp +"</Sms></Response>" ;
194- @ Test
195- public void testSendMessageToRestcomm () throws SmppInvalidArgumentException , IOException , InterruptedException {
194+ @ Test
195+ public void testSendMessageToRestcommUTF8 () throws SmppInvalidArgumentException , IOException , InterruptedException {
196+ testSendMessageToRestcomm (msgBody , msgBodyResp , CharsetUtil .CHARSET_UTF_8 );
197+ }
196198
197- stubFor (get (urlPathEqualTo ("/smsApp" ))
198- .willReturn (aResponse ()
199- .withStatus (200 )
200- .withHeader ("Content-Type" , "text/xml" )
201- .withBody (smsEchoRcml )));
199+ @ Test
200+ public void testSendMessageToRestcommUCS2 () throws SmppInvalidArgumentException , IOException , InterruptedException {
201+ testSendMessageToRestcomm (msgBody , msgBodyRespUCS2 , CharsetUtil .CHARSET_UCS_2 );
202+ }
203+
204+ public void testSendMessageToRestcomm (String msgBodySend , String msgBodyResp , Charset charset ) throws SmppInvalidArgumentException , IOException , InterruptedException {
202205
203- mockSmppServer .sendSmppMessageToRestcomm (msgBody ,to ,from ,CharsetUtil .CHARSET_GSM );
206+ String smsEchoRcml = "<Response><Sms to=\" " + from + "\" from=\" " + to + "\" >" + msgBodyResp + "</Sms></Response>" ;
207+ stubFor (get (urlPathEqualTo ("/smsApp" )).willReturn (aResponse ()
208+ .withStatus (200 ).withHeader ("Content-Type" , "text/xml" )
209+ .withBody (smsEchoRcml )));
210+
211+ mockSmppServer .sendSmppMessageToRestcomm (msgBodySend , to , from ,
212+ charset );
204213 Thread .sleep (2000 );
205214 assertTrue (mockSmppServer .isMessageSent ());
206- Thread .sleep (2000 );
207- assertTrue (mockSmppServer .isMessageReceived ());
208- SmppInboundMessageEntity inboundMessageEntity = mockSmppServer .getSmppInboundMessageEntity ();
209- assertNotNull (inboundMessageEntity );
210- assertTrue (inboundMessageEntity .getSmppTo ().equals (from ));
211- assertTrue (inboundMessageEntity .getSmppFrom ().equals (to ));
212- assertTrue (inboundMessageEntity .getSmppContent ().equals (msgBodyResp ));
213- }
215+ Thread .sleep (2000 );
216+ assertTrue (mockSmppServer .isMessageReceived ());
217+ SmppInboundMessageEntity inboundMessageEntity = mockSmppServer .getSmppInboundMessageEntity ();
218+ assertNotNull (inboundMessageEntity );
219+
220+ logger .info ("msgBodyResp: " + msgBodyResp );
221+ logger .info ("getSmppContent: " + inboundMessageEntity .getSmppContent ());
222+
223+ assertTrue (inboundMessageEntity .getSmppTo ().equals (from ));
224+ assertTrue (inboundMessageEntity .getSmppFrom ().equals (to ));
225+ assertTrue (inboundMessageEntity .getSmppContent ().equals (msgBodyResp ));
226+ }
214227
215228 private String smsEchoRcmlPureSipProviderNumber = "<Response><Sms to=\" " +from +"\" from=\" " +toPureSipProviderNumber +"\" >" +msgBodyResp +"</Sms></Response>" ;
216229 @ Test //https://telestax.atlassian.net/browse/RESTCOMM-1428, https://telestax.atlassian.net/browse/POSTMORTEM-13
@@ -237,7 +250,7 @@ public void testSendSMPPMessageToRestcommPureSipProviderNumber () throws SmppInv
237250 private String smsEchoRcmlUCS2 = "<Response><Sms to=\" " +from +"\" from=\" " +to +"\" >" +msgBodyRespUCS2 +"</Sms></Response>" ;
238251 @ Test
239252 @ Category (value ={FeatureAltTests .class , BrokenTests .class })
240- public void testSendMessageToRestcommUCS2 () throws SmppInvalidArgumentException , IOException , InterruptedException {
253+ public void testSendMessageToRestcommUCS2_2 () throws SmppInvalidArgumentException , IOException , InterruptedException {
241254
242255 stubFor (get (urlPathEqualTo ("/smsApp" ))
243256 .willReturn (aResponse ()
0 commit comments