|
1 /* |
|
2 * Copyright (c) 2002 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 FILES] - do not remove |
|
19 #include <e32svr.h> |
|
20 #include <e32math.h> |
|
21 #include <StifParser.h> |
|
22 #include <Stiftestinterface.h> |
|
23 #include <SenServiceConnection.h> |
|
24 #include <SenServicePattern.h> |
|
25 #include <SenHttpTransportProperties.h> |
|
26 #include "SenHostletConnection.h" |
|
27 #include "TestConsumer.h" |
|
28 #include "TestHostlet.h" |
|
29 #include <SenFacet.h> |
|
30 |
|
31 #include <SenTransportProperties.h> |
|
32 #include "hostconnTester.h" |
|
33 |
|
34 // EXTERNAL DATA STRUCTURES |
|
35 //extern ?external_data; |
|
36 |
|
37 // EXTERNAL FUNCTION PROTOTYPES |
|
38 //extern ?external_function( ?arg_type,?arg_type ); |
|
39 |
|
40 // CONSTANTS |
|
41 //const ?type ?constant_var = ?constant; |
|
42 |
|
43 // MACROS |
|
44 //#define ?macro ?macro_def |
|
45 |
|
46 // LOCAL CONSTANTS AND MACROS |
|
47 //const ?type ?constant_var = ?constant; |
|
48 //#define ?macro_name ?macro_def |
|
49 |
|
50 // MODULE DATA STRUCTURES |
|
51 //enum ?declaration |
|
52 //typedef ?declaration |
|
53 |
|
54 // LOCAL FUNCTION PROTOTYPES |
|
55 //?type ?function_name( ?arg_type, ?arg_type ); |
|
56 |
|
57 // FORWARD DECLARATIONS |
|
58 //class ?FORWARD_CLASSNAME; |
|
59 |
|
60 // ============================= LOCAL FUNCTIONS =============================== |
|
61 |
|
62 //Macro for Porting to STIF |
|
63 #define LOCAL_ASSERT(expression) {if(!(expression)){return KErrArgument;}} |
|
64 #define LOCAL_VOID_ASSERT(expression) {if(!(expression)){return ;}} |
|
65 |
|
66 namespace |
|
67 { |
|
68 _LIT8(KHostletEndpoint, "hostlet://UnitTestHostlet"); |
|
69 _LIT8(KHostletEndpoint1, "hostlet://UnitTestHostlet-1"); |
|
70 _LIT8(KHostletContract, "urn:nokia.com.serene:unit-test-hostlet"); |
|
71 _LIT8(KHostletContract1, "urn:nokia.com.serene:unit-test-hostlet-1"); |
|
72 |
|
73 void threadMainL(TAny* aPtr) |
|
74 { |
|
75 TConsumerTestTask* pTask = (TConsumerTestTask*) aPtr; |
|
76 pTask->Execute(); |
|
77 // Go safely out of scope (will destroy this thread) |
|
78 } |
|
79 |
|
80 TInt threadFunction(TAny* aPtr) |
|
81 { |
|
82 CTrapCleanup* pCleanup = CTrapCleanup::New(); |
|
83 CActiveScheduler::Install(NULL); // remove one |
|
84 CActiveScheduler* pScheduler = new (ELeave) CActiveScheduler(); |
|
85 CActiveScheduler::Install(pScheduler); |
|
86 |
|
87 TInt leaveCode(KErrNone); |
|
88 TRAP(leaveCode, threadMainL(aPtr)); |
|
89 |
|
90 CActiveScheduler::Install(NULL); // uninstall scheduler |
|
91 delete pScheduler; |
|
92 delete pCleanup; |
|
93 |
|
94 return leaveCode; |
|
95 } |
|
96 |
|
97 |
|
98 TInt CreateThreadForConsumerTask(RThread& aThread, const TDesC& aThreadName, TConsumerTestTask& aTask) |
|
99 { |
|
100 TName threadName(aThreadName); |
|
101 // Append a random number to make it unique |
|
102 threadName.AppendNum(Math::Random(), EHex); |
|
103 |
|
104 #ifdef EKA2 |
|
105 RAllocator& heap = User::Allocator(); // RHeap is deprecated in EKA2 |
|
106 return aThread.Create(threadName, // name |
|
107 threadFunction, |
|
108 KDefaultStackSize, |
|
109 &heap, |
|
110 &aTask); |
|
111 #else // EKA1 |
|
112 RHeap& heap = User::Heap(); |
|
113 return aThread.Create(threadName, // name |
|
114 threadFunction, |
|
115 KDefaultStackSize, |
|
116 &heap, |
|
117 &aTask); |
|
118 #endif // EKA |
|
119 } |
|
120 } |
|
121 // ============================ MEMBER FUNCTIONS =============================== |
|
122 |
|
123 // ----------------------------------------------------------------------------- |
|
124 // ChostconnTester::Delete |
|
125 // Delete here all resources allocated and opened from test methods. |
|
126 // Called from destructor. |
|
127 // ----------------------------------------------------------------------------- |
|
128 // |
|
129 void ChostconnTester::Delete() |
|
130 { |
|
131 |
|
132 } |
|
133 |
|
134 // ----------------------------------------------------------------------------- |
|
135 // ChostconnTester::RunMethodL |
|
136 // Run specified method. Contains also table of test mothods and their names. |
|
137 // ----------------------------------------------------------------------------- |
|
138 // |
|
139 TInt ChostconnTester::RunMethodL( |
|
140 CStifItemParser& aItem ) |
|
141 { |
|
142 |
|
143 static TStifFunctionInfo const KFunctions[] = |
|
144 { |
|
145 // Copy this line for every implemented function. |
|
146 // First string is the function name used in TestScripter script file. |
|
147 // Second is the actual implementation member function. |
|
148 ENTRY("NewL-ChostconnTester", ChostconnTester::UT_CSenHostletConnection_NewLL), |
|
149 |
|
150 ENTRY("NewLC-ChostconnTester", ChostconnTester::UT_CSenHostletConnection_NewLCL), |
|
151 ENTRY("Identifier-ChostconnTester", ChostconnTester::UT_CSenHostletConnection_IdentifierL), |
|
152 |
|
153 ENTRY("FrameworkId-ChostconnTester", ChostconnTester::UT_CSenHostletConnection_FrameworkIdL), |
|
154 |
|
155 ENTRY("RequestUtf8-ChostconnTester", ChostconnTester::UT_CSenHostletConnection_RequestUtf8L), |
|
156 |
|
157 ENTRY("ThreadId-ChostconnTester", ChostconnTester::UT_CSenHostletConnection_ThreadIdL), |
|
158 |
|
159 ENTRY("NewLC-ChostconnTester", ChostconnTester::UT_CSenHostletConnection_NewLC_3InvokesL), |
|
160 |
|
161 ENTRY("RespondL1-ChostconnTester", ChostconnTester::UT_CSenHostletConnection_RespondL1L), |
|
162 ENTRY("NewLC-ChostconnTester ", ChostconnTester::UT_CSenHostletConnection_NewLC_3InvokesL), |
|
163 |
|
164 ENTRY("RespondL1-ChostconnTester ", ChostconnTester::UT_CSenHostletConnection_RespondL1L), |
|
165 |
|
166 ENTRY("RespondL2-ChostconnTester", ChostconnTester::UT_CSenHostletConnection_RespondL2L), |
|
167 |
|
168 ENTRY("RespondL3-ChostconnTester", ChostconnTester::UT_CSenHostletConnection_RespondL3L), |
|
169 |
|
170 ENTRY("RespondL_negative_response_code-ChostconnTester", ChostconnTester::UT_CSenHostletConnection_Negative_ResponseCodeL), |
|
171 |
|
172 ENTRY("RespondL_self_def_URI-ChostconnTester", ChostconnTester::UT_CSenHostletConnection_HC_SelfDef_URIL), |
|
173 |
|
174 //ENTRY("RespondL delete HC after SC is created-ChostconnTester", ChostconnTester::UT_CSenHostletConnection_Delete_HCL), |
|
175 |
|
176 ENTRY("NewL_leaves_with_KErrSenEndpointReserved-ChostconnTester", ChostconnTester::UT_CSenHostletConnection_Two_Equal_UID3L), |
|
177 |
|
178 ENTRY("RespondL_Two_HC_with_the_same_Endpoints_UIDs-ChostconnTester", ChostconnTester::UT_CSenHostletConnection_Two_Equal_EndpointsL), |
|
179 |
|
180 ENTRY("RespondL_Two_HC_Two_SC_diff_contracts-ChostconnTester", ChostconnTester::UT_CSenHostletConnection_Two_HC_Two_SC1L), |
|
181 |
|
182 ENTRY("RespondL_Two_HC_Two_SC_diff_endpionts-ChostconnTester",ChostconnTester::UT_CSenHostletConnection_Two_HC_Two_SC2L), |
|
183 |
|
184 ENTRY("RespondL_Two_HC_Two_SC_diff_endpionts_the_same_contract-ChostconnTester", ChostconnTester::UT_CSenHostletConnection_Two_HC_Two_SC3L), |
|
185 |
|
186 ENTRY("RespondL_Delete_SC_before_calling_HC::RespondL-ChostconnTester", ChostconnTester::UT_CSenHostletConnection_DeleteSC_before_HCRespondLL), |
|
187 |
|
188 ENTRY("RespondL_Call_RespondL_multipe_times-ChostconnTester", ChostconnTester::UT_CSenHostletConnection_RespondL_4multipleTimesL), |
|
189 |
|
190 ENTRY("RespondL_SC::Cancel_after_request-ChostconnTester", ChostconnTester::UT_CSenHostletConnection_SC_Cancel_After_RequestL), |
|
191 |
|
192 ENTRY("RespondL_Set_Expose_Facet-ChostconnTester", ChostconnTester::UT_CSenHostletConnection_Set_Expose_FacetL), |
|
193 |
|
194 ENTRY("HC_responds_with_TP-ChostconnTester", ChostconnTester::UT_CSenHostletConnection_RespondWithPropertiesL), |
|
195 |
|
196 //ENTRY("New REST SC + SubmitL Test-ChostconnTester", ChostconnTester::UT_CSenHostletConnection_CreateConnAndSubmit_Rest_MultiThreadL), |
|
197 |
|
198 //ENTRY("New WS-I SC + SubmitL Test-ChostconnTester", ChostconnTester::UT_CSenHostletConnection_CreateConnAndSubmit_WSI_MultiThreadL), |
|
199 |
|
200 |
|
201 //ENTRY("SendL WS-I Test-ChostconnTester", ChostconnTester::UT_CSenHostletConnection_Send_WSIL), |
|
202 |
|
203 //ENTRY("Desc EP + SendL-WS-I-Test-ChostconnTester", ChostconnTester::UT_CSenHostletConnection_DescEndpoint_Send_WSIL), |
|
204 |
|
205 ENTRY("SendL_from_2_SCs_to_1_HC-ChostconnTester", ChostconnTester::UT_CSenHostletConnection_2SC1HCL) |
|
206 |
|
207 }; |
|
208 const TInt count = sizeof( KFunctions ) / |
|
209 sizeof( TStifFunctionInfo ); |
|
210 |
|
211 return RunInternalL( KFunctions, count, aItem ); |
|
212 } |
|
213 |
|
214 // ----------------------------------------------------------------------------- |
|
215 // ChostconnTester::?member_function |
|
216 // ?implementation_description |
|
217 // (other items were commented in a header). |
|
218 // ----------------------------------------------------------------------------- |
|
219 // |
|
220 /* |
|
221 TInt ChostconnTester::?member_function( |
|
222 CItemParser& aItem ) |
|
223 { |
|
224 |
|
225 ?code |
|
226 |
|
227 } |
|
228 */ |
|
229 |
|
230 // ========================== OTHER EXPORTED FUNCTIONS ========================= |
|
231 // None |
|
232 // METHODS |
|
233 |
|
234 void ChostconnTester::StartActiveScheduler(TInt aNumberOfPendingOps) |
|
235 { |
|
236 iNumberOfPendingOps = aNumberOfPendingOps; |
|
237 CActiveScheduler::Start(); |
|
238 } |
|
239 |
|
240 void ChostconnTester::StopActiveScheduler () |
|
241 { |
|
242 iNumberOfPendingOps--; |
|
243 if ( iNumberOfPendingOps == 0 ) |
|
244 { |
|
245 CActiveScheduler::Stop(); |
|
246 } |
|
247 } |
|
248 |
|
249 void TConsumerTestTask::Execute() |
|
250 { |
|
251 switch(iJob) |
|
252 { |
|
253 case(ECreateConnAndSubmit): // this is a very oddly orientated, wild case.. |
|
254 { |
|
255 if(ipOwner) |
|
256 { |
|
257 CTestConsumer* pConsumer = CTestConsumer::NewL(ipOwner); // uses the default implementations for setstatus, handlemessage, handleerror |
|
258 CleanupStack::PushL(pConsumer); |
|
259 |
|
260 // Note, if NOT set, iEndpoint is typically KNullDesC8 (zero-lenght), which is OK, too. |
|
261 CSenServicePattern* pPattern = CSenServicePattern::NewLC(iEndpoint, KHostletContract); |
|
262 if(iFrameworkId.Length()>0) |
|
263 { |
|
264 pPattern->SetFrameworkIdL(iFrameworkId); |
|
265 } |
|
266 else |
|
267 { |
|
268 pPattern->SetFrameworkIdL(KDefaultRestServicesFrameworkID); |
|
269 } |
|
270 |
|
271 CSenServiceConnection* pConnection = CSenServiceConnection::NewL(*pConsumer, *pPattern); |
|
272 CleanupStack::PopAndDestroy(pPattern); |
|
273 CleanupStack::PushL(pConnection); |
|
274 |
|
275 // Construct service connection by starting active scheduler.. |
|
276 ipOwner->StartActiveScheduler(1); |
|
277 |
|
278 // Check that NO HandleErrorL callback was received: |
|
279 LOCAL_VOID_ASSERT( pConsumer->iErrorCode == KErrNone ); |
|
280 |
|
281 |
|
282 // Check that the Status of the ServiceConnection |
|
283 // is KSenConnectionStatusReady |
|
284 LOCAL_VOID_ASSERT( pConsumer->iConnectionStatus == KSenConnectionStatusReady); |
|
285 |
|
286 // execution returns here EITHER when HandleMessageL or HandleErrorL has been invoked.. |
|
287 if(iProperties.Length()==0) |
|
288 { |
|
289 if(ipSoapMsg) |
|
290 { |
|
291 iStatusCode = pConnection->SubmitL(*ipSoapMsg, ipNotOwnedData); |
|
292 } |
|
293 else |
|
294 { |
|
295 iStatusCode = pConnection->SubmitL(iRequest, ipNotOwnedData); |
|
296 } |
|
297 } |
|
298 else |
|
299 { |
|
300 if(ipSoapMsg) |
|
301 { |
|
302 iStatusCode = pConnection->SubmitL(*ipSoapMsg, iProperties, ipNotOwnedData); |
|
303 } |
|
304 else |
|
305 { |
|
306 iStatusCode = pConnection->SubmitL(iRequest, iProperties, ipNotOwnedData); |
|
307 } |
|
308 } |
|
309 CleanupStack::PopAndDestroy(pConnection); |
|
310 CleanupStack::PopAndDestroy(pConsumer); |
|
311 } |
|
312 } |
|
313 break; |
|
314 |
|
315 case(ESubmit): |
|
316 { |
|
317 if(iProperties.Length()==0) |
|
318 { |
|
319 iStatusCode = iConnection.SubmitL(iRequest, ipNotOwnedData); |
|
320 } |
|
321 else |
|
322 { |
|
323 iStatusCode = iConnection.SubmitL(iRequest, iProperties, ipNotOwnedData); |
|
324 } |
|
325 } |
|
326 break; |
|
327 |
|
328 case(EActiveSubmit): |
|
329 { |
|
330 if ( ipActive) |
|
331 { |
|
332 // Perform blocking (sync) submit: |
|
333 if(iProperties.Length()==0) |
|
334 { |
|
335 iStatusCode = iConnection.SubmitL(iRequest, ipNotOwnedData); |
|
336 } |
|
337 else |
|
338 { |
|
339 iStatusCode = iConnection.SubmitL(iRequest, iProperties, ipNotOwnedData); |
|
340 } |
|
341 |
|
342 // Notify "owner" that blocking operation has completed |
|
343 TRequestStatus* status = &ipActive->iStatus; |
|
344 RThread owner; |
|
345 owner.Open(ipActive->iOwnerThreadId); |
|
346 owner.RequestComplete(status, CActiveConsumerTestTask::EDeliverResponse ); |
|
347 } |
|
348 } |
|
349 break; |
|
350 |
|
351 } |
|
352 } |
|
353 |
|
354 ///////////////////////////////////////////////////////////////////////////////////////////////// |
|
355 // HELPER CLASS for SC (active) tasks: |
|
356 // Public METHODS |
|
357 |
|
358 CActiveConsumerTestTask* CActiveConsumerTestTask::NewL(TConsumerTestTask& aTask, const TDesC& aThreadName, ChostconnTester& aOwner) |
|
359 { |
|
360 CActiveConsumerTestTask* pNew = CActiveConsumerTestTask::NewLC(aTask, aThreadName, aOwner); |
|
361 CleanupStack::Pop(); |
|
362 return pNew; |
|
363 } |
|
364 |
|
365 CActiveConsumerTestTask* CActiveConsumerTestTask::NewLC(TConsumerTestTask& aTask, const TDesC& aThreadName, ChostconnTester& aOwner) |
|
366 { |
|
367 CActiveConsumerTestTask* pNew = new (ELeave) CActiveConsumerTestTask(aTask, aOwner); |
|
368 CleanupStack::PushL(pNew); |
|
369 pNew->ConstructL(aThreadName); |
|
370 return pNew; |
|
371 } |
|
372 |
|
373 CActiveConsumerTestTask::CActiveConsumerTestTask(TConsumerTestTask& aTask, ChostconnTester& aOwner) |
|
374 : CActive(EPriorityStandard), |
|
375 iTask(aTask), |
|
376 iOwner(aOwner) |
|
377 { |
|
378 CActiveScheduler::Add(this); |
|
379 } |
|
380 |
|
381 CActiveConsumerTestTask::~CActiveConsumerTestTask() |
|
382 { |
|
383 if(IsActive()) |
|
384 { |
|
385 Cancel(); // issues DoCancel(); |
|
386 } |
|
387 iTaskThread.Close(); |
|
388 } |
|
389 |
|
390 void CActiveConsumerTestTask::RunL() |
|
391 { |
|
392 switch(iStatus.Int()) |
|
393 { |
|
394 case(EInvokeService): |
|
395 { |
|
396 iTaskThread.Resume(); |
|
397 } |
|
398 break; |
|
399 |
|
400 case(EDeliverResponse): |
|
401 { |
|
402 iOwner.StopActiveScheduler(); // submit complete.. |
|
403 } |
|
404 break; |
|
405 /* case defaul: // unknown */ |
|
406 } |
|
407 } |
|
408 void CActiveConsumerTestTask::DoCancel() |
|
409 { |
|
410 iOwner.StopActiveScheduler(); |
|
411 } |
|
412 |
|
413 // Private METHODS |
|
414 void CActiveConsumerTestTask::ConstructL(const TDesC& aThreadName) |
|
415 { |
|
416 RThread thread; |
|
417 iOwnerThreadId = thread.Id(); |
|
418 |
|
419 TInt createThreadRetVal = CreateThreadForConsumerTask(iTaskThread, aThreadName, iTask); |
|
420 User::LeaveIfError( createThreadRetVal ); |
|
421 SetActive(); |
|
422 } |
|
423 |
|
424 |
|
425 ///////////////////////////////////////////////////////////////////////////////////////////////// |
|
426 |
|
427 void ChostconnTester::UT_CSenHostletConnection_WSI_DescribeServiceL(CSenXmlServiceDescription& aSD) |
|
428 { |
|
429 aSD.SetFrameworkIdL(KDefaultBasicWebServicesFrameworkID); |
|
430 aSD.SetEndPointL(KHostletEndpoint); |
|
431 aSD.SetContractL(KHostletContract); |
|
432 } |
|
433 |
|
434 void ChostconnTester::UT_CSenHostletConnection_WSI_DescribeService_2L(CSenXmlServiceDescription& aSD) |
|
435 { |
|
436 aSD.SetFrameworkIdL(KDefaultBasicWebServicesFrameworkID); |
|
437 aSD.SetContractL(KHostletContract); |
|
438 } |
|
439 |
|
440 |
|
441 void ChostconnTester::UT_CSenHostletConnection_NewLL_SetStatus(ChostconnTester* apTestSuite, |
|
442 TInt aStatus ) |
|
443 { |
|
444 switch( aStatus ) |
|
445 { |
|
446 case KSenConnectionStatusReady: |
|
447 { |
|
448 apTestSuite->StopActiveScheduler(); // otherwise failed SC construction is reported via HandleErrorL(!) |
|
449 } |
|
450 break; |
|
451 case KSenConnectionStatusNew: |
|
452 case KSenConnectionStatusExpired: |
|
453 default: |
|
454 break; |
|
455 } |
|
456 } |
|
457 |
|
458 |
|
459 |
|
460 // not in use atm: |
|
461 void ChostconnTester::UT_CSenHostletConnection_NewLL_HandleMessageL(ChostconnTester* /* apTestSuite */, const TDesC8& /* aMessage*/ ) |
|
462 { |
|
463 } |
|
464 |
|
465 //used by UT_CSenHostletConnection_Negative_ResponseCodeL |
|
466 //used by UT_CSenHostletConnection_Delete_HCL |
|
467 void ChostconnTester::UT_CSenHostletConnection_NewLL_HandleErrorL(ChostconnTester* apTestSuite, const TInt /*aErrorCode*/ , const TDesC8& /* aMessage */) |
|
468 { |
|
469 apTestSuite->iWas_HandleErrorL_Accessed = ETrue; |
|
470 } |
|
471 |
|
472 //used by the UT_CSenHostletConnection_Negative_ResponseCodeL |
|
473 TInt ChostconnTester::UT_CSenHostletConnection_NewLL_OnServiceL(ChostconnTester* apTestSuite , MSenHostletRequest& /*aRequest*/ , MSenHostletResponse& aResponse ) |
|
474 { |
|
475 TInt alteredResponseCode = -148000; |
|
476 _LIT8(KAlteredResponse, "<Response><ReplyMessage>Response Altered in UT_CSenHostletConnection_NewLL_OnServiceL.</ReplyMessage><Request>%S</Request></Response>"); |
|
477 apTestSuite->ipHostlet->iResponseCodes[apTestSuite->ipHostlet->iTxnIds.Count()-1] = alteredResponseCode; |
|
478 aResponse.SetResponseUtf8L(KAlteredResponse, alteredResponseCode); |
|
479 return KErrNone; |
|
480 } |
|
481 |
|
482 // not in use atm: |
|
483 TInt ChostconnTester::UT_CSenHostletConnection_NewLL_OnServiceCompleteL(ChostconnTester* /* apTestSuite */, const TInt /* aTxnId */, TInt /* aCompletionCode */, const TDesC8& /* aDesc */ ) |
|
484 { |
|
485 return KErrNone; |
|
486 } |
|
487 |
|
488 //used by the UT_CSenHostletConnection_DeleteSC_before_HCRespondLL method |
|
489 TInt ChostconnTester::UT_CSenHostletConnection_NewLL_OnService1L(ChostconnTester* apTestSuite , MSenHostletRequest& /*aRequest*/ , MSenHostletResponse& /*aResponse*/ ) |
|
490 { |
|
491 apTestSuite->ipConnection->Cancel(); |
|
492 delete apTestSuite->ipConnection; |
|
493 apTestSuite->ipConnection = NULL; |
|
494 return KErrNone; |
|
495 } |
|
496 |
|
497 //used by UT_CSenHostletConnection_DeleteSC_before_HCRespondLL |
|
498 TInt ChostconnTester::UT_CSenHostletConnection_NewLL_OnServiceComplete1L(ChostconnTester* apTestSuite, const TInt /* aTxnId */, TInt /*aCompletionCode*/ , const TDesC8& /* aDesc */ ) |
|
499 { |
|
500 apTestSuite->iWas_OnServiceL_Accessed = ETrue; |
|
501 return KErrNone; |
|
502 } |
|
503 |
|
504 // used by the UT_CSenHostletConnection_RespondL_4multipleTimesL method |
|
505 TInt ChostconnTester::UT_CSenHostletConnection_NewLL_OnService2L(ChostconnTester* apTestSuite , MSenHostletRequest& /*aRequest*/ , MSenHostletResponse& aResponse ) |
|
506 { |
|
507 TInt respondRetCode = apTestSuite->ipHostletConnection->RespondL(aResponse); |
|
508 TInt respondRetCode1 = apTestSuite->ipHostletConnection->RespondL(aResponse); |
|
509 LOCAL_ASSERT(respondRetCode == KErrNone); |
|
510 LOCAL_ASSERT(respondRetCode1 == KErrAlreadyExists); |
|
511 return KErrNone; |
|
512 } |
|
513 |
|
514 // to be used (currently does nothing) by the UT_CSenHostletConnection_RespondL_4multipleTimesL method |
|
515 TInt ChostconnTester::UT_CSenHostletConnection_NewLL_OnServiceComplete2L(ChostconnTester* /* apTestSuite */, const TInt /* aTxnId */, TInt /*aCompletionCode*/ , const TDesC8& /* aDesc */ ) |
|
516 { |
|
517 return KErrNone; |
|
518 } |
|
519 |
|
520 //used by the UT_CSenHostletConnection_SC_Cancel_After_RequestL method |
|
521 void ChostconnTester::UT_CSenHostletConnection_NewLL_HandleError1L(ChostconnTester* apTestSuite, const TInt /* aErrorCode */, const TDesC8& /* aMessage */) |
|
522 { |
|
523 // TInt a = aErrorCode; |
|
524 apTestSuite->iWas_HandleErrorL_Accessed = ETrue; |
|
525 } |
|
526 //used by the UT_CSenHostletConnection_SC_Cancel_After_RequestL method |
|
527 TInt ChostconnTester::UT_CSenHostletConnection_NewLL_OnService3L(ChostconnTester* apTestSuite , MSenHostletRequest& /*aRequest*/ , MSenHostletResponse& /*aResponse*/ ) |
|
528 { |
|
529 // apTestSuite->ipConnection->Cancel(); |
|
530 //canceling request |
|
531 apTestSuite->ipConnection->CancelTransaction(apTestSuite->iTxnID); |
|
532 return KErrNone; |
|
533 } |
|
534 |
|
535 |
|
536 //used by the UT_CSenHostletConnection_RespondWithPropertiesL method in order to provide transport properties with the response |
|
537 TInt ChostconnTester::UT_CSenHostletConnection_RespondWithPropertiesL_OnServiceL(ChostconnTester* apTestSuite , MSenHostletRequest& /*aRequest*/ , MSenHostletResponse& aResponse ) |
|
538 { |
|
539 TInt txn = apTestSuite->ipHostlet->iTxnIds.Count()-1; |
|
540 TPtr8 response = apTestSuite->ipHostlet->iResponses[txn]->Des(); |
|
541 |
|
542 TInt responseCode = apTestSuite->ipHostlet->iResponseCodes[txn]; |
|
543 |
|
544 CSenTransportProperties* pTransportProperties = CSenTransportProperties::NewLC(); |
|
545 _LIT8(KTestCid, "test:cid"); |
|
546 _LIT8(KTestFile, "c:\\test.file.txt"); |
|
547 pTransportProperties->SetFileAttachmentL( KTestCid, KTestFile ); |
|
548 |
|
549 if( apTestSuite->ipHostlet->iResponseProps.Append( pTransportProperties ) ) |
|
550 { |
|
551 // error: |
|
552 CleanupStack::PopAndDestroy(pTransportProperties); |
|
553 return KErrNoMemory; |
|
554 } |
|
555 else |
|
556 { |
|
557 // ok |
|
558 CleanupStack::Pop(pTransportProperties); |
|
559 aResponse.SetResponseUtf8L(response, responseCode, pTransportProperties); // by default, all requests are "accepted" |
|
560 return KErrNone; |
|
561 } |
|
562 } |
|
563 |
|
564 |
|
565 |
|
566 //--------------------------------------------------------------- |
|
567 // Test Cases |
|
568 //--------------------------------------------------------------- |
|
569 |
|
570 |
|
571 TInt ChostconnTester::UT_CSenHostletConnection_NewLL(CStifItemParser& aItem) |
|
572 { |
|
573 |
|
574 ipHostlet = CTestHostlet::NewL(this); // uses default implementations for servicel and onservicecompletel |
|
575 ipConsumer = CTestConsumer::NewL(this); // uses the default implementations for setstatus, handlemessage, handleerror |
|
576 |
|
577 // ipHostlet = CTestHostlet::NewL(this, |
|
578 // &ChostconnTester::UT_CSenHostletConnection_NewLL_OnServiceL, |
|
579 // &ChostconnTester::UT_CSenHostletConnection_NewLL_OnServiceCompleteL); |
|
580 |
|
581 // ipConsumer = CTestConsumer::NewL(this, |
|
582 // &ChostconnTester::UT_CSenHostletConnection_NewLL_HandleMessageL, |
|
583 // &ChostconnTester::UT_CSenHostletConnection_NewLL_HandleErrorL, |
|
584 // &ChostconnTester::UT_CSenHostletConnection_NewLL_SetStatus); |
|
585 |
|
586 ipHostletConnection = CSenHostletConnection::NewL(*ipHostlet); |
|
587 |
|
588 CSenServicePattern* pPattern = |
|
589 CSenServicePattern::NewLC(KNullDesC8, KHostletContract); |
|
590 pPattern->SetFrameworkIdL(KDefaultRestServicesFrameworkID); |
|
591 |
|
592 ipConnection = CSenServiceConnection::NewL(*ipConsumer, *pPattern); |
|
593 CleanupStack::PopAndDestroy(pPattern); |
|
594 |
|
595 // Construct service connection |
|
596 StartActiveScheduler(1); |
|
597 |
|
598 _LIT8(KRequest, "<ab:Query xmlns:ab=\"urn:nokia:test:addrbook:2004-09\"><ab:QueryItem><ab:Select>/ab:Card[containts[ab:N/ab:FAMILY,\'Bob\'] or containts[ab:N/ab:GIVEN,\'Bob\'] or containts[ab:TEL,\'Bob\']]</ab:Select></ab:QueryItem></ab:Query>"); |
|
599 |
|
600 TInt transactionIdOrError = ipConnection->SendL(KRequest); |
|
601 |
|
602 LOCAL_ASSERT(transactionIdOrError > KErrNone); |
|
603 |
|
604 // Invoke service ONCE (one call to ServiceL), respond to consumer ONCE => two calls |
|
605 StartActiveScheduler(2); |
|
606 |
|
607 // ---- Following conditions MUST be met ---- |
|
608 |
|
609 // 1. Hostlet receives request that consumer made |
|
610 LOCAL_ASSERT( *ipHostlet->iRequests[0] == KRequest); |
|
611 |
|
612 // 2. Consumer receives response that hostlet provided |
|
613 LOCAL_ASSERT( *ipConsumer->iResponses[0] == *ipHostlet->iResponses[0]); |
|
614 LOCAL_ASSERT( ipConsumer->iResponseCodes[0] == ipHostlet->iResponseCodes[0]) |
|
615 |
|
616 // 3. Hostlet receives completion code (delivery code) |
|
617 LOCAL_ASSERT( ipHostlet->iTxnIds[0] == transactionIdOrError ); |
|
618 LOCAL_ASSERT( ipHostlet->iCompletionCodes[0] == KErrNone ); // true in this "OK" -test case |
|
619 |
|
620 // --- Conditions END --- |
|
621 |
|
622 delete ipConnection; |
|
623 ipConnection = NULL; |
|
624 delete ipHostletConnection; |
|
625 ipHostletConnection = NULL; |
|
626 delete ipHostlet; |
|
627 ipHostlet = NULL; |
|
628 delete ipConsumer; |
|
629 ipConsumer = NULL; |
|
630 |
|
631 return KErrNone; |
|
632 } |
|
633 |
|
634 |
|
635 TInt ChostconnTester::UT_CSenHostletConnection_NewLCL(CStifItemParser& aItem) |
|
636 { |
|
637 |
|
638 ipHostlet = CTestHostlet::NewL(this); // uses default implementations for servicel and onservicecompletel |
|
639 ipConsumer = CTestConsumer::NewL(this); // uses the default implementations for setstatus, handlemessage, handleerror |
|
640 |
|
641 // ipHostlet = CTestHostlet::NewL(this, |
|
642 // &ChostconnTester::UT_CSenHostletConnection_NewLL_OnServiceL, |
|
643 // &ChostconnTester::UT_CSenHostletConnection_NewLL_OnServiceCompleteL); |
|
644 |
|
645 // ipConsumer = CTestConsumer::NewL(this, |
|
646 // &ChostconnTester::UT_CSenHostletConnection_NewLL_HandleMessageL, |
|
647 // &ChostconnTester::UT_CSenHostletConnection_NewLL_HandleErrorL, |
|
648 // &ChostconnTester::UT_CSenHostletConnection_NewLL_SetStatus); |
|
649 |
|
650 ipHostletConnection = CSenHostletConnection::NewLC(*ipHostlet); |
|
651 |
|
652 CSenServicePattern* pPattern = |
|
653 CSenServicePattern::NewLC(KNullDesC8, KHostletContract); |
|
654 pPattern->SetFrameworkIdL(KDefaultRestServicesFrameworkID); |
|
655 |
|
656 ipConnection = CSenServiceConnection::NewL(*ipConsumer, *pPattern); |
|
657 CleanupStack::PopAndDestroy(pPattern); |
|
658 |
|
659 // Construct service connection |
|
660 StartActiveScheduler(1); |
|
661 |
|
662 _LIT8(KRequest, "<ab:Query xmlns:ab=\"urn:nokia:test:addrbook:2004-09\"><ab:QueryItem><ab:Select>/ab:Card[containts[ab:N/ab:FAMILY,\'Bob\'] or containts[ab:N/ab:GIVEN,\'Bob\'] or containts[ab:TEL,\'Bob\']]</ab:Select></ab:QueryItem></ab:Query>"); |
|
663 |
|
664 TInt transactionIdOrError = ipConnection->SendL(KRequest); |
|
665 |
|
666 LOCAL_ASSERT(transactionIdOrError > KErrNone); |
|
667 |
|
668 // Invoke service ONCE (one call to ServiceL), respond to consumer ONCE => two calls |
|
669 StartActiveScheduler(2); |
|
670 |
|
671 // ---- Following conditions MUST be met ---- |
|
672 |
|
673 // 1. Hostlet receives request that consumer made |
|
674 LOCAL_ASSERT( *ipHostlet->iRequests[0] == KRequest); |
|
675 |
|
676 // 2. Consumer receives response that hostlet provided |
|
677 LOCAL_ASSERT( *ipConsumer->iResponses[0] == *ipHostlet->iResponses[0]); |
|
678 LOCAL_ASSERT( ipConsumer->iResponseCodes[0] == ipHostlet->iResponseCodes[0]) |
|
679 |
|
680 // 3. Hostlet receives completion code (delivery code) |
|
681 LOCAL_ASSERT( ipHostlet->iTxnIds[0] == transactionIdOrError ); |
|
682 LOCAL_ASSERT( ipHostlet->iCompletionCodes[0] == KErrNone ); // true in this "OK" -test case |
|
683 |
|
684 // --- Conditions END --- |
|
685 |
|
686 delete ipConnection; |
|
687 ipConnection = NULL; |
|
688 CleanupStack::PopAndDestroy(ipHostletConnection); |
|
689 //delete ipHostletConnection; |
|
690 //ipHostletConnection = NULL; |
|
691 delete ipHostlet; |
|
692 ipHostlet = NULL; |
|
693 delete ipConsumer; |
|
694 ipConsumer = NULL; |
|
695 |
|
696 return KErrNone; |
|
697 } |
|
698 TInt ChostconnTester::UT_CSenHostletConnection_IdentifierL(CStifItemParser& aItem ) |
|
699 { |
|
700 |
|
701 ipHostlet = CTestHostlet::NewL(this); // uses default implementations for servicel and onservicecompletel |
|
702 ipConsumer = CTestConsumer::NewL(this); // uses the default implementations for setstatus, handlemessage, handleerror |
|
703 |
|
704 // ipHostlet = CTestHostlet::NewL(this, |
|
705 // &ChostconnTester::UT_CSenHostletConnection_NewLL_OnServiceL, |
|
706 // &ChostconnTester::UT_CSenHostletConnection_NewLL_OnServiceCompleteL); |
|
707 |
|
708 // ipConsumer = CTestConsumer::NewL(this, |
|
709 // &ChostconnTester::UT_CSenHostletConnection_NewLL_HandleMessageL, |
|
710 // &ChostconnTester::UT_CSenHostletConnection_NewLL_HandleErrorL, |
|
711 // &ChostconnTester::UT_CSenHostletConnection_NewLL_SetStatus); |
|
712 |
|
713 ipHostletConnection = CSenHostletConnection::NewL(*ipHostlet); |
|
714 |
|
715 CSenServicePattern* pPattern = |
|
716 CSenServicePattern::NewLC(KNullDesC8, KHostletContract); |
|
717 pPattern->SetFrameworkIdL(KDefaultRestServicesFrameworkID); |
|
718 |
|
719 ipConnection = CSenServiceConnection::NewL(*ipConsumer, *pPattern); |
|
720 CleanupStack::PopAndDestroy(pPattern); |
|
721 |
|
722 TInt id; |
|
723 id = ipHostletConnection->Identifier(); |
|
724 LOCAL_ASSERT( id != KErrNotReady); |
|
725 TPtrC8 framework = ipHostlet->FrameworkId(); |
|
726 // Construct service connection |
|
727 StartActiveScheduler(1); |
|
728 |
|
729 _LIT8(KRequest, "<ab:Query xmlns:ab=\"urn:nokia:test:addrbook:2004-09\"><ab:QueryItem><ab:Select>/ab:Card[containts[ab:N/ab:FAMILY,\'Bob\'] or containts[ab:N/ab:GIVEN,\'Bob\'] or containts[ab:TEL,\'Bob\']]</ab:Select></ab:QueryItem></ab:Query>"); |
|
730 |
|
731 TInt transactionIdOrError = ipConnection->SendL(KRequest); |
|
732 |
|
733 LOCAL_ASSERT(transactionIdOrError > KErrNone); |
|
734 |
|
735 // Invoke service ONCE (one call to ServiceL), respond to consumer ONCE => two calls |
|
736 StartActiveScheduler(2); |
|
737 |
|
738 // ---- Following conditions MUST be met ---- |
|
739 |
|
740 // 1. Hostlet receives request that consumer made |
|
741 LOCAL_ASSERT( *ipHostlet->iRequests[0] == KRequest); |
|
742 |
|
743 // 2. Consumer receives response that hostlet provided |
|
744 LOCAL_ASSERT( *ipConsumer->iResponses[0] == *ipHostlet->iResponses[0]); |
|
745 LOCAL_ASSERT( ipConsumer->iResponseCodes[0] == ipHostlet->iResponseCodes[0]) |
|
746 |
|
747 // 3. Hostlet receives completion code (delivery code) |
|
748 LOCAL_ASSERT( ipHostlet->iTxnIds[0] == transactionIdOrError ); |
|
749 LOCAL_ASSERT( ipHostlet->iCompletionCodes[0] == KErrNone ); // true in this "OK" -test case |
|
750 |
|
751 // --- Conditions END --- |
|
752 |
|
753 delete ipConnection; |
|
754 ipConnection = NULL; |
|
755 delete ipHostletConnection; |
|
756 ipHostletConnection = NULL; |
|
757 delete ipHostlet; |
|
758 ipHostlet = NULL; |
|
759 delete ipConsumer; |
|
760 ipConsumer = NULL; |
|
761 |
|
762 return KErrNone; |
|
763 } |
|
764 |
|
765 TInt ChostconnTester::UT_CSenHostletConnection_FrameworkIdL(CStifItemParser& aItem ) |
|
766 { |
|
767 ipHostlet = CTestHostlet::NewL(this); // uses default implementations for servicel and onservicecompletel |
|
768 ipConsumer = CTestConsumer::NewL(this); // uses the default implementations for setstatus, handlemessage, handleerror |
|
769 |
|
770 // ipHostlet = CTestHostlet::NewL(this, |
|
771 // &ChostconnTester::UT_CSenHostletConnection_NewLL_OnServiceL, |
|
772 // &ChostconnTester::UT_CSenHostletConnection_NewLL_OnServiceCompleteL); |
|
773 |
|
774 // ipConsumer = CTestConsumer::NewL(this, |
|
775 // &ChostconnTester::UT_CSenHostletConnection_NewLL_HandleMessageL, |
|
776 // &ChostconnTester::UT_CSenHostletConnection_NewLL_HandleErrorL, |
|
777 // &ChostconnTester::UT_CSenHostletConnection_NewLL_SetStatus); |
|
778 |
|
779 ipHostletConnection = CSenHostletConnection::NewL(*ipHostlet); |
|
780 |
|
781 CSenServicePattern* pPattern = |
|
782 CSenServicePattern::NewLC(KNullDesC8, KHostletContract); |
|
783 pPattern->SetFrameworkIdL(KDefaultRestServicesFrameworkID); |
|
784 |
|
785 ipConnection = CSenServiceConnection::NewL(*ipConsumer, *pPattern); |
|
786 CleanupStack::PopAndDestroy(pPattern); |
|
787 |
|
788 TInt id; |
|
789 id = ipHostletConnection->Identifier(); |
|
790 LOCAL_ASSERT( id != KErrNotReady); |
|
791 _LIT8(KFramework, "REST"); |
|
792 TPtrC8 framework = ipHostlet->FrameworkId(); |
|
793 LOCAL_ASSERT( framework == KFramework); |
|
794 // Construct service connection |
|
795 StartActiveScheduler(1); |
|
796 |
|
797 _LIT8(KRequest, "<ab:Query xmlns:ab=\"urn:nokia:test:addrbook:2004-09\"><ab:QueryItem><ab:Select>/ab:Card[containts[ab:N/ab:FAMILY,\'Bob\'] or containts[ab:N/ab:GIVEN,\'Bob\'] or containts[ab:TEL,\'Bob\']]</ab:Select></ab:QueryItem></ab:Query>"); |
|
798 |
|
799 TInt transactionIdOrError = ipConnection->SendL(KRequest); |
|
800 |
|
801 LOCAL_ASSERT(transactionIdOrError > KErrNone); |
|
802 |
|
803 // Invoke service ONCE (one call to ServiceL), respond to consumer ONCE => two calls |
|
804 StartActiveScheduler(2); |
|
805 |
|
806 // ---- Following conditions MUST be met ---- |
|
807 |
|
808 // 1. Hostlet receives request that consumer made |
|
809 LOCAL_ASSERT( *ipHostlet->iRequests[0] == KRequest); |
|
810 |
|
811 // 2. Consumer receives response that hostlet provided |
|
812 LOCAL_ASSERT( *ipConsumer->iResponses[0] == *ipHostlet->iResponses[0]); |
|
813 LOCAL_ASSERT( ipConsumer->iResponseCodes[0] == ipHostlet->iResponseCodes[0]) |
|
814 |
|
815 // 3. Hostlet receives completion code (delivery code) |
|
816 LOCAL_ASSERT( ipHostlet->iTxnIds[0] == transactionIdOrError ); |
|
817 LOCAL_ASSERT( ipHostlet->iCompletionCodes[0] == KErrNone ); // true in this "OK" -test case |
|
818 |
|
819 // --- Conditions END --- |
|
820 |
|
821 delete ipConnection; |
|
822 ipConnection = NULL; |
|
823 delete ipHostletConnection; |
|
824 ipHostletConnection = NULL; |
|
825 delete ipHostlet; |
|
826 ipHostlet = NULL; |
|
827 delete ipConsumer; |
|
828 ipConsumer = NULL; |
|
829 |
|
830 return KErrNone; |
|
831 } |
|
832 |
|
833 TInt ChostconnTester::UT_CSenHostletConnection_RequestUtf8L(CStifItemParser& aItem ) |
|
834 { |
|
835 |
|
836 ipHostlet = CTestHostlet::NewL(this); // uses default implementations for servicel and onservicecompletel |
|
837 ipConsumer = CTestConsumer::NewL(this); // uses the default implementations for setstatus, handlemessage, handleerror |
|
838 |
|
839 // ipHostlet = CTestHostlet::NewL(this, |
|
840 // &ChostconnTester::UT_CSenHostletConnection_NewLL_OnServiceL, |
|
841 // &ChostconnTester::UT_CSenHostletConnection_NewLL_OnServiceCompleteL); |
|
842 |
|
843 // ipConsumer = CTestConsumer::NewL(this, |
|
844 // &ChostconnTester::UT_CSenHostletConnection_NewLL_HandleMessageL, |
|
845 // &ChostconnTester::UT_CSenHostletConnection_NewLL_HandleErrorL, |
|
846 // &ChostconnTester::UT_CSenHostletConnection_NewLL_SetStatus); |
|
847 |
|
848 ipHostletConnection = CSenHostletConnection::NewL(*ipHostlet); |
|
849 |
|
850 CSenServicePattern* pPattern = |
|
851 CSenServicePattern::NewLC(KNullDesC8, KHostletContract); |
|
852 pPattern->SetFrameworkIdL(KDefaultRestServicesFrameworkID); |
|
853 |
|
854 ipConnection = CSenServiceConnection::NewL(*ipConsumer, *pPattern); |
|
855 CleanupStack::PopAndDestroy(pPattern); |
|
856 |
|
857 TInt id; |
|
858 id = ipHostletConnection->Identifier(); |
|
859 LOCAL_ASSERT( id != KErrNotReady); |
|
860 TPtrC8 request = ipHostlet->RequestUtf8(); |
|
861 LOCAL_ASSERT( request == _L8("")); |
|
862 // Construct service connection |
|
863 StartActiveScheduler(1); |
|
864 |
|
865 _LIT8(KRequest, "<ab:Query xmlns:ab=\"urn:nokia:test:addrbook:2004-09\"><ab:QueryItem><ab:Select>/ab:Card[containts[ab:N/ab:FAMILY,\'Bob\'] or containts[ab:N/ab:GIVEN,\'Bob\'] or containts[ab:TEL,\'Bob\']]</ab:Select></ab:QueryItem></ab:Query>"); |
|
866 |
|
867 TInt transactionIdOrError = ipConnection->SendL(KRequest); |
|
868 |
|
869 LOCAL_ASSERT(transactionIdOrError > KErrNone); |
|
870 |
|
871 // Invoke service ONCE (one call to ServiceL), respond to consumer ONCE => two calls |
|
872 StartActiveScheduler(2); |
|
873 |
|
874 // ---- Following conditions MUST be met ---- |
|
875 |
|
876 // 1. Hostlet receives request that consumer made |
|
877 LOCAL_ASSERT( *ipHostlet->iRequests[0] == KRequest); |
|
878 |
|
879 // 2. Consumer receives response that hostlet provided |
|
880 LOCAL_ASSERT( *ipConsumer->iResponses[0] == *ipHostlet->iResponses[0]); |
|
881 LOCAL_ASSERT( ipConsumer->iResponseCodes[0] == ipHostlet->iResponseCodes[0]) |
|
882 |
|
883 // 3. Hostlet receives completion code (delivery code) |
|
884 LOCAL_ASSERT( ipHostlet->iTxnIds[0] == transactionIdOrError ); |
|
885 LOCAL_ASSERT( ipHostlet->iCompletionCodes[0] == KErrNone ); // true in this "OK" -test case |
|
886 |
|
887 // --- Conditions END --- |
|
888 |
|
889 delete ipConnection; |
|
890 ipConnection = NULL; |
|
891 delete ipHostletConnection; |
|
892 ipHostletConnection = NULL; |
|
893 delete ipHostlet; |
|
894 ipHostlet = NULL; |
|
895 delete ipConsumer; |
|
896 ipConsumer = NULL; |
|
897 |
|
898 return KErrNone; |
|
899 } |
|
900 |
|
901 TInt ChostconnTester::UT_CSenHostletConnection_ThreadIdL(CStifItemParser& aItem ) |
|
902 { |
|
903 |
|
904 ipHostlet = CTestHostlet::NewL(this); // uses default implementations for servicel and onservicecompletel |
|
905 ipConsumer = CTestConsumer::NewL(this); // uses the default implementations for setstatus, handlemessage, handleerror |
|
906 |
|
907 // ipHostlet = CTestHostlet::NewL(this, |
|
908 // &ChostconnTester::UT_CSenHostletConnection_NewLL_OnServiceL, |
|
909 // &ChostconnTester::UT_CSenHostletConnection_NewLL_OnServiceCompleteL); |
|
910 |
|
911 // ipConsumer = CTestConsumer::NewL(this, |
|
912 // &ChostconnTester::UT_CSenHostletConnection_NewLL_HandleMessageL, |
|
913 // &ChostconnTester::UT_CSenHostletConnection_NewLL_HandleErrorL, |
|
914 // &ChostconnTester::UT_CSenHostletConnection_NewLL_SetStatus); |
|
915 |
|
916 ipHostletConnection = CSenHostletConnection::NewL(*ipHostlet); |
|
917 |
|
918 CSenServicePattern* pPattern = |
|
919 CSenServicePattern::NewLC(KNullDesC8, KHostletContract); |
|
920 pPattern->SetFrameworkIdL(KDefaultRestServicesFrameworkID); |
|
921 |
|
922 ipConnection = CSenServiceConnection::NewL(*ipConsumer, *pPattern); |
|
923 CleanupStack::PopAndDestroy(pPattern); |
|
924 |
|
925 TInt id; |
|
926 id = ipHostletConnection->Identifier(); |
|
927 LOCAL_ASSERT( id != KErrNotReady); |
|
928 TPtrC threadId = ipHostlet->ThreadId(); |
|
929 LOCAL_ASSERT( threadId == _L("")); |
|
930 // Construct service connection |
|
931 StartActiveScheduler(1); |
|
932 |
|
933 _LIT8(KRequest, "<ab:Query xmlns:ab=\"urn:nokia:test:addrbook:2004-09\"><ab:QueryItem><ab:Select>/ab:Card[containts[ab:N/ab:FAMILY,\'Bob\'] or containts[ab:N/ab:GIVEN,\'Bob\'] or containts[ab:TEL,\'Bob\']]</ab:Select></ab:QueryItem></ab:Query>"); |
|
934 |
|
935 TInt transactionIdOrError = ipConnection->SendL(KRequest); |
|
936 |
|
937 LOCAL_ASSERT(transactionIdOrError > KErrNone); |
|
938 |
|
939 // Invoke service ONCE (one call to ServiceL), respond to consumer ONCE => two calls |
|
940 StartActiveScheduler(2); |
|
941 |
|
942 // ---- Following conditions MUST be met ---- |
|
943 |
|
944 // 1. Hostlet receives request that consumer made |
|
945 LOCAL_ASSERT( *ipHostlet->iRequests[0] == KRequest); |
|
946 |
|
947 // 2. Consumer receives response that hostlet provided |
|
948 LOCAL_ASSERT( *ipConsumer->iResponses[0] == *ipHostlet->iResponses[0]); |
|
949 LOCAL_ASSERT( ipConsumer->iResponseCodes[0] == ipHostlet->iResponseCodes[0]) |
|
950 |
|
951 // 3. Hostlet receives completion code (delivery code) |
|
952 LOCAL_ASSERT( ipHostlet->iTxnIds[0] == transactionIdOrError ); |
|
953 LOCAL_ASSERT( ipHostlet->iCompletionCodes[0] == KErrNone ); // true in this "OK" -test case |
|
954 |
|
955 // --- Conditions END --- |
|
956 |
|
957 delete ipConnection; |
|
958 ipConnection = NULL; |
|
959 delete ipHostletConnection; |
|
960 ipHostletConnection = NULL; |
|
961 delete ipHostlet; |
|
962 ipHostlet = NULL; |
|
963 delete ipConsumer; |
|
964 ipConsumer = NULL; |
|
965 |
|
966 return KErrNone; |
|
967 } |
|
968 TInt ChostconnTester::UT_CSenHostletConnection_ConsumerIdL(CStifItemParser& aItem ) |
|
969 { |
|
970 |
|
971 ipHostlet = CTestHostlet::NewL(this); // uses default implementations for servicel and onservicecompletel |
|
972 ipConsumer = CTestConsumer::NewL(this); // uses the default implementations for setstatus, handlemessage, handleerror |
|
973 |
|
974 // ipHostlet = CTestHostlet::NewL(this, |
|
975 // &ChostconnTester::UT_CSenHostletConnection_NewLL_OnServiceL, |
|
976 // &ChostconnTester::UT_CSenHostletConnection_NewLL_OnServiceCompleteL); |
|
977 |
|
978 // ipConsumer = CTestConsumer::NewL(this, |
|
979 // &ChostconnTester::UT_CSenHostletConnection_NewLL_HandleMessageL, |
|
980 // &ChostconnTester::UT_CSenHostletConnection_NewLL_HandleErrorL, |
|
981 // &ChostconnTester::UT_CSenHostletConnection_NewLL_SetStatus); |
|
982 |
|
983 ipHostletConnection = CSenHostletConnection::NewL(*ipHostlet); |
|
984 |
|
985 CSenServicePattern* pPattern = |
|
986 CSenServicePattern::NewLC(KNullDesC8, KHostletContract); |
|
987 pPattern->SetFrameworkIdL(KDefaultRestServicesFrameworkID); |
|
988 |
|
989 ipConnection = CSenServiceConnection::NewL(*ipConsumer, *pPattern); |
|
990 CleanupStack::PopAndDestroy(pPattern); |
|
991 |
|
992 TInt id; |
|
993 id = ipHostletConnection->Identifier(); |
|
994 LOCAL_ASSERT( id != KErrNotReady); |
|
995 TPtrC8 consumerId = ipHostlet->ConsumerId(); |
|
996 LOCAL_ASSERT( consumerId == _L8("")); |
|
997 // Construct service connection |
|
998 StartActiveScheduler(1); |
|
999 |
|
1000 _LIT8(KRequest, "<ab:Query xmlns:ab=\"urn:nokia:test:addrbook:2004-09\"><ab:QueryItem><ab:Select>/ab:Card[containts[ab:N/ab:FAMILY,\'Bob\'] or containts[ab:N/ab:GIVEN,\'Bob\'] or containts[ab:TEL,\'Bob\']]</ab:Select></ab:QueryItem></ab:Query>"); |
|
1001 |
|
1002 TInt transactionIdOrError = ipConnection->SendL(KRequest); |
|
1003 |
|
1004 LOCAL_ASSERT(transactionIdOrError > KErrNone); |
|
1005 |
|
1006 // Invoke service ONCE (one call to ServiceL), respond to consumer ONCE => two calls |
|
1007 StartActiveScheduler(2); |
|
1008 |
|
1009 // ---- Following conditions MUST be met ---- |
|
1010 |
|
1011 // 1. Hostlet receives request that consumer made |
|
1012 LOCAL_ASSERT( *ipHostlet->iRequests[0] == KRequest); |
|
1013 |
|
1014 // 2. Consumer receives response that hostlet provided |
|
1015 LOCAL_ASSERT( *ipConsumer->iResponses[0] == *ipHostlet->iResponses[0]); |
|
1016 LOCAL_ASSERT( ipConsumer->iResponseCodes[0] == ipHostlet->iResponseCodes[0]) |
|
1017 |
|
1018 // 3. Hostlet receives completion code (delivery code) |
|
1019 LOCAL_ASSERT( ipHostlet->iTxnIds[0] == transactionIdOrError ); |
|
1020 LOCAL_ASSERT( ipHostlet->iCompletionCodes[0] == KErrNone ); // true in this "OK" -test case |
|
1021 |
|
1022 // --- Conditions END --- |
|
1023 |
|
1024 delete ipConnection; |
|
1025 ipConnection = NULL; |
|
1026 delete ipHostletConnection; |
|
1027 ipHostletConnection = NULL; |
|
1028 delete ipHostlet; |
|
1029 ipHostlet = NULL; |
|
1030 delete ipConsumer; |
|
1031 ipConsumer = NULL; |
|
1032 |
|
1033 return KErrNone; |
|
1034 } |
|
1035 TInt ChostconnTester::UT_CSenHostletConnection_RequestIdL(CStifItemParser& aItem ) |
|
1036 { |
|
1037 |
|
1038 ipHostlet = CTestHostlet::NewL(this); // uses default implementations for servicel and onservicecompletel |
|
1039 ipConsumer = CTestConsumer::NewL(this); // uses the default implementations for setstatus, handlemessage, handleerror |
|
1040 |
|
1041 // ipHostlet = CTestHostlet::NewL(this, |
|
1042 // &ChostconnTester::UT_CSenHostletConnection_NewLL_OnServiceL, |
|
1043 // &ChostconnTester::UT_CSenHostletConnection_NewLL_OnServiceCompleteL); |
|
1044 |
|
1045 // ipConsumer = CTestConsumer::NewL(this, |
|
1046 // &ChostconnTester::UT_CSenHostletConnection_NewLL_HandleMessageL, |
|
1047 // &ChostconnTester::UT_CSenHostletConnection_NewLL_HandleErrorL, |
|
1048 // &ChostconnTester::UT_CSenHostletConnection_NewLL_SetStatus); |
|
1049 |
|
1050 ipHostletConnection = CSenHostletConnection::NewL(*ipHostlet); |
|
1051 |
|
1052 CSenServicePattern* pPattern = |
|
1053 CSenServicePattern::NewLC(KNullDesC8, KHostletContract); |
|
1054 pPattern->SetFrameworkIdL(KDefaultRestServicesFrameworkID); |
|
1055 |
|
1056 ipConnection = CSenServiceConnection::NewL(*ipConsumer, *pPattern); |
|
1057 CleanupStack::PopAndDestroy(pPattern); |
|
1058 |
|
1059 TInt id; |
|
1060 id = ipHostletConnection->Identifier(); |
|
1061 LOCAL_ASSERT( id != KErrNotReady); |
|
1062 TInt requestId = ipHostlet->RequestId(); |
|
1063 LOCAL_ASSERT( requestId == KErrNone); |
|
1064 // Construct service connection |
|
1065 StartActiveScheduler(1); |
|
1066 |
|
1067 _LIT8(KRequest, "<ab:Query xmlns:ab=\"urn:nokia:test:addrbook:2004-09\"><ab:QueryItem><ab:Select>/ab:Card[containts[ab:N/ab:FAMILY,\'Bob\'] or containts[ab:N/ab:GIVEN,\'Bob\'] or containts[ab:TEL,\'Bob\']]</ab:Select></ab:QueryItem></ab:Query>"); |
|
1068 |
|
1069 TInt transactionIdOrError = ipConnection->SendL(KRequest); |
|
1070 |
|
1071 LOCAL_ASSERT(transactionIdOrError > KErrNone); |
|
1072 |
|
1073 // Invoke service ONCE (one call to ServiceL), respond to consumer ONCE => two calls |
|
1074 StartActiveScheduler(2); |
|
1075 |
|
1076 // ---- Following conditions MUST be met ---- |
|
1077 |
|
1078 // 1. Hostlet receives request that consumer made |
|
1079 LOCAL_ASSERT( *ipHostlet->iRequests[0] == KRequest); |
|
1080 |
|
1081 // 2. Consumer receives response that hostlet provided |
|
1082 LOCAL_ASSERT( *ipConsumer->iResponses[0] == *ipHostlet->iResponses[0]); |
|
1083 LOCAL_ASSERT( ipConsumer->iResponseCodes[0] == ipHostlet->iResponseCodes[0]) |
|
1084 |
|
1085 // 3. Hostlet receives completion code (delivery code) |
|
1086 LOCAL_ASSERT( ipHostlet->iTxnIds[0] == transactionIdOrError ); |
|
1087 LOCAL_ASSERT( ipHostlet->iCompletionCodes[0] == KErrNone ); // true in this "OK" -test case |
|
1088 |
|
1089 // --- Conditions END --- |
|
1090 |
|
1091 delete ipConnection; |
|
1092 ipConnection = NULL; |
|
1093 delete ipHostletConnection; |
|
1094 ipHostletConnection = NULL; |
|
1095 delete ipHostlet; |
|
1096 ipHostlet = NULL; |
|
1097 delete ipConsumer; |
|
1098 ipConsumer = NULL; |
|
1099 |
|
1100 return KErrNone; |
|
1101 } |
|
1102 |
|
1103 |
|
1104 |
|
1105 TInt ChostconnTester::UT_CSenHostletConnection_NewLC_3InvokesL(CStifItemParser& aItem) |
|
1106 { |
|
1107 |
|
1108 // Try to send _two_ messages from ServiceConnection to HostletConnection |
|
1109 // and check that everything goes OK. |
|
1110 |
|
1111 _LIT8(KRequest, "<ab:Query xmlns:ab=\"urn:nokia:test:addrbook:2004-09\"><ab:QueryItem><ab:Select>/ab:Card[containts[ab:N/ab:FAMILY,\'Abel\'] or containts[ab:N/ab:GIVEN,\'Abel\'] or containts[ab:TEL,\'Abel\']]</ab:Select></ab:QueryItem></ab:Query>"); |
|
1112 _LIT8(KRequest2, "<ab:Query xmlns:ab=\"urn:nokia:test:addrbook:2004-09\"><ab:QueryItem><ab:Select>/ab:Card[containts[ab:N/ab:FAMILY,\'Bob\'] or containts[ab:N/ab:GIVEN,\'Bob\'] or containts[ab:TEL,\'Bob\']]</ab:Select></ab:QueryItem></ab:Query>"); |
|
1113 _LIT8(KRequest3, "<ab:Query xmlns:ab=\"urn:nokia:test:addrbook:2004-09\"><ab:QueryItem><ab:Select>/ab:Card[containts[ab:N/ab:FAMILY,\'Clarice\'] or containts[ab:N/ab:GIVEN,\'Clarice\'] or containts[ab:TEL,\'Clarice\']]</ab:Select></ab:QueryItem></ab:Query>"); |
|
1114 |
|
1115 // Construct Hostlet |
|
1116 ipHostlet = CTestHostlet::NewL(this); // uses default implementations for servicel and onservicecompletel |
|
1117 ipHostletConnection = CSenHostletConnection::NewL(*ipHostlet); |
|
1118 |
|
1119 // Construct ServiceConnection |
|
1120 ipConsumer = CTestConsumer::NewL(this); // uses the default implementations for setstatus, handlemessage, handleerror |
|
1121 CSenServicePattern* pPattern = |
|
1122 CSenServicePattern::NewLC(KNullDesC8, KHostletContract); |
|
1123 pPattern->SetFrameworkIdL(KDefaultRestServicesFrameworkID); |
|
1124 |
|
1125 ipConnection = CSenServiceConnection::NewL(*ipConsumer, *pPattern); |
|
1126 CleanupStack::PopAndDestroy(pPattern); |
|
1127 StartActiveScheduler(1); |
|
1128 |
|
1129 // Check that the Status of the ServiceConnection |
|
1130 // is KSenConnectionStatusReady |
|
1131 LOCAL_ASSERT( ipConsumer->iConnectionStatus == KSenConnectionStatusReady); |
|
1132 |
|
1133 // ServiceConnection is ready |
|
1134 |
|
1135 // => Send first request to the Hostlet |
|
1136 TInt transactionIdOrError = ipConnection->SendL(KRequest); |
|
1137 |
|
1138 // Check that SendL returned transaction Id |
|
1139 LOCAL_ASSERT(transactionIdOrError > KErrNone); |
|
1140 |
|
1141 // => Send second request to the Hostlet |
|
1142 TInt transactionIdOrError2 = ipConnection->SendL(KRequest2); |
|
1143 |
|
1144 // => Send second request to the Hostlet |
|
1145 TInt transactionIdOrError3 = ipConnection->SendL(KRequest3); |
|
1146 |
|
1147 // Check that SendL returned transaction Id |
|
1148 LOCAL_ASSERT(transactionIdOrError > KErrNone); |
|
1149 |
|
1150 // Invoke service THREE TIMES (one call to ServiceL), respond to consumer THREE TIMES => six async calls: |
|
1151 StartActiveScheduler(6); |
|
1152 |
|
1153 // ---- Following conditions MUST be met ---- |
|
1154 |
|
1155 // 1. Hostlet receives request that consumer made |
|
1156 LOCAL_ASSERT(*ipHostlet->iRequests[0] == KRequest); |
|
1157 LOCAL_ASSERT(*ipHostlet->iRequests[1] == KRequest2); |
|
1158 LOCAL_ASSERT(*ipHostlet->iRequests[2] == KRequest3); |
|
1159 |
|
1160 // 2. Consumer receives response that hostlet provided |
|
1161 LOCAL_ASSERT( *ipConsumer->iResponses[0] == *ipHostlet->iResponses[0]); |
|
1162 LOCAL_ASSERT( *ipConsumer->iResponses[1] == *ipHostlet->iResponses[1]); |
|
1163 LOCAL_ASSERT( *ipConsumer->iResponses[2] == *ipHostlet->iResponses[2]); |
|
1164 |
|
1165 // 3. Hostlet receives completion code (delivery code) |
|
1166 LOCAL_ASSERT( ipConsumer->iResponseCodes[0] == ipHostlet->iResponseCodes[0]) |
|
1167 LOCAL_ASSERT( ipConsumer->iResponseCodes[1] == ipHostlet->iResponseCodes[1]) |
|
1168 LOCAL_ASSERT( ipConsumer->iResponseCodes[2] == ipHostlet->iResponseCodes[2]) |
|
1169 |
|
1170 |
|
1171 LOCAL_ASSERT( ipHostlet->iTxnIds[0] == transactionIdOrError); |
|
1172 LOCAL_ASSERT( ipHostlet->iTxnIds[1] == transactionIdOrError2); |
|
1173 LOCAL_ASSERT( ipHostlet->iTxnIds[2] == transactionIdOrError3); |
|
1174 |
|
1175 |
|
1176 // --- Conditions END --- |
|
1177 |
|
1178 delete ipConnection; |
|
1179 ipConnection = NULL; |
|
1180 delete ipHostletConnection; |
|
1181 ipHostletConnection = NULL; |
|
1182 delete ipHostlet; |
|
1183 ipHostlet = NULL; |
|
1184 delete ipConsumer; |
|
1185 ipConsumer = NULL; |
|
1186 |
|
1187 return KErrNone; |
|
1188 } |
|
1189 |
|
1190 |
|
1191 TInt ChostconnTester::UT_CSenHostletConnection_RespondL1L(CStifItemParser& aItem) |
|
1192 { |
|
1193 |
|
1194 // Try to send _one_ message from ServiceConnection to HostletConnection |
|
1195 // and check that everything goes OK. |
|
1196 |
|
1197 // Construct Hostlet |
|
1198 ipHostlet = CTestHostlet::NewL(this); // uses default implementations for servicel and onservicecompletel |
|
1199 ipHostletConnection = CSenHostletConnection::NewL(*ipHostlet); |
|
1200 |
|
1201 // Construct ServiceConnection |
|
1202 ipConsumer = CTestConsumer::NewL(this); // uses the default implementations for setstatus, handlemessage, handleerror |
|
1203 CSenServicePattern* pPattern = |
|
1204 CSenServicePattern::NewLC(KNullDesC8, KHostletContract); |
|
1205 pPattern->SetFrameworkIdL(KDefaultRestServicesFrameworkID); |
|
1206 |
|
1207 ipConnection = CSenServiceConnection::NewL(*ipConsumer, *pPattern); |
|
1208 CleanupStack::PopAndDestroy(pPattern); |
|
1209 StartActiveScheduler(1); |
|
1210 |
|
1211 // Check that the Status of the ServiceConnection |
|
1212 // is KSenConnectionStatusReady |
|
1213 LOCAL_ASSERT( ipConsumer->iConnectionStatus == KSenConnectionStatusReady); |
|
1214 |
|
1215 |
|
1216 CSenTransportProperties* pProps = CSenTransportProperties::NewLC(); |
|
1217 pProps->SetPropertyL(_L8("KTestProperty"), _L8("KTestPropertyValue")); |
|
1218 HBufC8* pPropsAsXml = pProps->AsUtf8LC(); |
|
1219 TPtrC8 propertiesAsXml = pPropsAsXml->Des(); |
|
1220 |
|
1221 // ServiceConnection is ready |
|
1222 // => Send request to the Hostlet |
|
1223 _LIT8(KRequest, "<ab:Query xmlns:ab=\"urn:nokia:test:addrbook:2004-09\"><ab:QueryItem><ab:Select>/ab:Card[containts[ab:N/ab:FAMILY,\'Bob\'] or containts[ab:N/ab:GIVEN,\'Bob\'] or containts[ab:TEL,\'Bob\']]</ab:Select></ab:QueryItem></ab:Query>"); |
|
1224 TInt transactionIdOrError = ipConnection->SendL(KRequest, propertiesAsXml); |
|
1225 |
|
1226 // Check that SendL returned transaction Id |
|
1227 LOCAL_ASSERT(transactionIdOrError > KErrNone); |
|
1228 |
|
1229 // Invoke service ONCE (one call to ServiceL), respond to consumer ONCE => two calls |
|
1230 StartActiveScheduler(2); |
|
1231 |
|
1232 // ---- Following conditions MUST be met ---- |
|
1233 |
|
1234 // 1. Hostlet receives request that consumer made |
|
1235 LOCAL_ASSERT( *ipHostlet->iRequests[0] == KRequest); |
|
1236 |
|
1237 // 2. Consumer receives response that hostlet provided |
|
1238 LOCAL_ASSERT( *ipConsumer->iResponses[0] == *ipHostlet->iResponses[0]); |
|
1239 LOCAL_ASSERT( ipConsumer->iResponseCodes[0] == ipHostlet->iResponseCodes[0]) |
|
1240 |
|
1241 // 3. Hostlet receives completion code (delivery code) |
|
1242 LOCAL_ASSERT( ipHostlet->iTxnIds[0] == transactionIdOrError ); |
|
1243 LOCAL_ASSERT( ipHostlet->iCompletionCodes[0] == KErrNone ); // true in this "OK" -test case |
|
1244 |
|
1245 // 4. The properties that were sent via SC were received in HC |
|
1246 MSenProperties::TSenPropertiesClassType type = ipHostlet->iRequestPropTypes[0]; |
|
1247 TPtrC8 properties = ipHostlet->iRequestProps[0]->Des(); |
|
1248 |
|
1249 LOCAL_ASSERT( properties == propertiesAsXml ); |
|
1250 |
|
1251 // --- Conditions END --- |
|
1252 |
|
1253 CleanupStack::PopAndDestroy( pPropsAsXml ); |
|
1254 CleanupStack::PopAndDestroy( pProps ); |
|
1255 |
|
1256 |
|
1257 delete ipConnection; |
|
1258 ipConnection = NULL; |
|
1259 delete ipHostletConnection; |
|
1260 ipHostletConnection = NULL; |
|
1261 delete ipHostlet; |
|
1262 ipHostlet = NULL; |
|
1263 delete ipConsumer; |
|
1264 ipConsumer = NULL; |
|
1265 |
|
1266 return KErrNone; |
|
1267 } |
|
1268 |
|
1269 |
|
1270 TInt ChostconnTester::UT_CSenHostletConnection_RespondL2L(CStifItemParser& aItem) |
|
1271 { |
|
1272 |
|
1273 // Try to send _two_ messages from ServiceConnection to HostletConnection |
|
1274 // and check that everything goes OK. |
|
1275 |
|
1276 _LIT8(KRequest, "<ab:Query xmlns:ab=\"urn:nokia:test:addrbook:2004-09\"><ab:QueryItem><ab:Select>/ab:Card[containts[ab:N/ab:FAMILY,\'Bob\'] or containts[ab:N/ab:GIVEN,\'Bob\'] or containts[ab:TEL,\'Bob\']]</ab:Select></ab:QueryItem></ab:Query>"); |
|
1277 |
|
1278 // Construct Hostlet |
|
1279 ipHostlet = CTestHostlet::NewL(this); // uses default implementations for servicel and onservicecompletel |
|
1280 ipHostletConnection = CSenHostletConnection::NewL(*ipHostlet); |
|
1281 |
|
1282 // Construct ServiceConnection |
|
1283 ipConsumer = CTestConsumer::NewL(this); // uses the default implementations for setstatus, handlemessage, handleerror |
|
1284 CSenServicePattern* pPattern = |
|
1285 CSenServicePattern::NewLC(KNullDesC8, KHostletContract); |
|
1286 pPattern->SetFrameworkIdL(KDefaultRestServicesFrameworkID); |
|
1287 |
|
1288 ipConnection = CSenServiceConnection::NewL(*ipConsumer, *pPattern); |
|
1289 CleanupStack::PopAndDestroy(pPattern); |
|
1290 StartActiveScheduler(1); |
|
1291 |
|
1292 // Check that the Status of the ServiceConnection |
|
1293 // is KSenConnectionStatusReady |
|
1294 LOCAL_ASSERT( ipConsumer->iConnectionStatus == KSenConnectionStatusReady); |
|
1295 |
|
1296 // ServiceConnection is ready |
|
1297 |
|
1298 // => Send first request to the Hostlet |
|
1299 TInt transactionIdOrError = ipConnection->SendL(KRequest); |
|
1300 |
|
1301 // Check that SendL returned transaction Id |
|
1302 LOCAL_ASSERT(transactionIdOrError > KErrNone); |
|
1303 |
|
1304 // => Send second request to the Hostlet |
|
1305 TInt transactionIdOrError2 = ipConnection->SendL(KRequest); |
|
1306 |
|
1307 // Check that SendL returned transaction Id |
|
1308 LOCAL_ASSERT(transactionIdOrError > KErrNone); |
|
1309 |
|
1310 // Invoke service TWICE (one call to ServiceL), respond to consumer TWICE => four calls: |
|
1311 StartActiveScheduler(4); |
|
1312 |
|
1313 // ---- Following conditions MUST be met ---- |
|
1314 |
|
1315 // 1. Hostlet receives request that consumer made |
|
1316 LOCAL_ASSERT( *ipHostlet->iRequests[0] == KRequest); |
|
1317 LOCAL_ASSERT( *ipHostlet->iRequests[1] == KRequest); |
|
1318 |
|
1319 // 2. Consumer receives response that hostlet provided |
|
1320 LOCAL_ASSERT( *ipConsumer->iResponses[0] == *ipHostlet->iResponses[0]); |
|
1321 LOCAL_ASSERT( *ipConsumer->iResponses[1] == *ipHostlet->iResponses[1]); |
|
1322 |
|
1323 LOCAL_ASSERT( ipConsumer->iResponseCodes[0] == ipHostlet->iResponseCodes[0]) |
|
1324 LOCAL_ASSERT( ipConsumer->iResponseCodes[1] == ipHostlet->iResponseCodes[1]) |
|
1325 |
|
1326 // 3. Hostlet receives completion code (delivery code) |
|
1327 LOCAL_ASSERT( ipHostlet->iTxnIds[0] == transactionIdOrError) |
|
1328 LOCAL_ASSERT( ipHostlet->iTxnIds[1] == transactionIdOrError2) |
|
1329 |
|
1330 LOCAL_ASSERT( ipHostlet->iCompletionCodes[0] == KErrNone ); // true in this "OK" -test case |
|
1331 LOCAL_ASSERT( ipHostlet->iCompletionCodes[1] == KErrNone ); // true in this "OK" -test case |
|
1332 |
|
1333 // --- Conditions END --- |
|
1334 |
|
1335 delete ipConnection; |
|
1336 ipConnection = NULL; |
|
1337 delete ipHostletConnection; |
|
1338 ipHostletConnection = NULL; |
|
1339 delete ipHostlet; |
|
1340 ipHostlet = NULL; |
|
1341 delete ipConsumer; |
|
1342 ipConsumer = NULL; |
|
1343 |
|
1344 return KErrNone; |
|
1345 } |
|
1346 |
|
1347 |
|
1348 TInt ChostconnTester::UT_CSenHostletConnection_RespondL3L(CStifItemParser& aItem) |
|
1349 { |
|
1350 //Memory leak detection is not supported since Symbian 9.0 (EKA2 kernel) environments. |
|
1351 //This this is added to handle thread handle leak in testmodule0 |
|
1352 TestModuleIf().SetBehavior( CTestModuleIf::ETestLeaksHandles); |
|
1353 |
|
1354 // Try to send _one_ message from ServiceConnection to HostletConnection |
|
1355 // and check that everything goes OK. |
|
1356 |
|
1357 // Construct Hostlet |
|
1358 ipHostlet = CTestHostlet::NewL(this); // uses default implementations for servicel and onservicecompletel |
|
1359 ipHostletConnection = CSenHostletConnection::NewL(*ipHostlet); |
|
1360 |
|
1361 // Construct ServiceConnection |
|
1362 ipConsumer = CTestConsumer::NewL(this); // uses the default implementations for setstatus, handlemessage, handleerror |
|
1363 CSenServicePattern* pPattern = |
|
1364 CSenServicePattern::NewLC(KNullDesC8, KHostletContract); |
|
1365 pPattern->SetFrameworkIdL(KDefaultRestServicesFrameworkID); |
|
1366 |
|
1367 ipConnection = CSenServiceConnection::NewL(*ipConsumer, *pPattern); |
|
1368 CleanupStack::PopAndDestroy(pPattern); |
|
1369 StartActiveScheduler(1); |
|
1370 |
|
1371 // Check that the Status of the ServiceConnection |
|
1372 // is KSenConnectionStatusReady |
|
1373 LOCAL_ASSERT( ipConsumer->iConnectionStatus == KSenConnectionStatusReady); |
|
1374 |
|
1375 // Construct 2. ServiceConnection |
|
1376 CTestConsumer* pConsumer2 = CTestConsumer::NewLC(this); // uses the default implementations for setstatus, handlemessage, handleerror |
|
1377 |
|
1378 CSenServicePattern* pPattern2 = |
|
1379 CSenServicePattern::NewLC(KNullDesC8, KHostletContract); |
|
1380 pPattern2->SetFrameworkIdL(KDefaultRestServicesFrameworkID); |
|
1381 CSenServiceConnection* pConnection2 = CSenServiceConnection::NewL(*pConsumer2, *pPattern2); |
|
1382 CleanupStack::PopAndDestroy(pPattern2); |
|
1383 CleanupStack::PushL(pConnection2); |
|
1384 StartActiveScheduler(1); |
|
1385 |
|
1386 // Check that the Status of the ServiceConnection |
|
1387 // is KSenConnectionStatusReady |
|
1388 LOCAL_ASSERT( pConsumer2->iConnectionStatus == KSenConnectionStatusReady); |
|
1389 |
|
1390 CSenTransportProperties* pProps = CSenTransportProperties::NewLC(); |
|
1391 pProps->SetPropertyL(_L8("KTestProperty"), _L8("KTestPropertyValue")); |
|
1392 HBufC8* pPropsAsXml = pProps->AsUtf8LC(); |
|
1393 TPtrC8 propertiesAsXml = pPropsAsXml->Des(); |
|
1394 |
|
1395 // ServiceConnection is ready |
|
1396 // => Send request to the Hostlet |
|
1397 _LIT8(KRequest, "<ab:Query xmlns:ab=\"urn:nokia:test:addrbook:2004-09\"><ab:QueryItem><ab:Select>/ab:Card[containts[ab:N/ab:FAMILY,\'Bob\'] or containts[ab:N/ab:GIVEN,\'Bob\'] or containts[ab:TEL,\'Bob\']]</ab:Select></ab:QueryItem></ab:Query>"); |
|
1398 TInt transactionIdOrError = ipConnection->SendL(KRequest, propertiesAsXml); |
|
1399 |
|
1400 // Check that SendL returned transaction Id |
|
1401 LOCAL_ASSERT(transactionIdOrError > KErrNone); |
|
1402 |
|
1403 // 2. ServiceConnection is ready |
|
1404 // => Send 2. request to the Hostlet |
|
1405 TInt transactionIdOrError2 = pConnection2->SendL(KRequest, propertiesAsXml); |
|
1406 |
|
1407 // Check that SendL returned transaction Id |
|
1408 LOCAL_ASSERT(transactionIdOrError2 > KErrNone); |
|
1409 |
|
1410 // Invoke service TWICE (two calls to ServiceL), respond to consumer TWICE => four calls |
|
1411 StartActiveScheduler(4); |
|
1412 |
|
1413 // ---- Following conditions MUST be met ---- |
|
1414 |
|
1415 // 1. Hostlet receives request that consumer made |
|
1416 LOCAL_ASSERT( *ipHostlet->iRequests[0] == KRequest); |
|
1417 |
|
1418 // 2. Consumer receives response that hostlet provided |
|
1419 LOCAL_ASSERT( *ipConsumer->iResponses[0] == *ipHostlet->iResponses[0]); |
|
1420 LOCAL_ASSERT( ipConsumer->iResponseCodes[0] == ipHostlet->iResponseCodes[0]) |
|
1421 |
|
1422 // 3. Hostlet receives completion code (delivery code) |
|
1423 LOCAL_ASSERT( ipHostlet->iTxnIds[0] == transactionIdOrError ); |
|
1424 LOCAL_ASSERT( ipHostlet->iCompletionCodes[0] == KErrNone ); // true in this "OK" -test case |
|
1425 |
|
1426 // 4. The properties that were sent via SC were received in HC |
|
1427 MSenProperties::TSenPropertiesClassType type = ipHostlet->iRequestPropTypes[0]; |
|
1428 TPtrC8 properties = ipHostlet->iRequestProps[0]->Des(); |
|
1429 |
|
1430 LOCAL_ASSERT( properties == propertiesAsXml ); |
|
1431 |
|
1432 // --- Conditions END --- |
|
1433 |
|
1434 CleanupStack::PopAndDestroy( pPropsAsXml ); |
|
1435 CleanupStack::PopAndDestroy( pProps ); |
|
1436 |
|
1437 |
|
1438 delete ipConnection; |
|
1439 ipConnection = NULL; |
|
1440 delete ipHostletConnection; |
|
1441 ipHostletConnection = NULL; |
|
1442 delete ipHostlet; |
|
1443 ipHostlet = NULL; |
|
1444 delete ipConsumer; |
|
1445 ipConsumer = NULL; |
|
1446 |
|
1447 CleanupStack::PopAndDestroy(pConnection2); |
|
1448 CleanupStack::PopAndDestroy(pConsumer2); |
|
1449 |
|
1450 return KErrNone; |
|
1451 } |
|
1452 |
|
1453 |
|
1454 TInt ChostconnTester::UT_CSenHostletConnection_Negative_ResponseCodeL(CStifItemParser& aItem) |
|
1455 { |
|
1456 |
|
1457 |
|
1458 iWas_HandleErrorL_Accessed = EFalse; |
|
1459 ipHostlet = CTestHostlet::NewL(this, |
|
1460 &ChostconnTester::UT_CSenHostletConnection_NewLL_OnServiceL, |
|
1461 NULL); |
|
1462 |
|
1463 ipConsumer = CTestConsumer::NewL(this, |
|
1464 NULL, |
|
1465 &ChostconnTester::UT_CSenHostletConnection_NewLL_HandleErrorL, |
|
1466 NULL); |
|
1467 |
|
1468 ipHostletConnection = CSenHostletConnection::NewL(*ipHostlet); |
|
1469 |
|
1470 CSenServicePattern* pPattern = |
|
1471 CSenServicePattern::NewLC(KNullDesC8, KHostletContract); |
|
1472 pPattern->SetFrameworkIdL(KDefaultRestServicesFrameworkID); |
|
1473 |
|
1474 ipConnection = CSenServiceConnection::NewL(*ipConsumer, *pPattern); |
|
1475 CleanupStack::PopAndDestroy(pPattern); |
|
1476 |
|
1477 // Construct service connection |
|
1478 StartActiveScheduler(1); |
|
1479 |
|
1480 |
|
1481 _LIT8(KRequest, "<ab:Query xmlns:ab=\"urn:nokia:test:addrbook:2004-09\"><ab:QueryItem><ab:Select>/ab:Card[containts[ab:N/ab:FAMILY,\'Bob\'] or containts[ab:N/ab:GIVEN,\'Bob\'] or containts[ab:TEL,\'Bob\']]</ab:Select></ab:QueryItem></ab:Query>"); |
|
1482 |
|
1483 TInt transactionIdOrError = ipConnection->SendL(KRequest); |
|
1484 LOCAL_ASSERT(transactionIdOrError > KErrNone); |
|
1485 |
|
1486 // Invoke service ONCE (one call to ServiceL), respond to consumer ONCE => two calls |
|
1487 StartActiveScheduler(2); |
|
1488 // ---- Following conditions MUST be met ---- |
|
1489 |
|
1490 // 1. Hostlet receives request that consumer made |
|
1491 LOCAL_ASSERT( *ipHostlet->iRequests[0] == KRequest); |
|
1492 |
|
1493 // 2. Consumer receives response that hostlet provided |
|
1494 |
|
1495 LOCAL_ASSERT( *ipConsumer->iResponses[0] == *ipHostlet->iResponses[0]); |
|
1496 LOCAL_ASSERT( ipConsumer->iResponseCodes[0] == ipHostlet->iResponseCodes[0]) |
|
1497 |
|
1498 |
|
1499 // 3. Hostlet receives completion code (delivery code) |
|
1500 LOCAL_ASSERT( ipHostlet->iTxnIds[0] == transactionIdOrError ); |
|
1501 LOCAL_ASSERT( ipHostlet->iCompletionCodes[0] == KErrNone ); |
|
1502 |
|
1503 //4. HandleErrorL accesed after negative iResponseCodes |
|
1504 LOCAL_ASSERT( iWas_HandleErrorL_Accessed ); |
|
1505 |
|
1506 // --- Conditions END --- |
|
1507 |
|
1508 delete ipConnection; |
|
1509 ipConnection = NULL; |
|
1510 delete ipHostletConnection; |
|
1511 ipHostletConnection = NULL; |
|
1512 delete ipHostlet; |
|
1513 ipHostlet = NULL; |
|
1514 delete ipConsumer; |
|
1515 ipConsumer = NULL; |
|
1516 |
|
1517 return KErrNone; |
|
1518 } |
|
1519 |
|
1520 |
|
1521 |
|
1522 TInt ChostconnTester::UT_CSenHostletConnection_HC_SelfDef_URIL(CStifItemParser& aItem) |
|
1523 { |
|
1524 |
|
1525 |
|
1526 ipHostlet = CTestHostlet::NewL(this); // uses default implementations for servicel and onservicecompletel |
|
1527 ipConsumer = CTestConsumer::NewL(this); // uses the default implementations for setstatus, handlemessage, handleerror |
|
1528 |
|
1529 |
|
1530 ipHostlet->ipHostletDescription->SetEndPointL(KHostletEndpoint); |
|
1531 ipHostletConnection = CSenHostletConnection::NewL(*ipHostlet); |
|
1532 |
|
1533 |
|
1534 CSenServicePattern* pPattern = |
|
1535 CSenServicePattern::NewLC(KHostletEndpoint, KNullDesC8); |
|
1536 |
|
1537 pPattern->SetFrameworkIdL(KDefaultRestServicesFrameworkID); |
|
1538 |
|
1539 |
|
1540 ipConnection = CSenServiceConnection::NewL(*ipConsumer, *pPattern); |
|
1541 CleanupStack::PopAndDestroy(pPattern); |
|
1542 |
|
1543 // Construct service connection |
|
1544 StartActiveScheduler(1); |
|
1545 |
|
1546 // Check that the Status of the ServiceConnection |
|
1547 // is KSenConnectionStatusReady |
|
1548 LOCAL_ASSERT( ipConsumer->iConnectionStatus == KSenConnectionStatusReady); |
|
1549 |
|
1550 _LIT8(KRequest, "<ab:Query xmlns:ab=\"urn:nokia:test:addrbook:2004-09\"><ab:QueryItem><ab:Select>/ab:Card[containts[ab:N/ab:FAMILY,\'Bob\'] or containts[ab:N/ab:GIVEN,\'Bob\'] or containts[ab:TEL,\'Bob\']]</ab:Select></ab:QueryItem></ab:Query>"); |
|
1551 |
|
1552 TInt transactionIdOrError = ipConnection->SendL(KRequest); |
|
1553 LOCAL_ASSERT(transactionIdOrError > KErrNone); |
|
1554 |
|
1555 // Invoke service ONCE (one call to ServiceL), respond to consumer ONCE => two calls |
|
1556 StartActiveScheduler(2); |
|
1557 // ---- Following conditions MUST be met ---- |
|
1558 |
|
1559 // 1. Hostlet receives request that consumer made |
|
1560 LOCAL_ASSERT( *ipHostlet->iRequests[0] == KRequest); |
|
1561 |
|
1562 // 2. Consumer receives response that hostlet provided |
|
1563 |
|
1564 LOCAL_ASSERT( *ipConsumer->iResponses[0] == *ipHostlet->iResponses[0]); |
|
1565 LOCAL_ASSERT( ipConsumer->iResponseCodes[0] == ipHostlet->iResponseCodes[0]) |
|
1566 |
|
1567 |
|
1568 // 3. Hostlet receives completion code (delivery code) |
|
1569 LOCAL_ASSERT( ipHostlet->iTxnIds[0] == transactionIdOrError ); |
|
1570 LOCAL_ASSERT( ipHostlet->iCompletionCodes[0] == KErrNone ); // true in this "OK" -test case |
|
1571 |
|
1572 // --- Conditions END --- |
|
1573 |
|
1574 delete ipConnection; |
|
1575 ipConnection = NULL; |
|
1576 delete ipHostletConnection; |
|
1577 ipHostletConnection = NULL; |
|
1578 delete ipHostlet; |
|
1579 ipHostlet = NULL; |
|
1580 delete ipConsumer; |
|
1581 ipConsumer = NULL; |
|
1582 |
|
1583 return KErrNone; |
|
1584 } |
|
1585 |
|
1586 /* |
|
1587 TInt ChostconnTester::UT_CSenHostletConnection_Delete_HCL(CStifItemParser& aItem) |
|
1588 { |
|
1589 |
|
1590 |
|
1591 iWas_HandleErrorL_Accessed = EFalse; |
|
1592 ipHostlet = CTestHostlet::NewL(this); // uses default implementations for servicel and onservicecompletel |
|
1593 ipConsumer = CTestConsumer::NewL(this, |
|
1594 NULL, |
|
1595 &ChostconnTester::UT_CSenHostletConnection_NewLL_HandleErrorL, |
|
1596 NULL); |
|
1597 |
|
1598 ipHostletConnection = CSenHostletConnection::NewL(*ipHostlet); |
|
1599 |
|
1600 CSenServicePattern* pPattern = |
|
1601 CSenServicePattern::NewLC(KNullDesC8, KHostletContract); |
|
1602 pPattern->SetFrameworkIdL(KDefaultRestServicesFrameworkID); |
|
1603 |
|
1604 ipConnection = CSenServiceConnection::NewL(*ipConsumer, *pPattern); |
|
1605 CleanupStack::PopAndDestroy(pPattern); |
|
1606 |
|
1607 // Construct service connection |
|
1608 StartActiveScheduler(1); |
|
1609 |
|
1610 //delete Hostlet Connection |
|
1611 delete ipHostletConnection; |
|
1612 ipHostletConnection = NULL; |
|
1613 |
|
1614 |
|
1615 TInt transactionIdOrError = ipConnection->SendL(KRequest); |
|
1616 |
|
1617 // ---- Following conditions MUST be met ---- |
|
1618 LOCAL_ASSERT(transactionIdOrError == KErrSenHostNotAvailable); |
|
1619 |
|
1620 // Start waiting for HandleError Callback which is caused |
|
1621 // by error in SendL |
|
1622 StartActiveScheduler(1); |
|
1623 // Callback was get => Check that callback was HandleError |
|
1624 LOCAL_ASSERT( iWas_HandleErrorL_Accessed ); |
|
1625 |
|
1626 // --- Conditions END --- |
|
1627 |
|
1628 delete ipConnection; |
|
1629 ipConnection = NULL; |
|
1630 |
|
1631 delete ipHostlet; |
|
1632 ipHostlet = NULL; |
|
1633 delete ipConsumer; |
|
1634 ipConsumer = NULL; |
|
1635 |
|
1636 |
|
1637 return KErrNone; |
|
1638 } |
|
1639 |
|
1640 |
|
1641 */ |
|
1642 TInt ChostconnTester::UT_CSenHostletConnection_Two_Equal_UID3L(CStifItemParser& aItem) |
|
1643 { |
|
1644 |
|
1645 ipHostlet = CTestHostlet::NewL(this); // uses default implementations for servicel and onservicecompletel |
|
1646 |
|
1647 ipHostletConnection = CSenHostletConnection::NewL(*ipHostlet); |
|
1648 |
|
1649 //Check if CSenHostletConnection::NewL leaves with KErrSenEndpointReserved |
|
1650 /* EUNIT_ASSERT_SPECIFIC_LEAVE(ipHostletConnection1 = CSenHostletConnection::NewL(*ipHostlet),KErrSenEndpointReserved);*/ |
|
1651 TRAPD(res,ipHostletConnection1 = CSenHostletConnection::NewL(*ipHostlet)) ; |
|
1652 User::LeaveIfError(res == KErrSenEndpointReserved); |
|
1653 |
|
1654 |
|
1655 delete ipHostletConnection; |
|
1656 ipHostletConnection = NULL; |
|
1657 delete ipHostlet; |
|
1658 ipHostlet = NULL; |
|
1659 |
|
1660 return KErrNone; |
|
1661 } |
|
1662 |
|
1663 TInt ChostconnTester::UT_CSenHostletConnection_Two_Equal_EndpointsL(CStifItemParser& aItem) |
|
1664 { |
|
1665 |
|
1666 ipHostlet = CTestHostlet::NewL(this); // uses default implementations for servicel and onservicecompletel |
|
1667 ipHostlet->ipHostletDescription->SetEndPointL(KHostletEndpoint); |
|
1668 ipHostletConnection = CSenHostletConnection::NewL(*ipHostlet); |
|
1669 |
|
1670 //Check if CSenHostletConnection::NewL leaves with KErrSenEndpointReserved |
|
1671 /*EUNIT_ASSERT_SPECIFIC_LEAVE(ipHostletConnection1 = CSenHostletConnection::NewL(*ipHostlet),KErrSenEndpointReserved);*/ |
|
1672 TRAPD(res,ipHostletConnection1 = CSenHostletConnection::NewL(*ipHostlet)) ; |
|
1673 User::LeaveIfError(res == KErrSenEndpointReserved); |
|
1674 |
|
1675 delete ipHostletConnection; |
|
1676 ipHostletConnection = NULL; |
|
1677 delete ipHostlet; |
|
1678 ipHostlet = NULL; |
|
1679 |
|
1680 return KErrNone; |
|
1681 } |
|
1682 |
|
1683 |
|
1684 TInt ChostconnTester::UT_CSenHostletConnection_Two_HC_Two_SC1L(CStifItemParser& aItem) |
|
1685 { |
|
1686 //Memory leak detection is not supported since Symbian 9.0 (EKA2 kernel) environments. |
|
1687 //This this is added to handle thread handle leak in testmodule0 |
|
1688 TestModuleIf().SetBehavior( CTestModuleIf::ETestLeaksHandles); |
|
1689 |
|
1690 |
|
1691 //First pair of HC and SC |
|
1692 ipHostlet = CTestHostlet::NewL(this); // uses default implementations for servicel and onservicecompletel |
|
1693 ipConsumer = CTestConsumer::NewL(this); // uses the default implementations for setstatus, handlemessage, handleerror |
|
1694 |
|
1695 ipHostletConnection = CSenHostletConnection::NewL(*ipHostlet); |
|
1696 |
|
1697 CSenServicePattern* pPattern = |
|
1698 CSenServicePattern::NewLC(KNullDesC8, KHostletContract); |
|
1699 pPattern->SetFrameworkIdL(KDefaultRestServicesFrameworkID); |
|
1700 |
|
1701 ipConnection = CSenServiceConnection::NewL(*ipConsumer, *pPattern); |
|
1702 CleanupStack::PopAndDestroy(pPattern); |
|
1703 |
|
1704 // Construct service connection |
|
1705 StartActiveScheduler(1); |
|
1706 |
|
1707 // Check that the Status of the ServiceConnection |
|
1708 // is KSenConnectionStatusReady |
|
1709 LOCAL_ASSERT( ipConsumer->iConnectionStatus == KSenConnectionStatusReady); |
|
1710 |
|
1711 |
|
1712 //Second pair of HC and SC |
|
1713 ipHostlet1 = CTestHostlet::NewL(this); // uses default implementations for servicel and onservicecompletel |
|
1714 ipConsumer1 = CTestConsumer::NewL(this); // uses the default implementations for setstatus, handlemessage, handleerror |
|
1715 |
|
1716 ipHostlet1->ipHostletDescription->SetContractL(KHostletContract1); |
|
1717 ipHostletConnection1 = CSenHostletConnection::NewL(*ipHostlet1); |
|
1718 |
|
1719 CSenServicePattern* pPattern1 = |
|
1720 CSenServicePattern::NewLC(KNullDesC8, KHostletContract1); |
|
1721 pPattern1->SetFrameworkIdL(KDefaultRestServicesFrameworkID); |
|
1722 |
|
1723 ipConnection1 = CSenServiceConnection::NewL(*ipConsumer1, *pPattern1); |
|
1724 CleanupStack::PopAndDestroy(pPattern1); |
|
1725 |
|
1726 // Construct service connection |
|
1727 StartActiveScheduler(1); |
|
1728 |
|
1729 // Check that the Status of the ServiceConnection |
|
1730 // is KSenConnectionStatusReady |
|
1731 LOCAL_ASSERT( ipConsumer1->iConnectionStatus == KSenConnectionStatusReady); |
|
1732 |
|
1733 _LIT8(KRequest, "<ab:Query xmlns:ab=\"urn:nokia:test:addrbook:2004-09\"><ab:QueryItem><ab:Select>/ab:Card[containts[ab:N/ab:FAMILY,\'Bob\'] or containts[ab:N/ab:GIVEN,\'Bob\'] or containts[ab:TEL,\'Bob\']]</ab:Select></ab:QueryItem></ab:Query>"); |
|
1734 _LIT8(KRequest1, "<ab:Query xmlns:ab=\"urn:nokia:test:addrbook:2004-09\"><ab:QueryItem><ab:Select>/ab:Card[containts[ab:N/ab:FAMILY,\'Bob1\'] or containts[ab:N/ab:GIVEN,\'Bob1\'] or containts[ab:TEL,\'Bob1\']]</ab:Select></ab:QueryItem></ab:Query>"); |
|
1735 |
|
1736 ipUsedHostletConnection = ipHostletConnection; |
|
1737 |
|
1738 TInt transactionIdOrError = ipConnection->SendL(KRequest); |
|
1739 LOCAL_ASSERT(transactionIdOrError > KErrNone); |
|
1740 |
|
1741 // Invoke service ONCE (one call to ServiceL), respond to consumer ONCE => two calls |
|
1742 StartActiveScheduler(2); |
|
1743 |
|
1744 ipUsedHostletConnection = ipHostletConnection1; |
|
1745 transactionIdOrError = ipConnection1->SendL(KRequest1); |
|
1746 LOCAL_ASSERT(transactionIdOrError > KErrNone); |
|
1747 |
|
1748 // Invoke service ONCE (one call to ServiceL), respond to consumer ONCE => two calls |
|
1749 StartActiveScheduler(2); |
|
1750 |
|
1751 // ---- Following conditions MUST be met ---- |
|
1752 |
|
1753 // First pair of the HC and SC |
|
1754 // 1. Hostlet receives request that consumer made |
|
1755 LOCAL_ASSERT( *ipHostlet->iRequests[0] == KRequest); |
|
1756 |
|
1757 // 2. Consumer receives response that hostlet provided |
|
1758 LOCAL_ASSERT( *ipConsumer->iResponses[0] == *ipHostlet->iResponses[0]); |
|
1759 LOCAL_ASSERT( ipConsumer->iResponseCodes[0] == ipHostlet->iResponseCodes[0]) |
|
1760 |
|
1761 // 3. Hostlet receives completion code (delivery code) |
|
1762 LOCAL_ASSERT( ipHostlet->iTxnIds[0] == transactionIdOrError ); |
|
1763 LOCAL_ASSERT( ipHostlet->iCompletionCodes[0] == KErrNone ); // true in this "OK" -test case |
|
1764 |
|
1765 // Second pair of the HC and SC |
|
1766 // 1. Hostlet receives request that consumer made |
|
1767 LOCAL_ASSERT( *ipHostlet1->iRequests[0] == KRequest1); |
|
1768 |
|
1769 // 2. Consumer receives response that hostlet provided |
|
1770 LOCAL_ASSERT( *ipConsumer1->iResponses[0] == *ipHostlet1->iResponses[0]); |
|
1771 LOCAL_ASSERT( ipConsumer1->iResponseCodes[0] == ipHostlet1->iResponseCodes[0]) |
|
1772 |
|
1773 // 3. Hostlet receives completion code (delivery code) |
|
1774 LOCAL_ASSERT( ipHostlet1->iTxnIds[0] == transactionIdOrError ); |
|
1775 LOCAL_ASSERT( ipHostlet1->iCompletionCodes[0] == KErrNone ); // true in this "OK" -test case |
|
1776 |
|
1777 // --- Conditions END --- |
|
1778 |
|
1779 ipUsedHostletConnection = NULL; |
|
1780 |
|
1781 delete ipConnection; |
|
1782 ipConnection = NULL; |
|
1783 delete ipHostletConnection; |
|
1784 ipHostletConnection = NULL; |
|
1785 delete ipHostlet; |
|
1786 ipHostlet = NULL; |
|
1787 delete ipConsumer; |
|
1788 ipConsumer = NULL; |
|
1789 |
|
1790 delete ipConnection1; |
|
1791 ipConnection1 = NULL; |
|
1792 delete ipHostletConnection1; |
|
1793 ipHostletConnection1 = NULL; |
|
1794 delete ipHostlet1; |
|
1795 ipHostlet1 = NULL; |
|
1796 delete ipConsumer1; |
|
1797 ipConsumer1 = NULL; |
|
1798 |
|
1799 |
|
1800 return KErrNone; |
|
1801 } |
|
1802 |
|
1803 |
|
1804 |
|
1805 TInt ChostconnTester::UT_CSenHostletConnection_Two_HC_Two_SC2L(CStifItemParser& aItem) |
|
1806 { |
|
1807 //Memory leak detection is not supported since Symbian 9.0 (EKA2 kernel) environments. |
|
1808 //This this is added to handle thread handle leak in testmodule0 |
|
1809 TestModuleIf().SetBehavior( CTestModuleIf::ETestLeaksHandles); |
|
1810 |
|
1811 |
|
1812 //First pair of HC and SC |
|
1813 ipHostlet = CTestHostlet::NewL(this); // uses default implementations for servicel and onservicecompletel |
|
1814 ipConsumer = CTestConsumer::NewL(this); // uses the default implementations for setstatus, handlemessage, handleerror |
|
1815 |
|
1816 ipHostlet->ipHostletDescription->SetEndPointL(KHostletEndpoint); |
|
1817 ipHostlet->ipHostletDescription->SetContractL(KNullDesC8); |
|
1818 ipHostletConnection = CSenHostletConnection::NewL(*ipHostlet); |
|
1819 |
|
1820 CSenServicePattern* pPattern = |
|
1821 CSenServicePattern::NewLC(KHostletEndpoint, KNullDesC8); |
|
1822 pPattern->SetFrameworkIdL(KDefaultRestServicesFrameworkID); |
|
1823 |
|
1824 ipConnection = CSenServiceConnection::NewL(*ipConsumer, *pPattern); |
|
1825 CleanupStack::PopAndDestroy(pPattern); |
|
1826 |
|
1827 // Construct service connection |
|
1828 StartActiveScheduler(1); |
|
1829 |
|
1830 // Check that the Status of the ServiceConnection |
|
1831 // is KSenConnectionStatusReady |
|
1832 LOCAL_ASSERT( ipConsumer->iConnectionStatus == KSenConnectionStatusReady); |
|
1833 |
|
1834 |
|
1835 //Second pair of HC and SC |
|
1836 ipHostlet1 = CTestHostlet::NewL(this); // uses default implementations for servicel and onservicecompletel |
|
1837 ipConsumer1 = CTestConsumer::NewL(this); // uses the default implementations for setstatus, handlemessage, handleerror |
|
1838 |
|
1839 |
|
1840 ipHostlet1->ipHostletDescription->SetEndPointL(KHostletEndpoint1); |
|
1841 ipHostlet1->ipHostletDescription->SetContractL(KNullDesC8); |
|
1842 ipHostletConnection1 = CSenHostletConnection::NewL(*ipHostlet1); |
|
1843 |
|
1844 CSenServicePattern* pPattern1 = |
|
1845 CSenServicePattern::NewLC(KHostletEndpoint1, KNullDesC8); |
|
1846 pPattern1->SetFrameworkIdL(KDefaultRestServicesFrameworkID); |
|
1847 |
|
1848 ipConnection1 = CSenServiceConnection::NewL(*ipConsumer1, *pPattern1); |
|
1849 CleanupStack::PopAndDestroy(pPattern1); |
|
1850 |
|
1851 // Construct service connection |
|
1852 StartActiveScheduler(1); |
|
1853 |
|
1854 // Check that the Status of the ServiceConnection |
|
1855 // is KSenConnectionStatusReady |
|
1856 LOCAL_ASSERT( ipConsumer1->iConnectionStatus == KSenConnectionStatusReady); |
|
1857 |
|
1858 _LIT8(KRequest, "<ab:Query xmlns:ab=\"urn:nokia:test:addrbook:2004-09\"><ab:QueryItem><ab:Select>/ab:Card[containts[ab:N/ab:FAMILY,\'Bob\'] or containts[ab:N/ab:GIVEN,\'Bob\'] or containts[ab:TEL,\'Bob\']]</ab:Select></ab:QueryItem></ab:Query>"); |
|
1859 _LIT8(KRequest1, "<ab:Query xmlns:ab=\"urn:nokia:test:addrbook:2004-09\"><ab:QueryItem><ab:Select>/ab:Card[containts[ab:N/ab:FAMILY,\'Bob1\'] or containts[ab:N/ab:GIVEN,\'Bob1\'] or containts[ab:TEL,\'Bob1\']]</ab:Select></ab:QueryItem></ab:Query>"); |
|
1860 |
|
1861 ipUsedHostletConnection = ipHostletConnection; |
|
1862 TInt transactionIdOrError = ipConnection->SendL(KRequest); |
|
1863 LOCAL_ASSERT(transactionIdOrError > KErrNone); |
|
1864 |
|
1865 // Invoke service ONCE (one call to ServiceL), respond to consumer ONCE => two calls |
|
1866 StartActiveScheduler(2); |
|
1867 |
|
1868 ipUsedHostletConnection = ipHostletConnection1; |
|
1869 transactionIdOrError = ipConnection1->SendL(KRequest1); |
|
1870 LOCAL_ASSERT(transactionIdOrError > KErrNone); |
|
1871 |
|
1872 // Invoke service ONCE (one call to ServiceL), respond to consumer ONCE => two calls |
|
1873 StartActiveScheduler(2); |
|
1874 |
|
1875 // ---- Following conditions MUST be met ---- |
|
1876 |
|
1877 // First pair of the HC and SC |
|
1878 // 1. Hostlet receives request that consumer made |
|
1879 LOCAL_ASSERT( *ipHostlet->iRequests[0] == KRequest); |
|
1880 |
|
1881 // 2. Consumer receives response that hostlet provided |
|
1882 LOCAL_ASSERT( *ipConsumer->iResponses[0] == *ipHostlet->iResponses[0]); |
|
1883 LOCAL_ASSERT( ipConsumer->iResponseCodes[0] == ipHostlet->iResponseCodes[0]) |
|
1884 |
|
1885 // 3. Hostlet receives completion code (delivery code) |
|
1886 LOCAL_ASSERT( ipHostlet->iTxnIds[0] == transactionIdOrError ); |
|
1887 LOCAL_ASSERT( ipHostlet->iCompletionCodes[0] == KErrNone ); // true in this "OK" -test case |
|
1888 |
|
1889 // Second pair of the HC and SC |
|
1890 // 1. Hostlet receives request that consumer made |
|
1891 LOCAL_ASSERT( *ipHostlet1->iRequests[0] == KRequest1); |
|
1892 |
|
1893 // 2. Consumer receives response that hostlet provided |
|
1894 LOCAL_ASSERT( *ipConsumer1->iResponses[0] == *ipHostlet1->iResponses[0]); |
|
1895 LOCAL_ASSERT( ipConsumer1->iResponseCodes[0] == ipHostlet1->iResponseCodes[0]) |
|
1896 |
|
1897 // 3. Hostlet receives completion code (delivery code) |
|
1898 LOCAL_ASSERT( ipHostlet1->iTxnIds[0] == transactionIdOrError ); |
|
1899 LOCAL_ASSERT( ipHostlet1->iCompletionCodes[0] == KErrNone ); // true in this "OK" -test case |
|
1900 |
|
1901 // --- Conditions END --- |
|
1902 |
|
1903 ipUsedHostletConnection = NULL; |
|
1904 |
|
1905 delete ipConnection; |
|
1906 ipConnection = NULL; |
|
1907 delete ipHostletConnection; |
|
1908 ipHostletConnection = NULL; |
|
1909 delete ipHostlet; |
|
1910 ipHostlet = NULL; |
|
1911 delete ipConsumer; |
|
1912 ipConsumer = NULL; |
|
1913 |
|
1914 delete ipConnection1; |
|
1915 ipConnection1 = NULL; |
|
1916 delete ipHostletConnection1; |
|
1917 ipHostletConnection1 = NULL; |
|
1918 delete ipHostlet1; |
|
1919 ipHostlet1 = NULL; |
|
1920 delete ipConsumer1; |
|
1921 ipConsumer1 = NULL; |
|
1922 |
|
1923 |
|
1924 return KErrNone; |
|
1925 } |
|
1926 |
|
1927 |
|
1928 TInt ChostconnTester::UT_CSenHostletConnection_Two_HC_Two_SC3L(CStifItemParser& aItem) |
|
1929 { |
|
1930 //Memory leak detection is not supported since Symbian 9.0 (EKA2 kernel) environments. |
|
1931 //This this is added to handle thread handle leak in testmodule0 |
|
1932 TestModuleIf().SetBehavior( CTestModuleIf::ETestLeaksHandles); |
|
1933 |
|
1934 |
|
1935 //First pair of HC and SC |
|
1936 ipHostlet = CTestHostlet::NewL(this); // uses default implementations for servicel and onservicecompletel |
|
1937 ipConsumer = CTestConsumer::NewL(this); // uses the default implementations for setstatus, handlemessage, handleerror |
|
1938 |
|
1939 ipHostlet->ipHostletDescription->SetEndPointL(KHostletEndpoint); |
|
1940 ipHostlet->ipHostletDescription->SetContractL(KNullDesC8); |
|
1941 ipHostletConnection = CSenHostletConnection::NewL(*ipHostlet); |
|
1942 |
|
1943 CSenServicePattern* pPattern = |
|
1944 CSenServicePattern::NewLC(KHostletEndpoint, KNullDesC8); |
|
1945 pPattern->SetFrameworkIdL(KDefaultRestServicesFrameworkID); |
|
1946 |
|
1947 ipConnection = CSenServiceConnection::NewL(*ipConsumer, *pPattern); |
|
1948 CleanupStack::PopAndDestroy(pPattern); |
|
1949 |
|
1950 // Construct service connection |
|
1951 StartActiveScheduler(1); |
|
1952 // Check that the Status of the ServiceConnection |
|
1953 // is KSenConnectionStatusReady |
|
1954 LOCAL_ASSERT( ipConsumer->iConnectionStatus == KSenConnectionStatusReady); |
|
1955 |
|
1956 //Second pair of HC and SC |
|
1957 ipHostlet1 = CTestHostlet::NewL(this); // uses default implementations for servicel and onservicecompletel |
|
1958 ipConsumer1 = CTestConsumer::NewL(this); // uses the default implementations for setstatus, handlemessage, handleerror |
|
1959 |
|
1960 |
|
1961 ipHostlet1->ipHostletDescription->SetEndPointL(KHostletEndpoint1); |
|
1962 ipHostlet1->ipHostletDescription->SetContractL(KNullDesC8); |
|
1963 ipHostletConnection1 = CSenHostletConnection::NewL(*ipHostlet1); |
|
1964 |
|
1965 CSenServicePattern* pPattern1 = |
|
1966 CSenServicePattern::NewLC(KHostletEndpoint1, KNullDesC8); |
|
1967 pPattern1->SetFrameworkIdL(KDefaultRestServicesFrameworkID); |
|
1968 |
|
1969 ipConnection1 = CSenServiceConnection::NewL(*ipConsumer1, *pPattern1); |
|
1970 CleanupStack::PopAndDestroy(pPattern1); |
|
1971 |
|
1972 // Construct service connection |
|
1973 StartActiveScheduler(1); |
|
1974 // Check that the Status of the ServiceConnection |
|
1975 // is KSenConnectionStatusReady |
|
1976 LOCAL_ASSERT( ipConsumer1->iConnectionStatus == KSenConnectionStatusReady); |
|
1977 |
|
1978 _LIT8(KRequest, "<ab:Query xmlns:ab=\"urn:nokia:test:addrbook:2004-09\"><ab:QueryItem><ab:Select>/ab:Card[containts[ab:N/ab:FAMILY,\'Bob\'] or containts[ab:N/ab:GIVEN,\'Bob\'] or containts[ab:TEL,\'Bob\']]</ab:Select></ab:QueryItem></ab:Query>"); |
|
1979 _LIT8(KRequest1, "<ab:Query xmlns:ab=\"urn:nokia:test:addrbook:2004-09\"><ab:QueryItem><ab:Select>/ab:Card[containts[ab:N/ab:FAMILY,\'Bob1\'] or containts[ab:N/ab:GIVEN,\'Bob1\'] or containts[ab:TEL,\'Bob1\']]</ab:Select></ab:QueryItem></ab:Query>"); |
|
1980 |
|
1981 ipUsedHostletConnection = ipHostletConnection; |
|
1982 TInt transactionIdOrError = ipConnection->SendL(KRequest); |
|
1983 LOCAL_ASSERT(transactionIdOrError > KErrNone); |
|
1984 |
|
1985 // Invoke service ONCE (one call to ServiceL), respond to consumer ONCE => two calls |
|
1986 StartActiveScheduler(2); |
|
1987 |
|
1988 ipUsedHostletConnection = ipHostletConnection1; |
|
1989 transactionIdOrError = ipConnection1->SendL(KRequest1); |
|
1990 LOCAL_ASSERT(transactionIdOrError > KErrNone); |
|
1991 |
|
1992 // Invoke service ONCE (one call to ServiceL), respond to consumer ONCE => two calls |
|
1993 StartActiveScheduler(2); |
|
1994 |
|
1995 // ---- Following conditions MUST be met ---- |
|
1996 |
|
1997 // First pair of the HC and SC |
|
1998 // 1. Hostlet receives request that consumer made |
|
1999 LOCAL_ASSERT( *ipHostlet->iRequests[0] == KRequest); |
|
2000 |
|
2001 // 2. Consumer receives response that hostlet provided |
|
2002 LOCAL_ASSERT( *ipConsumer->iResponses[0] == *ipHostlet->iResponses[0]); |
|
2003 LOCAL_ASSERT( ipConsumer->iResponseCodes[0] == ipHostlet->iResponseCodes[0]) |
|
2004 |
|
2005 // 3. Hostlet receives completion code (delivery code) |
|
2006 LOCAL_ASSERT( ipHostlet->iTxnIds[0] == transactionIdOrError ); |
|
2007 LOCAL_ASSERT( ipHostlet->iCompletionCodes[0] == KErrNone ); // true in this "OK" -test case |
|
2008 |
|
2009 // Second pair of the HC and SC |
|
2010 // 1. Hostlet receives request that consumer made |
|
2011 LOCAL_ASSERT( *ipHostlet1->iRequests[0] == KRequest1); |
|
2012 |
|
2013 // 2. Consumer receives response that hostlet provided |
|
2014 LOCAL_ASSERT( *ipConsumer1->iResponses[0] == *ipHostlet1->iResponses[0]); |
|
2015 LOCAL_ASSERT( ipConsumer1->iResponseCodes[0] == ipHostlet1->iResponseCodes[0]) |
|
2016 |
|
2017 // 3. Hostlet receives completion code (delivery code) |
|
2018 LOCAL_ASSERT( ipHostlet1->iTxnIds[0] == transactionIdOrError ); |
|
2019 LOCAL_ASSERT( ipHostlet1->iCompletionCodes[0] == KErrNone ); // true in this "OK" -test case |
|
2020 |
|
2021 // --- Conditions END --- |
|
2022 |
|
2023 ipUsedHostletConnection = NULL; |
|
2024 |
|
2025 delete ipConnection; |
|
2026 ipConnection = NULL; |
|
2027 delete ipHostletConnection; |
|
2028 ipHostletConnection = NULL; |
|
2029 delete ipHostlet; |
|
2030 ipHostlet = NULL; |
|
2031 delete ipConsumer; |
|
2032 ipConsumer = NULL; |
|
2033 |
|
2034 delete ipConnection1; |
|
2035 ipConnection1 = NULL; |
|
2036 delete ipHostletConnection1; |
|
2037 ipHostletConnection1 = NULL; |
|
2038 delete ipHostlet1; |
|
2039 ipHostlet1 = NULL; |
|
2040 delete ipConsumer1; |
|
2041 ipConsumer1 = NULL; |
|
2042 |
|
2043 return KErrNone; |
|
2044 } |
|
2045 |
|
2046 |
|
2047 |
|
2048 TInt ChostconnTester::UT_CSenHostletConnection_DeleteSC_before_HCRespondLL(CStifItemParser& aItem) |
|
2049 { |
|
2050 |
|
2051 iWas_OnServiceL_Accessed = false; |
|
2052 ipHostlet = CTestHostlet::NewL(this, |
|
2053 &ChostconnTester::UT_CSenHostletConnection_NewLL_OnService1L, |
|
2054 &ChostconnTester::UT_CSenHostletConnection_NewLL_OnServiceComplete1L); |
|
2055 |
|
2056 ipConsumer = CTestConsumer::NewL(this); // uses the default implementations for setstatus, handlemessage, handleerror |
|
2057 |
|
2058 |
|
2059 |
|
2060 ipHostletConnection = CSenHostletConnection::NewL(*ipHostlet); |
|
2061 |
|
2062 CSenServicePattern* pPattern = |
|
2063 CSenServicePattern::NewLC(KNullDesC8, KHostletContract); |
|
2064 pPattern->SetFrameworkIdL(KDefaultRestServicesFrameworkID); |
|
2065 |
|
2066 ipConnection = CSenServiceConnection::NewL(*ipConsumer, *pPattern); |
|
2067 CleanupStack::PopAndDestroy(pPattern); |
|
2068 |
|
2069 // Construct service connection |
|
2070 StartActiveScheduler(1); |
|
2071 |
|
2072 // Check that the Status of the ServiceConnection |
|
2073 // is KSenConnectionStatusReady |
|
2074 LOCAL_ASSERT( ipConsumer->iConnectionStatus == KSenConnectionStatusReady); |
|
2075 |
|
2076 _LIT8(KRequest, "<ab:Query xmlns:ab=\"urn:nokia:test:addrbook:2004-09\"><ab:QueryItem><ab:Select>/ab:Card[containts[ab:N/ab:FAMILY,\'Bob\'] or containts[ab:N/ab:GIVEN,\'Bob\'] or containts[ab:TEL,\'Bob\']]</ab:Select></ab:QueryItem></ab:Query>"); |
|
2077 |
|
2078 TInt transactionIdOrError = ipConnection->SendL(KRequest); |
|
2079 LOCAL_ASSERT(transactionIdOrError > KErrNone); |
|
2080 |
|
2081 // Invoke service ONCE (one call to ServiceL), respond to consumer ONCE => two calls |
|
2082 StartActiveScheduler(1); |
|
2083 |
|
2084 |
|
2085 // ---- Following conditions MUST be met ---- |
|
2086 |
|
2087 // 1. Hostlet receives request that consumer made |
|
2088 LOCAL_ASSERT( *ipHostlet->iRequests[0] == KRequest); |
|
2089 |
|
2090 // 2. onServiceL accesed |
|
2091 LOCAL_ASSERT( iWas_OnServiceL_Accessed ); |
|
2092 |
|
2093 // 3. Hostlet receives completion code (delivery code) |
|
2094 LOCAL_ASSERT( ipHostlet->iCompletionCodes[0] < KErrNone ); |
|
2095 |
|
2096 // --- Conditions END --- |
|
2097 |
|
2098 |
|
2099 delete ipHostletConnection; |
|
2100 ipHostletConnection = NULL; |
|
2101 delete ipHostlet; |
|
2102 ipHostlet = NULL; |
|
2103 delete ipConsumer; |
|
2104 ipConsumer = NULL; |
|
2105 |
|
2106 return KErrNone; |
|
2107 } |
|
2108 |
|
2109 |
|
2110 TInt ChostconnTester::UT_CSenHostletConnection_RespondL_4multipleTimesL(CStifItemParser& aItem) |
|
2111 { |
|
2112 |
|
2113 ipHostlet = CTestHostlet::NewL(this, |
|
2114 &ChostconnTester::UT_CSenHostletConnection_NewLL_OnService2L, |
|
2115 &ChostconnTester::UT_CSenHostletConnection_NewLL_OnServiceComplete2L); |
|
2116 |
|
2117 ipConsumer = CTestConsumer::NewL(this); // uses the default implementations for setstatus, handlemessage, handleerror |
|
2118 |
|
2119 |
|
2120 |
|
2121 ipHostletConnection = CSenHostletConnection::NewL(*ipHostlet); |
|
2122 |
|
2123 CSenServicePattern* pPattern = |
|
2124 CSenServicePattern::NewLC(KNullDesC8, KHostletContract); |
|
2125 pPattern->SetFrameworkIdL(KDefaultRestServicesFrameworkID); |
|
2126 |
|
2127 ipConnection = CSenServiceConnection::NewL(*ipConsumer, *pPattern); |
|
2128 CleanupStack::PopAndDestroy(pPattern); |
|
2129 |
|
2130 // Construct service connection |
|
2131 StartActiveScheduler(1); |
|
2132 |
|
2133 // Check that the Status of the ServiceConnection |
|
2134 // is KSenConnectionStatusReady |
|
2135 LOCAL_ASSERT( ipConsumer->iConnectionStatus == KSenConnectionStatusReady); |
|
2136 |
|
2137 |
|
2138 _LIT8(KRequest, "<ab:Query xmlns:ab=\"urn:nokia:test:addrbook:2004-09\"><ab:QueryItem><ab:Select>/ab:Card[containts[ab:N/ab:FAMILY,\'Bob\'] or containts[ab:N/ab:GIVEN,\'Bob\'] or containts[ab:TEL,\'Bob\']]</ab:Select></ab:QueryItem></ab:Query>"); |
|
2139 |
|
2140 |
|
2141 TInt transactionIdOrError = ipConnection->SendL(KRequest); |
|
2142 LOCAL_ASSERT(transactionIdOrError > KErrNone); |
|
2143 |
|
2144 // Invoke service ONCE (one call to ServiceL), respond to consumer ONCE => two calls |
|
2145 StartActiveScheduler(2); |
|
2146 |
|
2147 |
|
2148 // ---- Following conditions MUST be met ---- |
|
2149 |
|
2150 |
|
2151 // --- Conditions END --- |
|
2152 |
|
2153 delete ipConnection; |
|
2154 ipConnection = NULL; |
|
2155 delete ipHostletConnection; |
|
2156 ipHostletConnection = NULL; |
|
2157 delete ipHostlet; |
|
2158 ipHostlet = NULL; |
|
2159 delete ipConsumer; |
|
2160 ipConsumer = NULL; |
|
2161 |
|
2162 return KErrNone; |
|
2163 } |
|
2164 |
|
2165 |
|
2166 |
|
2167 |
|
2168 TInt ChostconnTester::UT_CSenHostletConnection_SC_Cancel_After_RequestL(CStifItemParser& aItem) |
|
2169 { |
|
2170 |
|
2171 |
|
2172 iWas_HandleErrorL_Accessed = EFalse; |
|
2173 |
|
2174 |
|
2175 ipHostlet = CTestHostlet::NewL(this, |
|
2176 &ChostconnTester::UT_CSenHostletConnection_NewLL_OnService3L, |
|
2177 NULL); |
|
2178 |
|
2179 ipConsumer = CTestConsumer::NewL(this, |
|
2180 NULL, |
|
2181 &ChostconnTester::UT_CSenHostletConnection_NewLL_HandleError1L, |
|
2182 NULL); |
|
2183 |
|
2184 |
|
2185 ipHostletConnection = CSenHostletConnection::NewL(*ipHostlet); |
|
2186 |
|
2187 CSenServicePattern* pPattern = |
|
2188 CSenServicePattern::NewLC(KNullDesC8, KHostletContract); |
|
2189 pPattern->SetFrameworkIdL(KDefaultRestServicesFrameworkID); |
|
2190 |
|
2191 ipConnection = CSenServiceConnection::NewL(*ipConsumer, *pPattern); |
|
2192 CleanupStack::PopAndDestroy(pPattern); |
|
2193 |
|
2194 // Construct service connection |
|
2195 StartActiveScheduler(1); |
|
2196 |
|
2197 // Check that the Status of the ServiceConnection |
|
2198 // is KSenConnectionStatusReady |
|
2199 LOCAL_ASSERT( ipConsumer->iConnectionStatus == KSenConnectionStatusReady); |
|
2200 |
|
2201 _LIT8(KRequest, "<ab:Query xmlns:ab=\"urn:nokia:test:addrbook:2004-09\"><ab:QueryItem><ab:Select>/ab:Card[containts[ab:N/ab:FAMILY,\'Bob\'] or containts[ab:N/ab:GIVEN,\'Bob\'] or containts[ab:TEL,\'Bob\']]</ab:Select></ab:QueryItem></ab:Query>"); |
|
2202 |
|
2203 TInt transactionIdOrError = ipConnection->SendL(KRequest); |
|
2204 iTxnID=transactionIdOrError; |
|
2205 LOCAL_ASSERT(transactionIdOrError > KErrNone); |
|
2206 |
|
2207 //ipConnection->Cancel(); |
|
2208 // Invoke service ONCE (one call to ServiceL), respond to consumer ONCE => two calls |
|
2209 StartActiveScheduler(2); |
|
2210 |
|
2211 |
|
2212 |
|
2213 // |
|
2214 // ---- Following conditions MUST be met ---- |
|
2215 |
|
2216 //1 KErrSenCancelled reported |
|
2217 LOCAL_ASSERT( ipConsumer->iResponseCodes[0] == KErrSenCancelled); |
|
2218 |
|
2219 //2. HandleErrorL accesed after negative iResponseCodes |
|
2220 LOCAL_ASSERT( iWas_HandleErrorL_Accessed ); |
|
2221 // --- Conditions END --- |
|
2222 |
|
2223 delete ipConnection; |
|
2224 ipConnection = NULL; |
|
2225 delete ipHostletConnection; |
|
2226 ipHostletConnection = NULL; |
|
2227 delete ipHostlet; |
|
2228 ipHostlet = NULL; |
|
2229 delete ipConsumer; |
|
2230 ipConsumer = NULL; |
|
2231 |
|
2232 |
|
2233 return KErrNone; |
|
2234 } |
|
2235 |
|
2236 |
|
2237 TInt ChostconnTester::UT_CSenHostletConnection_Set_Expose_FacetL(CStifItemParser& aItem) |
|
2238 { |
|
2239 |
|
2240 |
|
2241 ipHostlet = CTestHostlet::NewL(this); // uses default implementations for servicel and onservicecompletel |
|
2242 |
|
2243 CSenFacet* pExposed = CSenFacet::NewL(); |
|
2244 CleanupStack::PushL(pExposed); |
|
2245 pExposed->SetNameL(KExposeLocalServiceFacet); // from MSenServiceDescription.h |
|
2246 ipHostlet->ipHostletDescription->SetFacetL(*pExposed); |
|
2247 CleanupStack::PopAndDestroy(); // pExposed |
|
2248 |
|
2249 RFacetArray facets; |
|
2250 ipHostlet->ipHostletDescription->FacetsL(facets); |
|
2251 |
|
2252 LOCAL_ASSERT(facets[0]->Name() == KExposeLocalServiceFacet); |
|
2253 |
|
2254 facets.ResetAndDestroy(); |
|
2255 delete ipHostlet; |
|
2256 ipHostlet = NULL; |
|
2257 |
|
2258 |
|
2259 return KErrNone; |
|
2260 } |
|
2261 |
|
2262 /* |
|
2263 TInt ChostconnTester::UT_CSenHostletConnection_CreateConnAndSubmit_Rest_MultiThreadL(CStifItemParser& aItem) |
|
2264 { |
|
2265 |
|
2266 // uses default implementations for servicel and onservicecompletel |
|
2267 ipHostlet = CTestHostlet::NewL(this); |
|
2268 ipHostletConnection = CSenHostletConnection::NewL(*ipHostlet); |
|
2269 |
|
2270 HBufC8* pResponseTo = NULL; |
|
2271 |
|
2272 // Invoke service once. But, due this is performed synchronously within the SAME PROCESS, we need |
|
2273 // another thread (otherwise ActiveScheduler cannot serve this WS request, ServiceL is never invoked). |
|
2274 |
|
2275 TConsumerTestTask task( *ipConnection, |
|
2276 KRequest, |
|
2277 KDefaultRestServicesFrameworkID, |
|
2278 TConsumerTestTask::ECreateConnAndSubmit, |
|
2279 pResponseTo ); |
|
2280 task.ipOwner = this; |
|
2281 |
|
2282 RThread localThread; |
|
2283 _LIT(KThreadName, "tSubmitRestFromThread_"); |
|
2284 |
|
2285 TInt createThreadRetVal = CreateThreadForConsumerTask(localThread, KThreadName, task); |
|
2286 |
|
2287 LOCAL_ASSERT( createThreadRetVal == KErrNone ); |
|
2288 |
|
2289 localThread.Resume(); // start the thread. |
|
2290 |
|
2291 // Would NOT work: // TInt transactionIdOrError = ipConnection->SubmitL(KRequest, pResponseTo); |
|
2292 // LOCAL_ASSERT(transactionIdOrError > KErrNone); |
|
2293 |
|
2294 |
|
2295 // Respond to consumer ONCE => only one call.. |
|
2296 StartActiveScheduler(1); |
|
2297 |
|
2298 // Push the local pointer to the response descriptor into cleanupstack: |
|
2299 CleanupStack::PushL(pResponseTo); |
|
2300 |
|
2301 // ---- Following conditions MUST be met ---- |
|
2302 |
|
2303 // SubmitL must return KErrNone(!) |
|
2304 // Note: from Submit, one cannot get TXN ID, but either OK (KErrNone) or an error |
|
2305 // LOCAL_ASSERT( task.iStatusCode == KErrNone ); |
|
2306 |
|
2307 |
|
2308 // 1. Hostlet receives request that consumer made |
|
2309 LOCAL_ASSERT( *ipHostlet->iRequests[0] == KRequest); |
|
2310 |
|
2311 // 2. Consumer receives response that hostlet provided |
|
2312 LOCAL_ASSERT( *pResponseTo == *ipHostlet->iResponses[0]); |
|
2313 |
|
2314 |
|
2315 // 3. Hostlet receives completion code (delivery code) |
|
2316 LOCAL_ASSERT( ipHostlet->iCompletionCodes[0] == KErrNone ); // true in this "OK" -test case |
|
2317 |
|
2318 // --- Conditions END --- |
|
2319 |
|
2320 CleanupStack::PopAndDestroy(pResponseTo); |
|
2321 |
|
2322 localThread.Close(); |
|
2323 delete ipConnection; |
|
2324 ipConnection = NULL; |
|
2325 delete ipHostletConnection; |
|
2326 ipHostletConnection = NULL; |
|
2327 delete ipHostlet; |
|
2328 ipHostlet = NULL; |
|
2329 delete ipConsumer; |
|
2330 ipConsumer = NULL; |
|
2331 |
|
2332 return KErrNone; |
|
2333 } |
|
2334 */ |
|
2335 |
|
2336 |
|
2337 TInt ChostconnTester::UT_CSenHostletConnection_Submit_Rest_MultiThreadL(CStifItemParser& aItem) |
|
2338 { |
|
2339 |
|
2340 ipHostlet = CTestHostlet::NewL(this); // uses default implementations for servicel and onservicecompletel |
|
2341 ipConsumer = CTestConsumer::NewL(this); // uses the default implementations for setstatus, handlemessage, handleerror |
|
2342 |
|
2343 |
|
2344 ipHostletConnection = CSenHostletConnection::NewL(*ipHostlet); |
|
2345 |
|
2346 CSenServicePattern* pPattern = |
|
2347 CSenServicePattern::NewLC(KNullDesC8, KHostletContract); |
|
2348 pPattern->SetFrameworkIdL(KDefaultRestServicesFrameworkID); |
|
2349 |
|
2350 ipConnection = CSenServiceConnection::NewL(*ipConsumer, *pPattern); |
|
2351 CleanupStack::PopAndDestroy(pPattern); |
|
2352 |
|
2353 // Construct service connection |
|
2354 StartActiveScheduler(1); |
|
2355 |
|
2356 _LIT8(KRequest, "<ab:Query xmlns:ab=\"urn:nokia:test:addrbook:2004-09\"><ab:QueryItem><ab:Select>/ab:Card[containts[ab:N/ab:FAMILY,\'Bob\'] or containts[ab:N/ab:GIVEN,\'Bob\'] or containts[ab:TEL,\'Bob\']]</ab:Select></ab:QueryItem></ab:Query>"); |
|
2357 |
|
2358 HBufC8* pResponseTo = NULL; |
|
2359 |
|
2360 // Invoke service once. But, due this is performed synchronously within the SAME PROCESS, we need |
|
2361 // another thread (otherwise ActiveScheduler cannot serve this WS request, ServiceL is never invoked). |
|
2362 |
|
2363 TConsumerTestTask task( *ipConnection, |
|
2364 KRequest, |
|
2365 KDefaultRestServicesFrameworkID, // not used by this test case.. |
|
2366 TConsumerTestTask::ESubmit, |
|
2367 pResponseTo); |
|
2368 |
|
2369 RThread localThread; |
|
2370 _LIT(KThreadName, "tSubmitRestFromThread_"); |
|
2371 |
|
2372 TInt createThreadRetVal = CreateThreadForConsumerTask(localThread, KThreadName, task); |
|
2373 |
|
2374 LOCAL_ASSERT( createThreadRetVal == KErrNone ); |
|
2375 |
|
2376 localThread.Resume(); // start the thread. |
|
2377 |
|
2378 // Would NOT work: // TInt transactionIdOrError = ipConnection->SubmitL(KRequest, pResponseTo); |
|
2379 // LOCAL_ASSERT(transactionIdOrError > KErrNone); |
|
2380 |
|
2381 // Respond to consumer ONCE => only one call.. |
|
2382 StartActiveScheduler(1); |
|
2383 |
|
2384 // Push the local pointer to the response descriptor into cleanupstack: |
|
2385 CleanupStack::PushL(pResponseTo); |
|
2386 |
|
2387 // ---- Following conditions MUST be met ---- |
|
2388 |
|
2389 // SubmitL must return KErrNone(!) |
|
2390 // Note: from Submit, one cannot get TXN ID, but either OK (KErrNone) or an error |
|
2391 LOCAL_ASSERT( task.iStatusCode == KErrNone ); |
|
2392 |
|
2393 |
|
2394 // 1. Hostlet receives request that consumer made |
|
2395 LOCAL_ASSERT( *ipHostlet->iRequests[0] == KRequest); |
|
2396 |
|
2397 // 2. Consumer receives response that hostlet provided |
|
2398 LOCAL_ASSERT( *pResponseTo == *ipHostlet->iResponses[0]); |
|
2399 |
|
2400 |
|
2401 // 3. Hostlet receives completion code (delivery code) |
|
2402 LOCAL_ASSERT( ipHostlet->iCompletionCodes[0] == KErrNone ); // true in this "OK" -test case |
|
2403 |
|
2404 // --- Conditions END --- |
|
2405 |
|
2406 CleanupStack::PopAndDestroy(pResponseTo); |
|
2407 delete ipConnection; |
|
2408 ipConnection = NULL; |
|
2409 delete ipHostletConnection; |
|
2410 ipHostletConnection = NULL; |
|
2411 delete ipHostlet; |
|
2412 ipHostlet = NULL; |
|
2413 delete ipConsumer; |
|
2414 ipConsumer = NULL; |
|
2415 |
|
2416 return KErrNone; |
|
2417 } |
|
2418 |
|
2419 |
|
2420 TInt ChostconnTester::UT_CSenHostletConnection_Submit_Rest_ActiveL(CStifItemParser& aItem) |
|
2421 { |
|
2422 |
|
2423 ipHostlet = CTestHostlet::NewL(this); // uses default implementations for servicel and onservicecompletel |
|
2424 ipConsumer = CTestConsumer::NewL(this); // uses the default implementations for setstatus, handlemessage, handleerror |
|
2425 |
|
2426 |
|
2427 ipHostletConnection = CSenHostletConnection::NewL(*ipHostlet); |
|
2428 CSenServicePattern* pPattern = CSenServicePattern::NewLC(KNullDesC8, KHostletContract); |
|
2429 pPattern->SetFrameworkIdL(KDefaultRestServicesFrameworkID); |
|
2430 |
|
2431 ipConnection = CSenServiceConnection::NewL(*ipConsumer, *pPattern); |
|
2432 CleanupStack::PopAndDestroy(pPattern); |
|
2433 |
|
2434 // Construct service connection |
|
2435 StartActiveScheduler(1); |
|
2436 |
|
2437 _LIT8(KRequest, "<ab:Query xmlns:ab=\"urn:nokia:test:addrbook:2004-09\"><ab:QueryItem><ab:Select>/ab:Card[containts[ab:N/ab:FAMILY,\'Bob\'] or containts[ab:N/ab:GIVEN,\'Bob\'] or containts[ab:TEL,\'Bob\']]</ab:Select></ab:QueryItem></ab:Query>"); |
|
2438 |
|
2439 HBufC8* pResponseTo = NULL; |
|
2440 |
|
2441 // Invoke service once. But, due this is performed synchronously within the SAME PROCESS, we need |
|
2442 // another thread (otherwise ActiveScheduler cannot serve this WS request, ServiceL is never invoked). |
|
2443 |
|
2444 TConsumerTestTask task( *ipConnection, |
|
2445 KRequest, |
|
2446 KDefaultRestServicesFrameworkID, // not used by this test case atm |
|
2447 TConsumerTestTask::EActiveSubmit, |
|
2448 pResponseTo); |
|
2449 |
|
2450 _LIT(KThreadName, "tSubmitRestFromAO_"); |
|
2451 CActiveConsumerTestTask* pActiveTask = CActiveConsumerTestTask::NewLC(task, KThreadName(), *this); // push pActiveTask |
|
2452 task.ipActive = pActiveTask; |
|
2453 |
|
2454 if(!pActiveTask->IsActive()) |
|
2455 { |
|
2456 |
|
2457 pActiveTask->SetActive(); |
|
2458 |
|
2459 return KErrNone; |
|
2460 } |
|
2461 |
|
2462 pActiveTask->iStatus = KRequestPending; |
|
2463 TRequestStatus* status = &pActiveTask->iStatus; |
|
2464 User::RequestComplete( status, CActiveConsumerTestTask::EInvokeService ); |
|
2465 |
|
2466 // Would NOT work: // TInt transactionIdOrError = ipConnection->SubmitL(KRequest, pResponseTo); |
|
2467 // LOCAL_ASSERT(transactionIdOrError > KErrNone); |
|
2468 |
|
2469 // Submit a single request (via help of an AO!), respond to consumer ONCE, => two calls |
|
2470 StartActiveScheduler(2); |
|
2471 |
|
2472 // Push the local pointer to the response descriptor into cleanupstack: |
|
2473 CleanupStack::PushL(pResponseTo); |
|
2474 |
|
2475 // ---- Following conditions MUST be met ---- |
|
2476 |
|
2477 // SubmitL must return KErrNone(!) |
|
2478 // Note: from Submit, one cannot get TXN ID, but either OK (KErrNone) or an error |
|
2479 LOCAL_ASSERT( task.iStatusCode == KErrNone ); |
|
2480 |
|
2481 |
|
2482 // 1. Hostlet receives request that consumer made |
|
2483 LOCAL_ASSERT( *ipHostlet->iRequests[0] == KRequest); |
|
2484 |
|
2485 // 2. Consumer receives response that hostlet provided |
|
2486 LOCAL_ASSERT( *pResponseTo == *ipHostlet->iResponses[0]); |
|
2487 |
|
2488 |
|
2489 // 3. Hostlet receives completion code (delivery code) |
|
2490 LOCAL_ASSERT( ipHostlet->iCompletionCodes[0] == KErrNone ); // true in this "OK" -test case |
|
2491 |
|
2492 // --- Conditions END --- |
|
2493 |
|
2494 CleanupStack::PopAndDestroy(pResponseTo); |
|
2495 delete ipConnection; |
|
2496 ipConnection = NULL; |
|
2497 delete ipHostletConnection; |
|
2498 ipHostletConnection = NULL; |
|
2499 delete ipHostlet; |
|
2500 ipHostlet = NULL; |
|
2501 delete ipConsumer; |
|
2502 ipConsumer = NULL; |
|
2503 |
|
2504 |
|
2505 return KErrNone; |
|
2506 } |
|
2507 |
|
2508 /* |
|
2509 TInt ChostconnTester::UT_CSenHostletConnection_CreateConnAndSubmit_WSI_MultiThreadL(CStifItemParser& aItem) |
|
2510 { |
|
2511 |
|
2512 // This test case uses default implementations for servicel and onservicecompletel, |
|
2513 // BUT(!) describeservicel has been overridden! |
|
2514 ipHostlet = CTestHostlet::NewL(this, NULL, NULL, ChostconnTester::UT_CSenHostletConnection_WSI_DescribeServiceL); |
|
2515 |
|
2516 // variant point 1: |
|
2517 // ipHostlet = CTestHostlet::NewL(this); |
|
2518 ipHostletConnection = CSenHostletConnection::NewL(*ipHostlet); |
|
2519 |
|
2520 CSenSoapMessage* pSoapMessage = CreateAuthRequestLC(); |
|
2521 HBufC8* pAsXml = pSoapMessage->AsXmlL(); |
|
2522 CleanupStack::PushL(pAsXml); |
|
2523 TPtrC8 request = pAsXml->Des(); |
|
2524 |
|
2525 CSenTransportProperties* pProps = CSenTransportProperties::NewLC(); // push pProps |
|
2526 pProps->SetPropertyL(_L8("KTestProperty"), _L8("KTestPropertyValue")); |
|
2527 HBufC8* pPropsAsXml = pProps->AsUtf8L(); |
|
2528 CleanupStack::PopAndDestroy(pProps); |
|
2529 |
|
2530 CleanupStack::PushL(pPropsAsXml); |
|
2531 TPtrC8 properties = pPropsAsXml->Des(); |
|
2532 |
|
2533 |
|
2534 HBufC8* pResponseTo = NULL; |
|
2535 |
|
2536 // Invoke service once. But, due this is performed synchronously within the SAME PROCESS, we need |
|
2537 // another thread (otherwise ActiveScheduler cannot serve this WS request, ServiceL is never invoked). |
|
2538 |
|
2539 |
|
2540 // NOTE-NOTE: if WS-I is used instead of REST, timing changes and race-codition occurs |
|
2541 |
|
2542 TConsumerTestTask task( *ipConnection, // not used in this test case |
|
2543 request, // not used in this test case |
|
2544 KDefaultBasicWebServicesFrameworkID, |
|
2545 TConsumerTestTask::ECreateConnAndSubmit, |
|
2546 pResponseTo); |
|
2547 task.ipOwner = this; |
|
2548 |
|
2549 task.iEndpoint.Set(KHostletEndpoint); |
|
2550 // variant point 2: |
|
2551 // -- comment out above line: task.iEndpoint.Set(KHostletEndpoint); |
|
2552 |
|
2553 task.ipSoapMsg = pSoapMessage; |
|
2554 |
|
2555 task.iProperties.Set(properties); |
|
2556 |
|
2557 RThread localThread; |
|
2558 _LIT(KThreadName, "tSubmitWsiFromThread_"); |
|
2559 |
|
2560 TInt createThreadRetVal = CreateThreadForConsumerTask(localThread, KThreadName, task); |
|
2561 |
|
2562 LOCAL_ASSERT( createThreadRetVal == KErrNone ); |
|
2563 |
|
2564 // Now start the thread that will execute SubmitL: |
|
2565 localThread.Resume(); // start the thread |
|
2566 |
|
2567 // Would NOT work: // TInt transactionIdOrError = ipConnection->SubmitL(KRequest, pResponseTo); |
|
2568 // LOCAL_ASSERT(transactionIdOrError > KErrNone); |
|
2569 |
|
2570 // Respond to consumer ONCE => only one call.. |
|
2571 StartActiveScheduler(1); |
|
2572 |
|
2573 |
|
2574 // Push the local pointer to the response descriptor into cleanupstack: |
|
2575 CleanupStack::PushL(pResponseTo); |
|
2576 |
|
2577 // ---- Following conditions MUST be met ---- |
|
2578 |
|
2579 // SubmitL must return KErrNone(!) |
|
2580 // Note: from Submit, one cannot get TXN ID, but either OK (KErrNone) or an error |
|
2581 //LOCAL_ASSERT( task.iStatusCode == KErrNone ); |
|
2582 |
|
2583 |
|
2584 // 1. Hostlet receives request that consumer made |
|
2585 LOCAL_ASSERT( *ipHostlet->iRequests[0] == request); |
|
2586 |
|
2587 // 2. Consumer receives response that hostlet provided |
|
2588 //LOCAL_ASSERT( *pResponseTo == *ipHostlet->iResponses[0]); |
|
2589 |
|
2590 |
|
2591 // 3. Hostlet receives completion code (delivery code) |
|
2592 LOCAL_ASSERT( ipHostlet->iCompletionCodes[0] == KErrNone ); // true in this "OK" -test case |
|
2593 |
|
2594 // --- Conditions END --- |
|
2595 |
|
2596 // Response received, de-alloc response, request properties, request as XML descs and SOAP-MSG obj |
|
2597 CleanupStack::PopAndDestroy( pResponseTo ); |
|
2598 |
|
2599 CleanupStack::PopAndDestroy( pPropsAsXml ); |
|
2600 |
|
2601 CleanupStack::PopAndDestroy( pAsXml ); |
|
2602 |
|
2603 CleanupStack::PopAndDestroy( pSoapMessage ); |
|
2604 |
|
2605 localThread.Close(); |
|
2606 delete ipConnection; |
|
2607 ipConnection = NULL; |
|
2608 delete ipHostletConnection; |
|
2609 ipHostletConnection = NULL; |
|
2610 delete ipHostlet; |
|
2611 ipHostlet = NULL; |
|
2612 delete ipConsumer; |
|
2613 ipConsumer = NULL; |
|
2614 |
|
2615 return KErrNone; |
|
2616 } |
|
2617 |
|
2618 */ |
|
2619 |
|
2620 |
|
2621 |
|
2622 /* |
|
2623 // DOES NOT WORK, submit blocks the single ActiveScheduler... |
|
2624 TInt ChostconnTester::UT_CSenHostletConnection_Submit_WSIL(CStifItemParser& aItem) |
|
2625 { |
|
2626 |
|
2627 ipHostlet = CTestHostlet::NewL(this); // uses default implementations for servicel and onservicecompletel |
|
2628 ipConsumer = CTestConsumer::NewL(this); // uses the default implementations for setstatus, handlemessage, handleerror |
|
2629 |
|
2630 ipHostletConnection = CSenHostletConnection::NewL(*ipHostlet); |
|
2631 |
|
2632 CSenServicePattern* pPattern = |
|
2633 CSenServicePattern::NewLC(KNullDesC8, KHostletContract); |
|
2634 pPattern->SetFrameworkIdL(KDefaultBasicWebServicesFrameworkID); |
|
2635 |
|
2636 ipConnection = CSenServiceConnection::NewL(*ipConsumer, *pPattern); |
|
2637 CleanupStack::PopAndDestroy(pPattern); |
|
2638 |
|
2639 // Construct service connection |
|
2640 StartActiveScheduler(1); |
|
2641 |
|
2642 // Check that the Status of the ServiceConnection |
|
2643 // is KSenConnectionStatusReady |
|
2644 LOCAL_ASSERT( ipConsumer->iConnectionStatus == KSenConnectionStatusReady); |
|
2645 |
|
2646 CSenSoapMessage* pSOAPMessage = CreateAuthRequestLC(); |
|
2647 HBufC8* pAsXml = pSOAPMessage->AsXmlL(); |
|
2648 CleanupStack::PushL(pAsXml); |
|
2649 |
|
2650 CSenTransportProperties* pProps = CSenTransportProperties::NewLC(); |
|
2651 pProps->SetPropertyL(_L8("KTestProperty"), _L8("KTestPropertyValue")); |
|
2652 HBufC8* pPropsAsXml = pProps->AsUtf8LC(); |
|
2653 |
|
2654 HBufC8* pResponseTo = NULL; |
|
2655 |
|
2656 TInt transactionIdOrError = ipConnection->SubmitL(*pSOAPMessage, *pPropsAsXml, pResponseTo); |
|
2657 LOCAL_ASSERT(transactionIdOrError > KErrNone); |
|
2658 |
|
2659 |
|
2660 // Invoke service ONCE (one call to ServiceL), respond to consumer ONCE => two calls |
|
2661 StartActiveScheduler(2); |
|
2662 |
|
2663 // ---- Following conditions MUST be met ---- |
|
2664 |
|
2665 // 1. Hostlet receives request that consumer made |
|
2666 LOCAL_ASSERT( *ipHostlet->iRequests[0] == *pAsXml); |
|
2667 |
|
2668 // 2. Consumer receives response that hostlet provided |
|
2669 LOCAL_ASSERT( *pResponseTo == *ipHostlet->iResponses[0]); |
|
2670 |
|
2671 // 3. Hostlet receives completion code (delivery code) |
|
2672 LOCAL_ASSERT( ipHostlet->iTxnIds[0] == transactionIdOrError ); |
|
2673 LOCAL_ASSERT( ipHostlet->iCompletionCodes[0] == KErrNone ); // true in this "OK" -test case |
|
2674 |
|
2675 // --- Conditions END --- |
|
2676 |
|
2677 CleanupStack::PopAndDestroy(pPropsAsXml); |
|
2678 CleanupStack::PopAndDestroy(pProps); |
|
2679 CleanupStack::PopAndDestroy(pAsXml); |
|
2680 CleanupStack::PopAndDestroy(pSOAPMessage); |
|
2681 delete ipConnection; |
|
2682 ipConnection = NULL; |
|
2683 delete ipHostletConnection; |
|
2684 ipHostletConnection = NULL; |
|
2685 delete ipHostlet; |
|
2686 ipHostlet = NULL; |
|
2687 delete ipConsumer; |
|
2688 ipConsumer = NULL; |
|
2689 |
|
2690 |
|
2691 return KErrNone; |
|
2692 } |
|
2693 |
|
2694 */ |
|
2695 /* |
|
2696 TInt ChostconnTester::UT_CSenHostletConnection_Send_WSIL() |
|
2697 { |
|
2698 |
|
2699 // This case uses default implementations for servicel and onservicecompletel: |
|
2700 ipHostlet = CTestHostlet::NewL(this, NULL, NULL, ChostconnTester::UT_CSenHostletConnection_WSI_DescribeService_2L); |
|
2701 |
|
2702 // This case uses the default implementations for setstatus, handlemessage, handleerror: |
|
2703 ipConsumer = CTestConsumer::NewL(this); |
|
2704 |
|
2705 ipHostletConnection = CSenHostletConnection::NewL(*ipHostlet); |
|
2706 |
|
2707 CSenServicePattern* pPattern = CSenServicePattern::NewLC(KNullDesC8, KHostletContract); |
|
2708 // Choose WS-I service invokation framework |
|
2709 pPattern->SetFrameworkIdL(KDefaultBasicWebServicesFrameworkID); |
|
2710 |
|
2711 ipConnection = CSenServiceConnection::NewL(*ipConsumer, *pPattern); |
|
2712 CleanupStack::PopAndDestroy(pPattern); |
|
2713 |
|
2714 // Construct service connection |
|
2715 StartActiveScheduler(1); |
|
2716 |
|
2717 // Check that NO HandleErrorL callback was received: |
|
2718 LOCAL_ASSERT( ipConsumer->iErrorCode == KErrSenHostNotAvailable ); |
|
2719 |
|
2720 // Check that the Status of the ServiceConnection |
|
2721 // is KSenConnectionStatusReady |
|
2722 LOCAL_ASSERT( ipConsumer->iConnectionStatus == KSenConnectionStatusCreateFailed); |
|
2723 |
|
2724 /* |
|
2725 // Check that NO HandleErrorL callback was received: |
|
2726 LOCAL_ASSERT( ipConsumer->iErrorCode == KErrNone ); |
|
2727 |
|
2728 |
|
2729 // Check that the Status of the ServiceConnection |
|
2730 // is KSenConnectionStatusReady |
|
2731 LOCAL_ASSERT( ipConsumer->iConnectionStatus == KSenConnectionStatusReady); |
|
2732 |
|
2733 CSenSoapMessage* pSOAPMessage = CreateAuthRequestLC(); |
|
2734 HBufC8* pAsXml = pSOAPMessage->AsXmlL(); |
|
2735 CleanupStack::PushL(pAsXml); |
|
2736 TPtrC8 request = pAsXml->Des(); |
|
2737 |
|
2738 TInt transactionIdOrError = ipConnection->SendL(*pSOAPMessage); |
|
2739 LOCAL_ASSERT(transactionIdOrError > KErrNone); |
|
2740 |
|
2741 // Invoke service ONCE (one SendL calling ServiceL), respond to consumer ONCE => two calls |
|
2742 StartActiveScheduler(2); |
|
2743 |
|
2744 // ---- Following conditions MUST be met ---- |
|
2745 |
|
2746 // 1. Hostlet receives request that consumer made |
|
2747 LOCAL_ASSERT( *ipHostlet->iRequests[0] == request); |
|
2748 |
|
2749 // 2. Consumer receives response that hostlet provided |
|
2750 LOCAL_ASSERT( *ipConsumer->iResponses[0] == *ipHostlet->iResponses[0]); |
|
2751 LOCAL_ASSERT( ipConsumer->iResponseCodes[0] == ipHostlet->iResponseCodes[0]) |
|
2752 |
|
2753 // 3. Hostlet receives completion code (delivery code) |
|
2754 LOCAL_ASSERT( ipHostlet->iTxnIds[0] == transactionIdOrError ); |
|
2755 LOCAL_ASSERT( ipHostlet->iCompletionCodes[0] == KErrNone ); // true in this "OK" -test case |
|
2756 |
|
2757 |
|
2758 // --- Conditions END --- |
|
2759 |
|
2760 CleanupStack::PopAndDestroy(pAsXml); |
|
2761 CleanupStack::PopAndDestroy(pSOAPMessage); |
|
2762 */ |
|
2763 /* |
|
2764 delete ipConnection; |
|
2765 ipConnection = NULL; |
|
2766 |
|
2767 delete ipHostletConnection; |
|
2768 ipHostletConnection = NULL; |
|
2769 |
|
2770 delete ipConsumer; |
|
2771 ipConsumer = NULL; |
|
2772 |
|
2773 delete ipHostlet; |
|
2774 ipHostlet = NULL; |
|
2775 |
|
2776 |
|
2777 return KErrNone; |
|
2778 } |
|
2779 |
|
2780 */ |
|
2781 /* |
|
2782 TInt ChostconnTester::UT_CSenHostletConnection_DescEndpoint_Send_WSIL() |
|
2783 { |
|
2784 |
|
2785 // This case uses default implementations for servicel and onservicecompletel: |
|
2786 // NOTE: for ALL OTHER BUT REST hostlets, one must DESCRIBE framework ID |
|
2787 // via MSenHostlet::DescribeServiceL(!) |
|
2788 ipHostlet = CTestHostlet::NewL(this, NULL, NULL, ChostconnTester::UT_CSenHostletConnection_WSI_DescribeServiceL); |
|
2789 |
|
2790 // This case uses the default implementations for setstatus, handlemessage, handleerror: |
|
2791 ipConsumer = CTestConsumer::NewL(this); |
|
2792 |
|
2793 ipHostletConnection = CSenHostletConnection::NewL(*ipHostlet); |
|
2794 |
|
2795 CSenServicePattern* pPattern = CSenServicePattern::NewLC(KHostletEndpoint, KHostletContract); |
|
2796 // Choose WS-I service invokation framework |
|
2797 pPattern->SetFrameworkIdL(KDefaultBasicWebServicesFrameworkID); |
|
2798 |
|
2799 ipConnection = CSenServiceConnection::NewL(*ipConsumer, *pPattern); |
|
2800 CleanupStack::PopAndDestroy(pPattern); |
|
2801 |
|
2802 // Construct service connection |
|
2803 StartActiveScheduler(1); |
|
2804 |
|
2805 // Check that NO HandleErrorL callback was received: |
|
2806 LOCAL_ASSERT( ipConsumer->iErrorCode == KErrNone ); |
|
2807 |
|
2808 |
|
2809 // Check that the Status of the ServiceConnection |
|
2810 // is KSenConnectionStatusReady |
|
2811 LOCAL_ASSERT( ipConsumer->iConnectionStatus == KSenConnectionStatusReady); |
|
2812 |
|
2813 CSenSoapMessage* pSOAPMessage = CreateAuthRequestLC(); |
|
2814 HBufC8* pAsXml = pSOAPMessage->AsXmlL(); |
|
2815 CleanupStack::PushL(pAsXml); |
|
2816 TPtrC8 request = pAsXml->Des(); |
|
2817 |
|
2818 TInt transactionIdOrError = ipConnection->SendL(*pSOAPMessage); |
|
2819 LOCAL_ASSERT(transactionIdOrError > KErrNone); |
|
2820 |
|
2821 // Invoke service ONCE (one SendL calling ServiceL), respond to consumer ONCE => two calls |
|
2822 StartActiveScheduler(2); |
|
2823 |
|
2824 // ---- Following conditions MUST be met ---- |
|
2825 |
|
2826 // 1. Hostlet receives request that consumer made |
|
2827 LOCAL_ASSERT( *ipHostlet->iRequests[0] == request); |
|
2828 |
|
2829 // 2. Consumer receives response that hostlet provided |
|
2830 LOCAL_ASSERT( *ipConsumer->iResponses[0] == *ipHostlet->iResponses[0]); |
|
2831 LOCAL_ASSERT( ipConsumer->iResponseCodes[0] == ipHostlet->iResponseCodes[0]) |
|
2832 |
|
2833 // 3. Hostlet receives completion code (delivery code) |
|
2834 LOCAL_ASSERT( ipHostlet->iTxnIds[0] == transactionIdOrError ); |
|
2835 LOCAL_ASSERT( ipHostlet->iCompletionCodes[0] == KErrNone ); // true in this "OK" -test case |
|
2836 |
|
2837 |
|
2838 // --- Conditions END --- |
|
2839 |
|
2840 CleanupStack::PopAndDestroy(pAsXml); |
|
2841 CleanupStack::PopAndDestroy(pSOAPMessage); |
|
2842 |
|
2843 delete ipConnection; |
|
2844 ipConnection = NULL; |
|
2845 |
|
2846 delete ipHostletConnection; |
|
2847 ipHostletConnection = NULL; |
|
2848 |
|
2849 delete ipConsumer; |
|
2850 ipConsumer = NULL; |
|
2851 |
|
2852 delete ipHostlet; |
|
2853 ipHostlet = NULL; |
|
2854 |
|
2855 |
|
2856 return KErrNone; |
|
2857 } |
|
2858 |
|
2859 |
|
2860 */ |
|
2861 |
|
2862 // Leaks memory |
|
2863 TInt ChostconnTester::UT_CSenHostletConnection_2SC1HCL(CStifItemParser& aItem) |
|
2864 { |
|
2865 TestModuleIf().SetBehavior( CTestModuleIf::ETestLeaksHandles ); |
|
2866 |
|
2867 |
|
2868 // The only HC |
|
2869 ipHostlet = CTestHostlet::NewL(this); // uses default implementations for servicel and onservicecompletel |
|
2870 ipHostletConnection = CSenHostletConnection::NewL(*ipHostlet); |
|
2871 |
|
2872 |
|
2873 // First SC |
|
2874 ipConsumer = CTestConsumer::NewL(this); // uses the default implementations for setstatus, handlemessage, handleerror |
|
2875 CSenServicePattern* pPattern = |
|
2876 CSenServicePattern::NewLC(KNullDesC8, KHostletContract); |
|
2877 pPattern->SetFrameworkIdL(KDefaultRestServicesFrameworkID); |
|
2878 ipConnection = CSenServiceConnection::NewL(*ipConsumer, *pPattern); |
|
2879 CleanupStack::PopAndDestroy(pPattern); |
|
2880 |
|
2881 // Construct service connection |
|
2882 StartActiveScheduler(1); |
|
2883 |
|
2884 // Check that the Status of the ServiceConnection |
|
2885 // is KSenConnectionStatusReady |
|
2886 LOCAL_ASSERT( ipConsumer->iConnectionStatus == KSenConnectionStatusReady); |
|
2887 |
|
2888 // Second SC |
|
2889 ipConsumer1 = CTestConsumer::NewL(this); // uses the default implementations for setstatus, handlemessage, handleerror |
|
2890 CSenServicePattern* pPattern1 = |
|
2891 CSenServicePattern::NewLC(KNullDesC8, KHostletContract); |
|
2892 pPattern1->SetFrameworkIdL(KDefaultRestServicesFrameworkID); |
|
2893 ipConnection1 = CSenServiceConnection::NewL(*ipConsumer1, *pPattern1); |
|
2894 CleanupStack::PopAndDestroy(pPattern1); |
|
2895 |
|
2896 // Construct service connection |
|
2897 StartActiveScheduler(1); |
|
2898 |
|
2899 // Check that the Status of the ServiceConnection |
|
2900 // is KSenConnectionStatusReady |
|
2901 LOCAL_ASSERT( ipConsumer1->iConnectionStatus == KSenConnectionStatusReady); |
|
2902 |
|
2903 _LIT8(KRequest, "<ab:Query xmlns:ab=\"urn:nokia:test:addrbook:2004-09\"><ab:QueryItem><ab:Select>/ab:Card[containts[ab:N/ab:FAMILY,\'Bob\'] or containts[ab:N/ab:GIVEN,\'Bob\'] or containts[ab:TEL,\'Bob\']]</ab:Select></ab:QueryItem></ab:Query>"); |
|
2904 _LIT8(KRequest1, "<ab:Query xmlns:ab=\"urn:nokia:test:addrbook:2004-09\"><ab:QueryItem><ab:Select>/ab:Card[containts[ab:N/ab:FAMILY,\'Bob1\'] or containts[ab:N/ab:GIVEN,\'Bob1\'] or containts[ab:TEL,\'Bob1\']]</ab:Select></ab:QueryItem></ab:Query>"); |
|
2905 |
|
2906 |
|
2907 TInt transactionIdOrError = ipConnection->SendL(KRequest); |
|
2908 LOCAL_ASSERT(transactionIdOrError > KErrNone); |
|
2909 |
|
2910 // Invoke service ONCE (one call to ServiceL), respond to consumer ONCE => two calls |
|
2911 StartActiveScheduler(2); |
|
2912 |
|
2913 TInt transactionIdOrError1 = ipConnection1->SendL(KRequest1); |
|
2914 LOCAL_ASSERT(transactionIdOrError1 > KErrNone); |
|
2915 |
|
2916 // Invoke service ONCE (one call to ServiceL), respond to consumer ONCE => two calls |
|
2917 StartActiveScheduler(2); |
|
2918 |
|
2919 // ---- Following conditions MUST be met ---- |
|
2920 |
|
2921 // First SC |
|
2922 // 1. Hostlet receives request that consumer made |
|
2923 LOCAL_ASSERT( *ipHostlet->iRequests[0] == KRequest); |
|
2924 |
|
2925 // 2. The 1st Consumer receives response that hostlet provided |
|
2926 LOCAL_ASSERT( *ipConsumer->iResponses[0] == *ipHostlet->iResponses[0]); |
|
2927 LOCAL_ASSERT( ipConsumer->iResponseCodes[0] == ipHostlet->iResponseCodes[0]) |
|
2928 |
|
2929 // 3. Hostlet receives completion code from 1st Consumer (delivery code) |
|
2930 //We should check TxnID as after Dispatcher Implementation VTxnID get return from SendL |
|
2931 // LOCAL_ASSERT( ipHostlet->iTxnIds[0] == transactionIdOrError ); |
|
2932 LOCAL_ASSERT( ipHostlet->iCompletionCodes[0] == KErrNone ); // true in this "OK" -test case |
|
2933 |
|
2934 // Second SC |
|
2935 // 1. Hostlet receives request that consumer made |
|
2936 LOCAL_ASSERT( *ipHostlet->iRequests[1] == KRequest1); |
|
2937 |
|
2938 // 2. The 2nd Consumer receives response that hostlet provided |
|
2939 LOCAL_ASSERT( *ipConsumer1->iResponses[0] == *ipHostlet->iResponses[1]); |
|
2940 LOCAL_ASSERT( ipConsumer1->iResponseCodes[0] == ipHostlet->iResponseCodes[1]) |
|
2941 |
|
2942 // 3. Hostlet receives completion code from 2nd Consumer (delivery code) |
|
2943 // LOCAL_ASSERT( ipHostlet->iTxnIds[1] == transactionIdOrError1 ); |
|
2944 LOCAL_ASSERT( ipHostlet->iCompletionCodes[1] == KErrNone ); // true in this "OK" -test case |
|
2945 |
|
2946 // --- Conditions END --- |
|
2947 delete ipHostletConnection; |
|
2948 ipHostletConnection = NULL; |
|
2949 |
|
2950 delete ipHostlet; |
|
2951 ipHostlet = NULL; |
|
2952 |
|
2953 delete ipConnection; |
|
2954 ipConnection = NULL; |
|
2955 |
|
2956 delete ipConsumer; |
|
2957 ipConsumer = NULL; |
|
2958 |
|
2959 delete ipConnection1; |
|
2960 ipConnection1 = NULL; |
|
2961 |
|
2962 delete ipConsumer1; |
|
2963 ipConsumer1 = NULL; |
|
2964 |
|
2965 |
|
2966 return KErrNone; |
|
2967 } |
|
2968 |
|
2969 |
|
2970 TInt ChostconnTester::UT_CSenHostletConnection_RespondWithPropertiesL(CStifItemParser& aItem) |
|
2971 { |
|
2972 |
|
2973 // Try to send one message from ServiceConnection to HostletConnection, |
|
2974 // which provides response (TRANSPORT) properties to the response message |
|
2975 |
|
2976 // Construct Hostlet |
|
2977 |
|
2978 ipHostlet = CTestHostlet::NewL(this, &ChostconnTester::UT_CSenHostletConnection_RespondWithPropertiesL_OnServiceL); |
|
2979 ipHostletConnection = CSenHostletConnection::NewL(*ipHostlet); |
|
2980 |
|
2981 // Construct ServiceConnection |
|
2982 ipConsumer = CTestConsumer::NewL(this); // uses the default implementations for setstatus, handlemessage, handleerror |
|
2983 CSenServicePattern* pPattern = |
|
2984 CSenServicePattern::NewLC(KNullDesC8, KHostletContract); |
|
2985 pPattern->SetFrameworkIdL(KDefaultRestServicesFrameworkID); |
|
2986 |
|
2987 ipConnection = CSenServiceConnection::NewL(*ipConsumer, *pPattern); |
|
2988 CleanupStack::PopAndDestroy(pPattern); |
|
2989 StartActiveScheduler(1); |
|
2990 |
|
2991 // Check that the Status of the ServiceConnection |
|
2992 // is KSenConnectionStatusReady |
|
2993 LOCAL_ASSERT( ipConsumer->iConnectionStatus == KSenConnectionStatusReady); |
|
2994 |
|
2995 // ServiceConnection is ready |
|
2996 // => Send request to the Hostlet |
|
2997 _LIT8(KRequest, "<ab:Query xmlns:ab=\"urn:nokia:test:addrbook:2004-09\"><ab:QueryItem><ab:Select>/ab:Card[containts[ab:N/ab:FAMILY,\'Bob\'] or containts[ab:N/ab:GIVEN,\'Bob\'] or containts[ab:TEL,\'Bob\']]</ab:Select></ab:QueryItem></ab:Query>"); |
|
2998 TInt transactionIdOrError = ipConnection->SendL(KRequest); |
|
2999 |
|
3000 // Check that SendL returned transaction Id |
|
3001 LOCAL_ASSERT(transactionIdOrError > KErrNone); |
|
3002 |
|
3003 // Invoke service ONCE (one call to ServiceL), respond to consumer ONCE => two calls |
|
3004 StartActiveScheduler(2); |
|
3005 |
|
3006 // ---- Following conditions MUST be met ---- |
|
3007 |
|
3008 // 1. Hostlet receives request that consumer made |
|
3009 LOCAL_ASSERT( *ipHostlet->iRequests[0] == KRequest); |
|
3010 |
|
3011 // 2. Consumer receives response that hostlet provided |
|
3012 LOCAL_ASSERT( *ipConsumer->iResponses[0] == *ipHostlet->iResponses[0]); |
|
3013 LOCAL_ASSERT( ipConsumer->iResponseCodes[0] == ipHostlet->iResponseCodes[0]) |
|
3014 |
|
3015 // 3. Hostlet receives completion code (delivery code) |
|
3016 LOCAL_ASSERT( ipHostlet->iTxnIds[0] == transactionIdOrError ); |
|
3017 LOCAL_ASSERT( ipHostlet->iCompletionCodes[0] == KErrNone ); // true in this "OK" -test case |
|
3018 |
|
3019 MSenProperties* pHostletProps = ipHostlet->iResponseProps[0]; |
|
3020 |
|
3021 LOCAL_ASSERT( ipHostlet->iResponseProps[0] != NULL ); // The tp that was sent |
|
3022 LOCAL_ASSERT( ipConsumer->iResponseProperties[0] != NULL); // The tp that was received |
|
3023 |
|
3024 |
|
3025 |
|
3026 |
|
3027 HBufC8* pSerializedPropsSentByHC = ipHostlet->iResponseProps[0]->AsUtf8LC(); // push |
|
3028 HBufC8* pSerializedPropsReceivedBySC = ipConsumer->iResponseProperties[0]->AsUtf8LC(); // push |
|
3029 |
|
3030 LOCAL_ASSERT( *pSerializedPropsSentByHC == *pSerializedPropsReceivedBySC ); |
|
3031 |
|
3032 /*EUNIT_PRINT(_L("=> Properties that HC sent:"));*/ |
|
3033 RDebug::Print (_L("=> Properties that HC sent:")); |
|
3034 RDebug::RawPrint(*pSerializedPropsSentByHC); |
|
3035 RDebug::Print(_L("=> Properties that SC received:")); |
|
3036 RDebug::RawPrint(*pSerializedPropsReceivedBySC); |
|
3037 |
|
3038 CleanupStack::PopAndDestroy(pSerializedPropsReceivedBySC); // SC's TP AsUtf8LC |
|
3039 CleanupStack::PopAndDestroy(pSerializedPropsSentByHC); // HC's TP AsUtf8LC |
|
3040 |
|
3041 |
|
3042 // --- Conditions END --- |
|
3043 |
|
3044 delete ipConnection; |
|
3045 ipConnection = NULL; |
|
3046 delete ipHostletConnection; |
|
3047 ipHostletConnection = NULL; |
|
3048 delete ipHostlet; |
|
3049 ipHostlet = NULL; |
|
3050 delete ipConsumer; |
|
3051 ipConsumer = NULL; |
|
3052 |
|
3053 return KErrNone; |
|
3054 } |
|
3055 |
|
3056 |
|
3057 |
|
3058 CSenSoapMessage* ChostconnTester::CreateAuthRequestLC() |
|
3059 { |
|
3060 _LIT8(KRequest, "<ab:Query xmlns:ab=\"urn:nokia:test:addrbook:2004-09\"><ab:QueryItem><ab:Select>/ab:Card[containts[ab:N/ab:FAMILY,\'Bob\'] or containts[ab:N/ab:GIVEN,\'Bob\'] or containts[ab:TEL,\'Bob\']]</ab:Select></ab:QueryItem></ab:Query>"); |
|
3061 CSenSoapMessage* pSOAPMessage = CSenSoapMessage::NewL(); |
|
3062 CleanupStack::PushL(pSOAPMessage); |
|
3063 |
|
3064 //xxxxxxxx*************** CorrelationHeader starts *************************** |
|
3065 CSenBaseElement* pElement = CSenBaseElement::NewL(KHostletContract, _L8("Correlation"), _L8("sb:Correlation")); |
|
3066 CleanupStack::PushL(pElement); |
|
3067 |
|
3068 pElement->AddAttrL(_L8("messageID"),_L8("")); |
|
3069 pElement->AddAttrL(_L8("refToMessageID"),_L8("")); |
|
3070 |
|
3071 TTime t; |
|
3072 t.HomeTime(); |
|
3073 TBuf8<SenDateUtils::KXmlDateTimeMaxLength> ts; |
|
3074 SenDateUtils::ToXmlDateTimeUtf8L(ts, t); |
|
3075 pElement->AddAttrL(_L8("timestamp"), ts); |
|
3076 |
|
3077 pSOAPMessage->AddHeaderL(*pElement); // pElement will be owned by pSOAPMessage |
|
3078 CleanupStack::Pop(pElement); |
|
3079 //************************ CorrelationHeader ends **************************** |
|
3080 |
|
3081 pSOAPMessage->SetBodyL(KRequest); |
|
3082 return pSOAPMessage; |
|
3083 } |
|
3084 |
|
3085 // [End of File] - Do not remove |