/*******************************************************************

Copyright (c) 2004 Open Mobile Alliance, Ltd.  All Rights Reserved.

This software is made available under the usage and distribution terms 
covered by the Common Public License 1.0 and by using this software you
are bound by the terms and conditions of the same.

EXCEPT AS EXPRESSLY SET FORTH IN THE COMMON PUBLIC LICENSE,
THIS PROGRAM IS PROVIDED ON AN "AS IS" BASIS, 
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 
EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, 
ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, 
MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
   
Each recipient is solely responsible for determining the 
appropriateness of using and distributing this program and assumes 
all risks associated with its exercise of rights under the Common 
Public License, including but not limited to the risks and 
costs of program errors, compliance with applicable laws, 
damage to or loss of data, programs or equipment, and 
unavailability or interruption of operations.

********************************************************************/

#include "SctsDevManTestClient.h"
#include "SctsDevManDevice.h"
#include "SctsDevManSession.h"
#include "SctsDevManNotificationSession.h"
#ifdef __SCTS_USING_SCTS__

/******************************************************************
SctsDMTestCase 1xxC Definition
******************************************************************/
/* -- Removed by DM 1.2 ETS. -- */
//void SctsDMTestCase101C::StateInitiatePreProcess()
//{
//	if (!testGroup->device->GetPassword(true))
//	{
//		SctsErrorLog::OpenNode("Test Case 202C.","Pre-conditions");
//		SctsErrorLog::AppendError("Password is not configured. Incoming password MUST be configured to pass this test.");
//		SctsErrorLog::CloseNode();	
//		state=NOT_TESTED;
//	}
//	else
//	{
//		testGroup->device->SetAuthType(true,AUTH_BASIC);
//		testGroup->device->SetNonce(false,0,0);
//		state=TEST_FAILED;
//	}
//	doneSIPreP=true;	
//}

//void SctsDMTestCase101C::StateInitiatePostProcess()
//{
//	if (state!=TEST_FAILED) return;
//	if (testGroup->session->sentSyncHdrStatus==200 || testGroup->session->sentSyncHdrStatus==212)
//	{
//		state=TEST_PASSED;
//		doneSIPostP=true;
//	}
//}

void SctsDMTestCase101C::StateInitiatePostProcess()
{
	state=TEST_FAILED;
	if (((SctsDMServerSession *)testGroup->session)->clientInitiatedAlert)
	{
		state=TEST_PASSED;
		doneSIPostP=true;
	}
}

void SctsDMTestCase102C::StateInitiatePostProcess()
{
	state=TEST_FAILED;
	if (((SctsDMServerSession *)testGroup->session)->receivedDevInfo)
	{
		state=TEST_PASSED;
		doneSIPostP=true;
	}
}

void SctsDMTestCase103C::StateInitiatePostProcess()
{
	state=TEST_FAILED;
	if (((SctsDMServerSession *)testGroup->session)->targetLocURI && testGroup->device)
	{
		SctsDMNode *node=((SctsDMServerDevice *)testGroup->device)->FindDMNode("./DevInfo/DevId");
		if (node && node->data && !sctsStrcmp((char *)node->data,((SctsDMServerSession *)testGroup->session)->targetLocURI)) state=TEST_PASSED;
	}
}
/******************************************************************
SctsDMTestCase 2xxC Definition
******************************************************************/
void SctsDMTestCase201C::StateInitiatePreProcess()
{
	unsigned char *nonce;
	unsigned int size;
	testGroup->device->SetAuthType(true,AUTH_MD5);
	if (!testGroup->device->GetPassword(true))
	{
		SctsErrorLog::OpenNode("Test Case 202C.","Pre-conditions");
		SctsErrorLog::AppendError("Password is not configured. Incoming password MUST be configured to pass this test.");
		SctsErrorLog::CloseNode();	
		state=NOT_TESTED;
		return;
	}
	nonce=testGroup->device->GetNonce(true,size);
	if (!nonce || !size) 
	{
		nonce=(unsigned char *)sctsMalloc(sizeof(unsigned char *));
		sctsMemcpy(nonce,&nonce,sizeof(unsigned char*));
		testGroup->device->SetNonce(true,(unsigned char *)nonce,sizeof(unsigned char *));
	}
	state=TEST_PASSED;
	doneSIPreP=true;
}

/******************************************************************
SctsDMTestCase 3xxC Definition
******************************************************************/

void SctsDMTestCase301C::StateInitiatePreProcess()
{
	unsigned char *nonce;
	unsigned int size;
	testGroup->device->SetAuthType(true,AUTH_MD5);
	nonce=testGroup->device->GetNonce(true,size);
	if (!nonce || !size) 
	{
		nonce=(unsigned char *)sctsMalloc(sizeof(unsigned char *));
		sctsMemcpy(nonce,&nonce,sizeof(unsigned char*));
		testGroup->device->SetNonce(true,(unsigned char *)nonce,sizeof(unsigned char *));
	}

	state=TEST_FAILED;
	doneSIPreP=true;
}

void SctsDMTestCase301C::StateInitiatePostProcess()
{
	if (state!=TEST_FAILED) return;
	if (testGroup->session->sentSyncHdrStatus==200 || testGroup->session->sentSyncHdrStatus==212)
	{
		state=TEST_PASSED;
		doneSIPostP=true;
	}
}

void SctsDMTestCase302C::StateManagePreBuild()
{
	int rc=((SctsDMServerDevice *)testGroup->device)->GetDMNode(".",SIDX,DMPROP_NONE,&cmdRef);
	if (rc>300)
	{
		char tempBuffer[300];
		SctsErrorLog::OpenNode("Test Case 302C.","Pre-conditions");
		sprintf(tempBuffer,"Could not issue a Get on the root node.SCTS internally received a status code of %d",rc);
		SctsErrorLog::AppendError(tempBuffer);
		SctsErrorLog::CloseNode();	
	}
	else
		state=TEST_FAILED;
	doneSMPreB=true;	
}

void SctsDMTestCase302C::StateTerminate()
{
	SctsDMNode *tempNode;
	char errorMsg[500];
	if (state!=TEST_FAILED || !cmdRef) return;
	state=TEST_PASSED;
	SctsErrorLog::OpenNode("Test Case 302C failed.",0);
	while (true)
	{
		if (cmdRef->status!=200)
		{
			state=TEST_FAILED;
			SctsErrorLog::OpenNode("Get failed.","Expecting a status of 200 for the Get.");
			sprintf(errorMsg,"Received a status of %d for Get on node %s (Message ID : %d, Command ID : %s).",cmdRef->status,cmdRef->nodeRef->name,cmdRef->msgRef,cmdRef->cmdRef);
			break;
		}		
		if (!cmdRef->data)
		{
			state=TEST_FAILED;
			SctsErrorLog::OpenNode("Did not receive Results from the Test Object for the Get sent by SCTS",0);
			sprintf(errorMsg,"Did not receive Results for the Get on node %s (Message ID : %d, Command ID : %s)",cmdRef->nodeRef->name,cmdRef->msgRef,cmdRef->cmdRef);
			break;
		}	
		tempNode=(SctsDMNode *)cmdRef->data;
		if (!tempNode && tempNode->format && tempNode->format!=cmdRef->nodeRef->format) 
		{			
			state=TEST_FAILED;
			SctsErrorLog::OpenNode("Invalid Results",0);
			sprintf(errorMsg,"The format in Results for a Get on node %s is not correct.",cmdRef->nodeRef->name);
			break;
		}
		if (!sctsStrstr((char *)tempNode->data,"DevDetail") || !sctsStrstr((char *)tempNode->data,"DevInfo")/* || !sctsStrstr((char *)tempNode->data,"SyncML") */)
		{
			state=TEST_FAILED;
			SctsErrorLog::OpenNode("Invalid Results",0);
			sprintf(errorMsg,"The Results on the Root node does not indicate support for mandatory objects.");
			break;
		}
		break;
	}
	if (state==TEST_FAILED)
	{
		SctsErrorLog::AppendError(errorMsg);
		SctsErrorLog::CloseNode();
	}
	SctsErrorLog::CloseNode();
}

void SctsDMTestCase303C::StateManagePreBuild()
{
	int rc=((SctsDMServerDevice *)testGroup->device)->GetDMNode("./DevDetail/URI/MaxDepth",SIDX,DMPROP_NONE,&cmdRef);
	state=TEST_FAILED;
	if (rc>300)
	{
		char tempBuffer[300];
		SctsErrorLog::OpenNode("Test Case 303C.","Pre-conditions");
		sprintf(tempBuffer,"Could not issue a Get on the node './DevDetail/URI/MaxDepth'.SCTS internally received a status code of %d",rc);
		SctsErrorLog::AppendError(tempBuffer);
		SctsErrorLog::CloseNode();	
		state=NOT_TESTED;
	}
	doneSMPreB=true;	
}

void SctsDMTestCase303C::StateTerminate()
{
	SctsDMNode *tempNode;
	char errorMsg[500];
	if (state!=TEST_FAILED || !cmdRef) return;
	state=TEST_PASSED;
	SctsErrorLog::OpenNode("Test Case 302C failed.",0);
	while (true)
	{
		if (cmdRef->status!=200)
		{
			state=TEST_FAILED;
			SctsErrorLog::OpenNode("Get failed.","Expecting a status of 200 for the Get.");
			sprintf(errorMsg,"Received a status of %d for Get on node %s (Message ID : %d, Command ID : %s).",cmdRef->status,cmdRef->nodeRef->name,cmdRef->msgRef,cmdRef->cmdRef);
			break;
		}		
		if (cmdRef->status==200 && !cmdRef->data)
		{
			state=TEST_FAILED;
			SctsErrorLog::OpenNode("Did not receive Results from the Test Object for the Get(s) sent by SCTS",0);
			sprintf(errorMsg,"Did not receive Results for the Get on node %s (Message ID : %d, Command ID : %s)",cmdRef->nodeRef->name,cmdRef->msgRef,cmdRef->cmdRef);
			break;
		}	
		tempNode=(SctsDMNode *)cmdRef->data;
		if (tempNode->format && tempNode->format!=cmdRef->nodeRef->format) 
		{
			state=TEST_FAILED;
			SctsErrorLog::OpenNode("Invalid Results",0);
			sprintf(errorMsg,"The format in Results for a Get on node %s is not correct.",cmdRef->nodeRef->name);
			break;
		}
		break;
	}
	if (state==TEST_FAILED)
	{
		SctsErrorLog::AppendError(errorMsg);
		SctsErrorLog::CloseNode();
	}
	SctsErrorLog::CloseNode();
}

void SctsDMTestCase304C::StateManagePreBuild()
{
	int rc;
	/* Add a new Node and issue a Get on it. */
	state=TEST_FAILED;
	((SctsDMServerDevice *)testGroup->device)->AddDMNode("./InvalidNode",SIDX,"null",0,0,0,0);
	rc=((SctsDMServerDevice *)testGroup->device)->GetDMNode("./InvalidNode",SIDX,DMPROP_NONE,&cmdRef);
	if (rc>300)
	{
		char tempBuffer[300];
		SctsErrorLog::OpenNode("Test Case 304C.","Pre-conditions");
		sprintf(tempBuffer,"Could not issue a Get on the Invalid node.SCTS internally generated a status code of %d",rc);
		SctsErrorLog::AppendError(tempBuffer);
		SctsErrorLog::CloseNode();	
		state=NOT_TESTED;
	}
	doneSMPreB=true;
}

void SctsDMTestCase304C::StateTerminate()
{
	if (state!=TEST_FAILED || !cmdRef) return;
	state=TEST_PASSED;
	if (cmdRef->status!=404)
	{
		char errorMsg[500];
		state=TEST_FAILED;
		SctsErrorLog::OpenNode("Test Case 304C failed.","Get on Invalid node failed.");
		sprintf(errorMsg,"Expecting a status of 404 for the Get on the Invalid node.Received a status of %d(Message ID : %d, Command ID : %s).",cmdRef->status,cmdRef->msgRef,cmdRef->cmdRef);
		SctsErrorLog::AppendError(errorMsg);
		SctsErrorLog::CloseNode();
	}
	if (cmdRef->nodeRef) ((SctsDMServerDevice *)testGroup->device)->DeleteDMNode("./InvalidNode",SIDX);	
}

/******************************************************************
SctsDMTestCase 4xxC Definition
******************************************************************/

void SctsDMTestCase401C::StateInitiatePreProcess()
{
	unsigned char *nonce;
	unsigned int size;
	testGroup->device->SetAuthType(true,AUTH_HMAC);
	nonce=testGroup->device->GetNonce(true,size);
	if (!nonce || !size) 
	{
		nonce=(unsigned char *)sctsMalloc(sizeof(unsigned char *));
		sctsMemcpy(nonce,&nonce,sizeof(unsigned char*));
		testGroup->device->SetNonce(true,(unsigned char *)nonce,sizeof(unsigned char *));
	}
	state=TEST_FAILED;
	doneSIPreP=true;
}

void SctsDMTestCase401C::StateInitiatePostProcess()
{
	if (testGroup->session->sentSyncHdrStatus==200 || testGroup->session->sentSyncHdrStatus==212)
	{
		state=TEST_PASSED;
		doneSIPostP=true;
	}
}

/******************************************************************
SctsDMTestCase 5xxC Definition
******************************************************************/

bool SctsDMTestCase501C::StatePreReq()
{
	/* Create user interaction alert to input the name of the leaf node to add */
	bool flag=false;
	std::list<char *> items;
	std::list<char *>::iterator it;
	char *nodeName;
	char buffer[500];
	int rc;
	do
	{
		items.clear();
		items.push_back("Enter the name of the interior node to be added.");
		(*componentUIC.interactionAlert)(flag?"Node already exists":"Test case pre-requisite",1102,items,-1,-1,-1,".",'T','A');
		nodeName=items.back();
		if (!sctsStrcmp(nodeName,"")) return false;
		sprintf(buffer,"%s/%s",testGroup->device->tester->testNode,nodeName);
		flag=((SctsDMServerDevice *)testGroup->device)->FindDMNode(buffer)!=0;
	} while (flag);
	if ((rc=((SctsDMServerDevice *)testGroup->device)->AddDMNode(buffer,SIDX,"node",false,0,0,0,0,&cmdRef))!=200)
	{
		sprintf(buffer,"Could not Add an interior node %s.SCTS internally generated a status code of %d",nodeName,rc);
		MessageBox(0,buffer,"Test Pre-Requisities",MB_ICONERROR);
		return false;
	}
	state=TEST_FAILED;
	return true;
}

void SctsDMTestCase501C::StateInitiatePreProcess()
{
	//testGroup->device->SetAuthType(true,AUTH_BASIC);
	testGroup->device->SetNonce(false,0,0);
	doneSIPreP=true;	
}

void SctsDMTestCase501C::StateManagePostProcess()
{
	char errorMsg[500];
	if (state!=TEST_FAILED || !cmdRef || !cmdRef->status) return;
	state=TEST_PASSED;
	switch (cmdRef->command)
	{
	case SCTS_ADD:
		{
			if (cmdRef->status!=200 && cmdRef->status!=405)
			{
				state=TEST_FAILED;
				SctsErrorLog::OpenNode("Test Case 501C failed.","Add failed.");
				sprintf(errorMsg,"Expecting a status of 200 or 405,received a status of %d for Add on node %s (Message ID : %d, Command ID : %s).",cmdRef->status,cmdRef->nodeRef->name,cmdRef->msgRef,cmdRef->cmdRef);													
			}
			if (cmdRef->status==405) state=NOT_SUPPORTED;
			if (cmdRef->status!=200)
			{
				SCTSASSERT(cmdRef->nodeRef);
				((SctsDMServerDevice *)testGroup->device)->DeleteDMNode(cmdRef->nodeRef,SIDX);
				cmdRef->nodeRef=0;		
				doneSMPostP=true;					
			}
			else
			{
				SctsDMCommand *command=new SctsDMCommand(SCTS_GET,cmdRef->nodeRef,DMPROP_NONE,true);
				((SctsDMServerDevice *)testGroup->device)->InsertCommand(command);
				cmdRef=command;		
				state=TEST_FAILED;
				cmdRef->status=0;					
				return;
			}
			break;
		}
	case SCTS_RESULTS:
		{
			if (cmdRef->status!=200)
			{
				state=TEST_FAILED;
				SctsErrorLog::OpenNode("Test Case 501C failed.","Get failed.");
				sprintf(errorMsg,"Expecting a status of 200, received a status of %d for Get on node %s (Message ID : %d, Command ID : %s).",cmdRef->status,cmdRef->nodeRef->name,cmdRef->msgRef,cmdRef->cmdRef);					
				break;
			}
			doneSMPostP=true;
			break;
		}
	default:
		{
			state=TEST_FAILED;
			SctsErrorLog::OpenNode("Test Case 501C failed.","Invalid command");
			sprintf(errorMsg,"Not Expecting Command %s, (Message ID : %d, Command ID : %s)",sctsCommandStrings[cmdRef->command],cmdRef->msgRef,cmdRef->cmdRef);				
			break;
		}
	};
	if (state==TEST_FAILED)
	{
		doneSMPostP=true;
		SctsErrorLog::AppendError(errorMsg);
		SctsErrorLog::CloseNode();
		if (state==TEST_FAILED && cmdRef->nodeRef)
		if (cmdRef->nodeRef) ((SctsDMServerDevice *)testGroup->device)->DeleteDMNode(cmdRef->nodeRef,SIDX);
	}
}


