javacommons/comms/tsrc/src/commsmessage.cpp
branchRCL_3
changeset 14 04becd199f91
equal deleted inserted replaced
13:f5050f1da672 14:04becd199f91
       
     1 /*
       
     2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  ?Description
       
    15 *
       
    16 */
       
    17 
       
    18 #include "TestHarness.h"
       
    19 #include "javauid.h"
       
    20 #include "javacommonutils.h"
       
    21 #include "exceptionbase.h"
       
    22 
       
    23 #include "commsmessage.h"
       
    24 #include "commspermissions.h"
       
    25 #include "commsclientendpoint.h"
       
    26 #include "echoserver.h"
       
    27 
       
    28 using namespace java::comms;
       
    29 using namespace std;
       
    30 using java::util::Uid;
       
    31 using java::util::JavaCommonUtils;
       
    32 
       
    33 
       
    34 class PermissionListener : public CommsListener
       
    35 {
       
    36 public:
       
    37     CommsMessage msg;
       
    38     CommsEndpoint* comms;
       
    39 
       
    40     virtual void processMessage(CommsMessage& aMessage)
       
    41     {
       
    42         msg = aMessage;
       
    43         CommsMessage reply;
       
    44         reply.replyTo(aMessage);
       
    45         comms->send(reply);
       
    46     }
       
    47 };
       
    48 
       
    49 
       
    50 
       
    51 TEST_GROUP(CommsMessage)
       
    52 {
       
    53     EchoServer server;
       
    54     CommsClientEndpoint client;
       
    55 
       
    56     TEST_SETUP()
       
    57     {
       
    58         server.start(IPC_ADDRESS_COMMS_MODULE_TEST);
       
    59         client.connect(IPC_ADDRESS_COMMS_MODULE_TEST);
       
    60     }
       
    61 
       
    62     TEST_TEARDOWN()
       
    63     {
       
    64         client.disconnect();
       
    65         server.stop();
       
    66     }
       
    67 };
       
    68 
       
    69 /**
       
    70  * Test setters and getters
       
    71  * 1: test header setters and getters
       
    72  * 2: test message body setters and getters
       
    73  * 3: read contents multiple times
       
    74  */
       
    75 TEST(CommsMessage, getterSetter)
       
    76 {
       
    77 #ifdef __SYMBIAN32__
       
    78     EXPECT_N_LEAKS(1);
       
    79 #else
       
    80     EXPECT_N_LEAKS(2);
       
    81 #endif
       
    82     // 1: test header setters and getters
       
    83     CommsMessage msg;
       
    84     msg.setModuleId(1111);
       
    85     msg.setMessageId(2222);
       
    86     msg.setMessageRef(3333);
       
    87 
       
    88     CommsMessage receivedMsg;
       
    89     CHECK(!client.sendReceive(msg, receivedMsg, 1));
       
    90 
       
    91     CHECK(msg.getModuleId() == receivedMsg.getModuleId());
       
    92     CHECK(msg.getMessageId() == receivedMsg.getMessageId());
       
    93     CHECK(msg.getMessageRef() == receivedMsg.getMessageRef());
       
    94 
       
    95     // 2: test message body setters and getters
       
    96     string sin = "this is a string";
       
    97     wstring win = L"this is a wstring";
       
    98     int in = 1;
       
    99     long long lin = -1LL;
       
   100     Uid uid(L"sampleUid");
       
   101 
       
   102     msg << sin << win << in << lin << uid;
       
   103     CHECK(!client.sendReceive(msg, receivedMsg, 1));
       
   104     string sout;
       
   105     wstring wout;
       
   106     int out;
       
   107     long long lout;
       
   108     Uid uidOut;
       
   109     receivedMsg >> sout >> wout >> out >> lout >> uidOut;
       
   110 
       
   111     CHECK(0 == sin.compare(sout));
       
   112     CHECK(0 == win.compare(wout));
       
   113     CHECK(in == out);
       
   114     CHECK(lin == lout);
       
   115     CHECK(uid == uidOut);
       
   116 
       
   117     // 3: read contents multiple times
       
   118     CommsMessage m;
       
   119     m << "test" << 1;
       
   120     CommsMessage r;
       
   121     CHECK(!client.sendReceive(m, r, 1));
       
   122     string s, s2;
       
   123     int i, i2;
       
   124     r >> s >> i;
       
   125     r.begin();
       
   126     r >> s2 >> i2;
       
   127     CHECK(0 == s.compare(s));
       
   128     CHECK(i == i2);
       
   129 }
       
   130 
       
   131 
       
   132 /**
       
   133  * Test CommsMessage streaming
       
   134  * 1: check ascii chars
       
   135  */
       
   136 TEST(CommsMessage, ascii)
       
   137 {
       
   138     CommsMessage msg;
       
   139     const int len = 0xff;
       
   140     char chars[len];
       
   141     for (int i=0; i < len; i++)
       
   142     {
       
   143         chars[i] = i;
       
   144     }
       
   145     string ascii(chars, len);
       
   146     msg << ascii;
       
   147     string result;
       
   148     msg >> result;
       
   149     CHECK(0 == ascii.compare(result));
       
   150 
       
   151     char* arr = msg.toByteArray();
       
   152     CommsMessage msg2(reinterpret_cast<ipcMessage_t*>(arr));
       
   153 
       
   154     msg2 >> result;
       
   155     CHECK(0 == ascii.compare(result));
       
   156 }
       
   157 
       
   158 
       
   159 /**
       
   160  * Test CommsMessage streaming
       
   161  * 1: check special cases: space, '\n' and empty string
       
   162  */
       
   163 TEST(CommsMessage, SpecialChars)
       
   164 {
       
   165     CommsMessage msg;
       
   166     string a = "";
       
   167     string b = "\n";
       
   168     string c;
       
   169     string d = " ";
       
   170     string e = "  ";
       
   171     string f = "\n\n";
       
   172     string g = "\n ";
       
   173     string h = " \r\n";
       
   174     int i = 0;
       
   175     int j = 0xffffffff;
       
   176     long long k = -1LL;
       
   177     long long l = 0LL;
       
   178     Uid m;
       
   179 
       
   180     msg << a << i << k << b << c << j << d << e << l << f << g << h << m;
       
   181     string ao, bo, co, doo, eo, fo, go, ho;
       
   182     int io, jo;
       
   183     long long ko, lo;
       
   184     Uid mo;
       
   185     msg >> ao >> io >> ko >> bo >> co >> jo >> doo >> eo >> lo >> fo >> go >> ho >> mo;
       
   186 
       
   187     CHECK(0 == a.compare(ao));
       
   188     CHECK(0 == b.compare(bo));
       
   189     CHECK(0 == c.compare(co));
       
   190     CHECK(0 == d.compare(doo));
       
   191     CHECK(0 == e.compare(eo));
       
   192     CHECK(0 == f.compare(fo));
       
   193     CHECK(0 == g.compare(go));
       
   194     CHECK(0 == h.compare(ho));
       
   195     CHECK(i == io);
       
   196     CHECK(j == jo);
       
   197     CHECK(k == ko);
       
   198     CHECK(l == lo);
       
   199     CHECK(m == mo);
       
   200     // make copy
       
   201     char* arr = msg.toByteArray();
       
   202     CommsMessage msg2(reinterpret_cast<ipcMessage_t*>(arr));
       
   203 
       
   204     msg2 >> ao >> io >> ko >> bo >> co >> jo >> doo >> eo >> lo >> fo >> go >> ho >> mo;
       
   205 
       
   206     CHECK(0 == a.compare(ao));
       
   207     CHECK(0 == b.compare(bo));
       
   208     CHECK(0 == c.compare(co));
       
   209     CHECK(0 == d.compare(doo));
       
   210     CHECK(0 == e.compare(eo));
       
   211     CHECK(0 == f.compare(fo));
       
   212     CHECK(0 == g.compare(go));
       
   213     CHECK(0 == h.compare(ho));
       
   214     CHECK(i == io);
       
   215     CHECK(j == jo);
       
   216     CHECK(k == ko);
       
   217     CHECK(l == lo);
       
   218     CHECK(m == mo);
       
   219 }
       
   220 
       
   221 /**
       
   222  * Test CommsMessage streaming
       
   223  * 1: empty message
       
   224  */
       
   225 TEST(CommsMessage, empty)
       
   226 {
       
   227     CommsMessage msg;
       
   228 
       
   229     char* arr = msg.toByteArray();
       
   230     CommsMessage msg2(reinterpret_cast<ipcMessage_t*>(arr));
       
   231 
       
   232     CommsMessage msg3(msg);
       
   233     CommsMessage msg4 = msg;
       
   234     CommsMessage msg5 = msg;
       
   235 
       
   236     CHECK(0 == msg.toString().compare(msg2.toString()));
       
   237     CHECK(0 == msg.toString().compare(msg3.toString()));
       
   238     CHECK(0 == msg.toString().compare(msg4.toString()));
       
   239 
       
   240     // check that content can be added ok
       
   241     string s = "hello world";
       
   242     int i = 3;
       
   243     msg5 << i << s;
       
   244 
       
   245     string so;
       
   246     int io;
       
   247 
       
   248     msg5 >> io >> so;
       
   249     CHECK(0 == s.compare(so));
       
   250     CHECK(i == io);
       
   251 }
       
   252 
       
   253 /**
       
   254  * Test CommsMessage streaming
       
   255  * 1: copy constructor and assingment test
       
   256  * 2: copy constructor and assingment test (bytearray)
       
   257  * 3: self-assingment test
       
   258  */
       
   259 TEST(CommsMessage, constuctor)
       
   260 {
       
   261     // 1: copy constructor and assingment test
       
   262     CommsMessage msg;
       
   263 
       
   264     msg << "hello" << "world" << "this is test #" << 4;
       
   265 
       
   266     CommsMessage msg2(msg);
       
   267     CommsMessage msg3 = msg;
       
   268 
       
   269     CHECK(0 == msg.toString().compare(msg2.toString()));
       
   270     CHECK(0 == msg.toString().compare(msg3.toString()));
       
   271 
       
   272     // 2: copy constructor and assingment test (bytearray)
       
   273     CommsMessage m;
       
   274 
       
   275     m << "hello" << "world" << "this is test #" << 4;
       
   276 
       
   277     char* arr = m.toByteArray();
       
   278     CommsMessage m2(reinterpret_cast<ipcMessage_t*>(arr));
       
   279 
       
   280     CHECK(0 == m.toString().compare(m2.toString()));
       
   281 
       
   282     // 3: self-assingment test
       
   283     CommsMessage self;
       
   284 
       
   285     self << "hello";
       
   286     CHECK((self = self) == &self)
       
   287     string s;
       
   288     self >> s;
       
   289     CHECK(0 == s.compare("hello"));
       
   290 }
       
   291 
       
   292 /**
       
   293  * Test CommsMessage streaming
       
   294  * 1: read same value multiple times
       
   295  */
       
   296 TEST(CommsMessage, multipleReads)
       
   297 {
       
   298     CommsMessage msg;
       
   299 
       
   300     msg << "string 1" << "string 2" << "string 3" << "string 4";
       
   301     string a, b, c, temp;
       
   302 
       
   303     msg >> a;
       
   304     msg.begin();
       
   305 
       
   306     msg >> b;
       
   307 
       
   308     while (!(msg>>temp))
       
   309     {
       
   310         // read everything
       
   311     };
       
   312 
       
   313     msg.begin();
       
   314     msg >> c;
       
   315 
       
   316     CHECK(0 == a.compare(b));
       
   317     CHECK(0 == a.compare(c));
       
   318 }
       
   319 
       
   320 /**
       
   321  * Test CommsMessage streaming
       
   322  * 1: read in wrong order
       
   323  */
       
   324 TEST(CommsMessage, readOrder)
       
   325 {
       
   326     CommsMessage msg;
       
   327 
       
   328     msg << "string 1" << 1 << 2 << "string 2";
       
   329     string a, b;
       
   330     int i, j;
       
   331 
       
   332     msg >> i >> a >> b >> j;
       
   333     CHECK(0 == i);
       
   334 
       
   335     CommsMessage msg2;
       
   336     msg2 >> i >> a;
       
   337     CHECK(0 == i);
       
   338     CHECK(0 == a.compare(""));
       
   339 }
       
   340 
       
   341 /**
       
   342  * Test resetting CommsMessage
       
   343  * 1: reset message with payload
       
   344  * 2: reset empty message
       
   345  */
       
   346 TEST(CommsMessage, reset)
       
   347 {
       
   348     CommsMessage empty;
       
   349 
       
   350     // 1: reset message with payload
       
   351     CommsMessage msg;
       
   352     msg.setModuleId(1111);
       
   353     msg.setMessageId(2222);
       
   354     msg.setMessageRef(3333);
       
   355     msg.setSender(4444);
       
   356     msg.setReceiver(5555);
       
   357     msg << "string 1" << 1;
       
   358     msg.reset();
       
   359 
       
   360     CHECK(0 == msg.toString().compare(empty.toString()));
       
   361     CHECK(msg.getModuleId() == empty.getModuleId());
       
   362     CHECK(msg.getMessageId() == empty.getMessageId());
       
   363     CHECK(msg.getMessageRef() == empty.getMessageRef());
       
   364     CHECK(msg.getSender() == empty.getSender());
       
   365     CHECK(msg.getReceiver() == empty.getReceiver());
       
   366 
       
   367     // 2: reset empty message
       
   368     CommsMessage msg2;
       
   369     msg2.reset();
       
   370 
       
   371     CHECK(0 == msg2.toString().compare(empty.toString()));
       
   372     CHECK(msg2.getModuleId() == empty.getModuleId());
       
   373     CHECK(msg2.getMessageId() == empty.getMessageId());
       
   374     CHECK(msg2.getMessageRef() == empty.getMessageRef());
       
   375     CHECK(msg2.getSender() == empty.getSender());
       
   376     CHECK(msg2.getReceiver() == empty.getReceiver());
       
   377 }
       
   378 
       
   379 /**
       
   380  * Test replyTo method
       
   381  * 1: test replyTo method
       
   382  */
       
   383 TEST(CommsMessage, replyTo)
       
   384 {
       
   385     // 1: test replyTo method
       
   386     CommsMessage msg;
       
   387     msg.setModuleId(1111);
       
   388     msg.setMessageId(2222);
       
   389     msg.setMessageRef(3333);
       
   390     msg.setSender(4444);
       
   391     msg.setReceiver(5555);
       
   392 
       
   393     CommsMessage reply;
       
   394     reply.replyTo(msg);
       
   395 
       
   396     CHECK(msg.getModuleId() == reply.getModuleId());
       
   397     CHECK(msg.getMessageId() == reply.getMessageId());
       
   398     CHECK(msg.getMessageRef() == reply.getMessageRef());
       
   399     CHECK(msg.getSender() == reply.getReceiver());
       
   400     CHECK(msg.getReceiver() == reply.getSender());
       
   401 }
       
   402 
       
   403 /**
       
   404  * Test CommsMessage with different character encodings
       
   405  * 1: write and read UTF16 / UTF8 strings
       
   406  * 2: read-write mismatch cases string / wstring
       
   407  */
       
   408 TEST(CommsMessage, charEncoding)
       
   409 {
       
   410     // 1: write and read UTF16 / UTF8 strings
       
   411     CommsMessage msg;
       
   412 
       
   413     // devanagari letter A, tibetan digit zero, katakana letter YA
       
   414     wstring w1 = L"\u0905\u0F20\u30E4";
       
   415     string w1_in_utf8 = wstringToUtf8(w1);
       
   416 
       
   417     // latin small letter a with diaeresis, latin small letter a with ring above,
       
   418     // latin small letter o with diaeresis, Euro symbol
       
   419     wstring w2 = L"\u00E4\u00E5\u00F6\u20AC";
       
   420     string w2_in_utf8 = wstringToUtf8(w1);
       
   421 
       
   422     // Japanese Yen symbol, Roman AE with acute accent, Greek Capital Alpha, Greek Capital Omega,
       
   423     // Euro symbol, Rupee symbol, Cyrillic capital letter DZHE, Arabic letter TEH
       
   424     wstring w3 = L"\u00a5\u01FC\u0391\u03A9\u20ac\u20a8\u040F\u062A";
       
   425     string w3_in_utf8 = wstringToUtf8(w3);
       
   426 
       
   427     msg << w1 << w1_in_utf8 << w2 << w2_in_utf8 << w3 << w3_in_utf8;
       
   428     wstring wo1, wo2, wo3;
       
   429     string so1, so2, so3;
       
   430     msg >> wo1 >> so1 >> wo2 >> so2 >> wo3 >> so3;
       
   431 
       
   432     CHECK(0 == wo1.compare(w1));
       
   433     CHECK(0 == wo2.compare(w2));
       
   434     CHECK(0 == wo3.compare(w3));
       
   435     CHECK(0 == so1.compare(w1_in_utf8));
       
   436     CHECK(0 == so2.compare(w2_in_utf8));
       
   437     CHECK(0 == so3.compare(w3_in_utf8));
       
   438 
       
   439     // 2: read-write mismatch cases string / wstring
       
   440     msg.reset();
       
   441     string s4 = "hello world";
       
   442     wstring w4 = L"hello world";
       
   443 
       
   444     // devanagari letter A, tibetan digit zero, katakana letter YA
       
   445     string utf8 = "\xE0\xA4\x85\xE0\xBC\xA0\xE3\x83\xA4";
       
   446     wstring utf16 = L"\u0905\u0F20\u30E4";
       
   447 
       
   448     msg << s4 << w4 << utf8 << utf16;
       
   449     string so4, utf8_out;
       
   450     wstring wo4, utf16_out;
       
   451     // read in wrong order string as wstring and wstrings as string
       
   452     msg >> wo4 >> so4 >> utf16_out >> utf8_out;
       
   453 
       
   454     CHECK(0 == so4.compare(s4));
       
   455     CHECK(0 == wo4.compare(w4));
       
   456 
       
   457     CHECK(0 == utf8_out.compare(utf8));
       
   458     CHECK(0 == utf16_out.compare(utf16));
       
   459 
       
   460 }
       
   461 
       
   462 
       
   463 /**
       
   464  * Test hasPermission method
       
   465  * 1: test hasPermission method when used without client
       
   466  */
       
   467 TEST(CommsMessage, hasPermission)
       
   468 {
       
   469     // 1: test hasPermission method
       
   470     CommsMessage msg;
       
   471     CommsMessage msg2 = msg;
       
   472     CommsMessage msg3(msg);
       
   473 
       
   474     CHECK(msg.hasPermission(MANAGE_CERTIFICATES) == false);
       
   475     CHECK(msg2.hasPermission(MANAGE_CERTIFICATES) == false);
       
   476     CHECK(msg3.hasPermission(MANAGE_CERTIFICATES) == false);
       
   477 }
       
   478 
       
   479 
       
   480 /**
       
   481  * Test hasPermission method with all permissions
       
   482  * 1: check trust in client and server side
       
   483  */
       
   484 TEST(CommsMessage, hasPermissionAll)
       
   485 {
       
   486     // 1: check trust in client and server side
       
   487     CommsMessage msg;
       
   488     CommsMessage msg2;
       
   489 
       
   490     CommsServerEndpoint server;
       
   491     CommsClientEndpoint client;
       
   492 
       
   493     PermissionListener listener;
       
   494     listener.comms = &server;
       
   495 
       
   496     CHECK(!server.registerDefaultListener(&listener));
       
   497     CHECK(!server.start(IPC_ADDRESS_COMMS_MODULE_TEST+1));
       
   498     CHECK(!client.connect(IPC_ADDRESS_COMMS_MODULE_TEST+1));
       
   499 
       
   500     CommsPermission permissions = (CommsPermission)((int)MANAGE_CERTIFICATES |
       
   501                                   (int)INSTALL_APPLICATION |
       
   502                                   (int)LAUNCH_APPLICATION |
       
   503                                   (int)STOP_APPLICATION);
       
   504 
       
   505     CHECK(client.sendReceive(msg, msg2, 2) == 0);
       
   506 
       
   507     CHECK(msg2.hasPermission(permissions) == true);
       
   508     CHECK(listener.msg.hasPermission(permissions) == true);
       
   509 
       
   510     CHECK(!client.disconnect());
       
   511     CHECK(!server.stop());
       
   512 }
       
   513 
       
   514 /**
       
   515  * Test hasPermission method with manage certificates permission
       
   516  * 1: check trust in client and server side
       
   517  */
       
   518 TEST(CommsMessage, hasPermissionManageCerts)
       
   519 {
       
   520     // 1: check trust in client and server side
       
   521     CommsMessage msg;
       
   522     CommsMessage msg2;
       
   523 
       
   524     CommsServerEndpoint server;
       
   525     CommsClientEndpoint client;
       
   526 
       
   527     PermissionListener listener;
       
   528     listener.comms = &server;
       
   529 
       
   530     CHECK(!server.registerDefaultListener(&listener));
       
   531     CHECK(!server.start(IPC_ADDRESS_COMMS_MODULE_TEST+1));
       
   532     CHECK(!client.connect(IPC_ADDRESS_COMMS_MODULE_TEST+1));
       
   533 
       
   534     CommsPermission permissions = MANAGE_CERTIFICATES;
       
   535 
       
   536     CHECK(client.sendReceive(msg, msg2, 2) == 0);
       
   537 
       
   538     CHECK(msg2.hasPermission(permissions) == true);
       
   539     CHECK(listener.msg.hasPermission(permissions) == true);
       
   540 
       
   541     CHECK(!client.disconnect());
       
   542     CHECK(!server.stop());
       
   543 }
       
   544 
       
   545 /**
       
   546  * Test hasPermission method with install app permission
       
   547  * 1: check trust in client and server side
       
   548  */
       
   549 TEST(CommsMessage, hasPermissionInstallApp)
       
   550 {
       
   551     // 1: check trust in client and server side
       
   552     CommsMessage msg;
       
   553     CommsMessage msg2;
       
   554 
       
   555     CommsServerEndpoint server;
       
   556     CommsClientEndpoint client;
       
   557 
       
   558     PermissionListener listener;
       
   559     listener.comms = &server;
       
   560 
       
   561     CHECK(!server.registerDefaultListener(&listener));
       
   562     CHECK(!server.start(IPC_ADDRESS_COMMS_MODULE_TEST+1));
       
   563     CHECK(!client.connect(IPC_ADDRESS_COMMS_MODULE_TEST+1));
       
   564 
       
   565     CommsPermission permissions = INSTALL_APPLICATION;
       
   566 
       
   567     CHECK(client.sendReceive(msg, msg2, 2) == 0);
       
   568 
       
   569     CHECK(msg2.hasPermission(permissions) == true);
       
   570     CHECK(listener.msg.hasPermission(permissions) == true);
       
   571 
       
   572     CHECK(!client.disconnect());
       
   573     CHECK(!server.stop());
       
   574 }
       
   575 
       
   576 /**
       
   577  * Test hasPermission method with launch app permission
       
   578  * 1: check trust in client and server side
       
   579  */
       
   580 TEST(CommsMessage, hasPermissionLaunchApp)
       
   581 {
       
   582     // 1: check trust in client and server side
       
   583     CommsMessage msg;
       
   584     CommsMessage msg2;
       
   585 
       
   586     CommsServerEndpoint server;
       
   587     CommsClientEndpoint client;
       
   588 
       
   589     PermissionListener listener;
       
   590     listener.comms = &server;
       
   591 
       
   592     CHECK(!server.registerDefaultListener(&listener));
       
   593     CHECK(!server.start(IPC_ADDRESS_COMMS_MODULE_TEST+1));
       
   594     CHECK(!client.connect(IPC_ADDRESS_COMMS_MODULE_TEST+1));
       
   595 
       
   596     CommsPermission permissions = LAUNCH_APPLICATION;
       
   597 
       
   598     CHECK(client.sendReceive(msg, msg2, 2) == 0);
       
   599 
       
   600     CHECK(msg2.hasPermission(permissions) == true);
       
   601     CHECK(listener.msg.hasPermission(permissions) == true);
       
   602 
       
   603     CHECK(!client.disconnect());
       
   604     CHECK(!server.stop());
       
   605 }
       
   606 
       
   607 /**
       
   608  * Test hasPermission method with stop app permission
       
   609  * 1: check trust in client and server side
       
   610  */
       
   611 TEST(CommsMessage, hasPermissionStopApp)
       
   612 {
       
   613     // 1: check trust in client and server side
       
   614     CommsMessage msg;
       
   615     CommsMessage msg2;
       
   616 
       
   617     CommsServerEndpoint server;
       
   618     CommsClientEndpoint client;
       
   619 
       
   620     PermissionListener listener;
       
   621     listener.comms = &server;
       
   622 
       
   623     CHECK(!server.registerDefaultListener(&listener));
       
   624     CHECK(!server.start(IPC_ADDRESS_COMMS_MODULE_TEST+1));
       
   625     CHECK(!client.connect(IPC_ADDRESS_COMMS_MODULE_TEST+1));
       
   626 
       
   627     CommsPermission permissions = STOP_APPLICATION;
       
   628 
       
   629     CHECK(client.sendReceive(msg, msg2, 2) == 0);
       
   630 
       
   631     CHECK(msg2.hasPermission(permissions) == true);
       
   632     CHECK(listener.msg.hasPermission(permissions) == true);
       
   633 
       
   634     CHECK(!client.disconnect());
       
   635     CHECK(!server.stop());
       
   636 }
       
   637 
       
   638