You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by ha...@apache.org on 2006/01/11 11:24:09 UTC

svn commit: r367995 - in /webservices/axis/trunk/c/tests/auto_build/testcases: client/cpp/CookiesClient.cpp output/Cookies.cpp.out output/Cookies.request output/Cookies_ServerResponse.expected

Author: hawkeye
Date: Wed Jan 11 02:24:04 2006
New Revision: 367995

URL: http://svn.apache.org/viewcvs?rev=367995&view=rev
Log:
Altered Cookie test to test new functionality

Modified:
    webservices/axis/trunk/c/tests/auto_build/testcases/client/cpp/CookiesClient.cpp
    webservices/axis/trunk/c/tests/auto_build/testcases/output/Cookies.cpp.out
    webservices/axis/trunk/c/tests/auto_build/testcases/output/Cookies.request
    webservices/axis/trunk/c/tests/auto_build/testcases/output/Cookies_ServerResponse.expected

Modified: webservices/axis/trunk/c/tests/auto_build/testcases/client/cpp/CookiesClient.cpp
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/c/tests/auto_build/testcases/client/cpp/CookiesClient.cpp?rev=367995&r1=367994&r2=367995&view=diff
==============================================================================
--- webservices/axis/trunk/c/tests/auto_build/testcases/client/cpp/CookiesClient.cpp (original)
+++ webservices/axis/trunk/c/tests/auto_build/testcases/client/cpp/CookiesClient.cpp Wed Jan 11 02:24:04 2006
@@ -15,6 +15,7 @@
 
 #include "Calculator.hpp"
 #include <axis/AxisException.hpp>
+#include <axis/GDefine.hpp>
 #include <ctype.h>
 #include <iostream>
 #include <signal.h>
@@ -22,6 +23,7 @@
 void sig_handler(int);
 void PrintUsage();
 bool IsNumber(const char* p);