bool SctsDMTestCase502C::StatePreReq()
{
	/* Create user interaction alert to input the name of the leaf node to add */
	bool flag=false;
	std::list<char *> items;
	char *nodeName;
	char buffer[500];
	int rc;
	do
	{
		items.clear();
		items.push_back("Enter the name of the leaf node to be added.");
		(*componentUIC.interactionAlert)(flag?"Node already exists":"Test case pre-requisite",1102,items,-1,-1,-1,".",'T','A');
		nodeName=items.back();
		if (!sctsStrcmp(nodeName,"")) return false;
		sprintf(buffer,"%s/%s",testGroup->device->tester->testNode,nodeName);
		flag=((SctsDMServerDevice *)testGroup->device)->FindDMNode(buffer)!=0;
	} while (flag);
	testGroup->device->tester->leaftestNode=sctsStrdup(nodeName);
	sprintf(buffer,"%s/%s",testGroup->device->tester->testNode,testGroup->device->tester->leaftestNode);
	if ((rc=((SctsDMServerDevice *)testGroup->device)->AddDMNode(buffer,SIDX,"chr",false,"Hello DevMan","text/plain",12,0,&cmdRef))!=200)
	{
		sprintf(buffer,"Could not Add node %s under %s.SCTS internally generated a status code of %d",testGroup->device->tester->leaftestNode,testGroup->device->tester->testNode,rc);
		MessageBox(0,buffer,"Test Pre-Requisities",MB_ICONERROR);
		return false;
	}
	state=TEST_FAILED;
	return true;
}

void SctsDMTestCase502C::StateManagePostProcess()
{
	char errorMsg[500];
	if (state!=TEST_FAILED || !cmdRef || !cmdRef->status) return;
	state=TEST_PASSED;
	switch(cmdRef->command)
	{
	case SCTS_ADD:
		{
			if (cmdRef->status!=200 && cmdRef->status!=405) 
			{
				state=TEST_FAILED;
				SctsErrorLog::OpenNode("Test Case 502C failed.","Add failed.");
				sprintf(errorMsg,"Expecting a status of 200 or 405, received a status of %d for Add on node %s (Message ID : %d, Command ID : %s).",cmdRef->status,cmdRef->nodeRef->name,cmdRef->msgRef,cmdRef->cmdRef);
				break;
			}
			if (cmdRef->status==405) state=NOT_SUPPORTED;
			if (cmdRef->status!=200)
			{
				SCTSASSERT(cmdRef->nodeRef);
				((SctsDMServerDevice *)testGroup->device)->DeleteDMNode(cmdRef->nodeRef,SIDX);
				cmdRef->nodeRef=0;		
				doneSMPostP=true;
			}
			else
			{
				SctsDMCommand *command=new SctsDMCommand(SCTS_GET,cmdRef->nodeRef,DMPROP_NONE,true);
				((SctsDMServerDevice *)testGroup->device)->InsertCommand(command);
				cmdRef=command;		
				cmdRef->status=0;
				state=TEST_FAILED;
				return;
			}
			break;
		}
	case SCTS_RESULTS:	
		{
			if (cmdRef->status!=200)
			{
				state=TEST_FAILED;
				SctsErrorLog::OpenNode("Test Case 502C failed.","Get failed.");
				sprintf(errorMsg,"Expecting a status of 200, received a status of %d for Get on node %s (Message ID : %d, Command ID : %s).",cmdRef->status,cmdRef->nodeRef->name,cmdRef->msgRef,cmdRef->cmdRef);
				break;
			}
			if (!cmdRef->data)
			{
				state=TEST_FAILED;
				SctsErrorLog::OpenNode("Test Case 502C failed.","Did not receive Results for the Get.");
				sprintf(errorMsg,"Did not receive Results for the Get on node %s (Message ID : %d, Command ID : %s)",cmdRef->nodeRef->name,cmdRef->msgRef,cmdRef->cmdRef);
				break;
			}
			SctsDMNode *resultsNode=(SctsDMNode *)cmdRef->data;
			if (resultsNode->format!=cmdRef->nodeRef->format)
			{
				state=TEST_FAILED;
				SctsErrorLog::OpenNode("Test Case 502C failed.","Format incorrect in the Results");
				sprintf(errorMsg,"Did not receive valid format in the Results for the Get on node %s, expected format %s, (Message ID : %d, Command ID : %s)",cmdRef->nodeRef->name,SctsDMFormatString[cmdRef->nodeRef->format],cmdRef->msgRef,cmdRef->cmdRef);
			}
			doneSMPostP=true;
			break;
		}
		default:
		{
			state=TEST_FAILED;
			SctsErrorLog::OpenNode("Test Case 502C failed.","Invalid command");
			sprintf(errorMsg,"Did not receive valid format in the Results for the Get on node %s, expected format %s, (Message ID : %d, Command ID : %s)",cmdRef->nodeRef->name,SctsDMFormatString[cmdRef->nodeRef->format],cmdRef->msgRef,cmdRef->cmdRef);				
			break;
		}
	};
	if (state==TEST_FAILED)
	{
		doneSMPostP=true;
		SctsErrorLog::AppendError(errorMsg);
		SctsErrorLog::CloseNode();
	}	
}

void SctsDMTestCase503C::StateManagePreBuild()
{
	SctsDMTestCase *testcase=0;
	SctsDMNode *tempNode;
	char buffer[500];
	testcase=(*testGroup->testCases.begin());
	if (testcase->GetState()!=NOT_SUPPORTED) state=NOT_SUPPORTED;
	if (testcase->GetState()!=TEST_PASSED) return;
	sprintf(buffer,"%s/%s",testGroup->device->tester->testNode,testGroup->device->tester->leaftestNode);
	tempNode=((SctsDMServerDevice *)testGroup->device)->FindDMNode(buffer);
	if (!tempNode) 
	{
		doneSMPreB=true;
		return;
	}
	SctsDMCommand *command=new SctsDMCommand(SCTS_ADD,tempNode,DMPROP_NONE,false);
	((SctsDMServerDevice *)testGroup->device)->InsertCommand(command);
	cmdRef=command;
	cmdRef->nodeRef=tempNode;
	state=TEST_FAILED;
	doneSMPreB=true;
}

void SctsDMTestCase503C::StateManagePostProcess()
{
	char errorMsg[500];
	if (state!=TEST_FAILED || !cmdRef) return;
	state=TEST_PASSED;
	if (cmdRef->status!=418)
	{
		state=TEST_FAILED;
		SctsErrorLog::OpenNode("Test Case 503C failed.","Get failed.");
		sprintf(errorMsg,"Expecting a status of 418, received a status of %d for Get on node %s (Message ID : %d, Command ID %s).",cmdRef->status,cmdRef->nodeRef->name,cmdRef->msgRef,cmdRef->cmdRef);
		SctsErrorLog::AppendError(errorMsg);
		SctsErrorLog::CloseNode();
	}
	doneSMPostP=true;
}

/******************************************************************
SctsDMTestCase 6xxC Definition
******************************************************************/

bool SctsDMTestCase601C::StatePreReq()
{
	SctsDMNode *node,*child;
	char buffer[200];
	int rc;
	state=TEST_FAILED;
	std::list<char *> items;
	node=((SctsDMServerDevice *)testGroup->device)->FindDMNode(testGroup->device->tester->testNode);
	items.push_back("Select the node to be replaced.");
	for (child=node->child;child;child=child->next)
	{ 
		if (child->format!=DMFORMAT_NODE) items.push_back(child->name);
	}
	if (items.size()==1)
	{
		sprintf(buffer,"There are no leaf nodes under the currently configured test node '%s'.",testGroup->device->tester->testNode);
		MessageBox(0,buffer,"Test Pre-Requisities",MB_ICONERROR);
		return false;
	}
	(*componentUIC.interactionAlert)("Test case pre-requisite",1103,items,-1,-1,-1,0,0,0);
	rc=atoi(items.front());
	child=node->child;
	do
	{
		if (child->format!=DMFORMAT_NODE) --rc;
		if (rc) child=child->next;
	} while (rc);
	if ((rc=((SctsDMServerDevice *)testGroup->device)->ReplaceDMNodeData(child,SIDX,"GoodBye DevMan",14,"chr","text/plain",&cmdRef))!=200)
	{
		sprintf(buffer,"Could not insert replace on the node %s/%s. SCTS internally generated a status code of %d.",testGroup->device->tester->testNode,child->name,rc);
		MessageBox(0,buffer,"Test Pre-Requisities",MB_ICONERROR);
		return false;
	}
	state=TEST_FAILED;
	return true;
}

void SctsDMTestCase601C::StateManagePostProcess()
{
	char errorMsg[500];
	if (state!=TEST_FAILED || !cmdRef || !cmdRef->status) return;
	state=TEST_PASSED;
	if (cmdRef->status!=200)
	{
		state=TEST_FAILED;
		SctsErrorLog::OpenNode("Test Case 601C failed.","Replace failed.");
		sprintf(errorMsg,"Expecting a status of 200, received a status of %d for Replace on node %s (Message ID : %d, Command ID : %s).",cmdRef->status,cmdRef->nodeRef->name,cmdRef->msgRef,cmdRef->cmdRef);
		SctsErrorLog::AppendError(errorMsg);
		SctsErrorLog::CloseNode();								
		doneSMPostP=true;
	}
}
	
void SctsDMTestCase602C::StateManagePreBuild()
{
	/* Add a new node, which does not exist on the client called InvalidNode,
	   Issue a Replace on this new node. */
	char buffer[100];
	sctsStrcpy(buffer,"./InvalidNode");
	((SctsDMServerDevice *)testGroup->device)->AddDMNode(buffer,SIDX,"chr",false,"Invalid Node",0,12,0,0);
	((SctsDMServerDevice *)testGroup->device)->ReplaceDMNodeData(buffer,SIDX,"Replace on non-existant node.",29,"chr",0,&cmdRef);
	state=TEST_FAILED;
	doneSMPreB=true;
}

void SctsDMTestCase602C::StateManagePostProcess()
{
	if (state!=TEST_FAILED || !cmdRef || !cmdRef->status) return;
	if (cmdRef->command==SCTS_REPLACE)
	{
		if (cmdRef->status!=404)
		{
			char errorMsg[500];
			SctsErrorLog::OpenNode("Test Case 602C failed.","Replace on non-existant node.");
			sprintf(errorMsg,"Expecting a status of 404 for the Replace on the non-existant node.Received a status of %d(Message ID : %d, Command ID : %s).",cmdRef->status,cmdRef->msgRef,cmdRef->cmdRef);
			SctsErrorLog::AppendError(errorMsg);
			SctsErrorLog::CloseNode();
			doneSMPostP=true;
			((SctsDMServerDevice *)testGroup->device)->DeleteDMNode("./InvalidNode",SIDX);
			return;
		}
		SctsDMCommand *command=new SctsDMCommand(SCTS_GET,cmdRef->nodeRef);
		cmdRef->nodeRef=0;
		cmdRef=command;
		((SctsDMServerDevice *)testGroup->device)->InsertCommand(command);
		return;
	}
	state=TEST_PASSED;
	if (cmdRef->command==SCTS_GET)
	{
		if (cmdRef->status!=404)
		{
			char errorMsg[500];
			state=TEST_FAILED;
			SctsErrorLog::OpenNode("Test Case 602C failed.","Get on non-existant node.");
			sprintf(errorMsg,"Expecting a status of 404 for the Get on the non-existant node.Received a status of %d(Message ID : %d, Command ID : %s).",cmdRef->status,cmdRef->msgRef,cmdRef->cmdRef);
			SctsErrorLog::AppendError(errorMsg);
			SctsErrorLog::CloseNode();			
		}
	}
}

void SctsDMTestCase602C::StateTerminate()
{
	((SctsDMServerDevice *)testGroup->device)->DeleteDMNode("./InvalidNode",SIDX);
}
/******************************************************************
SctsDMTestCase 7xxC Definition
******************************************************************/

bool SctsDMTestCase701C::StatePreReq()
{
	char buffer[300];
	SctsDMNode *node,*child;
	int rc;
	std::list<char *> items;
	node=((SctsDMServerDevice *)testGroup->device)->FindDMNode(testGroup->device->tester->testNode);
	items.push_back("Select the node to be replaced.");
	for (child=node->child;child;child=child->next)
	{ 
		if (child->format!=DMFORMAT_NODE) items.push_back(child->name);
	}
	if (items.size()==1)
	{
		sprintf(buffer,"There are no leaf nodes under the currently configured test node '%s'.",testGroup->device->tester->testNode);
		MessageBox(0,buffer,"Test Pre-Requisities",MB_ICONERROR);
		return false;
	}
	(*componentUIC.interactionAlert)("Test case pre-requisite",1103,items,-1,-1,-1,0,0,0);
	rc=atoi(items.front());
	child=node->child;
	do
	{
		if (child->format!=DMFORMAT_NODE) --rc;
		if (rc) child=child->next;
	} while (rc);
	
	cmdRef=new SctsDMCommand(SCTS_SEQUENCE_START);
	((SctsDMServerDevice *)testGroup->device)->InsertCommand(cmdRef);
	if ((rc=((SctsDMServerDevice *)testGroup->device)->ReplaceDMNodeData(child,SIDX,"New Data",8,"chr",0,&command1))!=200)
	{
		sprintf(buffer,"Could not insert replace on the node %s/%s. SCTS internally generated a status code of %d.",testGroup->device->tester->testNode,child->name,rc);
		MessageBox(0,buffer,"Test Pre-Requisities",MB_ICONERROR);
		return false;
	}
	if ((rc=((SctsDMServerDevice *)testGroup->device)->GetDMNode(child,SIDX,DMPROP_NONE,&command2))!=200)
	{
		sprintf(buffer,"Could not insert Get on the node %s/%s. SCTS internally generated a status code of %d.",testGroup->device->tester->testNode,child->name,rc);
		MessageBox(0,buffer,"Test Pre-Requisities",MB_ICONERROR);
		return false;
	}
	((SctsDMServerDevice *)testGroup->device)->InsertCommand(new SctsDMCommand(SCTS_SEQUENCE_END)); 
	state=TEST_FAILED;
	return true;	
}

void SctsDMTestCase701C::StateManagePostProcess()
{
	char errorMsg[500];
	if (state!=TEST_FAILED  || !cmdRef || !cmdRef->status) return;
	if (cmdRef->status!=200)
	{
		SctsErrorLog::OpenNode("Test Case 701C failed.","Sequence");
		sprintf(errorMsg,"Expecting a status of 200 for the Sequence.Received a status of %d(Message ID : %d, Command ID : %s).",cmdRef->status,cmdRef->msgRef,cmdRef->cmdRef);
		SctsErrorLog::AppendError(errorMsg);
		SctsErrorLog::CloseNode();			
		doneSMPostP=true;
		return;
	}
	if (command1->status!=200)
	{
		SctsErrorLog::OpenNode("Test Case 701C failed.","Replace");
		sprintf(errorMsg,"Expecting a status of 200 for the Replace.Received a status of %d(Message ID : %d, command1 ID : %s).",command1->status,command1->msgRef,command1->cmdRef);
		SctsErrorLog::AppendError(errorMsg);
		SctsErrorLog::CloseNode();			
		doneSMPostP=true;
		return;
	}
	if (command2->status!=200)
	{
		SctsErrorLog::OpenNode("Test Case 701C failed.","Get");
		sprintf(errorMsg,"Expecting a status of 200 for the Delete.Received a status of %d(Message ID : %d, command2 ID : %s).",command2->status,command2->msgRef,command2->cmdRef);
		SctsErrorLog::AppendError(errorMsg);
		SctsErrorLog::CloseNode();			
		doneSMPostP=true;
		return;
	}	
	if (!command2->data || !((SctsDMNode *)command2->data)->data)
	{
		SctsErrorLog::OpenNode("Test Case 701C failed.","Get");
		SctsErrorLog::AppendError("Did not receive valid results for the Get");
		SctsErrorLog::CloseNode();			
		doneSMPostP=true;
		return;
	}
	if (sctsStrcmp((char *)((SctsDMNode *)command2->data)->data,"New Data"))
	{
		SctsErrorLog::OpenNode("Test Case 701C failed.","Get");
		SctsErrorLog::AppendError("Did not receive valid results for the Get");
		SctsErrorLog::CloseNode();			
		doneSMPostP=true;
		return;
	}
	state=TEST_PASSED;
	doneSMPostP=true;
}

