Changed testing code to be a component with a JS driver rather than an executable. Added first pass of proxy test. [not part of build]

This commit is contained in:
vidur%netscape.com 2002-01-09 01:27:44 +00:00
Родитель f52421a312
Коммит 7c0adc3167
13 изменённых файлов: 969 добавлений и 331 удалений

Просмотреть файл

@ -26,8 +26,10 @@ VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = wsproxytests
XPIDL_MODULE = wsproxytests
MODULE = wsproxytest
LIBRARY_NAME = wsproxytest
IS_COMPONENT = 1
MODULE_NAME = WSPProxyTestModule
REQUIRES = xpcom \
string \
@ -36,6 +38,7 @@ REQUIRES = xpcom \
caps \
js \
necko \
dom \
$(NULL)
XPIDLSRCS = .\nsIWSPProxyTest.idl \
@ -43,19 +46,18 @@ XPIDLSRCS = .\nsIWSPProxyTest.idl \
CPPSRCS = \
wspproxytest.cpp \
wspproxytestmodule.cpp \
$(NULL)
SIMPLE_PROGRAMS = $(CPPSRCS:.cpp=$(BIN_SUFFIX))
LOCAL_INCLUDES = \
-I$(srcdir)/../ \
$(NULL)
#include $(topsrcdir)/config/config.mk
LIBS = \
$(DIST)/lib/libxmlextrasproxy_s.$(LIB_SUFFIX) \
EXTRA_DSO_LDOPTS = \
$(LIBS_DIR) \
$(MOZ_COMPONENT_LIBS) \
$(ZLIB_LIBS) \
$(MOZ_JS_LIBS) \
$(XPCOM_LIBS) \
$(NSPR_LIBS) \
$(NULL)
include $(topsrcdir)/config/rules.mk
DEFINES += -DUSE_NSREG

Просмотреть файл

@ -41,10 +41,16 @@
#include "nsISupports.idl"
#include "nsIWebServiceProxy.idl"
[scriptable, uuid(f8127804-529d-4f9f-90cc-e7447491ed42)]
interface nsIWSPProxyTestListener : nsISupports {
void onIsPrimeProxyTestComplete(in AString result);
};
[scriptable, uuid(fd25b392-f435-4aea-bbbc-0886f8239dce)]
interface nsIWSPProxyTest : nsISupports {
void testComplexTypeWrapper();
void testPropertyBagWrapper();
AString testComplexTypeWrapper();
AString testPropertyBagWrapper();
void testIsPrimeProxy(in nsIWSPProxyTestListener aListener);
};
[uuid(6de70ec8-46fb-49d5-8dac-9d2eae42ea5a)]
@ -77,3 +83,33 @@ interface nsIWSPTestComplexType : nsISupports {
0xcdb03ec6, 0x4a5e, 0x4461, \
{0x99, 0x6e, 0x16, 0xf5, 0x17, 0xe5, 0x3b, 0x87} }
%}
[scriptable, uuid(5d557963-b082-4f93-b96d-8e4d6b7cd5cd)]
interface statisticStruct : nsISupports {
readonly attribute double average;
readonly attribute double standardDeviation;
};
[scriptable, uuid(4814fb14-d081-4cb9-995d-fd6472913c6c)]
interface SpheonJSAOPStatisticsPortType : nsISupports {
statisticStruct getStatistics(in PRUint32 valsLength, [array, size_is(valsLength)] in double vals);
boolean isPrimeNumber(in PRInt32 prime);
PRInt32 crossSum(in PRInt32 sum);
};
[scriptable, uuid(7b7b9508-8a0a-4b41-bf35-167804376c40)]
interface SpheonJSAOPStatisticsPortTypeListener : nsISupports {
void getStatisticsCallback(in nsIException error, in statisticStruct retval);
void isPrimeNumberCallback(in nsIException error, in boolean retval);
void crossSumCallback(in nsIException error, in PRInt32 retval);
};
[scriptable, uuid(bbae3748-d7eb-453c-8b48-7b760f7075f6)]
interface SpheonJSAOPStatisticsPortTypeAsync : nsISupports {
void setListener(in SpheonJSAOPStatisticsPortTypeListener listener);
nsIWebServiceCallContext getStatistics(in PRUint32 valsLength,
[array, size_is(valsLength)] in double vals);
nsIWebServiceCallContext isPrimeNumber(in PRInt32 prime);
nsIWebServiceCallContext crossSum(in PRInt32 sum);
};

Просмотреть файл

