You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by pe...@apache.org on 2004/10/05 17:46:39 UTC
cvs commit: ws-axis/c/tests/auto_build/testcases/client/cpp CalculatorDocClient.cpp ExceptionTestDocClient.cpp FaultMappingDocClient.cpp InteropTestRound1DocClient.cpp MathOpsDocClient.cpp SimpleArrayDocClient.cpp SimpleRefDocClient.cpp
perryan 2004/10/05 08:46:39
Added: c/tests/auto_build/testcases/client/cpp
CalculatorDocClient.cpp ExceptionTestDocClient.cpp
FaultMappingDocClient.cpp
InteropTestRound1DocClient.cpp MathOpsDocClient.cpp
SimpleArrayDocClient.cpp SimpleRefDocClient.cpp
Log:
New files added whcih are just a copy of the existing tests with the same name without the Doc in the name. These are used to run against the doc literal wsdls in the test framework.
CVS: ----------------------------------------------------------------------
CVS: PR:
CVS: If this change addresses a PR in the problem report tracking
CVS: database, then enter the PR number(s) here.
CVS: Obtained from:
CVS: If this change has been taken from another system, such as NCSA,
CVS: then name the system in this line, otherwise delete it.
CVS: Submitted by:
CVS: If this code has been contributed to Apache by someone else; i.e.,
CVS: they sent us a patch or a new module, then include their name/email
CVS: address here. If this is your work then delete this line.
CVS: Reviewed by:
CVS: If we are doing pre-commit code reviews and someone else has
CVS: reviewed your changes, include their name(s) here.
CVS: If you have not had it reviewed then delete this line.
Revision Changes Path
1.1 ws-axis/c/tests/auto_build/testcases/client/cpp/CalculatorDocClient.cpp
Index: CalculatorDocClient.cpp
===================================================================
#include "Calculator.h"
#include <axis/AxisGenException.h>
#include <ctype.h>
void PrintUsage();
bool IsNumber(const char* p);
int main(int argc, char* argv[])
{
char endpoint[256];
const char* url="http://192.168.101.4:80/axis/Calculator";
const char* op = 0;
int i1=0, i2=0;
int iResult;
char* pcDetail;
pcDetail = 0;
url = argv[1];
try
{
printf("Sending Requests to Server %s .......\n\n", url);
sprintf(endpoint, "%s", url);
Calculator ws(endpoint);
op = "add";
i1 = 2;
i2 = 3;
if (strcmp(op, "add") == 0)
{
iResult = ws.add(i1, i2);
//ws.getFaultDetail(&pcDetail);
printf("%d\n", iResult);
/*printf("pcDetail:%s\n", pcDetail);*/
}
}
catch(AxisException& e)
{
printf("Exception : %s\n", e.what());
}
catch(exception& e)
{
printf("Unknown exception has occured\n" );
}
catch(...)
{
printf("Unknown exception has occured\n" );
}
return 0;
}
void PrintUsage()
{
printf("Usage :\n Calculator <server> <port> <operation> <parameter> <parameter>\n\n");
exit(1);
}
bool IsNumber(const char* p)
{
for (int x=0; x < strlen(p); x++)
{
if (!isdigit(p[x])) return false;
}
return true;
}
1.1 ws-axis/c/tests/auto_build/testcases/client/cpp/ExceptionTestDocClient.cpp
Index: ExceptionTestDocClient.cpp
===================================================================
#include "MathOps.h"
#include <axis/server/AxisException.h>
#include <ctype.h>
void PrintUsage();
bool IsNumber(const char* p);
int main(int argc, char* argv[])
{
char endpoint[256];
const char* server="localhost";
const char* port="80";
const char* url="http://localhost:80/axis/MathOps";
const char* op = 0;
char* p1 = 0;
const char* p2 = 0;
int p3 = 0;
int i1=0, i2=0;
int iResult;
char* pcDetail;
url = argv[1];
op = "div";
i1 = 10;
i2 = 5;
if (strcmp(op, "div") == 0)
{
for(p3 = 0; p3 < 3; p3++)
{
try
{
switch(p3)
{
case 0:
/* Sends a normal request. the result should be the division of
* two numbers the user has provided
*/
//sprintf(endpoint, "http://%s:%s/axis/MathOps", server, port);
sprintf(endpoint, "%s", url);
break;
case 1:
/* Service name is missing. The message
* Exception : AxisSoapException:Soap action is empty
* should be returned to the user.
*/
//sprintf(endpoint, "http://%s:%s/axis", server, port);
sprintf(endpoint, "%s", url);
p1 = strrchr(endpoint, '/');
*p1 = (char)NULL; // Set a NULL at the last '/' char to strip the service endpoint interface
break;
case 2:
/* Service name is wrong. The message
* Exception : AxisWsddException:Requested service not found
* should be returned to the user.
*/
//sprintf(endpoint, "http://%s:%s/axis/Math", server, port);
sprintf(endpoint, "%s", url);
p1 = endpoint + (strlen(endpoint) - 3);
*p1 = (char)NULL; // Set a NULL to strip the last 3 chars
break;
case 3:
/* Service path is empty. The message
* The corresponding http fail message
* should be returned to the user.
*/
/*sprintf(endpoint, "http://%s:%s/", server, port);*/
printf("This test has been temporarily terminated" \
" due to an unresolved bug\n");
exit(0); /* This is temporary code*/
break;
case 4:
/* Exception : AxisTransportException:Unexpected string
* received. Most probably server returned an empty stream
*/
sprintf(endpoint, "", server, port);
//sprintf(endpoint, "http://%s:%s", server, port);
break;
default:
printf("Invalid option for the last parameter\n\n");
return 0;
}
//sprintf(endpoint, "http://%s:%s/axis/MathOps", server, port);
printf("ENDPOINT = %s\n", endpoint);
MathOps ws(endpoint);
iResult = ws.div(i1, i2);
printf("Result is:%d\n", iResult);
}
catch(AxisException& e)
{
printf("%s\n", e.what());
}
catch(exception& e)
{
printf("Unknown exception has occured\n");
}
catch(...)
{
printf("Unknown exception has occured\n");
}
}
}
else
{
printf("Invalid operation %s\n\n", op);
PrintUsage();
}
return 0;
}
void PrintUsage()
{
printf("Usage :\n MathOps <server> <port> <operation> <parameter> <parameter> <parameter>\n\n");
exit(1);
}
bool IsNumber(const char* p)
{
for (int x=1; x < strlen(p); x++)
{
if (!isdigit(p[x])) return false;
}
return true;
}
1.1 ws-axis/c/tests/auto_build/testcases/client/cpp/FaultMappingDocClient.cpp
Index: FaultMappingDocClient.cpp
===================================================================
#include "MathOps.h"
#include <axis/server/AxisException.h>
#include <ctype.h>
void PrintUsage();
bool IsNumber(const char* p);
int main(int argc, char* argv[])
{
char endpoint[256];
const char* server="localhost";
const char* url="http://localhost:80/axis/MathOps";
const char* port="80";
const char* op = 0;
const char* p1 = 0;
const char* p2 = 0;
int i1=0, i2=0;
int iResult;
char* pcDetail;
url = argv[1];
sprintf(endpoint, "%s", url);
MathOps ws(endpoint);
op = "div";
if (strcmp(op, "div") == 0)
{
for(int i = 0; i < 4; i++)
{
printf("%d\n", i);
switch(i)
{
case 0: i1 = 10; i2 = 5; break;
case 1: i1 = 10; i2 = 0; break;
case 2: i1 = 1000; i2 = 5; break;
case 3: i1 = 10; i2 = -5; break;
}
try
{
iResult = ws.div(i1, i2);
printf("Result is:%d\n", iResult);
}
catch(MathOpsService_AxisClientException& e)
{
printf("%s\n", e.what());
}
catch(AxisException& e)
{
printf("Exception : %s\n", e.what());
}
catch(exception& e)
{
}
catch(...)
{
}
}
}
else
{
printf("Invalid operation %s\n\n", op);
PrintUsage();
}
return 0;
}
void PrintUsage()
{
printf("Usage :\n MathOps <server> <port> <operation> <parameter> <parameter>\n\n");
exit(1);
}
bool IsNumber(const char* p)
{
for (int x=1; x < strlen(p); x++)
{
if (!isdigit(p[x])) return false;
}
return true;
}
1.1 ws-axis/c/tests/auto_build/testcases/client/cpp/InteropTestRound1DocClient.cpp
Index: InteropTestRound1DocClient.cpp
===================================================================
// InteropBaseClient.cpp : Defines the entry point for the console application.
//
#include <string>
using namespace std;
#include "InteropTestPortType.h"
#define ARRAYSIZE 2
int main(int argc, char* argv[])
{
int x;
char buffer1[100];
char endpoint[256];
const char* server="localhost";
const char* port="80";
sprintf(endpoint, "http://%s:%s/axis/base", server, port);
try
{
InteropTestPortType ws(endpoint, APTHTTP);
ws.setTransportTimeout(5);
printf("invoking echoString...\n");
//testing echoString
string bigstring;
for (int ii=0;ii<2;ii++)
{
bigstring += "hello world ";
}
strcpy(buffer1, bigstring.c_str());
printf(ws.echoString(buffer1));
if (0 == strcmp(ws.echoString("hello world"), "hello world"))
printf("successful\n");
else
printf("failed\n");
// testing echoStringArray
xsd__string_Array arrstr;
arrstr.m_Array = new char*[ARRAYSIZE];
arrstr.m_Size = ARRAYSIZE;
sprintf(buffer1, "%dth element of string array", 0);
//sprintf(buffer2, "%dth element of string array", 1);
for(int i=0; i< ARRAYSIZE; i++)
{
arrstr.m_Array[i] = buffer1;
}
//arrstr.m_Array[1] = buffer2;
printf("invoking echoStringArray...\n");
if (ws.echoStringArray(arrstr).m_Array != NULL)
printf("successful\n");
else
printf("failed\n");
// testing echoInteger
printf("invoking echoInteger...\n");
if (ws.echoInteger(56) == 56)
printf("successful\n");
else
printf("failed\n");
// testing echoIntegerArray
xsd__int_Array arrint;
arrint.m_Array = new int[ARRAYSIZE];
arrint.m_Size = ARRAYSIZE;
for (x=0;x<ARRAYSIZE;x++)
{
arrint.m_Array[x] = x;
}
printf("invoking echoIntegerArray...\n");
if (ws.echoIntegerArray(arrint).m_Array != NULL)
printf("successful\n");
else
printf("failed\n");
// testing echoFloat
printf("invoking echoFloat...\n");
float fvalue = 1.4214;
if (ws.echoFloat(fvalue) > 1.42)
printf("successful\n");
else
printf("failed\n");
// testing echoFloat
xsd__float_Array arrfloat;
arrfloat.m_Array = new float[ARRAYSIZE];
arrfloat.m_Size = ARRAYSIZE;
for (x=0;x<ARRAYSIZE;x++)
{
arrfloat.m_Array[x] = 1.1111*x;
}
printf("invoking echoFloatArray...\n");
if (ws.echoFloatArray(arrfloat).m_Array != NULL)
printf("successful\n");
else
printf("failed\n");
// testing echo Struct
SOAPStruct stct;
stct.varFloat = 12345.7346345;
stct.varInt = 5000;
stct.varString = strdup("This is string in SOAPStruct");
printf("invoking echoStruct...\n");
if (ws.echoStruct(&stct) != NULL)
printf("successful\n");
else
printf("failed\n");
//testing echo Array of Struct
SOAPStruct_Array arrstct;
arrstct.m_Array = new SOAPStruct[ARRAYSIZE];
arrstct.m_Size = ARRAYSIZE;
for (x=0;x<ARRAYSIZE;x++)
{
arrstct.m_Array[x].varFloat = 1.1111*x;
arrstct.m_Array[x].varInt = x;
sprintf(buffer1, "varString of %dth element of SOAPStruct array", x);
arrstct.m_Array[x].varString = buffer1;
}
//testing echo Struct Array
printf("invoking echoStructArray...\n");
if (ws.echoStructArray(arrstct).m_Array != NULL)
printf("successful\n");
else
printf("failed\n");
//testing echo void
printf("invoking echoVoid...\n");
ws.echoVoid();
printf("successful\n");
//testing echo base 64 binary
const char* bstr = "some string that is sent encoded to either base64Binary or hexBinary";
printf("invoking echoBase64...\n");
xsd__base64Binary bb;
bb.__ptr = (unsigned char*)strdup(bstr);
bb.__size = strlen(bstr);
if (bb.__size == ws.echoBase64(bb).__size)
{
printf("successful\n");
printf("Returned String :\n%s\n", bb.__ptr);
}
else
printf("failed\n");
time_t tim;
time(&tim);
tm* lt = gmtime(&tim);
printf("invoking echoDate...\n");
if (memcmp(&ws.echoDate(*lt), lt, sizeof(tm)) == 0)
printf("successful\n");
else
printf("failed\n");
//testing echo hex binary
printf("invoking echoHexBinary...\n");
xsd__hexBinary hb;
hb.__ptr = (unsigned char*)strdup(bstr);
hb.__size = strlen(bstr);
if (hb.__size == ws.echoHexBinary(hb).__size)
{
printf("successful\n");
printf("Returned String :\n%s\n", hb.__ptr);
}
else
printf("failed\n");
//testing echo decimal
printf("invoking echoDecimal...\n");
if (ws.echoDecimal(1234.567890) > 1234.56)
printf("successful\n");
else
printf("failed\n");
//testing echo boolean
printf("invoking echoBoolean...\n");
if (ws.echoBoolean(true_) == true_)
printf("successful\n");
else
printf("failed\n");
}
catch(AxisException& e)
{
printf("%s\n", e.what());
}
catch(exception& e)
{
printf("%s\n", e.what());
}
catch(...)
{
printf("Unknown exception has occured\n");
}
//getchar();
return 0;
}
1.1 ws-axis/c/tests/auto_build/testcases/client/cpp/MathOpsDocClient.cpp
Index: MathOpsDocClient.cpp
===================================================================
#include "MathOps.h"
#include <axis/server/AxisException.h>
#include <ctype.h>
void PrintUsage();
bool IsNumber(const char* p);
int main(int argc, char* argv[])
{
char endpoint[256];
const char* server="localhost";
const char* port="80";
const char* op = 0;
const char* p1 = 0;
const char* p2 = 0;
int i1=0, i2=0;
int iResult;
char* pcDetail;
try
{
sprintf(endpoint, "http://%s:%s/axis/MathOps", server, port);
MathOps ws(endpoint);
op = "div";/*Operation name*/
i1 = 10;/*First parameter*/
i2 = 5;/*Second parameter*/
if (strcmp(op, "div") == 0)
{
iResult = ws.div(i1, i2);
printf("Result is:%d\n", iResult);
}
else
{
printf("Invalid operation %s\n\n", op);
PrintUsage();
}
}
catch(AxisException& e)
{
printf("%s\n", e.what());
}
catch(exception& e)
{
printf("Unknown exception has occured\n");
}
catch(...)
{
printf("Unknown exception has occured\n");
}
return 0;
}
void PrintUsage()
{
printf("Usage :\n MathOps <server> <port> <operation> <parameter> <parameter>\n\n");
exit(1);
}
bool IsNumber(const char* p)
{
for (int x=0; x < strlen(p); x++)
{
if (!isdigit(p[x])) return false;
}
return true;
}
1.1 ws-axis/c/tests/auto_build/testcases/client/cpp/SimpleArrayDocClient.cpp
Index: SimpleArrayDocClient.cpp
===================================================================
// ArrayClient.cpp : Defines the entry point for the console application.i
//
#include <string>
using namespace std;
#include "ArrayTestPortType.h"
#include <axis/AxisGenException.h>
#define ARRAYSIZE 2
int main(int argc, char* argv[])
{
int x;
char buffer1[100];
char endpoint[256];
const char* url="http://localhost:80/axis/MathOps";
const char* server="localhost";
const char* port="80";
url = argv[1];
try
{
printf("Sending Requests to Server %s ........\n\n", url);
sprintf(endpoint, "%s", url);
ArrayTestPortType ws(endpoint);
//testing echoIntArray
IntArrayType arrin;
arrin.intItem.m_Array = new int[ARRAYSIZE];
arrin.intItem.m_Size = ARRAYSIZE;
for (x=0;x<ARRAYSIZE;x++)
{
arrin.intItem.m_Array[x] = x;
}
printf("invoking echoIntArray...\n");
if (ws.echoIntArray(&arrin)->intItem.m_Array != NULL)
printf("successful \n");
else
printf("failed \n");
}
catch(AxisException& e)
{
printf("Exception : %s\n", e.what());
}
catch(exception& e)
{
printf("Unknown exception has occured\n");
}
catch(...)
{
printf("Unknown exception has occured\n");
}
return 0;
}
1.1 ws-axis/c/tests/auto_build/testcases/client/cpp/SimpleRefDocClient.cpp
Index: SimpleRefDocClient.cpp
===================================================================
// InteropBaseClient.cpp : Defines the entry point for the console application.
//
#include <string>
using namespace std;
#include "RefTestPortType.h"
#include <axis/AxisGenException.h>
#define ARRAYSIZE 2
int main(int argc, char* argv[])
{
int x;
char buffer1[100];
char endpoint[256];
const char* url="http://localhost:80/axis/MathOps";
const char* server="localhost";
const char* port="80";
url = argv[1];
try
{
printf("Sending Requests to Server %s ........\n\n", url);
sprintf(endpoint, "%s", url);
//endpoint for Axis Java sample
//sprintf(endpoint, "http://%s:%s/axis/services/echo", server, port);
RefTestPortType ws(endpoint);
printf("invoking echoInt..\n");
IntType refint;
refint.intItem =56;
if ((ws.echoInt(&refint))->intItem == 56)
printf("successful\n");
else
printf("failed \n");
}
catch(AxisException& e)
{
printf("Exception : %s\n", e.what());
}
catch(exception& e)
{
printf("Unknown exception has occured\n");
}
catch(...)
{
printf("Unknown exception has occured\n");
}
return 0;
}