axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From prest...@apache.org
Subject svn commit: r393445 - /webservices/axis/trunk/c/tests/auto_build/testcases/client/cpp/CalculatorDocProgConfigClient.cpp
Date Wed, 12 Apr 2006 12:37:49 GMT
Author: prestonf
Date: Wed Apr 12 05:37:48 2006
New Revision: 393445

URL: http://svn.apache.org/viewcvs?rev=393445&view=rev
Log:
Added additional code to report errors if expected environment variables cannot be found.

Modified:
    webservices/axis/trunk/c/tests/auto_build/testcases/client/cpp/CalculatorDocProgConfigClient.cpp

Modified: webservices/axis/trunk/c/tests/auto_build/testcases/client/cpp/CalculatorDocProgConfigClient.cpp
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/c/tests/auto_build/testcases/client/cpp/CalculatorDocProgConfigClient.cpp?rev=393445&r1=393444&r2=393445&view=diff
==============================================================================
--- webservices/axis/trunk/c/tests/auto_build/testcases/client/cpp/CalculatorDocProgConfigClient.cpp
(original)
+++ webservices/axis/trunk/c/tests/auto_build/testcases/client/cpp/CalculatorDocProgConfigClient.cpp
Wed Apr 12 05:37:48 2006
@@ -20,129 +20,151 @@
 #include <iostream>
 #include <signal.h>
 
-void sig_handler(int);
+void sig_handler( int);
 void PrintUsage();
-bool IsNumber(const char* p);
+bool IsNumber( const char * p);
 
