コード例 #1
0
 void testRLIwithAccountNumberAndPassword()
 {
     RliMessageHandler rlihandler(protocol_);
     VnocMessageSocketHandler<MockTcpConnection> handler(conn_);
     handler.setProtocol(protocol_);
     handler.start();
     MSG_RLI rliMessage;
     unsigned char tmp[16] = {0};
     srand((unsigned int)time(0));
     for(int i = 0; i < 16; ++i)
     {
         tmp[i] = rand() % 256;
     }
     rliMessage.SetAccountNumber(tmp, 16);
     for(int i = 0; i < 16; ++i)
     {
         tmp[i] = rand() % 256;
     }
     rliMessage.SetPassword(tmp, 16);
     PackMessage packer;
     int len = packer.GetMessageLen(&rliMessage);
     char *buf = new char[len];
     packer.Pack(&rliMessage, (byte *)buf, len);
     conn_->setRecv(buf, len);
     char *sendBuf = (char*)conn_->getSendBuf();
     //return an ALI message with login-success
     CMessageParser parser;
     CMessage *msg = parser.Parse((byte*)sendBuf, conn_->getSendLen());
     CPPUNIT_ASSERT(msg->GetMessageType() == MSG_ALI_TYPE);
     CPPUNIT_ASSERT(((MSG_ALI*)msg)->GetLoginResult() == 0);
     delete msg;
     delete buf;
 }
コード例 #2
0
 void testRVC()
 {
     RvcMessageHandler rvchandler(protocol_);
     VnocMessageSocketHandler<MockTcpConnection> handler(conn_);
     handler.setProtocol(protocol_);
     handler.start();
     MSG_RVC rvcMessage;
     PackMessage packer;
     int len = packer.GetMessageLen(&rvcMessage);
     char *buf = new char[len];
     packer.Pack(&rvcMessage, (byte *)buf, len);
     conn_->setRecv(buf, len);
     const char *sendBuf = conn_->getSendBuf();
     //return an AVC message
     CMessageParser parser;
     CMessage *msg = parser.Parse((byte*)sendBuf, conn_->getSendLen());
     CPPUNIT_ASSERT(msg->GetMessageType() == MSG_AVC_TYPE);
     delete msg;
     delete buf;
 }
コード例 #3
0
 void testRLIdefault()
 {
     RliMessageHandler rlihandler(protocol_);
     VnocMessageSocketHandler<MockTcpConnection> handler(conn_);
     handler.setProtocol(protocol_);
     handler.start();
     MSG_RLI rliMessage;
     PackMessage packer;
     int len = packer.GetMessageLen(&rliMessage);
     char *buf = new char[len];
     packer.Pack(&rliMessage, (byte *)buf, len);
     conn_->setRecv(buf, len);
     char *sendBuf = (char*)conn_->getSendBuf();
     //return an ALI message with login-failure.
     CMessageParser parser;
     CMessage *msg = parser.Parse((byte*)sendBuf, conn_->getSendLen());
     CPPUNIT_ASSERT(msg->GetMessageType() == MSG_ALI_TYPE);
     CPPUNIT_ASSERT(((MSG_ALI*)msg)->GetLoginResult() == 1);
     delete msg;
     delete buf;
 }