@ -79,10 +79,13 @@ WSPProxyTest::~WSPProxyTest()
{
}
NS_IMPL_ISUPPORTS1(WSPProxyTest, nsIWSPProxyTest)
NS_IMPL_ISUPPORTS3_CI(WSPProxyTest,
nsIWSPProxyTest,
nsIWSDLLoadListener,
SpheonJSAOPStatisticsPortTypeListener)
nsresult
WSPProxyTest::CreateComplexTypeWrapper(WSPComplexTypeWrapper** aWrapper,
WSPProxyTest::CreateComplexTypeWrapper(nsIWebServiceComplexTypeWrapper** aWrapper,
nsIInterfaceInfo** aInfo)
{
static nsIID sComplexTypeIID = NS_GET_IID(nsIWSPTestComplexType);
@ -105,40 +108,52 @@ WSPProxyTest::CreateComplexTypeWrapper(WSPComplexTypeWrapper** aWrapper,
*aInfo = iinfo;
NS_ADDREF(*aInfo);
return WSPComplexTypeWrapper::Create(ct, iinfo, aWrapper);
nsCOMPtr<nsIWebServiceComplexTypeWrapper> wrapper = do_CreateInstance(NS_WEBSERVICECOMPLEXTYPEWRAPPER_CONTRACTID, &rv);
if (NS_FAILED(rv)) {
return rv;
}
rv = wrapper->Init(ct, iinfo);
if (NS_FAILED(rv)) {
return rv;
}
*aWrapper = wrapper;
NS_ADDREF(*aWrapper);
return NS_OK;
}
NS_IMETHODIMP
WSPProxyTest::TestComplexTypeWrapper()
WSPProxyTest::TestComplexTypeWrapper(nsAWritableString& aResult)
{
nsCOMPtr<nsIInterfaceInfo> info;
nsCOMPtr<WSPComplexTypeWrapper> wrapper;
nsCOMPtr<nsIWebServiceComplexTypeWrapper> wrapper;
nsresult rv = CreateComplexTypeWrapper(getter_AddRefs(wrapper),
getter_AddRefs(info));
if (NS_FAILED(rv)) {
return rv;
aResult.Assign(NS_LITERAL_STRING("WSPProxyTest: Failed creating complex type wrapper"));
return NS_OK;
}
nsCOMPtr<nsIPropertyBag> propBag = do_QueryInterface(wrapper);
if (!propBag) {
aResult.Assign(NS_LITERAL_STRING("WSPProxyTest: Wrapper is not property bag"));
return NS_ERROR_FAILURE;
}
rv = TestComplexTypeWrapperInstance(propBag);
if (NS_FAILED(rv)) {
return rv;
}
TestComplexTypeWrapperInstance(propBag, aResult);
return NS_OK;
}
nsresult
WSPProxyTest::TestComplexTypeWrapperInstance(nsIPropertyBag* propBag)
WSPProxyTest::TestComplexTypeWrapperInstance(nsIPropertyBag* propBag,
nsAWritableString& aResult)
{
nsCOMPtr<nsISimpleEnumerator> enumerator;
nsresult rv = propBag->GetEnumerator(getter_AddRefs(enumerator));
if (NS_FAILED(rv)) {
aResult.Assign(NS_LITERAL_STRING("WSPProxyTest: Failed getting property bag enumerator"));
return rv;
}
@ -150,7 +165,7 @@ WSPProxyTest::TestComplexTypeWrapperInstance(nsIPropertyBag* propBag)
#define GET_AND_TEST_NAME(_name) \
rv = enumerator->GetNext(getter_AddRefs(sup)); \
if (NS_FAILED(rv)) { \
printf("WSPProxyTest: Failed getting property " #_name "\n"); \
aResult.Assign(NS_LITERAL_STRING("WSPProxyTest: Failed getting property ") + NS_LITERAL_STRING(#_name)); \
return rv; \
} \
\
@ -161,7 +176,7 @@ WSPProxyTest::TestComplexTypeWrapperInstance(nsIPropertyBag* propBag)
\
prop->GetName(propName); \
if (!propName.Equals(NS_LITERAL_STRING(#_name))) { \
printf("WSPProxyTest: Name doesn't match for property " #_name "\n");\
aResult.Assign(NS_LITERAL_STRING("WSPProxyTest: Name doesn't match for property ") + NS_LITERAL_STRING(#_name)); \
return NS_ERROR_FAILURE; \
} \
prop->GetValue(getter_AddRefs(val)); \
@ -174,11 +189,11 @@ WSPProxyTest::TestComplexTypeWrapperInstance(nsIPropertyBag* propBag)
_t _name; \
rv = val->GetAs##_n(&_name); \
if (NS_FAILED(rv)) { \
printf("WSPProxyTest: Failed getting value for property " #_name "\n");\
aResult.Assign(NS_LITERAL_STRING("WSPProxyTest: Failed getting value for property ") + NS_LITERAL_STRING(#_name)); \
return rv; \
} \
if (_name != _val) { \
printf("WSPProxyTest: Value doesn't match for property " #_name "\n");\
aResult.Assign(NS_LITERAL_STRING("WSPProxyTest: Value doesn't match for property ") + NS_LITERAL_STRING(#_name)); \
return NS_ERROR_FAILURE; \
}
@ -200,12 +215,12 @@ WSPProxyTest::TestComplexTypeWrapperInstance(nsIPropertyBag* propBag)
nsAutoString str;
rv = val->GetAsAString(str);
if (NS_FAILED(rv)) {
printf("WSPProxyTest: Failed getting value for property s\n");
aResult.Assign(NS_LITERAL_STRING("WSPProxyTest: Failed getting value for property s"));
return rv;
}
if (!str.Equals(NS_LITERAL_STRING(STRING_VAL))) {
printf("WSPProxyTest: Value doesn't match for property s\n");
aResult.Assign(NS_LITERAL_STRING("WSPProxyTest: Value doesn't match for property s"));
return NS_ERROR_FAILURE;
}
@ -213,12 +228,12 @@ WSPProxyTest::TestComplexTypeWrapperInstance(nsIPropertyBag* propBag)
nsCOMPtr<nsISupports> supVal;
rv = val->GetAsISupports(getter_AddRefs(supVal));
if (NS_FAILED(rv)) {
printf("WSPProxyTest: Failed getting value for property p\n");
aResult.Assign(NS_LITERAL_STRING("WSPProxyTest: Failed getting value for property p"));
return rv;
}
nsCOMPtr<nsIPropertyBag> propBagVal = do_QueryInterface(supVal, &rv);
if (NS_FAILED(rv)) {
printf("WSPProxyTest: Value doesn't match for property p\n");
aResult.Assign(NS_LITERAL_STRING("WSPProxyTest: Value doesn't match for property p"));
return rv;
}
@ -226,129 +241,115 @@ WSPProxyTest::TestComplexTypeWrapperInstance(nsIPropertyBag* propBag)
PRUint16 dataType;
val->GetDataType(&dataType);
if (dataType != nsIDataType::VTYPE_EMPTY) {
printf("WSPProxyTest: Value doesn't match for property p\n");
aResult.Assign(NS_LITERAL_STRING("WSPProxyTest: Value doesn't match for property p"));
return NS_ERROR_FAILURE;
}
PRUint16 type;
PRUint32 index, count;
nsIVariant** arrayVal;
PRUint32* arrayVal1;
GET_AND_TEST_NAME(array1)
nsIID iid;
rv = val->GetAsArray(&type, &iid, &count, (void**)&arrayVal);
rv = val->GetAsArray(&type, &iid, &count, (void**)&arrayVal1);
if (NS_FAILED(rv)) {
printf("WSPProxyTest: Failed getting value for property array1\n");
aResult.Assign(NS_LITERAL_STRING("WSPProxyTest: Failed getting value for property array1"));
return rv;
}
for (index = 0; index < count; index++) {
nsIVariant* arrayVar = arrayVal[index];
PRUint32 arrayInt;
rv = arrayVar->GetAsUint32(&arrayInt);
if (NS_FAILED(rv)) {
printf("WSPProxyTest: Failed getting value for element of property array1\n");
return rv;
}
if (arrayInt != sArray1[index]) {
printf("WSPProxyTest: Value doesn't match for element of property array1\n");
if (arrayVal1[index] != sArray1[index]) {
aResult.Assign(NS_LITERAL_STRING("WSPProxyTest: Value doesn't match for element of property array1"));
return rv;
}
}
NS_FREE_XPCOM_ISUPPORTS_POINTER_ARRAY(count, arrayVal);
nsMemory::Free(arrayVal1);
double* arrayVal2;
GET_AND_TEST_NAME(array2)
rv = val->GetAsArray(&type, &iid, &count, (void**)&arrayVal);
rv = val->GetAsArray(&type, &iid, &count, (void**)&arrayVal2);
if (NS_FAILED(rv)) {
printf("WSPProxyTest: Failed getting value for property array2\n");
aResult.Assign(NS_LITERAL_STRING("WSPProxyTest: Failed getting value for property array2"));
return rv;
}
for (index = 0; index < count; index++) {
nsIVariant* arrayVar = arrayVal[index];
double arrayDouble;
rv = arrayVar->GetAsDouble(&arrayDouble);
if (NS_FAILED(rv)) {
printf("WSPProxyTest: Failed getting value for element of property array1\n");
return rv;
}
if (arrayDouble != sArray2[index]) {
printf("WSPProxyTest: Value doesn't match for element of property array1\n");
if (arrayVal2[index] != sArray2[index]) {
aResult.Assign(NS_LITERAL_STRING("WSPProxyTest: Value doesn't match for element of property array2"));
return rv;
}
}
NS_FREE_XPCOM_ISUPPORTS_POINTER_ARRAY(count, arrayVal);
nsMemory::Free(arrayVal2);
nsISupports** arrayVal3;
GET_AND_TEST_NAME(array3)
rv = val->GetAsArray(&type, &iid, &count, (void**)&arrayVal);
rv = val->GetAsArray(&type, &iid, &count, (void**)&arrayVal3);
if (NS_FAILED(rv)) {
printf("WSPProxyTest: Failed getting value for property array2\n");
aResult.Assign(NS_LITERAL_STRING("WSPProxyTest: Failed getting value for property array3"));
return rv;
}
nsIVariant* array3Var = arrayVal[0];
rv = array3Var->GetAsISupports(getter_AddRefs(supVal));
propBagVal = do_QueryInterface(arrayVal3[0], &rv);
if (NS_FAILED(rv)) {
printf("WSPProxyTest: Failed getting value for element of property array3\n");
aResult.Assign(NS_LITERAL_STRING("WSPProxyTest: Value doesn't match for element of property array3"));
return rv;
}
propBagVal = do_QueryInterface(supVal, &rv);
if (NS_FAILED(rv)) {
printf("WSPProxyTest: Value doesn't match for element of property array3\n");
return rv;
}
array3Var = arrayVal[1];
array3Var->GetDataType(&dataType);
if (dataType != nsIDataType::VTYPE_EMPTY) {
printf("WSPProxyTest: Value doesn't match for element of property array3\n");
if (arrayVal3[1] != nsnull) {
aResult.Assign(NS_LITERAL_STRING("WSPProxyTest: Value doesn't match for element of property array3"));
return NS_ERROR_FAILURE;
}
NS_FREE_XPCOM_ISUPPORTS_POINTER_ARRAY(count, arrayVal);
NS_FREE_XPCOM_ISUPPORTS_POINTER_ARRAY(count, arrayVal3);
#undef GET_AND_TEST
#undef GET_AND_TEST_NAME
aResult.Assign(NS_LITERAL_STRING("WSPProxyTest: Test Succeeded!"));
return NS_OK;
}
NS_IMETHODIMP
WSPProxyTest::TestPropertyBagWrapper()
WSPProxyTest::TestPropertyBagWrapper(nsAWritableString& aResult)
{
nsCOMPtr<nsIInterfaceInfo> info;
nsCOMPtr<WSPComplexTypeWrapper> ctwrapper;
nsCOMPtr<nsIWebServiceComplexTypeWrapper> ctwrapper;
nsresult rv = CreateComplexTypeWrapper(getter_AddRefs(ctwrapper),
getter_AddRefs(info));
if (NS_FAILED(rv)) {
return rv;
aResult.Assign(NS_LITERAL_STRING("WSPProxyTest: Failed creating complex type wrapper"));
return NS_OK;
}
nsCOMPtr<nsIPropertyBag> propBag = do_QueryInterface(ctwrapper);
if (!propBag) {
return NS_ERROR_FAILURE;
aResult.Assign(NS_LITERAL_STRING("WSPProxyTest: Wrapper is not property bag"));
return NS_OK;
}
WSPPropertyBagWrapper* wrapper;
rv = WSPPropertyBagWrapper::Create(propBag, info, &wrapper);
nsCOMPtr<nsIWebServicePropertyBagWrapper> wrapper = do_CreateInstance(NS_WEBSERVICEPROPERTYBAGWRAPPER_CONTRACTID, &rv);
if (NS_FAILED(rv)) {
return rv;
aResult.Assign(NS_LITERAL_STRING("WSPProxyTest: Failed creating property bag wrapper"));
return NS_OK;
}
rv = wrapper->Init(propBag, info);
if (NS_FAILED(rv)) {
aResult.Assign(NS_LITERAL_STRING("WSPProxyTest: Failed initializing property bag wrapper"));
return NS_OK;
}
nsCOMPtr<nsIWSPTestComplexType> ct = do_QueryInterface(wrapper, &rv);
NS_RELEASE(wrapper);
if (NS_FAILED(rv)) {
return rv;
aResult.Assign(NS_LITERAL_STRING("WSPProxyTest: Property bag wrapper doesn't QI correctly"));
return NS_OK;
}
#define GET_AND_TEST(_t, _name, _val) \
_t _name; \
rv = ct->Get##_name(&_name); \
if (NS_FAILED(rv)) { \
printf("WSPProxyTest: Failed to get value for attribute" #_name "\n"); \
return rv; \
aResult.Assign(NS_LITERAL_STRING("WSPProxyTest: Failed to get value for attribute") + NS_LITERAL_STRING(#_name)); \
return NS_OK; \
} \
if (_name != _val) { \
printf("WSPProxyTest: Value doesn't match for attribute " #_name "\n"); \
return NS_ERROR_FAILURE; \
aResult.Assign(NS_LITERAL_STRING("WSPProxyTest: Value doesn't match for attribute ") + NS_LITERAL_STRING(#_name)); \
return NS_OK; \
}
GET_AND_TEST(PRUint8, I8, sInt8Val)
@ -368,29 +369,29 @@ WSPProxyTest::TestPropertyBagWrapper()
nsAutoString str;
rv = ct->GetS(str);
if (NS_FAILED(rv)) {
printf("WSPProxyTest: Failed to get value for attribute s\n");
return rv;
aResult.Assign(NS_LITERAL_STRING("WSPProxyTest: Failed to get value for attribute s"));
return NS_OK;
}
if (!str.Equals(NS_LITERAL_STRING(STRING_VAL))) {
printf("WSPProxyTest: Value doesn't match for attribute s\n");
return NS_ERROR_FAILURE;
aResult.Assign(NS_LITERAL_STRING("WSPProxyTest: Value doesn't match for attribute s"));
return NS_OK;
}
nsCOMPtr<nsIWSPTestComplexType> p;
rv = ct->GetP(getter_AddRefs(p));
if (NS_FAILED(rv)) {
printf("WSPProxyTest: Failed to get value for attribute p\n");
return rv;
aResult.Assign(NS_LITERAL_STRING("WSPProxyTest: Failed to get value for attribute p"));
return NS_OK;
}
rv = ct->GetP2(getter_AddRefs(p));
if (NS_FAILED(rv)) {
printf("WSPProxyTest: Failed to get value for attribute p2\n");
return rv;
aResult.Assign(NS_LITERAL_STRING("WSPProxyTest: Failed to get value for attribute p2"));
return NS_OK;
}
if (p) {
printf("WSPProxyTest: Value doesn't match for attribute p2\n");
return NS_ERROR_FAILURE;
aResult.Assign(NS_LITERAL_STRING("WSPProxyTest: Value doesn't match for attribute p2"));
return NS_OK;
}
PRUint32 index, count;
@ -398,13 +399,13 @@ WSPProxyTest::TestPropertyBagWrapper()
PRUint32* array1;
rv = ct->Array1(&count, &array1);
if (NS_FAILED(rv)) {
printf("WSPProxyTest: Failed to get value for attribute array1\n");
return rv;
aResult.Assign(NS_LITERAL_STRING("WSPProxyTest: Failed to get value for attribute array1"));
return NS_OK;
}
for (index = 0; index < count; index++) {
if (array1[index] != sArray1[index]) {
printf("WSPProxyTest: Value doesn't match for element of attribute array1\n");
return NS_ERROR_FAILURE;
aResult.Assign(NS_LITERAL_STRING("WSPProxyTest: Value doesn't match for element of attribute array1"));
return NS_OK;
}
}
nsMemory::Free(array1);
@ -412,13 +413,13 @@ WSPProxyTest::TestPropertyBagWrapper()
double* array2;
rv = ct->Array2(&count, &array2);
if (NS_FAILED(rv)) {
printf("WSPProxyTest: Failed to get value for attribute array2\n");
return rv;
aResult.Assign(NS_LITERAL_STRING("WSPProxyTest: Failed to get value for attribute array2"));
return NS_OK;
}
for (index = 0; index < count; index++) {
if (array2[index] != sArray2[index]) {
printf("WSPProxyTest: Value doesn't match for element of attribute array2\n");
return NS_ERROR_FAILURE;
aResult.Assign(NS_LITERAL_STRING("WSPProxyTest: Value doesn't match for element of attribute array2"));
return NS_OK;
}
}
nsMemory::Free(array2);
@ -426,20 +427,164 @@ WSPProxyTest::TestPropertyBagWrapper()
nsIWSPTestComplexType** array3;
rv = ct->Array3(&count, &array3);
if (NS_FAILED(rv)) {
printf("WSPProxyTest: Failed to get value for attribute array3\n");
return rv;
aResult.Assign(NS_LITERAL_STRING("WSPProxyTest: Failed to get value for attribute array3"));
return NS_OK;
}
if (!array3[0] || array3[1]) {
printf("WSPProxyTest: Value doesn't match for element of attribute array3\n");
return NS_ERROR_FAILURE;
aResult.Assign(NS_LITERAL_STRING("WSPProxyTest: Value doesn't match for element of attribute array3"));
return NS_OK;
}
NS_FREE_XPCOM_ISUPPORTS_POINTER_ARRAY(count, array3);
#undef GET_AND_TEST
aResult.Assign(NS_LITERAL_STRING("WSPProxyTest: Test Succeeded!"));
return NS_OK;
}
/* void testIsPrimeProxy(nsIWSPProxyTestListener* aListener); */
NS_IMETHODIMP
WSPProxyTest::TestIsPrimeProxy(nsIWSPProxyTestListener* aListener)
{
mListener = aListener;
nsCOMPtr<nsIWSDLLoader> loader = do_CreateInstance(NS_WSDLLOADER_CONTRACTID);
if (!loader) {
mListener->OnIsPrimeProxyTestComplete(NS_LITERAL_STRING("Couldn't create WSDL loader"));
return NS_OK;
}
#define ISPRIMEURL "http://green.nscp.aoltw.net/vidur/wsdl/statistics.wsdl"
#define ISPRIMEPORT "SpheonJSAOPStatisticsPort"
nsresult rv = loader->LoadAsync(NS_LITERAL_STRING(ISPRIMEURL),
NS_LITERAL_STRING(ISPRIMEPORT),
this);
if (NS_FAILED(rv)) {
mListener->OnIsPrimeProxyTestComplete(NS_LITERAL_STRING("Failed loading WSDL file"));
}
return NS_OK;
}
/* void onLoad (in nsIWSDLPort port); */
NS_IMETHODIMP
WSPProxyTest::OnLoad(nsIWSDLPort *port)
{
nsresult rv;
nsCOMPtr<nsIInterfaceInfoManager> manager = do_GetService(NS_INTERFACEINFOMANAGER_SERVICE_CONTRACTID, &rv);
if (NS_FAILED(rv)) {
mListener->OnIsPrimeProxyTestComplete(NS_LITERAL_STRING("Couldn't create interface info manager"));
return NS_OK;
}
static nsIID sPortIID = NS_GET_IID(SpheonJSAOPStatisticsPortTypeAsync);
nsCOMPtr<nsIInterfaceInfo> iinfo;
rv = manager->GetInfoForIID(&sPortIID, getter_AddRefs(iinfo));
if (NS_FAILED(rv)) {
mListener->OnIsPrimeProxyTestComplete(NS_LITERAL_STRING("Couldn't find interface info for port"));
return NS_OK;
}
nsCOMPtr<nsIWebServiceProxy> proxy(do_CreateInstance(NS_WEBSERVICEPROXY_CONTRACTID));
if (!proxy) {
mListener->OnIsPrimeProxyTestComplete(NS_LITERAL_STRING("Couldn't create proxy"));
return NS_OK;
}
proxy->Init(port, iinfo, NS_LITERAL_STRING("foo"), PR_TRUE);
mProxy = do_QueryInterface(proxy);
if (!mProxy) {
mListener->OnIsPrimeProxyTestComplete(NS_LITERAL_STRING("Couldn't QI proxy to isPrime interface"));
return NS_OK;
}
mProxy->SetListener(this);
nsCOMPtr<nsIWebServiceCallContext> context;
rv = mProxy->IsPrimeNumber(5, getter_AddRefs(context));
if (NS_FAILED(rv)) {
mListener->OnIsPrimeProxyTestComplete(NS_LITERAL_STRING("Failed call to IsPrimeNumber"));
return NS_OK;
}
return NS_OK;
}
/* void onError (in nsresult status, in AString statusMessage); */
NS_IMETHODIMP
WSPProxyTest::OnError(nsresult status, const nsAString & statusMessage)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* void getStatisticsCallback (in nsIException error, in statisticStruct retval); */
NS_IMETHODIMP
WSPProxyTest::GetStatisticsCallback(nsIException *error, statisticStruct *retval)
{
if (error) {
nsXPIDLCString str;
error->ToString(getter_Copies(str));
mListener->OnIsPrimeProxyTestComplete(NS_ConvertASCIItoUCS2(str.get()));
}
else if (!retval) {
mListener->OnIsPrimeProxyTestComplete(NS_LITERAL_STRING("Incorrect value returned from IsPrimeNumber"));
}
else {
double average;
retval->GetAverage(&average);
if (average != 2.725) {
mListener->OnIsPrimeProxyTestComplete(NS_LITERAL_STRING("Incorrect value returned from IsPrimeNumber"));
}
else {
mListener->OnIsPrimeProxyTestComplete(NS_LITERAL_STRING("Test Succeeded!"));
}
}
return NS_OK;
}
/* void isPrimeNumberCallback (in nsIException error, in boolean retval); */
NS_IMETHODIMP
WSPProxyTest::IsPrimeNumberCallback(nsIException *error, PRBool retval)
{
if (error) {
nsXPIDLCString str;
error->ToString(getter_Copies(str));
mListener->OnIsPrimeProxyTestComplete(NS_ConvertASCIItoUCS2(str.get()));
}
else if (!retval) {
mListener->OnIsPrimeProxyTestComplete(NS_LITERAL_STRING("Incorrect value returned from IsPrimeNumber"));
}
else {
// Success!!
mListener->OnIsPrimeProxyTestComplete(NS_LITERAL_STRING("Test Succeeded!"));
#if 0
static double vals[4] = { 1.7, 3.4, 5.6, 0.2 };
nsCOMPtr<nsIWebServiceCallContext> context;
nsresult rv = mProxy->GetStatistics(sizeof(vals)/sizeof(double), vals,
getter_AddRefs(context));
if (NS_FAILED(rv)) {
mListener->OnIsPrimeProxyTestComplete(NS_LITERAL_STRING("Failed call to GetStatistics"));
}
#endif
}
return NS_OK;
}
/* void crossSumCallback (in nsIException error, in PRInt32 retval); */
NS_IMETHODIMP
WSPProxyTest::CrossSumCallback(nsIException *error, PRInt32 retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
///////////////////////////////////////////////////
//
// Implementation of WSPTestComplexType
//
///////////////////////////////////////////////////
WSPTestComplexType::WSPTestComplexType()
{
NS_INIT_ISUPPORTS();
@ -644,44 +789,3 @@ WSPTestComplexType::Array3(PRUint32 *length, nsIWSPTestComplexType ***array3)
return NS_OK;
}
int main (int argc, char* argv[])
{
nsIServiceManager *servMgr;
nsresult rv = NS_InitXPCOM2(&servMgr, nsnull, nsnull);
if (NS_FAILED(rv)) {
printf("failed to initialize XPCOM");
return rv;
}
nsCOMPtr<WSPProxyTest> test = new WSPProxyTest();
if (!test) {
printf("Error creating proxy test instance\n");
return NS_ERROR_OUT_OF_MEMORY;
}
printf("--- Testing complex type wrapper --- \n");
rv = test->TestComplexTypeWrapper();
if (NS_FAILED(rv)) {
printf("--- Test FAILED --- \n");
}
else {
printf("--- Test SUCCEEDED --- \n");
}
printf("--- Testing property bag wrapper --- \n");
rv = test->TestPropertyBagWrapper();
if (NS_FAILED(rv)) {
printf("--- Test FAILED --- \n");
}
else {
printf("--- Test SUCCEEDED --- \n");
}
if (servMgr)
rv = NS_ShutdownXPCOM(servMgr);
return rv;
}

Просмотреть файл

@ -43,20 +43,28 @@
#include "nsIWSPProxyTest.h"
#include "nsIPropertyBag.h"
#include "wspprivate.h"
#include "nsIWSDLLoader.h"
class WSPProxyTest : public nsIWSPProxyTest {
class WSPProxyTest : public nsIWSPProxyTest,
public nsIWSDLLoadListener,
public SpheonJSAOPStatisticsPortTypeListener
{
public:
WSPProxyTest();
virtual ~WSPProxyTest();
NS_DECL_ISUPPORTS
NS_DECL_NSIWSPPROXYTEST
NS_DECL_NSIWSDLLOADLISTENER
NS_DECL_SPHEONJSAOPSTATISTICSPORTTYPELISTENER
protected:
nsresult CreateComplexTypeWrapper(WSPComplexTypeWrapper** aWrapper,
nsresult CreateComplexTypeWrapper(nsIWebServiceComplexTypeWrapper** aWrapper,
nsIInterfaceInfo** aInfo);
nsresult TestComplexTypeWrapperInstance(nsIPropertyBag* propBag);
nsresult TestComplexTypeWrapperInstance(nsIPropertyBag* propBag,
nsAWritableString& aResult);
nsCOMPtr<nsIWSPProxyTestListener> mListener;
nsCOMPtr<SpheonJSAOPStatisticsPortTypeAsync> mProxy;
};
class WSPTestComplexType : public nsIWSPTestComplexType {

Просмотреть файл

@ -0,0 +1,89 @@
<?xml version="1.0"?>
<!--
- The contents of this file are subject to the Mozilla Public
- License Version 1.1 (the "License"); you may not use this file
- except in compliance with the License. You may obtain a copy of
- the License at http://www.mozilla.org/MPL/
-
- Software distributed under the License is distributed on an "AS
- IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
- implied. See the License for the specific language governing
- rights and limitations under the License.
-
- The Original Code is Mozilla Test Cases.
-
- The Initial Developer of the Original Code is Netscape Communications
- Corp. Portions created by Netscape Communications Corp. are
- Copyright (C) 2001 Netscape Communications Corp. All
- Rights Reserved.
-
- Contributor(s):
-->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Web Service Proxy Tests</title>
<style type="text/css">
.box {
display: box;
border: 1px solid black;
margin-bottom: 0.5em;
}
.boxheader {
font-weight: bold;
color: maroon;
}
pre {
margin-left: 2em;
}
</style>
<script type="text/javascript">
function WSPTest() {
this.wsptest = new WebServiceProxyTest();
}
WSPTest.prototype.onIsPrimeProxyTestComplete = function(str) {
document.getElementById("id3").firstChild.nodeValue = str;
}
WSPTest.prototype.startTest = function() {
try {
document.getElementById("id1").firstChild.nodeValue = this.wsptest.testComplexTypeWrapper();
}
catch (e) {
document.getElementById("id1").firstChild.nodeValue = "FAILED!";
}
try {
document.getElementById("id2").firstChild.nodeValue = this.wsptest.testPropertyBagWrapper();
}
catch (e) {
document.getElementById("id2").firstChild.nodeValue = "FAILED!";
}
try {
this.wsptest.testIsPrimeProxy(this);
}
catch (e) {
document.getElementById("id3").firstChild.nodeValue = "FAILED!";
}
}
var test = new WSPTest();
</script>
</head>
<body onload="test.startTest()">
<h1>Web Service Proxy Tests</h1>
<div class="box"><span class="boxheader">Complex Type Wrapper Test</span>
<pre id="id1">@@No result@@</pre>
</div>
<div class="box"><span class="boxheader">Property Bag Wrapper Test</span>
<pre id="id2">@@No result@@</pre>
</div>
<div class="box"><span class="boxheader">IsPrime Proxy Test</span>
<pre id="id3">@@No result@@</pre>
</div>
</body>
</html>

Просмотреть файл

@ -0,0 +1,81 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* John Bandhauer (jband@netscape.com)
* Vidur Apparao (vidur@netscape.com)
*
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "wspproxytest.h"
#include "nsIGenericFactory.h"
#include "nsIServiceManager.h"
#include "nsICategoryManager.h"
#include "nsIScriptNameSpaceManager.h"
NS_GENERIC_FACTORY_CONSTRUCTOR(WSPProxyTest)
NS_DECL_CLASSINFO(WSPProxyTest)
static NS_METHOD
RegisterWSPProxyTest(nsIComponentManager *aCompMgr,
nsIFile *aPath,
const char *registryLocation,
const char *componentType,
const nsModuleComponentInfo *info)
{
nsresult rv = NS_OK;
nsCOMPtr<nsICategoryManager> catman =
do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv);
if (NS_FAILED(rv))
return rv;
nsXPIDLCString previous;
rv = catman->AddCategoryEntry(JAVASCRIPT_GLOBAL_CONSTRUCTOR_CATEGORY,
"WebServiceProxyTest",
NS_WSPPROXYTEST_CONTRACTID,
PR_TRUE, PR_TRUE, getter_Copies(previous));
return rv;
}
static nsModuleComponentInfo components[] = {
{ "WebServiceProxyTest", NS_WSPPROXYTEST_CID, NS_WSPPROXYTEST_CONTRACTID,
WSPProxyTestConstructor, RegisterWSPProxyTest, nsnull, nsnull,
NS_CI_INTERFACE_GETTER_NAME(WSPProxyTest),
nsnull, &NS_CLASSINFO_NAME(WSPProxyTest),
nsIClassInfo::DOM_OBJECT }
};
NS_IMPL_NSGETMODULE(WSPProxyTestModule, components)

Просмотреть файл

@ -26,8 +26,10 @@ VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = wsproxytests
XPIDL_MODULE = wsproxytests
MODULE = wsproxytest
LIBRARY_NAME = wsproxytest
IS_COMPONENT = 1
MODULE_NAME = WSPProxyTestModule
REQUIRES = xpcom \
string \
@ -36,6 +38,7 @@ REQUIRES = xpcom \
caps \
js \
necko \
dom \
$(NULL)
XPIDLSRCS = .\nsIWSPProxyTest.idl \
@ -43,19 +46,18 @@ XPIDLSRCS = .\nsIWSPProxyTest.idl \
CPPSRCS = \
wspproxytest.cpp \
wspproxytestmodule.cpp \
$(NULL)
SIMPLE_PROGRAMS = $(CPPSRCS:.cpp=$(BIN_SUFFIX))
LOCAL_INCLUDES = \
-I$(srcdir)/../ \
$(NULL)
#include $(topsrcdir)/config/config.mk
LIBS = \
$(DIST)/lib/libxmlextrasproxy_s.$(LIB_SUFFIX) \
EXTRA_DSO_LDOPTS = \
$(LIBS_DIR) \
$(MOZ_COMPONENT_LIBS) \
$(ZLIB_LIBS) \
$(MOZ_JS_LIBS) \
$(XPCOM_LIBS) \
$(NSPR_LIBS) \
$(NULL)
include $(topsrcdir)/config/rules.mk
DEFINES += -DUSE_NSREG

Просмотреть файл

@ -22,6 +22,10 @@
DEPTH=..\..\..\..\..
MODULE=wsproxytest
LIBRARY_NAME=wsproxytest
MODULE_NAME=WSPProxyTestModule
DEFINES=-D_IMPL_NS_HTML -DWIN32_LEAN_AND_MEAN
XPIDLSRCS = .\nsIWSPProxyTest.idl \
$(NULL)
@ -33,31 +37,25 @@ REQUIRES = xpcom \
caps \
js \
necko \
dom \
$(NULL)
CPP_OBJS= \
.\$(OBJDIR)\wspproxytest.obj \
.\$(OBJDIR)\wspproxytestmodule.obj \
$(NULL)
EXPORTS = \
$(NULL)
LLIBS= \
$(DIST)\lib\xpcom.lib \
$(DIST)\lib\js3250.lib \
$(LIBNSPR) \
$(NULL)
include <$(DEPTH)/config/config.mak>
MAKE_OBJ_TYPE = EXE
PROG1 = .\$(OBJDIR)\wspproxytest.exe
PROGRAMS = $(PROG1) \
$(NULL)
LCFLAGS = -DUSE_NSREG -GX
LLIBS = \
$(DIST)\lib\xpcom.lib \
$(DIST)\lib\xmlextrasproxy_s.lib \
$(LIBNSPR)
LINCS=-I..\
include <$(DEPTH)\config\rules.mak>
libs:: $(PROGRAMS)
-for %p in ($(PROGRAMS)) do $(MAKE_INSTALL) %p $(DIST)\bin
clobber::
-for %p in ($(PROGRAMS)) do $(RM) %p $(DIST)\bin\%p
$(PROG1): $(OBJDIR) wspproxytest.cpp

Просмотреть файл

@ -41,10 +41,16 @@
#include "nsISupports.idl"
#include "nsIWebServiceProxy.idl"
[scriptable, uuid(f8127804-529d-4f9f-90cc-e7447491ed42)]
interface nsIWSPProxyTestListener : nsISupports {
void onIsPrimeProxyTestComplete(in AString result);
};
[scriptable, uuid(fd25b392-f435-4aea-bbbc-0886f8239dce)]
interface nsIWSPProxyTest : nsISupports {
void testComplexTypeWrapper();
void testPropertyBagWrapper();
AString testComplexTypeWrapper();
AString testPropertyBagWrapper();
void testIsPrimeProxy(in nsIWSPProxyTestListener aListener);
};
[uuid(6de70ec8-46fb-49d5-8dac-9d2eae42ea5a)]
@ -77,3 +83,33 @@ interface nsIWSPTestComplexType : nsISupports {
0xcdb03ec6, 0x4a5e, 0x4461, \
{0x99, 0x6e, 0x16, 0xf5, 0x17, 0xe5, 0x3b, 0x87} }
%}
[scriptable, uuid(5d557963-b082-4f93-b96d-8e4d6b7cd5cd)]
interface statisticStruct : nsISupports {
readonly attribute double average;
readonly attribute double standardDeviation;
};
[scriptable, uuid(4814fb14-d081-4cb9-995d-fd6472913c6c)]
interface SpheonJSAOPStatisticsPortType : nsISupports {
statisticStruct getStatistics(in PRUint32 valsLength, [array, size_is(valsLength)] in double vals);
boolean isPrimeNumber(in PRInt32 prime);
PRInt32 crossSum(in PRInt32 sum);
};
[scriptable, uuid(7b7b9508-8a0a-4b41-bf35-167804376c40)]
interface SpheonJSAOPStatisticsPortTypeListener : nsISupports {
void getStatisticsCallback(in nsIException error, in statisticStruct retval);
void isPrimeNumberCallback(in nsIException error, in boolean retval);
void crossSumCallback(in nsIException error, in PRInt32 retval);
};
[scriptable, uuid(bbae3748-d7eb-453c-8b48-7b760f7075f6)]
interface SpheonJSAOPStatisticsPortTypeAsync : nsISupports {
void setListener(in SpheonJSAOPStatisticsPortTypeListener listener);
nsIWebServiceCallContext getStatistics(in PRUint32 valsLength,
[array, size_is(valsLength)] in double vals);
nsIWebServiceCallContext isPrimeNumber(in PRInt32 prime);
nsIWebServiceCallContext crossSum(in PRInt32 sum);
};

Просмотреть файл

@ -79,10 +79,13 @@ WSPProxyTest::~WSPProxyTest()
{
}
NS_IMPL_ISUPPORTS1(WSPProxyTest, nsIWSPProxyTest)
NS_IMPL_ISUPPORTS3_CI(WSPProxyTest,
nsIWSPProxyTest,
nsIWSDLLoadListener,
SpheonJSAOPStatisticsPortTypeListener)
nsresult
WSPProxyTest::CreateComplexTypeWrapper(WSPComplexTypeWrapper** aWrapper,
WSPProxyTest::CreateComplexTypeWrapper(nsIWebServiceComplexTypeWrapper** aWrapper,
nsIInterfaceInfo** aInfo)
{
static nsIID sComplexTypeIID = NS_GET_IID(nsIWSPTestComplexType);
@ -105,40 +108,52 @@ WSPProxyTest::CreateComplexTypeWrapper(WSPComplexTypeWrapper** aWrapper,
*aInfo = iinfo;
NS_ADDREF(*aInfo);
return WSPComplexTypeWrapper::Create(ct, iinfo, aWrapper);
nsCOMPtr<nsIWebServiceComplexTypeWrapper> wrapper = do_CreateInstance(NS_WEBSERVICECOMPLEXTYPEWRAPPER_CONTRACTID, &rv);
if (NS_FAILED(rv)) {
return rv;
}
rv = wrapper->Init(ct, iinfo);
if (NS_FAILED(rv)) {
return rv;
}
*aWrapper = wrapper;
NS_ADDREF(*aWrapper);
return NS_OK;
}
NS_IMETHODIMP
WSPProxyTest::TestComplexTypeWrapper()
WSPProxyTest::TestComplexTypeWrapper(nsAWritableString& aResult)
{
nsCOMPtr<nsIInterfaceInfo> info;
nsCOMPtr<WSPComplexTypeWrapper> wrapper;
nsCOMPtr<nsIWebServiceComplexTypeWrapper> wrapper;
nsresult rv = CreateComplexTypeWrapper(getter_AddRefs(wrapper),
getter_AddRefs(info));
if (NS_FAILED(rv)) {
return rv;
aResult.Assign(NS_LITERAL_STRING("WSPProxyTest: Failed creating complex type wrapper"));
return NS_OK;
}
nsCOMPtr<nsIPropertyBag> propBag = do_QueryInterface(wrapper);
if (!propBag) {
aResult.Assign(NS_LITERAL_STRING("WSPProxyTest: Wrapper is not property bag"));
return NS_ERROR_FAILURE;
}
rv = TestComplexTypeWrapperInstance(propBag);
if (NS_FAILED(rv)) {
return rv;
}
TestComplexTypeWrapperInstance(propBag, aResult);
return NS_OK;
}
nsresult
WSPProxyTest::TestComplexTypeWrapperInstance(nsIPropertyBag* propBag)
WSPProxyTest::TestComplexTypeWrapperInstance(nsIPropertyBag* propBag,
nsAWritableString& aResult)
{
nsCOMPtr<nsISimpleEnumerator> enumerator;
nsresult rv = propBag->GetEnumerator(getter_AddRefs(enumerator));
if (NS_FAILED(rv)) {
aResult.Assign(NS_LITERAL_STRING("WSPProxyTest: Failed getting property bag enumerator"));
return rv;
}
@ -150,7 +165,7 @@ WSPProxyTest::TestComplexTypeWrapperInstance(nsIPropertyBag* propBag)
#define GET_AND_TEST_NAME(_name) \
rv = enumerator->GetNext(getter_AddRefs(sup)); \
if (NS_FAILED(rv)) { \
printf("WSPProxyTest: Failed getting property " #_name "\n"); \
aResult.Assign(NS_LITERAL_STRING("WSPProxyTest: Failed getting property ") + NS_LITERAL_STRING(#_name)); \
return rv; \
} \
\
@ -161,7 +176,7 @@ WSPProxyTest::TestComplexTypeWrapperInstance(nsIPropertyBag* propBag)
\
prop->GetName(propName); \
if (!propName.Equals(NS_LITERAL_STRING(#_name))) { \
printf("WSPProxyTest: Name doesn't match for property " #_name "\n");\
aResult.Assign(NS_LITERAL_STRING("WSPProxyTest: Name doesn't match for property ") + NS_LITERAL_STRING(#_name)); \
return NS_ERROR_FAILURE; \
} \
prop->GetValue(getter_AddRefs(val)); \
@ -174,11 +189,11 @@ WSPProxyTest::TestComplexTypeWrapperInstance(nsIPropertyBag* propBag)
_t _name; \
rv = val->GetAs##_n(&_name); \
if (NS_FAILED(rv)) { \
printf("WSPProxyTest: Failed getting value for property " #_name "\n");\
aResult.Assign(NS_LITERAL_STRING("WSPProxyTest: Failed getting value for property ") + NS_LITERAL_STRING(#_name)); \
return rv; \
} \
if (_name != _val) { \
printf("WSPProxyTest: Value doesn't match for property " #_name "\n");\
aResult.Assign(NS_LITERAL_STRING("WSPProxyTest: Value doesn't match for property ") + NS_LITERAL_STRING(#_name)); \
return NS_ERROR_FAILURE; \
}
@ -200,12 +215,12 @@ WSPProxyTest::TestComplexTypeWrapperInstance(nsIPropertyBag* propBag)
nsAutoString str;
rv = val->GetAsAString(str);
if (NS_FAILED(rv)) {
printf("WSPProxyTest: Failed getting value for property s\n");
aResult.Assign(NS_LITERAL_STRING("WSPProxyTest: Failed getting value for property s"));
return rv;
}
if (!str.Equals(NS_LITERAL_STRING(STRING_VAL))) {
printf("WSPProxyTest: Value doesn't match for property s\n");
aResult.Assign(NS_LITERAL_STRING("WSPProxyTest: Value doesn't match for property s"));
return NS_ERROR_FAILURE;
}
@ -213,12 +228,12 @@ WSPProxyTest::TestComplexTypeWrapperInstance(nsIPropertyBag* propBag)
nsCOMPtr<nsISupports> supVal;
rv = val->GetAsISupports(getter_AddRefs(supVal));
if (NS_FAILED(rv)) {
printf("WSPProxyTest: Failed getting value for property p\n");
aResult.Assign(NS_LITERAL_STRING("WSPProxyTest: Failed getting value for property p"));
return rv;
}
nsCOMPtr<nsIPropertyBag> propBagVal = do_QueryInterface(supVal, &rv);
if (NS_FAILED(rv)) {
printf("WSPProxyTest: Value doesn't match for property p\n");
aResult.Assign(NS_LITERAL_STRING("WSPProxyTest: Value doesn't match for property p"));
return rv;
}
@ -226,129 +241,115 @@ WSPProxyTest::TestComplexTypeWrapperInstance(nsIPropertyBag* propBag)
PRUint16 dataType;
val->GetDataType(&dataType);
if (dataType != nsIDataType::VTYPE_EMPTY) {
printf("WSPProxyTest: Value doesn't match for property p\n");
aResult.Assign(NS_LITERAL_STRING("WSPProxyTest: Value doesn't match for property p"));
return NS_ERROR_FAILURE;
}
PRUint16 type;
PRUint32 index, count;
nsIVariant** arrayVal;
PRUint32* arrayVal1;
GET_AND_TEST_NAME(array1)
nsIID iid;
rv = val->GetAsArray(&type, &iid, &count, (void**)&arrayVal);
rv = val->GetAsArray(&type, &iid, &count, (void**)&arrayVal1);
if (NS_FAILED(rv)) {
printf("WSPProxyTest: Failed getting value for property array1\n");
aResult.Assign(NS_LITERAL_STRING("WSPProxyTest: Failed getting value for property array1"));
return rv;
}
for (index = 0; index < count; index++) {
nsIVariant* arrayVar = arrayVal[index];
PRUint32 arrayInt;
rv = arrayVar->GetAsUint32(&arrayInt);
if (NS_FAILED(rv)) {
printf("WSPProxyTest: Failed getting value for element of property array1\n");
return rv;
}
if (arrayInt != sArray1[index]) {
printf("WSPProxyTest: Value doesn't match for element of property array1\n");
if (arrayVal1[index] != sArray1[index]) {
aResult.Assign(NS_LITERAL_STRING("WSPProxyTest: Value doesn't match for element of property array1"));
return rv;
}
}
NS_FREE_XPCOM_ISUPPORTS_POINTER_ARRAY(count, arrayVal);
nsMemory::Free(arrayVal1);
double* arrayVal2;
GET_AND_TEST_NAME(array2)
rv = val->GetAsArray(&type, &iid, &count, (void**)&arrayVal);
rv = val->GetAsArray(&type, &iid, &count, (void**)&arrayVal2);
if (NS_FAILED(rv)) {
printf("WSPProxyTest: Failed getting value for property array2\n");
aResult.Assign(NS_LITERAL_STRING("WSPProxyTest: Failed getting value for property array2"));
return rv;
}
for (index = 0; index < count; index++) {
nsIVariant* arrayVar = arrayVal[index];
double arrayDouble;
rv = arrayVar->GetAsDouble(&arrayDouble);
if (NS_FAILED(rv)) {
printf("WSPProxyTest: Failed getting value for element of property array1\n");
return rv;
}
if (arrayDouble != sArray2[index]) {
printf("WSPProxyTest: Value doesn't match for element of property array1\n");
if (arrayVal2[index] != sArray2[index]) {
aResult.Assign(NS_LITERAL_STRING("WSPProxyTest: Value doesn't match for element of property array2"));
return rv;
}
}
NS_FREE_XPCOM_ISUPPORTS_POINTER_ARRAY(count, arrayVal);
nsMemory::Free(arrayVal2);
nsISupports** arrayVal3;
GET_AND_TEST_NAME(array3)
rv = val->GetAsArray(&type, &iid, &count, (void**)&arrayVal);
rv = val->GetAsArray(&type, &iid, &count, (void**)&arrayVal3);
if (NS_FAILED(rv)) {
printf("WSPProxyTest: Failed getting value for property array2\n");
aResult.Assign(NS_LITERAL_STRING("WSPProxyTest: Failed getting value for property array3"));
return rv;
}
nsIVariant* array3Var = arrayVal[0];
rv = array3Var->GetAsISupports(getter_AddRefs(supVal));
propBagVal = do_QueryInterface(arrayVal3[0], &rv);
if (NS_FAILED(rv)) {
printf("WSPProxyTest: Failed getting value for element of property array3\n");
aResult.Assign(NS_LITERAL_STRING("WSPProxyTest: Value doesn't match for element of property array3"));
return rv;
}
propBagVal = do_QueryInterface(supVal, &rv);
if (NS_FAILED(rv)) {
printf("WSPProxyTest: Value doesn't match for element of property array3\n");
return rv;
}
array3Var = arrayVal[1];
array3Var->GetDataType(&dataType);
if (dataType != nsIDataType::VTYPE_EMPTY) {
printf("WSPProxyTest: Value doesn't match for element of property array3\n");
if (arrayVal3[1] != nsnull) {
aResult.Assign(NS_LITERAL_STRING("WSPProxyTest: Value doesn't match for element of property array3"));
return NS_ERROR_FAILURE;
}
NS_FREE_XPCOM_ISUPPORTS_POINTER_ARRAY(count, arrayVal);
NS_FREE_XPCOM_ISUPPORTS_POINTER_ARRAY(count, arrayVal3);
#undef GET_AND_TEST
#undef GET_AND_TEST_NAME
aResult.Assign(NS_LITERAL_STRING("WSPProxyTest: Test Succeeded!"));
return NS_OK;
}
NS_IMETHODIMP
WSPProxyTest::TestPropertyBagWrapper()
WSPProxyTest::TestPropertyBagWrapper(nsAWritableString& aResult)
{
nsCOMPtr<nsIInterfaceInfo> info;
nsCOMPtr<WSPComplexTypeWrapper> ctwrapper;
nsCOMPtr<nsIWebServiceComplexTypeWrapper> ctwrapper;
nsresult rv = CreateComplexTypeWrapper(getter_AddRefs(ctwrapper),
getter_AddRefs(info));
if (NS_FAILED(rv)) {
return rv;
aResult.Assign(NS_LITERAL_STRING("WSPProxyTest: Failed creating complex type wrapper"));
return NS_OK;
}
nsCOMPtr<nsIPropertyBag> propBag = do_QueryInterface(ctwrapper);
if (!propBag) {
return NS_ERROR_FAILURE;
aResult.Assign(NS_LITERAL_STRING("WSPProxyTest: Wrapper is not property bag"));
return NS_OK;
}
WSPPropertyBagWrapper* wrapper;
rv = WSPPropertyBagWrapper::Create(propBag, info, &wrapper);
nsCOMPtr<nsIWebServicePropertyBagWrapper> wrapper = do_CreateInstance(NS_WEBSERVICEPROPERTYBAGWRAPPER_CONTRACTID, &rv);
if (NS_FAILED(rv)) {
return rv;
aResult.Assign(NS_LITERAL_STRING("WSPProxyTest: Failed creating property bag wrapper"));
return NS_OK;
}
rv = wrapper->Init(propBag, info);
if (NS_FAILED(rv)) {
aResult.Assign(NS_LITERAL_STRING("WSPProxyTest: Failed initializing property bag wrapper"));
return NS_OK;
}
nsCOMPtr<nsIWSPTestComplexType> ct = do_QueryInterface(wrapper, &rv);
NS_RELEASE(wrapper);
if (NS_FAILED(rv)) {
return rv;
aResult.Assign(NS_LITERAL_STRING("WSPProxyTest: Property bag wrapper doesn't QI correctly"));
return NS_OK;
}
#define GET_AND_TEST(_t, _name, _val) \
_t _name; \
rv = ct->Get##_name(&_name); \
if (NS_FAILED(rv)) { \
printf("WSPProxyTest: Failed to get value for attribute" #_name "\n"); \
return rv; \
aResult.Assign(NS_LITERAL_STRING("WSPProxyTest: Failed to get value for attribute") + NS_LITERAL_STRING(#_name)); \
return NS_OK; \
} \
if (_name != _val) { \
printf("WSPProxyTest: Value doesn't match for attribute " #_name "\n"); \
return NS_ERROR_FAILURE; \
aResult.Assign(NS_LITERAL_STRING("WSPProxyTest: Value doesn't match for attribute ") + NS_LITERAL_STRING(#_name)); \
return NS_OK; \
}
GET_AND_TEST(PRUint8, I8, sInt8Val)
@ -368,29 +369,29 @@ WSPProxyTest::TestPropertyBagWrapper()
nsAutoString str;
rv = ct->GetS(str);
if (NS_FAILED(rv)) {
printf("WSPProxyTest: Failed to get value for attribute s\n");
return rv;
aResult.Assign(NS_LITERAL_STRING("WSPProxyTest: Failed to get value for attribute s"));
return NS_OK;
}
if (!str.Equals(NS_LITERAL_STRING(STRING_VAL))) {
printf("WSPProxyTest: Value doesn't match for attribute s\n");
return NS_ERROR_FAILURE;
aResult.Assign(NS_LITERAL_STRING("WSPProxyTest: Value doesn't match for attribute s"));
return NS_OK;
}
nsCOMPtr<nsIWSPTestComplexType> p;
rv = ct->GetP(getter_AddRefs(p));
if (NS_FAILED(rv)) {
printf("WSPProxyTest: Failed to get value for attribute p\n");
return rv;
aResult.Assign(NS_LITERAL_STRING("WSPProxyTest: Failed to get value for attribute p"));
return NS_OK;
}
rv = ct->GetP2(getter_AddRefs(p));
if (NS_FAILED(rv)) {
printf("WSPProxyTest: Failed to get value for attribute p2\n");
return rv;
aResult.Assign(NS_LITERAL_STRING("WSPProxyTest: Failed to get value for attribute p2"));
return NS_OK;
}
if (p) {
printf("WSPProxyTest: Value doesn't match for attribute p2\n");
return NS_ERROR_FAILURE;
aResult.Assign(NS_LITERAL_STRING("WSPProxyTest: Value doesn't match for attribute p2"));
return NS_OK;
}
PRUint32 index, count;
@ -398,13 +399,13 @@ WSPProxyTest::TestPropertyBagWrapper()
PRUint32* array1;
rv = ct->Array1(&count, &array1);
if (NS_FAILED(rv)) {
printf("WSPProxyTest: Failed to get value for attribute array1\n");
return rv;
aResult.Assign(NS_LITERAL_STRING("WSPProxyTest: Failed to get value for attribute array1"));
return NS_OK;
}
for (index = 0; index < count; index++) {
if (array1[index] != sArray1[index]) {
printf("WSPProxyTest: Value doesn't match for element of attribute array1\n");
return NS_ERROR_FAILURE;
aResult.Assign(NS_LITERAL_STRING("WSPProxyTest: Value doesn't match for element of attribute array1"));
return NS_OK;
}
}
nsMemory::Free(array1);
@ -412,13 +413,13 @@ WSPProxyTest::TestPropertyBagWrapper()
double* array2;
rv = ct->Array2(&count, &array2);
if (NS_FAILED(rv)) {
printf("WSPProxyTest: Failed to get value for attribute array2\n");
return rv;
aResult.Assign(NS_LITERAL_STRING("WSPProxyTest: Failed to get value for attribute array2"));
return NS_OK;
}
for (index = 0; index < count; index++) {
if (array2[index] != sArray2[index]) {
printf("WSPProxyTest: Value doesn't match for element of attribute array2\n");
return NS_ERROR_FAILURE;
aResult.Assign(NS_LITERAL_STRING("WSPProxyTest: Value doesn't match for element of attribute array2"));
return NS_OK;
}
}
nsMemory::Free(array2);
@ -426,20 +427,164 @@ WSPProxyTest::TestPropertyBagWrapper()
nsIWSPTestComplexType** array3;
rv = ct->Array3(&count, &array3);
if (NS_FAILED(rv)) {
printf("WSPProxyTest: Failed to get value for attribute array3\n");
return rv;
aResult.Assign(NS_LITERAL_STRING("WSPProxyTest: Failed to get value for attribute array3"));
return NS_OK;
}
if (!array3[0] || array3[1]) {
printf("WSPProxyTest: Value doesn't match for element of attribute array3\n");
return NS_ERROR_FAILURE;
aResult.Assign(NS_LITERAL_STRING("WSPProxyTest: Value doesn't match for element of attribute array3"));
return NS_OK;
}
NS_FREE_XPCOM_ISUPPORTS_POINTER_ARRAY(count, array3);
#undef GET_AND_TEST
aResult.Assign(NS_LITERAL_STRING("WSPProxyTest: Test Succeeded!"));
return NS_OK;
}
/* void testIsPrimeProxy(nsIWSPProxyTestListener* aListener); */
NS_IMETHODIMP
WSPProxyTest::TestIsPrimeProxy(nsIWSPProxyTestListener* aListener)
{
mListener = aListener;
nsCOMPtr<nsIWSDLLoader> loader = do_CreateInstance(NS_WSDLLOADER_CONTRACTID);
if (!loader) {
mListener->OnIsPrimeProxyTestComplete(NS_LITERAL_STRING("Couldn't create WSDL loader"));
return NS_OK;
}
#define ISPRIMEURL "http://green.nscp.aoltw.net/vidur/wsdl/statistics.wsdl"
#define ISPRIMEPORT "SpheonJSAOPStatisticsPort"
nsresult rv = loader->LoadAsync(NS_LITERAL_STRING(ISPRIMEURL),
NS_LITERAL_STRING(ISPRIMEPORT),
this);
if (NS_FAILED(rv)) {
mListener->OnIsPrimeProxyTestComplete(NS_LITERAL_STRING("Failed loading WSDL file"));
}
return NS_OK;
}
/* void onLoad (in nsIWSDLPort port); */
NS_IMETHODIMP
WSPProxyTest::OnLoad(nsIWSDLPort *port)
{
nsresult rv;
nsCOMPtr<nsIInterfaceInfoManager> manager = do_GetService(NS_INTERFACEINFOMANAGER_SERVICE_CONTRACTID, &rv);
if (NS_FAILED(rv)) {
mListener->OnIsPrimeProxyTestComplete(NS_LITERAL_STRING("Couldn't create interface info manager"));
return NS_OK;
}
static nsIID sPortIID = NS_GET_IID(SpheonJSAOPStatisticsPortTypeAsync);
nsCOMPtr<nsIInterfaceInfo> iinfo;
rv = manager->GetInfoForIID(&sPortIID, getter_AddRefs(iinfo));
if (NS_FAILED(rv)) {
mListener->OnIsPrimeProxyTestComplete(NS_LITERAL_STRING("Couldn't find interface info for port"));
return NS_OK;
}
nsCOMPtr<nsIWebServiceProxy> proxy(do_CreateInstance(NS_WEBSERVICEPROXY_CONTRACTID));
if (!proxy) {
mListener->OnIsPrimeProxyTestComplete(NS_LITERAL_STRING("Couldn't create proxy"));
return NS_OK;
}
proxy->Init(port, iinfo, NS_LITERAL_STRING("foo"), PR_TRUE);
mProxy = do_QueryInterface(proxy);
if (!mProxy) {
mListener->OnIsPrimeProxyTestComplete(NS_LITERAL_STRING("Couldn't QI proxy to isPrime interface"));
return NS_OK;
}
mProxy->SetListener(this);
nsCOMPtr<nsIWebServiceCallContext> context;
rv = mProxy->IsPrimeNumber(5, getter_AddRefs(context));
if (NS_FAILED(rv)) {
mListener->OnIsPrimeProxyTestComplete(NS_LITERAL_STRING("Failed call to IsPrimeNumber"));
return NS_OK;
}
return NS_OK;
}
/* void onError (in nsresult status, in AString statusMessage); */
NS_IMETHODIMP
WSPProxyTest::OnError(nsresult status, const nsAString & statusMessage)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* void getStatisticsCallback (in nsIException error, in statisticStruct retval); */
NS_IMETHODIMP
WSPProxyTest::GetStatisticsCallback(nsIException *error, statisticStruct *retval)
{
if (error) {
nsXPIDLCString str;
error->ToString(getter_Copies(str));
mListener->OnIsPrimeProxyTestComplete(NS_ConvertASCIItoUCS2(str.get()));
}
else if (!retval) {
mListener->OnIsPrimeProxyTestComplete(NS_LITERAL_STRING("Incorrect value returned from IsPrimeNumber"));
}
else {
double average;
retval->GetAverage(&average);
if (average != 2.725) {
mListener->OnIsPrimeProxyTestComplete(NS_LITERAL_STRING("Incorrect value returned from IsPrimeNumber"));
}
else {
mListener->OnIsPrimeProxyTestComplete(NS_LITERAL_STRING("Test Succeeded!"));
}
}
return NS_OK;
}
/* void isPrimeNumberCallback (in nsIException error, in boolean retval); */
NS_IMETHODIMP
WSPProxyTest::IsPrimeNumberCallback(nsIException *error, PRBool retval)
{
if (error) {
nsXPIDLCString str;
error->ToString(getter_Copies(str));
mListener->OnIsPrimeProxyTestComplete(NS_ConvertASCIItoUCS2(str.get()));
}
else if (!retval) {
mListener->OnIsPrimeProxyTestComplete(NS_LITERAL_STRING("Incorrect value returned from IsPrimeNumber"));
}
else {
// Success!!
mListener->OnIsPrimeProxyTestComplete(NS_LITERAL_STRING("Test Succeeded!"));
#if 0
static double vals[4] = { 1.7, 3.4, 5.6, 0.2 };
nsCOMPtr<nsIWebServiceCallContext> context;
nsresult rv = mProxy->GetStatistics(sizeof(vals)/sizeof(double), vals,
getter_AddRefs(context));
if (NS_FAILED(rv)) {
mListener->OnIsPrimeProxyTestComplete(NS_LITERAL_STRING("Failed call to GetStatistics"));
}
#endif
}
return NS_OK;
}
/* void crossSumCallback (in nsIException error, in PRInt32 retval); */
NS_IMETHODIMP
WSPProxyTest::CrossSumCallback(nsIException *error, PRInt32 retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
///////////////////////////////////////////////////
//
// Implementation of WSPTestComplexType
//
///////////////////////////////////////////////////
WSPTestComplexType::WSPTestComplexType()
{
NS_INIT_ISUPPORTS();
@ -644,44 +789,3 @@ WSPTestComplexType::Array3(PRUint32 *length, nsIWSPTestComplexType ***array3)
return NS_OK;
}
int main (int argc, char* argv[])
{
nsIServiceManager *servMgr;
nsresult rv = NS_InitXPCOM2(&servMgr, nsnull, nsnull);
if (NS_FAILED(rv)) {
printf("failed to initialize XPCOM");
return rv;
}
nsCOMPtr<WSPProxyTest> test = new WSPProxyTest();
if (!test) {
printf("Error creating proxy test instance\n");
return NS_ERROR_OUT_OF_MEMORY;
}
printf("--- Testing complex type wrapper --- \n");
rv = test->TestComplexTypeWrapper();
if (NS_FAILED(rv)) {
printf("--- Test FAILED --- \n");
}
else {
printf("--- Test SUCCEEDED --- \n");
}
printf("--- Testing property bag wrapper --- \n");
rv = test->TestPropertyBagWrapper();
if (NS_FAILED(rv)) {
printf("--- Test FAILED --- \n");
}
else {
printf("--- Test SUCCEEDED --- \n");
}
if (servMgr)
rv = NS_ShutdownXPCOM(servMgr);
return rv;
}

Просмотреть файл

@ -43,20 +43,28 @@
#include "nsIWSPProxyTest.h"
#include "nsIPropertyBag.h"
#include "wspprivate.h"
#include "nsIWSDLLoader.h"
class WSPProxyTest : public nsIWSPProxyTest {
class WSPProxyTest : public nsIWSPProxyTest,
public nsIWSDLLoadListener,
public SpheonJSAOPStatisticsPortTypeListener
{
public:
WSPProxyTest();
virtual ~WSPProxyTest();
NS_DECL_ISUPPORTS
NS_DECL_NSIWSPPROXYTEST
NS_DECL_NSIWSDLLOADLISTENER
NS_DECL_SPHEONJSAOPSTATISTICSPORTTYPELISTENER
protected:
nsresult CreateComplexTypeWrapper(WSPComplexTypeWrapper** aWrapper,
nsresult CreateComplexTypeWrapper(nsIWebServiceComplexTypeWrapper** aWrapper,
nsIInterfaceInfo** aInfo);
nsresult TestComplexTypeWrapperInstance(nsIPropertyBag* propBag);
nsresult TestComplexTypeWrapperInstance(nsIPropertyBag* propBag,
nsAWritableString& aResult);
nsCOMPtr<nsIWSPProxyTestListener> mListener;
nsCOMPtr<SpheonJSAOPStatisticsPortTypeAsync> mProxy;
};
class WSPTestComplexType : public nsIWSPTestComplexType {

Просмотреть файл

@ -0,0 +1,89 @@
<?xml version="1.0"?>
<!--
- The contents of this file are subject to the Mozilla Public
- License Version 1.1 (the "License"); you may not use this file
- except in compliance with the License. You may obtain a copy of
- the License at http://www.mozilla.org/MPL/
-
- Software distributed under the License is distributed on an "AS
- IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
- implied. See the License for the specific language governing
- rights and limitations under the License.
-
- The Original Code is Mozilla Test Cases.
-
- The Initial Developer of the Original Code is Netscape Communications
- Corp. Portions created by Netscape Communications Corp. are
- Copyright (C) 2001 Netscape Communications Corp. All
- Rights Reserved.
-
- Contributor(s):
-->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Web Service Proxy Tests</title>
<style type="text/css">
.box {
display: box;
border: 1px solid black;
margin-bottom: 0.5em;
}
.boxheader {
font-weight: bold;
color: maroon;
}
pre {
margin-left: 2em;
}
</style>
<script type="text/javascript">
function WSPTest() {
this.wsptest = new WebServiceProxyTest();
}
WSPTest.prototype.onIsPrimeProxyTestComplete = function(str) {
document.getElementById("id3").firstChild.nodeValue = str;
}
WSPTest.prototype.startTest = function() {
try {
document.getElementById("id1").firstChild.nodeValue = this.wsptest.testComplexTypeWrapper();
}
catch (e) {
document.getElementById("id1").firstChild.nodeValue = "FAILED!";
}
try {
document.getElementById("id2").firstChild.nodeValue = this.wsptest.testPropertyBagWrapper();
}
catch (e) {
document.getElementById("id2").firstChild.nodeValue = "FAILED!";
}
try {
this.wsptest.testIsPrimeProxy(this);
}
catch (e) {
document.getElementById("id3").firstChild.nodeValue = "FAILED!";
}
}
var test = new WSPTest();
</script>
</head>
<body onload="test.startTest()">
<h1>Web Service Proxy Tests</h1>
<div class="box"><span class="boxheader">Complex Type Wrapper Test</span>
<pre id="id1">@@No result@@</pre>
</div>
<div class="box"><span class="boxheader">Property Bag Wrapper Test</span>
<pre id="id2">@@No result@@</pre>
</div>
<div class="box"><span class="boxheader">IsPrime Proxy Test</span>
<pre id="id3">@@No result@@</pre>
</div>
</body>
</html>

Просмотреть файл

@ -0,0 +1,81 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* John Bandhauer (jband@netscape.com)
* Vidur Apparao (vidur@netscape.com)
*
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "wspproxytest.h"
#include "nsIGenericFactory.h"
#include "nsIServiceManager.h"
#include "nsICategoryManager.h"
#include "nsIScriptNameSpaceManager.h"
NS_GENERIC_FACTORY_CONSTRUCTOR(WSPProxyTest)
NS_DECL_CLASSINFO(WSPProxyTest)
static NS_METHOD
RegisterWSPProxyTest(nsIComponentManager *aCompMgr,
nsIFile *aPath,
const char *registryLocation,
const char *componentType,
const nsModuleComponentInfo *info)
{
nsresult rv = NS_OK;
nsCOMPtr<nsICategoryManager> catman =
do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv);
if (NS_FAILED(rv))
return rv;
nsXPIDLCString previous;
rv = catman->AddCategoryEntry(JAVASCRIPT_GLOBAL_CONSTRUCTOR_CATEGORY,
"WebServiceProxyTest",
NS_WSPPROXYTEST_CONTRACTID,
PR_TRUE, PR_TRUE, getter_Copies(previous));
return rv;
}
static nsModuleComponentInfo components[] = {
{ "WebServiceProxyTest", NS_WSPPROXYTEST_CID, NS_WSPPROXYTEST_CONTRACTID,
WSPProxyTestConstructor, RegisterWSPProxyTest, nsnull, nsnull,
NS_CI_INTERFACE_GETTER_NAME(WSPProxyTest),
nsnull, &NS_CLASSINFO_NAME(WSPProxyTest),
nsIClassInfo::DOM_OBJECT }
};
NS_IMPL_NSGETMODULE(WSPProxyTestModule, components)