axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nadira...@apache.org
Subject svn commit: r399535 - in /webservices/axis/trunk/c/tests/auto_build/testcases/client/cpp: XSD_IDClient.cpp XSD_NCNameClient.cpp XSD_NameClient.cpp
Date Thu, 04 May 2006 04:12:59 GMT
Author: nadiramra
Date: Wed May  3 21:12:56 2006
New Revision: 399535

URL: http://svn.apache.org/viewcvs?rev=399535&view=rev
Log:
Fix memory leaks in test case.

Modified:
    webservices/axis/trunk/c/tests/auto_build/testcases/client/cpp/XSD_IDClient.cpp
    webservices/axis/trunk/c/tests/auto_build/testcases/client/cpp/XSD_NCNameClient.cpp
    webservices/axis/trunk/c/tests/auto_build/testcases/client/cpp/XSD_NameClient.cpp

Modified: webservices/axis/trunk/c/tests/auto_build/testcases/client/cpp/XSD_IDClient.cpp
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/c/tests/auto_build/testcases/client/cpp/XSD_IDClient.cpp?rev=399535&r1=399534&r2=399535&view=diff
==============================================================================
--- webservices/axis/trunk/c/tests/auto_build/testcases/client/cpp/XSD_IDClient.cpp (original)
+++ webservices/axis/trunk/c/tests/auto_build/testcases/client/cpp/XSD_IDClient.cpp Wed May
 3 21:12:56 2006
@@ -63,6 +63,8 @@
                 cout << "non-nillable element=" << result << endl;
             else
                 cout << "non-nillable element=<empty>" << endl;
+                
+            delete result;
         }
         else
             cout << "non-nillable element=<nil>" << endl;
@@ -80,6 +82,8 @@
                 cout << "empty non-nillable element=" << result << endl;
             else
                 cout << "empty non-nillable element=<empty>" << endl;
+                
+            delete result;
         }
         else
             cout << "empty non-nillable element=<nil>" << endl;
@@ -94,6 +98,8 @@
                 cout << "non-nillable element with XML reserved characters=" <<
result << endl;
             else
                 cout << "non-nillable element with XML reserved characters=<empty>"
<< endl;
+                
+            delete result;
         }
         else
             cout << "non-nillable element with XML reserved characters=<nil>"
<< endl;
@@ -107,6 +113,8 @@
                 cout << "non-nillable element with whitespace characters=\"" <<
result << "\"" << endl;
             else
                 cout << "non-nillable element with whitespace characters=<empty>"
<< endl;
+                
+            delete result;
         }
         else
             cout << "non-nillable element with whitespace characters=<nil>" <<
endl;

Modified: webservices/axis/trunk/c/tests/auto_build/testcases/client/cpp/XSD_NCNameClient.cpp
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/c/tests/auto_build/testcases/client/cpp/XSD_NCNameClient.cpp?rev=399535&r1=399534&r2=399535&view=diff
==============================================================================
--- webservices/axis/trunk/c/tests/auto_build/testcases/client/cpp/XSD_NCNameClient.cpp (original)
+++ webservices/axis/trunk/c/tests/auto_build/testcases/client/cpp/XSD_NCNameClient.cpp Wed
May  3 21:12:56 2006
@@ -64,6 +64,8 @@
                 cout << "non-nillable element=" << result << endl;
             else
                 cout << "non-nillable element=<empty>" << endl;
+                
+            delete result;
         }
         else
             cout << "non-nillable element=<nil>" << endl;
@@ -81,6 +83,8 @@
                 cout << "empty non-nillable element=" << result << endl;
             else
                 cout << "empty non-nillable element=<empty>" << endl;
+                
+            delete result;
         }
         else
             cout << "empty non-nillable element=<nil>" << endl;

Modified: webservices/axis/trunk/c/tests/auto_build/testcases/client/cpp/XSD_NameClient.cpp
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/c/tests/auto_build/testcases/client/cpp/XSD_NameClient.cpp?rev=399535&r1=399534&r2=399535&view=diff
==============================================================================
--- webservices/axis/trunk/c/tests/auto_build/testcases/client/cpp/XSD_NameClient.cpp (original)
+++ webservices/axis/trunk/c/tests/auto_build/testcases/client/cpp/XSD_NameClient.cpp Wed
May  3 21:12:56 2006
@@ -14,6 +14,15 @@
 // limitations under the License.
 
 
+/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
+/* NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE   */
+/* ----------------------------------------------------------------   */
+/* CHANGES TO THIS FILE MAY ALSO REQUIRE CHANGES TO THE               */
+/* C-EQUIVALENT FILE. PLEASE ENSURE THAT IT IS DONE.                  */
+/* ----------------------------------------------------------------   */
+/* NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE   */
+/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
+
 #include "XSD_Name.hpp"
 #include <axis/AxisException.hpp>
 #include <ctype.h>
