You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by pe...@apache.org on 2005/02/16 15:27:09 UTC

cvs commit: ws-axis/c/tests/auto_build/testcases/tests TestSetHandlerProperty.xml

perryan     2005/02/16 06:27:09

  Added:       c/tests/auto_build/testcases/client/cpp
                        TestSetHandlerPropertyClient.cpp
               c/tests/auto_build/testcases/handlers/TestSetHandlerProperty/testhandler
                        THandler.cpp THandler.h TestHandler.cpp
               c/tests/auto_build/testcases/output
                        TestSetHandlerProperty.expected
               c/tests/auto_build/testcases/tests
                        TestSetHandlerProperty.xml
  Log:
  Added setHandlerProperty test for Manohar
  
  Revision  Changes    Path
  1.1                  ws-axis/c/tests/auto_build/testcases/client/cpp/TestSetHandlerPropertyClient.cpp
  
  Index: TestSetHandlerPropertyClient.cpp
  ===================================================================
  /* 
   *****************************************************************************
   * This test tests the functionality of setHandlerProperty() of Stub class.
   * Test Logic
   * Set a value for a property and and get it's value in Handler and also
   * set the value for a property in handler and get that value in Client.
   *
   * The test is supposed to be passed when values set in client are 
   * received in handler and vice versa.
   *****************************************************************************
   */
  
  #include "Calculator.hpp"
  #include<iostream>
  
  int main(int argc, char* argv[])
  {
  	char endpoint[256];
  	const char* url="http://localhost:80/axis/Calculator";
  	int iResult;
  	
  
  	url = argv[1];
  
  	try
  	{
  		sprintf(endpoint, "%s", url);
  		Calculator ws(endpoint);
  		char buffer[100];
  		char* pbuff=buffer; 
  		
  		ws.setHandlerProperty("prop1", (void*)"value1", 7);
  		ws.setHandlerProperty("prop2", &pbuff, 100);
  		
  		iResult = ws.add(2,3);
  		cout << iResult << endl;
  		cout << "value of prop2 printed in client is = " << buffer << endl;
  	
  	}
  	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" );
  	}
  	cout << "---------------- TEST COMPLETE ----------------" << endl;
  	return 0;
  }
  
  
  
  
  
  1.1                  ws-axis/c/tests/auto_build/testcases/handlers/TestSetHandlerProperty/testhandler/THandler.cpp
  
  Index: THandler.cpp
  ===================================================================
  /*
   *   Copyright 2003-2004 The Apache Software Foundation.
   *
   *   Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
   *
   *   Unless required by applicable law or agreed to in writing, software
   *   distributed under the License is distributed on an "AS IS" BASIS,
   *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   *   See the License for the specific language governing permissions and
   *   limitations under the License.
   *
   *
   * @author Manohar Chintala (cmanohar@in.ibm.com)
   *
   *****************************************************************************
   * Test Logic.
   * Get value of a property which is set in client in the resquest.
   *
   * In the response, set a value into the buffer whose address is passed in from 
   * client and get that value in client. This way we can ensure that values 
   * set in the client is received in handler and values set in handler are
   * received in client.
   *
   *****************************************************************************
   */
  
  #include "THandler.h"
  #include <axis/GDefine.hpp>
  #include <axis/IHandlerSoapSerializer.hpp>
  #include <axis/IHandlerSoapDeSerializer.hpp>
  #include <axis/BasicNode.hpp>
  #include <iostream>
  
  THandler::THandler()
  {
      m_pOption = NULL;
      m_sEmpty = "";
  }
  
  THandler::~THandler()
  {
  
  }
  
  const string& THandler::getOption(const string& sArg)
  {
    map<string, string>::const_iterator it = m_pOption->find(sArg);
    if (it != m_pOption->end())
    {
        return (*it).second;
    }
    return m_sEmpty;	
  }
  
  void THandler::setOptionList(const map<string, string>* OptionList)
  {
     m_pOption = OptionList;
  }
  
  int THandler::invoke(void *pvIMsg)
  {
  	IMessageData *pIMsg = (IMessageData*) pvIMsg;
  
  	if(pIMsg->isPastPivot()) {
  		/*this is a response*/
  
  		char** chk1 = (char**)pIMsg->getProperty("prop2");
  		strcpy(*chk1, "value2");
  		cout << "value of prop2 set in handler is = " << *chk1 << endl;
  		
  	} else {
  		/*this is a request*/
  		
  		char* chk2 = (char*) pIMsg->getProperty("prop1");
  		cout << "value of prop1 is = " << chk2 << endl;		
  	}
  
  	return AXIS_SUCCESS;
  }
  
  void THandler::onFault(void *pvIMsg)
  {
  
  }
  
  int THandler::init()
  {
  	//do any initialization, resetting of values
  
  	return AXIS_SUCCESS;
  }
  
  int THandler::fini()
  {
  	//do any finalizatoin
  
  	return AXIS_SUCCESS;
  }
  
  
  
  1.1                  ws-axis/c/tests/auto_build/testcases/handlers/TestSetHandlerProperty/testhandler/THandler.h
  
  Index: THandler.h
  ===================================================================
  /*
   *   Copyright 2003-2004 The Apache Software Foundation.
   *
   *   Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
   *
   *   Unless required by applicable law or agreed to in writing, software
   *   distributed under the License is distributed on an "AS IS" BASIS,
   *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   *   See the License for the specific language governing permissions and
   *   limitations under the License.
   *
   *
   * @author Andrew Perry (perryan@uk.ibm.com)
   *
   *****************************************************************************
   * Test Logic.
   * Get an empty property in the response and make sure it is empty.
   *
   * Test success is measured by comparing the actual response with an expected
   * response. So on failure just write anything to stdout and the test will 
   * fail.
   *****************************************************************************
   *
   */
  
  #if !defined(_THANDLER_H____OF_AXIS_INCLUDED_)
  #define _THANDLER_H____OF_AXIS_INCLUDED_
  
  #include <axis/Handler.hpp>
  
  AXIS_CPP_NAMESPACE_USE
  
  class THandler : public Handler
  {
  public:
  	int AXISCALL fini();
  	int AXISCALL init();
  	void AXISCALL onFault(void* pvIMsg);
  	int AXISCALL invoke(void* pvIMsg);
  	void setOptionList(const map<string, string>* OptionList);
  	const string& getOption(const string& sArg);
  	THandler();
  	virtual ~THandler();
  
  protected:
      string m_sEmpty;   
  
  };
  
  #endif // !defined(_THANDLER_H____OF_AXIS_INCLUDED_)
  
  
  
  1.1                  ws-axis/c/tests/auto_build/testcases/handlers/TestSetHandlerProperty/testhandler/TestHandler.cpp
  
  Index: TestHandler.cpp
  ===================================================================
  /*
   *   Copyright 2003-2004 The Apache Software Foundation.
   *
   *   Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
   *
   *   Unless required by applicable law or agreed to in writing, software
   *   distributed under the License is distributed on an "AS IS" BASIS,
   *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   *   See the License for the specific language governing permissions and
   *   limitations under the License.
   *
   *
   * @author Andrew Perry (perryan@uk.ibm.com)
   *
   *****************************************************************************
   * Test Logic.
   * Get an empty property in the response and make sure it is empty.
   *
   * Test success is measured by comparing the actual response with an expected
   * response. So on failure just write anything to stdout and the test will 
   * fail.
   *****************************************************************************
   *
   */
  
  //
  //////////////////////////////////////////////////////////////////////
  
  #include "THandler.h"
  #include <axis/GDefine.hpp>
  
  extern "C" {
  //the two export functions////////////////////////////////////////////
  
  //Following describes how the export function of the handler DLLs (or .so s)
  
  STORAGE_CLASS_INFO
  int GetClassInstance(BasicHandler **inst)
  {
  	*inst = new BasicHandler();
  	
  	THandler* pTHandler = new THandler();
  	(*inst)->_functions = 0;
  	if (pTHandler)
  	{
  		(*inst)->_object = pTHandler;
  		return pTHandler->init();
  	}
  	
  	return AXIS_FAIL;
  }
  
  STORAGE_CLASS_INFO
  int DestroyInstance(BasicHandler *inst)
  {
  	if (inst)
  	{
  		Handler* pH = static_cast<Handler*>(inst->_object);
  		pH->fini();
  		delete pH;
  		delete inst;
  		return AXIS_SUCCESS;
  	}
  	return AXIS_FAIL;
  }
  
  }
  
  
  
  1.1                  ws-axis/c/tests/auto_build/testcases/output/TestSetHandlerProperty.expected
  
  Index: TestSetHandlerProperty.expected
  ===================================================================
  value of prop1 is = value1
  value of prop2 set in handler is = value2
  5
  value of prop2 printed in client is = value2
  ---------------- TEST COMPLETE ----------------
  
  
  
  1.1                  ws-axis/c/tests/auto_build/testcases/tests/TestSetHandlerProperty.xml
  
  Index: TestSetHandlerProperty.xml
  ===================================================================
  <test>
      <name>TestSetHandlerProperty</name>
      <description>CalculatorDoc with Handler and IMessageData->getProperty() when no property set</description>
      <clientLang>cpp</clientLang>
      <clientCode>TestSetHandlerPropertyClient.cpp</clientCode>
      <wsdl>CalculatorDoc.wsdl</wsdl>
      <expected>
          <output>
              TestSetHandlerProperty.expected
          </output>
      </expected>
      <handler>
          <directory>
              TestSetHandlerProperty
          </directory>
         <service>
             Calculator
         </service>
      </handler>
  	<endpoint>http://localhost:80/Calculator/services/Calculator</endpoint>
  </test>