-int main(int argc, char* argv[])
+int main( int argc, char* argv[])
 {
-	char endpoint[256];
-	const char* url="http://localhost:80/axis/Calculator";
-	const char* op = 0;
-	int i1=0, i2=0;
-	char* libhome = NULL;
-	char parserlocation[255] ;
-	char httptransportlocation[255];
-	char httpchannellocation[255];
-	int iResult;
-
-	signal(SIGILL, sig_handler);
-	signal(SIGABRT, sig_handler);
-	signal(SIGSEGV, sig_handler);
-	//signal(SIGQUIT, sig_handler);
-	//signal(SIGBUS, sig_handler);
-	signal(SIGFPE, sig_handler);
+	char			endpoint[256];
+	char *			url = "http://localhost:80/axis/Calculator";
+	char *			libhome = NULL;
+	char			parserlocation[255];
+	char			httptransportlocation[255];
+	char			httpchannellocation[255];
+	int				iResult;
+
+	signal( SIGILL, sig_handler);
+	signal( SIGABRT, sig_handler);
+	signal( SIGSEGV, sig_handler);
+	//signal( SIGQUIT, sig_handler);
+	//signal( SIGBUS, sig_handler);
+	signal( SIGFPE, sig_handler);
 
 	url = argv[1];
 	
-		bool bSuccess = false;
-		int	iRetryIterationCount = 3;
+	bool	bSuccess = false;
+	int		iRetryIterationCount = 3;
 
-		do
+	do
+	{
+		try
 		{
-			try
+			sprintf( endpoint, "%s", url);
+            
+			AxisCPPConfigDefaults	config;
+			char *					installdir = NULL;
+
+			if( (installdir = getenv( "INSTALLDIR")) == NULL)
+			{
+				cout << "Error - Environment variable 'INSTALLDIR' has not been set." <<
endl;
+
+				installdir = getenv( "AXISCPP_DEPLOY");
+			}
+
+			config.setAxisHome( installdir);
+			config.setClientLog( "Client.taw");
+			
+			char	wsddfile[255];
+			
+			sprintf( wsddfile, "%s/%s", installdir, "ClientFile.wsdd");
+
+			config.setClientWSDDFile( wsddfile);
+
+			if( (libhome = getenv( "LIBHOME")) == NULL)
+			{
+				cout << "Error - Environment variable 'LIBHOME' has not been set." << endl;
+
+				libhome = new char[ strlen( installdir) + 10];
+
+				sprintf( libhome, "%s/obj/bin", installdir);
+			}
+
+#if defined WIN32
+			sprintf( parserlocation,       "%s/%s", libhome, "AxisXMLParser.dll");
+			sprintf( httptransportlocation,"%s/%s", libhome, "HTTPTransport.dll");
+			sprintf( httpchannellocation,  "%s/%s", libhome, "HTTPChannel.dll");
+
+			config.setXMLParserLibrary( parserlocation);
+			config.setHTTPTransportLibrary( httptransportlocation);
+			config.setHTTPChannelLibrary( httpchannellocation);
+#elif defined AIX
+			sprintf( parserlocation,        "%s/%s", libhome, "libaxis_xmlparser.a");
+			sprintf( httptransportlocation, "%s/%s", libhome, "libhttp_transport.a");
+			sprintf( httpchannellocation,   "%s/%s", libhome, "libhttp_channel.a");
+
+			config.setXMLParserLibrary( parserlocation);
+			config.setHTTPTransportLibrary( httptransportlocation);
+			config.setHTTPChannelLibrary( httpchannellocation);
+#else
+			sprintf( parserlocation,        "%s/%s", libhome, "libaxis_xmlparser.so");
+			sprintf( httptransportlocation, "%s/%s", libhome, "libhttp_transport.so");
+			sprintf( httpchannellocation,   "%s/%s", libhome, "libhttp_channel.so");
+
+			config.setXMLParserLibrary( parserlocation);
+			config.setHTTPTransportLibrary( httptransportlocation);
+			config.setHTTPChannelLibrary( httpchannellocation);
+#endif
+
+			config.apply();
+//				axishome = config.getAxisHome();
+//				cout << "Axis Home = " << axishome << endl;
+
+			char *	wsddfile1 = NULL;
+
+			wsddfile1 = config.getClientWSDDFile();
+
+			cout << "Client Log file name = " << config.getClientLog() << endl;
+
+			if( strcmp( parserlocation, config.getXMLParserLibrary()) == 0)
 			{
-				sprintf(endpoint, "%s", url);
-                		AxisCPPConfigDefaults config;
-                		char* installdir = NULL;
-				installdir = getenv( "INSTALLDIR" );
-                		config.setAxisHome(installdir);
-                		config.setClientLog("Client.taw");
-                		char wsddfile[255];
-				sprintf(wsddfile,"%s/%s",installdir,"ClientFile.wsdd");
-                		//char* wsddfile = "ClientFile.wsdd";
-                		config.setClientWSDDFile(wsddfile);
-
-				libhome = getenv("LIBHOME");
-
-                		#if defined ( WIN32 )
-				sprintf(parserlocation,"%s/%s",libhome,"AxisXMLParser.dll");
-				sprintf(httptransportlocation,"%s/%s",libhome,"HTTPTransport.dll");
-				sprintf(httpchannellocation,"%s/%s",libhome,"HTTPChannel.dll");
-				config.setXMLParserLibrary(parserlocation);
-                		config.setHTTPTransportLibrary(httptransportlocation);
-                		config.setHTTPChannelLibrary(httpchannellocation);
-
-				#elif defined ( AIX )
-				sprintf(parserlocation,"%s/%s",libhome,"libaxis_xmlparser.a");
-				sprintf(httptransportlocation,"%s/%s",libhome,"libhttp_transport.a");
-				sprintf(httpchannellocation,"%s/%s",libhome,"libhttp_channel.a");
-				config.setXMLParserLibrary(parserlocation);
-                		config.setHTTPTransportLibrary(httptransportlocation);
-                		config.setHTTPChannelLibrary(httpchannellocation);
-
-				#else 
-				sprintf(parserlocation,"%s/%s",libhome,"libaxis_xmlparser.so");
-				sprintf(httptransportlocation,"%s/%s",libhome,"libhttp_transport.so");
-				sprintf(httpchannellocation,"%s/%s",libhome,"libhttp_channel.so");
-				config.setXMLParserLibrary(parserlocation);
-                		config.setHTTPTransportLibrary(httptransportlocation);
-                		config.setHTTPChannelLibrary(httpchannellocation);
-				#endif
-
-                		config.apply();
-                		//axishome = config.getAxisHome();
-                		//cout << "Axis Home = " << axishome << endl;
-                		char* wsddfile1 = NULL;
-                		wsddfile1 = config.getClientWSDDFile();
-				cout<< "Client Log file name = " << config.getClientLog() << endl;
-                		char* parser  = config.getXMLParserLibrary();
-                		//cout << "XML Parser used = " << parser << endl;
+				cout << "XML Parser is  matched" << endl;
+			}
+			else
+			{ 
+				cout << "XML parser is not matched" << endl;
+			}
 	
-				if (strcmp (parserlocation,parser) == 0)
-				{
-					cout << "XML Parser is  matched" << endl;
-				}
-				else{ 
-					cout << "XML parser is not matched" << endl;
-				}
-		
-				if ( strcmp(httptransportlocation,config.getHTTPTransportLibrary()) == 0)
-				{
-					cout << "HTTP Transport is matched" << endl;
-				}
-				else{
-					cout << "HTTP Transport is not matched" << endl;
-				}
+			if( strcmp( httptransportlocation, config.getHTTPTransportLibrary()) == 0)
+			{
+				cout << "HTTP Transport is matched" << endl;
+			}
+			else
+			{
+				cout << "HTTP Transport is not matched" << endl;
+			}
 
-				if ( strcmp(httpchannellocation,config.getHTTPChannelLibrary()) == 0)
-				{
-					cout << "HTTP Channel lib is matched" << endl;
-				}
-				else {
-					cout << "HTTP Channel is not matched" << endl;
-				}
+			if( strcmp( httpchannellocation, config.getHTTPChannelLibrary()) == 0)
+			{
+				cout << "HTTP Channel lib is matched" << endl;
+			}
+			else
+			{
+				cout << "HTTP Channel is not matched" << endl;
+			}
 
-                		Calculator ws(endpoint);
+			Calculator ws( endpoint);
 
-				op = "add";
-				i1 = 2;
-				i2 = 3;
+			char *	op = "add";
+			int		i1 = 2;
+			int		i2 = 3;
 
-				if (strcmp(op, "add") == 0)
-				{
-					iResult = ws.add(i1, i2);
-					cout << iResult << endl;
-					bSuccess = true;
-				}
+			if( strcmp( op, "add") == 0)
+			{
+				iResult = ws.add( i1, i2);
+
+				cout << iResult << endl;
+
+				bSuccess = true;
 			}
-		catch(AxisException& e)
+		}
+		catch( AxisException& e)
 		{
 			bool bSilent = false;
 
 			if( e.getExceptionCode() == CLIENT_TRANSPORT_OPEN_CONNECTION_FAILED)
 			{
-				if( iRetryIterationCount > 0)
+				if( iRetryIterationCount > 1)
 				{
 					bSilent = true;
 				}
@@ -152,45 +174,54 @@
 				iRetryIterationCount = 0;
 			}
 
-            		if( !bSilent)
+           	if( !bSilent)
 			{
 				cout << "Exception : " << e.what() << endl;
 			}
 		}
-		catch(exception& e)
+		catch( exception& e)
 		{
-	    		cout << "Unknown exception has occured" << endl;
+	    	cout << "Unknown exception has occured : " << e.what() << endl;
 		} 
-		catch(...)
+		catch( ...)
 		{
-	    		cout << "Unknown exception has occured" << endl;
+	    	cout << "Unknown exception has occured" << endl;
 		}
-		iRetryIterationCount--;
-		} 
-		while( iRetryIterationCount > 0 && !bSuccess);
-  		cout<< "---------------------- TEST COMPLETE -----------------------------"<<
endl;
 	
-		return 0;
+		iRetryIterationCount--;
+	} while( iRetryIterationCount > 0 && !bSuccess);
+          	
+	cout << "---------------------- TEST COMPLETE -----------------------------" <<
endl;
+
+	return 0;
 }
 
 void PrintUsage()
 {
-	printf("Usage :\n Calculator <url>\n\n");
-	exit(1);
+	cout << "Usage :" << endl << "Calculator <url>" << endl <<
endl;
+
+	exit( 1);
 }
 
-bool IsNumber(const char* p)
+bool IsNumber( const char * p)
 {
-	for (int x=0; x < strlen(p); x++)
+	for( int x = 0; x < (int) strlen( p); x++)
 	{
-		if (!isdigit(p[x])) return false;
+		if( !isdigit( p[x]))
+		{
+			return false;
+		}
 	}
+
 	return true;
 }
 
-void sig_handler(int sig) {
-	signal(sig, sig_handler);
+void sig_handler( int sig)
+{
+	signal( sig, sig_handler);
+
     cout << "SIGNAL RECEIVED " << sig << endl;
-	exit(1);
+	
+	exit( 1);
 }
 



Mime
View raw message