Merge test folder of test branch
[iotivity.git] / test / src / tc / ca / junit / src / org / iotivity / test / ca / tc / stc / CAClientTest.java
1 /******************************************************************
2 *
3 * Copyright 2016 Samsung Electronics All Rights Reserved.
4 *
5 *
6 *
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 *
19 ******************************************************************/
20
21 package org.iotivity.test.ca.tc.stc;
22
23 import android.content.Context;
24 import junit.framework.TestCase;
25 import org.iotivity.CAJni;
26 import org.iotivity.test.ca.tc.helper.*;
27
28 import android.test.AndroidTestCase;
29
30 import static org.iotivity.test.ca.tc.helper.TestInfo.*;
31
32 public class CAClientTest extends AndroidTestCase {
33
34     public CAClientTest() {
35     }
36
37     protected void setUp() throws Exception {
38         super.setUp();
39         CAJni.readConfig();
40         CAJni.setContext(getContext(), MainActivity.getActivity());
41     }
42
43     protected void tearDown() throws Exception {
44         super.tearDown();
45     }
46
47     /**
48      * @since 2015-09-18
49      * @see CAResult_t CAInitialize()
50      * @see void CARegisterHandler(CARequestCallback ReqHandler,
51      *      CAResponseCallback RespHandler, CAErrorCallback ErrorHandler)
52      * @see CAResult_t CAGenerateToken(CAToken_t *token, uint8_t tokenLength)
53      * @see CAResult_t CACreateEndpoint(CATransportFlags_t flags,
54      *      CATransportAdapter_t adapter, const char *addr, uint16_t port,
55      *      CAEndpoint_t **object)
56      * @see void CADestroyEndpoint(CAEndpoint_t *object)
57      * @see void CADestroyToken(CAToken_t token)
58      * @see CAResult_t CAHandleRequestResponse()
59      * @see void CATerminate()
60      * @objective Check the functionality of CASelectNetwork to receive response
61      *            message when available network is selected
62      * @target CAResult_t CASelectNetwork(const uint32_t interestedNetwork)
63      * @transport bt, ble
64      * @test_data Request Messages Response Messages
65      * @pre_condition 1. [Server] Call CAInitialize to initialize CA 2. [Server]
66      *                Select Network by CASelectNetwork API 3. [Server] Call
67      *                CARegisterHandler to register handler 4. [Server] Call
68      *                CAStartListeningServer to start server 5. [Server] Call
69      *                CAHandleRequestResponse periodically to recieve client
70      *                request 6. [Client] Call CAInitialize to initialize CA 7.
71      *                [Client] Select Network by CASelectNetwork API 8. [Client]
72      *                Call CARegisterHandler to register handler 9. [Client]
73      *                Call CAStartDiscoveryServer 10.[Client] Call
74      *                CAGenerateToken to generate token 11.[Client] Call
75      *                CACreateEndpoint to create endpoint for server
76      * @procedure 1. [Server] Configure the server simulator with a request to
77      *            send back a certain amount of response messages 2. [Client]
78      *            Attempt to receive the requested amount of unicast response
79      *            messages from the server simulator 3. [Client] Check and
80      *            compare the received amount with the requested amount
81      * @post_condition 1. [Client] Destroy token 2. [Client] Destroy endpoint 3.
82      *                 [CLient] Terminate CA
83      * @expected The requested amount of response messages should be received in
84      *           client side
85      */
86
87     public void testLeSelectNetworkForIncomingMessages_P() {
88
89         if (!CAJni.establishConnectionWithServer()) {
90             fail();
91             return;
92         }
93
94         CAJni.setupTestCase(MESSAGE_INCOMING, MESSAGE_PAYLOAD,
95                 MESSAGE_UNICAST);
96
97         if (!CAJni.initClientNetwork()) {
98             fail();
99             return;
100         }
101
102         if (!CAJni.sendConfigurationRequest(SEND_MESSAGE,
103                 MESSAGE_RESPONSE, CA_PUT)) {
104             fail();
105             CAJni.terminate();
106             return;
107         }
108
109         if (!CAJni.checkReceiveCount(TOTAL_MESSAGE)) {
110             fail();
111         }
112
113         CAJni.terminate();
114     }
115
116     /**
117      * @since 2015-09-18
118      * @see CAResult_t CAInitialize()
119      * @see void CARegisterHandler(CARequestCallback ReqHandler,
120      *      CAResponseCallback RespHandler, CAErrorCallback ErrorHandler)
121      * @see CAResult_t CAGenerateToken(CAToken_t *token, uint8_t tokenLength)
122      * @see CAResult_t CACreateEndpoint(CATransportFlags_t flags,
123      *      CATransportAdapter_t adapter, const char *addr, uint16_t port,
124      *      CAEndpoint_t **object)
125      * @see void CADestroyEndpoint(CAEndpoint_t *object)
126      * @see void CADestroyToken(CAToken_t token)
127      * @see CAResult_t CAHandleRequestResponse()
128      * @see void CATerminate()
129      * @objective Check the functionality of CASelectNetwork & CAUnSelectNetwork
130      *            to receive response message when no network is selected
131      * @target CAResult_t CASelectNetwork(CATransportAdapter_t
132      *         interestedNetwork)
133      * @target CAResult_t CAUnSelectNetwork(CATransportAdapter_t
134      *         nonInterestedNetwork)
135      * @transport bt, ble
136      * @test_data Request Messages Response Messages
137      * @pre_condition 1. [Server] Call CAInitialize to initialize CA 2. [Server]
138      *                Select Network by CASelectNetwork API 3. [Server] Call
139      *                CARegisterHandler to register handler 4. [Server] Call
140      *                CAStartListeningServer to start server 5. [Server] Call
141      *                CAHandleRequestResponse periodically to recieve client
142      *                request 6. [Client] Call CAInitialize to initialize CA 7.
143      *                [Client] Select Network by CASelectNetwork API 8. [Client]
144      *                Call CARegisterHandler to register handler 9. [Client]
145      *                Call CAStartDiscoveryServer 10.[Client] Call
146      *                CAGenerateToken to generate token 11.[Client] Call
147      *                CACreateEndpoint to create endpoint for server
148      * @procedure 1. [Server] Configure the server simulator with a request to
149      *            send back a certain amount of response messages 2. [Client]
150      *            UnSelect the network 3. [Client] Attempt to receive the
151      *            requested amount of unicast response messages from the server
152      *            simulator 4. [Client] Check and compare the received amount
153      *            with zero
154      * @post_condition 1. [Client] Destroy token 2. [Client] Destroy endpoint 3.
155      *                 [Client] Terminate CA
156      * @expected The received amount should be zero in client side
157      */
158     public void testLeSelectUnAvailableNetworkForIncomingMessages_N() {
159
160         if (!CAJni.establishConnectionWithServer()) {
161             fail();
162             return;
163         }
164
165         CAJni.setupTestCase(MESSAGE_INCOMING, MESSAGE_PAYLOAD,
166                 MESSAGE_UNICAST);
167
168         if (!CAJni.initClientNetwork()) {
169             fail();
170             return;
171         }
172
173         if (!CAJni.sendConfigurationRequest(SEND_MESSAGE,
174                 MESSAGE_RESPONSE, CA_PUT)) {
175             fail();
176             CAJni.terminate();
177             return;
178         }
179
180         if (!CAJni.unSelectNetwork()) {
181             fail();
182             CAJni.terminate();
183             return;
184         }
185
186         if (CAJni.selectCustomNetwork(INVALID_NETWORK, CA_STATUS_OK)) {
187             fail();
188             CAJni.terminate();
189             return;
190         }
191
192         if (!CAJni.checkReceiveCount(0)) {
193             fail();
194         }
195
196         CAJni.terminate();
197     }
198
199     /**
200      * @since 2015-09-18
201      * @see CAResult_t CAInitialize()
202      * @see void CARegisterHandler(CARequestCallback ReqHandler,
203      *      CAResponseCallback RespHandler, CAErrorCallback ErrorHandler)
204      * @see CAResult_t CAGenerateToken(CAToken_t *token, uint8_t tokenLength)
205      * @see CAResult_t CACreateEndpoint(CATransportFlags_t flags,
206      *      CATransportAdapter_t adapter, const char *addr, uint16_t port,
207      *      CAEndpoint_t **object)
208      * @see CAResult_t CASendRequest(const CAEndpoint_t *object, const
209      *      CARequestInfo_t *requestInfo)
210      * @see void CADestroyEndpoint(CAEndpoint_t *object)
211      * @see void CADestroyToken(CAToken_t token)
212      * @see CAResult_t CAHandleRequestResponse()
213      * @see void CATerminate()
214      * @objective Check the functionality of CASelectNetwork to send message
215      *            when available network is selected
216      * @target CAResult_t CASelectNetwork(const uint32_t interestedNetwork)
217      * @transport bt, ble
218      * @test_data Request Messages Request Messages
219      * @pre_condition 1. [Server] Call CAInitialize to initialize CA 2. [Server]
220      *                Select Network by CASelectNetwork API 3. [Server] Call
221      *                CARegisterHandler to register handler 4. [Server] Call
222      *                CAStartListeningServer to start server 5. [Server] Call
223      *                CAHandleRequestResponse periodically to recieve client
224      *                request 6. [Client] Call CAInitialize to initialize CA 7.
225      *                [Client] Select Network by CASelectNetwork API 8. [Client]
226      *                Call CARegisterHandler to register handler 9. [Client]
227      *                Call CAStartDiscoveryServer 10.[Client] Call
228      *                CAGenerateToken to generate token 11.[Client] Call
229      *                CACreateEndpoint to create endpoint for server
230      * @procedure 1. [Client] Attempt to send a certain amount of request
231      *            messages to the server simulator 2. [Client] Attempt to
232      *            receive acknowledgments for all the sent messages
233      * @post_condition 1. [Client] Destroy token 2. [Client] Destroy endpoint 3.
234      *                 [CLient] Terminate CA
235      * @expected The number of acknowledgments should be equal to the amount of
236      *           sent messages
237      */
238     public void testLeSelectNetworkForOutgoingMessages_P() {
239
240         if (!CAJni.establishConnectionWithServer()) {
241             fail();
242             return;
243         }
244
245
246         CAJni.setupTestCase(MESSAGE_OUTGOING, MESSAGE_PAYLOAD,
247                 MESSAGE_UNICAST);
248
249         if (!CAJni.initClientNetwork()) {
250             fail();
251             return;
252         }
253
254         if (!CAJni.sendRequest(URI_TYPE_NORMAL, PAYLOAD_TYPE_NORMAL,
255                 CA_MSG_NONCONFIRM, CA_PUT, HEADER_NONE, false)) {
256             fail();
257             CAJni.terminate();
258             return;
259         }
260
261         if (!CAJni.checkReceiveCount(TOTAL_MESSAGE)) {
262             fail();
263         }
264
265         CAJni.terminate();
266     }
267
268     /**
269      * @since 2015-09-18
270      * @see CAResult_t CAInitialize()
271      * @see void CARegisterHandler(CARequestCallback ReqHandler,
272      *      CAResponseCallback RespHandler, CAErrorCallback ErrorHandler)
273      * @see CAResult_t CAGenerateToken(CAToken_t *token, uint8_t tokenLength)
274      * @see CAResult_t CACreateEndpoint(CATransportFlags_t flags,
275      *      CATransportAdapter_t adapter, const char *addr, uint16_t port,
276      *      CAEndpoint_t **object)
277      * @see void CADestroyEndpoint(CAEndpoint_t *object)
278      * @see void CADestroyToken(CAToken_t token)
279      * @see CAResult_t CAHandleRequestResponse()
280      * @see void CATerminate()
281      * @objective Test the effect of select/unselect network on incoming unicast
282      *            messages in a loop
283      * @target CAResult_t CASelectNetwork(const uint32_t interestedNetwork)
284      * @target CAResult_t CAUnSelectNetwork(CATransportAdapter_t
285      *         nonInterestedNetwork)
286      * @transport bt, ble
287      * @test_data Request Messages Response Messages
288      * @pre_condition 1. [Server] Call CAInitialize to initialize CA 2. [Server]
289      *                Select Network by CASelectNetwork API 3. [Server] Call
290      *                CARegisterHandler to register handler 4. [Server] Call
291      *                CAStartListeningServer to start server 5. [Server] Call
292      *                CAHandleRequestResponse periodically to recieve client
293      *                request 6. [Client] Call CAInitialize to initialize CA 7.
294      *                [Client] Call CARegisterHandler to register handler 8.
295      *                [Client] Call CAStartDiscoveryServer
296      * @procedure 1. [Client] Select Network by CASelectNetwork API 2. [Client]
297      *            Call CAGenerateToken to generate token 3. [Client] Call
298      *            CACreateEndpoint to create endpoint for server 4. [Server]
299      *            Configure the server simulator with a request to send back a
300      *            certain amount of response messages 5. [Client] Attempt to
301      *            receive the requested amount of unicast response messages from
302      *            the server simulator 6. [Client] Check and compare the
303      *            received amount with the requested amount 7. [Client] Destroy
304      *            token 8. [Client] Destroy endpoint 9. [CLient] Unselect the
305      *            network 10.Repeat procedure 1 to 8 multiple times
306      * @post_condition [CLient] Terminate CA
307      * @expected The requested amount of response messages should be received
308      *           each time in client side
309      */
310     public void testLeSelectNetworkSequentiallyForIncomingMessages_P() {
311
312         if (!CAJni.establishConnectionWithServer()) {
313             fail();
314             return;
315         }
316
317
318         CAJni.setupTestCase(MESSAGE_INCOMING, MESSAGE_PAYLOAD,
319                 MESSAGE_UNICAST);
320
321         if (!CAJni.initClientNetwork()) {
322             fail();
323             return;
324         }
325
326         for (int i = 0; i < TRY_COUNT; i++) {
327             if (i > 0) {
328                 if (!CAJni.selectNetwork()) {
329                     fail();
330                     CAJni.terminate();
331                     return;
332                 }
333             }
334
335             if (!CAJni.sendConfigurationRequest(SEND_MESSAGE,
336                     MESSAGE_RESPONSE, CA_PUT)) {
337                 fail();
338                 CAJni.terminate();
339                 return;
340             }
341
342             if (!CAJni.checkReceiveCount(TOTAL_MESSAGE)) {
343                 fail();
344                 CAJni.terminate();
345                 return;
346             }
347
348             if (!CAJni.unSelectNetwork()) {
349                 fail();
350                 CAJni.terminate();
351                 return;
352             }
353
354         }
355
356         CAJni.terminate();
357
358     }
359
360     /**
361      * @since 2015-09-18
362      * @see CAResult_t CAInitialize()
363      * @see void CATerminate()
364      * @objective Test the effect of selecting network and receving incoming
365      *            unicast messages for multiple times
366      * @target CAResult_t CASelectNetwork(const uint32_t interestedNetwork)
367      * @target CAResult_t CAUnSelectNetwork(CATransportAdapter_t
368      *         nonInterestedNetwork)
369      * @target void CARegisterHandler(CARequestCallback ReqHandler,
370      *         CAResponseCallback RespHandler, CAErrorCallback ErrorHandler)
371      * @target CAResult_t CAGenerateToken(CAToken_t *token, uint8_t tokenLength)
372      * @target CAResult_t CACreateEndpoint(CATransportFlags_t flags,
373      *         CATransportAdapter_t adapter, const char *addr, uint16_t port,
374      *         CAEndpoint_t **object)
375      * @target void CADestroyEndpoint(CAEndpoint_t *object)
376      * @target void CADestroyToken(CAToken_t token)
377      * @target CAResult_t CAHandleRequestResponse()
378      * @transport bt, ble
379      * @test_data Request Messages Response Messages
380      * @pre_condition 1. [Server] Call CAInitialize to initialize CA 2. [Server]
381      *                Select Network by CASelectNetwork API 3. [Server] Call
382      *                CARegisterHandler to register handler 4. [Server] Call
383      *                CAStartListeningServer to start server 5. [Server] Call
384      *                CAHandleRequestResponse periodically to recieve client
385      *                request 6. [Client] Call CAInitialize to initialize CA 7.
386      *                [Client] Call CARegisterHandler to register handler 8.
387      *                [Client] Call CAStartDiscoveryServer
388      * @procedure 1. [Client] Select Network by CASelectNetwork API 2. [Client]
389      *            Call CAGenerateToken to generate token 3. [Client] Call
390      *            CACreateEndpoint to create endpoint for server 4. [Server]
391      *            Configure the server simulator with a request to send back a
392      *            certain amount of response messages 5. [Client] Attempt to
393      *            receive the requested amount of unicast response messages from
394      *            the server simulator 6. [Client] Check and compare the
395      *            received amount with the requested amount 7. [Client] Destroy
396      *            token 8. [Client] Destroy endpoint 9. Repeat procedure 1 to 8
397      *            multiple times
398      * @post_condition [CLient] Terminate CA
399      * @expected The requested amount of response messages should be received
400      *           each time in client side
401      */
402     public void testLeSelectNetworkMultipleTimesForIncomingMessages_P() {
403
404         if (!CAJni.establishConnectionWithServer()) {
405             fail();
406             return;
407         }
408
409
410         CAJni.setupTestCase(MESSAGE_INCOMING, MESSAGE_PAYLOAD,
411                 MESSAGE_UNICAST);
412
413         if (!CAJni.initClientNetwork()) {
414             fail();
415             return;
416         }
417
418         for (int i = 0; i < TRY_COUNT; i++) {
419             if (!CAJni.selectNetwork()) {
420                 fail();
421                 CAJni.terminate();
422                 return;
423             }
424
425             if (!CAJni.sendConfigurationRequest(SEND_MESSAGE,
426                     MESSAGE_RESPONSE, CA_PUT)) {
427                 fail();
428                 CAJni.terminate();
429                 return;
430             }
431
432             if (!CAJni.checkReceiveCount(TOTAL_MESSAGE)) {
433                 fail();
434                 CAJni.terminate();
435                 return;
436             }
437         }
438
439         CAJni.terminate();
440     }
441
442     /**
443      * @since 2015-09-18
444      * @see CAResult_t CAInitialize()
445      * @see void CARegisterHandler(CARequestCallback ReqHandler,
446      *      CAResponseCallback RespHandler, CAErrorCallback ErrorHandler)
447      * @see CAResult_t CAGenerateToken(CAToken_t *token, uint8_t tokenLength)
448      * @see CAResult_t CACreateEndpoint(CATransportFlags_t flags,
449      *      CATransportAdapter_t adapter, const char *addr, uint16_t port,
450      *      CAEndpoint_t **object)
451      * @see CAResult_t CASelectNetwork(const uint32_t interestedNetwork)
452      * @see void CADestroyEndpoint(CAEndpoint_t *object)
453      * @see void CADestroyToken(CAToken_t token)
454      * @see CAResult_t CAHandleRequestResponse()
455      * @see void CATerminate()
456      * @objective Test unicast message sending functionality by sending out
457      *            request messages
458      * @target CAResult_t CASendRequest(const CAEndpoint_t *object, const
459      *         CARequestInfo_t *requestInfo)
460      * @transport bt, ble
461      * @test_data Request Messages Request Messages
462      * @pre_condition 1. [Server] Call CAInitialize to initialize CA 2. [Server]
463      *                Select Network by CASelectNetwork API 3. [Server] Call
464      *                CARegisterHandler to register handler 4. [Server] Call
465      *                CAStartListeningServer to start server 5. [Server] Call
466      *                CAHandleRequestResponse periodically to recieve client
467      *                request 6. [Client] Call CAInitialize to initialize CA 7.
468      *                [Client] Select Network by CASelectNetwork API 8. [Client]
469      *                Call CARegisterHandler to register handler 9. [Client]
470      *                Call CAStartDiscoveryServer 10.[Client] Call
471      *                CAGenerateToken to generate token 11.[Client] Call
472      *                CACreateEndpoint to create endpoint for server
473      * @procedure 1. [Client] Attempt to send a certain amount of request
474      *            messages to the server simulator using no header option 2.
475      *            [Client] Attempt to receive acknowledgments for all the sent
476      *            messages 3. [Client] Check and compare the amount of received
477      *            acknowledgments with the amount of sent messages
478      * @post_condition 1. [Client] Destroy token 2. [Client] Destroy endpoint 3.
479      *                 [CLient] Terminate CA
480      * @expected The number of acknowledgments should be equal to the amount of
481      *           sent messages and received header options should be same NULL
482      */
483     public void testLeSendRequest_P() {
484
485         if (!CAJni.establishConnectionWithServer()) {
486             fail();
487             return;
488         }
489
490         for (int i = 0; i < TRY_COUNT; i++) {
491
492             CAJni.setupTestCase(MESSAGE_OUTGOING, MESSAGE_PAYLOAD,
493                     MESSAGE_UNICAST);
494
495             CAJni
496                     .setContext(getContext(), MainActivity.getActivity());
497
498             if (!CAJni.initClientNetwork()) {
499                 fail();
500                 return;
501             }
502
503             if (!CAJni.sendRequest(URI_TYPE_NORMAL,
504                     PAYLOAD_TYPE_NORMAL, CA_MSG_NONCONFIRM, CA_PUT,
505                     HEADER_NONE, false)) {
506                 fail();
507                 CAJni.terminate();
508                 return;
509             }
510
511             if (!CAJni.checkReceiveCount(TOTAL_MESSAGE)) {
512                 fail();
513             }
514
515             CAJni.terminate();
516         }
517     }
518
519     /**
520      * @since 2015-09-18
521      * @see CAResult_t CAInitialize()
522      * @see void CARegisterHandler(CARequestCallback ReqHandler,
523      *      CAResponseCallback RespHandler, CAErrorCallback ErrorHandler)
524      * @see CAResult_t CAGenerateToken(CAToken_t *token, uint8_t tokenLength)
525      * @see CAResult_t CACreateEndpoint(CATransportFlags_t flags,
526      *      CATransportAdapter_t adapter, const char *addr, uint16_t port,
527      *      CAEndpoint_t **object)
528      * @see CAResult_t CASelectNetwork(const uint32_t interestedNetwork)
529      * @see void CADestroyEndpoint(CAEndpoint_t *object)
530      * @see void CADestroyToken(CAToken_t token)
531      * @see CAResult_t CAHandleRequestResponse()
532      * @see void CATerminate()
533      * @objective Test unicast message sending functionality by sending out
534      *            request messages without header option
535      * @target CAResult_t CASendRequest(const CAEndpoint_t *object, const
536      *         CARequestInfo_t *requestInfo)
537      * @transport bt, ble
538      * @test_data Request Messages Request Messages
539      * @pre_condition 1. [Server] Call CAInitialize to initialize CA 2. [Server]
540      *                Select Network by CASelectNetwork API 3. [Server] Call
541      *                CARegisterHandler to register handler 4. [Server] Call
542      *                CAStartListeningServer to start server 5. [Server] Call
543      *                CAHandleRequestResponse periodically to recieve client
544      *                request 6. [Client] Call CAInitialize to initialize CA 7.
545      *                [Client] Select Network by CASelectNetwork API 8. [Client]
546      *                Call CARegisterHandler to register handler 9. [Client]
547      *                Call CAStartDiscoveryServer 10.[Client] Call
548      *                CAGenerateToken to generate token 11.[Client] Call
549      *                CACreateEndpoint to create endpoint for server
550      * @procedure 1. [Client] Attempt to send a certain amount of request
551      *            messages to the server simulator using no header option 2.
552      *            [Client] Attempt to receive acknowledgments for all the sent
553      *            messages 3. [Client] Check and compare the amount of received
554      *            acknowledgments with the amount of sent messages
555      * @post_condition 1. [Client] Destroy token 2. [Client] Destroy endpoint 3.
556      *                 [CLient] Terminate CA
557      * @expected The number of acknowledgments should be equal to the amount of
558      *           sent messages and received header options should be same NULL
559      */
560     public void testLeSendRequestWithoutHeaderOption_P() {
561
562         if (!CAJni.establishConnectionWithServer()) {
563             fail();
564             return;
565         }
566
567
568         CAJni.setupTestCase(MESSAGE_OUTGOING, MESSAGE_HEADER,
569                 MESSAGE_UNICAST);
570
571         if (!CAJni.initClientNetwork()) {
572             fail();
573             return;
574         }
575
576         if (!CAJni.sendRequest(URI_TYPE_NORMAL, PAYLOAD_TYPE_NORMAL,
577                 CA_MSG_NONCONFIRM, CA_PUT, HEADER_NONE, false)) {
578             fail();
579             CAJni.terminate();
580             return;
581         }
582
583         if (!CAJni.checkReceiveCount(TOTAL_MESSAGE)) {
584             fail();
585         }
586
587         CAJni.terminate();
588     }
589
590     /**
591      * @since 2015-09-18
592      * @see CAResult_t CAInitialize()
593      * @see void CARegisterHandler(CARequestCallback ReqHandler,
594      *      CAResponseCallback RespHandler, CAErrorCallback ErrorHandler)
595      * @see CAResult_t CAGenerateToken(CAToken_t *token, uint8_t tokenLength)
596      * @see CAResult_t CACreateEndpoint(CATransportFlags_t flags,
597      *      CATransportAdapter_t adapter, const char *addr, uint16_t port,
598      *      CAEndpoint_t **object)
599      * @see CAResult_t CASelectNetwork(const uint32_t interestedNetwork)
600      * @see void CADestroyEndpoint(CAEndpoint_t *object)
601      * @see void CADestroyToken(CAToken_t token)
602      * @see CAResult_t CAHandleRequestResponse()
603      * @see void CATerminate()
604      * @objective Test unicast message sending functionality by sending out
605      *            request messages with header option
606      * @target CAResult_t CASendRequest(const CAEndpoint_t *object, const
607      *         CARequestInfo_t *requestInfo)
608      * @transport bt, ble
609      * @test_data Request Messages Request Messages
610      * @pre_condition 1. [Server] Call CAInitialize to initialize CA 2. [Server]
611      *                Select Network by CASelectNetwork API 3. [Server] Call
612      *                CARegisterHandler to register handler 4. [Server] Call
613      *                CAStartListeningServer to start server 5. [Server] Call
614      *                CAHandleRequestResponse periodically to recieve client
615      *                request 6. [Client] Call CAInitialize to initialize CA 7.
616      *                [Client] Select Network by CASelectNetwork API 8. [Client]
617      *                Call CARegisterHandler to register handler 9. [Client]
618      *                Call CAStartDiscoveryServer 10.[Client] Call
619      *                CAGenerateToken to generate token 11.[Client] Call
620      *                CACreateEndpoint to create endpoint for server
621      * @procedure 1. [Client] Attempt to send a certain amount of request
622      *            messages to the server simulator using header option 2.
623      *            [Client] Attempt to receive acknowledgments for all the sent
624      *            messages 3. [Client] Check and compare the amount of received
625      *            acknowledgments with the amount of sent messages
626      * @post_condition 1. [Client] Destroy token 2. [Client] Destroy endpoint 3.
627      *                 [CLient] Terminate CA
628      * @expected The number of acknowledgments should be equal to the amount of
629      *           sent messages and received header option should be same as send
630      *           header option
631      */
632     public void testLeSendRequestWithHeaderOption_P() {
633
634         if (!CAJni.establishConnectionWithServer()) {
635             fail();
636             return;
637         }
638
639
640         CAJni.setupTestCase(MESSAGE_OUTGOING, MESSAGE_HEADER,
641                 MESSAGE_UNICAST);
642
643         if (!CAJni.initClientNetwork()) {
644             fail();
645             return;
646         }
647
648         if (!CAJni.sendRequest(URI_TYPE_NORMAL, PAYLOAD_TYPE_NORMAL,
649                 CA_MSG_NONCONFIRM, CA_PUT, HEADER_ONE, false)) {
650             fail();
651             CAJni.terminate();
652             return;
653         }
654
655         if (!CAJni.checkReceiveCount(TOTAL_MESSAGE)) {
656             fail();
657         }
658
659         CAJni.terminate();
660     }
661
662     /**
663      * @since 2015-09-18
664      * @see CAResult_t CAInitialize()
665      * @see void CARegisterHandler(CARequestCallback ReqHandler,
666      *      CAResponseCallback RespHandler, CAErrorCallback ErrorHandler)
667      * @see CAResult_t CAGenerateToken(CAToken_t *token, uint8_t tokenLength)
668      * @see CAResult_t CACreateEndpoint(CATransportFlags_t flags,
669      *      CATransportAdapter_t adapter, const char *addr, uint16_t port,
670      *      CAEndpoint_t **object)
671      * @see CAResult_t CASelectNetwork(const uint32_t interestedNetwork)
672      * @see void CADestroyEndpoint(CAEndpoint_t *object)
673      * @see void CADestroyToken(CAToken_t token)
674      * @see CAResult_t CAHandleRequestResponse()
675      * @see void CATerminate()
676      * @objective Test unicast message sending functionality by sending out
677      *            request messages with header options
678      * @target CAResult_t CASendRequest(const CAEndpoint_t *object, const
679      *         CARequestInfo_t *requestInfo)
680      * @transport bt, ble
681      * @test_data Request Messages Request Messages
682      * @pre_condition 1. [Server] Call CAInitialize to initialize CA 2. [Server]
683      *                Select Network by CASelectNetwork API 3. [Server] Call
684      *                CARegisterHandler to register handler 4. [Server] Call
685      *                CAStartListeningServer to start server 5. [Server] Call
686      *                CAHandleRequestResponse periodically to recieve client
687      *                request 6. [Client] Call CAInitialize to initialize CA 7.
688      *                [Client] Select Network by CASelectNetwork API 8. [Client]
689      *                Call CARegisterHandler to register handler 9. [Client]
690      *                Call CAStartDiscoveryServer 10.[Client] Call
691      *                CAGenerateToken to generate token 11.[Client] Call
692      *                CACreateEndpoint to create endpoint for server
693      * @procedure 1. [Client] Attempt to send a certain amount of request
694      *            messages to the server simulator using header options 2.
695      *            [Client] Attempt to receive acknowledgments for all the sent
696      *            messages 3. [Client] Check and compare the amount of received
697      *            acknowledgments with the amount of sent messages
698      * @post_condition 1. [Client] Destroy token 2. [Client] Destroy endpoint 3.
699      *                 [CLient] Terminate CA
700      * @expected The number of acknowledgments should be equal to the amount of
701      *           sent messages and received header option should be same as send
702      *           header options
703      */
704     public void testLeSendRequestWithHeaderOptions_P() {
705
706         if (!CAJni.establishConnectionWithServer()) {
707             fail();
708             return;
709         }
710
711
712         CAJni.setupTestCase(MESSAGE_OUTGOING, MESSAGE_HEADER,
713                 MESSAGE_UNICAST);
714
715         if (!CAJni.initClientNetwork()) {
716             fail();
717             return;
718         }
719
720         if (!CAJni.sendRequest(URI_TYPE_NORMAL, PAYLOAD_TYPE_NORMAL,
721                 CA_MSG_NONCONFIRM, CA_PUT, HEADER_TWO, false)) {
722             fail();
723             CAJni.terminate();
724             return;
725         }
726
727         if (!CAJni.checkReceiveCount(TOTAL_MESSAGE)) {
728             fail();
729         }
730
731         CAJni.terminate();
732     }
733
734     /**
735      * @since 2014-12-24
736      * @see CAResult_t CAInitialize()
737      * @see CAResult_t CAInitialize()
738      * @see void CARegisterHandler(CARequestCallback ReqHandler,
739      *      CAResponseCallback RespHandler, CAErrorCallback ErrorHandler)
740      * @see CAResult_t CAGenerateToken(CAToken_t *token, uint8_t tokenLength)
741      * @see CAResult_t CACreateEndpoint(CATransportFlags_t flags,
742      *      CATransportAdapter_t adapter, const char *addr, uint16_t port,
743      *      CAEndpoint_t **object)
744      * @see CAResult_t CASelectNetwork(const uint32_t interestedNetwork)
745      * @see void CADestroyEndpoint(CAEndpoint_t *object)
746      * @see void CADestroyToken(CAToken_t token)
747      * @see CAResult_t CAHandleRequestResponse()
748      * @see void CATerminate()
749      * @objective Test unicast message sending functionality by sending out
750      *            request messages with empty payloads
751      * @target CAResult_t CASendRequest(const CAEndpoint_t *object, const
752      *         CARequestInfo_t *requestInfo)
753      * @transport bt, ble
754      * @test_data Request Messages Empty Payloads
755      * @pre_condition 1. [Server] Call CAInitialize to initialize CA 2. [Server]
756      *                Select Network by CASelectNetwork API 3. [Server] Call
757      *                CARegisterHandler to register handler 4. [Server] Call
758      *                CAStartListeningServer to start server 5. [Server] Call
759      *                CAHandleRequestResponse periodically to recieve client
760      *                request 6. [Client] Call CAInitialize to initialize CA 7.
761      *                [Client] Select Network by CASelectNetwork API 8. [Client]
762      *                Call CARegisterHandler to register handler 9. [Client]
763      *                Call CAStartDiscoveryServer 10.[Client] Call
764      *                CAGenerateToken to generate token 11.[Client] Call
765      *                CACreateEndpoint to create endpoint for server
766      * @procedure 1. [Client] Keep the payload empty while forming the
767      *            CARequestInfo_t 2. [Client] Attempt to send a certain amount
768      *            of request messages to the server simulator using header
769      *            options 3. [Client] Attempt to receive acknowledgments for all
770      *            the sent messages 4. [Client] Check and compare the amount of
771      *            received acknowledgments with the amount of sent messages
772      * @post_condition 1. [Client] Destroy token 2. [Client] Destroy endpoint 3.
773      *                 [CLient] Terminate CA
774      * @expected The number of acknowledgments should be equal to the amount of
775      *           sent messages
776      */
777     public void testLeSendRequestWithEmptyPayload_P() {
778
779         if (!CAJni.establishConnectionWithServer()) {
780             fail();
781             return;
782         }
783
784
785         CAJni.setupTestCase(MESSAGE_OUTGOING, MESSAGE_URI,
786                 MESSAGE_UNICAST);
787
788         if (!CAJni.initClientNetwork()) {
789             fail();
790             return;
791         }
792
793         if (!CAJni.sendRequest(URI_TYPE_NORMAL, PAYLOAD_TYPE_EMPTY,
794                 CA_MSG_NONCONFIRM, CA_PUT, HEADER_NONE, false)) {
795             fail();
796             CAJni.terminate();
797             return;
798         }
799
800         if (!CAJni.checkReceiveCount(TOTAL_MESSAGE)) {
801             fail();
802         }
803
804         CAJni.terminate();
805     }
806
807     /**
808      * @since 2015-09-18
809      * @see CAResult_t CAInitialize()
810      * @see void CARegisterHandler(CARequestCallback ReqHandler,
811      *      CAResponseCallback RespHandler, CAErrorCallback ErrorHandler)
812      * @see CAResult_t CAGenerateToken(CAToken_t *token, uint8_t tokenLength)
813      * @see CAResult_t CACreateEndpoint(CATransportFlags_t flags,
814      *      CATransportAdapter_t adapter, const char *addr, uint16_t port,
815      *      CAEndpoint_t **object)
816      * @see CAResult_t CASelectNetwork(const uint32_t interestedNetwork)
817      * @see void CADestroyEndpoint(CAEndpoint_t *object)
818      * @see void CADestroyToken(CAToken_t token)
819      * @see CAResult_t CAHandleRequestResponse()
820      * @see void CATerminate()
821      * @objective Test unicast message sending functionality by sending out
822      *            request messages with null payloads
823      * @target CAResult_t CASendRequest(const CAEndpoint_t *object, const
824      *         CARequestInfo_t *requestInfo)
825      * @transport bt, ble
826      * @test_data Request Messages NULL Payloads
827      * @pre_condition 1. [Server] Call CAInitialize to initialize CA 2. [Server]
828      *                Select Network by CASelectNetwork API 3. [Server] Call
829      *                CARegisterHandler to register handler 4. [Server] Call
830      *                CAStartListeningServer to start server 5. [Server] Call
831      *                CAHandleRequestResponse periodically to recieve client
832      *                request 6. [Client] Call CAInitialize to initialize CA 7.
833      *                [Client] Select Network by CASelectNetwork API 8. [Client]
834      *                Call CARegisterHandler to register handler 9. [Client]
835      *                Call CAStartDiscoveryServer 10.[Client] Call
836      *                CAGenerateToken to generate token 11.[Client] Call
837      *                CACreateEndpoint to create endpoint for server
838      * @procedure 1. [Client] Keep the payload null while forming the
839      *            CARequestInfo_t 2. [Client] Attempt to send a certain amount
840      *            of request messages to the server simulator using header
841      *            options 3. [Client] Attempt to receive acknowledgments for all
842      *            the sent messages 4. [Client] Check and compare the amount of
843      *            received acknowledgments with the amount of sent messages
844      * @post_condition 1. [Client] Destroy token 2. [Client] Destroy endpoint 3.
845      *                 [CLient] Terminate CA
846      * @expected The number of acknowledgments should be equal to the amount of
847      *           sent messages
848      */
849     public void testLeSendRequestWithNullPayload_P() {
850
851         if (!CAJni.establishConnectionWithServer()) {
852             fail();
853             return;
854         }
855
856
857         CAJni.setupTestCase(MESSAGE_OUTGOING, MESSAGE_URI,
858                 MESSAGE_UNICAST);
859
860         if (!CAJni.initClientNetwork()) {
861             fail();
862             return;
863         }
864
865         if (!CAJni.sendRequest(URI_TYPE_NORMAL, PAYLOAD_TYPE_NULL,
866                 CA_MSG_NONCONFIRM, CA_PUT, HEADER_NONE, false)) {
867             fail();
868             CAJni.terminate();
869             return;
870         }
871
872         if (!CAJni.checkReceiveCount(TOTAL_MESSAGE)) {
873             fail();
874         }
875
876         CAJni.terminate();
877     }
878
879     /**
880      * @since 2015-09-18
881      * @see CAResult_t CAInitialize()
882      * @see void CARegisterHandler(CARequestCallback ReqHandler,
883      *      CAResponseCallback RespHandler, CAErrorCallback ErrorHandler)
884      * @see CAResult_t CAGenerateToken(CAToken_t *token, uint8_t tokenLength)
885      * @see CAResult_t CACreateEndpoint(CATransportFlags_t flags,
886      *      CATransportAdapter_t adapter, const char *addr, uint16_t port,
887      *      CAEndpoint_t **object)
888      * @see CAResult_t CASelectNetwork(const uint32_t interestedNetwork)
889      * @see void CADestroyEndpoint(CAEndpoint_t *object)
890      * @see void CADestroyToken(CAToken_t token)
891      * @see CAResult_t CAHandleRequestResponse()
892      * @see void CATerminate()
893      * @objective Test unicast message retransmission functionality using
894      *            message type CA_MSG_CONFIRM
895      * @target CAResult_t CASendRequest(const CAEndpoint_t *object, const
896      *         CARequestInfo_t *requestInfo)
897      * @transport bt, ble
898      * @test_data Request Messages Request message of type CA_MSG_CONFIRM
899      * @pre_condition 1. [Server] Call CAInitialize to initialize CA 2. [Server]
900      *                Select Network by CASelectNetwork API 3. [Server] Call
901      *                CARegisterHandler to register handler 4. [Server] Call
902      *                CAStartListeningServer to start server 5. [Server] Call
903      *                CAHandleRequestResponse periodically to recieve client
904      *                request 6. [Client] Call CAInitialize to initialize CA 7.
905      *                [Client] Select Network by CASelectNetwork API 8. [Client]
906      *                Call CARegisterHandler to register handler 9. [Client]
907      *                Call CAStartDiscoveryServer 10.[Client] Call
908      *                CAGenerateToken to generate token 11.[Client] Call
909      *                CACreateEndpoint to create endpoint for server
910      * @procedure 1. [Client] Set CAMessageType_t as CA_MSG_CONFIRM while
911      *            forming CAInfo_t 2. [Client] Attempt to send 1 request, the
912      *            server simulator will ignore it 3. [Client] Auto
913      *            retransmission should occur 4. [Server] The server simulator
914      *            is expected to respond to it with type CA_MSG_ACKNOWLEDGE 5.
915      *            [Client] Attempt to receive the acknowledgement from server
916      * @post_condition 1. [Client] Destroy token 2. [Client] Destroy endpoint 3.
917      *                 [CLient] Terminate CA
918      * @expected The request message should be acknowledged
919      */
920     public void testLeSendRequestWithMessageTypeConfirm_P() {
921
922         if (!CAJni.establishConnectionWithServer()) {
923             fail();
924             return;
925         }
926
927
928         CAJni.setupTestCase(MESSAGE_OUTGOING, MESSAGE_PAYLOAD,
929                 MESSAGE_UNICAST);
930
931         if (!CAJni.initClientNetwork()) {
932             fail();
933             return;
934         }
935
936         if (!CAJni.sendRequest(URI_TYPE_NORMAL, PAYLOAD_TYPE_NORMAL,
937                 CA_MSG_CONFIRM, CA_PUT, HEADER_NONE, false)) {
938             fail();
939             CAJni.terminate();
940             return;
941         }
942
943         if (!CAJni.checkReceiveCount(1)) {
944             fail();
945         }
946
947         CAJni.terminate();
948     }
949
950     /**
951      * @since 2015-09-18
952      * @see CAResult_t CAInitialize()
953      * @see void CARegisterHandler(CARequestCallback ReqHandler,
954      *      CAResponseCallback RespHandler, CAErrorCallback ErrorHandler)
955      * @see CAResult_t CAGenerateToken(CAToken_t *token, uint8_t tokenLength)
956      * @see CAResult_t CACreateEndpoint(CATransportFlags_t flags,
957      *      CATransportAdapter_t adapter, const char *addr, uint16_t port,
958      *      CAEndpoint_t **object)
959      * @see CAResult_t CASelectNetwork(const uint32_t interestedNetwork)
960      * @see void CADestroyEndpoint(CAEndpoint_t *object)
961      * @see void CADestroyToken(CAToken_t token)
962      * @see CAResult_t CAHandleRequestResponse()
963      * @see void CATerminate()
964      * @objective Test unicast message sending functionality using wrong
965      *            endpoint
966      * @target CAResult_t CASendRequest(const CAEndpoint_t *object, const
967      *         CARequestInfo_t *requestInfo)
968      * @transport bt, ble
969      * @test_data Request Messages Wrong endpoint URI
970      * @pre_condition 1. [Server] Call CAInitialize to initialize CA 2. [Server]
971      *                Select Network by CASelectNetwork API 3. [Server] Call
972      *                CARegisterHandler to register handler 4. [Server] Call
973      *                CAStartListeningServer to start server 5. [Server] Call
974      *                CAHandleRequestResponse periodically to recieve client
975      *                request 6. [Client] Call CAInitialize to initialize CA 7.
976      *                [Client] Select Network by CASelectNetwork API 8. [Client]
977      *                Call CARegisterHandler to register handler 9. [Client]
978      *                Call CAStartDiscoveryServer 10.[Client] Call
979      *                CAGenerateToken to generate token 11.[Client] Call
980      *                CACreateEndpoint to create endpoint from a wrong URI which
981      *                does not belong to the server
982      * @procedure 1. [Client] Attempt to send a certain amount of request
983      *            messages to the server 2. [Client] Attempt to receive
984      *            acknowledgments for all the sent messages 3. [Client] Check
985      *            and compare the amount of received acknowledgments with zero
986      * @post_condition 1. [Client] Destroy token 2. [Client] Destroy endpoint 3.
987      *                 [CLient] Terminate CA
988      * @expected The received amount should be zero
989      */
990     public void testLeSendRequestWithWrongEndpoint_N() {
991
992         if (!CAJni.establishConnectionWithServer()) {
993             fail();
994             return;
995         }
996
997         CAJni.setupTestCase(MESSAGE_OUTGOING, MESSAGE_PAYLOAD,
998                 MESSAGE_UNICAST);
999
1000         if (!CAJni.initClientNetwork()) {
1001             fail();
1002             return;
1003         }
1004
1005         if (!CAJni.sendRequest(URI_TYPE_ARBITRARY_ENDPOINT,
1006                 PAYLOAD_TYPE_NORMAL, CA_MSG_NONCONFIRM, CA_PUT, HEADER_NONE,
1007                 false)) {
1008             fail();
1009             CAJni.terminate();
1010             return;
1011         }
1012
1013         if (!CAJni.checkReceiveCount(0)) {
1014             fail();
1015         }
1016
1017         CAJni.terminate();
1018     }
1019
1020     /**
1021      * @since 2015-09-18
1022      * @see CAResult_t CAInitialize()
1023      * @see void CARegisterHandler(CARequestCallback ReqHandler,
1024      *      CAResponseCallback RespHandler, CAErrorCallback ErrorHandler)
1025      * @see CAResult_t CAGenerateToken(CAToken_t *token, uint8_t tokenLength)
1026      * @see CAResult_t CACreateEndpoint(CATransportFlags_t flags,
1027      *      CATransportAdapter_t adapter, const char *addr, uint16_t port,
1028      *      CAEndpoint_t **object)
1029      * @see CAResult_t CASelectNetwork(const uint32_t interestedNetwork)
1030      * @see void CADestroyEndpoint(CAEndpoint_t *object)
1031      * @see void CADestroyToken(CAToken_t token)
1032      * @see CAResult_t CAHandleRequestResponse()
1033      * @see void CATerminate()
1034      * @objective Test unicast message retransmission functionality using
1035      *            invalid method
1036      * @target CAResult_t CASendRequest(const CAEndpoint_t *object, const
1037      *         CARequestInfo_t *requestInfo)
1038      * @transport bt, ble
1039      * @test_data Request Messages Request message of invalid method
1040      * @pre_condition 1. [Server] Call CAInitialize to initialize CA 2. [Server]
1041      *                Select Network by CASelectNetwork API 3. [Server] Call
1042      *                CARegisterHandler to register handler 4. [Server] Call
1043      *                CAStartListeningServer to start server 5. [Server] Call
1044      *                CAHandleRequestResponse periodically to recieve client
1045      *                request 6. [Client] Call CAInitialize to initialize CA 7.
1046      *                [Client] Select Network by CASelectNetwork API 8. [Client]
1047      *                Call CARegisterHandler to register handler 9. [Client]
1048      *                Call CAStartDiscoveryServer 10.[Client] Call
1049      *                CAGenerateToken to generate token 11.[Client] Call
1050      *                CACreateEndpoint to create endpoint for server
1051      * @procedure 1. [Client] Set meythodas CA_INVALID while forming CAInfo_t 2.
1052      *            [Client] Attempt to send 1 request, the server simulator will
1053      *            ignore it 3. [Client] Auto retransmission should occur 4.
1054      *            [Server] The server simulator is expected to respond to it
1055      *            with type CA_MSG_ACKNOWLEDGE 5. [Client] Attempt to receive
1056      *            the acknowledgement from server
1057      * @post_condition 1. [Client] Destroy token 2. [Client] Destroy endpoint 3.
1058      *                 [CLient] Terminate CA
1059      * @expected The request message should be acknowledged
1060      */
1061     public void testLeSendRequestWithInvalidMethod_N() {
1062
1063         if (!CAJni.establishConnectionWithServer()) {
1064             fail();
1065             return;
1066         }
1067
1068
1069         CAJni.setupTestCase(MESSAGE_OUTGOING, MESSAGE_PAYLOAD,
1070                 MESSAGE_UNICAST);
1071
1072         if (!CAJni.initClientNetwork()) {
1073             fail();
1074             return;
1075         }
1076
1077         if (!CAJni.sendRequest(URI_TYPE_NORMAL, PAYLOAD_TYPE_NORMAL,
1078                 CA_MSG_NONCONFIRM, CA_INVALID, HEADER_NONE, false)) {
1079             fail();
1080             CAJni.terminate();
1081             return;
1082         }
1083
1084         if (!CAJni.checkReceiveCount(0)) {
1085             fail();
1086         }
1087
1088         CAJni.terminate();
1089     }
1090
1091     /**
1092      * @since 2015-09-18
1093      * @see CAResult_t CAInitialize()
1094      * @see void CARegisterHandler(CARequestCallback ReqHandler,
1095      *      CAResponseCallback RespHandler, CAErrorCallback ErrorHandler)
1096      * @see CAResult_t CAGenerateToken(CAToken_t *token, uint8_t tokenLength)
1097      * @see CAResult_t CACreateEndpoint(CATransportFlags_t flags,
1098      *      CATransportAdapter_t adapter, const char *addr, uint16_t port,
1099      *      CAEndpoint_t **object)
1100      * @see CAResult_t CASelectNetwork(const uint32_t interestedNetwork)
1101      * @see void CADestroyEndpoint(CAEndpoint_t *object)
1102      * @see void CADestroyToken(CAToken_t token)
1103      * @see CAResult_t CAHandleRequestResponse()
1104      * @see void CATerminate()
1105      * @objective Test unicast message sending functionality by sending out GET
1106      *            request messages
1107      * @target CAResult_t CASendRequest(const CAEndpoint_t *object, const
1108      *         CARequestInfo_t *requestInfo)
1109      * @transport bt, ble
1110      * @test_data Request Messages Request messages with method GET
1111      * @pre_condition 1. [Server] Call CAInitialize to initialize CA 2. [Server]
1112      *                Select Network by CASelectNetwork API 3. [Server] Call
1113      *                CARegisterHandler to register handler 4. [Server] Call
1114      *                CAStartListeningServer to start server 5. [Server] Call
1115      *                CAHandleRequestResponse periodically to recieve client
1116      *                request 6. [Client] Call CAInitialize to initialize CA 7.
1117      *                [Client] Select Network by CASelectNetwork API 8. [Client]
1118      *                Call CARegisterHandler to register handler 9. [Client]
1119      *                Call CAStartDiscoveryServer 10.[Client] Call
1120      *                CAGenerateToken to generate token 11.[Client] Call
1121      *                CACreateEndpoint to create endpoint for server
1122      * @procedure 1. [Client] Set CA_GET for CAMethod_t while forming
1123      *            CARequestInfo_t 2. [Client] Attempt to send a certain amount
1124      *            of request messages to the server 3. [Client] Attempt to
1125      *            receive acknowledgments for all the sent messages 4. [Client]
1126      *            Check and compare the amount of received acknowledgments with
1127      *            the amount of sent messages
1128      * @post_condition 1. [Client] Destroy token 2. [Client] Destroy endpoint 3.
1129      *                 [CLient] Terminate CA
1130      * @expected The number of acknowledgments should be equal to the amount of
1131      *           sent messages
1132      */
1133     public void testLeSendGetRequest_P() {
1134
1135         if (!CAJni.establishConnectionWithServer()) {
1136             fail();
1137             return;
1138         }
1139
1140         CAJni.setupTestCase(MESSAGE_OUTGOING, MESSAGE_PAYLOAD,
1141                 MESSAGE_UNICAST);
1142
1143         if (!CAJni.initClientNetwork()) {
1144             fail();
1145             return;
1146         }
1147
1148         if (!CAJni.sendRequest(URI_TYPE_NORMAL, PAYLOAD_TYPE_NORMAL,
1149                 CA_MSG_NONCONFIRM, CA_GET, HEADER_NONE, false)) {
1150             fail();
1151             CAJni.terminate();
1152             return;
1153         }
1154
1155         if (!CAJni.checkReceiveCount(TOTAL_MESSAGE)) {
1156             fail();
1157         }
1158
1159         CAJni.terminate();
1160     }
1161
1162     /**
1163      * @since 2015-09-18
1164      * @see CAResult_t CAInitialize()
1165      * @see void CARegisterHandler(CARequestCallback ReqHandler,
1166      *      CAResponseCallback RespHandler, CAErrorCallback ErrorHandler)
1167      * @see CAResult_t CAGenerateToken(CAToken_t *token, uint8_t tokenLength)
1168      * @see CAResult_t CACreateEndpoint(CATransportFlags_t flags,
1169      *      CATransportAdapter_t adapter, const char *addr, uint16_t port,
1170      *      CAEndpoint_t **object)
1171      * @see CAResult_t CASelectNetwork(const uint32_t interestedNetwork)
1172      * @see void CADestroyEndpoint(CAEndpoint_t *object)
1173      * @see void CADestroyToken(CAToken_t token)
1174      * @see CAResult_t CAHandleRequestResponse()
1175      * @see void CATerminate()
1176      * @objective Test unicast message sending functionality by sending out PUT
1177      *            request messages
1178      * @target CAResult_t CASendRequest(const CAEndpoint_t *object, const
1179      *         CARequestInfo_t *requestInfo)
1180      * @transport bt, ble
1181      * @test_data Request Messages Request messages with method PUT
1182      * @pre_condition 1. [Server] Call CAInitialize to initialize CA 2. [Server]
1183      *                Select Network by CASelectNetwork API 3. [Server] Call
1184      *                CARegisterHandler to register handler 4. [Server] Call
1185      *                CAStartListeningServer to start server 5. [Server] Call
1186      *                CAHandleRequestResponse periodically to recieve client
1187      *                request 6. [Client] Call CAInitialize to initialize CA 7.
1188      *                [Client] Select Network by CASelectNetwork API 8. [Client]
1189      *                Call CARegisterHandler to register handler 9. [Client]
1190      *                Call CAStartDiscoveryServer 10.[Client] Call
1191      *                CAGenerateToken to generate token 11.[Client] Call
1192      *                CACreateEndpoint to create endpoint for server
1193      * @procedure 1. [Client] Set CA_PUT for CAMethod_t while forming
1194      *            CARequestInfo_t 2. [Client] Attempt to send a certain amount
1195      *            of request messages to the server 3. [Client] Attempt to
1196      *            receive acknowledgments for all the sent messages 4. [Client]
1197      *            Check and compare the amount of received acknowledgments with
1198      *            the amount of sent messages
1199      * @post_condition 1. [Client] Destroy token 2. [Client] Destroy endpoint 3.
1200      *                 [CLient] Terminate CA
1201      * @expected The number of acknowledgments should be equal to the amount of
1202      *           sent messages
1203      */
1204     public void testLeSendPutRequest_P() {
1205
1206         if (!CAJni.establishConnectionWithServer()) {
1207             fail();
1208             return;
1209         }
1210
1211
1212         CAJni.setupTestCase(MESSAGE_OUTGOING, MESSAGE_PAYLOAD,
1213                 MESSAGE_UNICAST);
1214
1215         if (!CAJni.initClientNetwork()) {
1216             fail();
1217             return;
1218         }
1219
1220         if (!CAJni.sendRequest(URI_TYPE_NORMAL, PAYLOAD_TYPE_NORMAL,
1221                 CA_MSG_NONCONFIRM, CA_PUT, HEADER_NONE, false)) {
1222             fail();
1223             CAJni.terminate();
1224             return;
1225         }
1226
1227         if (!CAJni.checkReceiveCount(TOTAL_MESSAGE)) {
1228             fail();
1229         }
1230
1231         CAJni.terminate();
1232     }
1233
1234     /**
1235      * @since 2015-09-18
1236      * @see CAResult_t CAInitialize()
1237      * @see void CARegisterHandler(CARequestCallback ReqHandler,
1238      *      CAResponseCallback RespHandler, CAErrorCallback ErrorHandler)
1239      * @see CAResult_t CAGenerateToken(CAToken_t *token, uint8_t tokenLength)
1240      * @see CAResult_t CACreateEndpoint(CATransportFlags_t flags,
1241      *      CATransportAdapter_t adapter, const char *addr, uint16_t port,
1242      *      CAEndpoint_t **object)
1243      * @see CAResult_t CASelectNetwork(const uint32_t interestedNetwork)
1244      * @see void CADestroyEndpoint(CAEndpoint_t *object)
1245      * @see void CADestroyToken(CAToken_t token)
1246      * @see CAResult_t CAHandleRequestResponse()
1247      * @see void CATerminate()
1248      * @objective Test unicast message sending functionality by sending out POST
1249      *            request messages
1250      * @target CAResult_t CASendRequest(const CAEndpoint_t *object, const
1251      *         CARequestInfo_t *requestInfo)
1252      * @transport bt, ble
1253      * @test_data Request Messages Request messages with method POST
1254      * @pre_condition 1. [Server] Call CAInitialize to initialize CA 2. [Server]
1255      *                Select Network by CASelectNetwork API 3. [Server] Call
1256      *                CARegisterHandler to register handler 4. [Server] Call
1257      *                CAStartListeningServer to start server 5. [Server] Call
1258      *                CAHandleRequestResponse periodically to recieve client
1259      *                request 6. [Client] Call CAInitialize to initialize CA 7.
1260      *                [Client] Select Network by CASelectNetwork API 8. [Client]
1261      *                Call CARegisterHandler to register handler 9. [Client]
1262      *                Call CAStartDiscoveryServer 10.[Client] Call
1263      *                CAGenerateToken to generate token 11.[Client] Call
1264      *                CACreateEndpoint to create endpoint for server
1265      * @procedure 1. [Client] Set CA_POST for CAMethod_t while forming
1266      *            CARequestInfo_t 2. [Client] Attempt to send a certain amount
1267      *            of request messages to the server 3. [Client] Attempt to
1268      *            receive acknowledgments for all the sent messages 4. [Client]
1269      *            Check and compare the amount of received acknowledgments with
1270      *            the amount of sent messages
1271      * @post_condition 1. [Client] Destroy token 2. [Client] Destroy endpoint 3.
1272      *                 [CLient] Terminate CA
1273      * @expected The number of acknowledgments should be equal to the amount of
1274      *           sent messages
1275      */
1276     public void testLeSendPostRequest_P() {
1277
1278         if (!CAJni.establishConnectionWithServer()) {
1279             fail();
1280             return;
1281         }
1282
1283
1284         CAJni.setupTestCase(MESSAGE_OUTGOING, MESSAGE_PAYLOAD,
1285                 MESSAGE_UNICAST);
1286
1287         if (!CAJni.initClientNetwork()) {
1288             fail();
1289             return;
1290         }
1291
1292         if (!CAJni.sendRequest(URI_TYPE_NORMAL, PAYLOAD_TYPE_NORMAL,
1293                 CA_MSG_NONCONFIRM, CA_POST, HEADER_NONE, false)) {
1294             fail();
1295             CAJni.terminate();
1296             return;
1297         }
1298
1299         if (!CAJni.checkReceiveCount(TOTAL_MESSAGE)) {
1300             fail();
1301         }
1302
1303         CAJni.terminate();
1304     }
1305
1306     /**
1307      * @since 2015-09-18
1308      * @see CAResult_t CAInitialize()
1309      * @see void CARegisterHandler(CARequestCallback ReqHandler,
1310      *      CAResponseCallback RespHandler, CAErrorCallback ErrorHandler)
1311      * @see CAResult_t CAGenerateToken(CAToken_t *token, uint8_t tokenLength)
1312      * @see CAResult_t CACreateEndpoint(CATransportFlags_t flags,
1313      *      CATransportAdapter_t adapter, const char *addr, uint16_t port,
1314      *      CAEndpoint_t **object)
1315      * @see CAResult_t CASelectNetwork(const uint32_t interestedNetwork)
1316      * @see void CADestroyEndpoint(CAEndpoint_t *object)
1317      * @see void CADestroyToken(CAToken_t token)
1318      * @see CAResult_t CAHandleRequestResponse()
1319      * @see void CATerminate()
1320      * @objective Test unicast message sending functionality by sending out
1321      *            DELETE request messages
1322      * @target CAResult_t CASendRequest(const CAEndpoint_t *object, const
1323      *         CARequestInfo_t *requestInfo)
1324      * @transport bt, ble
1325      * @test_data Request Messages Request messages with method DELETE
1326      * @pre_condition 1. [Server] Call CAInitialize to initialize CA 2. [Server]
1327      *                Select Network by CASelectNetwork API 3. [Server] Call
1328      *                CARegisterHandler to register handler 4. [Server] Call
1329      *                CAStartListeningServer to start server 5. [Server] Call
1330      *                CAHandleRequestResponse periodically to recieve client
1331      *                request 6. [Client] Call CAInitialize to initialize CA 7.
1332      *                [Client] Select Network by CASelectNetwork API 8. [Client]
1333      *                Call CARegisterHandler to register handler 9. [Client]
1334      *                Call CAStartDiscoveryServer 10.[Client] Call
1335      *                CAGenerateToken to generate token 11.[Client] Call
1336      *                CACreateEndpoint to create endpoint for server
1337      * @procedure 1. [Client] Set CA_DELETE for CAMethod_t while forming
1338      *            CARequestInfo_t 2. [Client] Attempt to send a certain amount
1339      *            of request messages to the server 3. [Client] Attempt to
1340      *            receive acknowledgments for all the sent messages 4. [Client]
1341      *            Check and compare the amount of received acknowledgments with
1342      *            the amount of sent messages
1343      * @post_condition 1. [Client] Destroy token 2. [Client] Destroy endpoint 3.
1344      *                 [CLient] Terminate CA
1345      * @expected The number of acknowledgments should be equal to the amount of
1346      *           sent messages
1347      */
1348     public void testLeSendDeleteRequest_P() {
1349
1350         if (!CAJni.establishConnectionWithServer()) {
1351             fail();
1352             return;
1353         }
1354
1355
1356         CAJni.setupTestCase(MESSAGE_OUTGOING, MESSAGE_PAYLOAD,
1357                 MESSAGE_UNICAST);
1358
1359         if (!CAJni.initClientNetwork()) {
1360             fail();
1361             return;
1362         }
1363
1364         if (!CAJni.sendRequest(URI_TYPE_NORMAL, PAYLOAD_TYPE_NORMAL,
1365                 CA_MSG_NONCONFIRM, CA_DELETE, HEADER_NONE, false)) {
1366             fail();
1367             CAJni.terminate();
1368             return;
1369         }
1370
1371         if (!CAJni.checkReceiveCount(TOTAL_MESSAGE)) {
1372             fail();
1373         }
1374
1375         CAJni.terminate();
1376     }
1377
1378     /**
1379      * @since 2015-09-18
1380      * @see CAResult_t CAInitialize()
1381      * @see CAResult_t CAGenerateToken(CAToken_t *token, uint8_t tokenLength)
1382      * @see CAResult_t CACreateEndpoint(CATransportFlags_t flags,
1383      *      CATransportAdapter_t adapter, const char *addr, uint16_t port,
1384      *      CAEndpoint_t **object)
1385      * @see CAResult_t CASelectNetwork(const uint32_t interestedNetwork)
1386      * @see CAResult_t CASendRequest(const CAEndpoint_t *object, const
1387      *      CARequestInfo_t *requestInfo)
1388      * @see void CADestroyEndpoint(CAEndpoint_t *object)
1389      * @see void CADestroyToken(CAToken_t token)
1390      * @see CAResult_t CAHandleRequestResponse()
1391      * @see void CATerminate()
1392      * @objective Test 'CARegisterHandler' by registering null response handler
1393      * @target void CARegisterHandler(CARequestCallback ReqHandler,
1394      *         CAResponseCallback RespHandler, CAErrorCallback ErrorHandler)
1395      * @transport bt, ble
1396      * @test_data Request Messages null response handler
1397      * @pre_condition 1. [Server] Call CAInitialize to initialize CA 2. [Server]
1398      *                Select Network by CASelectNetwork API 3. [Server] Call
1399      *                CARegisterHandler to register handler 4. [Server] Call
1400      *                CAStartListeningServer to start server 5. [Server] Call
1401      *                CAHandleRequestResponse periodically to recieve client
1402      *                request 6. [Client] Call CAInitialize to initialize CA 7.
1403      *                [Client] Select Network by CASelectNetwork API 8. [Client]
1404      *                Call CAGenerateToken to generate token 9. [Client] Call
1405      *                CACreateEndpoint to create endpoint for server
1406      * @procedure 1. [Client] Call CARegisterHandler with Null Response Handler
1407      *            2. [Server] Configure the server with a request to send back a
1408      *            certain amount of response messages 3. [Client] Attempt to
1409      *            receive a certain amount of unicast response messages from the
1410      *            server 4. [Client] Check and compare the received amount with
1411      *            zero
1412      * @post_condition 1. [Client] Destroy token 2. [Client] Destroy endpoint 3.
1413      *                 [CLient] Terminate CA
1414      * @expected No response messages should be received
1415      */
1416     public void testLeReceiveWithNullResponseHandler_N() {
1417
1418         if (!CAJni.establishConnectionWithServer()) {
1419             fail();
1420             return;
1421         }
1422
1423
1424         CAJni.setupTestCase(MESSAGE_INCOMING, MESSAGE_PAYLOAD,
1425                 MESSAGE_UNICAST);
1426
1427         if (!CAJni.initNetwork()) {
1428             fail();
1429             return;
1430         }
1431
1432         CAJni.registerHandler(HANDLER_NORMAL, HANDLER_NULL);
1433
1434         if (!CAJni.sendConfigurationRequest(SEND_MESSAGE,
1435                 MESSAGE_RESPONSE, CA_PUT)) {
1436             fail();
1437             CAJni.terminate();
1438             return;
1439         }
1440
1441         if (!CAJni.checkReceiveCount(0)) {
1442             fail();
1443         }
1444
1445         CAJni.terminate();
1446     }
1447
1448     /**
1449      * @since 2015-09-18
1450      * @see CAResult_t CAInitialize()
1451      * @see CAResult_t CAGenerateToken(CAToken_t *token, uint8_t tokenLength)
1452      * @see CAResult_t CACreateEndpoint(CATransportFlags_t flags,
1453      *      CATransportAdapter_t adapter, const char *addr, uint16_t port,
1454      *      CAEndpoint_t **object)
1455      * @see CAResult_t CASelectNetwork(const uint32_t interestedNetwork)
1456      * @see CAResult_t CASendRequest(const CAEndpoint_t *object, const
1457      *      CARequestInfo_t *requestInfo)
1458      * @see void CADestroyEndpoint(CAEndpoint_t *object)
1459      * @see void CADestroyToken(CAToken_t token)
1460      * @see void CATerminate()
1461      * @objective Test the impact or consequence of not calling
1462      *            CARegisterHandler Test in receiving response
1463      * @target CAResult_t CAHandleRequestResponse()
1464      * @transport bt, ble
1465      * @test_data Request Messages none
1466      * @pre_condition 1. [Server] Call CAInitialize to initialize CA 2. [Server]
1467      *                Select Network by CASelectNetwork API 3. [Server] Call
1468      *                CARegisterHandler to register handler 4. [Server] Call
1469      *                CAStartListeningServer to start server 5. [Server] Call
1470      *                CAHandleRequestResponse periodically to recieve client
1471      *                request 6. [Client] Call CAInitialize to initialize CA 7.
1472      *                [Client] Select Network by CASelectNetwork API 8. [Client]
1473      *                Do not Register the handler 9. [Client] Call
1474      *                CAGenerateToken to generate token 10. [Client] Call
1475      *                CACreateEndpoint to create endpoint for server
1476      * @procedure 1. [Server] Configure the server with a request to send back a
1477      *            certain amount of response messages 2. [Client] Attempt to
1478      *            receive the requested amount of unicast response messages from
1479      *            the server 3. [Client] Check and compare the received amount
1480      *            with zero
1481      * @post_condition 1. [Client] Destroy token 2. [Client] Destroy endpoint 3.
1482      *                 [CLient] Terminate CA
1483      * @expected No response messages should be received
1484      */
1485     public void testLeReceiveResponseWithoutCallingCARegisterHandler_N() {
1486
1487         CAJni.setupTestCase(MESSAGE_OUTGOING, MESSAGE_PAYLOAD,
1488                 MESSAGE_MULTICAST);
1489
1490         if (!CAJni.initNetwork()) {
1491             fail();
1492             return;
1493         }
1494
1495         if (!CAJni.sendRequestToAll(URI_TYPE_NORMAL,
1496                 PAYLOAD_TYPE_NORMAL, CA_MSG_NONCONFIRM, CA_GET, HEADER_NONE)) {
1497             fail();
1498             CAJni.terminate();
1499             return;
1500         }
1501
1502         if (!CAJni.checkReceiveCount(0)) {
1503             fail();
1504         }
1505
1506         CAJni.terminate();
1507
1508     }
1509
1510     /**
1511      * @since 2015-09-18
1512      * @see CAResult_t CAInitialize()
1513      * @see CAResult_t CAGenerateToken(CAToken_t *token, uint8_t tokenLength)
1514      * @see CAResult_t CACreateEndpoint(CATransportFlags_t flags,
1515      *      CATransportAdapter_t adapter, const char *addr, uint16_t port,
1516      *      CAEndpoint_t **object)
1517      * @see CAResult_t CASelectNetwork(const uint32_t interestedNetwork)
1518      * @see CAResult_t CASendRequest(const CAEndpoint_t *object, const
1519      *      CARequestInfo_t *requestInfo)
1520      * @see void CADestroyEndpoint(CAEndpoint_t *object)
1521      * @see void CADestroyToken(CAToken_t token)
1522      * @see CAResult_t CAHandleRequestResponse()
1523      * @see void CATerminate()
1524      * @objective Test 'CARegisterHandler' when registration is done twice by
1525      *            using two different response handler
1526      * @target void CARegisterHandler(CARequestCallback ReqHandler,
1527      *         CAResponseCallback RespHandler, CAErrorCallback ErrorHandler)
1528      * @transport bt, ble
1529      * @test_data Request Messages two different response handler
1530      * @pre_condition 1. [Server] Call CAInitialize to initialize CA 2. [Server]
1531      *                Select Network by CASelectNetwork API 3. [Server] Call
1532      *                CARegisterHandler to register handler 4. [Server] Call
1533      *                CAStartListeningServer to start server 5. [Server] Call
1534      *                CAHandleRequestResponse periodically to recieve client
1535      *                request 6. [Client] Call CAInitialize to initialize CA 7.
1536      *                [Client] Select Network by CASelectNetwork API
1537      * @procedure 1. [Client] Call CARegisterHandler twice with two different
1538      *            Response Handler 2. [Client] Call CAStartDiscoveryServer 3.
1539      *            [Client] Call CAGenerateToken to generate token 4. [Client]
1540      *            Call CACreateEndpoint to create endpoint for server 5.
1541      *            [Server] Configure the server with a request to send back a
1542      *            certain amount of response messages 6. [Client] Attempt to
1543      *            receive the requested amount of unicast response messages from
1544      *            the server 7. [Client] Check and compare the received amount
1545      *            by the both handler with the requested amount
1546      * @post_condition 1. [Client] Destroy token 2. [Client] Destroy endpoint 3.
1547      *                 [CLient] Terminate CA
1548      * @expected Second handler will receive requested amount of response
1549      *           messages and first handler will receive no response message
1550      */
1551     public void testLeReceiveWithSecondResponseHandler_P() {
1552
1553         if (!CAJni.establishConnectionWithServer()) {
1554             fail();
1555             return;
1556         }
1557
1558
1559         CAJni.setupTestCase(MESSAGE_INCOMING, MESSAGE_PAYLOAD,
1560                 MESSAGE_UNICAST);
1561
1562         if (!CAJni.initNetwork()) {
1563             fail();
1564             return;
1565         }
1566
1567         CAJni.registerHandler(HANDLER_NORMAL, HANDLER_NORMAL);
1568         CAJni.registerHandler(HANDLER_NORMAL, HANDLER_SECOND);
1569
1570         if (!CAJni.startDiscoveryServer(CA_STATUS_OK)) {
1571             fail();
1572             CAJni.terminate();
1573             return;
1574         }
1575
1576         if (!CAJni.sendConfigurationRequest(SEND_MESSAGE,
1577                 MESSAGE_RESPONSE, CA_PUT)) {
1578             fail();
1579             CAJni.terminate();
1580             return;
1581         }
1582
1583         if (!CAJni.checkReceiveCount(TOTAL_MESSAGE)) {
1584             fail();
1585         }
1586
1587         CAJni.terminate();
1588     }
1589
1590     /**
1591      * @since 2015-09-18
1592      * @see CAResult_t CAInitialize()
1593      * @see CAResult_t CAGenerateToken(CAToken_t *token, uint8_t tokenLength)
1594      * @see CAResult_t CACreateEndpoint(CATransportFlags_t flags,
1595      *      CATransportAdapter_t adapter, const char *addr, uint16_t port,
1596      *      CAEndpoint_t **object)
1597      * @see CAResult_t CASelectNetwork(const uint32_t interestedNetwork)
1598      * @see CAResult_t CASendRequest(const CAEndpoint_t *object, const
1599      *      CARequestInfo_t *requestInfo)
1600      * @see void CADestroyEndpoint(CAEndpoint_t *object)
1601      * @see void CADestroyToken(CAToken_t token)
1602      * @see CAResult_t CAHandleRequestResponse()
1603      * @see void CATerminate()
1604      * @objective Test 'CARegisterHandler' by doing registration twice using
1605      *            first a valid response handler then a null response handler
1606      * @target void CARegisterHandler(CARequestCallback ReqHandler,
1607      *         CAResponseCallback RespHandler, CAErrorCallback ErrorHandler)
1608      * @transport bt, ble
1609      * @test_data Request Messages valid response handler & null response handler
1610      * @pre_condition 1. [Server] Call CAInitialize to initialize CA 2. [Server]
1611      *                Select Network by CASelectNetwork API 3. [Server] Call
1612      *                CARegisterHandler to register handler 4. [Server] Call
1613      *                CAStartListeningServer to start server 5. [Server] Call
1614      *                CAHandleRequestResponse periodically to recieve client
1615      *                request 6. [Client] Call CAInitialize to initialize CA 7.
1616      *                [Client] Select Network by CASelectNetwork API
1617      * @procedure 1. [Client] Call CARegisterHandler twice by using first a
1618      *            valid response handler then a null response handler 2.
1619      *            [Client] Call CAStartDiscoveryServer 3. [Client] Call
1620      *            CAGenerateToken to generate token 4. [Client] Call
1621      *            CACreateEndpoint to create endpoint for server 5. [Server]
1622      *            Configure the server with a request to send back a certain
1623      *            amount of response messages 6. [Client] Attempt to receive the
1624      *            requested amount of unicast response messages from the server
1625      *            7. [Client] Check and compare the received amount wit zero
1626      * @post_condition 1. [Client] Destroy token 2. [Client] Destroy endpoint 3.
1627      *                 [CLient] Terminate CA
1628      * @expected No response messages should be received
1629      */
1630     public void testLeReceiveAfterRegisteringWithValidFollowedByNullResponseHandler_N() {
1631
1632         if (!CAJni.establishConnectionWithServer()) {
1633             fail();
1634             return;
1635         }
1636
1637
1638         CAJni.setupTestCase(MESSAGE_INCOMING, MESSAGE_PAYLOAD,
1639                 MESSAGE_UNICAST);
1640
1641         if (!CAJni.initNetwork()) {
1642             fail();
1643             return;
1644         }
1645
1646         CAJni.registerHandler(HANDLER_NORMAL, HANDLER_NORMAL);
1647
1648         CAJni.registerHandler(HANDLER_NORMAL, HANDLER_NULL);
1649
1650         if (!CAJni.sendConfigurationRequest(SEND_MESSAGE,
1651                 MESSAGE_RESPONSE, CA_PUT)) {
1652             fail();
1653             CAJni.terminate();
1654             return;
1655         }
1656
1657         if (!CAJni.checkReceiveCount(0)) {
1658             fail();
1659         }
1660
1661         CAJni.terminate();
1662     }
1663 }