/******************************************************************
SctsDMTestCase 8xxC Definition
******************************************************************/

bool SctsDMTestCase801C::StatePreReq()
{
	char **data;
	SctsDMNode *node,*child;
	char buffer[300];
	int rc;
	std::list<char *> items;
	node=((SctsDMServerDevice *)testGroup->device)->FindDMNode(testGroup->device->tester->testNode);
	items.push_back("Select the node to be replaced.");
	for (child=node->child;child;child=child->next)
	{ 
		if (child->format!=DMFORMAT_NODE) items.push_back(child->name);
	}
	if (items.size()==1)
	{
		sprintf(buffer,"There are no leaf nodes under the currently configured test node '%s'.",testGroup->device->tester->testNode);
		MessageBox(0,buffer,"Test Pre-Requisities",MB_ICONERROR);
		return false;
	}
	(*componentUIC.interactionAlert)("Test case pre-requisite",1103,items,-1,-1,-1,0,0,0);
	rc=atoi(items.front());
	child=node->child;
	do
	{
		if (child->format!=DMFORMAT_NODE) --rc;
		if (rc) child=child->next;
	} while (rc);

	((SctsDMServerDevice *)testGroup->device)->InsertCommand(new SctsDMCommand(SCTS_SEQUENCE_START));
	cmdRef=new SctsDMCommand(SCTS_ALERT);
	data=(char **)sctsMalloc(sizeof(char *)*3);
	data[0]=(char *)1101;
	sprintf(buffer,"Replace data of node: %s/%s?",testGroup->device->tester->testNode,child->name);
	data[1]=(char *)sctsStrdup("MAXDT=10");
	data[2]=(char *)sctsStrdup(buffer);
	cmdRef->data=data;
	cmdRef->size=3;
	((SctsDMServerDevice *)testGroup->device)->InsertCommand(cmdRef);

	if ((rc=((SctsDMServerDevice *)testGroup->device)->ReplaceDMNodeData(child,SIDX,"New data",8,"chr",0,&command))!=200)
	{
		sprintf(buffer,"Could not Replace data of Node %s/%s.SCTS internally generated a status code of %d.",testGroup->device->tester->testNode,child->name,rc);
		MessageBox(0,buffer,"Test Pre-Requisities",MB_ICONERROR);
		return false;
	}
	command->reusable=false;
	((SctsDMServerDevice *)testGroup->device)->InsertCommand(new SctsDMCommand(SCTS_SEQUENCE_END));
	state=TEST_FAILED;
	return true;
}

void SctsDMTestCase801C::StateTerminate()
{
	char errorMsg[300];
	if (state!=TEST_FAILED || !cmdRef) return;
	state=TEST_PASSED;
	if (cmdRef->status!=200 && cmdRef->status!=406)
	{
		state=TEST_FAILED;
		SctsErrorLog::OpenNode("Test Case 801C failed.","User Interaction Alert.");
		sprintf(errorMsg,"Expecting a status of 200/406, received a status of %d for User Interaction Alert (Message ID : %d, Command ID : %s).",cmdRef->status,cmdRef->msgRef,cmdRef->cmdRef);
		SctsErrorLog::AppendError(errorMsg);
		SctsErrorLog::CloseNode();		
		return;
	}	
	if (cmdRef->status==406) state=NOT_SUPPORTED;
	if (command->status!=200 && command->status!=215)
	{
		state=TEST_FAILED;
		SctsErrorLog::OpenNode("Test Case 801C failed.","User Interaction Alert.");
		sprintf(errorMsg,"Expecting a status of 200/215 on the Replace inside sequence,received a status of %d (Message ID : %d, Command ID : %s).",command->status,command->msgRef,command->cmdRef);
		SctsErrorLog::AppendError(errorMsg);
		SctsErrorLog::CloseNode();		
	}	
}
	
bool SctsDMTestCase802C::StatePreReq()
{
	int rc;
	char **data;
	SctsDMNode *node,*child;
	char buffer[300];
	std::list<char *> items;
	node=((SctsDMServerDevice *)testGroup->device)->FindDMNode(testGroup->device->tester->testNode);
	items.push_back("Select the node to be replaced.");
	for (child=node->child;child;child=child->next)
	{ 
		if (child->format!=DMFORMAT_NODE) items.push_back(child->name);
	}
	if (items.size()==1)
	{
		sprintf(buffer,"There are no leaf nodes under the currently configured test node '%s'.",testGroup->device->tester->testNode);
		MessageBox(0,buffer,"Test Pre-Requisities",MB_ICONERROR);
		return false;
	}
	(*componentUIC.interactionAlert)("Test case pre-requisite",1103,items,-1,-1,-1,0,0,0);
	rc=atoi(items.front());
	child=node->child;
	do
	{
		if (child->format!=DMFORMAT_NODE) --rc;
		if (rc) child=child->next;
	} while (rc);
	
	((SctsDMServerDevice *)testGroup->device)->InsertCommand(new SctsDMCommand(SCTS_SEQUENCE_START));
	cmdRef=new SctsDMCommand(SCTS_ALERT);
	data=(char **)sctsMalloc(sizeof(char *)*3);
	data[0]=(char *)1101;
	data[1]=(char *)sctsStrdup("MAXDT=10");
	sprintf(buffer,"Replace data of node: %s/%s",testGroup->device->tester->testNode,child->name);
	data[2]=(char *)sctsStrdup(buffer);
	cmdRef->data=data;
	cmdRef->size=3;
	((SctsDMServerDevice *)testGroup->device)->InsertCommand(cmdRef);
	if ((rc=((SctsDMServerDevice *)testGroup->device)->ReplaceDMNodeData(child,SIDX,"New data",8,"chr",0,&command))!=200)
	{
		sprintf(buffer,"Could not Replace data of Node %s/%s.SCTS internally generated a status code of %d.",testGroup->device->tester->testNode,child->name,rc);
		MessageBox(0,buffer,"Test Pre-Requisities",MB_ICONERROR);
		return false;
	}
	((SctsDMServerDevice *)testGroup->device)->InsertCommand(new SctsDMCommand(SCTS_SEQUENCE_END));	
	state=TEST_FAILED;
	return true;
}

void SctsDMTestCase802C::StateTerminate()
{
	char errorMsg[300];
	if (state!=TEST_FAILED  || !cmdRef) return;
	state=TEST_PASSED;
	if (cmdRef->status!=304 )
	{
		state=TEST_FAILED;
		SctsErrorLog::OpenNode("Test Case 802C failed.","User Interaction Alert.");
		sprintf(errorMsg,"Expecting a status of 304, received a status of %d for User Interaction Alert (Message ID : %d, Command ID : %s).",cmdRef->status,cmdRef->msgRef,cmdRef->cmdRef);
		SctsErrorLog::AppendError(errorMsg);
		SctsErrorLog::CloseNode();		
		return;
	}	
	if (command->status!=215)
	{
		state=TEST_FAILED;
		SctsErrorLog::OpenNode("Test Case 802C failed.","User Interaction Alert.");
		sprintf(errorMsg,"Expecting a status of 215 on the Replace inside sequence,received a status of %d (Message ID : %d, Command ID : %s).",command->status,command->msgRef,command->cmdRef);
		SctsErrorLog::AppendError(errorMsg);
		SctsErrorLog::CloseNode();		
	}	
}

/******************************************************************
SctsDMTestCase 9xxC Definition
******************************************************************/

bool SctsDMTestCase901C::StatePreReq()
{
	SctsDMNode *node,*child;
	char buffer[300];
	int rc;
	std::list<char *> items;
	node=((SctsDMServerDevice *)testGroup->device)->FindDMNode(testGroup->device->tester->testNode);
	items.push_back("Select the interior node to be deleted.");
	for (child=node->child;child;child=child->next)
	{ 
		if (child->format==DMFORMAT_NODE) items.push_back(child->name);
	}
	if (items.size()==1)
	{
		sprintf(buffer,"There are no nodes interior nodes configured under test node '%s'.",testGroup->device->tester->testNode);
		MessageBox(0,buffer,"Test Pre-Requisities",MB_ICONERROR);
		return false;
	}
	(*componentUIC.interactionAlert)("Test case pre-requisite",1103,items,-1,-1,-1,0,0,0);
	rc=atoi(items.front());
	child=node->child;
	do
	{
		if (child->format==DMFORMAT_NODE) --rc;
		if (rc) child=child->next;
	} while (rc);
	
	if ((rc=((SctsDMServerDevice *)testGroup->device)->DeleteDMNode(child,SIDX,&cmdRef))!=200)
	{
		sprintf(buffer,"Could not insert delete on the interior node.SCTS internally generated a status code of %d,",rc);
		MessageBox(0,buffer,"Test Pre-Requisities",MB_ICONERROR);
		return false;
	}
	state=TEST_FAILED;
	return true;
}

void SctsDMTestCase901C::StateTerminate()	
{
	char errorMsg[500];
	if (state!=TEST_FAILED || !cmdRef) return;
	state=TEST_PASSED;
	if (cmdRef->status && cmdRef->status!=200 && cmdRef->status!=406)
	{
		state=TEST_FAILED;
		SctsErrorLog::OpenNode("Test Case 901C failed.","Delete on a interior node failed.");
		sprintf(errorMsg,"Expecting a status of 200/406, received a status of %d for Delete on node %s (Message ID : %d, Command ID : %s).",cmdRef->status,cmdRef->nodeRef->name,cmdRef->msgRef,cmdRef->cmdRef);
		SctsErrorLog::AppendError(errorMsg);
		SctsErrorLog::CloseNode();								
	}
	if (cmdRef->status==406) state=NOT_SUPPORTED;
	if (cmdRef->status!=200 && cmdRef->nodeRef) 
	{
		cmdRef->RollBack();
		if (((SctsDMServerDevice *)testGroup->device)->uiCallback) (*((SctsDMServerDevice *)testGroup->device)->uiCallback)((SctsDMTree *)(SctsDMServerDevice *)testGroup->device,cmdRef->nodeRef,SCTS_ADD);
	}
}

bool SctsDMTestCase902C::StatePreReq()
{
	char buffer[100];
	int rc;
	sctsStrcpy(buffer,"./InvalidNode");
	((SctsDMServerDevice *)testGroup->device)->AddDMNode(buffer,SIDX,"node",false,0,0,0);
	if ((rc=((SctsDMServerDevice *)testGroup->device)->DeleteDMNode(buffer,SIDX,&cmdRef))!=200)
	{
		sprintf(buffer,"Could not insert delete on the invalid node.SCTS internally generated a status code of %d,",rc);
		MessageBox(0,buffer,"Test Pre-Requisities",MB_ICONERROR);
		return false;
	}
	state=TEST_FAILED;
	return true;
}

void SctsDMTestCase902C::StateTerminate()
{
	if (state!=TEST_FAILED || !cmdRef) return;
	state=TEST_PASSED;
	if (cmdRef->status!=404 && cmdRef->status!=406)
	{
		char errorMsg[500];
		state=TEST_FAILED;
		SctsErrorLog::OpenNode("Test Case 902C failed.","Delete on Invalid node failed.");
		sprintf(errorMsg,"Expecting a status of 404/406, received a status of %d for Delete on node %s (Message ID : %d, Command ID : %s).",cmdRef->status,cmdRef->nodeRef->name,cmdRef->msgRef,cmdRef->cmdRef);
		SctsErrorLog::AppendError(errorMsg);
		SctsErrorLog::CloseNode();
	}		
	if (cmdRef->status==406) state=NOT_SUPPORTED;
	if (cmdRef->nodeRef) ((SctsDMServerDevice *)testGroup->device)->DeleteDMNode(cmdRef->nodeRef,SIDX);
}

bool SctsDMTestCase903C::StatePreReq()
{
	cmdRef=new SctsDMCommand(SCTS_DELETE,((SctsDMServerDevice *)testGroup->device)->root,DMPROP_NONE);
	((SctsDMServerDevice *)testGroup->device)->InsertCommand(cmdRef);
	state=TEST_FAILED;
	return true;
}

void SctsDMTestCase903C::StateTerminate()		
{
	if (state!=TEST_FAILED || !cmdRef) return;
	state=TEST_PASSED;
	if (cmdRef->status!=405 && cmdRef->status!=406)
	{
		char errorMsg[900];
		state=TEST_FAILED;
		SctsErrorLog::OpenNode("Test Case 903C failed.","Delete on Root node.");
		sprintf(errorMsg,"Received a status of %d for Delete on node %s, expecting status 405/406 (Message ID : %d, Command ID : %s).",cmdRef->status,cmdRef->nodeRef->name,cmdRef->msgRef,cmdRef->cmdRef);
		SctsErrorLog::AppendError(errorMsg);
		SctsErrorLog::CloseNode();
	}		
	if (cmdRef->status==406) state=NOT_SUPPORTED;
}


/******************************************************************
SctsDMTestCase 10xxC Definition
******************************************************************/

void SctsDMTestCase1001C::StateInitiatePreBuild()
{
	if (!((SctsDMServerSession *)testGroup->session)->maxMsgSize || ((SctsDMServerSession *)testGroup->session)->maxMsgSize>10000)
		((SctsDMServerSession *)testGroup->session)->maxMsgSize=5000;
	doneSIPreB=true;
}

void SctsDMTestCase1001C::StateManagePreBuild()
{
	int count=0;

	if (testGroup->session->encoding==XML)
		count=((SctsDMServerSession *)testGroup->session)->maxMsgSize/80;
	else
		count=((SctsDMServerSession *)testGroup->session)->maxMsgSize/25;

	while (count--)
		((SctsDMServerDevice *)testGroup->device)->GetDMNode("./DevDetail/URI",SIDX,DMPROP_NONE,&cmdRef);	
	state=TEST_FAILED;
	doneSMPreB=true;
}

void SctsDMTestCase1001C::StateTerminate()
{
	if (((SctsDMServerSession *)testGroup->session)->IsSuccessful())
		state=TEST_PASSED;
}

/******************************************************************
SctsDMTestCase 11xxC Definition
******************************************************************/

bool SctsDMTestCase1101C::StatePreReq()
{
	bool flag=false;
	std::list<char *> items;
	char *nodeName;
	char buffer[500];
	int rc;
	command=0;
	command1=0;
	/* Insert Atomic */
	cmdRef=new SctsDMCommand(SCTS_ATOMIC_START);
	((SctsDMServerDevice *)testGroup->device)->InsertCommand(cmdRef);
	/* Insert a Add on new node */
		/* Create user interaction alert to input the name of the leaf node to add */
	do
	{
		items.clear();
		items.push_back("Enter the name of the leaf node to be added.");
		(*componentUIC.interactionAlert)(flag?"Node already exists":"Test case pre-requisite",1102,items,-1,-1,-1,".",'T','A');
		nodeName=items.back();
		if (!sctsStrcmp(nodeName,"")) return false;
		sprintf(buffer,"%s/%s",testGroup->device->tester->testNode,nodeName);
		flag=((SctsDMServerDevice *)testGroup->device)->FindDMNode(buffer)!=0;
	} while (flag);

	if ((rc=((SctsDMServerDevice *)testGroup->device)->AddDMNode(buffer,SIDX,"node",false,0,0,0,&cmdRef->nodeRef,&command))!=200)
	{
		sprintf(buffer,"Could not Add an leaf node %s.SCTS internally generated a status code of %d",nodeName,rc);
		MessageBox(0,buffer,"Test Pre-Requisities",MB_ICONERROR);
		return false;
	}
	sctsStrcpy(buffer,"./InvalidNodeInAtomic");
	/* Create a invalid node */
	((SctsDMServerDevice *)testGroup->device)->AddDMNode(buffer,SIDX,"node",false,0,0,0);
	/* Insert a Delete command on the invalid node */
	((SctsDMServerDevice *)testGroup->device)->DeleteDMNode(buffer,SIDX,&command1);
	/* Insert the End Atomic */
	((SctsDMServerDevice *)testGroup->device)->InsertCommand(new SctsDMCommand(SCTS_ATOMIC_END));
	state=TEST_FAILED;
	return true;	
}

