phoenixframe平台连接socket服务器,并接收返回值的示例

原创
2015/08/15 11:09
阅读数 197
package org.phoenix.cases.plugin;

import java.util.LinkedList;

import org.phoenix.model.CaseLogBean;
import org.phoenix.model.UnitLogBean;
import org.phoenix.plugins.ITelnetClient;
import org.phoenix.proxy.ActionProxy;

/**
 * Telnet客户端测试
 * @author mengfeiyang
 *
 */
public class TelnetPluginTest extends ActionProxy{
	@Override
	public LinkedList<UnitLogBean> run(CaseLogBean caseLogBean) {
		init(caseLogBean);
		//连接SocketServer
		ITelnetClient telnet = phoenix.telnetClient().configTelnetClient("localhost", 8889);
		String rs = telnet.sendCommand("!showorders", "datas");//向socketServer发送指令,如果返回值以datas结尾,则终止数据接收
		System.out.println(rs);
		phoenix.checkPoint().checkIsNull(rs);
		String rs2 = telnet.sendCommand("!showusers", "]");
		System.out.println(rs2);
		phoenix.checkPoint().checkIsNull(rs2);
		telnet.disconnect();//断开本次的连接
		
		return getUnitLog(); 
	}
	
	public static void main(String[] args) {
		TelnetPluginTest p = new TelnetPluginTest();
		LinkedList<UnitLogBean> ll = p.run(new CaseLogBean());
		for(UnitLogBean l : ll){
			System.out.println(l.getContent());
		}
	}
}

 

展开阅读全文
加载中

作者的其它热门文章

打赏
0
0 收藏
分享
打赏
0 评论
0 收藏
0
分享
返回顶部
顶部