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/01/14 18:21:22 UTC
cvs commit: ws-axis/c/tests/auto_build/testcases/handlers/handler_test15/testhandler THandler.cpp THandler.h TestHandler.cpp
perryan 2005/01/14 09:21:22
Added: c/tests/auto_build/testcases/handlers/handler_test11/testhandler
THandler.cpp THandler.h TestHandler.cpp
c/tests/auto_build/testcases/handlers/handler_test12/testhandler
THandler.cpp THandler.h TestHandler.cpp
c/tests/auto_build/testcases/handlers/handler_test13/testhandler
THandler.cpp THandler.h TestHandler.cpp
c/tests/auto_build/testcases/handlers/handler_test14/testhandler
THandler.cpp THandler.h TestHandler.cpp
c/tests/auto_build/testcases/handlers/handler_test15/testhandler2
THandler2.cpp THandler2.h TestHandler2.cpp
c/tests/auto_build/testcases/handlers/handler_test15/testhandler
THandler.cpp THandler.h TestHandler.cpp
Log:
New Handler API tests
Revision Changes Path
1.1 ws-axis/c/tests/auto_build/testcases/handlers/handler_test11/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 Andrew Perry (perryan@uk.ibm.com)
*
*****************************************************************************
* Test Logic.
* Create a SOAP Header block with the localname and URI specified in the
* constructor.
*
* Test success is measured by comparing the actual request with an expected
* request.
*****************************************************************************
*
*/
#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*/
} else {
/*this is a request*/
IHandlerSoapSerializer* pISZ;
pIMsg->getSoapSerializer(&pISZ);
IHeaderBlock* pIHeaderBlock= pISZ->createHeaderBlock("chbTest", "http://soapinterop.org/echoheader/");
const AxisChar* pachHeaderVal = "createHeaderBlock with localName and URI";
BasicNode* pBasicNode = pIHeaderBlock->createChild(CHARACTER_NODE);
pBasicNode->setValue(pachHeaderVal);
pIHeaderBlock->addChild(pBasicNode);
}
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/handler_test11/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.
* Add a SOAP header element
*
* Test success is measured by comparing the actual request with an expected
* resquest.
*****************************************************************************
*
*/
#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/handler_test11/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.
* Add a SOAP header element
*
* Test success is measured by comparing the actual request with an expected
* resquest.
*****************************************************************************
*
*/
//
//////////////////////////////////////////////////////////////////////
#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/handlers/handler_test12/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 Andrew Perry (perryan@uk.ibm.com)
*
*****************************************************************************
* Test Logic.
* Add an existing HeaderBlock to the SOAP Header
*
* Test success is measured by comparing the actual request with an expected
* request.
*****************************************************************************
*
*/
#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*/
} else {
/*this is a request*/
IHandlerSoapSerializer* pISZ;
pIMsg->getSoapSerializer(&pISZ);
IHeaderBlock* pIHeaderBlock = pISZ->createHeaderBlock("ahb", "http://soapinterop.org/axis/");
BasicNode* pBasicNode = pIHeaderBlock->createChild(CHARACTER_NODE);
pBasicNode->setValue("This is a test");
pIHeaderBlock->addChild(pBasicNode);
IHeaderBlock* pIHeaderBlock2 = pIHeaderBlock->clone();
pIHeaderBlock2->setLocalName("ahb2");
pIHeaderBlock2->setUri("http://soapinterop.org/axis2/");
BasicNode* pBasicNode2 = pIHeaderBlock2->createChild(CHARACTER_NODE);
pBasicNode2->setValue("Test2");
pIHeaderBlock2->addChild(pBasicNode2);
pISZ->addHeaderBlock(pIHeaderBlock2);
}
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/handler_test12/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.
* Add a SOAP header element in each handler in a handler chain.
*
* Test success is measured by comparing the actual request with an expected
* resquest.
*****************************************************************************
*
*
*/
#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/handler_test12/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.
* Add a SOAP header element in each handler in a handler chain.
*
* Test success is measured by comparing the actual request with an expected
* resquest.
*****************************************************************************
*
*
*/
//
//////////////////////////////////////////////////////////////////////
#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/handlers/handler_test13/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 Andrew Perry (perryan@uk.ibm.com)
*
*****************************************************************************
* Test Logic.
* Add an existing HeaderBlock to the SOAP Header
*
* Test success is measured by comparing the actual request with an expected
* request.
*****************************************************************************
*
*/
#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*/
} else {
/*this is a request*/
IHandlerSoapSerializer* pISZ;
pIMsg->getSoapSerializer(&pISZ);
IHeaderBlock* pIHeaderBlock = pISZ->createHeaderBlock("ahb", "http://soapinterop.org/axis/");
BasicNode* pBasicNode = pIHeaderBlock->createChild(CHARACTER_NODE);
IHeaderBlock* pIHeaderBlock2 = pIHeaderBlock->clone();
pBasicNode->setValue("This is a test");
pIHeaderBlock->addChild(pBasicNode);
pIHeaderBlock2->setLocalName("ahb2");
pIHeaderBlock2->setUri("http://soapinterop.org/axis2/");
BasicNode* pBasicNode2 = pIHeaderBlock2->createChild(CHARACTER_NODE);
pBasicNode2->setValue("Test2");
pIHeaderBlock2->addChild(pBasicNode2);
pISZ->addHeaderBlock(pIHeaderBlock2);
}
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/handler_test13/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.
* Add a SOAP header element in each handler in a handler chain.
*
* Test success is measured by comparing the actual request with an expected
* resquest.
*****************************************************************************
*
*
*/
#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/handler_test13/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.
* Add a SOAP header element in each handler in a handler chain.
*
* Test success is measured by comparing the actual request with an expected
* resquest.
*****************************************************************************
*
*
*/
//
//////////////////////////////////////////////////////////////////////
#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/handlers/handler_test14/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 Andrew Perry (perryan@uk.ibm.com)
*
*****************************************************************************
* Test Logic.
* Add a SOAP header element and set the SOAP Version
*
* Test success is measured by comparing the actual request with an expected
* resquest.
*****************************************************************************
*
*/
#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*/
} else {
/*this is a request*/
IHandlerSoapSerializer* pISZ;
pIMsg->getSoapSerializer(&pISZ);
pISZ->setSoapVersion(SOAP_VER_1_2);
IHeaderBlock* pIHeaderBlock= pISZ->createHeaderBlock();
pIHeaderBlock->setLocalName("echoMeString");
pIHeaderBlock->setUri("http://soapinterop.org/soapversion/");
const AxisChar* pachHeaderVal = "Soap Version Test";
BasicNode* pBasicNode = pIHeaderBlock->createChild(CHARACTER_NODE);
pBasicNode->setValue(pachHeaderVal);
pIHeaderBlock->addChild(pBasicNode);
}
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/handler_test14/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.
* Add a SOAP header element
*
* Test success is measured by comparing the actual request with an expected
* resquest.
*****************************************************************************
*
*/
#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/handler_test14/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.
* Add a SOAP header element
*
* Test success is measured by comparing the actual request with an expected
* resquest.
*****************************************************************************
*
*/
//
//////////////////////////////////////////////////////////////////////
#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/handlers/handler_test15/testhandler2/THandler2.cpp
Index: THandler2.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.
* Set a property in the request flow and get it in the response flow and
* make sure they are the same.
*
* 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 "THandler2.h"
#include <axis/GDefine.hpp>
#include <axis/IHandlerSoapSerializer.hpp>
#include <axis/IHandlerSoapDeSerializer.hpp>
#include <axis/BasicNode.hpp>
#include <iostream>
THandler2::THandler2()
{
m_pOption = NULL;
m_sEmpty = "";
}
THandler2::~THandler2()
{
}
const string& THandler2::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 THandler2::setOptionList(const map<string, string>* OptionList)
{
m_pOption = OptionList;
}
int THandler2::invoke(void *pvIMsg)
{
IMessageData *pIMsg = (IMessageData*) pvIMsg;
if(pIMsg->isPastPivot()) {
/*this is a response*/
} else {
/*this is a request*/
IHandlerSoapSerializer* pISZ;
// Get the IHandlerSoapSerializer from IMessageData
pIMsg->getSoapSerializer(&pISZ);
IHeaderBlock* pIHeaderBlock = pISZ->getFirstHeaderBlock();
printHeaderBlock(pIHeaderBlock, "getFirstHeaderBlock()");
pIHeaderBlock = pISZ->getNextHeaderBlock();
printHeaderBlock(pIHeaderBlock, "getNextHeaderBlock()");
pIHeaderBlock = pISZ->getNextHeaderBlock();
printHeaderBlock(pIHeaderBlock, "getNextHeaderBlock()");
pIHeaderBlock = pISZ->getNextHeaderBlock();
printHeaderBlock(pIHeaderBlock, "getNextHeaderBlock()");
pIHeaderBlock = pISZ->getHeaderBlock("hb2", "http://soapinterop.org/axis2/");
printHeaderBlock(pIHeaderBlock, "getHeaderBlock(\"hb2\", namespace)");
pIHeaderBlock = pISZ->getCurrentHeaderBlock();
printHeaderBlock(pIHeaderBlock, "getCurrentHeaderBlock()");
pIHeaderBlock = pISZ->getHeaderBlock("hb3", "http://soapinterop.org/axis3/");
printHeaderBlock(pIHeaderBlock, "getHeaderBlock(\"hb3\", namespace)");
pIHeaderBlock = pISZ->getHeaderBlock("hb1", "http://soapinterop.org/axis/");
printHeaderBlock(pIHeaderBlock, "getHeaderBlock(\"hb1\", namespace)");
pIHeaderBlock = pISZ->getFirstHeaderBlock();
printHeaderBlock(pIHeaderBlock, "getFirstHeaderBlock()");
pIHeaderBlock = pISZ->getCurrentHeaderBlock();
printHeaderBlock(pIHeaderBlock, "getCurrentHeaderBlock()");
pIHeaderBlock = pISZ->getNextHeaderBlock();
printHeaderBlock(pIHeaderBlock, "getNextHeaderBlock()");
pIHeaderBlock = pISZ->getCurrentHeaderBlock();
printHeaderBlock(pIHeaderBlock, "getCurrentHeaderBlock()");
}
return AXIS_SUCCESS;
}
void THandler2::printHeaderBlock(IHeaderBlock* pHb, const char* text) {
printf("%-32s - ", text);
if(pHb) {
int num_children = pHb->getNoOfChildren();
for(int cnt=1; cnt<=num_children; cnt++) {
BasicNode* pBn = pHb->getChild(cnt);
if(pBn) {
printf("%s:child(%d) - Value = %s\n", pHb->getLocalName(), cnt, pBn->getValue());
fflush(stdout);
}
}
} else {
printf("HeaderBlock is NULL\n");
}
}
void THandler2::onFault(void *pvIMsg)
{
}
int THandler2::init()
{
//do any initialization, resetting of values
return AXIS_SUCCESS;
}
int THandler2::fini()
{
//do any finalizatoin
return AXIS_SUCCESS;
}
1.1 ws-axis/c/tests/auto_build/testcases/handlers/handler_test15/testhandler2/THandler2.h
Index: THandler2.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.
* Set a struct as a property in the request in the second handler in a chain
* and get the property in the response message.
*
* 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(_THANDLER2_H____OF_AXIS_INCLUDED_)
#define _THANDLER2_H____OF_AXIS_INCLUDED_
#include <axis/Handler.hpp>
AXIS_CPP_NAMESPACE_USE
class THandler2 : 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);
THandler2();
virtual ~THandler2();
protected:
string m_sEmpty;
private:
void printHeaderBlock(IHeaderBlock* pHb, const char*);
};
#endif // !defined(_THANDLER2_H____OF_AXIS_INCLUDED_)
1.1 ws-axis/c/tests/auto_build/testcases/handlers/handler_test15/testhandler2/TestHandler2.cpp
Index: TestHandler2.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.
* Set a struct as a property in the request in the second handler in a chain
* and get the property in the response message.
*
* 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 "THandler2.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();
THandler2* pTHandler = new THandler2();
(*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/handlers/handler_test15/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 Andrew Perry (perryan@uk.ibm.com)
*
*****************************************************************************
* Test Logic.
* Add an existing HeaderBlock to the SOAP Header
*
* Test success is measured by comparing the actual request with an expected
* request.
*****************************************************************************
*
*/
#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*/
} else {
/*this is a request*/
IHandlerSoapSerializer* pISZ;
pIMsg->getSoapSerializer(&pISZ);
IHeaderBlock* pIHeaderBlock = pISZ->createHeaderBlock("hb1", "http://soapinterop.org/axis/");
BasicNode* pBasicNode = pIHeaderBlock->createChild(CHARACTER_NODE);
pBasicNode->setValue("Test1");
pIHeaderBlock->addChild(pBasicNode);
IHeaderBlock* pIHeaderBlock2 = pISZ->createHeaderBlock("hb2", "http://soapinterop.org/axis2/");
BasicNode* pBasicNode2 = pIHeaderBlock2->createChild(CHARACTER_NODE);
pBasicNode2->setValue("Test2");
pIHeaderBlock2->addChild(pBasicNode2);
IHeaderBlock* pIHeaderBlock3 = pISZ->createHeaderBlock("hb3", "http://soapinterop.org/axis3/");
BasicNode* pBasicNode3 = pIHeaderBlock3->createChild(CHARACTER_NODE);
pBasicNode3->setValue("Test3");
pIHeaderBlock3->addChild(pBasicNode3);
}
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/handler_test15/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.
* Add a SOAP header element in each handler in a handler chain.
*
* Test success is measured by comparing the actual request with an expected
* resquest.
*****************************************************************************
*
*
*/
#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/handler_test15/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.
* Add a SOAP header element in each handler in a handler chain.
*
* Test success is measured by comparing the actual request with an expected
* resquest.
*****************************************************************************
*
*
*/
//
//////////////////////////////////////////////////////////////////////
#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;
}
}