void SctsDMTestCase1101C::StateManagePostProcess()
{
	char errorMsg[500];
	if (state!=TEST_FAILED || !cmdRef || !cmdRef->status) return;
	state=TEST_PASSED;
	while (true)
	{
		if (cmdRef->command==SCTS_ATOMIC_START)
		{
			if (cmdRef->status==406) 
			{
				state=NOT_SUPPORTED;
				break;
			}			
			if (cmdRef->status!=507)
			{
				state=TEST_FAILED;
				SctsErrorLog::OpenNode("Test Case 1101C failed.","Atomic.");
				sprintf(errorMsg,"Expecting a status of 507, received a status of %d on Atomic (Message ID : %d, Command ID : %s).",cmdRef->status,cmdRef->msgRef,cmdRef->cmdRef);
				break;
			}
			cmdRef=new SctsDMCommand(SCTS_GET,command->nodeRef);
			cmdRef->nodeRef=cmdRef->nodeRef;
			((SctsDMServerDevice *)testGroup->device)->InsertCommand(cmdRef);
			state=TEST_FAILED;
			return;
		}
		if (cmdRef->command==SCTS_RESULTS)
		{
			if (cmdRef->status!=404)				
			{
				state=TEST_FAILED;
				SctsErrorLog::OpenNode("Test Case 1101C failed.","Atomic.");
				sprintf(errorMsg,"Expecting a status of 404, received a status of %d on Get (Message ID : %d, Command ID : %s).",cmdRef->status,cmdRef->msgRef,cmdRef->cmdRef);
				break;
			}
		}
		break;
	}
	if (state==TEST_FAILED)
	{
		SctsErrorLog::AppendError(errorMsg);
		SctsErrorLog::CloseNode();			
	}
	if (command && command->nodeRef)	((SctsDMServerDevice *)testGroup->device)->DeleteDMNode(command->nodeRef,SIDX);
	if (command1 && command1->nodeRef) ((SctsDMServerDevice *)testGroup->device)->DeleteDMNode(command1->nodeRef,SIDX);
	doneSMPostP=true;
}

/******************************************************************
SctsDMTestCase 12xxC Definition
******************************************************************/

bool SctsDMTestCase1201C::StatePreReq()
{
	int rc;
	char buffer[300];
	if ((rc=((SctsDMServerDevice *)testGroup->device)->GetDMNode("./DevInfo",SIDX,DMPROP_NONE,&cmdRef))!=200)
	{
		sprintf(buffer,"Could not issue a Get on the node './DevInfo'.SCTS internally received a status code of %d",rc);
		MessageBox(0,buffer,"Test Pre-Requisities",MB_ICONERROR);
		return false;
	}
	else
		state=TEST_FAILED;
	return true;
}

void SctsDMTestCase1201C::StateTerminate()	
{
	SctsDMNode *tempNode;
	char errorMsg[500];
	if (state!=TEST_FAILED || !cmdRef || !cmdRef->status) return;
	state=TEST_PASSED;
	SctsErrorLog::OpenNode("Test Case 1201C failed.",0);
	while (true)
	{
		if (cmdRef->status!=200)
		{
			state=TEST_FAILED;
			SctsErrorLog::OpenNode("Get failed.","Expecting a status of 200 for the Get.");
			sprintf(errorMsg,"Received a status of %d for Get on node ./DevInfo.(Message ID : %d, Command ID : %s).",cmdRef->status,cmdRef->msgRef,cmdRef->cmdRef);
			break;
		}		
		if (!cmdRef->data)
		{
			state=TEST_FAILED;
			SctsErrorLog::OpenNode("Did not receive Results from the Test Object for the Get sent by SCTS",0);
			sprintf(errorMsg,"Did not receive Results for the Get on node ./DevInfo (Message ID : %d, Command ID : %s)",cmdRef->msgRef,cmdRef->cmdRef);
			break;
		}	
		tempNode=(SctsDMNode *)cmdRef->data;
		if (!tempNode && tempNode->format && tempNode->format!=cmdRef->nodeRef->format) 
		{			
			state=TEST_FAILED;
			SctsErrorLog::OpenNode("Invalid Results",0);
			sprintf(errorMsg,"The format in Results for a Get on node ./DevInfo is not correct.");
			break;
		}
		if (!sctsStrstr((char *)tempNode->data,"DevId"))
		{
			state=TEST_FAILED;
			SctsErrorLog::OpenNode("Invalid Results",0);
			sprintf(errorMsg,"Results for Get on ./DevInfo does not contain node DevId.");
			break;
		}
		if (!sctsStrstr((char *)tempNode->data,"Man"))
		{
			state=TEST_FAILED;
			SctsErrorLog::OpenNode("Invalid Results",0);
			sprintf(errorMsg,"Results for Get on ./DevInfo does not contain node Man.");
			break;
		}
		if (!sctsStrstr((char *)tempNode->data,"Mod"))
		{
			state=TEST_FAILED;
			SctsErrorLog::OpenNode("Invalid Results",0);
			sprintf(errorMsg,"Results for Get on ./DevInfo does not contain node Mod.");
			break;
		}
		if (!sctsStrstr((char *)tempNode->data,"DmV"))
		{
			state=TEST_FAILED;
			SctsErrorLog::OpenNode("Invalid Results",0);
			sprintf(errorMsg,"Results for Get on ./DevInfo does not contain node DmV.");
			break;
		}
		if (!sctsStrstr((char *)tempNode->data,"Lang"))
		{
			state=TEST_FAILED;
			SctsErrorLog::OpenNode("Invalid Results",0);
			sprintf(errorMsg,"Results for Get on ./DevInfo does not contain node Lang.");
			break;
		}
		break;
	}
	if (state==TEST_FAILED)
	{
		SctsErrorLog::AppendError(errorMsg);
		SctsErrorLog::CloseNode();
	}
	SctsErrorLog::CloseNode();
}

bool SctsDMTestCase1202C::StatePreReq()
{
	int rc;
	char buffer[300];
	if ((rc=((SctsDMServerDevice *)testGroup->device)->GetDMNode("./DevDetail",SIDX,DMPROP_NONE,&cmdRef))!=200)
	{
		sprintf(buffer,"Could not issue a Get on the node './DevDetail'.SCTS internally received a status code of %d",rc);
		MessageBox(0,buffer,"Test Pre-Requisities",MB_ICONERROR);	
		return false;
	}
	else
		state=TEST_FAILED;
	return true;
}

void SctsDMTestCase1202C::StateTerminate()	
{
	SctsDMNode *tempNode;
	char errorMsg[500];
	if (state!=TEST_FAILED || !cmdRef || !cmdRef->status) return;
	state=TEST_PASSED;
	SctsErrorLog::OpenNode("Test Case 1202C failed.",0);
	while (true)
	{
		if (cmdRef->status!=200)
		{
			state=TEST_FAILED;
			SctsErrorLog::OpenNode("Get failed.","Expecting a status of 200 for the Get.");
			sprintf(errorMsg,"Received a status of %d for Get on node './DevDetail' (Message ID : %d, Command ID : %s).",cmdRef->status,cmdRef->msgRef,cmdRef->cmdRef);
			break;
		}		
		if (!cmdRef->data)
		{
			state=TEST_FAILED;
			SctsErrorLog::OpenNode("Did not receive Results from the Test Object for the Get sent by SCTS",0);
			sprintf(errorMsg,"Did not receive Results for the Get on node '/DevDetail' (Message ID : %d, Command ID : %s)",cmdRef->msgRef,cmdRef->cmdRef);
			break;
		}	
		tempNode=(SctsDMNode *)cmdRef->data;
		if (!tempNode && tempNode->format && tempNode->format!=cmdRef->nodeRef->format) 
		{			
			state=TEST_FAILED;
			SctsErrorLog::OpenNode("Invalid Results",0);
			sprintf(errorMsg,"The format in Results for a Get on node './DevDetail is not correct.");
			break;
		}
		if (!sctsStrstr((char *)tempNode->data,"URI"))
		{
			state=TEST_FAILED;
			SctsErrorLog::OpenNode("Invalid Results",0);
			sprintf(errorMsg,"Results for Get on ./DevDetail does not contain node URI.");
			break;
		}
		if (!sctsStrstr((char *)tempNode->data,"OEM"))
		{
			state=TEST_FAILED;
			SctsErrorLog::OpenNode("Invalid Results",0);
			sprintf(errorMsg,"Results for Get on ./DevDetail does not contain node OEM.");
			break;
		}
		if (!sctsStrstr((char *)tempNode->data,"FwV"))
		{
			state=TEST_FAILED;
			SctsErrorLog::OpenNode("Invalid Results",0);
			sprintf(errorMsg,"Results for Get on ./DevDetail does not contain node FwV.");
			break;
		}
		if (!sctsStrstr((char *)tempNode->data,"SwV"))
		{
			state=TEST_FAILED;
			SctsErrorLog::OpenNode("Invalid Results",0);
			sprintf(errorMsg,"Results for Get on ./DevDetail does not contain node SwV.");
			break;
		}
		if (!sctsStrstr((char *)tempNode->data,"HwV"))
		{
			state=TEST_FAILED;
			SctsErrorLog::OpenNode("Invalid Results",0);
			sprintf(errorMsg,"Results for Get on ./DevDetail does not contain node HwV.");
			break;
		}
		if (!sctsStrstr((char *)tempNode->data,"LrgObj"))
		{
			state=TEST_FAILED;
			SctsErrorLog::OpenNode("Invalid Results",0);
			sprintf(errorMsg,"Results for Get on ./DevDetail does not contain node LrgObj.");
			break;
		}
		break;
	}
	if (state==TEST_FAILED)
	{
		SctsErrorLog::AppendError(errorMsg);
		SctsErrorLog::CloseNode();
	}
	SctsErrorLog::CloseNode();
}


bool SctsDMTestCase1203C::StatePreReq()
{
	/* Create user interaction alert to input the name of the DMAcc node */
    //bool flag=false;
	//std::list<char *> items;
	//std::list<char *>::iterator it;
	char buffer[500];
	int rc;

    nodeName = 0;

    SctsDMDevice::MDAccType::iterator it = ((SctsDMServerDevice *)testGroup->device)->accounts.begin();
    while (it != ((SctsDMServerDevice *)testGroup->device)->accounts.end())
    {
        std::string serverIDPath = (it->second).accPath;
        serverIDPath += "/ServerID";
        SctsDMNode *node = ((SctsDMServerDevice *)testGroup->device)->FindDMNode((char *)serverIDPath.c_str());
        if (!sctsStrcmp((char *)node->data, "Scts"))
        {
            break;
        }
        ++it;
    }
	if (it == ((SctsDMServerDevice *)testGroup->device)->accounts.end())
	{
		MessageBox(0,"No DM Accounts present on device with Scts as the ServerID.","Test Pre-Requisites",MB_ICONEXCLAMATION);
		return false;
	}
    nodeName = sctsStrdup((it->second).accPath.c_str());

    /*
	do
	{
		items.clear();
		items.push_back("Enter the full path of DMAcc interior node.");
		(*componentUIC.interactionAlert)(flag?"Node not exist":"Test case pre-requisite",1102,items,-1,-1,-1,"",'T','A');
		nodeName=items.back();
		if (!sctsStrcmp(nodeName,"")) return false;
		flag=((SctsDMServerDevice *)testGroup->device)->FindDMNode(nodeName)==0;
	} while (flag);
    */

	if ((rc=((SctsDMServerDevice *)testGroup->device)->GetDMNode(nodeName,SIDX,DMPROP_NONE,&cmdRef))!=200)
	{
		sprintf(buffer,"Could not issue a Get on the node %s. SCTS internally generated a status code of %d.",nodeName,rc);
		MessageBox(0,buffer,"Test Pre-Requisities",MB_ICONERROR);
		return false;
	}
	nodeName=sctsStrdup(nodeName);
	state=TEST_FAILED;
	return true;
}

