东软SMIAS Java API移动短信接入JUnit TestCase
2008-02-23 09:35:29来源:互联网 阅读 ()
package sms.test;
import com.commerceware.cmpp.*;
import junit.Framework.TestCase;
public class JFTest extends TestCase {
protected void setUp() throws Exception {
super.setUp();
}
protected void tearDown() throws Exception {
super.tearDown();
}
public void testJF()
{
cmppe_result result = null;
CMPP cmpp = new CMPP();
conn_desc connDesc = new conn_desc();
String loginID = "0****3";
String userID = "099****3\0";
String password = "your pwd";
String icpID = "9****2\0";
String dst = "13950009***\0";
String mess = "全长20位,不推荐全用\0";
String sVCType = "44****\0";
String ip = "211.*.*.*";
int port = 7890;
System.out.println("开始运行...");
try{
cmpp.cmpp_connect_to_ismg(ip, port, connDesc);
System.out.println("连接完毕!");
cmpp.cmpp_login(connDesc, loginID, password, (byte)2, 0x12, (int)System.currentTimeMillis());
result = cmpp.readResPack(connDesc);
if (result.stat != CMPP.CMPPE_RSP_SUCCESS){
System.out.println("登录失败 " result.stat);
System.exit(0);
}else{
}
}catch(Exception e){
System.out.println("登录失败 " e);
System.exit(0);
}
System.out.println("登录成功");
cmppe_submit submitStruct = new cmppe_submit();
try{
submitStruct.set_svctype(svcType.getBytes());
submitStruct.set_srcaddr(userID.getBytes());
submitStruct.set_ducount((byte)1);
byte[][] dstByte= {{0,0},{0,0}};
dstByte[0] = dst.getBytes();
submitStruct.set_dstaddr(dstByte);
submitStruct.set_msgmode((byte)1);
// submitStruct.set_feetype((byte)1);
// submitStruct.set_infofee(300);
byte[] message = mess.getBytes();
submitStruct.set_msg((byte)15, message.length, message);
submitStruct.set_icpid( icpID.getBytes());
cmpp.cmpp_submit(connDesc, submitStruct);
}catch(Exception e){
System.out.println("异常失败 " e);
System.exit(1);
}
try{
for(;;){
result= cmpp.readResPack(connDesc);
switch(result.pack_id){
case CMPP.CMPPE_NACK_RESP:
System.out.println("Get Nack Pack");
break;
case CMPP.CMPPE_SUBMIT_RESP:
System.out.println("Get Sumit Resp. stat = " result.stat);
break;
case CMPP.CMPPE_DELIVER:
cmppe_deliver_result deliverResult = (cmppe_deliver_result)result;
System.out.println("Deliver Status Rpt " deliverResult.status_rpt);
System.out.println("Deliver Src " new String(deliverResult.src_addr));
System.out.println("Deliver Dst " new String(deliverResult.dst_addr));
System.out.println("Deliver Message " new String(deliverResult.short_msg,"GB2312"));
cmpp.cmpp_send_deliver_resp(connDesc, deliverResult.seq, deliverResult.stat);
break;
}
}
}catch(Exception e){
System.out.println("异常退出 " e);
}
}
}
上一篇: 使用APACHE ORO 实现正则替换
下一篇: BeanFactory & Context In Spring
标签:
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有
IDC资讯: 主机资讯 注册资讯 托管资讯 vps资讯 网站建设
网站运营: 建站经验 策划盈利 搜索优化 网站推广 免费资源
网络编程: Asp.Net编程 Asp编程 Php编程 Xml编程 Access Mssql Mysql 其它
服务器技术: Web服务器 Ftp服务器 Mail服务器 Dns服务器 安全防护
软件技巧: 其它软件 Word Excel Powerpoint Ghost Vista QQ空间 QQ FlashGet 迅雷
网页制作: FrontPages Dreamweaver Javascript css photoshop fireworks Flash