websrv_pub/web_service_connection_api/tsrc/SenConnectionTimeoutsTester/src/SenConnectionTimeoutsTesterBlocks.cpp
changeset 0 62f9d29f7211
child 23 a1df79fa35b4
equal deleted inserted replaced
-1:000000000000 0:62f9d29f7211
       
     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 
       
    19 // [INCLUDE FILES] - do not remove
       
    20 #include <e32svr.h>
       
    21 #include <StifParser.h>
       
    22 #include <StifTestInterface.h>
       
    23 #include "SenConnectionTimeoutsTester.h"
       
    24 
       
    25 //  EXTERNAL INCLUDES
       
    26 #include <http.h>
       
    27 #include <httperr.h>
       
    28 
       
    29 #include <SenBaseFragment.h>
       
    30 #include <SenBaseElement.h>
       
    31 #include <SenDomFragment.h>
       
    32 #include <SenServiceConnection.h>
       
    33 #include <SenServicePattern.h>
       
    34 #include <SenSoapEnvelope.h>
       
    35 #include <SenSoapEnvelope2.h>
       
    36 #include <SenXmlReader.h>
       
    37 #include <SenXmlServiceDescription.h>
       
    38 #include <SenXmlUtils.h>
       
    39 #include <SenServiceManager.h>
       
    40 #include <SenIdentityProvider.h>
       
    41 #include <SenHttpTransportProperties.h>
       
    42 #include <SenSoapMessage.h>
       
    43 #include <SenSoapMessage2.h>
       
    44 #include <SenDateUtils.h>
       
    45 #include <SenTransportProperties.h>
       
    46 
       
    47 #include <xmlengchunkcontainer.h>
       
    48 #include <xmlengfilecontainer.h>
       
    49 #include <xmlengserializer.h>
       
    50 
       
    51 #include <e32base.h> // for CActive
       
    52 #include <aknnotewrappers.h> 
       
    53 
       
    54 #include <commdb.h>
       
    55 
       
    56 #include <s32file.h>    // filestream
       
    57 #include <e32svr.h>     // fileman
       
    58 // EXTERNAL DATA STRUCTURES
       
    59 //extern  ?external_data;
       
    60 
       
    61 // EXTERNAL FUNCTION PROTOTYPES  
       
    62 //extern ?external_function( ?arg_type,?arg_type );
       
    63 
       
    64 // CONSTANTS
       
    65 namespace 
       
    66     {
       
    67         
       
    68 #ifdef AOL_RADIO_SERVICE
       
    69     // AOL redio.etenee.net:9080
       
    70     _LIT8(KWSPContract,         "urn:aol-com:services:radio");
       
    71     _LIT8(KAuthServEndpoint,    "http://radio.etenee.net:9080/tfs/IDPSSO_IDWSF");
       
    72     _LIT8(KASProviderID,        "http://radio.etenee.net:9080/tfs/");
       
    73     _LIT8(KTestAuthzID,         "012345678901234");
       
    74     _LIT8(KTestPassword,        "012345678901234");
       
    75 #elif VALIMO_ADDRESSBOOK_SERVICE
       
    76     // Addressbook service hosted inside Nokia intra by ASP / testing team
       
    77     _LIT8(KWSPContract,         "urn:nokia:test:addrbook:2004-09");
       
    78     _LIT8(KAuthServEndpoint,    "http://10.21.32.110/tfs/IDPSSO_IDWSF10");
       
    79     _LIT8(KASProviderID,        "provider01");
       
    80     _LIT8(KTestAuthzID,         "john");
       
    81     _LIT8(KTestPassword,        "password");
       
    82 #elif SYSOPENDIGIA_ADDRESSBOOK_SERVICE
       
    83     _LIT8(KWSPContract,         "urn:nokia:test:addrbook:2004-09");
       
    84     _LIT8(KAuthServEndpoint,    "http://ys01liw022.partner.yomi.com:9080/tfs/IDPSSO_IDWSF");
       
    85     _LIT8(KASProviderID,        "http://ys01liw022.partner.yomi.com:9080/tfs/");
       
    86     _LIT8(KTestAuthzID,         "012345678901234");
       
    87     _LIT8(KTestPassword,        "012345678901234");
       
    88 #else // == default (no MACROs defined in .mmp)
       
    89     // Addressbook service hosted by Forum Nokia (accessible from external network)
       
    90     _LIT8(KWSPContract,         "urn:nokia:test:addrbook:2004-09"); aa
       
    91     _LIT8(KAuthServEndpoint,    "http://selma.ndhub.net:9080/tfs/IDPSSO_IDWSF");
       
    92     _LIT8(KASProviderID,        "http://selma.ndhub.net:9080/tfs/");
       
    93     _LIT8(KTestAuthzID,         "testuser1");
       
    94     _LIT8(KTestPassword,        "testuser1");
       
    95 #endif // FN_ADDRESSBOOK_SERVICE
       
    96 
       
    97 
       
    98     _LIT8(KASContract,              "urn:liberty:as:2004-04");
       
    99     _LIT8(KHttpsEndPoint,           "https://10.21.32.110/sereneHardCoded/WS_WSI_R9980_001" );    
       
   100     
       
   101     _LIT8(KWSIFrameworkID,          "WS-I");
       
   102     _LIT8(KIDWSFFrameworkID,        "ID-WSF");
       
   103     _LIT8(KRESTFrameworkID,         "REST");       
       
   104 //    _LIT8(KWsStarFrameworkID,       "WS-STAR");       
       
   105 #ifdef SYSOPENDIGIA_ADDRESSBOOK_SERVICE
       
   106     _LIT8(KAddressBookServiceId,    "http://radio.aol.com/xsd/2.0/ns/");
       
   107     _LIT8(KAddressBookContract,     "http://radio.aol.com/xsd/2.0/ns/");
       
   108 #else
       
   109     _LIT8(KAddressBookServiceId,    "urn:nokia:test:addrbook:2004-09");
       
   110     _LIT8(KAddressBookContract,     "urn:nokia:test:addrbook:2004-09");
       
   111 #endif
       
   112     
       
   113 #ifdef SYSOPENDIGIA_ADDRESSBOOK_SERVICE
       
   114     _LIT(KIAPName,                  "Ethernet No Daemon Static IP");
       
   115 #else
       
   116     //_LIT(KIAPName,                  "Ethernet with Daemon Dynamic IP");
       
   117     //_LIT(KIAPName,                  "Ethernet No Daemon Static IP");
       
   118     _LIT(KIAPName,                  "Ethernet with Daemon Dynamic IP");
       
   119 #endif
       
   120     _LIT8(KLoggerFileNameProperty,  "HttpLoggerFileName");
       
   121 
       
   122     _LIT(KFileToRead,               "c:\\Logs\\LoggingHttpFilter\\httptrace.xml");
       
   123     _LIT8(KFileName,                "httptrace.xml");
       
   124 
       
   125     _LIT8(KHTTPMethodGet,           "GET");
       
   126     _LIT8(KHTTPMethodPost,          "POST");
       
   127     
       
   128 //    const TBool MultipleSimultanousRHttpSessionsSupported = EFalse;
       
   129     // If IAP changes all previously sent messages will be canceled.
       
   130     
       
   131     
       
   132     _LIT8(KProxyHost,               "172.19.160.50"); // IP address to: bsprx01.americas.nokia.com
       
   133     const TInt KProxyPort =         8080;
       
   134     
       
   135     }
       
   136 
       
   137 
       
   138 // MACROS
       
   139 //#define ?macro ?macro_def
       
   140 //Macro for Porting to STIF
       
   141 #define LOCAL_ASSERT(expression)	{if(!(expression)){return KErrArgument;}}
       
   142 
       
   143 // LOCAL CONSTANTS AND MACROS
       
   144 //const ?type ?constant_var = ?constant;
       
   145 //#define ?macro_name ?macro_def
       
   146 
       
   147 // MODULE DATA STRUCTURES
       
   148 //enum ?declaration
       
   149 //typedef ?declaration
       
   150 
       
   151 // LOCAL FUNCTION PROTOTYPES
       
   152 //?type ?function_name( ?arg_type, ?arg_type );
       
   153 
       
   154 // FORWARD DECLARATIONS
       
   155 //class ?FORWARD_CLASSNAME;
       
   156 
       
   157 // ============================= LOCAL FUNCTIONS ===============================
       
   158 
       
   159 // -----------------------------------------------------------------------------
       
   160 // ?function_name ?description.
       
   161 // ?description
       
   162 // Returns: ?value_1: ?description
       
   163 //          ?value_n: ?description_line1
       
   164 //                    ?description_line2
       
   165 // -----------------------------------------------------------------------------
       
   166 //
       
   167 /*
       
   168 ?type ?function_name(
       
   169     ?arg_type arg,  // ?description
       
   170     ?arg_type arg)  // ?description
       
   171     {
       
   172 
       
   173     ?code  // ?comment
       
   174 
       
   175     // ?comment
       
   176     ?code
       
   177     }
       
   178 */
       
   179 
       
   180 // ============================ MEMBER FUNCTIONS ===============================
       
   181 
       
   182 // -----------------------------------------------------------------------------
       
   183 // CSenConnectionTimeoutsTester::Delete
       
   184 // Delete here all resources allocated and opened from test methods. 
       
   185 // Called from destructor. 
       
   186 // -----------------------------------------------------------------------------
       
   187 //
       
   188 void CSenConnectionTimeoutsTester::Delete() 
       
   189     {
       
   190 
       
   191     }
       
   192 
       
   193 // -----------------------------------------------------------------------------
       
   194 // CSenConnectionTimeoutsTester::RunMethodL
       
   195 // Run specified method. Contains also table of test mothods and their names.
       
   196 // -----------------------------------------------------------------------------
       
   197 //
       
   198 TInt CSenConnectionTimeoutsTester::RunMethodL( 
       
   199     CStifItemParser& aItem ) 
       
   200     {
       
   201 
       
   202     static TStifFunctionInfo const KFunctions[] =
       
   203         {  
       
   204         // Copy this line for every implemented function.
       
   205         // First string is the function name used in TestScripter script file.
       
   206         // Second is the actual implementation member function. 
       
   207 		ENTRY("SendL_TPAsync1Test_CSenServiceConnection_SendLconnectionisnotinitialized", CSenConnectionTimeoutsTester_TP_Async1),
       
   208 		ENTRY("SendL_TPAsync2Test_CSenServiceConnection_SendLconnectionisnotinitialized", CSenConnectionTimeoutsTester_TP_Async2),
       
   209         //ADD NEW ENTRY HERE
       
   210         // [test cases entries] - Do not remove
       
   211 
       
   212         };
       
   213 
       
   214     const TInt count = sizeof( KFunctions ) / 
       
   215                         sizeof( TStifFunctionInfo );
       
   216 
       
   217     return RunInternalL( KFunctions, count, aItem );
       
   218 
       
   219     }
       
   220 
       
   221 
       
   222 // CONSTRUCTION
       
   223 //CSenConnectionTimeoutsTester* CSenConnectionTimeoutsTester::NewL()
       
   224 //    {
       
   225 //    CSenConnectionTimeoutsTester* self = CSenConnectionTimeoutsTester::NewLC();
       
   226 //    CleanupStack::Pop();
       
   227 
       
   228 //    return self;
       
   229 //    }
       
   230 
       
   231 //CSenConnectionTimeoutsTester* CSenConnectionTimeoutsTester::NewLC()
       
   232 //    {
       
   233 //    CSenConnectionTimeoutsTester* self = new( ELeave ) CSenConnectionTimeoutsTester();
       
   234 //    CleanupStack::PushL( self );
       
   235 
       
   236 //    self->ConstructL();
       
   237 
       
   238 //    return self;
       
   239 //    }
       
   240 
       
   241 
       
   242 // Default constructor
       
   243 //CSenConnectionTimeoutsTester::CSenConnectionTimeoutsTester():iInitialized(FALSE)
       
   244 //    {
       
   245 //    }
       
   246       
       
   247 // Second phase construct
       
   248 //void CSenConnectionTimeoutsTester::ConstructL()
       
   249 //    {
       
   250     // The ConstructL from the base class CEUnitTestSuiteClass must be called.
       
   251     // It generates the test case table.
       
   252 //    CEUnitTestSuiteClass::ConstructL();
       
   253 //    }
       
   254 
       
   255 //  METHODS
       
   256 
       
   257 void CSenConnectionTimeoutsTester::HandleMessageL(const TDesC8& aMessage)
       
   258     {
       
   259     iCallback = ECallbackHandleMessage;
       
   260     if ( ipMessage )
       
   261         {
       
   262         delete ipMessage;
       
   263         ipMessage = NULL;
       
   264         }
       
   265     ipMessage = aMessage.AllocL();
       
   266     iTransactionId = iServiceConnection->TxnId();
       
   267 
       
   268     StopActiveScheduler();
       
   269     }
       
   270 
       
   271 void CSenConnectionTimeoutsTester::HandleErrorL(const int aErrorCode, const TDesC8& aError)
       
   272     {
       
   273     iCallback = ECallbackHandleError;
       
   274     iErrorCode = aErrorCode;
       
   275     
       
   276     // debugging only - START
       
   277     if( HTTPStatus::IsInformational( this->iErrorCode ) )
       
   278         {
       
   279         // if((aStatus >= HTTPStatus::EContinue) && (aStatus < HTTPStatus::EOk))
       
   280         RDebug::Print(_L("- HTTP error code: IS INFORMATION."));
       
   281         }
       
   282     if( HTTPStatus::IsSuccessful( this->iErrorCode ) )
       
   283         {
       
   284         // if((aStatus >= HTTPStatus::EOk) && (aStatus < HTTPStatus::EMultipleChoices))
       
   285         RDebug::Print(_L("- HTTP error code: IS SUCCESSFUL."));
       
   286         }
       
   287     if( HTTPStatus::IsRedirection( this->iErrorCode ) )
       
   288         {
       
   289         // if((aStatus >= HTTPStatus::EMultipleChoices) && (aStatus < HTTPStatus::EBadRequest))
       
   290         RDebug::Print(_L("- HTTP error code: IS REDIRECTION."));
       
   291         }
       
   292     if( HTTPStatus::IsClientError( this->iErrorCode ) )
       
   293         {
       
   294         // if((aStatus >= HTTPStatus::EBadRequest) && (aStatus < HTTPStatus::EInternalServerError))
       
   295         RDebug::Print(_L("- HTTP error code: IS CLIENT ERROR."));
       
   296         }
       
   297     if( HTTPStatus::IsServerError( this->iErrorCode ) )
       
   298         {
       
   299         // if(aStatus >= HTTPStatus::EInternalServerError)
       
   300         RDebug::Print(_L("- HTTP error code: IS CLIENT ERROR."));
       
   301         }    
       
   302     // debuggin only - END
       
   303     
       
   304     if ( ipMessage )
       
   305         {
       
   306         delete ipMessage;
       
   307         ipMessage = NULL;
       
   308         }
       
   309     ipMessage = aError.AllocL();
       
   310     iTransactionId = iServiceConnection->TxnId();
       
   311     
       
   312     TBuf<70> errorMessage;
       
   313     _LIT(KErrNotInitialized, "Connection isn't initialized.");
       
   314     
       
   315     switch(aErrorCode) 
       
   316         {
       
   317         case KErrSubmitting:
       
   318             errorMessage = KErrNotInitialized;
       
   319             break;
       
   320         default:
       
   321             break;
       
   322         }   
       
   323 
       
   324     StopActiveScheduler();
       
   325     }
       
   326 
       
   327 void CSenConnectionTimeoutsTester::ErrorL(TInt aCode)
       
   328     {
       
   329     _LIT(KNotReady, "Connection is not ready.");
       
   330     
       
   331     TBuf<70> errorMessage;
       
   332     switch(aCode) 
       
   333         {
       
   334         case EConnectionNotReady:
       
   335             errorMessage = KNotReady;
       
   336             break;
       
   337         default:
       
   338             break;
       
   339         }
       
   340     }
       
   341 
       
   342 void CSenConnectionTimeoutsTester::SetStatus(const TInt aStatus)
       
   343     {
       
   344     switch(aStatus)
       
   345         {
       
   346         case KSenConnectionStatusNew:
       
   347             break;
       
   348         case KSenConnectionStatusReady:
       
   349             iInitialized = ETrue;
       
   350             break;
       
   351         case KSenConnectionStatusExpired:
       
   352             break;
       
   353         default:
       
   354             TBuf<32> num;
       
   355             num.AppendNum(aStatus);
       
   356             break;
       
   357         }
       
   358 
       
   359     if ( aStatus >= KSenConnectionStatusCreateFailed && aStatus <= KSenConnectionStatusMetadataExchange )
       
   360         {
       
   361         if(!iInitialized)
       
   362             {
       
   363             TInt leaveCode(KErrNone);
       
   364             TRAP(leaveCode, ErrorL(EConnectionNotReady));
       
   365             leaveCode = 0; // not used
       
   366             }
       
   367         iConnectionState = aStatus;
       
   368         StopActiveScheduler();
       
   369         }
       
   370     }
       
   371 
       
   372 
       
   373 void CSenConnectionTimeoutsTester::SetupL(  )
       
   374     {
       
   375     __UHEAP_MARK;
       
   376 
       
   377     RFile file;
       
   378     RFs iFsSession;
       
   379     _LIT(KFileName,"c:\\testing\\data\\rest.on");
       
   380     
       
   381    
       
   382     User::LeaveIfError(iFsSession.Connect());
       
   383         
       
   384     TInt fileOP = file.Open(iFsSession,KFileName,EFileRead);
       
   385     if (fileOP == KErrNone) 
       
   386         {
       
   387         RDebug::Print(_L( "Found rest.on file => using RESTful framework" ) ); 
       
   388         file.Close();
       
   389         ipFrameworkID = HBufC8::NewL(KRESTFrameworkID().Length());
       
   390         ipFrameworkID->Des().Append(KRESTFrameworkID);
       
   391         }
       
   392     else
       
   393         {
       
   394         RDebug::Print(_L( "File rest.on not found => defaulting to WS-I" ) ); 
       
   395         ipFrameworkID = HBufC8::NewL(KWSIFrameworkID().Length());
       
   396         ipFrameworkID->Des().Append(KWSIFrameworkID);
       
   397         }
       
   398     iFsSession.Close();
       
   399     
       
   400     iCallback = ECallbackNone;
       
   401     }
       
   402 
       
   403 void CSenConnectionTimeoutsTester::Teardown(  )
       
   404     {
       
   405     delete ipFrameworkID;
       
   406     ipFrameworkID = NULL;
       
   407     delete ipMessage;
       
   408     ipMessage = NULL;
       
   409     __UHEAP_MARKEND;
       
   410     }
       
   411 
       
   412 
       
   413 
       
   414     
       
   415 
       
   416 //Befor executing this TC remember to set big enought TimeOut value (10 min.)
       
   417 
       
   418 TInt CSenConnectionTimeoutsTester::CSenConnectionTimeoutsTester_TP_Async1(CStifItemParser& aItem)
       
   419 {
       
   420 
       
   421     
       
   422     
       
   423     _LIT8(KAsyncEndPoint,           "http://10.21.32.110/sereneHardCoded/WS_Async_002");
       
   424     _LIT8(KCustomHttpHeader,        "CustomHeader");
       
   425     
       
   426     _LIT8(KLogFile,                "httptrace");
       
   427     _LIT(KFileExtension,          ".xml");
       
   428     _LIT8(KCustomHttpHeaderValue,  "AsyncTest_");
       
   429     _LIT(KLogFileToRead,           "c:\\Logs\\LoggingHttpFilter\\httptrace");
       
   430     
       
   431     SetupL();
       
   432     CSenServicePattern* pPattern =
       
   433         CSenServicePattern::NewLC(KAsyncEndPoint, KNullDesC8());
       
   434     pPattern->SetFrameworkIdL(*ipFrameworkID);
       
   435     
       
   436     iServiceConnection = CSenServiceConnection::NewL(*this, *pPattern);
       
   437     
       
   438     CleanupStack::PopAndDestroy(pPattern);
       
   439     
       
   440     StartActiveScheduler(1);
       
   441     LOCAL_ASSERT(iConnectionState == KSenConnectionStatusReady);
       
   442     // Connection is ready to be used.
       
   443     
       
   444     // 2. Get TP using SC:TransportPropertiesL()
       
   445     HBufC8* pTransportPropertiesAsXml = NULL;
       
   446     iServiceConnection->TransportPropertiesL(pTransportPropertiesAsXml);
       
   447     if ( pTransportPropertiesAsXml )
       
   448         {
       
   449         delete pTransportPropertiesAsXml;
       
   450         }
       
   451      
       
   452      
       
   453     TBuf8<255> tempLogFile;     
       
   454     TBuf8<255> tempCustomHttpHeaderValue;
       
   455     TBuf<255> tempLogFileToRead;
       
   456     
       
   457     for (TInt i = 1; i <= 8; i++)
       
   458     {
       
   459         tempLogFile.Copy(KLogFile);
       
   460         tempLogFile.AppendNum(i);
       
   461         tempLogFile.Append(KFileExtension);
       
   462     
       
   463         tempCustomHttpHeaderValue.Copy(KCustomHttpHeaderValue);
       
   464         tempCustomHttpHeaderValue.AppendNum(i);
       
   465         
       
   466         tempLogFileToRead.Copy(KLogFileToRead);
       
   467         tempLogFileToRead.AppendNum(i);
       
   468         tempLogFileToRead.Append(KFileExtension);
       
   469         
       
   470         TL(CSenConnectionTimeoutsTester_TP_Send(tempLogFile,KCustomHttpHeader,tempCustomHttpHeaderValue,iServiceConnection) == KErrNone) ;    
       
   471         TL(CSenConnectionTimeoutsTester_TP_CheckLogs( tempLogFileToRead,  KCustomHttpHeader, tempCustomHttpHeaderValue) == KErrNone);     
       
   472         
       
   473     }//for i
       
   474                                                   
       
   475     
       
   476         delete iServiceConnection;
       
   477         iServiceConnection = NULL;
       
   478         Teardown();
       
   479 		return KErrNone;    
       
   480     }    
       
   481 
       
   482 
       
   483 
       
   484 //Before executing this TC remember to set big enought TimeOut value (10 min.)
       
   485 TInt CSenConnectionTimeoutsTester::CSenConnectionTimeoutsTester_TP_Async2(CStifItemParser& aItem)
       
   486     {
       
   487     _LIT8(KAsyncEndPoint,           "http://10.21.32.110/sereneHardCoded/WS_Async_002");
       
   488     _LIT8(KCustomHttpHeader,        "CustomHeader");
       
   489     
       
   490     _LIT8(KLogFile,                "httptrace");
       
   491     _LIT(KFileExtension,          ".xml");
       
   492     _LIT8(KCustomHttpHeaderValue,  "AsyncTest_");
       
   493     _LIT(KLogFileToRead,           "c:\\Logs\\LoggingHttpFilter\\httptrace");
       
   494     
       
   495 	SetupL();
       
   496     CSenServicePattern* pPattern = CSenServicePattern::NewLC(KAsyncEndPoint, KNullDesC8());
       
   497     pPattern->SetFrameworkIdL(*ipFrameworkID);
       
   498     
       
   499     iServiceConnection = CSenServiceConnection::NewL(*this, *pPattern);
       
   500     
       
   501     CleanupStack::PopAndDestroy(pPattern);
       
   502     
       
   503     StartActiveScheduler(1);
       
   504     LOCAL_ASSERT(iConnectionState == KSenConnectionStatusReady);
       
   505     // Connection is ready to be used.
       
   506     
       
   507     // 2. Get TP using SC:TransportPropertiesL()
       
   508     HBufC8* pTransportPropertiesAsXml = NULL;
       
   509     iServiceConnection->TransportPropertiesL(pTransportPropertiesAsXml);
       
   510     if ( pTransportPropertiesAsXml )
       
   511         {
       
   512         delete pTransportPropertiesAsXml;
       
   513         }
       
   514 
       
   515     TBuf8<255> tempLogFile;     
       
   516     TBuf8<255> tempCustomHttpHeader;
       
   517     TBuf8<255> tempCustomHttpHeaderValue;
       
   518     TBuf<255> tempLogFileToRead;
       
   519     
       
   520     for (TInt i = 1; i <= 8; i++)
       
   521     {
       
   522         tempLogFile.Copy(KLogFile);
       
   523         tempLogFile.AppendNum(i);
       
   524         tempLogFile.Append(KFileExtension);
       
   525         
       
   526         tempCustomHttpHeader.Copy(KCustomHttpHeader);
       
   527         tempCustomHttpHeader.AppendNum(i);
       
   528     
       
   529         tempCustomHttpHeaderValue.Copy(KCustomHttpHeaderValue);
       
   530         tempCustomHttpHeaderValue.AppendNum(i);
       
   531         
       
   532         tempLogFileToRead.Copy(KLogFileToRead);
       
   533         tempLogFileToRead.AppendNum(i);
       
   534         tempLogFileToRead.Append(KFileExtension);
       
   535         
       
   536         TL(CSenConnectionTimeoutsTester_TP_Send(tempLogFile,tempCustomHttpHeader,tempCustomHttpHeaderValue,iServiceConnection) == KErrNone) ; 
       
   537         TL(CSenConnectionTimeoutsTester_TP_CheckLogs( tempLogFileToRead,  tempCustomHttpHeader, tempCustomHttpHeaderValue) == KErrNone);      
       
   538         
       
   539     }//for i
       
   540                                                   
       
   541     
       
   542     delete iServiceConnection;
       
   543     iServiceConnection = NULL;
       
   544     Teardown();
       
   545 		return KErrNone;     
       
   546      
       
   547     }    
       
   548 
       
   549 
       
   550 TInt CSenConnectionTimeoutsTester::CSenConnectionTimeoutsTester_TP_Send(const TDesC8& aLogFileName, const TDesC8& aCustomHttpHeader,
       
   551                                                                 const TDesC8& aCustomHttpHeaderValue, CSenServiceConnection* iServiceConnection)
       
   552     {
       
   553     TInt result = KErrNone;
       
   554     CSenSoapMessage* pSOAPMessage = CreateAuthRequestLC();
       
   555 
       
   556     // SendL(MSG) // with custom header
       
   557     CSenHttpTransportProperties* pHttpProperties = CSenHttpTransportProperties::NewLC();    
       
   558     pHttpProperties->SetHttpHeaderL(KLoggerFileNameProperty, aLogFileName);
       
   559     pHttpProperties->SetHttpHeaderL(aCustomHttpHeader, aCustomHttpHeaderValue);
       
   560     TUint32 iapId = SearchIAPIdByName(KIAPName);
       
   561     pHttpProperties->SetIapIdL(iapId);
       
   562     HBufC8* pSerializedProperties = pHttpProperties->AsUtf8L();
       
   563     CleanupStack::PushL(pSerializedProperties);
       
   564     iServiceConnection->SendL(*pSOAPMessage, *pSerializedProperties);
       
   565     StartActiveScheduler(1);
       
   566     //RDebug::Print(_L(iCallback == ECallbackHandleMessage);
       
   567     if(iCallback != ECallbackHandleMessage) return KErrGeneral;
       
   568    
       
   569     CleanupStack::PopAndDestroy(pSerializedProperties);
       
   570     CleanupStack::PopAndDestroy(pHttpProperties);
       
   571     CleanupStack::PopAndDestroy(pSOAPMessage);
       
   572     return result;
       
   573     }  
       
   574     
       
   575     
       
   576 TInt CSenConnectionTimeoutsTester::CSenConnectionTimeoutsTester_TP_CheckLogs(const TDesC& aLogFilePath,  const TDesC8& aCustomHttpHeader, const TDesC8& aCustomHttpHeaderValue)
       
   577     {
       
   578     TInt result = KErrNone;
       
   579     HBufC8* pFileContent = ReadFileL(aLogFilePath);
       
   580     //RDebug::Print(_L(pFileContent != NULL);
       
   581     if (pFileContent == NULL) return KErrNotFound;
       
   582     
       
   583     CleanupStack::PushL(pFileContent);
       
   584     HBufC8* pValue = HttpPropertyValueFromXmlLC(*pFileContent, aCustomHttpHeader);
       
   585     //RDebug::Print(_L(*pValue == aCustomHttpHeaderValue);
       
   586     if (*pValue != aCustomHttpHeaderValue) return KErrNotFound;
       
   587     
       
   588     CleanupStack::PopAndDestroy(pValue);
       
   589     CleanupStack::PopAndDestroy(pFileContent);    
       
   590 
       
   591     return result;
       
   592     }
       
   593 
       
   594 
       
   595 HBufC8* CSenConnectionTimeoutsTester::HttpMethodValueFromXmlLC(const TDesC8& aXml)
       
   596     {
       
   597     CSenXmlReader* pReader = CSenXmlReader::NewL();
       
   598     CleanupStack::PushL(pReader);
       
   599     CSenDomFragment* pDom = CSenDomFragment::NewL();
       
   600     CleanupStack::PushL(pDom);
       
   601     pReader->SetContentHandler(*pDom);
       
   602     pDom->SetReader(*pReader);
       
   603     pReader->ParseL(aXml);
       
   604     
       
   605     CSenElement& element = pDom->AsElement();
       
   606     CSenElement* pRequestElement = element.Element(_L8("Request"));
       
   607     CSenElement* pTPElement = pRequestElement->Element(_L8("Method"));
       
   608     
       
   609     HBufC8* pRetBuf = pTPElement->Content().AllocL();
       
   610 
       
   611     CleanupStack::PopAndDestroy(pDom);
       
   612     CleanupStack::PopAndDestroy(pReader);
       
   613     
       
   614     CleanupStack::PushL(pRetBuf);
       
   615     
       
   616     return pRetBuf;
       
   617     }
       
   618 
       
   619 HBufC8* CSenConnectionTimeoutsTester::HttpPropertyValueFromXmlLC(const TDesC8& aXml,
       
   620                                                              const TDesC8& aPropertyName)
       
   621     {
       
   622     CSenXmlReader* pReader = CSenXmlReader::NewL();
       
   623     CleanupStack::PushL(pReader);
       
   624     CSenDomFragment* pDom = CSenDomFragment::NewL();
       
   625     CleanupStack::PushL(pDom);
       
   626     pReader->SetContentHandler(*pDom);
       
   627     pDom->SetReader(*pReader);
       
   628     pReader->ParseL(aXml);
       
   629     
       
   630     HBufC8* pRetBuf = NULL;
       
   631     
       
   632     CSenElement& element = pDom->AsElement();
       
   633     CSenElement* pRequestElement = element.Element(_L8("Request"));
       
   634     if ( pRequestElement )
       
   635         {
       
   636         CSenElement* pTPElement = pRequestElement->Element(_L8("TranportProperties"));
       
   637         if ( pTPElement )
       
   638             {
       
   639             CSenElement* pElement = pTPElement->Element(aPropertyName);
       
   640             if ( pElement )
       
   641                 {
       
   642                 pRetBuf = pElement->Content().AllocL();
       
   643                 }
       
   644             }
       
   645         }
       
   646 
       
   647     CleanupStack::PopAndDestroy(pDom);
       
   648     CleanupStack::PopAndDestroy(pReader);
       
   649     CleanupStack::PushL(pRetBuf);
       
   650     return pRetBuf;
       
   651     }
       
   652     
       
   653 HBufC8* CSenConnectionTimeoutsTester::ReadFileL(const TDesC& aFilename)
       
   654     {
       
   655     RFs fsSession;
       
   656     CleanupClosePushL(fsSession);
       
   657     User::LeaveIfError(fsSession.Connect() == NULL);
       
   658     TEntry entry;
       
   659     User::LeaveIfError(fsSession.Entry(aFilename,entry));
       
   660     HBufC8* pFileContent = NULL;
       
   661     RFileReadStream fileInStream;
       
   662     CleanupClosePushL(fileInStream);
       
   663     if (fileInStream.Open(fsSession,aFilename,EFileRead) == KErrNone)
       
   664         {
       
   665         HBufC8* pTempFileContent = HBufC8::NewLC(entry.iSize+10);
       
   666         TRAPD(error,
       
   667             fileInStream.ReadL((TUint8*)pTempFileContent->Ptr(),entry.iSize);
       
   668             );
       
   669             
       
   670         if (!error)
       
   671             {
       
   672             TPtrC8 fileContent((TUint8*)pTempFileContent->Ptr(),entry.iSize);
       
   673             pFileContent = fileContent.AllocL();
       
   674             }
       
   675         CleanupStack::PopAndDestroy(pTempFileContent);
       
   676         }
       
   677     CleanupStack::PopAndDestroy(&fileInStream);
       
   678     CleanupStack::PopAndDestroy(&fsSession);
       
   679     return pFileContent;
       
   680     }
       
   681     
       
   682 TUint32 CSenConnectionTimeoutsTester::SearchIAPIdByName(const TDesC& aIAPName)
       
   683     {
       
   684     TBool found = EFalse;
       
   685     CCommsDatabase* pDB = CCommsDatabase::NewL(EDatabaseTypeIAP);
       
   686     CleanupStack::PushL(pDB);
       
   687     
       
   688     //open internet accesspoint table
       
   689     CCommsDbTableView* pDbTView = pDB->OpenTableLC(TPtrC(IAP));
       
   690     TInt retVal = pDbTView->GotoFirstRecord();
       
   691     TBuf<128> name; 
       
   692     TUint32 id = 0;
       
   693     //Find the correct record
       
   694     while ( retVal == KErrNone && found == EFalse )
       
   695         {
       
   696         pDbTView->ReadTextL(TPtrC(COMMDB_NAME), name);
       
   697         pDbTView->ReadUintL(TPtrC(COMMDB_ID), id);
       
   698         found = ( name == aIAPName ); 
       
   699         if ( !found )
       
   700             {
       
   701             retVal = pDbTView->GotoNextRecord();
       
   702             }
       
   703         }
       
   704     CleanupStack::PopAndDestroy(pDbTView);
       
   705     CleanupStack::PopAndDestroy(pDB);
       
   706     return id;
       
   707     }
       
   708     
       
   709 CSenSoapMessage* CSenConnectionTimeoutsTester::CreateAuthRequestLC()
       
   710     {
       
   711     _LIT8(KRequest, "<sa:SASLRequest xmlns:sa=\"urn:liberty:sa:2004-04\" mechanism=\"PLAIN ANONYMOUS\" advisoryAuthnID=\"012345678901234\"/>");
       
   712     CSenSoapMessage* pSOAPMessage = CSenSoapMessage::NewL();
       
   713     CleanupStack::PushL(pSOAPMessage);
       
   714 
       
   715     //xxxxxxxx*************** CorrelationHeader starts ***************************
       
   716     CSenBaseElement* pElement = CSenBaseElement::NewL(_L8("urn:liberty:sb:2003-08"), _L8("Correlation"), _L8("sb:Correlation"));
       
   717     CleanupStack::PushL(pElement);
       
   718 
       
   719     pElement->AddAttrL(_L8("messageID"),_L8(""));
       
   720     pElement->AddAttrL(_L8("refToMessageID"),_L8(""));
       
   721 
       
   722     TTime t;
       
   723     t.HomeTime();
       
   724     TBuf8<SenDateUtils::KXmlDateTimeMaxLength> ts;
       
   725     SenDateUtils::ToXmlDateTimeUtf8L(ts, t);
       
   726     pElement->AddAttrL(_L8("timestamp"), ts);
       
   727 
       
   728     pSOAPMessage->AddHeaderL(*pElement); // pElement will be owned by pSOAPMessage
       
   729     CleanupStack::Pop(pElement);
       
   730     //************************ CorrelationHeader ends ****************************
       
   731 
       
   732     pSOAPMessage->SetBodyL(KRequest);
       
   733     return pSOAPMessage;    
       
   734     }
       
   735      
       
   736 CSenSoapMessage2* CSenConnectionTimeoutsTester::CreateNewAuthRequestLC()
       
   737     {
       
   738     _LIT8(KRequest, "<sa:SASLRequest xmlns:sa=\"urn:liberty:sa:2004-04\" mechanism=\"PLAIN ANONYMOUS\" advisoryAuthnID=\"012345678901234\"/>");
       
   739     CSenSoapMessage2* pSOAPMessage = CSenSoapMessage2::NewL();
       
   740     CleanupStack::PushL(pSOAPMessage);
       
   741 
       
   742     //xxxxxxxx*************** CorrelationHeader starts ***************************
       
   743     /*CSenBaseElement* pElement = CSenBaseElement::NewL(_L8("urn:liberty:sb:2003-08"), _L8("Correlation"), _L8("sb:Correlation"));
       
   744     CleanupStack::PushL(pElement);
       
   745 
       
   746     pElement->AddAttrL(_L8("messageID"),_L8(""));
       
   747     pElement->AddAttrL(_L8("refToMessageID"),_L8(""));
       
   748 
       
   749     TTime t;
       
   750     t.HomeTime();
       
   751     TBuf8<SenDateUtils::KXmlDateTimeMaxLength> ts;
       
   752     SenDateUtils::ToXmlDateTimeUtf8L(ts, t);
       
   753     pElement->AddAttrL(_L8("timestamp"), ts);
       
   754 
       
   755     //pSOAPMessage->AddHeaderL(*pElement); // pElement will be owned by pSOAPMessage
       
   756     CleanupStack::Pop(pElement);*/
       
   757     //************************ CorrelationHeader ends ****************************
       
   758 
       
   759     pSOAPMessage->SetBodyL(KRequest);
       
   760     return pSOAPMessage;    
       
   761     }
       
   762     
       
   763 void CSenConnectionTimeoutsTester::StartActiveScheduler(TInt aNumberOfPendingOps)
       
   764     {
       
   765     iNumberOfPendingOps = aNumberOfPendingOps;
       
   766     CActiveScheduler::Start();
       
   767     }
       
   768        
       
   769 void CSenConnectionTimeoutsTester::StopActiveScheduler()
       
   770     {
       
   771     iNumberOfPendingOps--;
       
   772     if ( iNumberOfPendingOps == 0 )
       
   773         {
       
   774         CActiveScheduler::Stop();
       
   775         }
       
   776     }
       
   777 
       
   778 // -----------------------------------------------------------------------------
       
   779 // CSenConnectionTimeoutsTester::?member_function
       
   780 // ?implementation_description
       
   781 // (other items were commented in a header).
       
   782 // -----------------------------------------------------------------------------
       
   783 //
       
   784 /*
       
   785 TInt CSenConnectionTimeoutsTester::?member_function(
       
   786    CItemParser& aItem )
       
   787    {
       
   788 
       
   789    ?code
       
   790 
       
   791    }
       
   792 */
       
   793 
       
   794 // ========================== OTHER EXPORTED FUNCTIONS =========================
       
   795 // None
       
   796 
       
   797 //  [End of File] - Do not remove