void SctsDMTestCase1203C::StateManagePostProcess()
{
	if (state!=TEST_FAILED || !cmdRef || !cmdRef->status) return;

    SctsDMNode *tempNode;
    char errorMsg[500]={0};
	SctsErrorLog::OpenNode("Test Case 1203C failed.",0);
	char *tempBuf=0;
	while (true)
	{
		if (cmdRef->status!=200)
		{
			state=TEST_FAILED;
			SctsErrorLog::OpenNode("Get failed.","Expecting a status of 200 for the Get.");
			sprintf(errorMsg,"Received a status of %d for Get on node %s/%s (Message ID : %d, Command ID : %s).",cmdRef->status,nodeName,cmdRef->nodeRef->name,cmdRef->msgRef,cmdRef->cmdRef);
			break;
		}		
		if (!cmdRef->data)
		{
			state=TEST_FAILED;
			SctsErrorLog::OpenNode("Did not receive Results from the Test Object for the Get sent by SCTS",0);
			sprintf(errorMsg,"Did not receive Results for the Get on node %s (Message ID : %d, Command ID : %s)",cmdRef->nodeRef->name,cmdRef->msgRef,cmdRef->cmdRef);
			break;
		}	

        tempNode=(SctsDMNode *)cmdRef->data;
		if (!tempNode && tempNode->format && tempNode->format!=cmdRef->nodeRef->format) 
		{			
			state=TEST_FAILED;
			SctsErrorLog::OpenNode("Invalid Results",0);
			sprintf(errorMsg,"The format in Results for a Get on node %s is not correct.",cmdRef->nodeRef->name);
			break;
		}

        tempBuf=(char *)sctsMalloc(tempNode->size+3);
		sctsStrcpy(tempBuf+1,(char *)tempNode->data);
		tempBuf[0]='/';
		tempBuf[tempNode->size+1]='/';
		tempBuf[tempNode->size+2]=0;

        if (snType == SN_NOTSET)
        {
		    if (!sctsStrstr(tempBuf,"/AppID/"))
		    {
			    state=TEST_FAILED;
			    SctsErrorLog::OpenNode("Invalid Results",0);
			    sprintf(errorMsg,"Results for Get on %s does not contain node AppID.",tempNode->name);
			    break;
		    }
		    if (!sctsStrstr(tempBuf,"/ServerID/"))
		    {
			    state=TEST_FAILED;
			    SctsErrorLog::OpenNode("Invalid Results",0);
			    sprintf(errorMsg,"Results for Get on %s does not contain node ServerID.",tempNode->name);
			    break;
		    }
		    if (!sctsStrstr(tempBuf,"/AppAddr/"))
		    {
			    state=TEST_FAILED;
			    SctsErrorLog::OpenNode("Invalid Results",0);
			    sprintf(errorMsg,"Results for Get on %s does not contain node AppAddr.",tempNode->name);
			    break;
		    }
            else
            {
                tmpNodeName = nodeName;
                tmpNodeName += "/AppAddr";
                SctsDMNode *node=((SctsDMServerDevice *)testGroup->device)->FindDMNode((char *)tmpNodeName.c_str());
                SctsDMCommand *command=new SctsDMCommand(SCTS_GET,node);
                cmdRef->nodeRef=0;
                cmdRef=command;
                ((SctsDMServerDevice *)testGroup->device)->InsertCommand(command);
                snType = SN_APPADDR;
                snCount |= SN_APPADDR;
            }
            if (sctsStrstr(tempBuf,"/ToConRef/"))
            {
                snCount |= SN_TOCONREF;
            }
            if (sctsStrstr(tempBuf,"/AppAuth/"))
            {
                snCount |= SN_APPAUTH;
            }
        }
        else if(snType != SN_NOTSET)
        {
            snCount &= ~snType;
            if (snType == SN_APPADDR)
            {
                if (sctsStrlen(tempBuf) < 3)
		        {
			        state=TEST_FAILED;
			        SctsErrorLog::OpenNode("Invalid Results",0);
			        sprintf(errorMsg,"Results for Get on %s does not contain subnode.",tempNode->name);
			        break;
		        }
                tmpNodeName = nodeName;
                tmpNodeName += "/AppAddr";
                *sctsStrstr(tempBuf+1, "/") = '\0';
                tmpNodeName += tempBuf;
                SctsDMNode *node=((SctsDMServerDevice *)testGroup->device)->FindDMNode((char *)tmpNodeName.c_str());
                SctsDMCommand *command=new SctsDMCommand(SCTS_GET,node);
                cmdRef->nodeRef=0;
                cmdRef=command;
                ((SctsDMServerDevice *)testGroup->device)->InsertCommand(command);
                snType = SN_APPADDR_X;
                snCount |= SN_APPADDR_X;
            }
            else if (snType == SN_APPADDR_X)
            {
		        if (!sctsStrstr(tempBuf,"/Addr/"))
		        {
			        state=TEST_FAILED;
			        SctsErrorLog::OpenNode("Invalid Results",0);
			        sprintf(errorMsg,"Results for Get on %s does not contain node Addr.",tempNode->name);
			        break;
		        }
		        if (!sctsStrstr(tempBuf,"/AddrType/"))
		        {
			        state=TEST_FAILED;
			        SctsErrorLog::OpenNode("Invalid Results",0);
			        sprintf(errorMsg,"Results for Get on %s does not contain node AddrType.",tempNode->name);
			        break;
		        }
                if (sctsStrstr(tempBuf, "/Port/"))
		        {
                    tmpNodeName += "/Port";
                    SctsDMNode *node=((SctsDMServerDevice *)testGroup->device)->FindDMNode((char *)tmpNodeName.c_str());
                    SctsDMCommand *command=new SctsDMCommand(SCTS_GET,node);
                    cmdRef->nodeRef=0;
                    cmdRef=command;
                    ((SctsDMServerDevice *)testGroup->device)->InsertCommand(command);
                    snType = SN_APPADDR_X_PORT;
                    snCount |= SN_APPADDR_X_PORT;
		        }
                else
                    snType = SN_NOTSET;
            }
            else if (snType == SN_APPADDR_X_PORT)
            {
                if (sctsStrlen(tempBuf) < 3)
		        {
			        state=TEST_FAILED;
			        SctsErrorLog::OpenNode("Invalid Results",0);
			        sprintf(errorMsg,"Results for Get on %s does not contain subnode.",tempNode->name);
			        break;
		        }
                *sctsStrstr(tempBuf+1, "/") = '\0';
                tmpNodeName += tempBuf;
                SctsDMNode *node=((SctsDMServerDevice *)testGroup->device)->FindDMNode((char *)tmpNodeName.c_str());
                SctsDMCommand *command=new SctsDMCommand(SCTS_GET,node);
                cmdRef->nodeRef=0;
                cmdRef=command;
                ((SctsDMServerDevice *)testGroup->device)->InsertCommand(command);
                snType = SN_APPADDR_X_PORT_X;
                snCount |= SN_APPADDR_X_PORT_X;
            }
            else if (snType == SN_APPADDR_X_PORT_X)
            {
		        if (!sctsStrstr(tempBuf,"/PortNbr/"))
		        {
			        state=TEST_FAILED;
			        SctsErrorLog::OpenNode("Invalid Results",0);
			        sprintf(errorMsg,"Results for Get on %s does not contain node PortNbr.",tempNode->name);
			        break;
		        }
                snType = SN_NOTSET;
            }
            else if (snType == SN_TOCONREF)
            {
                if (sctsStrlen(tempBuf) < 3)
		        {
			        state=TEST_FAILED;
			        SctsErrorLog::OpenNode("Invalid Results",0);
			        sprintf(errorMsg,"Results for Get on %s does not contain subnode.",tempNode->name);
			        break;
		        }
                *sctsStrstr(tempBuf+1, "/") = '\0';
                tmpNodeName += tempBuf;
                SctsDMNode *node=((SctsDMServerDevice *)testGroup->device)->FindDMNode((char *)tmpNodeName.c_str());
                SctsDMCommand *command=new SctsDMCommand(SCTS_GET,node);
                cmdRef->nodeRef=0;
                cmdRef=command;
                ((SctsDMServerDevice *)testGroup->device)->InsertCommand(command);
                snType = SN_TOCONREF_X;
                snCount |= SN_TOCONREF_X;
            }
            else if (snType == SN_TOCONREF_X)
            {
		        if (!sctsStrstr(tempBuf,"/ConRef/"))
		        {
			        state=TEST_FAILED;
			        SctsErrorLog::OpenNode("Invalid Results",0);
			        sprintf(errorMsg,"Results for Get on %s does not contain node ConRef.",tempNode->name);
			        break;
		        }
                snType = SN_NOTSET;
            }
            else if (snType == SN_APPAUTH)
            {
                if (sctsStrlen(tempBuf) < 3)
		        {
			        state=TEST_FAILED;
			        SctsErrorLog::OpenNode("Invalid Results",0);
			        sprintf(errorMsg,"Results for Get on %s does not contain subnode.",tempNode->name);
			        break;
		        }
                *sctsStrstr(tempBuf+1, "/") = '\0';
                tmpNodeName += tempBuf;
                SctsDMNode *node=((SctsDMServerDevice *)testGroup->device)->FindDMNode((char *)tmpNodeName.c_str());
                SctsDMCommand *command=new SctsDMCommand(SCTS_GET,node);
                cmdRef->nodeRef=0;
                cmdRef=command;
                ((SctsDMServerDevice *)testGroup->device)->InsertCommand(command);
                snType = SN_APPAUTH_X;
                snCount |= SN_APPAUTH_X;
            }
            else if (snType == SN_APPAUTH_X)
            {
		        if (!sctsStrstr(tempBuf,"/AAuthLevel/"))
		        {
			        state=TEST_FAILED;
			        SctsErrorLog::OpenNode("Invalid Results",0);
			        sprintf(errorMsg,"Results for Get on %s does not contain node AAuthLevel.",tempNode->name);
			        break;
		        }
		        if (!sctsStrstr(tempBuf,"/AAuthType/"))
		        {
			        state=TEST_FAILED;
			        SctsErrorLog::OpenNode("Invalid Results",0);
			        sprintf(errorMsg,"Results for Get on %s does not contain node AAuthType.",tempNode->name);
			        break;
		        }
                snType = SN_NOTSET;
            }

            if ((snCount & SN_TOCONREF) && (snType == SN_NOTSET))
            {
                tmpNodeName = nodeName;
                tmpNodeName += "/ToConRef";
                SctsDMNode *node=((SctsDMServerDevice *)testGroup->device)->FindDMNode((char *)tmpNodeName.c_str());
                SctsDMCommand *command=new SctsDMCommand(SCTS_GET,node);
                cmdRef->nodeRef=0;
                cmdRef=command;
                ((SctsDMServerDevice *)testGroup->device)->InsertCommand(command);
                snType = SN_TOCONREF;
            }
            else if ((snCount & SN_APPAUTH) && (snType == SN_NOTSET))
            {
                tmpNodeName = nodeName;
                tmpNodeName += "/AppAuth";
                SctsDMNode *node=((SctsDMServerDevice *)testGroup->device)->FindDMNode((char *)tmpNodeName.c_str());
                SctsDMCommand *command=new SctsDMCommand(SCTS_GET,node);
                cmdRef->nodeRef=0;
                cmdRef=command;
                ((SctsDMServerDevice *)testGroup->device)->InsertCommand(command);
                snType = SN_APPAUTH;
            }

            if (snCount == SN_NOTSET && snType == SN_NOTSET)
            {
                state=TEST_PASSED;
	            doneSMPostP=true;
            }
        }
		break;
	}
	if (tempBuf) sctsFree(tempBuf);
	if (state==TEST_FAILED && errorMsg[0])
	{
		SctsErrorLog::AppendError(errorMsg);
	}
	SctsErrorLog::CloseNode();
}

/******************************************************************
SctsDMTestCase 13xxC Definition
******************************************************************/

bool SctsDMTestCase1301C::StatePreReq()
{
	int rc;
	char buffer[300];
	if ((rc=((SctsDMServerDevice *)testGroup->device)->GetDMNode(".",SIDX,DMPROP_ACL,&cmdRef))!=200)
	{
		sprintf(buffer,"Could not issue a Get on the root node ACL.SCTS internally received a status code of %d",rc);
		MessageBox(0,buffer,"Test Pre-Requisities",MB_ICONERROR);
		return false;
	}
	else
		state=TEST_FAILED;
	return true;
}

void SctsDMTestCase1301C::StateTerminate()	
{
	SctsDMNode *tempNode;
	char errorMsg[500];
	if (state!=TEST_FAILED || !cmdRef || !cmdRef->status) return;
	state=TEST_PASSED;
	SctsErrorLog::OpenNode("Test Case 1301C failed.",0);
	while (true)
	{
		if (cmdRef->status!=200)
		{
			state=TEST_FAILED;
			SctsErrorLog::OpenNode("Get failed.","Expecting a status of 200 for the Get.");
			sprintf(errorMsg,"Received a status of %d for Get on node .?prop=acl (Message ID : %d, Command ID : %s).",cmdRef->status,cmdRef->msgRef,cmdRef->cmdRef);
			break;
		}		
		if (!cmdRef->data)
		{
			state=TEST_FAILED;
			SctsErrorLog::OpenNode("Did not receive Results from the Test Object for the Get sent by SCTS",0);
			sprintf(errorMsg,"Did not receive Results for the Get on node .?prop=acl (Message ID : %d, Command ID : %s)",cmdRef->msgRef,cmdRef->cmdRef);
			break;
		}
		tempNode=((SctsDMServerDevice *)testGroup->device)->FindDMNode(".");
		if (!tempNode->VerifyACLSyntax((char *)cmdRef->data))
		{
			state=TEST_FAILED;
			SctsErrorLog::OpenNode("ACL Syntax is incorrect",0);
			sprintf(errorMsg,"The ACL %s is not properly formatted",(char *)cmdRef->data);
			break;
		}
		break;
	}
	if (state==TEST_FAILED)
	{
		SctsErrorLog::AppendError(errorMsg);
		SctsErrorLog::CloseNode();
	}
	SctsErrorLog::CloseNode();
}

bool SctsDMTestCase1302C::StatePreReq()
{
	int rc;
	char buffer[300];
	if ((rc=((SctsDMServerDevice *)testGroup->device)->GetDMNode(".",SIDX,DMPROP_FORMAT,&cmdRef))!=200)
	{
		sprintf(buffer,"Could not issue a Get on the .?prop=Format.SCTS internally received a status code of %d",rc);
		MessageBox(0,buffer,"Test Pre-Requisities",MB_ICONERROR);
		return false;
	}
	else
		state=TEST_FAILED;
	return true;
}

void SctsDMTestCase1302C::StateTerminate()	
{
	char errorMsg[500];
	if (state!=TEST_FAILED || !cmdRef || !cmdRef->status) return;
	state=TEST_PASSED;
	SctsErrorLog::OpenNode("Test Case 1302C failed.",0);
	while (true)
	{
		if (cmdRef->status!=200)
		{
			state=TEST_FAILED;
			SctsErrorLog::OpenNode("Get failed.","Expecting a status of 200 for the Get.");
			sprintf(errorMsg,"Received a status of %d for Get on node .?prop=format (Message ID : %d, Command ID : %s).",cmdRef->status,cmdRef->msgRef,cmdRef->cmdRef);
			break;
		}		
		if (!cmdRef->data)
		{
			state=TEST_FAILED;
			SctsErrorLog::OpenNode("Did not receive Results from the Test Object for the Get sent by SCTS",0);
			sprintf(errorMsg,"Did not receive Results for the Get on node .?prop=format  (Message ID : %d, Command ID : %s)",cmdRef->msgRef,cmdRef->cmdRef);
			break;
		}
		if (sctsStrcmp((char *)cmdRef->data,"node"))
		{
			state=TEST_FAILED;
			SctsErrorLog::OpenNode("Format of root node is incorrect.",0);
			sprintf(errorMsg,"The format of the root node should be 'node', received results is %s",(char *)cmdRef->data);
			break;
		}
		break;
	}
	if (state==TEST_FAILED)
	{
		SctsErrorLog::AppendError(errorMsg);
		SctsErrorLog::CloseNode();
	}
	SctsErrorLog::CloseNode();
}

bool SctsDMTestCase1303C::StatePreReq()
{
	int rc;
	char buffer[300];
	if ((rc=((SctsDMServerDevice *)testGroup->device)->GetDMNode(".",SIDX,DMPROP_MIMETYPE,&cmdRef))!=200)
	{
		sprintf(buffer,"Could not issue a Get on .?prop=Type.SCTS internally received a status code of %d",rc);
		MessageBox(0,buffer,"Test Pre-Requisities",MB_ICONERROR);	
		return false;
	}
	else
		state=TEST_FAILED;	
	return true;
}

void SctsDMTestCase1303C::StateTerminate()	
{
	char errorMsg[500];
	if (state!=TEST_FAILED || !cmdRef || !cmdRef->status) return;
	state=TEST_PASSED;
	SctsErrorLog::OpenNode("Test Case 1303C failed.",0);
	if (cmdRef->status!=200)
	{
		state=TEST_FAILED;
		SctsErrorLog::OpenNode("Get failed.","Expecting a status of 200 for the Get.");
		sprintf(errorMsg,"Received a status of %d for Get on node .?prop=Type (Message ID : %d, Command ID : %s).",cmdRef->status,cmdRef->msgRef,cmdRef->cmdRef);
	}		
	if (state==TEST_FAILED)
	{
		SctsErrorLog::AppendError(errorMsg);
		SctsErrorLog::CloseNode();
	}
	SctsErrorLog::CloseNode();
}

bool SctsDMTestCase1304C::StatePreReq()
{
	SctsDMNode *node=((SctsDMServerDevice *)testGroup->device)->FindDMNode(".");
	cmdRef=new SctsDMCommand(SCTS_GET,node,DMPROP_SIZE);
	cmdRef->nodeRef=node;
	((SctsDMServerDevice *)testGroup->device)->InsertCommand(cmdRef);
	state=TEST_FAILED;
	return true;
}

void SctsDMTestCase1304C::StateTerminate()	
{
	char errorMsg[500];
	if (state!=TEST_FAILED || !cmdRef || !cmdRef->status) return;
	state=TEST_PASSED;
	SctsErrorLog::OpenNode("Test Case 1304C failed.",0);
	if (cmdRef->status!=405 && cmdRef->status!=406)
	{
		state=TEST_FAILED;
		SctsErrorLog::OpenNode("Get failed.","Expecting a status of 405/406 for the Get.");
		sprintf(errorMsg,"Received a status of %d for Get on node .?prop=Size (Message ID : %d, Command ID : %s).",cmdRef->status,cmdRef->msgRef,cmdRef->cmdRef);
		SctsErrorLog::AppendError(errorMsg);
		SctsErrorLog::CloseNode();
	}		
	SctsErrorLog::CloseNode();
}

bool SctsDMTestCase1305C::StatePreReq()
{
	int rc;
	char buffer[300];
	if ((rc=((SctsDMServerDevice *)testGroup->device)->GetDMNode("./DevDetail/URI",SIDX,DMPROP_NAME,&cmdRef))!=200)
	{
		sprintf(buffer,"Could not issue a Get on the './DevDetail/URI?prop=Name'.SCTS internally received a status code of %d",rc);
		MessageBox(0,buffer,"Test Pre-Requisities",MB_ICONERROR);			
		return false;
	}
	else
		state=TEST_FAILED;
	return true;
}

void SctsDMTestCase1305C::StateTerminate()	
{
	char errorMsg[500];
	if (state!=TEST_FAILED || !cmdRef || !cmdRef->status) return;
	state=TEST_PASSED;
	SctsErrorLog::OpenNode("Test Case 1305C failed.",0);
	while (true)
	{
		if (cmdRef->status!=200)
		{
			state=TEST_FAILED;
			SctsErrorLog::OpenNode("Get failed.","Expecting a status of 200 for the Get.");
			sprintf(errorMsg,"Received a status of %d for Get on node ./DevDetail/URI?prop=Name (Message ID : %d, Command ID : %s).",cmdRef->status,cmdRef->msgRef,cmdRef->cmdRef);
			break;
		}		
		if (!cmdRef->data)
		{
			state=TEST_FAILED;
			SctsErrorLog::OpenNode("Did not receive Results from the Test Object for the Get sent by SCTS",0);
			sprintf(errorMsg,"Did not receive Results for the Get on node ./DevDetail/URI?prop=Name (Message ID : %d, Command ID : %s)",cmdRef->msgRef,cmdRef->cmdRef);
			break;
		}
		if (sctsStrcmp((char *)cmdRef->data,"URI"))
		{
			state=TEST_FAILED;
			SctsErrorLog::OpenNode("Invalid Results.",0);
			sprintf(errorMsg,"Results for Get on './DevDetail/URI?prop=Name'was incorrect. Expected results 'URI', received results '%s'.",(char *)cmdRef->data);
			break;
		}
		break;
	}
	if (state==TEST_FAILED)
	{
		SctsErrorLog::AppendError(errorMsg);
		SctsErrorLog::CloseNode();
	}
	SctsErrorLog::CloseNode();
}

bool SctsDMTestCase1306C::StatePreReq()
{
	int rc;
	char buffer[300];
	if ((rc=((SctsDMServerDevice *)testGroup->device)->GetDMNode("./DevDetail/URI/MaxTotLen",SIDX,DMPROP_SIZE,&cmdRef))!=200)
	{
		sprintf(buffer,"Could not issue a Get on './DevDetail/URI/MaxTotLen?prop=Size'.SCTS internally received a status code of %d",rc);
		MessageBox(0,buffer,"Test Pre-Requisities",MB_ICONERROR);			
		return false;
	}
	else
		state=TEST_FAILED;
	return true;	
}

