ws-axis-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From whitl...@apache.org
Subject cvs commit: ws-axis/c/tests/auto_build/testcases/client/cpp IHeaderBlockTest3Client.cpp
Date Tue, 01 Mar 2005 12:16:17 GMT
whitlock    2005/03/01 04:16:17

  Modified:    c/include/axis IHeaderBlock.hpp
               c/src/soap Attribute.cpp Attribute.h HeaderBlock.cpp
               c/tests/auto_build/testcases/client/cpp
                        IHeaderBlockTest3Client.cpp
  Log:
  AXISCPP-494 Fix IHeaderBlockTest3.
  Make localname mandatory on IHeaderBlock::createAttribute and all other parameters optional
  Fix memory leak in HeaderBlock::createAttribute
  Allow a prefix to match a namespace within a header block
  
  Revision  Changes    Path
  1.14      +7 -8      ws-axis/c/include/axis/IHeaderBlock.hpp
  
  Index: IHeaderBlock.hpp
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/include/axis/IHeaderBlock.hpp,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- IHeaderBlock.hpp	24 Feb 2005 10:53:29 -0000	1.13
  +++ IHeaderBlock.hpp	1 Mar 2005 12:16:16 -0000	1.14
  @@ -174,11 +174,10 @@
         * We expect that the server side will fail.
         * e.g. If creating more than one attribute with the same name the outcome is undefined
         * 
  -      *
  -      * @param localname The local name of the attribute.
  -      * @param prefix The prefix of the attribute.
  -      * @param uri The namespace uri of the attribute.
  -      * @param value The value of the attribute.
  +      * @param localname The local name of the attribute. (mandatory)
  +      * @param prefix The prefix of the attribute. (optional)
  +      * @param uri The namespace uri of the attribute. (optional)
  +      * @param value The value of the attribute. (optional)
         *
         * @return A pointer to the created Attribute will be returned.
         */
  @@ -192,9 +191,9 @@
         * We expect that the server side will fail.
         * e.g. If creating more than one attribute with the same name the outcome is undefined
         *
  -      * @param localname The local name of the attribute.
  -      * @param prefix The prefix of the attribute.
  -      * @param value The value of the attribute.
  +      * @param localname The local name of the attribute. (mandatory)
  +      * @param prefix The prefix of the attribute. (optional)
  +      * @param value The value of the attribute. (optional)
         *
         * @return A pointer to the created Attribute will be returned.
         */
  
  
  
  1.35      +4 -3      ws-axis/c/src/soap/Attribute.cpp
  
  Index: Attribute.cpp
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/src/soap/Attribute.cpp,v
  retrieving revision 1.34
  retrieving revision 1.35
  diff -u -r1.34 -r1.35
  --- Attribute.cpp	23 Feb 2005 15:31:20 -0000	1.34
  +++ Attribute.cpp	1 Mar 2005 12:16:16 -0000	1.35
  @@ -175,11 +175,12 @@
   }
   
   int Attribute::serialize(SoapSerializer& pSZ, 
  -                         list<AxisChar*>& lstTmpNameSpaceStack)
  +                         list<AxisChar*>& lstTmpNameSpaceStack,
  +						 const AxisChar *uri)
   {    
       int intStatus= AXIS_FAIL;
   
  -    if (isSerializable() && !pSZ.getNamespaceURL( m_prefix).empty())
  +    if (isSerializable() && (!pSZ.getNamespaceURL( m_prefix).empty() || NULL!=uri))
       {        
           pSZ.serialize(" ", NULL);
   
  @@ -188,7 +189,7 @@
   		 *  not worry to declare the namespace at all. Because it is the users
   		 *  responsibiltiy to add his/her namespace declaration seperately.
            */
  -        if(!m_prefix.empty())
  +        if(!m_prefix.empty() || NULL!=uri)
           {            
               pSZ.serialize(m_prefix.c_str(), ":", NULL);
           }
  
  
  
  1.13      +1 -1      ws-axis/c/src/soap/Attribute.h
  
  Index: Attribute.h
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/src/soap/Attribute.h,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- Attribute.h	11 Feb 2005 18:45:33 -0000	1.12
  +++ Attribute.h	1 Mar 2005 12:16:16 -0000	1.13
  @@ -50,7 +50,7 @@
       int initializeForTesting();
   #endif
       int serialize(SoapSerializer& pSZ) const;
  -    int serialize(SoapSerializer& pSZ, list<AxisChar*>& lstTmpNameSpaceStack);
  +    int serialize(SoapSerializer& pSZ, list<AxisChar*>& lstTmpNameSpaceStack,
const AxisChar *uri=NULL);
   
       Attribute();    
       Attribute(const AxisChar* localname, const AxisChar* prefix, 
  
  
  
  1.57      +54 -30    ws-axis/c/src/soap/HeaderBlock.cpp
  
  Index: HeaderBlock.cpp
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/src/soap/HeaderBlock.cpp,v
  retrieving revision 1.56
  retrieving revision 1.57
  diff -u -r1.56 -r1.57
  --- HeaderBlock.cpp	25 Feb 2005 10:25:11 -0000	1.56
  +++ HeaderBlock.cpp	1 Mar 2005 12:16:16 -0000	1.57
  @@ -312,8 +312,26 @@
       list<Attribute*>::iterator itCurrAttribute= m_attributes.begin();
   
       while(itCurrAttribute != m_attributes.end())
  -    {        
  -        iStatus= (*itCurrAttribute)->serialize(pSZ, lstTmpNameSpaceStack);
  +    {    
  +		// See if this prefix matches a namespace within this headerblock
  +		const AxisChar *uri = NULL;
  +		Attribute *attr = *itCurrAttribute;
  +		const AxisChar *attrPrefix = attr->getPrefix();
  +		if (NULL != attrPrefix)
  +		{
  +			list<Namespace*>::iterator itNs = m_namespaceDecls.begin();
  +			while (itNs != m_namespaceDecls.end())
  +			{
  +				if (0 == strcmp((*itNs)->getPrefix(), attrPrefix))
  +				{
  +					uri = (*itNs)->getURI();
  +					break;
  +				}
  +				itNs++;
  +			}
  +		}
  +
  +        iStatus= (*itCurrAttribute)->serialize(pSZ, lstTmpNameSpaceStack, uri);
           if(iStatus==AXIS_FAIL)
           {
               break;
  @@ -547,6 +565,9 @@
   	return createImmediateChild(eNODE_TYPE, "", "", "", "");
   }
   
  +/**
  + * The localname must be specified, but all other input parameters are optional.
  + */
   IAttribute* HeaderBlock::createAttribute(const AxisChar *localname,
                                           const AxisChar *prefix,
                                           const AxisChar *value)
  @@ -554,43 +575,46 @@
       return createAttribute(localname, prefix, NULL, value);
   }
   
  +/**
  + * The localname must be specified, but all other input parameters are optional.
  + */
   IAttribute* HeaderBlock::createAttribute(const AxisChar *localname,
                                           const AxisChar *prefix,
                                           const AxisChar *uri,
                                           const AxisChar *value)
   {
   	Attribute* pAttribute=NULL;
  -  if(!localname)
  -   {
  -      localname="";
  -   }
  -   if(!prefix)
  -   {
  -      prefix="";
  -   }
  -   if(!uri)
  -   {
  -      uri="";
  -   }
  -   if(!value)
  -   {
  -      value = "";
  -   }
  +	if(!localname)
  +	{
  +		return NULL;
  +	}
  +	if(!prefix)
  +	{
  +		prefix="";
  +	}
  +	if(!uri)
  +	{
  +		uri="";
  +	}
  +	if(!value)
  +	{
  +		value = "";
  +	}
      
  -    pAttribute = new Attribute(localname, prefix, uri, value);
  -//	    m_attributes.push_back(pAttribute);
   	
  -       list<Attribute*>::iterator itCurrAttribute= m_attributes.begin();
  -       while(itCurrAttribute != m_attributes.end())
  -       {        
  -         if ((strcmp((*itCurrAttribute)->getLocalName(), localname) ==0) &&
(strcmp((*itCurrAttribute)->getPrefix(), prefix) ==0))
  -                return NULL;                 
  -            else
  -                itCurrAttribute++;        
  -        }    
  +	list<Attribute*>::iterator itCurrAttribute= m_attributes.begin();
  +	while(itCurrAttribute != m_attributes.end())
  +	{        
  +		if ((strcmp((*itCurrAttribute)->getLocalName(), localname) ==0) && 
  +			(strcmp((*itCurrAttribute)->getPrefix(), prefix) ==0))
  +			return NULL;
  +		else
  +			itCurrAttribute++;        
  +	}    
           
  -        m_attributes.push_back(pAttribute);
  -    return pAttribute;
  +	pAttribute = new Attribute(localname, prefix, uri, value);
  +	m_attributes.push_back(pAttribute);
  +	return pAttribute;
   }
   
   IAttribute* HeaderBlock::createStdAttribute(HEADER_BLOCK_STD_ATTR_TYPE 
  
  
  
  1.4       +7 -0      ws-axis/c/tests/auto_build/testcases/client/cpp/IHeaderBlockTest3Client.cpp
  
  Index: IHeaderBlockTest3Client.cpp
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/tests/auto_build/testcases/client/cpp/IHeaderBlockTest3Client.cpp,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- IHeaderBlockTest3Client.cpp	26 Feb 2005 12:09:36 -0000	1.3
  +++ IHeaderBlockTest3Client.cpp	1 Mar 2005 12:16:16 -0000	1.4
  @@ -31,11 +31,18 @@
   		IHeaderBlock *phb = ws.createSOAPHeaderBlock("TestHeader","http://ws.apache.org/");
   		INamespace *Insp1=phb->createNamespaceDecl(prefix,uri);			
   		INamespace *Insp2=phb->createNamespaceDecl("np1","http://axis.apache.org/");
  +
  +		IAttribute *attr1=phb->createAttribute(NULL,NULL,NULL,NULL);
  +        IAttribute *attr2=phb->createAttribute(NULL,NULL,NULL);
  +		if(attr1 || attr2)
  +			cout << "Attribute returned for NULL arguments in createAttribute"<<endl;
  +
   		const AxisChar *temp="apache";
   		const AxisChar *localname="name";	
   		IAttribute *Iattr1=phb->createAttribute(localname,prefix,temp);		
   		IAttribute *Iattr2=phb->createAttribute(localname,"np1","","Axis");		
   		IAttribute *Iattr3=phb->createAttribute(localname,"","","");		
  +
   		cout << "np:name=" << phb->getAttributeValue(localname,prefix)<<endl;
   		cout << "np1:name=" << phb->getAttributeValue("name","np1")<<endl;
   		cout <<"name=" << phb->getAttributeValue("name","")<<endl;
  
  
  

Mime
View raw message