@@ -22,6 +31,18 @@
 
 int main(int argc, char* argv[])
 {
+    XSD_Name* ws;
+    
+    xsd__Name input;
+    xsd__Name result;
+
+    RequiredAttributeElement requiredAttributeInput;
+    RequiredAttributeElement* requiredAttributeResult;
+    
+    
+    char emptyName[1] = "";
+    char simpleName[25] = "xml.si-mple_nam:e";    
+    
     char endpoint[256];
     const char* url="http://localhost:80/axis/XSD_Name";
 
@@ -31,161 +52,130 @@
     try
     {
         sprintf(endpoint, "%s", url);
-        XSD_Name* ws = new XSD_Name(endpoint);
+        ws = new XSD_Name(endpoint);
       
-        char emptyName[1] = "";
-        xsd__Name emptyInput = new char[1];
-        strcpy (emptyInput, emptyName);
-        //char simpleName[25] = "A simple test message!";
-        char simpleName[25] = "xml.si-mple_nam:e";
-        xsd__Name input = new char[25];
+        input = new char[25];
         strcpy (input, simpleName);
 
         // Test non-nillable element
-        xsd__Name result = ws->asNonNillableElement(input);
+        result = ws->asNonNillableElement(input);
         if (result)
         {
             if (*result)
-            {
                 cout << "non-nillable element=" << result << endl;
-            }
             else
-            {
                 cout << "non-nillable element=<empty>" << endl;
-            }
+                
+            delete result;
         }
         else
-        {
             cout << "non-nillable element=<nil>" << endl;
-        }
+
         delete [] input;
 
         // Test empty non-nillable element
-        result = ws->asNonNillableElement(emptyInput);
+        xsd__Name input = new char[1];
+        strcpy (input, emptyName);
+        
+        result = ws->asNonNillableElement(input);
         if (result)
         {
             if (*result)
-            {
                 cout << "empty non-nillable element=" << result << endl;
-            }
             else
-            {
                 cout << "empty non-nillable element=<empty>" << endl;
-            }
+                
+            delete result;
         }
         else
-        {
             cout << "empty non-nillable element=<nil>" << endl;
-        }
-        delete [] emptyInput;
+
+        delete [] input;
 
         // Test nillable element, with a value
         input = new char[25];
         strcpy (input, simpleName);
-        xsd__Name nillableResult = ws->asNillableElement(input);
-        if (nillableResult)
+        result = ws->asNillableElement(input);
+        if (result)
         {
-            if (*nillableResult)
-            {
-                cout << "nillable element=" << nillableResult << endl;
-            }
+            if (*result)
+                cout << "nillable element=" << result << endl;
             else
-            {
                 cout << "nillable element=<empty>" << endl;
-            }
-            delete nillableResult;
+                
+            delete result;
         }
         else
-        {
             cout << "nillable element=<nil>" << endl;
-        }
         delete [] input;
 
         // Test empty nillable element
-        emptyInput = new char[1];
-        strcpy (emptyInput, emptyName);
-        nillableResult = ws->asNillableElement(emptyInput);
-        if (nillableResult)
+        input = new char[1];
+        strcpy (input, emptyName);
+        result = ws->asNillableElement(input);
+        if (result)
         {
-            if (*nillableResult)
-            {
-                cout << "empty nillable element=" << nillableResult <<
endl;
-            }
+            if (*result)
+                cout << "empty nillable element=" << result << endl;
             else
-            {
                 cout << "empty nillable element=<empty>" << endl;
-            }
-            delete nillableResult;
+
+            delete result;
         }
         else
-        {
             cout << "empty nillable element=<nil>" << endl;
-        }
-        delete [] emptyInput;
+
+        delete [] input;
 
         // Test nillable element, with nil
-        nillableResult = ws->asNillableElement(NULL);
-        if (nillableResult)
+        result = ws->asNillableElement(NULL);
+        if (result)
         {
-            if (*nillableResult)
-            {
-                cout << "nil element=" << nillableResult << endl;
-            }
+            if (*result)
+                cout << "nil element=" << result << endl;
             else
-            {
                 cout << "nil element=<empty>" << endl;
-            }
-            delete nillableResult;
+                
+            delete result;
         }
         else
-        {
             cout << "nil element=<nil>" << endl;
-        }
 
         // Test required attribute
         input = new char[25];
         strcpy (input, simpleName);
-        RequiredAttributeElement requiredAttributeInput;
+
         requiredAttributeInput.setrequiredAttribute(input);
-        RequiredAttributeElement* requiredAttributeResult = ws->asRequiredAttribute(&requiredAttributeInput);
+        requiredAttributeResult = ws->asRequiredAttribute(&requiredAttributeInput);
+        
         if (requiredAttributeResult->getrequiredAttribute())
         {
             if (*(requiredAttributeResult->getrequiredAttribute()))
-            {
                 cout << "required attribute=" << requiredAttributeResult->getrequiredAttribute()
<< endl;
-            }
             else
-            {
                 cout << "required attribute=<empty>" << endl;
-            }
         }
         else
-        {
             cout << "required attribute=<nil>" << endl;
-        }
+            
         delete requiredAttributeResult;
 
         // Test empty required attribute
-        emptyInput = new char[1];
-        strcpy (emptyInput, emptyName);
-        requiredAttributeInput;
-        requiredAttributeInput.setrequiredAttribute(emptyInput);
+        input = new char[1];
+        strcpy (input, emptyName);
+
+        requiredAttributeInput.setrequiredAttribute(input);
         requiredAttributeResult = ws->asRequiredAttribute(&requiredAttributeInput);
         if (requiredAttributeResult->getrequiredAttribute())
         {
             if (*(requiredAttributeResult->getrequiredAttribute()))
-            {
                 cout << "empty required attribute=" << requiredAttributeResult->getrequiredAttribute()
<< endl;
-            }
             else
-            {
                 cout << "empty required attribute=<empty>" << endl;
-            }
         }
         else
-        {
             cout << "empty required attribute=<nil>" << endl;
-        }
+
         delete requiredAttributeResult;
 
 /*  Optional Attributes currently unsupported by WSDL2Ws
@@ -199,42 +189,32 @@
         if (optionalAttributeResult->getoptionalAttribute())
         {
             if (*(optionalAttributeResult->getoptionalAttribute()))
-            {
                 cout << "optional attribute, with data=" << optionalAttributeResult->getoptionalAttribute()
<< endl;
-            }
             else
-            {
                 cout << "optional attribute, with data=<empty>" << endl;
-            }
         }
         else
-        {
             cout << "optional attribute, with data=<not present>" << endl;
-        }
+
         delete [] input;
         delete optionalAttributeResult;
 
         // Test empty optional attribute
-        emptyInput = new char[1];
-        strcpy (emptyInput, emptyName);
-        optionalAttributeInput.setoptionalAttribute(emptyInput);
+        input = new char[1];
+        strcpy (input, emptyName);
+        optionalAttributeInput.setoptionalAttribute(input);
         optionalAttributeResult = ws->asOptionalAttribute(&optionalAttributeInput);
         if (optionalAttributeResult->getoptionalAttribute())
         {
             if (*(optionalAttributeResult->getoptionalAttribute()))
-            {
                 cout << "empty optional attribute=" << optionalAttributeResult->getoptionalAttribute()
<< endl;
-            }
             else
-            {
                 cout << "empty optional attribute=<empty>" << endl;
-            }
         }
         else
-        {
             cout << "empty optional attribute=<not present>" << endl;
-        }
-        delete [] emptyInput;
+
+        delete [] input;
         delete optionalAttributeResult;
 
         // Test optional attribute, not present
@@ -243,59 +223,45 @@
         if (optionalAttributeResult->getoptionalAttribute())
         {
             if (*(optionalAttributeResult->getoptionalAttribute()))
-            {
                 cout << "optional attribute, not present=" << optionalAttributeResult->getoptionalAttribute()
<< endl;
-            }
             else
-            {
                 cout << "optional attribute, not present=<empty>" << endl;
-            }
         }
         else
-        {
             cout << "optional attribute, not present=<not present>" <<
endl;
-        }
         delete optionalAttributeResult;
 */
 
         // Test array
-          xsd__Name_Array arrayInput;
-                 int arraySize=2;
-                 xsd__Name *array = new xsd__Name[arraySize];        
+        xsd__Name_Array arrayInput;
+        int arraySize=2;
+        xsd__Name *array = new xsd__Name[arraySize];        
         for (int inputIndex=0 ; inputIndex <arraySize ; inputIndex++)
         {
             array[inputIndex] = new char[25];
             strcpy (array[inputIndex], simpleName);
-           
         }
-                arrayInput.set(array,arraySize);
+        arrayInput.set(array,arraySize);
         xsd__Name_Array* arrayResult = ws->asArray(&arrayInput);
-                int outputSize=0;
-                const xsd__Name *output = arrayResult->get(outputSize);
+        int outputSize=0;
+        const xsd__Name *output = arrayResult->get(outputSize);
         cout << "array of " << outputSize << " elements" << endl;
         for (int index = 0; index < outputSize ; index++)
         {
             if (output!=NULL)
             {
                 if (output[index]!=NULL)
-                {
                     cout << "  element[" << index << "]=" << output[index]
<< endl;
-                }
                 else
-                {
                     cout << "  element[" << index << "]=<empty>"
<< endl;
-                }
              }
             else
-            {
                 cout << "  element[" << index << "]=<nil>" <<
endl;
-            }
         }
         // Clear up input array        
         for (int deleteIndex = 0 ; deleteIndex < arraySize ; deleteIndex++ )
-        {
             delete array[deleteIndex];
-        }
+
         delete [] array;
         delete arrayResult;
 
@@ -309,18 +275,13 @@
         if (complexTypeResult->getcomplexTypeElement())
         {
             if (*(complexTypeResult->getcomplexTypeElement()))
-            {
                 cout << "within complex type=" << complexTypeResult->getcomplexTypeElement()
<< endl;
-            }
             else
-            {
                 cout << "within complex type=<empty>" << endl;
-            }
         }
         else
-        {
             cout << "within complex type=<nil>" << endl;
-        }
+
         delete complexTypeResult;  
 
         // Tests now complete



Mime
View raw message