void SctsDMTestCase1306C::StateTerminate()	
{
	char errorMsg[500];
	if (state!=TEST_FAILED || !cmdRef || !cmdRef->status) return;
	state=TEST_PASSED;
	SctsErrorLog::OpenNode("Test Case 1306C failed.",0);
	while (true)
	{
		if (cmdRef->status!=200)
		{
			state=TEST_FAILED;
			SctsErrorLog::OpenNode("Get failed.","Expecting a status of 200 for the Get.");
			sprintf(errorMsg,"Received a status of %d for Get on node './DevDetail/URI/MaxTotLen?prop=Size' (Message ID : %d, Command ID : %s).",cmdRef->status,cmdRef->msgRef,cmdRef->cmdRef);
			break;
		}		
		if (!cmdRef->data)
		{
			state=TEST_FAILED;
			SctsErrorLog::OpenNode("Did not receive Results from the Test Object for the Get sent by SCTS",0);
			sprintf(errorMsg,"Did not receive Results for the Get on node './DevDetail/URI/MaxTotLen?prop=Size (Message ID : %d, Command ID : %s)",cmdRef->msgRef,cmdRef->cmdRef);
			break;
		}
		break;
	}
	if (state==TEST_FAILED)
	{
		SctsErrorLog::AppendError(errorMsg);
		SctsErrorLog::CloseNode();
	}
	SctsErrorLog::CloseNode();
}

bool SctsDMTestCase1307C::StatePreReq()
{
	SctsDMNode *node=((SctsDMServerDevice *)testGroup->device)->FindDMNode("./DevDetail");
	cmdRef=new SctsDMCommand(SCTS_REPLACE,node,DMPROP_NAME);
	cmdRef->nodeRef=node;
	cmdRef->data=sctsStrdup("DevDetail");
	((SctsDMServerDevice *)testGroup->device)->InsertCommand(cmdRef);
	state=TEST_FAILED;
	return true;
}

void SctsDMTestCase1307C::StateTerminate()	
{
	char errorMsg[500];
	if (state!=TEST_FAILED || !cmdRef ||!cmdRef->status) return;
	state=TEST_PASSED;
	SctsErrorLog::OpenNode("Test Case 1307C failed.",0);
	if (cmdRef->status!=405)
	{
		state=TEST_FAILED;
		SctsErrorLog::OpenNode("Get failed.","Expecting a status of 405 for the Replace on Name property of a permanent object.");
		sprintf(errorMsg,"Received a status of %d for Replace on Name property of the node './DevDetail.' (Message ID : %d, Command ID : %s).",cmdRef->status,cmdRef->msgRef,cmdRef->cmdRef);
		SctsErrorLog::AppendError(errorMsg);
		SctsErrorLog::CloseNode();
	
	}		
	SctsErrorLog::CloseNode();
}

bool SctsDMTestCase1308C::StatePreReq()
{
	int rc;
	char buffer[300];
	if ((rc=((SctsDMServerDevice *)testGroup->device)->ReplaceDMNodeProp(testGroup->device->tester->testNode,SIDX,DMPROP_ACL,"Replace=*&Add=*&Delete=*&Get=*&Exec=*",&cmdRef))!=200)
	{
		sprintf(buffer,"Could not issue a Get on './DevDetail/URI/MaxTotLen?prop=Size'.SCTS internally received a status code of %d",rc);
		MessageBox(0,buffer,"Test Pre-Requisities",MB_ICONERROR);			
		return false;
	}
	else
		state=TEST_FAILED;
	return true;
}

void SctsDMTestCase1308C::StateTerminate()	
{
	char errorMsg[500];
	if (state!=TEST_FAILED) return;
	state=TEST_PASSED;
	SctsErrorLog::OpenNode("Test Case 1308C failed.",0);
	if (cmdRef->status!=200)
	{
		state=TEST_FAILED;
		SctsErrorLog::OpenNode("Replace on ACL failed.","Expecting a status of 200 for the Replace on ACL.");
		sprintf(errorMsg,"Received a status of %d for Replace on ACL property. (Message ID : %d, Command ID : %s).",cmdRef->status,cmdRef->msgRef,cmdRef->cmdRef);
		SctsErrorLog::AppendError(errorMsg);
		SctsErrorLog::CloseNode();
	
	}		
	SctsErrorLog::CloseNode();
}

/******************************************************************
SctsDMTestCase 14xxC Definition
******************************************************************/

bool SctsDMTestCase1401C::StatePreReq()
{
	char buffer[300];
	int rc;
	if ((rc=((SctsDMServerDevice *)testGroup->device)->ReplaceDMNodeProp(testGroup->device->tester->testNode,SIDX,DMPROP_ACL,"Add=*&Get=*&Replace=*",&cmdRef))!=200)
	{
		sprintf(buffer,"SCTS does not have Replace access rights on the test node.SCTS internally generated a status code of %d.",rc);
		MessageBox(0,buffer,"Test Pre-Requisities",MB_ICONERROR);			
		return false;
	}
	state=TEST_FAILED;
	return true;
}	

void SctsDMTestCase1401C::StateManagePostProcess()
{
	char errorMsg[500];
	if (state!=TEST_FAILED || !cmdRef || !cmdRef->status) return;
	state=TEST_PASSED;
	switch (cmdRef->command)
	{
	case SCTS_REPLACE:
		{
			int rc;
			state=TEST_FAILED;
			if (cmdRef->status!=200)
			{
				SctsErrorLog::OpenNode("Test Case 1401C.","Pre-requisities.");
				sprintf(errorMsg,"Replace on the ACL of the test node failed. Expected status 200, received status %d",cmdRef->status);
				break;
			}
			if ((rc=((SctsDMServerDevice *)testGroup->device)->DeleteDMNode(testGroup->device->tester->testNode,SIDX,&cmdRef))!=200)
			{
				SctsErrorLog::OpenNode("Test Case 1401C.","Delete");
				sprintf(errorMsg,"Could not Delete the test node.SCTS internally generated a status code of %d",rc);
				break;
			}
			return;
		}
	case SCTS_DELETE:
		{
			int rc;
			state=TEST_FAILED;
			if (cmdRef->status!=425)
			{
				SctsErrorLog::OpenNode("Test Case 1401C failed.","ACL enforcement failed.");
				sprintf(errorMsg,"Expecting a status of 425,received a status of %d for Delete (Message ID : %d, Command ID : %s).",cmdRef->status,cmdRef->msgRef,cmdRef->cmdRef);									
				break;
			}
			else
			{
				cmdRef->RollBack();
				if (((SctsDMServerDevice *)testGroup->device)->uiCallback) (*((SctsDMServerDevice *)testGroup->device)->uiCallback)((SctsDMTree *)(SctsDMServerDevice *)testGroup->device,cmdRef->nodeRef,SCTS_ADD);
			}
			if ((rc=((SctsDMServerDevice *)testGroup->device)->GetDMNode(testGroup->device->tester->testNode,SIDX,DMPROP_NONE,&cmdRef))!=200)
			{
				SctsErrorLog::OpenNode("Test Case 1401C.","Get");
				sprintf(errorMsg,"Could not insert a Get Command.SCTS internally generated a status code of %d",rc);
				break;
			}
			return;
		}
	case SCTS_RESULTS:
		{
			if (cmdRef->status!=200)
			{
				state=TEST_FAILED;
				SctsErrorLog::OpenNode("Test Case 1401C failed.","Get failed.");
				sprintf(errorMsg,"Expecting a status of 200, received a status of %d for Get on test node (Message ID : %d, Command ID : %s).",cmdRef->status,cmdRef->msgRef,cmdRef->cmdRef);					
				break;
			}
			doneSMPostP=true;
			break;
		}
	default:
		{
			state=TEST_FAILED;
			SctsErrorLog::OpenNode("Test Case 1401C failed.","Invalid command");
			sprintf(errorMsg,"Not Expecting Command %s, (Message ID : %d, Command ID : %s)",sctsCommandStrings[cmdRef->command],cmdRef->msgRef,cmdRef->cmdRef);				
			break;
		}
	};
	if (state==TEST_FAILED)
	{
		doneSMPostP=true;
		SctsErrorLog::AppendError(errorMsg);
		SctsErrorLog::CloseNode();
	}
}

/******************************************************************
SctsDMTestCase 15xxC Definition
******************************************************************/

bool SctsDMTestCase1501C::StatePreReq()
{
	char buffer[500];
	int rc;
	SctsDMNode *testNode,*childNode;
	testNode=((SctsDMServerDevice *)testGroup->device)->FindDMNode(testGroup->device->tester->testNode);
	if (!testNode || !testNode->child)
	{
		sprintf(buffer,"Configure a Test interior node.The test node should have atleast one child node.");
		MessageBox(0,buffer,"Test Pre-Requisities",MB_ICONERROR);			
		return false;
	}
	childNode=testNode->child;
	while (childNode)
	{
		if (childNode->format!=DMFORMAT_NODE) break;
		childNode=childNode->next;
	}
	if (!childNode)
	{
		sprintf(buffer,"The Test interior node does not have any leaf nodes.");
		MessageBox(0,buffer,"Test Pre-Requisities",MB_ICONERROR);			
		return false;
	}
	if (!testNode->VerifyACL(SIDX,SCTS_REPLACE))
	{
		sprintf(buffer,"SCTS requires replace access rights on the configured Test interior node.");
		MessageBox(0,buffer,"Test Pre-Requisities",MB_ICONERROR);			
		return false;
	}
	if ((rc=((SctsDMServerDevice *)testGroup->device)->ReplaceDMNodeProp(childNode,SIDX,DMPROP_ACL,"Get=*&Replace=*&Delete=*",&cmdRef))!=200)
	{
		sprintf(buffer,"SCTS could not have replace the ACL of test node's child.SCTS internally generated a status code of %d.",rc);
		MessageBox(0,buffer,"Test Pre-Requisities",MB_ICONERROR);			
		return false;
	}
	if ((rc=((SctsDMServerDevice *)testGroup->device)->ReplaceDMNodeProp(testNode,SIDX,DMPROP_ACL,"Add=*&Delete=*&Get=*",&cmdRef1))!=200)
	{
		sprintf(buffer,"SCTS does not have Replace access rights on the test node.SCTS internally generated a status code of %d.",rc);
		MessageBox(0,buffer,"Test Pre-Requisities",MB_ICONERROR);			
		return false;
	}
	state=TEST_FAILED;
	return true;	
}	

void SctsDMTestCase1501C::StateManagePostProcess()
{
	char errorMsg[500];
	if (state!=TEST_FAILED || !cmdRef ||!cmdRef1) return;
	state=TEST_PASSED;
	if (cmdRef->status!=200 || cmdRef1->status!=200)
	{
		state=TEST_FAILED;
		SctsErrorLog::OpenNode("Test Case 1501C.","Replace on ACL.");
		sprintf(errorMsg,"Replace on the ACL of the test node failed. Expected status 200, received status %d",cmdRef->status);
		SctsErrorLog::AppendError(errorMsg);
		SctsErrorLog::CloseNode();
	}
	if (state==TEST_PASSED)
	{
		SctsDMCommand *command=new SctsDMCommand(SCTS_REPLACE,cmdRef->nodeRef,DMPROP_ACL);
		command->data=sctsStrdup("Get=*");
		command->size=5;
		((SctsDMServerDevice *)testGroup->device)->InsertCommand(command);
		cmdRef=command;
	}
	doneSMPostP=true;
}

void SctsDMTestCase1501C::StateTerminate()
{
	char errorMsg[500];
	if (state!=TEST_PASSED || !cmdRef) return;
	if (cmdRef->status!=425)
	{
		state=TEST_FAILED;
		SctsErrorLog::OpenNode("Test Case 1501C.","Replace on ACL.");
		sprintf(errorMsg,"Replace on the ACL of the child node while parent node does not have replace access right. Expected status 425, received status %d",cmdRef->status);
		SctsErrorLog::AppendError(errorMsg);
		SctsErrorLog::CloseNode();
	}
}

/******************************************************************
SctsDMTestCase 16xxC Definition
******************************************************************/

bool SctsDMTestCase1601C::StatePreReq()
{
	SctsDMNode *node,*child;
	char buffer[300];
	int rc;
	std::list<char *> items;
	node=((SctsDMServerDevice *)testGroup->device)->FindDMNode(testGroup->device->tester->testNode);
	items.push_back("Select the leaf node to be deleted.");
	for (child=node->child;child;child=child->next)
	{ 
		if (child->format!=DMFORMAT_NODE) items.push_back(child->name);
	}
	if (items.size()==1)
	{
		sprintf(buffer,"There are no leaf nodes configured under test node '%s'.",testGroup->device->tester->testNode);
		MessageBox(0,buffer,"Test Pre-Requisities",MB_ICONERROR);
		return false;
	}
	(*componentUIC.interactionAlert)("Test case pre-requisite",1103,items,-1,-1,-1,0,0,0);
	rc=atoi(items.front());
	child=node->child;
	do
	{
		if (child->format!=DMFORMAT_NODE) --rc;
		if (rc) child=child->next;
	} while (rc);
	

	if ((rc=((SctsDMServerDevice *)testGroup->device)->DeleteDMNode(child,SIDX,&cmdRef))!=200)
	{
		sprintf(buffer,"Could not Delete Node %s/%s.SCTS internally generated a status code of %d.",testGroup->device->tester->testNode,child->name,rc);
		MessageBox(0,buffer,"Test Pre-Requisities",MB_ICONERROR);
		return false;
	}
	state=TEST_FAILED;
	return true;
}

void SctsDMTestCase1601C::StateTerminate()	
{
	char errorMsg[500];
	if (state!=TEST_FAILED || !cmdRef || !cmdRef->status) return;
	state=TEST_PASSED;
	if (cmdRef->status!=200 && cmdRef->status!=406)
	{
		state=TEST_FAILED;
		SctsErrorLog::OpenNode("Test Case 1601C failed.","Delete failed.");
		sprintf(errorMsg,"Expecting a status of 200/406, received a status of %d for Delete on node %s (Message ID : %d, Command ID : %s).",cmdRef->status,cmdRef->nodeRef->name,cmdRef->msgRef,cmdRef->cmdRef);
		SctsErrorLog::AppendError(errorMsg);
		SctsErrorLog::CloseNode();								
	}
	if (cmdRef->status==406) state=NOT_SUPPORTED;
	if (cmdRef->status!=200 && cmdRef->nodeRef) 
	{
		cmdRef->RollBack();
		if (((SctsDMServerDevice *)testGroup->device)->uiCallback) (*((SctsDMServerDevice *)testGroup->device)->uiCallback)((SctsDMTree *)(SctsDMServerDevice *)testGroup->device,cmdRef->nodeRef,SCTS_ADD);		
	}
}


/******************************************************************
SctsDMTestCase 17xxC Definition
******************************************************************/

void SctsDMTestCase1701C::StateManagePreBuild()
{
	((SctsDMServerDevice *)testGroup->device)->GetDMNode("./DevDetail/LrgObj",SIDX,DMPROP_NONE,&cmdRef);
	state=TEST_FAILED;
	doneSMPreB=true;	
}

void SctsDMTestCase1701C::StateManagePostProcess()
{
	SctsDMNode *temp;
	char errorMsg[500];
	int rc=0;
	if (state!=TEST_FAILED || !cmdRef || !cmdRef->status) return;
	state=TEST_PASSED;
	if (cmdRef->nodeRef && !sctsStrcmp(cmdRef->nodeRef->name,"LrgObj"))
	{
		while (true)
		{
			if (cmdRef->status!=200)
			{
				SctsErrorLog::OpenNode("Test Case 1701C.","Get.");
				sprintf(errorMsg,"Get on ./DevDetail/LrgObj failed. Expected status 200, received status %d",cmdRef->status);
				break;
			}
			if (!cmdRef->data)
			{
				SctsErrorLog::OpenNode("Test Case 1701C.","Results");
				sprintf(errorMsg,"Did not receive valid results for Get on ./DevDetail/LrgObj.");
				break;
			}
			temp=(SctsDMNode *)cmdRef->data;
			if (temp->format!=DMFORMAT_BOOL)
			{
				SctsErrorLog::OpenNode("Test Case 1701C.","Results");
				sprintf(errorMsg,"Did not receive valid results for Get on ./DevDetail/LrgObj.Expected Format 'bool'.");
				break;
			}
			if (!(rc=sctsStrcmp((char *)temp->data,"true")) && !sctsStrcmp((char *)temp->data,"false"))
			{
				SctsErrorLog::OpenNode("Test Case 1701C.","Results");
				sprintf(errorMsg,"Did not receive valid results for Get on ./DevDetail/LrgObj.Expected data of either 'true' or 'false'.");
				break;
			}
			temp=((SctsDMServerDevice *)testGroup->device)->FindDMNode("./DevDetail/LrgObj");
			SCTSASSERT(temp);	
			if (temp->data) sctsFree(temp->data);
			if (rc)
			{
				temp->data=sctsStrdup("false");
				temp->size=5;
			}
			else
			{
				temp->data=sctsStrdup("true");
				temp->size=4;
			}
			break;			
		}
	}
	if (state==TEST_FAILED)
	{
		SctsErrorLog::AppendError(errorMsg);
		SctsErrorLog::CloseNode();
	}
	doneSMPostP=true;
}
char *SctsDMTestCase1702C::GetPath()
{
	return path;
}

