implementation of itoa/itow
[public/netxms.git] / tests / test-libnetxms / nxcp.cpp
CommitLineData
7a70e9de
VK
1#include <nms_common.h>
2#include <nms_util.h>
3#include <nxcpapi.h>
4#include <testtools.h>
5
6/**
7 * Poster thread
8 */
9static THREAD_RESULT THREAD_CALL PosterThread(void *arg)
10{
11 NXCPMessage *msg = new NXCPMessage();
12 msg->setCode(CMD_REQUEST_COMPLETED);
13 msg->setId(42);
14 ThreadSleepMs((UINT32)GetCurrentTimeMs() % 2000);
15 ((MsgWaitQueue *)arg)->put(msg);
16 return THREAD_OK;
17}
18
19/**
20 * Test message wait queue
21 */
22void TestMsgWaitQueue()
23{
24 StartTest(_T("Message wait queue"));
25
26 MsgWaitQueue *queue = new MsgWaitQueue;
27 ThreadCreate(PosterThread, 0, queue);
28 NXCPMessage *msg = queue->waitForMessage(CMD_REQUEST_COMPLETED, 42, 5000);
29 AssertNotNull(msg);
30 delete msg;
31
32 msg = queue->waitForMessage(CMD_REQUEST_COMPLETED, 42, 1000);
33 AssertNull(msg);
34
35 delete queue;
36
37 EndTest();
38}