applayerprotocols/httptransportfw/Test/TestScriptTest/CPipeliningTestEngine.cpp
changeset 0 b16258d2340f
child 12 f21293830889
equal deleted inserted replaced
-1:000000000000 0:b16258d2340f
       
     1 // Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #include "httptestutils.h"
       
    17 #include "CPipeliningTestEngine.h"
       
    18 #include "CPipeliningTestServer.h"
       
    19 #include "CPipeliningTestClient.h"
       
    20 
       
    21 #include "CPipeliningTestParams.h"
       
    22 #include "CPipeliningTestCase.h"
       
    23 #include "CPipeliningConfigTest.h"
       
    24 
       
    25 #include "ctestcaselocalandremotehost.h"
       
    26 
       
    27 #if !defined(__TESTSCRIPTS_H__)
       
    28 #include "TestScripts.h"
       
    29 #endif
       
    30 
       
    31 
       
    32 enum TPanic
       
    33 	{
       
    34 	EFailedToCreateEngine,
       
    35 	EFailedToReadIniFile
       
    36 	};
       
    37 	
       
    38 
       
    39 _LIT(KHttpPipeliningTestCompName, 	"pipelining");
       
    40 _LIT(KHttpPipeliningTestScriptName, "pipelining.ini");
       
    41 
       
    42 _LIT(KRunTestItemName, 				"RunTest");
       
    43 
       
    44 //TestCase
       
    45 _LIT(KTestCaseName,					"TestCaseName");
       
    46 _LIT(KTestBatchingEnabled,			"Batching");
       
    47 _LIT(KTestPipeliningEnabled,		"Pipelining");
       
    48 _LIT(KTestBufferSize,				"BufferSize");
       
    49 _LIT(KTestConnectionCount,			"ConnectionCount");
       
    50 _LIT(KTestTransactionCount,			"TotalTransactionCount");
       
    51 _LIT(KTestTransactionArr,			"TransactionList");
       
    52 _LIT(KRawRequest,					"RawRequest");
       
    53 _LIT(KRawResponse,					"RawResponse");
       
    54 _LIT(KExpectedRequest,				".ExpectedRequests");
       
    55 _LIT(KExpectedResponse,				".ExpectedResponses");
       
    56 _LIT(KTestUri,						"Uri");
       
    57 _LIT(KTestConn,						"Conn");
       
    58 _LIT(KError,						"Error");
       
    59 _LIT(KTransType,					"TransType");
       
    60 _LIT(KHeaderName,					"Header");
       
    61 _LIT(KHeaderVal,					".Val");
       
    62 _LIT(KTestReqMethod, 				"Method");
       
    63 
       
    64 
       
    65 _LIT(KTestHttpPipeliningTestTitle, "HTTP Pipelining Unit Test Harness");
       
    66 _LIT(KUriLog, "TestCaseParams: Uri[%d] = %S");
       
    67 _LIT(KRequestLog, "TestCaseParams: RawRequest [%d] = %S");
       
    68 _LIT(KResponseLog, "TestCaseParams: RawResponse [%d] = %S");
       
    69 _LIT(KHeaderLog, "TestCaseParams: Header [%d] = %S");
       
    70 _LIT(KHeaderValLog, "TestCaseParams: Header [%d] : Value [%d] = %S");
       
    71 
       
    72 
       
    73 CPipeliningTestEngine* CPipeliningTestEngine::NewL()
       
    74 	{
       
    75 	CPipeliningTestEngine* self = new (ELeave) CPipeliningTestEngine();
       
    76 	CleanupStack::PushL(self);
       
    77 	self->ConstructL();
       
    78 	CleanupStack::Pop(self);
       
    79 	return self;
       
    80 	}
       
    81 
       
    82 CPipeliningTestEngine::~CPipeliningTestEngine()
       
    83 	{
       
    84 	delete iTestServer;
       
    85 	delete iTestUtils;
       
    86 	}
       
    87 
       
    88 CPipeliningTestEngine::CPipeliningTestEngine()
       
    89 	{
       
    90 	}
       
    91 	
       
    92 void CPipeliningTestEngine::ConstructL()
       
    93 	{
       
    94 	iTestUtils = CHTTPTestUtils::NewL(KTestHttpPipeliningTestTitle());
       
    95 
       
    96 	iTestUtils->InitCommsL();
       
    97 	
       
    98 	iTestServer = CPipeliningTestServer::NewL(*iTestUtils, *this);
       
    99 	iTestServer->StartServerL();
       
   100 	}
       
   101 	
       
   102 void CPipeliningTestEngine::StartTestsL(TDesC& secName)
       
   103 	{	
       
   104 	TRAPD ( leaveErr,DoTestsL(secName));
       
   105 	if ( leaveErr != KErrNone )
       
   106 		{
       
   107 		_LIT(KTxtLeave, "Engine - Caught a Leave. Leave Error: %d");
       
   108 		iTestUtils->LogIt(KTxtLeave(), leaveErr);
       
   109 		_LIT(KTxtFailed, "**** TEST FAILED ****");
       
   110 		iTestUtils->LogIt(KTxtFailed);
       
   111 		User::LeaveIfError(leaveErr);
       
   112 		}
       
   113 	}
       
   114 
       
   115 void CPipeliningTestEngine::DoTestsL(TDesC& secName)
       
   116 	{
       
   117 	if((secName.Compare(_L("CONFIG_TEST1") ) == 0) || (secName.Compare(_L("CONFIG_TEST2") ) == 0) || (secName.Compare(_L("CONFIG_TEST3") ) == 0) || (secName.Compare(_L("CONFIG_TEST4") ) == 0))
       
   118 		{
       
   119 		DoPipeliningConfigTestsL(secName);
       
   120 		}
       
   121 	else
       
   122 		{
       
   123 		// Open the INI file to initialise the tests we're going to run
       
   124 		CScriptFile* iniFile = NULL;
       
   125 		TInt err = KErrNone;
       
   126 		
       
   127 		TRAP(err, iniFile = CScriptFile::NewL(*iTestUtils, KHttpPipeliningTestCompName(), KHttpPipeliningTestScriptName()));
       
   128 		if (err != KErrNone)
       
   129 			{
       
   130 			User::Leave(KErrNoMemory);
       
   131 			}
       
   132 		
       
   133 		CleanupStack::PushL(iniFile);
       
   134 				
       
   135 		// Create an array of sections from the script / ini file.
       
   136 		CArrayPtrFlat<CScriptSection>& sections=iniFile->Sections();
       
   137 
       
   138 		//create the  tests for iteration2 and  append them in the array
       
   139 		TInt secCount = sections.Count();
       
   140 		TInt count = secCount;
       
   141 		CScriptSection* section = NULL;
       
   142 
       
   143 		for ( TInt iter = 0 ; iter < count ; ++iter)
       
   144 			{
       
   145 			//create an array of tests to be sent to the engine
       
   146 			section = sections[iter];
       
   147 			
       
   148 			// TestCase
       
   149 			if ( section->SectionName().CompareF(secName) == 0)
       
   150 				{
       
   151 				TPtrC itemPtr(iniFile->Section(iter).Item(0).Item());
       
   152 				TInt itemFieldCount= iniFile->Section(iter).Items().Count();
       
   153 
       
   154 				TInt runTest = 0;
       
   155 				runTest = iniFile->ItemValue(iniFile->Section(iter).SectionName(), KRunTestItemName(), 0);
       
   156 				TPtrC runTestPtr = iniFile->Section(iter).ItemL(KRunTestItemName()).Value();
       
   157 				TLex  ptrToIntLex(runTestPtr);
       
   158 				ptrToIntLex.Val(runTest);
       
   159 			
       
   160 				if ( runTest == 1 )
       
   161 					{
       
   162 					CPipeliningTestParams* testCaseParams = CPipeliningTestParams::NewL(*iTestUtils);
       
   163 					CleanupStack::PushL(testCaseParams);
       
   164 							
       
   165 					TBuf<4> intStr;
       
   166 			
       
   167 					//Urichecking strings initialisation
       
   168 					HBufC* uriCheckingStringBuf = HBufC::NewL(10); 
       
   169 					CleanupStack::PushL(uriCheckingStringBuf);
       
   170 					TInt uriCtr = 1;
       
   171 					(uriCheckingStringBuf->Des()).Copy(KTestUri());					
       
   172 					intStr.Format(_L( "%d"), uriCtr++);
       
   173 					(uriCheckingStringBuf->Des()).Append(intStr);
       
   174 					
       
   175 					//RawRequest 
       
   176 					HBufC* rawRequestCheckingStringBuf = HBufC::NewL(24);
       
   177 					CleanupStack::PushL(rawRequestCheckingStringBuf);
       
   178 					TInt rawReqCtr = 1;
       
   179 					(rawRequestCheckingStringBuf->Des()).Copy(KRawRequest());					
       
   180 					intStr.Format(_L( "%d"), rawReqCtr++);
       
   181 					(rawRequestCheckingStringBuf->Des()).Append(intStr);
       
   182 					
       
   183 						
       
   184 					//RawResponse
       
   185 					HBufC* rawResponseCheckingStringBuf = HBufC::NewL(24);
       
   186 					CleanupStack::PushL(rawResponseCheckingStringBuf);
       
   187 					TInt rawRespCtr = 1;
       
   188 					(rawResponseCheckingStringBuf->Des()).Copy(KRawResponse());					
       
   189 					intStr.Format(_L( "%d"), rawRespCtr++);
       
   190 					(rawResponseCheckingStringBuf->Des()).Append(intStr);
       
   191 					
       
   192 					
       
   193 					//ConnRequest & ConnResponse
       
   194 					HBufC* connRequestArrStr = HBufC::NewL(32);
       
   195 					CleanupStack::PushL(connRequestArrStr);
       
   196 					HBufC* connResponseArrStr = HBufC::NewL(34);
       
   197 					CleanupStack::PushL(connResponseArrStr);
       
   198 					TInt connReqCtr = 1;
       
   199 					TInt connRespCtr = 1;
       
   200 					(connRequestArrStr->Des()).Copy(KTestConn());
       
   201 					(connResponseArrStr->Des()).Copy(KTestConn());
       
   202 					intStr.Format(_L( "%d"), connReqCtr++);
       
   203 					(connRequestArrStr->Des()).Append(intStr);
       
   204 					intStr.Format(_L( "%d"), connRespCtr++);
       
   205 					(connResponseArrStr->Des()).Append(intStr);
       
   206 					(connRequestArrStr->Des()).Append(KExpectedRequest());
       
   207 					(connResponseArrStr->Des()).Append(KExpectedResponse());
       
   208 					
       
   209 					//TransType
       
   210 					HBufC* transTypeStringBuf = HBufC::NewL(22);
       
   211 					CleanupStack::PushL(transTypeStringBuf);
       
   212 					TInt transTypeCtr = 2;
       
   213 					(transTypeStringBuf->Des()).Copy(KTransType());					
       
   214 					intStr.Format(_L( "%d"), transTypeCtr++);
       
   215 					(transTypeStringBuf->Des()).Append(intStr);		
       
   216 					
       
   217 					//Header2Process
       
   218 					HBufC* hdrName = HBufC::NewL(22);
       
   219 					CleanupStack::PushL(hdrName);
       
   220 					TInt hdrNameCtr = 1;
       
   221 					(hdrName->Des()).Copy(KHeaderName());					
       
   222 					intStr.Format(_L( "%d"), hdrNameCtr++);
       
   223 					(hdrName->Des()).Append(intStr);	
       
   224 					
       
   225 					//ValueOfHeader	
       
   226 					HBufC* hdrVal = HBufC::NewL(22);
       
   227 					CleanupStack::PushL(hdrVal);
       
   228 					HBufC* hdrValNext = HBufC::NewL(22);
       
   229 					CleanupStack::PushL(hdrValNext);
       
   230 					TInt hdrValCtr = 1;
       
   231 					(hdrVal->Des()).Copy(KHeaderName());
       
   232 					(hdrValNext->Des()).Copy(KHeaderName());					
       
   233 					intStr.Format(_L( "%d"), (hdrNameCtr - 1));
       
   234 					(hdrVal->Des()).Append(intStr);
       
   235 					intStr.Format(_L( "%d"), (hdrNameCtr));
       
   236 					(hdrValNext->Des()).Append(intStr);				
       
   237 					(hdrVal->Des()).Append(KHeaderVal());
       
   238 					(hdrValNext->Des()).Append(KHeaderVal());
       
   239 					intStr.Format(_L( "%d"), hdrValCtr++);
       
   240 					(hdrVal->Des()).Append(intStr);
       
   241 					(hdrValNext->Des()).Append(intStr);
       
   242 					
       
   243 					for (TInt fctr=0; fctr < itemFieldCount ; ++fctr)
       
   244 						{
       
   245 						//Get the field and value				
       
   246 						TPtrC itemFieldPtr(iniFile->Section(iter).Item(fctr).Item());
       
   247 						TPtrC itemValuePtr(iniFile->Section(iter).Item(fctr).Value());
       
   248 																
       
   249 						//which member of testcase param to set?
       
   250 						if (itemFieldPtr.Compare(KRunTestItemName()) == 0)
       
   251 							{
       
   252 							//RunTest
       
   253 							testCaseParams->SetRunTest(itemValuePtr);
       
   254 							TInt tempInt = 1;
       
   255 							iTestUtils->LogIt(_L("TestCaseParams: RunTest= %d"), tempInt);
       
   256 							}
       
   257 						
       
   258 						else if (itemFieldPtr.Compare(KTestPipeliningEnabled()) == 0)
       
   259 							{
       
   260 							//Pipelining Enabled
       
   261 							testCaseParams->EnablePipelining(itemValuePtr);
       
   262 							iTestUtils->LogIt(_L("TestCaseParams: PipeliningEnabled= %d"),testCaseParams->PipeliningEnabled());	
       
   263 							}
       
   264 						else if (itemFieldPtr.Compare(KTestBatchingEnabled()) == 0)			
       
   265 							{
       
   266 							//Batching Enabled
       
   267 							testCaseParams->EnableBatching( itemValuePtr );
       
   268 							iTestUtils->LogIt(_L("TestCaseParams: BatchingEnabled= %d"),testCaseParams->BatchingEnabled());	
       
   269 							}
       
   270 						else if (itemFieldPtr.Compare(KTestBufferSize()) == 0)				
       
   271 							{
       
   272 							//Buffer size
       
   273 							testCaseParams->SetBufferSize(itemValuePtr);
       
   274 							iTestUtils->LogIt(_L("TestCaseParams: BufferSize= %d"),testCaseParams->BufferSize());
       
   275 							}
       
   276 						else if (itemFieldPtr.Compare(KTestTransactionCount()) == 0)				
       
   277 							{
       
   278 							//TransactionCount
       
   279 							testCaseParams->SetTotalTransactionCount(itemValuePtr);
       
   280 							iTestUtils->LogIt(_L("TestCaseParams: TotalTransactionCount= %d"),testCaseParams->TotalTransactionCount());
       
   281 							}		
       
   282 						else if (itemFieldPtr.Compare(KTestConnectionCount()) == 0)			
       
   283 							{
       
   284 							//ConnectionCount
       
   285 							testCaseParams->SetConnectionCount(itemValuePtr);
       
   286 							iTestUtils->LogIt(_L("TestCaseParams: ConnectionCount= %d"),testCaseParams->ConnectionCount());
       
   287 							}
       
   288 						else if (itemFieldPtr.Compare(KError()) == 0)			
       
   289 							{
       
   290 							//Error
       
   291 							testCaseParams->SetErrorL(itemValuePtr);
       
   292 							iTestUtils->LogIt(_L("TestCaseParams: Error= %d"),testCaseParams->Error());
       
   293 							}
       
   294 						else if (itemFieldPtr.Compare(KTestCaseName()) == 0)				
       
   295 							{
       
   296 							//TestCaseName
       
   297 							testCaseParams->SetTestCaseNameL(itemValuePtr);
       
   298 							TPtrC tcName = testCaseParams->TestCaseName();
       
   299 							iTestUtils->LogIt(_L("TestCaseParams: TestCaseName= %S"),&tcName);
       
   300 							}
       
   301 						else if (itemFieldPtr.Compare(KTestTransactionArr()) == 0)
       
   302 							{
       
   303 							//TransArr
       
   304 							testCaseParams->SetSequenceArrL(itemValuePtr, ETransactionArray);
       
   305 							iTestUtils->LogIt(_L("TestCaseParams: SequenceArr= %S"), &itemValuePtr);
       
   306 							
       
   307 							}
       
   308 						else if(itemFieldPtr.Compare(KTestReqMethod()) == 0)
       
   309 							{
       
   310 							//Request Method
       
   311 							testCaseParams->SetReqMethodL(itemValuePtr);
       
   312 							TPtrC reqMethod = testCaseParams->ReqMethod();
       
   313 							iTestUtils->LogIt(_L("TestCaseParams: RequestMethod= %S"),&reqMethod );
       
   314 							}
       
   315 						else if ((itemFieldPtr.Compare(KTestUri()) == 0) || ((itemFieldPtr.Compare(*uriCheckingStringBuf)) == 0))
       
   316 							{
       
   317 							//Uri
       
   318 							testCaseParams->SetUriL(uriCtr-2, itemValuePtr);
       
   319 							TPtrC8 uri = (testCaseParams->UriL(uriCtr-2));
       
   320 							
       
   321 							//for logging
       
   322 							HBufC* uri16 = HBufC::NewL(uri.Length()*2);
       
   323 							CleanupStack::PushL(uri16);
       
   324 							(uri16->Des()).Copy(uri);
       
   325 							TPtrC uriPtr = (uri16->Des());					
       
   326 							iTestUtils->LogIt(KUriLog(), uriCtr-2 , &uriPtr);
       
   327 							CleanupStack::PopAndDestroy(uri16);
       
   328 							
       
   329 							//ready for checking next uri
       
   330 							(uriCheckingStringBuf->Des()).Copy(KTestUri());					
       
   331 							intStr.Format(_L( "%d"), uriCtr++);
       
   332 							(uriCheckingStringBuf->Des()).Append(intStr);
       
   333 							}
       
   334 
       
   335 						else if (itemFieldPtr.Compare(*rawRequestCheckingStringBuf) == 0)
       
   336 							{
       
   337 							//RawRequest
       
   338 							testCaseParams->SetRawRequestL(rawReqCtr-2, itemValuePtr);
       
   339 							TPtrC8 request = testCaseParams->RawRequest( rawReqCtr-2 );
       
   340 							
       
   341 							//for logging
       
   342 							HBufC* req16 = HBufC::NewL(request.Size() * 2);
       
   343 							CleanupStack::PushL(req16);
       
   344 							req16->Des().Copy(request);
       
   345 							TPtrC req16Ptr = req16->Des();
       
   346 							iTestUtils->LogIt(KRequestLog(),rawReqCtr-2,  &req16Ptr);
       
   347 							CleanupStack::PopAndDestroy(req16);
       
   348 							
       
   349 							//ready for checking next request
       
   350 							(rawRequestCheckingStringBuf->Des()).Copy(KRawRequest());					
       
   351 							intStr.Format(_L( "%d"), rawReqCtr++);
       
   352 							(rawRequestCheckingStringBuf->Des()).Append(intStr);
       
   353 							}
       
   354 
       
   355 						else if (itemFieldPtr.Compare(*rawResponseCheckingStringBuf) == 0)
       
   356 							{
       
   357 							//RawRequest
       
   358 							testCaseParams->SetRawResponseL(rawRespCtr-2, itemValuePtr);
       
   359 							TPtrC8 response = testCaseParams->RawResponse( rawRespCtr-2 );
       
   360 							
       
   361 							//for logging
       
   362 							HBufC* res16 = HBufC::NewL(response.Size() * 2);
       
   363 							CleanupStack::PushL(res16);
       
   364 							res16->Des().Copy(response);
       
   365 							TPtrC res16Ptr = res16->Des();
       
   366 							iTestUtils->LogIt(KResponseLog(),rawRespCtr-2,  &res16Ptr);
       
   367 							CleanupStack::PopAndDestroy(res16);
       
   368 							
       
   369 							//ready for checking next response
       
   370 							(rawResponseCheckingStringBuf->Des()).Copy(KRawResponse());					
       
   371 							intStr.Format(_L( "%d"), rawRespCtr++);
       
   372 							(rawResponseCheckingStringBuf->Des()).Append(intStr);
       
   373 							}
       
   374 
       
   375 						else if (itemFieldPtr.Compare(*connRequestArrStr) == 0)
       
   376 							{
       
   377 							//ConnReqArr
       
   378 							testCaseParams->SetSequenceArrL(itemValuePtr, ERequestArray);
       
   379 							TPtrC connRequestArrStrPtr = connRequestArrStr->Des();
       
   380 							iTestUtils->LogIt(_L("TestCaseParams: %S= %S"),&connRequestArrStrPtr, &itemValuePtr);
       
   381 							
       
   382 							//ready for checking next connReqArr
       
   383 							(connRequestArrStr->Des()).Copy(KTestConn());
       
   384 							intStr.Format(_L( "%d"), connReqCtr++);
       
   385 							(connRequestArrStr->Des()).Append(intStr);
       
   386 							(connRequestArrStr->Des()).Append(KExpectedRequest());
       
   387 							}
       
   388 							
       
   389 						else if (itemFieldPtr.Compare(*connResponseArrStr) == 0)
       
   390 							{
       
   391 							//ConnReqArr
       
   392 							testCaseParams->SetSequenceArrL(itemValuePtr, EResponseArray);
       
   393 							TPtrC connResponseArrStrPtr = connResponseArrStr->Des();
       
   394 							iTestUtils->LogIt(_L("TestCaseParams: %S= %S"),&connResponseArrStrPtr, &itemValuePtr);
       
   395 							
       
   396 							//ready for checking next connReqArr
       
   397 							(connResponseArrStr->Des()).Copy(KTestConn());
       
   398 							intStr.Format(_L( "%d"), connRespCtr++);
       
   399 							(connResponseArrStr->Des()).Append(intStr);
       
   400 							(connResponseArrStr->Des()).Append(KExpectedResponse());
       
   401 							}
       
   402 						
       
   403 						else if (itemFieldPtr.Compare(*transTypeStringBuf) == 0)
       
   404 							{
       
   405 							//TransType
       
   406 							TInt returnInt = testCaseParams->SetTransactionTypeL(( transTypeCtr - 1 ), itemValuePtr);
       
   407 							TPtrC transTypeStringBufPtr = transTypeStringBuf->Des();
       
   408 							iTestUtils->LogIt(_L("TestCaseParams: %S= %S"), &transTypeStringBufPtr, &itemValuePtr);
       
   409 							
       
   410 							TransInfo transTypeInfo = testCaseParams->TransactionType((transTypeCtr - 1));
       
   411 							
       
   412 							//ready for checking next transType
       
   413 							(transTypeStringBuf->Des()).Copy(KTransType());					
       
   414 							intStr.Format(_L( "%d"), transTypeCtr++);
       
   415 							(transTypeStringBuf->Des()).Append(intStr);
       
   416 							}
       
   417 						
       
   418 						else if (itemFieldPtr.Compare(*hdrName) == 0)				
       
   419 							{
       
   420 							//HeaderName
       
   421 							testCaseParams->SetHeaderToProcessL(hdrNameCtr-1, itemValuePtr);
       
   422 							TPtrC8 hdr2Process = testCaseParams->HeaderToProcess(hdrNameCtr-2);
       
   423 							
       
   424 							//for logging
       
   425 							HBufC *hdr16 = HBufC::NewLC(hdr2Process.Size() * 2);
       
   426 							hdr16->Des().Copy(hdr2Process);
       
   427 							TPtrC hdr16Ptr = hdr16->Des();
       
   428 							iTestUtils->LogIt(KHeaderLog(),hdrNameCtr-1,  &hdr16Ptr);
       
   429 							CleanupStack::PopAndDestroy(hdr16);
       
   430 							
       
   431 							//Get ready to look for next header
       
   432 							//ready for checking next response
       
   433 							(hdrName->Des()).Copy(KHeaderName());					
       
   434 							intStr.Format(_L( "%d"), hdrNameCtr++);
       
   435 							(hdrName->Des()).Append(intStr);
       
   436 							}
       
   437 							
       
   438 						else if ((itemFieldPtr.Compare(*hdrVal) == 0) || (itemFieldPtr.Compare(*hdrValNext) == 0))				
       
   439 							{
       
   440 							
       
   441 							if ((itemFieldPtr.Compare(*hdrValNext) == 0))
       
   442 								{
       
   443 								(hdrValNext->Des()).Copy(KHeaderName());					
       
   444 								intStr.Format(_L( "%d"), hdrNameCtr - 1);
       
   445 								(hdrValNext->Des()).Append(intStr);
       
   446 								(hdrValNext->Des()).Append(KHeaderVal());
       
   447 								intStr.Format(_L("%d"), 1);
       
   448 								(hdrValNext->Des()).Append(intStr);	
       
   449 								
       
   450 								hdrValCtr = 2;
       
   451 								}
       
   452 					
       
   453 							//Header Value Name
       
   454 							testCaseParams->SetHdrValL(hdrNameCtr-2, hdrValCtr-1, itemValuePtr);
       
   455 							TPtrC8 hdrValName = testCaseParams->HeaderVal(hdrNameCtr-2, hdrValCtr-1);
       
   456 							
       
   457 							//for logging
       
   458 							HBufC* hdrVal16 = HBufC::NewL(hdrValName.Size() * 2);
       
   459 							CleanupStack::PushL(hdrVal16);
       
   460 							hdrVal16->Des().Copy(hdrValName);
       
   461 							TPtrC hdrVal16Ptr = hdrVal16->Des();
       
   462 							iTestUtils->LogIt(KHeaderValLog(),hdrNameCtr-2, hdrValCtr-2,  &hdrVal16Ptr);
       
   463 							CleanupStack::PopAndDestroy(hdrVal16);
       
   464 							
       
   465 							//Get ready to look for next header
       
   466 							//ready for checking next response
       
   467 							(hdrVal->Des()).Copy(KHeaderName());
       
   468 							intStr.Format(_L( "%d"), hdrNameCtr - 2);	
       
   469 							(hdrVal->Des()).Append(intStr);						
       
   470 							(hdrVal->Des()).Append(KHeaderVal());					
       
   471 							intStr.Format(_L( "%d"), hdrValCtr++);
       
   472 							(hdrVal->Des()).Append(intStr);			
       
   473 							}
       
   474 							
       
   475 						
       
   476 						}//should have read all available params and values for a single test case
       
   477 
       
   478 						CleanupStack::PopAndDestroy( hdrValNext );
       
   479 						
       
   480 						CleanupStack::PopAndDestroy( hdrVal );
       
   481 						
       
   482 						CleanupStack::PopAndDestroy( hdrName );
       
   483 						
       
   484 						CleanupStack::PopAndDestroy( transTypeStringBuf );
       
   485 						
       
   486 						CleanupStack::PopAndDestroy( connResponseArrStr );
       
   487 						
       
   488 						CleanupStack::PopAndDestroy( connRequestArrStr );
       
   489 						
       
   490 						CleanupStack::PopAndDestroy( rawResponseCheckingStringBuf );			
       
   491 						
       
   492 						CleanupStack::PopAndDestroy( rawRequestCheckingStringBuf);
       
   493 						
       
   494 						CleanupStack::PopAndDestroy( uriCheckingStringBuf );
       
   495 				
       
   496 						
       
   497 						//Valid parameters? Need to fill up Validate & the switch handles
       
   498 						TRAPD(err, testCaseParams->ValidateL());
       
   499 						if (err == KErrNone)
       
   500 							{
       
   501 							CPipeliningTestCase* testCase1 = CPipeliningTestCase::NewL(*iTestUtils, *testCaseParams);
       
   502 							CleanupStack::PushL(testCase1);
       
   503 							RunTestL(secName, *testCase1);
       
   504 							CleanupStack::PopAndDestroy(testCase1);	
       
   505 							}
       
   506 						else
       
   507 							{
       
   508 							TPtrC testCaseNamePtr(testCaseParams->TestCaseName()) ;
       
   509 							switch (err)
       
   510 								{
       
   511 								case KErrGeneral :
       
   512 									iTestUtils->LogIt(_L("TestCaseParams->ValidateL(): %S : Invalid parameters"), &testCaseNamePtr );
       
   513 									break;							
       
   514 								default:
       
   515 									iTestUtils->LogIt(_L("TestCaseParams->ValidateL(): %S : Invalid parameters"), &testCaseNamePtr);
       
   516 									break;
       
   517 								}
       
   518 							}
       
   519 						
       
   520 						
       
   521 						testCaseParams->SetErrorL(_L("KErrNone"));
       
   522 						CleanupStack::Pop( testCaseParams );
       
   523 						delete testCaseParams;
       
   524 						}
       
   525 				break;
       
   526 				}
       
   527 				
       
   528 			}
       
   529 		CleanupStack::PopAndDestroy(iniFile);	
       
   530 		}
       
   531 	}
       
   532 
       
   533 void CPipeliningTestEngine::RunTestL(const TDesC& aSecName, MPipeliningTestCase& aTestCase)
       
   534 	{
       
   535 	// Run a single test case
       
   536 	iTestCase = &aTestCase;
       
   537 	iTestFailed = EFalse;
       
   538 	iTestUtils->StartTestL( aTestCase.TestCaseName() );
       
   539 	__TESTNAME(aTestCase.TestCaseName());
       
   540 	
       
   541 	CPipeliningTestClient* testClient;
       
   542 	if(aSecName.FindF(_L("TSWDEFECT")) ==0)
       
   543 	    {
       
   544 	    RDebug::Print(_L("TSWDEFECT"));
       
   545 	    _LIT(KTestCaseLocalAndRemoteHost, "TSWDEFECT1 JKUN-7VVGB6");
       
   546 	    if(aTestCase.TestCaseName().CompareF(KTestCaseLocalAndRemoteHost) == 0)
       
   547 	        {
       
   548 	        testClient = CTestCaseLocalAndRemoteHost::NewL(*iTestUtils, *this);
       
   549 	        }
       
   550 	    else
       
   551 	        {
       
   552 	        User::Invariant();
       
   553 	        }	     
       
   554 	    }
       
   555 	else
       
   556 	    {
       
   557 	    testClient = CPipeliningTestClient::NewL(*iTestUtils, *this);    
       
   558 	    }	
       
   559 	CleanupStack::PushL(testClient);
       
   560 	
       
   561 	testClient->SetTestCase(&aTestCase);
       
   562 	iTestServer->SetTestCase(&aTestCase);
       
   563 	testClient->StartClientL();
       
   564 	
       
   565 	CActiveScheduler::Start();
       
   566 	iTestServer->ResetServer();
       
   567     RDebug::Print(_L("After reseting the server: Last error: %d"), iEngineLastError);
       
   568 	User::LeaveIfError( iEngineLastError );
       
   569 
       
   570 	CleanupStack::PopAndDestroy(testClient);
       
   571     RDebug::Print(_L("Deleting Test client"));
       
   572 	iTestUtils->EndTest(iTestFailed);
       
   573 	}
       
   574 
       
   575 void CPipeliningTestEngine::DoPipeliningConfigTestsL(TDesC& secName)
       
   576 	/* A set of tests to config pipelining to restrict the number of transactions sent down one
       
   577 	   connection 
       
   578 	   
       
   579 	   The same test class object is reused with settings being changed between each test.
       
   580 	*/
       
   581 	{
       
   582 	_LIT(KPipeliningConfigTestName, "PipeliningConfig");
       
   583 	_LIT8(KUri1, "http://10.29.23.12/");
       
   584 	_LIT8(KUri2, "http://10.29.23.12/");
       
   585 	
       
   586 	CPipeliningConfigTest* test = CPipeliningConfigTest::NewLC(KPipeliningConfigTestName);
       
   587 	
       
   588 	
       
   589 	// 2 transactions to same location, with limit to only pipeline 1 at a time
       
   590 	// 2 connections expected
       
   591 	test->AddTransactionUrisL(KUri1, 2);
       
   592 	test->SetMaxNumberTransactionsToPipeline(1);
       
   593 	test->SetExpectedNumberConnections(2);
       
   594 	if( secName.Compare(_L("CONFIG_TEST1")) == 0 )
       
   595 		{
       
   596 		RunTestL(KNullDesC(), *test);
       
   597 		}
       
   598 	
       
   599 	// 4 transactions to same location, with limit to pipeline upto 2 at a time
       
   600 	// 2 connections expected
       
   601 	test->AddTransactionUrisL(KUri1, 2);
       
   602 	test->SetMaxNumberTransactionsToPipeline(2);
       
   603 	if( secName.Compare(_L("CONFIG_TEST2")) == 0 )
       
   604 		{
       
   605 		RunTestL(KNullDesC(), *test);
       
   606 		}
       
   607 
       
   608 	// 1 transaction to one location, 3 to another with limit to pipeline upto 2 at a time
       
   609 	// 3 connections expected
       
   610 	test->ClearTransactionUris();
       
   611 	test->AddTransactionUrisL(KUri2);
       
   612 	test->AddTransactionUrisL(KUri1,3);
       
   613 	test->SetExpectedNumberConnections(3);
       
   614 	if( secName.Compare(_L("CONFIG_TEST3")) == 0 )
       
   615 		{
       
   616 		RunTestL(KNullDesC(), *test);
       
   617 		}
       
   618 	
       
   619 	// 4 transactions to same location, limit to only pipeline 1 at a time
       
   620 	// Limit Transport Handlers to 3
       
   621 	// Expect 3 connections
       
   622 	test->ClearTransactionUris();
       
   623 	test->AddTransactionUrisL(KUri1, 4);
       
   624 	test->SetMaxNumberTransactionsToPipeline(1);
       
   625 	test->SetMaxNumberTransportHandlers(3);
       
   626 	if( secName.Compare(_L("CONFIG_TEST4")) == 0 )
       
   627 		{
       
   628 		RunTestL(KNullDesC(), *test);
       
   629 		}
       
   630 			
       
   631 	CleanupStack::PopAndDestroy(test);
       
   632 	}
       
   633 	
       
   634 
       
   635 void CPipeliningTestEngine::EndTest(TInt aError)
       
   636 	{
       
   637 	if( aError < KErrNone )
       
   638 		{
       
   639 		iEngineLastError = aError;
       
   640 		iTestFailed = ETrue;
       
   641 		_LIT(KTxtEndTestFail, "Engine - Test Failed. Completed with ErrorCode: %d");
       
   642 		iTestUtils->LogIt(KTxtEndTestFail(), aError);
       
   643 		}
       
   644 	else
       
   645 		{
       
   646 		__ASSERT_DEBUG( iTestCase != NULL, User::Invariant() );
       
   647 		
       
   648 		// Check that the number connections matched the expected number of connections
       
   649 		const TInt expectedConnections = iTestCase->ConnectionCount();
       
   650 		const TInt actualConnections = iTestServer->ConnectionCount();
       
   651 		_LIT(KTxtEndTestConnectionCount, "Engine - Connection count- Expected: %d, Actual: %d");
       
   652 		iTestUtils->LogIt(KTxtEndTestConnectionCount(), expectedConnections, actualConnections);
       
   653 		//Actual Connection is 3, this is to support changes made as part of defect: INC099971
       
   654 		_LIT(KTestCaseLocalAndRemoteHost, "TSWDEFECT1 JKUN-7VVGB6");
       
   655 		if((iTestCase->TestCaseName().CompareF(KTestCaseLocalAndRemoteHost) != 0) && actualConnections < expectedConnections  && !(expectedConnections == 1 && actualConnections == 3))
       
   656 			{
       
   657 			iEngineLastError = KErrGeneral;
       
   658 			iTestFailed = ETrue;
       
   659 			_LIT(KTxtEndTestConnectionFail, "Engine - Test Failed. Connection count mismatch.");
       
   660 			iTestUtils->LogIt(KTxtEndTestConnectionFail());
       
   661 			}
       
   662 		else
       
   663 			{
       
   664 			iTestFailed = EFalse;
       
   665 			_LIT(KTxtEndTestPass, "Engine - Test Completed Successfully");
       
   666 			iTestUtils->LogIt(KTxtEndTestPass());
       
   667 			}
       
   668 		}
       
   669 	
       
   670 	CActiveScheduler::Stop();
       
   671 	}
       
   672