+void callCalculatorAndPrintProperties(Calculator& calculator, int, int);
 
 int main(int argc, char* argv[])
 {
@@ -40,11 +42,6 @@
 
 	url = argv[1];
 
-		bool bSuccess = false;
-		int	iRetryIterationCount = 3;
-
-		do
-		{
 	try
 	{
 		sprintf(endpoint, "%s", url);
@@ -55,41 +52,68 @@
 		i2 = 3;
 
         ws.setMaintainSession(true);
-        iResult = ws.add(i1, i2);
-         cout << iResult << endl;
-        iResult = ws.add(i1, i2);
-        cout << iResult << endl;
-        bSuccess = true;
-          
+        cout << "Calling calculator for the first time and expecting Set-Cookie back"<<endl;
+        callCalculatorAndPrintProperties(ws, i1, i2);
+        
+        // get the cookies
+        cout <<"Storing the cookies so I can give them to the next web service"<<endl;
+        int currentCookieKey=0;
+        string cookieKeys[3];
+        const char* key = ws.getFirstTransportPropertyKey();
+        string keyString(key);
+        if(key)
+        {
+            if(keyString.compare("Set-Cookie")==0)
+            {
+             string valueString(ws.getCurrentTransportPropertyValue());
+             cookieKeys[currentCookieKey++] = valueString;
+            }
+        }
+        // then the rest
+        while(key = ws.getNextTransportPropertyKey())
+        {
+            string nextKeyString(key);
+            if(nextKeyString.compare("Set-Cookie")==0)
+            {
+             string valueString(ws.getCurrentTransportPropertyValue());
+            cookieKeys[currentCookieKey++] = valueString;
+            }
+        }
+        
+        cout << "Calling calculator for the second time and expecting to send the cookies back"<<endl;
+        callCalculatorAndPrintProperties(ws, i1, i2);
+        
         // Now create a new instance of the service and the cookies should be lost
+        cout <<"Use a new instance of calculator and ensure that the old cookies are lost"<<endl;
         Calculator calculator(endpoint);
         calculator.setMaintainSession(true);
-        iResult = calculator.add(i1, i2);
-        cout << iResult << endl;
-        
-        
-          
+        callCalculatorAndPrintProperties(calculator, i1, i2);
+        // OK, Now add the previously saved cookie on to this new service.
+        cout << "Add the cookies from the previous web service to the new web service"<<endl;
+        currentCookieKey=0;
+        while(currentCookieKey< 3)
+        {
+            calculator.setTransportProperty("Cookie", cookieKeys[currentCookieKey++].c_str());
+        }
+        cout <<"Completed adding cookies"<<endl;
+        // Call the service again twice to ensure that the key has been set as a cookie
+        cout <<"Call the calculator service twice and ensure that the cookies remain"<<endl;
+        callCalculatorAndPrintProperties(calculator, i1, i2);
+        callCalculatorAndPrintProperties(calculator, i1, i2);
+        // Delete one of the cookies
+        cout <<"Deleting the LtpaToken2 cookie"<<endl;
+        calculator.deleteTransportProperty("LtpaToken2");
+        cout << "Calling the service and not expecting the LtpaToken2 in the cookie header"<<endl;
+        callCalculatorAndPrintProperties(calculator, i1, i2);
+        // OK, now remove all the cookie remaining 
+        cout <<"Removing all the cookies by using the 'deleteTransportProperty(Cookie)' method"<<endl;
+        calculator.deleteTransportProperty("Cookie");
+        cout <<"Calling the service and expecting no cookies to be there"<<endl;
+        callCalculatorAndPrintProperties(calculator, i1, i2);
 	}
 	catch(AxisException& e)
 	{
-			bool bSilent = false;
-
-			if( e.getExceptionCode() == CLIENT_TRANSPORT_OPEN_CONNECTION_FAILED)
-			{
-				if( iRetryIterationCount > 0)
-				{
-					bSilent = true;
-				}
-			}
-			else
-			{
-				iRetryIterationCount = 0;
-			}
-
-            if( !bSilent)
-			{
-				cout << "Exception : " << e.what() << endl;
-			}
+			cout << "Exception : " << e.what() << endl;
 	}
 	catch(exception& e)
 	{
@@ -99,11 +123,48 @@
 	{
 	    cout << "Unknown exception has occured" << endl;
 	}
-		iRetryIterationCount--;
-		} while( iRetryIterationCount > 0 && !bSuccess);
   cout<< "---------------------- TEST COMPLETE -----------------------------"<< endl;
 	
 	return 0;
+}
+
+void callCalculatorAndPrintProperties(Calculator& calculator, int i1, int i2)
+{
+ 
+        int iResult = calculator.add(i1, i2);
+        // get the HTTP properties that were sent out
+        cout <<"----------------------------------------------------------"<<endl;
+        cout << "Properties that were sent out"<<endl;
+        const char* key = calculator.getFirstTransportPropertyKey(false);
+        if(key)
+        {
+            cout << key;
+            cout << "="<<calculator.getCurrentTransportPropertyValue(false)<<endl;
+        }
+        // then the rest
+        while(key = calculator.getNextTransportPropertyKey(false))
+        {
+            cout << key;
+            cout << "="<<calculator.getCurrentTransportPropertyValue(false)<<endl;
+        }
+        cout <<"----------------------------------------------------------"<<endl;
+        cout << "Properties that were received"<<endl;
+        key = calculator.getFirstTransportPropertyKey();
+        if(key)
+        {
+            cout << key;
+            cout << "="<<calculator.getCurrentTransportPropertyValue()<<endl;
+        }
+        // then the rest
+        while(key = calculator.getNextTransportPropertyKey())
+        {
+            cout << key;
+            cout << "="<<calculator.getCurrentTransportPropertyValue()<<endl;
+        }
+        cout <<"----------------------------------------------------------"<<endl;
+        
+        
+ 
 }
 
 void PrintUsage()

Modified: webservices/axis/trunk/c/tests/auto_build/testcases/output/Cookies.cpp.out
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/c/tests/auto_build/testcases/output/Cookies.cpp.out?rev=367995&r1=367994&r2=367995&view=diff
==============================================================================
--- webservices/axis/trunk/c/tests/auto_build/testcases/output/Cookies.cpp.out (original)
+++ webservices/axis/trunk/c/tests/auto_build/testcases/output/Cookies.cpp.out Wed Jan 11 02:24:04 2006
@@ -1,4 +1,96 @@
-5
-5
-5
+Calling calculator for the first time and expecting Set-Cookie back
+----------------------------------------------------------
+Properties that were sent out
+SOAPAction="Calculator#add"
+Content-Length=397
+----------------------------------------------------------
+Properties that were received
+Server= WebSphere Application Server/5.1
+Content-Type= text/xml; charset=utf-8
+Content-Language= en-GB
+Set-Cookie= LtpaToken2=1234567890abcdefghijklmnopqrstuvwxyz; Path=/ 
+Set-Cookie= LtpaToken==+yOkBBuvLtTaiuBDkfgy3W6mZraGn7V5Dzp; Path=/ 
+Set-Cookie= JSESSIONID=0000EyvJyGOS-2e9nlRijFiwKSR:-1; Path=/ 
+Transfer-Encoding= chunked
+----------------------------------------------------------
+Storing the cookies so I can give them to the next web service
+Calling calculator for the second time and expecting to send the cookies back
+----------------------------------------------------------
+Properties that were sent out
+SOAPAction="Calculator#add"
+Content-Length=397
+Cookie=LtpaToken2=1234567890abcdefghijklmnopqrstuvwxyz;LtpaToken==+yOkBBuvLtTaiuBDkfgy3W6mZraGn7V5Dzp;JSESSIONID=0000EyvJyGOS-2e9nlRijFiwKSR:-1
+----------------------------------------------------------
+Properties that were received
+Server= WebSphere Application Server/5.1
+Content-Type= text/xml; charset=utf-8
+Content-Language= en-GB
+Transfer-Encoding= chunked
+----------------------------------------------------------
+Use a new instance of calculator and ensure that the old cookies are lost
+----------------------------------------------------------
+Properties that were sent out
+SOAPAction="Calculator#add"
+Content-Length=397
+----------------------------------------------------------
+Properties that were received
+Server= WebSphere Application Server/5.1
+Content-Type= text/xml; charset=utf-8
+Content-Language= en-GB
+Transfer-Encoding= chunked
+----------------------------------------------------------
+Add the cookies from the previous web service to the new web service
+Completed adding cookies
+Call the calculator service twice and ensure that the cookies remain
+----------------------------------------------------------
+Properties that were sent out
+SOAPAction="Calculator#add"
+Content-Length=397
+Cookie=LtpaToken2=1234567890abcdefghijklmnopqrstuvwxyz;LtpaToken==+yOkBBuvLtTaiuBDkfgy3W6mZraGn7V5Dzp;JSESSIONID=0000EyvJyGOS-2e9nlRijFiwKSR:-1
+----------------------------------------------------------
+Properties that were received
+Server= WebSphere Application Server/5.1
+Content-Type= text/xml; charset=utf-8
+Content-Language= en-GB
+Transfer-Encoding= chunked
+----------------------------------------------------------
+----------------------------------------------------------
+Properties that were sent out
+SOAPAction="Calculator#add"
+Content-Length=397
+Cookie=LtpaToken2=1234567890abcdefghijklmnopqrstuvwxyz;LtpaToken==+yOkBBuvLtTaiuBDkfgy3W6mZraGn7V5Dzp;JSESSIONID=0000EyvJyGOS-2e9nlRijFiwKSR:-1
+----------------------------------------------------------
+Properties that were received
+Server= WebSphere Application Server/5.1
+Content-Type= text/xml; charset=utf-8
+Content-Language= en-GB
+Transfer-Encoding= chunked
+----------------------------------------------------------
+Deleting the LtpaToken2 cookie
+Calling the service and not expecting the LtpaToken2 in the cookie header
+----------------------------------------------------------
+Properties that were sent out
+SOAPAction="Calculator#add"
+Content-Length=397
+Cookie=LtpaToken==+yOkBBuvLtTaiuBDkfgy3W6mZraGn7V5Dzp;JSESSIONID=0000EyvJyGOS-2e9nlRijFiwKSR:-1
+----------------------------------------------------------
+Properties that were received
+Server= WebSphere Application Server/5.1
+Content-Type= text/xml; charset=utf-8
+Content-Language= en-GB
+Transfer-Encoding= chunked
+----------------------------------------------------------
+Removing all the cookies by using the 'deleteTransportProperty(Cookie)' method
+Calling the service and expecting no cookies to be there
+----------------------------------------------------------
+Properties that were sent out
+SOAPAction="Calculator#add"
+Content-Length=397
+----------------------------------------------------------
+Properties that were received
+Server= WebSphere Application Server/5.1
+Content-Type= text/xml; charset=utf-8
+Content-Language= en-GB
+Transfer-Encoding= chunked
+----------------------------------------------------------
 ---------------------- TEST COMPLETE -----------------------------

Modified: webservices/axis/trunk/c/tests/auto_build/testcases/output/Cookies.request
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/c/tests/auto_build/testcases/output/Cookies.request?rev=367995&r1=367994&r2=367995&view=diff
==============================================================================
--- webservices/axis/trunk/c/tests/auto_build/testcases/output/Cookies.request (original)
+++ webservices/axis/trunk/c/tests/auto_build/testcases/output/Cookies.request Wed Jan 11 02:24:04 2006
@@ -19,7 +19,74 @@
 Content-Type: text/xml; charset=UTF-8
 SOAPAction: "Calculator#add"
 Content-Length: 397
-Cookie:  LtpaToken2=1234567890abcdefghijklmnopqrstuvwxyz; LtpaToken==+yOkBBuvLtTaiuBDkfgy3W6mZraGn7V5Dzp; JSESSIONID=0000EyvJyGOS-2e9nlRijFiwKSR:-1
+Cookie: LtpaToken2=1234567890abcdefghijklmnopqrstuvwxyz;LtpaToken==+yOkBBuvLtTaiuBDkfgy3W6mZraGn7V5Dzp;JSESSIONID=0000EyvJyGOS-2e9nlRijFiwKSR:-1
+
+<?xml version='1.0' encoding='utf-8' ?>
+<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+<SOAP-ENV:Body>
+<ns1:add xmlns:ns1="http://localhost/axis/Calculator">
+<ns1:arg_0_0>2</ns1:arg_0_0>
+<ns1:arg_1_0>3</ns1:arg_1_0>
+</ns1:add>
+</SOAP-ENV:Body>
+</SOAP-ENV:Envelope>
+
+POST /axis/CalculatorDoc HTTP/1.1
+Host: 127.0.0.1:13260
+Content-Type: text/xml; charset=UTF-8
+SOAPAction: "Calculator#add"
+Content-Length: 397
+
+<?xml version='1.0' encoding='utf-8' ?>
+<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+<SOAP-ENV:Body>
+<ns1:add xmlns:ns1="http://localhost/axis/Calculator">
+<ns1:arg_0_0>2</ns1:arg_0_0>
+<ns1:arg_1_0>3</ns1:arg_1_0>
+</ns1:add>
+</SOAP-ENV:Body>
+</SOAP-ENV:Envelope>
+
+POST /axis/CalculatorDoc HTTP/1.1
+Host: 127.0.0.1:13260
+Content-Type: text/xml; charset=UTF-8
+SOAPAction: "Calculator#add"
+Content-Length: 397
+Cookie: LtpaToken2=1234567890abcdefghijklmnopqrstuvwxyz;LtpaToken==+yOkBBuvLtTaiuBDkfgy3W6mZraGn7V5Dzp;JSESSIONID=0000EyvJyGOS-2e9nlRijFiwKSR:-1
+
+<?xml version='1.0' encoding='utf-8' ?>
+<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+<SOAP-ENV:Body>
+<ns1:add xmlns:ns1="http://localhost/axis/Calculator">
+<ns1:arg_0_0>2</ns1:arg_0_0>
+<ns1:arg_1_0>3</ns1:arg_1_0>
+</ns1:add>
+</SOAP-ENV:Body>
+</SOAP-ENV:Envelope>
+
+POST /axis/CalculatorDoc HTTP/1.1
+Host: 127.0.0.1:13260
+Content-Type: text/xml; charset=UTF-8
+SOAPAction: "Calculator#add"
+Content-Length: 397
+Cookie: LtpaToken2=1234567890abcdefghijklmnopqrstuvwxyz;LtpaToken==+yOkBBuvLtTaiuBDkfgy3W6mZraGn7V5Dzp;JSESSIONID=0000EyvJyGOS-2e9nlRijFiwKSR:-1
+
+<?xml version='1.0' encoding='utf-8' ?>
+<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+<SOAP-ENV:Body>
+<ns1:add xmlns:ns1="http://localhost/axis/Calculator">
+<ns1:arg_0_0>2</ns1:arg_0_0>
+<ns1:arg_1_0>3</ns1:arg_1_0>
+</ns1:add>
+</SOAP-ENV:Body>
+</SOAP-ENV:Envelope>
+
+POST /axis/CalculatorDoc HTTP/1.1
+Host: 127.0.0.1:13260
+Content-Type: text/xml; charset=UTF-8
+SOAPAction: "Calculator#add"
+Content-Length: 397
+Cookie: LtpaToken==+yOkBBuvLtTaiuBDkfgy3W6mZraGn7V5Dzp;JSESSIONID=0000EyvJyGOS-2e9nlRijFiwKSR:-1
 
 <?xml version='1.0' encoding='utf-8' ?>
 <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

Modified: webservices/axis/trunk/c/tests/auto_build/testcases/output/Cookies_ServerResponse.expected
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/c/tests/auto_build/testcases/output/Cookies_ServerResponse.expected?rev=367995&r1=367994&r2=367995&view=diff
==============================================================================
--- webservices/axis/trunk/c/tests/auto_build/testcases/output/Cookies_ServerResponse.expected (original)
+++ webservices/axis/trunk/c/tests/auto_build/testcases/output/Cookies_ServerResponse.expected Wed Jan 11 02:24:04 2006
@@ -32,4 +32,59 @@
 ###
 <?xml version="1.0" encoding="utf-8"?>
 <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Header/><soapenv:Body><addResponse xmlns="http://localhost/axis/Calculator"><addReturn>5</addReturn></addResponse></soapenv:Body></soapenv:Envelope>
+0
+
+HTTP/1.1 200 OK
+Server: WebSphere Application Server/5.1
+Content-Type: text/xml; charset=utf-8
+Content-Language: en-GB
+Transfer-Encoding: chunked
+
+###
+<?xml version="1.0" encoding="utf-8"?>
+<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Header/><soapenv:Body><addResponse xmlns="http://localhost/axis/Calculator"><addReturn>5</addReturn></addResponse></soapenv:Body></soapenv:Envelope>
+0
+
+HTTP/1.1 200 OK
+Server: WebSphere Application Server/5.1
+Content-Type: text/xml; charset=utf-8
+Content-Language: en-GB
+Transfer-Encoding: chunked
+
+###
+<?xml version="1.0" encoding="utf-8"?>
+<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Header/><soapenv:Body><addResponse xmlns="http://localhost/axis/Calculator"><addReturn>5</addReturn></addResponse></soapenv:Body></soapenv:Envelope>
+0
+
+HTTP/1.1 200 OK
+Server: WebSphere Application Server/5.1
+Content-Type: text/xml; charset=utf-8
+Content-Language: en-GB
+Transfer-Encoding: chunked
+
+###
+<?xml version="1.0" encoding="utf-8"?>
+<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Header/><soapenv:Body><addResponse xmlns="http://localhost/axis/Calculator"><addReturn>5</addReturn></addResponse></soapenv:Body></soapenv:Envelope>
+0
+
+HTTP/1.1 200 OK
+Server: WebSphere Application Server/5.1
+Content-Type: text/xml; charset=utf-8
+Content-Language: en-GB
+Transfer-Encoding: chunked
+
+###
+<?xml version="1.0" encoding="utf-8"?>
+<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Header/><soapenv:Body><addResponse xmlns="http://localhost/axis/Calculator"><addReturn>5</addReturn></addResponse></soapenv:Body></soapenv:Envelope>
+0
+
+HTTP/1.1 200 OK
+Server: WebSphere Application Server/5.1
+Content-Type: text/xml; charset=utf-8
+Content-Language: en-GB
+Transfer-Encoding: chunked
+
+###
+<?xml version="1.0" encoding="utf-8"?>
+<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Header/><soapenv:Body><addResponse xmlns="http://localhost/axis/Calculator"><addReturn>5</addReturn></addResponse></soapenv:Body></soapenv:Envelope>
 0