void SctsDMTestCase1702C::FreePath()
{
	sctsFree(path);
}

bool SctsDMTestCase1702C::StatePreReq()
{
	bool flag=false;
	std::list<char *> items;
	std::list<char *>::iterator it;
	char *nodeName;
	char buffer[500];
	path=0;
	do
	{
		items.clear();
		items.push_back("Enter the name of the Large Object leaf node to be added.");
		(*componentUIC.interactionAlert)(flag?"Node already exists":"Test case pre-requisite",1102,items,-1,-1,-1,".",'T','A');
		nodeName=items.back();
		if (!sctsStrcmp(nodeName,"")) return false;
		sprintf(buffer,"%s/%s",testGroup->device->tester->testNode,nodeName);
		flag=((SctsDMServerDevice *)testGroup->device)->FindDMNode(buffer)!=0;
	} while (flag);
	path=sctsStrdup(buffer);
	return true;
}


void SctsDMTestCase1702C::StateManagePreBuild()
{
	int rc,size;
	SctsDMNode *node;
	char tempBuf[300];
	char errorMsg[300];
	char *buffer;
	SctsDMTestCase *testcase;
	std::list <SctsDMTestCase *>::iterator it;
	for (it=testGroup->testCases.begin();it!=testGroup->testCases.end();it++)
	{
		testcase=*it;
		if(testcase->GetID()==1701) break;
	}
	if (testcase->GetState()!=TEST_PASSED) return;
	node=((SctsDMServerDevice *)testGroup->device)->FindDMNode("./DevDetail/LrgObj");
	SCTSASSERT(node);
	if (node->size==4 && path)
	{
		size=((SctsDMServerSession *)testGroup->session)->largeObjectBufferSize;
		if (!size) size=2*((SctsDMServerSession *)testGroup->session)->maxMsgSize;
		buffer=(char *)sctsMalloc(size);
		sctsMemset(buffer,65,size);
		if ((rc=((SctsDMServerDevice *)testGroup->device)->AddDMNode(path,SIDX,"chr",false,buffer,"text/plain",size,0,&cmdRef))!=200)
		{
			SctsErrorLog::OpenNode("Test Case 1702C.","Pre-condition");
			sprintf(errorMsg,"Could not add node with path %s.SCTS internally generated a status code of %d",tempBuf,rc);
			SctsErrorLog::AppendError(errorMsg);
			SctsErrorLog::CloseNode();
			state=TEST_OPTIONAL;
			sctsFree(path);
			path=0;
		}
		else
			state=TEST_FAILED;
	}
	else
		state=NOT_SUPPORTED;
	doneSMPreB=true;	
}

void SctsDMTestCase1702C::StateManagePostProcess()
{
	char errorMsg[500];
	if (state!=TEST_FAILED || !cmdRef->status) return;
	if (cmdRef->status!=213 && cmdRef->status!=200)
	{
		if (cmdRef->nodeRef) ((SctsDMServerDevice *)testGroup->device)->DeleteDMNode(cmdRef->nodeRef,SIDX);
		state=TEST_FAILED;
		SctsErrorLog::OpenNode("Test Case 1702C.","Add");
		sprintf(errorMsg,"Add failed. Expected status 213/200, received status %d",cmdRef->status);
		doneSMPostP=true;
		SctsErrorLog::AppendError(errorMsg);
		SctsErrorLog::CloseNode();
	}
	if (cmdRef->status==200)
	{
		state=TEST_PASSED;
		doneSMPostP=true;	
	}
	
}

void SctsDMTestCase1703C::StateManagePreBuild()
{
	SctsDMTestCase *testcase;
	char *buffer;
	char errorMsg[300];
	int rc;
	std::list <SctsDMTestCase *>::iterator it;
	for (it=testGroup->testCases.begin();it!=testGroup->testCases.end();it++)
	{
		testcase=*it;
		if(testcase->GetID()==1702) break;
	}
	if (testcase->GetState()==NOT_SUPPORTED) state=NOT_SUPPORTED;
	if (testcase->GetState()!=TEST_PASSED) return;
	if (! (buffer=((SctsDMTestCase1702C *)testcase)->GetPath())) return;
	if ((rc=((SctsDMServerDevice *)testGroup->device)->GetDMNode(buffer,SIDX,DMPROP_NONE,&cmdRef))!=200)
	{
		SctsErrorLog::OpenNode("Test Case 1703C.","Pre-condition");
		sprintf(errorMsg,"Could not insert Get node with path %s.SCTS internally generated a status code of %d",buffer,rc);
		SctsErrorLog::AppendError(errorMsg);
		SctsErrorLog::CloseNode();
		state=TEST_OPTIONAL;
	}
	else
		state=TEST_FAILED;
	doneSMPreB=true;	
}

void SctsDMTestCase1703C::StateManagePostProcess()
{
	char errorMsg[500];
	int rc=0;
	if (state!=TEST_FAILED || !cmdRef || !cmdRef->status) return;
	if (cmdRef->status!=200)
	{
		SctsErrorLog::OpenNode("Test Case 1703C.","Get.");
		sprintf(errorMsg,"Expected status 200, received status %d",cmdRef->status);
		SctsErrorLog::AppendError(errorMsg);
		SctsErrorLog::CloseNode();		
	}
	if (((SctsDMServerSession *)testGroup->session)->largeObjectCmd==SCTS_RESULTS) state=TEST_PASSED;
	doneSMPostP=true;
}

void SctsDMTestCase1704C::StateManagePreBuild()
{
	SctsDMTestCase *testcase;
	char buffer[300];
	char errorMsg[300];
	int rc;
	std::list <SctsDMTestCase *>::iterator it;
	if (((SctsDMServerSession *)testGroup->session)->largeObjectSize) return;
	for (it=testGroup->testCases.begin();it!=testGroup->testCases.end();it++)
	{
		testcase=*it;
		if(testcase->GetID()==1703) break;
	}
	if (testcase->GetState()==NOT_SUPPORTED) state=NOT_SUPPORTED;
	if (testcase->GetState()!=TEST_PASSED) return;
	for (it=testGroup->testCases.begin();it!=testGroup->testCases.end();it++)
	{
		testcase=*it;
		if(testcase->GetID()==1702) break;
	}
	if (!((SctsDMTestCase1702C *)testcase)->GetPath()) return;
	if (state!=TEST_FAILED)
	{
		SctsAlert *alert=new SctsAlert(testGroup->session->currentCmdID,SctsItemList(),1222);
		((SctsDMServerSession *)testGroup->session)->outgoingMessage->InsertCommand(alert);
		++testGroup->session->currentCmdID;
		if (((SctsDMServerSession *)testGroup->session)->largeObjectBufferSize) 
			((SctsDMServerSession *)testGroup->session)->largeObjectBufferSize/=2;			
		else
		{
			SctsDMNode *node=((SctsDMServerDevice *)testGroup->device)->FindDMNode(((SctsDMTestCase1702C *)testcase)->GetPath());
			if (node && node->size) 
				((SctsDMServerSession *)testGroup->session)->largeObjectBufferSize=node->size-1;
		}
		state=TEST_FAILED;
		return;
	}
	if ((rc=((SctsDMServerDevice *)testGroup->device)->GetDMNode(((SctsDMTestCase1702C *)testcase)->GetPath(),SIDX,DMPROP_NONE,&cmdRef))!=200)
	{
		SctsErrorLog::OpenNode("Test Case 1704C.","Pre-condition");
		sprintf(errorMsg,"Could not insert Get node with path %s.SCTS internally generated a status code of %d",buffer,rc);
		SctsErrorLog::AppendError(errorMsg);
		SctsErrorLog::CloseNode();
		state=NOT_TESTED;
	}
	else
		state=TEST_FAILED;
	((SctsDMTestCase1702C *)testcase)->FreePath();
	doneSMPreB=true;	
}

void SctsDMTestCase1704C::StateTerminate()
{
	char errorMsg[500];
	int rc=0;
	if (state!=TEST_FAILED || !cmdRef || !cmdRef->status) return;
	if (cmdRef->status!=413)
	{
		SctsErrorLog::OpenNode("Test Case 1704C.","Get.");
		sprintf(errorMsg,"Expected status 413, received status %d",cmdRef->status);
		SctsErrorLog::AppendError(errorMsg);
		SctsErrorLog::CloseNode();		
	}
	else
		state=TEST_PASSED;		
	doneSMPostP=true;
}

/******************************************************************
SctsDMTestCase 18xxC Definition
******************************************************************/

bool SctsDMTestCase1801C::StatePreReq()
{
	char buffer[500];
	int rc;
	if ((rc=((SctsDMServerDevice *)testGroup->device)->GetDMNode("./DevDetail",SIDX,DMPROP_STRUCT,&cmdRef))!=200)
	{
		sprintf(buffer,"Could not issues a Get on ./DevDetail?list=Struct.SCTS internally generated a status code of %d.",rc);
		MessageBox(0,buffer,"Test Pre-Requisities",MB_ICONERROR);			
		return false;
	}
	state=TEST_FAILED;
	return true;
}	

void SctsDMTestCase1801C::StateManagePostProcess()
{
	char errorMsg[500];
	if (state!=TEST_FAILED || !cmdRef || !cmdRef->status) return;
	if (cmdRef->status!=200 && cmdRef->status!=406)
	{
		SctsErrorLog::OpenNode("Test Case 1801C.","Get.");
		sprintf(errorMsg,"Get on ./DevDetail?list=Struct failed. Expected status 200/406, received status %d",cmdRef->status);
		SctsErrorLog::AppendError(errorMsg);
		SctsErrorLog::CloseNode();
	}
	else
	{
		if (cmdRef->status==200)
			state=TEST_PASSED;
		else
			state=NOT_SUPPORTED;
	}
	doneSMPostP=true;
}

void SctsDMTestCase1801C::StateTerminate()
{
	char errorMsg[500];
	if (!testGroup->session->IsSuccessful()) 
	{
		state=TEST_FAILED;
		SctsErrorLog::OpenNode("Test Case 1801C.","Get.");
		sprintf(errorMsg,"Session did not complete successful.");
		SctsErrorLog::AppendError(errorMsg);
		SctsErrorLog::CloseNode();
	}
}

/******************************************************************
SctsDMTestCase 19xxC Definition
******************************************************************/

bool SctsDMTestCase1901C::StatePreReq()
{
	char buffer[500];
	int rc;
	if ((rc=((SctsDMServerDevice *)testGroup->device)->GetDMNode("./DevDetail",SIDX,DMPROP_STRUCTDATA,&cmdRef))!=200)
	{
		sprintf(buffer,"Could not issues a Get on ./DevDetail?list=StructData.SCTS internally generated a status code of %d.",rc);
		MessageBox(0,buffer,"Test Pre-Requisities",MB_ICONERROR);			
		return false;
	}
	state=TEST_FAILED;
	return true;
}	

void SctsDMTestCase1901C::StateManagePostProcess()
{
	char errorMsg[500];
	if (state!=TEST_FAILED || !cmdRef || !cmdRef->status) return;
	if (cmdRef->status!=200 && cmdRef->status!=406)
	{
		SctsErrorLog::OpenNode("Test Case 1901C.","Get.");
		sprintf(errorMsg,"Get on ./DevDetail?list=StructData failed. Expected status 200/406, received status %d",cmdRef->status);
		SctsErrorLog::AppendError(errorMsg);
		SctsErrorLog::CloseNode();
	}
	else
	{
		if (cmdRef->status==200)
			state=TEST_PASSED;
		else
			state=NOT_SUPPORTED;
	}
	doneSMPostP=true;
}

void SctsDMTestCase1901C::StateTerminate()
{
	char errorMsg[500];
	if (!testGroup->session->IsSuccessful()) 
	{
		state=TEST_FAILED;
		SctsErrorLog::OpenNode("Test Case 1901C.","Get.");
		sprintf(errorMsg,"Session did not complete successful.");
		SctsErrorLog::AppendError(errorMsg);
		SctsErrorLog::CloseNode();
	}
}

/******************************************************************
SctsDMTestCase 20xxC Definition
******************************************************************/

bool SctsDMTestCase2001C::StatePreReq()
{
	/* Create user interaction alert to input the name of the leaf node to add */
	bool flag=false;
	std::list<char *> items;
	char *address=0;
	char *port=0;
	SctsDMNode *node,*child;
	items.clear();
	items.push_back("Enter the Address of the Client Device.");
	(*componentUIC.interactionAlert)("Test case pre-requisite",1102,items,-1,-1,-1,".",'T','A');
	address=items.back();
	
	if (address) port=sctsStrchr(address,':');
	if (port) *port=0;

	HOSTENT *hostent=gethostbyname(address);
	
	if (!hostent || !hostent->h_addr_list)
	{
		MessageBox(0,"Invalid Address","Test Pre-Requisities",MB_ICONERROR);			
		return false;
	}

    SctsDMDevice::MDAccType::iterator it = ((SctsDMServerDevice *)testGroup->device)->accounts.begin();
    while (it != ((SctsDMServerDevice *)testGroup->device)->accounts.end())
    {
        std::string serverIDPath = (it->second).accPath;
        serverIDPath += "/ServerID";
        SctsDMNode *node = ((SctsDMServerDevice *)testGroup->device)->FindDMNode((char *)serverIDPath.c_str());
        if (!sctsStrcmp((char *)node->data, "Scts"))
        {
            break;
        }
        ++it;
    }
	if (it == ((SctsDMServerDevice *)testGroup->device)->accounts.end())
	{
		MessageBox(0,"No DM Accounts present on device with Scts as the ServerID.","Test Pre-Requisites",MB_ICONEXCLAMATION);
		return false;
	}

    node=((SctsDMServerDevice *)testGroup->device)->FindDMNode(((SctsDMServerDevice *)testGroup->device)->dmAccPath);
	SCTSASSERT(node);
	node=node->child;
	if (!node)
	{
		MessageBox(0,"No DM Accounts present on device.","Test Pre-Requisites",MB_ICONEXCLAMATION);
		return false;
	}
	while (node)
	{
		child=((SctsDMServerDevice *)testGroup->device)->FindDMNode("ServerID",node);
		if (child && child->data && !sctsStrcmp((char *)child->data,"Scts")) break;
		node=node->next;
	}
	if (!node)
	{
		MessageBox(0,"No DM Accounts present on device with Scts as the ServerID.","Test Pre-Requisites",MB_ICONEXCLAMATION);
		return false;
	}
	SctsDMNotification *notify=new SctsDMNotification((struct in_addr *)hostent->h_addr_list[0],port?atoi(port+1):80,(SctsDMServerDevice *)testGroup->device,node);
	sctsFree(address);
	notify->Create();
	return true;
}

void SctsDMTestCase2001C::StateTerminate()
{
	state=TEST_FAILED;
	if (((SctsDMServerSession *)testGroup->session)->serverInitiatedAlert) state=TEST_PASSED;
}

/******************************************************************
SctsDMTestCase 21xxC Definition
******************************************************************/

bool SctsDMTestCase2101C::StatePreReq()
{
	/* Create user interaction alert to input the name of the DMAcc node */
    bool flag=false;
	std::list<char *> items;
	std::list<char *>::iterator it;
	char buffer[500];
	int rc;
    char *nodeName = 0;

    do
	{
		items.clear();
		items.push_back("Enter the name of the node to be executed.");
		(*componentUIC.interactionAlert)(flag?"Node not exist":"Test case pre-requisite",1102,items,-1,-1,-1,"",'T','A');
		nodeName=items.back();
		if (!sctsStrcmp(nodeName,"")) return false;
		sprintf(buffer,"%s/%s",testGroup->device->tester->testNode,nodeName);
		flag=((SctsDMServerDevice *)testGroup->device)->FindDMNode(buffer)==0;
	} while (flag);

	if ((rc=((SctsDMServerDevice *)testGroup->device)->ExecDMNode(buffer,SIDX,&cmdRef))!=200)
	{
		sprintf(buffer,"Could not issue Exec on the node %s/%s. SCTS internally generated a status code of %d.",testGroup->device->tester->testNode,nodeName,rc);
		MessageBox(0,buffer,"Test Pre-Requisities",MB_ICONERROR);
		return false;
	}
	state=TEST_FAILED;
	doneSMPostP=true;
	return true;
}

void SctsDMTestCase2101C::StateTerminate()
{
	char errorMsg[500];
	if (state!=TEST_FAILED || !cmdRef || !cmdRef->status) return;
	if (cmdRef->status!=405)
	{
		state=TEST_FAILED;
		SctsErrorLog::OpenNode("Test Case 2101C failed.","Execute failed.");
		sprintf(errorMsg,"Expecting a status of 405, received a status of %d for execute on node %s (Message ID : %d, Command ID : %s).",cmdRef->status,cmdRef->nodeRef->name,cmdRef->msgRef,cmdRef->cmdRef);
		SctsErrorLog::AppendError(errorMsg);
		SctsErrorLog::CloseNode();
		return;
	}
	state=TEST_PASSED;
}

bool SctsDMTestCase2102C::StatePreReq()
{
	/* Create user interaction alert to input the name of the DMAcc node */
    bool flag=false;
	std::list<char *> items;
	std::list<char *>::iterator it;
	char buffer[500];
	int rc;
    char *nodeName = 0;

    do
	{
		items.clear();
		items.push_back("Enter another name of the node to be executed.");
		(*componentUIC.interactionAlert)(flag?"Node not exist":"Test case pre-requisite",1102,items,-1,-1,-1,"",'T','A');
		nodeName=items.back();
		if (!sctsStrcmp(nodeName,"")) return false;
		sprintf(buffer,"%s/%s",testGroup->device->tester->testNode,nodeName);
		flag=((SctsDMServerDevice *)testGroup->device)->FindDMNode(buffer)==0;
	} while (flag);

	if ((rc=((SctsDMServerDevice *)testGroup->device)->ExecDMNode(buffer,SIDX,&cmdRef))!=200)
	{
		sprintf(buffer,"Could not issue Exec on the node %s/%s. SCTS internally generated a status code of %d.",testGroup->device->tester->testNode,nodeName,rc);
		MessageBox(0,buffer,"Test Pre-Requisities",MB_ICONERROR);
		return false;
	}
	state=TEST_FAILED;
	return true;
}

void SctsDMTestCase2102C::StateTerminate()
{
	char errorMsg[500];
	if (state!=TEST_FAILED || !cmdRef || !cmdRef->status) return;
	if (cmdRef->status!=425)
	{
		state=TEST_FAILED;
		SctsErrorLog::OpenNode("Test Case 2102C failed.","Execute failed.");
		sprintf(errorMsg,"Expecting a status of 425, received a status of %d for execute on node %s (Message ID : %d, Command ID : %s).",cmdRef->status,cmdRef->nodeRef->name,cmdRef->msgRef,cmdRef->cmdRef);
		SctsErrorLog::AppendError(errorMsg);
		SctsErrorLog::CloseNode();
		return;
	}
	state=TEST_PASSED;
}

/******************************************************************
SctsDMTestCase 22xxC Definition
******************************************************************/

bool SctsDMTestCase2201C::StatePreReq()
{
	int rc;
	state = TEST_FAILED;
    char buffer[500];
    char fullNodePath[] = "./Intr1/Intr2/Intr3/Leaf";

    if ((rc=((SctsDMServerDevice *)testGroup->device)->AddFullDMNode(fullNodePath,SIDX,"chr",false,"2201C","text/plain",5,0,&cmdRef))!=200)
	{
		sprintf(buffer,"Could not Add an node %s.SCTS internally generated a status code of %d",fullNodePath,rc);
		MessageBox(0,buffer,"Test Pre-Requisities",MB_ICONERROR);
		return false;
	}
	state=TEST_FAILED;
	return true;
}

void SctsDMTestCase2201C::StateManagePostProcess()
{
	char errorMsg[500];
	if (state!=TEST_FAILED || !cmdRef || !cmdRef->status) return;
	state=TEST_PASSED;
	switch (cmdRef->command)
	{
	case SCTS_ADD:
		{
			if (cmdRef->status!=200)
			{
				state=TEST_FAILED;
				SctsErrorLog::OpenNode("Test Case 2201C failed.","Add failed.");
				sprintf(errorMsg,"Expecting a status of 200,received a status of %d for Add on node %s (Message ID : %d, Command ID : %s).",cmdRef->status,cmdRef->nodeRef->name,cmdRef->msgRef,cmdRef->cmdRef);
                SCTSASSERT(cmdRef->nodeRef);
                SctsDMNode *pNode = 0;
                for (int i = 0; i < 4; ++i)
                {
                    pNode = cmdRef->nodeRef;
                    cmdRef->nodeRef = cmdRef->nodeRef->parent;
				    ((SctsDMServerDevice *)testGroup->device)->DeleteDMNode(pNode,SIDX);
                }
			}
			else
			{
				SctsDMCommand *command=new SctsDMCommand(SCTS_GET,cmdRef->nodeRef,DMPROP_NONE,true);
				((SctsDMServerDevice *)testGroup->device)->InsertCommand(command);
				cmdRef=command;
				state=TEST_FAILED;
				cmdRef->status=0;
				return;
			}
			break;
		}
	case SCTS_RESULTS:
		{
			if (cmdRef->status!=200)
			{
				state=TEST_FAILED;
				SctsErrorLog::OpenNode("Test Case 2201C failed.","Get failed.");
				sprintf(errorMsg,"Expecting a status of 200, received a status of %d for Get on node %s (Message ID : %d, Command ID : %s).",cmdRef->status,cmdRef->nodeRef->name,cmdRef->msgRef,cmdRef->cmdRef);					
				break;
			}
			doneSMPostP=true;
			break;
		}
	default:
		{
			state=TEST_FAILED;
			SctsErrorLog::OpenNode("Test Case 2201C failed.","Invalid command");
			sprintf(errorMsg,"Not Expecting Command %s, (Message ID : %d, Command ID : %s)",sctsCommandStrings[cmdRef->command],cmdRef->msgRef,cmdRef->cmdRef);				
			break;
		}
	};
	if (state==TEST_FAILED)
	{
		doneSMPostP=true;
		SctsErrorLog::AppendError(errorMsg);
		SctsErrorLog::CloseNode();
	}
}

/******************************************************************
SctsDMTestCase 23xxC Definition
******************************************************************/

void SctsDMTestCase2301C::StateManagePreBuild()
{
	int rc=((SctsDMServerDevice *)testGroup->device)->GetDMNodeTNDS("./DevDetail",SIDX,"+ACL+Format+Value",&cmdRef);
	if (rc>300)
	{
		char tempBuffer[300];
		SctsErrorLog::OpenNode("Test Case 2301C.","Pre-conditions");
		sprintf(tempBuffer,"Could not issue a Get on the DevDetail node.SCTS internally received a status code of %d",rc);
		SctsErrorLog::AppendError(tempBuffer);
		SctsErrorLog::CloseNode();	
	}
	else
		state=TEST_FAILED;
	doneSMPreB=true;	
}

void SctsDMTestCase2301C::StateTerminate()
{
	char errorMsg[500];
	if (state!=TEST_FAILED || !cmdRef) return;
	state=TEST_PASSED;
	SctsErrorLog::OpenNode("Test Case 2301C failed.","Get TNDS failed.");
    SctsDMTNDSTree *tndsTree = 0;
	while (true)
	{
		if (cmdRef->status!=200)
		{
			state=TEST_FAILED;
			sprintf(errorMsg,"Received a status of %d for Get on node %s (Message ID : %d, Command ID : %s).",cmdRef->status,cmdRef->nodeRef->name,cmdRef->msgRef,cmdRef->cmdRef);
			break;
		}
        if (cmdRef->data==0)
		{
			state=TEST_FAILED;
			sprintf(errorMsg,"Not receive TNDS result.");
			break;
		}
        tndsTree = (SctsDMTNDSTree *)cmdRef->data;
        int rc = tndsTree->IsValid("+ACL+Format+Value");
        if (rc == SctsDMTNDSTree::NVAL_TYPE_FORMAT)
        {
			state=TEST_FAILED;
			sprintf(errorMsg,"Invalid TNDS result type/format.");
			break;
        }
        if (rc == SctsDMTNDSTree::NVAL_CONTENT)
        {
			state=TEST_FAILED;
			sprintf(errorMsg,"Invalid TNDS result content.");
			break;
        }
        if (rc == SctsDMTNDSTree::NVAL_STRUCTURE)
        {
			state=TEST_FAILED;
			sprintf(errorMsg,"Invalid TNDS structure of result.");
			break;
        }
        if (rc == SctsDMTNDSTree::NVAL_ENOUGH_INFO)
        {
			state=TEST_FAILED;
			sprintf(errorMsg,"Not enough TNDS contents.");
			break;
        }
        break;
	}
	if (state==TEST_FAILED)
	{
		SctsErrorLog::AppendError(errorMsg);
	}
	SctsErrorLog::CloseNode();
}

/******************************************************************
SctsDMTestCase 24xxC Definition
******************************************************************/

void SctsDMTestCase2401C::StateManagePreBuild()
{
    copyData = oldData = 0;
    int rc=((SctsDMServerDevice *)testGroup->device)->CopyDMNode("./DevInfo/DevId","./CopyNode",SIDX,&cmdRef);
	if (rc>300)
	{
		char tempBuffer[300];
		SctsErrorLog::OpenNode("Test Case 2401C.","Pre-conditions");
		sprintf(tempBuffer,"Could not issue a Copy on the DevId node.SCTS internally received a status code of %d",rc);
		SctsErrorLog::AppendError(tempBuffer);
		SctsErrorLog::CloseNode();	
	}
	else
    {
		state=TEST_FAILED;
    }
	doneSMPreB=true;	
}

void SctsDMTestCase2401C::StateManagePostProcess()
{
	char errorMsg[500];
	if (state!=TEST_FAILED || !cmdRef || !cmdRef->status) return;
	state=TEST_PASSED;
	switch (cmdRef->command)
	{
	case SCTS_COPY:
		{
			if (cmdRef->status!=200)
			{
				state=TEST_FAILED;
				SctsErrorLog::OpenNode("Test Case 2401C failed.","Copy failed.");
				sprintf(errorMsg,"Expecting a status of 200,received a status of %d for Copy DevId to %s (Message ID : %d, Command ID : %s).",cmdRef->status,cmdRef->nodeRef->name,cmdRef->msgRef,cmdRef->cmdRef);
                SCTSASSERT(cmdRef->nodeRef);
                ((SctsDMServerDevice *)testGroup->device)->DeleteDMNode(cmdRef->nodeRef,SIDX);
			}
            else
			{
                SctsDMCommand *command=new SctsDMCommand(SCTS_GET,cmdRef->nodeRef,DMPROP_NONE,true);
				((SctsDMServerDevice *)testGroup->device)->InsertCommand(command);
				cmdRef=command;
				state=TEST_FAILED;
				cmdRef->status=0;
				return;
			}
			break;
		}
	case SCTS_RESULTS:
		{
			if (cmdRef->status!=200)
			{
				state=TEST_FAILED;
				SctsErrorLog::OpenNode("Test Case 2401C failed.","Get failed.");
				sprintf(errorMsg,"Expecting a status of 200, received a status of %d for Get on node %s (Message ID : %d, Command ID : %s).",cmdRef->status,cmdRef->nodeRef->name,cmdRef->msgRef,cmdRef->cmdRef);					
				break;
			}
            if (!sctsStrcmp(cmdRef->nodeRef->name, "CopyNode"))
            {
                copyData = sctsStrdup((char *)cmdRef->data);
                cmdRef->nodeRef = ((SctsDMServerDevice *)testGroup->device)->FindDMNode("./DevInfo/DevId");
                SCTSASSERT(cmdRef->nodeRef);
				SctsDMCommand *command=new SctsDMCommand(SCTS_GET,cmdRef->nodeRef,DMPROP_NONE,true);
				((SctsDMServerDevice *)testGroup->device)->InsertCommand(command);
				cmdRef=command;
				state=TEST_FAILED;
				cmdRef->status=0;
				return;
            }
            else if (!sctsStrcmp(cmdRef->nodeRef->name, "DevId"))
            {
                oldData = sctsStrdup((char *)cmdRef->data);
                if (sctsStrcmp(copyData, oldData))
                {
                    state=TEST_FAILED;
			        SctsErrorLog::OpenNode("Test Case 2401C failed.","Different Result");
			        sprintf(errorMsg,"Receive different Result from copied node");
                }
                sctsFree(copyData);
                sctsFree(oldData);
            }
            else
            {
			    state=TEST_FAILED;
			    SctsErrorLog::OpenNode("Test Case 2401C failed.","Invalid Result");
			    sprintf(errorMsg,"Not Expecting Result, (Message ID : %d, Command ID : %s)",cmdRef->msgRef,cmdRef->cmdRef);
            }
			doneSMPostP=true;
			break;
		}
	default:
		{
			state=TEST_FAILED;
			SctsErrorLog::OpenNode("Test Case 2401C failed.","Invalid command");
			sprintf(errorMsg,"Not Expecting Command %s, (Message ID : %d, Command ID : %s)",sctsCommandStrings[cmdRef->command],cmdRef->msgRef,cmdRef->cmdRef);				
			break;
		}
	};
	if (state==TEST_FAILED)
	{
		doneSMPostP=true;
        if (copyData) sctsFree(copyData);
        if (oldData) sctsFree(oldData);
		SctsErrorLog::AppendError(errorMsg);
		SctsErrorLog::CloseNode();
	}
}

/******************************************************************
SctsDMTestCase 25xxC Definition
******************************************************************/

bool SctsDMTestCase2501C::StatePreReq()
{
	/* Create user interaction alert to input the name of the DMAcc node */
    bool flag=false;
	std::list<char *> items;
	std::list<char *>::iterator it;
	char buffer[500];
	int rc;
    char *nodeName = 0;
    correlator = "2501C";

    do
	{
		items.clear();
		items.push_back("Enter another name of the node to be executed.");
		(*componentUIC.interactionAlert)(flag?"Node not exist":"Test case pre-requisite",1102,items,-1,-1,-1,"",'T','A');
		nodeName=items.back();
		if (!sctsStrcmp(nodeName,"")) return false;
		sprintf(buffer,"%s/%s",testGroup->device->tester->testNode,nodeName);
		flag=((SctsDMServerDevice *)testGroup->device)->FindDMNode(buffer)==0;
	} while (flag);

    nodePath = buffer;
    if ((rc=((SctsDMServerDevice *)testGroup->device)->ExecDMNode((char *)nodePath.c_str(),SIDX,&cmdRef))!=200)
	{
		sprintf(buffer,"Could not issue Exec on the node %s/%s. SCTS internally generated a status code of %d.",testGroup->device->tester->testNode,nodeName,rc);
		MessageBox(0,buffer,"Test Pre-Requisities",MB_ICONERROR);
		return false;
	}
    cmdRef->cmdSpecific.correlator = correlator;
	state=TEST_FAILED;
	return true;
}

void SctsDMTestCase2501C::StateTerminate()
{
	char errorMsg[500];
	if (state!=TEST_FAILED || !cmdRef || !cmdRef->status) return;
	if (cmdRef->status!=200)
	{
		state=TEST_FAILED;
		SctsErrorLog::OpenNode("Test Case 2501C failed.","Execute failed.");
		sprintf(errorMsg,"Expecting a status of 200, received a status of %d for execute on node %s (Message ID : %d, Command ID : %s).",cmdRef->status,cmdRef->nodeRef->name,cmdRef->msgRef,cmdRef->cmdRef);
		SctsErrorLog::AppendError(errorMsg);
		SctsErrorLog::CloseNode();
		return;
	}
    SctsDMServerDevice *device = (SctsDMServerDevice *)testGroup->device;
    std::deque<SctsDMGenericAlert *>::iterator it = device->pendingGenericAlerts.begin();
    while (it != device->pendingGenericAlerts.end())
    {
        if ((*it)->source && (*it)->correlator && 
            !sctsStrcmp((*it)->source,(char *)nodePath.c_str()) && !sctsStrcmp((*it)->correlator,(char *)correlator.c_str()))
        {
            break;
        }
        ++it;
    }
    if (it != device->pendingGenericAlerts.end())
    {
		state=TEST_FAILED;
		SctsErrorLog::OpenNode("Test Case 2501C failed.","Execute failed.");
        sprintf(errorMsg,"Not receive expected Generic Alert(Correlator : %s).",correlator.c_str());
		SctsErrorLog::AppendError(errorMsg);
		SctsErrorLog::CloseNode();
		return;
    }
	state=TEST_PASSED;
}

#endif