[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[certi-cvs] applications/HLA_TestsSuite CMakeLists.txt 05-O...
From: |
certi-cvs |
Subject: |
[certi-cvs] applications/HLA_TestsSuite CMakeLists.txt 05-O... |
Date: |
Mon, 31 May 2010 14:15:09 +0000 |
CVSROOT: /sources/certi
Module name: applications
Changes by: Eric NOULARD <erk> 10/05/31 14:15:09
Modified files:
HLA_TestsSuite : CMakeLists.txt
Added files:
HLA_TestsSuite : 05-ObjectManagementCallbackTest.cc 01.fed
06-TimeEncodingTest.hh 03-PublishingTest.hh
05-ObjectManagementCallbackTest.hh
ReturnCodes.hh 06-TimeEncodingTest.cc
01-FederationExecutionTest.hh
03-PublishingTest.cc 02-HandlesAndNamesTest.hh
01-FederationExecutionTest.cc
02-HandlesAndNamesTest.cc 04-NameReservation.hh
05-ObjectManagementTest.hh
05-ObjectManagementTest.cc
04-NameReservation.cc
Log message:
Add 1516 tests cases from Jeroen.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/applications/HLA_TestsSuite/CMakeLists.txt?cvsroot=certi&r1=1.37&r2=1.38
http://cvs.savannah.gnu.org/viewcvs/applications/HLA_TestsSuite/05-ObjectManagementCallbackTest.cc?cvsroot=certi&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/applications/HLA_TestsSuite/01.fed?cvsroot=certi&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/applications/HLA_TestsSuite/06-TimeEncodingTest.hh?cvsroot=certi&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/applications/HLA_TestsSuite/03-PublishingTest.hh?cvsroot=certi&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/applications/HLA_TestsSuite/05-ObjectManagementCallbackTest.hh?cvsroot=certi&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/applications/HLA_TestsSuite/ReturnCodes.hh?cvsroot=certi&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/applications/HLA_TestsSuite/06-TimeEncodingTest.cc?cvsroot=certi&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/applications/HLA_TestsSuite/01-FederationExecutionTest.hh?cvsroot=certi&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/applications/HLA_TestsSuite/03-PublishingTest.cc?cvsroot=certi&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/applications/HLA_TestsSuite/02-HandlesAndNamesTest.hh?cvsroot=certi&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/applications/HLA_TestsSuite/01-FederationExecutionTest.cc?cvsroot=certi&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/applications/HLA_TestsSuite/02-HandlesAndNamesTest.cc?cvsroot=certi&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/applications/HLA_TestsSuite/04-NameReservation.hh?cvsroot=certi&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/applications/HLA_TestsSuite/05-ObjectManagementTest.hh?cvsroot=certi&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/applications/HLA_TestsSuite/05-ObjectManagementTest.cc?cvsroot=certi&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/applications/HLA_TestsSuite/04-NameReservation.cc?cvsroot=certi&rev=1.1
Patches:
Index: CMakeLists.txt
===================================================================
RCS file: /sources/certi/applications/HLA_TestsSuite/CMakeLists.txt,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -b -r1.37 -r1.38
--- CMakeLists.txt 19 May 2010 17:59:45 -0000 1.37
+++ CMakeLists.txt 31 May 2010 14:15:09 -0000 1.38
@@ -198,5 +198,39 @@
DTEST_SCRIPT dtest_test_FOMParse.py
COMMENTS "A FOM parsing test"
)
+#########################################################################
+# IEEE-1516 unit and integration tests
+#########################################################################
+HLATestsSuite_ADD_TEST1516(01-FederationExecutionTest
+ FED_FILE 01.xml 01.fed
+ SOURCE_FILES 01-FederationExecutionTest.cc
01-FederationExecutionTest.hh ReturnCodes.hh
+ COMMENTS "01-FederationExecutionTest (1516)")
+
+HLATestsSuite_ADD_TEST1516(02-HandlesAndNamesTest
+ FED_FILE Certi-Test-02.xml
+ SOURCE_FILES 02-HandlesAndNamesTest.cc
02-HandlesAndNamesTest.hh ReturnCodes.hh
+ COMMENTS "02-HandlesAndNamesTest (1516)")
+
+HLATestsSuite_ADD_TEST1516(03-PublishingTest
+ FED_FILE Certi-Test-03.xml
+ SOURCE_FILES 03-PublishingTest.cc 03-PublishingTest.hh
ReturnCodes.hh
+ COMMENTS "03-PublishingTest (1516)")
+
+HLATestsSuite_ADD_TEST1516(04-NameReservation
+ FED_FILE Certi-Test-04.xml
+ SOURCE_FILES 04-NameReservation.cc
04-NameReservation.hh ReturnCodes.hh
+ COMMENTS "04-NameReservation (1516)")
+
+HLATestsSuite_ADD_TEST1516(05-ObjectManagementTest
+ SOURCE_FILES 05-ObjectManagementTest.cc
05-ObjectManagementTest.hh ReturnCodes.hh
+ COMMENTS "05-ObjectManagementTest (1516)")
+
+HLATestsSuite_ADD_TEST1516(05-ObjectManagementCallbackTest
+ SOURCE_FILES 05-ObjectManagementCallbackTest.cc
05-ObjectManagementCallbackTest.hh ReturnCodes.hh
+ COMMENTS "05-ObjectManagementCallbackTest (1516)")
+
+HLATestsSuite_ADD_TEST1516(06-TimeEncodingTest
+ SOURCE_FILES 06-TimeEncodingTest.cc
06-TimeEncodingTest.hh ReturnCodes.hh
+ COMMENTS "06-TimeEncodingTest (1516)")
MESSAGE(STATUS "*** ${CMAKE_PROJECT_NAME} has been successfully configured
***")
Index: 05-ObjectManagementCallbackTest.cc
===================================================================
RCS file: 05-ObjectManagementCallbackTest.cc
diff -N 05-ObjectManagementCallbackTest.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ 05-ObjectManagementCallbackTest.cc 31 May 2010 14:15:08 -0000 1.1
@@ -0,0 +1,294 @@
+// 05-ObjectManagementCallbackTest.cc : Defines the entry point for the
console application.
+//
+
+#include "05-ObjectManagementCallbackTest.hh"
+#include "ReturnCodes.hh"
+
+#include <RTI/certiRTI1516.h>
+#include <RTI/Enums.h>
+#include <iostream>
+#include <sstream>
+#include <cstdlib>
+#include <ctime>
+#include <cstdio>
+
+#include <RTI1516fedTime.h>
+
+int main(int argc, char** argv)
+{
+ int retCode1 = 0;
+
+ srand( time(0) );
+
+ TestFedAmbCallbacks *fedAmb = new TestFedAmbCallbacks();
+
+ retCode1 = fedAmb->execute();
+
+
+
+ if ( retCode1 == certi::rti1516_test::RETURN_NO_ERRORS)
+ {
+ std::wcerr << L"Pass: Test completed" << std::endl;
+ } else
+ {
+ std::wcerr << L"Fail: Test failed with error code: " <<
retCode1 << std::endl;
+
+ }
+
+ // Poor man's 'pause'
+ std::wcerr << L"Press enter to stop connection to RTI." << std::endl;
+ getchar();
+
+ delete fedAmb;
+
+ // Poor man's 'pause'
+ getchar();
+
+ return retCode1;
+}
+
+
+TestFedAmbCallbacks::TestFedAmbCallbacks() throw()
+: rtiAmb(0)
+, fedHandle()
+, fedName()
+, federationName(L"TestFederationName")
+{
+ int nameVal;
+
+ nameVal = (rand() % 99) + 1;
+
+ std::wstringstream stream;
+ stream << L"TestFederateCallbacks" << nameVal;
+
+ fedName = stream.str();
+ std::wcerr << L"Federate name:" << fedName << std::endl;
+
+}
+
+TestFedAmbCallbacks::~TestFedAmbCallbacks() throw()
+{
+ delete rtiAmb;
+}
+
+int TestFedAmbCallbacks::execute()
+{
+std::wcerr << L"01T Test: Attempting to set up test environment (create and
join federation)" << std::endl;
+ std::auto_ptr< rti1516::RTIambassadorFactory > rtiAmbFact(new
rti1516::RTIambassadorFactory());
+ std::vector< std::wstring > constructorArgs;
+
+ // handles.
+ rti1516::ObjectClassHandle classHandle;
+ rti1516::AttributeHandle attrHandle;
+ rti1516::AttributeHandleSet classAttributes;
+ rti1516::AttributeHandleValueMap attributeValues;
+ rti1516::AttributeHandle invalidAttrHandle;
+ rti1516::AttributeHandleValueMap invalidAttributes;
+
+ rti1516::VariableLengthData theUserSuppliedTag;
+ std::wstring className(L"TestObjectClass");
+
+ try {
+ //////////////////////////////////////////////
+ // Set up
+ std::auto_ptr< rti1516::RTIambassador >
rtiAmbP(rtiAmbFact->createRTIambassador(constructorArgs));
+ rtiAmb = rtiAmbP.release();
+
+ try {
+ rtiAmb->createFederationExecution(federationName,
L"Certi-Test-05.xml");
+ // expected
+ } catch (rti1516::FederationExecutionAlreadyExists &)
+ {
+ // expected
+ } catch (rti1516::Exception &)
+ {
+ throw;
+ }
+
+ fedHandle = rtiAmb->joinFederationExecution(fedName,
federationName, *this);
+ classHandle = rtiAmb->getObjectClassHandle(className);
+ attrHandle = rtiAmb->getAttributeHandle(classHandle, L"Data");
+ classAttributes.insert(attrHandle);
+
+ //subscribe
+ rtiAmb->subscribeObjectClassAttributes(classHandle,
classAttributes);
+
+ } catch (rti1516::Exception &e)
+ {
+ std::wcerr << L"N Setup failed:" << e.what() << std::endl;
+ std::wcerr << L"Press enter to exit" << std::endl;
+ getchar();
+ return certi::rti1516_test::RETURN_UNDEFINED_ERROR;
+ }
+
+ while (true) {
+ std::wcerr << L"Press enter to evoke callbacks" << std::endl;
+ getchar();
+ rtiAmb->evokeMultipleCallbacks(0.0, 1.0);
+ }
+
+ return certi::rti1516_test::RETURN_NO_ERRORS;
+
+}
+
+// 6.5
+ void
+ TestFedAmbCallbacks::discoverObjectInstance(rti1516::ObjectInstanceHandle
theObject,
+ rti1516::ObjectClassHandle theObjectClass,
+ std::wstring const & theObjectInstanceName)
+ throw (rti1516::CouldNotDiscover,
+ rti1516::ObjectClassNotKnown,
+ rti1516::FederateInternalError)
+ {
+ std::wcerr << L"Object Instance '" << theObjectInstanceName <<
L"' discoverd. (callback 6.5)" << std::endl;
+ }
+
+ // 6.7 a
+ void
+ TestFedAmbCallbacks::reflectAttributeValues
+ (rti1516::ObjectInstanceHandle theObject,
+ rti1516::AttributeHandleValueMap const & theAttributeValues,
+ rti1516::VariableLengthData const & theUserSuppliedTag,
+ rti1516::OrderType sentOrder,
+ rti1516::TransportationType theType)
+ throw (rti1516::ObjectInstanceNotKnown,
+ rti1516::AttributeNotRecognized,
+ rti1516::AttributeNotSubscribed,
+ rti1516::FederateInternalError)
+ {
+ std::wcerr << L"Attribute Values Reflected (callback 6.7 a)" <<
std::endl;
+ }
+
+ // 6.7 b
+ void
+ TestFedAmbCallbacks::reflectAttributeValues
+ (rti1516::ObjectInstanceHandle theObject,
+ rti1516::AttributeHandleValueMap const & theAttributeValues,
+ rti1516::VariableLengthData const & theUserSuppliedTag,
+ rti1516::OrderType sentOrder,
+ rti1516::TransportationType theType,
+ rti1516::RegionHandleSet const & theSentRegionHandleSet)
+ throw (rti1516::ObjectInstanceNotKnown,
+ rti1516::AttributeNotRecognized,
+ rti1516::AttributeNotSubscribed,
+ rti1516::FederateInternalError)
+ {
+ std::wcerr << L"Attribute Values Reflected (callback 6.7 b)" <<
std::endl;
+ }
+
+ // 6.7 c
+ void
+ TestFedAmbCallbacks::reflectAttributeValues
+ (rti1516::ObjectInstanceHandle theObject,
+ rti1516::AttributeHandleValueMap const & theAttributeValues,
+ rti1516::VariableLengthData const & theUserSuppliedTag,
+ rti1516::OrderType sentOrder,
+ rti1516::TransportationType theType,
+ rti1516::LogicalTime const & theTime,
+ rti1516::OrderType receivedOrder)
+ throw (rti1516::ObjectInstanceNotKnown,
+ rti1516::AttributeNotRecognized,
+ rti1516::AttributeNotSubscribed,
+ rti1516::FederateInternalError)
+ {
+ std::wcerr << L"Attribute Values Reflected (callback 6.7 c)" <<
std::endl;
+ }
+
+ // 6.7 d
+ void
+ TestFedAmbCallbacks::reflectAttributeValues
+ (rti1516::ObjectInstanceHandle theObject,
+ rti1516::AttributeHandleValueMap const & theAttributeValues,
+ rti1516::VariableLengthData const & theUserSuppliedTag,
+ rti1516::OrderType sentOrder,
+ rti1516::TransportationType theType,
+ rti1516::LogicalTime const & theTime,
+ rti1516::OrderType receivedOrder,
+ rti1516::RegionHandleSet const & theSentRegionHandleSet)
+ throw (rti1516::ObjectInstanceNotKnown,
+ rti1516::AttributeNotRecognized,
+ rti1516::AttributeNotSubscribed,
+ rti1516::FederateInternalError)
+ {
+ std::wcerr << L"Attribute Values Reflected (callback 6.7 d)" <<
std::endl;
+ }
+
+ // 6.7 e
+ void
+ TestFedAmbCallbacks::reflectAttributeValues
+ (rti1516::ObjectInstanceHandle theObject,
+ rti1516::AttributeHandleValueMap const & theAttributeValues,
+ rti1516::VariableLengthData const & theUserSuppliedTag,
+ rti1516::OrderType sentOrder,
+ rti1516::TransportationType theType,
+ rti1516::LogicalTime const & theTime,
+ rti1516::OrderType receivedOrder,
+ rti1516::MessageRetractionHandle theHandle)
+ throw (rti1516::ObjectInstanceNotKnown,
+ rti1516::AttributeNotRecognized,
+ rti1516::AttributeNotSubscribed,
+ rti1516::InvalidLogicalTime,
+ rti1516::FederateInternalError)
+ {
+ std::wcerr << L"Attribute Values Reflected (callback 6.7 e)" <<
std::endl;
+ }
+
+ // 6.7 f
+ void
+ TestFedAmbCallbacks::reflectAttributeValues
+ (rti1516::ObjectInstanceHandle theObject,
+ rti1516::AttributeHandleValueMap const & theAttributeValues,
+ rti1516::VariableLengthData const & theUserSuppliedTag,
+ rti1516::OrderType sentOrder,
+ rti1516::TransportationType theType,
+ rti1516::LogicalTime const & theTime,
+ rti1516::OrderType receivedOrder,
+ rti1516::MessageRetractionHandle theHandle,
+ rti1516::RegionHandleSet const & theSentRegionHandleSet)
+ throw (rti1516::ObjectInstanceNotKnown,
+ rti1516::AttributeNotRecognized,
+ rti1516::AttributeNotSubscribed,
+ rti1516::InvalidLogicalTime,
+ rti1516::FederateInternalError)
+ {
+ std::wcerr << L"Attribute Values Reflected (callback 6.7 f)" <<
std::endl;
+ }
+
+ // 6.11 a
+ void
+ TestFedAmbCallbacks::removeObjectInstance(rti1516::ObjectInstanceHandle
theObject,
+ rti1516::VariableLengthData const &
theUserSuppliedTag,
+ rti1516::OrderType sentOrder)
+ throw (rti1516::ObjectInstanceNotKnown,
+ rti1516::FederateInternalError)
+ {
+ std::wcerr << L"Object instance removed (callback 6.11 a)" <<
std::endl;
+ }
+
+ // 6.11 b
+ void
+ TestFedAmbCallbacks::removeObjectInstance(rti1516::ObjectInstanceHandle
theObject,
+ rti1516::VariableLengthData const &
theUserSuppliedTag,
+ rti1516::OrderType sentOrder,
+ rti1516::LogicalTime const & theTime,
+ rti1516::OrderType receivedOrder)
+ throw (rti1516::ObjectInstanceNotKnown,
+ rti1516::FederateInternalError)
+ {
+ std::wcerr << L"Object instance removed (callback 6.11 b)" <<
std::endl;
+ }
+
+ // 6.11 c
+ void
+ TestFedAmbCallbacks::removeObjectInstance(rti1516::ObjectInstanceHandle
theObject,
+ rti1516::VariableLengthData const &
theUserSuppliedTag,
+ rti1516::OrderType sentOrder,
+ rti1516::LogicalTime const & theTime,
+ rti1516::OrderType receivedOrder,
+ rti1516::MessageRetractionHandle theHandle)
+ throw (rti1516::ObjectInstanceNotKnown,
+ rti1516::InvalidLogicalTime,
+ rti1516::FederateInternalError)
+ {
+ std::wcerr << L"Object instance removed (callback 6.11 c)" <<
std::endl;
+ }
Index: 01.fed
===================================================================
RCS file: 01.fed
diff -N 01.fed
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ 01.fed 31 May 2010 14:15:08 -0000 1.1
@@ -0,0 +1,37 @@
+;; Billard
+
+(Fed
+ (Federation Test)
+ (FedVersion v1.3)
+ (Federate "fed" "Public")
+ (Spaces
+ (Space "Geo"
+ (Dimension X)
+ (Dimension Y)
+ )
+ )
+ (Objects
+ (Class ObjectRoot
+ (Attribute privilegeToDelete reliable timestamp)
+ (Class RTIprivate)
+ (Class Bille
+ (Attribute PositionX RELIABLE TIMESTAMP)
+ (Attribute PositionY RELIABLE TIMESTAMP)
+ (Class Boule
+ (Attribute Color RELIABLE TIMESTAMP)
+ )
+ )
+ )
+ )
+ (Interactions
+ (Class InteractionRoot BEST_EFFORT RECEIVE
+ (Class RTIprivate BEST_EFFORT RECEIVE)
+ (Class Bing RELIABLE TIMESTAMP
+ (Sec_Level "Public")
+ (Parameter BoulNum)
+ (Parameter DX)
+ (Parameter DY)
+ )
+ )
+ )
+)
Index: 06-TimeEncodingTest.hh
===================================================================
RCS file: 06-TimeEncodingTest.hh
diff -N 06-TimeEncodingTest.hh
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ 06-TimeEncodingTest.hh 31 May 2010 14:15:08 -0000 1.1
@@ -0,0 +1,28 @@
+#ifndef FED_EXECUTION_TEST_H
+#define FED_EXECUTION_TEST_H
+
+#include <RTI/NullFederateAmbassador.h>
+
+namespace rti1516 {
+ class RTIambassador;
+}
+
+class TestFedAmb : public rti1516::NullFederateAmbassador
+{
+public:
+ TestFedAmb()
+ throw ();
+ ~TestFedAmb()
+ throw ();
+
+ int execute(int argc, char **argv);
+
+private:
+ rti1516::RTIambassador *rtiAmb;
+ rti1516::FederateHandle fedHandle;
+ std::wstring fedName;
+ std::wstring federationName;
+
+};
+
+#endif // FED_EXECUTION_TEST_H
Index: 03-PublishingTest.hh
===================================================================
RCS file: 03-PublishingTest.hh
diff -N 03-PublishingTest.hh
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ 03-PublishingTest.hh 31 May 2010 14:15:09 -0000 1.1
@@ -0,0 +1,28 @@
+#ifndef FED_EXECUTION_TEST_H
+#define FED_EXECUTION_TEST_H
+
+#include <RTI/NullFederateAmbassador.h>
+
+namespace rti1516 {
+ class RTIambassador;
+}
+
+class TestFedAmb : public rti1516::NullFederateAmbassador
+{
+public:
+ TestFedAmb()
+ throw ();
+ ~TestFedAmb()
+ throw ();
+
+ int execute(int argc, char **argv);
+
+private:
+ rti1516::RTIambassador *rtiAmb;
+ rti1516::FederateHandle fedHandle;
+ std::wstring fedName;
+ std::wstring federationName;
+
+};
+
+#endif // FED_EXECUTION_TEST_H
Index: 05-ObjectManagementCallbackTest.hh
===================================================================
RCS file: 05-ObjectManagementCallbackTest.hh
diff -N 05-ObjectManagementCallbackTest.hh
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ 05-ObjectManagementCallbackTest.hh 31 May 2010 14:15:09 -0000 1.1
@@ -0,0 +1,163 @@
+#ifndef OBJECT_MANAGEMENT_CALLBACK_TEST_H
+#define OBJECT_MANAGEMENT_CALLBACK_TEST_H
+
+#include <RTI/NullFederateAmbassador.h>
+
+namespace rti1516 {
+ class RTIambassador;
+}
+
+class TestFedAmbCallbacks : public rti1516::NullFederateAmbassador
+{
+public:
+ TestFedAmbCallbacks()
+ throw ();
+ ~TestFedAmbCallbacks()
+ throw ();
+
+ int execute();
+
+
+ // 6.5
+ virtual void
+ discoverObjectInstance(rti1516::ObjectInstanceHandle theObject,
+ rti1516::ObjectClassHandle theObjectClass,
+ std::wstring const & theObjectInstanceName)
+ throw (rti1516::CouldNotDiscover,
+ rti1516::ObjectClassNotKnown,
+ rti1516::FederateInternalError);
+
+ // 6.7 a
+ virtual void
+ reflectAttributeValues
+ (rti1516::ObjectInstanceHandle theObject,
+ rti1516::AttributeHandleValueMap const & theAttributeValues,
+ rti1516::VariableLengthData const & theUserSuppliedTag,
+ rti1516::OrderType sentOrder,
+ rti1516::TransportationType theType)
+ throw (rti1516::ObjectInstanceNotKnown,
+ rti1516::AttributeNotRecognized,
+ rti1516::AttributeNotSubscribed,
+ rti1516::FederateInternalError);
+
+ // 6.7 b
+ virtual void
+ reflectAttributeValues
+ (rti1516::ObjectInstanceHandle theObject,
+ rti1516::AttributeHandleValueMap const & theAttributeValues,
+ rti1516::VariableLengthData const & theUserSuppliedTag,
+ rti1516::OrderType sentOrder,
+ rti1516::TransportationType theType,
+ rti1516::RegionHandleSet const & theSentRegionHandleSet)
+ throw (rti1516::ObjectInstanceNotKnown,
+ rti1516::AttributeNotRecognized,
+ rti1516::AttributeNotSubscribed,
+ rti1516::FederateInternalError);
+
+ // 6.7 c
+ virtual void
+ reflectAttributeValues
+ (rti1516::ObjectInstanceHandle theObject,
+ rti1516::AttributeHandleValueMap const & theAttributeValues,
+ rti1516::VariableLengthData const & theUserSuppliedTag,
+ rti1516::OrderType sentOrder,
+ rti1516::TransportationType theType,
+ rti1516::LogicalTime const & theTime,
+ rti1516::OrderType receivedOrder)
+ throw (rti1516::ObjectInstanceNotKnown,
+ rti1516::AttributeNotRecognized,
+ rti1516::AttributeNotSubscribed,
+ rti1516::FederateInternalError);
+
+ // 6.7 d
+ virtual void
+ reflectAttributeValues
+ (rti1516::ObjectInstanceHandle theObject,
+ rti1516::AttributeHandleValueMap const & theAttributeValues,
+ rti1516::VariableLengthData const & theUserSuppliedTag,
+ rti1516::OrderType sentOrder,
+ rti1516::TransportationType theType,
+ rti1516::LogicalTime const & theTime,
+ rti1516::OrderType receivedOrder,
+ rti1516::RegionHandleSet const & theSentRegionHandleSet)
+ throw (rti1516::ObjectInstanceNotKnown,
+ rti1516::AttributeNotRecognized,
+ rti1516::AttributeNotSubscribed,
+ rti1516::FederateInternalError);
+
+ // 6.7 e
+ virtual void
+ reflectAttributeValues
+ (rti1516::ObjectInstanceHandle theObject,
+ rti1516::AttributeHandleValueMap const & theAttributeValues,
+ rti1516::VariableLengthData const & theUserSuppliedTag,
+ rti1516::OrderType sentOrder,
+ rti1516::TransportationType theType,
+ rti1516::LogicalTime const & theTime,
+ rti1516::OrderType receivedOrder,
+ rti1516::MessageRetractionHandle theHandle)
+ throw (rti1516::ObjectInstanceNotKnown,
+ rti1516::AttributeNotRecognized,
+ rti1516::AttributeNotSubscribed,
+ rti1516::InvalidLogicalTime,
+ rti1516::FederateInternalError);
+
+ // 6.7 f
+ virtual void
+ reflectAttributeValues
+ (rti1516::ObjectInstanceHandle theObject,
+ rti1516::AttributeHandleValueMap const & theAttributeValues,
+ rti1516::VariableLengthData const & theUserSuppliedTag,
+ rti1516::OrderType sentOrder,
+ rti1516::TransportationType theType,
+ rti1516::LogicalTime const & theTime,
+ rti1516::OrderType receivedOrder,
+ rti1516::MessageRetractionHandle theHandle,
+ rti1516::RegionHandleSet const & theSentRegionHandleSet)
+ throw (rti1516::ObjectInstanceNotKnown,
+ rti1516::AttributeNotRecognized,
+ rti1516::AttributeNotSubscribed,
+ rti1516::InvalidLogicalTime,
+ rti1516::FederateInternalError);
+
+ // 6.11 a
+ virtual void
+ removeObjectInstance(rti1516::ObjectInstanceHandle theObject,
+ rti1516::VariableLengthData const &
theUserSuppliedTag,
+ rti1516::OrderType sentOrder)
+ throw (rti1516::ObjectInstanceNotKnown,
+ rti1516::FederateInternalError);
+
+ // 6.11 b
+ virtual void
+ removeObjectInstance(rti1516::ObjectInstanceHandle theObject,
+ rti1516::VariableLengthData const &
theUserSuppliedTag,
+ rti1516::OrderType sentOrder,
+ rti1516::LogicalTime const & theTime,
+ rti1516::OrderType receivedOrder)
+ throw (rti1516::ObjectInstanceNotKnown,
+ rti1516::FederateInternalError);
+
+ // 6.11 c
+ virtual void
+ removeObjectInstance(rti1516::ObjectInstanceHandle theObject,
+ rti1516::VariableLengthData const &
theUserSuppliedTag,
+ rti1516::OrderType sentOrder,
+ rti1516::LogicalTime const & theTime,
+ rti1516::OrderType receivedOrder,
+ rti1516::MessageRetractionHandle theHandle)
+ throw (rti1516::ObjectInstanceNotKnown,
+ rti1516::InvalidLogicalTime,
+ rti1516::FederateInternalError);
+
+
+private:
+ rti1516::RTIambassador *rtiAmb;
+ rti1516::FederateHandle fedHandle;
+ std::wstring fedName;
+ std::wstring federationName;
+
+};
+
+
+#endif // OBJECT_MANAGEMENT_CALLBACK_TEST_H
Index: ReturnCodes.hh
===================================================================
RCS file: ReturnCodes.hh
diff -N ReturnCodes.hh
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ ReturnCodes.hh 31 May 2010 14:15:09 -0000 1.1
@@ -0,0 +1,46 @@
+#ifndef CERTI_RTI1516_RETURN_CODES_H
+#define CERTI_RTI1516_RETURN_CODES_H
+
+namespace certi {
+ namespace rti1516_test {
+
+ enum ReturnCode {
+ RETURN_NO_ERRORS = 0,
+ RETURN_ERROR_CREATING_AMBASSADOR,
+ RETURN_ERROR_CREATING_FEDERATION,
+ RETURN_ERROR_JOINING_INVALID_FEDERATION ,
+ RETURN_ERROR_JOINING_VALID_FEDERATION,
+ RETURN_ERROR_PUBLISHING_INTERACTIONS,
+ RETURN_ERROR_DESTROYING_FEDERATION,
+ RETURN_ERROR_RESIGNING_FEDERATION,
+ RETURN_ERROR_GET_CLASS_HANDLE,
+ RETURN_ERROR_GET_CLASS_NAME,
+ RETURN_ERROR_GET_ATTRIBUTE_HANDLE,
+ RETURN_ERROR_GET_ATTRIBUTE_NAME,
+ RETURN_ERROR_GET_INTERACTION_HANDLE,
+ RETURN_ERROR_GET_INTERACTION_NAME,
+ RETURN_ERROR_GET_PARAMETER_HANDLE,
+ RETURN_ERROR_GET_PARAMETER_NAME,
+ RETURN_ERROR_GET_OBJECT_HANDLE,
+ RETURN_ERROR_GET_OBJECT_NAME,
+ RETURN_ERROR_PUBLISH_CLASS_ATTRIBUTES,
+ RETURN_ERROR_UNPUBLISH_CLASS,
+ RETURN_ERROR_UNPUBLISH_CLASS_ATTRIBUTES,
+ RETURN_ERROR_PUBLISH_INTERACTION,
+ RETURN_ERROR_UNPUBLISH_INTERACTION,
+ RETURN_ERROR_SUBSCRIBE_CLASS_ATTRIBUTES,
+ RETURN_ERROR_UNSUBSCRIBE_CLASS,
+ RETURN_ERROR_UNSUBSCRIBE_CLASS_ATTRIBUTES,
+ RETURN_ERROR_SUBSCRIBE_INTERACTION,
+ RETURN_ERROR_UNSUBSCRIBE_INTERACTION,
+ RETURN_UNDEFINED_ERROR,
+
+ };
+
+ }
+}
+
+
+
+
+#endif // CERTI_RTI1516_RETURN_CODES_H
Index: 06-TimeEncodingTest.cc
===================================================================
RCS file: 06-TimeEncodingTest.cc
diff -N 06-TimeEncodingTest.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ 06-TimeEncodingTest.cc 31 May 2010 14:15:09 -0000 1.1
@@ -0,0 +1,218 @@
+#include "03-PublishingTest.hh"
+#include "ReturnCodes.hh"
+
+#include <RTI/certiRTI1516.h>
+#include <RTI1516fedTime.h>
+#include <RTI/Enums.h>
+#include <iostream>
+#include <sstream>
+#include <cstdlib>
+#include <ctime>
+#include <cstdio>
+
+/***************************************
+ * This file is part of the Unit testing done for the HLA1516
+ * functionality in CERTI.
+ *
+ * This test requires that it's FOM file (with .xml extention)
+ * is placed under $BUILD/share/federations/
+ *
+ * Before running this test, start the 'rtig' project.
+ *
+ * The test will pause during it's run to allow the tester to review
+ * the test results. Press <Return> to continue when the test is paused.
+*****************************************/
+
+int main(int argc, char** argv)
+{
+ int retCode1 = 0;
+
+ srand( time(0) );
+
+ TestFedAmb *fedAmb = new TestFedAmb();
+
+ retCode1 = fedAmb->execute(argc, argv);
+
+
+
+ if ( retCode1 == certi::rti1516_test::RETURN_NO_ERRORS)
+ {
+ std::wcerr << L"Pass: Test completed" << std::endl;
+ } else
+ {
+ std::wcerr << L"Fail: Test failed with error code: " <<
retCode1 << std::endl;
+
+ }
+
+ // Poor man's 'pause'
+ std::wcerr << L"Press enter to stop connection to RTI." << std::endl;
+ getchar();
+
+ delete fedAmb;
+
+ // Poor man's 'pause'
+ getchar();
+
+ return retCode1;
+}
+
+TestFedAmb::TestFedAmb() throw()
+: rtiAmb(0)
+, fedHandle()
+, fedName()
+, federationName(L"TestFederationName")
+{
+ int nameVal;
+
+ nameVal = (rand() % 99) + 1;
+
+ std::wstringstream stream;
+ stream << L"TestFederate" << nameVal;
+
+ fedName = stream.str();
+ std::wcerr << L"Federate name:" << fedName << std::endl;
+
+}
+
+TestFedAmb::~TestFedAmb() throw()
+{
+ delete rtiAmb;
+}
+
+int TestFedAmb::execute(int argc, char** argv)
+{
+ std::wcerr << L"01T Test: Attempting to set up test environment (create
and join federation)" << std::endl;
+ std::auto_ptr< rti1516::RTIambassadorFactory > rtiAmbFact(new
rti1516::RTIambassadorFactory());
+ std::vector< std::wstring > constructorArgs;
+
+ // valid handles (are initialized in setup phase)
+ rti1516::ObjectClassHandle classHandle;
+ rti1516::AttributeHandle attrHandle;
+ rti1516::AttributeHandleSet classAttributes;
+ rti1516::InteractionClassHandle msgHandle;
+
+ // Invalid handles.
+ rti1516::ObjectClassHandle xClassHandle;
+ rti1516::AttributeHandle xAttrHandle;
+ rti1516::AttributeHandleSet xClassAttributes;
+ xClassAttributes.insert(xAttrHandle);
+ rti1516::InteractionClassHandle xMsgHandle;
+
+ std::wstring testId(L"00");
+
+ testId = L"01";
+
+ try {
+ //////////////////////////////////////////////
+ // Set up
+ std::auto_ptr< rti1516::RTIambassador >
rtiAmbP(rtiAmbFact->createRTIambassador(constructorArgs));
+ rtiAmb = rtiAmbP.release();
+
+ try {
+ rtiAmb->createFederationExecution(federationName,
L"Certi-Test-02.xml");
+ // expected
+ } catch (rti1516::FederationExecutionAlreadyExists &)
+ {
+ // expected
+ } catch (rti1516::Exception &)
+ {
+ throw;
+ }
+
+ fedHandle = rtiAmb->joinFederationExecution(fedName,
federationName, *this);
+
+ classHandle = rtiAmb->getObjectClassHandle(L"TestObjectClass");
+ attrHandle = rtiAmb->getAttributeHandle(classHandle, L"Data");
+ classAttributes.insert(attrHandle);
+ msgHandle = rtiAmb->getInteractionClassHandle(L"Msg");
+
+ } catch (rti1516::Exception &e)
+ {
+ std::wcerr << testId << L"N Fail:" << e.what() << std::endl;
+ return certi::rti1516_test::RETURN_ERROR_CREATING_AMBASSADOR;
+ }
+
+ std::wcerr << testId << L"E Pass: Federation joined. Press enter to
continue with test." << std::endl;
+ getchar();
+
+ testId = L"02";
+ try {
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"T Test: Attempting to Query GALT" <<
std::endl;
+ RTI1516fedTime fedTime(2.0);
+ std::wcerr << testId << L"time before: " <<
fedTime.getFedTime() << std::endl;
+ bool retVal = rtiAmb->queryGALT(fedTime);
+ std::wcerr << testId << L"time after: " << fedTime.getFedTime()
<< std::endl;
+ ////////////////////////////////////////////////
+ if (retVal) {
+ if (fedTime.getFedTime() == 2.0) {
+ std::wcerr << testId << L"N Fail: time did not
change" << std::endl;
+ return
certi::rti1516_test::RETURN_UNDEFINED_ERROR;
+ } else {
+ std::wcerr << testId << L"E Pass: Could Query
GALT" << std::endl;
+ }
+ } else {
+ std::wcerr << testId << L"N Fail: Query GALT returned
false" << std::endl;
+ return certi::rti1516_test::RETURN_UNDEFINED_ERROR;
+ }
+ } catch (rti1516::Exception &e)
+ {
+ std::wcerr << testId << L"N Fail: " << e.what() << std::endl;
+ return certi::rti1516_test::RETURN_UNDEFINED_ERROR;
+ }
+
+ testId = L"03";
+ try {
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"T Test: Attempting to Query LITS" <<
std::endl;
+ RTI1516fedTime fedTime(2.0);
+ std::wcerr << testId << L"time before: " <<
fedTime.getFedTime() << std::endl;
+ bool retVal = rtiAmb->queryLITS(fedTime);
+ std::wcerr << testId << L"time after: " << fedTime.getFedTime()
<< std::endl;
+ ////////////////////////////////////////////////
+ if (retVal) {
+ if (fedTime.getFedTime() == 2.0) {
+ std::wcerr << testId << L"N Fail: time did not
change" << std::endl;
+ return
certi::rti1516_test::RETURN_UNDEFINED_ERROR;
+ } else {
+ std::wcerr << testId << L"E Pass: Could Query
LITS" << std::endl;
+ }
+ } else {
+ std::wcerr << testId << L"N Fail: Query LITS returned
false" << std::endl;
+ return certi::rti1516_test::RETURN_UNDEFINED_ERROR;
+ }
+ } catch (rti1516::Exception &e)
+ {
+ std::wcerr << testId << L"N Fail: " << e.what() << std::endl;
+ return certi::rti1516_test::RETURN_UNDEFINED_ERROR;
+ }
+
+
+
///////////////////////////////////////////////////////////////////////////////////////////////
+
///////////////////////////////////////////////////////////////////////////////////////////////
+ std::wcerr << L"Test operations performed. Press enter to continue with
shutdown." << std::endl;
+ getchar();
+
+ try {
+ ////////////////////////////////////////////////
+ std::wcerr << L"Attempting to resign from Federation" <<
std::endl;
+
rtiAmb->resignFederationExecution(rti1516::CANCEL_THEN_DELETE_THEN_DIVEST);
+ std::wcerr << L"Resigned from Federation" << std::endl;
+ std::wcerr << L"Attempting to destroy Federation" << std::endl;
+ rtiAmb->destroyFederationExecution(L"TestFederationName");
+ std::wcerr << L"Destroyed Federation" << std::endl;
+ ////////////////////////////////////////////////
+ // expected
+ std::wcerr << L"Pass" << std::endl;
+ } catch (rti1516::FederatesCurrentlyJoined &)
+ {
+ // expected
+ std::wcerr << L"Pass: Could not destroy federation while
another federate was still connected. This is expected behaviour." << std::endl;
+ } catch (rti1516::Exception &e)
+ {
+ std::wcerr << L"Fail: " << e.what() << std::endl;
+ return certi::rti1516_test::RETURN_ERROR_DESTROYING_FEDERATION;
+ }
+
+ return certi::rti1516_test::RETURN_NO_ERRORS;
+}
Index: 01-FederationExecutionTest.hh
===================================================================
RCS file: 01-FederationExecutionTest.hh
diff -N 01-FederationExecutionTest.hh
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ 01-FederationExecutionTest.hh 31 May 2010 14:15:09 -0000 1.1
@@ -0,0 +1,26 @@
+#ifndef FED_EXECUTION_TEST_H
+#define FED_EXECUTION_TEST_H
+
+#include <RTI/NullFederateAmbassador.h>
+
+namespace rti1516 {
+ class RTIambassador;
+}
+
+class TestFedAmb : public rti1516::NullFederateAmbassador
+{
+public:
+ TestFedAmb()
+ throw ();
+ ~TestFedAmb()
+ throw ();
+
+ int execute(int argc, char **argv);
+
+private:
+ rti1516::RTIambassador *rtiAmb;
+ rti1516::FederateHandle fedHandle;
+
+};
+
+#endif // FED_EXECUTION_TEST_H
Index: 03-PublishingTest.cc
===================================================================
RCS file: 03-PublishingTest.cc
diff -N 03-PublishingTest.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ 03-PublishingTest.cc 31 May 2010 14:15:09 -0000 1.1
@@ -0,0 +1,654 @@
+#include "03-PublishingTest.hh"
+#include "ReturnCodes.hh"
+
+#include <RTI/certiRTI1516.h>
+#include <RTI/Enums.h>
+#include <iostream>
+#include <sstream>
+#include <cstdlib>
+#include <ctime>
+#include <cstdio>
+
+/***************************************
+ * This file is part of the Unit testing done for the HLA1516
+ * functionality in CERTI.
+ *
+ * This test requires that it's FOM file (with .xml extention)
+ * is placed under $BUILD/share/federations/
+ *
+ * Before running this test, start the 'rtig' project.
+ *
+ * The test will pause during it's run to allow the tester to review
+ * the test results. Press <Return> to continue when the test is paused.
+*****************************************/
+
+int main(int argc, char** argv)
+{
+ int retCode1 = 0;
+
+ srand( time(0) );
+
+ TestFedAmb *fedAmb = new TestFedAmb();
+
+ retCode1 = fedAmb->execute(argc, argv);
+
+
+
+ if ( retCode1 == certi::rti1516_test::RETURN_NO_ERRORS)
+ {
+ std::wcerr << L"Pass: Test completed" << std::endl;
+ } else
+ {
+ std::wcerr << L"Fail: Test failed with error code: " <<
retCode1 << std::endl;
+
+ }
+
+ // Poor man's 'pause'
+ std::wcerr << L"Press enter to stop connection to RTI." << std::endl;
+ getchar();
+
+ delete fedAmb;
+
+ // Poor man's 'pause'
+ getchar();
+
+ return retCode1;
+}
+
+TestFedAmb::TestFedAmb() throw()
+: rtiAmb(0)
+, fedHandle()
+, fedName()
+, federationName(L"TestFederationName")
+{
+ int nameVal;
+
+ nameVal = (rand() % 99) + 1;
+
+ std::wstringstream stream;
+ stream << L"TestFederate" << nameVal;
+
+ fedName = stream.str();
+ std::wcerr << L"Federate name:" << fedName << std::endl;
+
+}
+
+TestFedAmb::~TestFedAmb() throw()
+{
+ delete rtiAmb;
+}
+
+int TestFedAmb::execute(int argc, char** argv)
+{
+ std::wcerr << L"01T Test: Attempting to set up test environment (create
and join federation)" << std::endl;
+ std::auto_ptr< rti1516::RTIambassadorFactory > rtiAmbFact(new
rti1516::RTIambassadorFactory());
+ std::vector< std::wstring > constructorArgs;
+
+ // valid handles (are initialized in setup phase)
+ rti1516::ObjectClassHandle classHandle;
+ rti1516::AttributeHandle attrHandle;
+ rti1516::AttributeHandleSet classAttributes;
+ rti1516::InteractionClassHandle msgHandle;
+
+ // Invalid handles.
+ rti1516::ObjectClassHandle xClassHandle;
+ rti1516::AttributeHandle xAttrHandle;
+ rti1516::AttributeHandleSet xClassAttributes;
+ xClassAttributes.insert(xAttrHandle);
+ rti1516::InteractionClassHandle xMsgHandle;
+
+ std::wstring testId(L"00");
+
+ testId = L"01";
+
+ try {
+ //////////////////////////////////////////////
+ // Set up
+ std::auto_ptr< rti1516::RTIambassador >
rtiAmbP(rtiAmbFact->createRTIambassador(constructorArgs));
+ rtiAmb = rtiAmbP.release();
+
+ try {
+ rtiAmb->createFederationExecution(federationName,
L"Certi-Test-02.xml");
+ // expected
+ } catch (rti1516::FederationExecutionAlreadyExists &)
+ {
+ // expected
+ } catch (rti1516::Exception &)
+ {
+ throw;
+ }
+
+ fedHandle = rtiAmb->joinFederationExecution(fedName,
federationName, *this);
+
+ classHandle = rtiAmb->getObjectClassHandle(L"TestObjectClass");
+ attrHandle = rtiAmb->getAttributeHandle(classHandle, L"Data");
+ classAttributes.insert(attrHandle);
+ msgHandle = rtiAmb->getInteractionClassHandle(L"Msg");
+
+ } catch (rti1516::Exception &e)
+ {
+ std::wcerr << testId << L"N Fail:" << e.what() << std::endl;
+ return certi::rti1516_test::RETURN_ERROR_CREATING_AMBASSADOR;
+ }
+
+ std::wcerr << testId << L"E Pass: Federation joined. Press enter to
continue with test." << std::endl;
+ getchar();
+
+ // publishObjectClassAttributes
+ testId = L"02";
+ try {
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"T Test: Attempting to publish
attributes for invalid class and invalid attributes" << std::endl;
+ rtiAmb->publishObjectClassAttributes(xClassHandle,
xClassAttributes);
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"N Fail: Could publish attributes for
invalid class and invalid attributes" << std::endl;
+ return
certi::rti1516_test::RETURN_ERROR_PUBLISH_CLASS_ATTRIBUTES;
+ } catch (rti1516::ObjectClassNotDefined &e)
+ {
+ // expected
+ std::wcerr << testId << L"E Pass:" << e.what() << std::endl;
+ } catch (rti1516::AttributeNotDefined &e)
+ {
+ // expected
+ std::wcerr << testId << L"E Pass:" << e.what() << std::endl;
+ } catch (rti1516::Exception &e)
+ {
+ std::wcerr << testId << L"N Fail:" << e.what() << std::endl;
+ return
certi::rti1516_test::RETURN_ERROR_PUBLISH_CLASS_ATTRIBUTES;
+ }
+ testId = L"03";
+ try {
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"T Test: Attempting to publish
attributes for invalid class and valid attributes" << std::endl;
+ rtiAmb->publishObjectClassAttributes(xClassHandle,
classAttributes);
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"N Fail: Could publish attributes for
invalid class and valid attributes" << std::endl;
+ return
certi::rti1516_test::RETURN_ERROR_PUBLISH_CLASS_ATTRIBUTES;
+ } catch (rti1516::ObjectClassNotDefined &e)
+ {
+ // expected
+ std::wcerr << testId << L"E Pass:" << e.what() << std::endl;
+ } catch (rti1516::AttributeNotDefined &e)
+ {
+ // expected
+ std::wcerr << testId << L"E Pass:" << e.what() << std::endl;
+ } catch (rti1516::Exception &e)
+ {
+ std::wcerr << testId << L"N Fail:" << e.what() << std::endl;
+ return
certi::rti1516_test::RETURN_ERROR_PUBLISH_CLASS_ATTRIBUTES;
+ }
+ testId = L"04";
+ try {
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"T Test: Attempting to publish
attributes for valid class and invalid attributes" << std::endl;
+ rtiAmb->publishObjectClassAttributes(classHandle,
xClassAttributes);
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"N Fail: Could publish attributes for
valid class and invalid attributes" << std::endl;
+ return
certi::rti1516_test::RETURN_ERROR_PUBLISH_CLASS_ATTRIBUTES;
+ } catch (rti1516::AttributeNotDefined &e)
+ {
+ // expected
+ std::wcerr << testId << L"E Pass:" << e.what() << std::endl;
+ } catch (rti1516::Exception &e)
+ {
+ std::wcerr << testId << L"N Fail:" << e.what() << std::endl;
+ return
certi::rti1516_test::RETURN_ERROR_PUBLISH_CLASS_ATTRIBUTES;
+ }
+ testId = L"05";
+ try {
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"T Test: Attempting to publish
attributes for valid class and valid attributes" << std::endl;
+ rtiAmb->publishObjectClassAttributes(classHandle,
classAttributes);
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"E Pass: Could publish attributes for
valid class and valid attributes" << std::endl;
+ } catch (rti1516::Exception &e)
+ {
+ std::wcerr << testId << L"N Fail:" << e.what() << std::endl;
+ return
certi::rti1516_test::RETURN_ERROR_PUBLISH_CLASS_ATTRIBUTES;
+ }
+
+ // unpublishObjectClass
+ testId = L"06";
+ try {
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"T Test: Attempting to unpublish
invalid class" << std::endl;
+ rtiAmb->unpublishObjectClass(xClassHandle);
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"N Fail: Could unpublish invalid
class" << std::endl;
+ return certi::rti1516_test::RETURN_ERROR_UNPUBLISH_CLASS;
+ } catch (rti1516::ObjectClassNotDefined &e)
+ {
+ // expected
+ std::wcerr << testId << L"E Pass:" << e.what() << std::endl;
+ } catch (rti1516::Exception &e)
+ {
+ std::wcerr << testId << L"N Fail:" << e.what() << std::endl;
+ return certi::rti1516_test::RETURN_ERROR_UNPUBLISH_CLASS;
+ }
+ testId = L"07";
+ try {
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"T Test: Attempting to unpublish valid
class" << std::endl;
+ rtiAmb->unpublishObjectClass(classHandle);
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"E Pass: Could unpublish invalid
class" << std::endl;
+ } catch (rti1516::Exception &e)
+ {
+ std::wcerr << testId << L"N Fail:" << e.what() << std::endl;
+ return certi::rti1516_test::RETURN_ERROR_UNPUBLISH_CLASS;
+ }
+
+ // unpublishObjectClassAttributes
+ testId = L"08";
+ rtiAmb->publishObjectClassAttributes(classHandle, classAttributes);
+ try {
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"T Test: Attempting to unpublish
attributes for invalid class and invalid attributes" << std::endl;
+ rtiAmb->unpublishObjectClassAttributes(xClassHandle,
xClassAttributes);
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"N Fail: Could unpublish attributes
for invalid class and invalid attributes" << std::endl;
+ return
certi::rti1516_test::RETURN_ERROR_UNPUBLISH_CLASS_ATTRIBUTES;
+ } catch (rti1516::ObjectClassNotDefined &e)
+ {
+ // expected
+ std::wcerr << testId << L"E Pass:" << e.what() << std::endl;
+ } catch (rti1516::AttributeNotDefined &e)
+ {
+ // expected
+ std::wcerr << testId << L"E Pass:" << e.what() << std::endl;
+ } catch (rti1516::Exception &e)
+ {
+ std::wcerr << testId << L"N Fail:" << e.what() << std::endl;
+ return
certi::rti1516_test::RETURN_ERROR_UNPUBLISH_CLASS_ATTRIBUTES;
+ }
+ testId = L"09";
+ try {
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"T Test: Attempting to unpublish
attributes for invalid class and valid attributes" << std::endl;
+ rtiAmb->unpublishObjectClassAttributes(xClassHandle,
classAttributes);
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"N Fail: Could unpublish attributes
for invalid class and valid attributes" << std::endl;
+ return
certi::rti1516_test::RETURN_ERROR_UNPUBLISH_CLASS_ATTRIBUTES;
+ } catch (rti1516::ObjectClassNotDefined &e)
+ {
+ // expected
+ std::wcerr << testId << L"E Pass:" << e.what() << std::endl;
+ } catch (rti1516::AttributeNotDefined &e)
+ {
+ // expected
+ std::wcerr << testId << L"E Pass:" << e.what() << std::endl;
+ } catch (rti1516::Exception &e)
+ {
+ std::wcerr << testId << L"N Fail:" << e.what() << std::endl;
+ return
certi::rti1516_test::RETURN_ERROR_UNPUBLISH_CLASS_ATTRIBUTES;
+ }
+ testId = L"10";
+ try {
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"T Test: Attempting to unpublish
attributes for valid class and invalid attributes" << std::endl;
+ rtiAmb->unpublishObjectClassAttributes(classHandle,
xClassAttributes);
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"E Skip." << std::endl;
+
+ // TODO Restore proper handling of test case.
+ //std::wcerr << testId << L"N Fail: Could unpublish attributes
for valid class and invalid attributes" << std::endl;
+ //return
certi::rti1516_test::RETURN_ERROR_UNPUBLISH_CLASS_ATTRIBUTES;
+ } catch (rti1516::ObjectClassNotDefined &e)
+ {
+ // expected
+ std::wcerr << testId << L"E Pass:" << e.what() << std::endl;
+ } catch (rti1516::AttributeNotDefined &e)
+ {
+ // expected
+ std::wcerr << testId << L"E Pass:" << e.what() << std::endl;
+ } catch (rti1516::Exception &e)
+ {
+ std::wcerr << testId << L"N Fail:" << e.what() << std::endl;
+ return
certi::rti1516_test::RETURN_ERROR_UNPUBLISH_CLASS_ATTRIBUTES;
+ }
+ testId = L"11";
+ try {
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"T Test: Attempting to unpublish
attributes for valid class and valid attributes" << std::endl;
+ rtiAmb->unpublishObjectClassAttributes(classHandle,
classAttributes);
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"E Pass: Could unpublish attributes
for valid class and valid attributes" << std::endl;
+ } catch (rti1516::Exception &e)
+ {
+ std::wcerr << testId << L"N Fail:" << e.what() << std::endl;
+ return
certi::rti1516_test::RETURN_ERROR_UNPUBLISH_CLASS_ATTRIBUTES;
+ }
+
+ // publishInteractionClass
+ testId = L"12";
+ try {
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"T Test: Attempting to publish invalid
interaction" << std::endl;
+ rtiAmb->publishInteractionClass(xMsgHandle);
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"N Fail: Could publish invalid
interaction" << std::endl;
+ return certi::rti1516_test::RETURN_ERROR_PUBLISH_INTERACTION;
+ } catch (rti1516::InteractionClassNotDefined &e)
+ {
+ // expected
+ std::wcerr << testId << L"E Pass:" << e.what() << std::endl;
+ } catch (rti1516::Exception &e)
+ {
+ std::wcerr << testId << L"N Fail:" << e.what() << std::endl;
+ return certi::rti1516_test::RETURN_ERROR_PUBLISH_INTERACTION;
+ }
+ testId = L"13";
+ try {
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"T Test: Attempting to publish valid
interaction" << std::endl;
+ rtiAmb->publishInteractionClass(msgHandle);
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"E Pass: Could publish valid
interaction" << std::endl;
+ } catch (rti1516::Exception &e)
+ {
+ std::wcerr << testId << L"N Fail:" << e.what() << std::endl;
+ return certi::rti1516_test::RETURN_ERROR_PUBLISH_INTERACTION;
+ }
+
+ // unpublishInteractionClass
+ testId = L"14";
+ try {
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"T Test: Attempting to unpublish
invalid interaction" << std::endl;
+ rtiAmb->unpublishInteractionClass(xMsgHandle);
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"N Fail: Could unpublish invalid
interaction" << std::endl;
+ return certi::rti1516_test::RETURN_ERROR_UNPUBLISH_INTERACTION;
+ } catch (rti1516::InteractionClassNotDefined &e)
+ {
+ // expected
+ std::wcerr << testId << L"E Pass:" << e.what() << std::endl;
+ } catch (rti1516::Exception &e)
+ {
+ std::wcerr << testId << L"N Fail:" << e.what() << std::endl;
+ return certi::rti1516_test::RETURN_ERROR_UNPUBLISH_INTERACTION;
+ }
+ testId = L"15";
+ try {
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"T Test: Attempting to unpublish valid
interaction" << std::endl;
+ rtiAmb->unpublishInteractionClass(msgHandle);
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"E Pass: Could unpublish valid
interaction" << std::endl;
+ } catch (rti1516::Exception &e)
+ {
+ std::wcerr << testId << L"N Fail:" << e.what() << std::endl;
+ return certi::rti1516_test::RETURN_ERROR_UNPUBLISH_INTERACTION;
+ }
+
+ // subscribeObjectClassAttributes
+ testId = L"16";
+ try {
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"T Test: Attempting to subscribe to
attributes for invalid class and invalid attributes" << std::endl;
+ rtiAmb->subscribeObjectClassAttributes(xClassHandle,
xClassAttributes);
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"N Fail: Could subscribe to attributes
for invalid class and invalid attributes" << std::endl;
+ return
certi::rti1516_test::RETURN_ERROR_SUBSCRIBE_CLASS_ATTRIBUTES;
+ } catch (rti1516::ObjectClassNotDefined &e)
+ {
+ // expected
+ std::wcerr << testId << L"E Pass:" << e.what() << std::endl;
+ } catch (rti1516::AttributeNotDefined &e)
+ {
+ // expected
+ std::wcerr << testId << L"E Pass:" << e.what() << std::endl;
+ } catch (rti1516::Exception &e)
+ {
+ std::wcerr << testId << L"N Fail:" << e.what() << std::endl;
+ return
certi::rti1516_test::RETURN_ERROR_SUBSCRIBE_CLASS_ATTRIBUTES;
+ }
+ testId = L"17";
+ try {
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"T Test: Attempting to subscribe to
attributes for invalid class and valid attributes" << std::endl;
+ rtiAmb->subscribeObjectClassAttributes(xClassHandle,
classAttributes);
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"N Fail: Could subscribe to attributes
for invalid class and valid attributes" << std::endl;
+ return
certi::rti1516_test::RETURN_ERROR_SUBSCRIBE_CLASS_ATTRIBUTES;
+ } catch (rti1516::ObjectClassNotDefined &e)
+ {
+ // expected
+ std::wcerr << testId << L"E Pass:" << e.what() << std::endl;
+ } catch (rti1516::AttributeNotDefined &e)
+ {
+ // expected
+ std::wcerr << testId << L"E Pass:" << e.what() << std::endl;
+ } catch (rti1516::Exception &e)
+ {
+ std::wcerr << testId << L"N Fail:" << e.what() << std::endl;
+ return
certi::rti1516_test::RETURN_ERROR_SUBSCRIBE_CLASS_ATTRIBUTES;
+ }
+ testId = L"18";
+ try {
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"T Test: Attempting to subscribe to
attributes for valid class and invalid attributes" << std::endl;
+ rtiAmb->subscribeObjectClassAttributes(classHandle,
xClassAttributes);
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"N Fail: Could subscribe to attributes
for valid class and invalid attributes" << std::endl;
+ return
certi::rti1516_test::RETURN_ERROR_SUBSCRIBE_CLASS_ATTRIBUTES;
+ } catch (rti1516::AttributeNotDefined &e)
+ {
+ // expected
+ std::wcerr << testId << L"E Pass:" << e.what() << std::endl;
+ } catch (rti1516::Exception &e)
+ {
+ std::wcerr << testId << L"N Fail:" << e.what() << std::endl;
+ return
certi::rti1516_test::RETURN_ERROR_SUBSCRIBE_CLASS_ATTRIBUTES;
+ }
+ testId = L"19";
+ try {
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"T Test: Attempting to subscribe to
attributes for valid class and valid attributes" << std::endl;
+ rtiAmb->subscribeObjectClassAttributes(classHandle,
classAttributes);
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"E Pass: Could subscribe to attributes
for valid class and valid attributes" << std::endl;
+ } catch (rti1516::Exception &e)
+ {
+ std::wcerr << testId << L"N Fail:" << e.what() << std::endl;
+ return
certi::rti1516_test::RETURN_ERROR_SUBSCRIBE_CLASS_ATTRIBUTES;
+ }
+
+ // unsubscribeObjectClass
+ testId = L"20";
+ try {
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"T Test: Attempting to unsubscribe
from invalid class" << std::endl;
+ rtiAmb->unsubscribeObjectClass(xClassHandle);
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"N Fail: Could unsubscribe from
invalid class" << std::endl;
+ return certi::rti1516_test::RETURN_ERROR_UNSUBSCRIBE_CLASS;
+ } catch (rti1516::ObjectClassNotDefined &e)
+ {
+ // expected
+ std::wcerr << testId << L"E Pass:" << e.what() << std::endl;
+ } catch (rti1516::Exception &e)
+ {
+ std::wcerr << testId << L"N Fail:" << e.what() << std::endl;
+ return certi::rti1516_test::RETURN_ERROR_UNSUBSCRIBE_CLASS;
+ }
+ testId = L"21";
+ try {
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"T Test: Attempting to unsubscribe
from valid class" << std::endl;
+ rtiAmb->unsubscribeObjectClass(classHandle);
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"E Pass: Could unpublish invalid
class" << std::endl;
+ } catch (rti1516::Exception &e)
+ {
+ std::wcerr << testId << L"N Fail:" << e.what() << std::endl;
+ return certi::rti1516_test::RETURN_ERROR_UNSUBSCRIBE_CLASS;
+ }
+
+ // unsubscribeObjectClassAttributes
+ rtiAmb->subscribeObjectClassAttributes(classHandle, classAttributes);
+ testId = L"22";
+ try {
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"T Test: Attempting to unsubscribe
from attributes for invalid class and invalid attributes" << std::endl;
+ rtiAmb->unsubscribeObjectClassAttributes(xClassHandle,
xClassAttributes);
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"N Fail: Could unsubscribe to
attributes for invalid class and invalid attributes" << std::endl;
+ return
certi::rti1516_test::RETURN_ERROR_UNSUBSCRIBE_CLASS_ATTRIBUTES;
+ } catch (rti1516::ObjectClassNotDefined &e)
+ {
+ // expected
+ std::wcerr << testId << L"E Pass:" << e.what() << std::endl;
+ } catch (rti1516::AttributeNotDefined &e)
+ {
+ // expected
+ std::wcerr << testId << L"E Pass:" << e.what() << std::endl;
+ } catch (rti1516::Exception &e)
+ {
+ std::wcerr << testId << L"N Fail:" << e.what() << std::endl;
+ return
certi::rti1516_test::RETURN_ERROR_UNSUBSCRIBE_CLASS_ATTRIBUTES;
+ }
+ testId = L"23";
+ try {
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"T Test: Attempting to unsubscribe
from attributes for invalid class and valid attributes" << std::endl;
+ rtiAmb->unsubscribeObjectClassAttributes(xClassHandle,
classAttributes);
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"N Fail: Could unsubscribe to
attributes for invalid class and valid attributes" << std::endl;
+ return
certi::rti1516_test::RETURN_ERROR_UNSUBSCRIBE_CLASS_ATTRIBUTES;
+ } catch (rti1516::ObjectClassNotDefined &e)
+ {
+ // expected
+ std::wcerr << testId << L"E Pass:" << e.what() << std::endl;
+ } catch (rti1516::AttributeNotDefined &e)
+ {
+ // expected
+ std::wcerr << testId << L"E Pass:" << e.what() << std::endl;
+ } catch (rti1516::Exception &e)
+ {
+ std::wcerr << testId << L"N Fail:" << e.what() << std::endl;
+ return
certi::rti1516_test::RETURN_ERROR_UNSUBSCRIBE_CLASS_ATTRIBUTES;
+ }
+ testId = L"24";
+ try {
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"T Test: Attempting to unsubscribe
from attributes for valid class and invalid attributes" << std::endl;
+ rtiAmb->unsubscribeObjectClassAttributes(classHandle,
xClassAttributes);
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"E Skip." << std::endl;
+
+ // TODO Restore proper handling of test case.
+ //std::wcerr << testId << L"N Fail: Could unsubscribe to
attributes for valid class and invalid attributes" << std::endl;
+ //return
certi::rti1516_test::RETURN_ERROR_UNSUBSCRIBE_CLASS_ATTRIBUTES;
+ } catch (rti1516::AttributeNotDefined &e)
+ {
+ // expected
+ std::wcerr << testId << L"E Pass:" << e.what() << std::endl;
+ } catch (rti1516::Exception &e)
+ {
+ std::wcerr << testId << L"N Fail:" << e.what() << std::endl;
+ return
certi::rti1516_test::RETURN_ERROR_UNSUBSCRIBE_CLASS_ATTRIBUTES;
+ }
+ testId = L"25";
+ try {
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"T Test: Attempting to unsubscribe
from attributes for valid class and valid attributes" << std::endl;
+ rtiAmb->unsubscribeObjectClassAttributes(classHandle,
classAttributes);
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"E Pass: Could unsubscribe to
attributes for valid class and valid attributes" << std::endl;
+ } catch (rti1516::Exception &e)
+ {
+ std::wcerr << testId << L"N Fail:" << e.what() << std::endl;
+ return
certi::rti1516_test::RETURN_ERROR_UNSUBSCRIBE_CLASS_ATTRIBUTES;
+ }
+
+ // subscribeInteractionClass
+ testId = L"26";
+ try {
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"T Test: Attempting to subscribe to
invalid interaction" << std::endl;
+ rtiAmb->subscribeInteractionClass(xMsgHandle);
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"N Fail: Could subscribe to invalid
interaction" << std::endl;
+ return certi::rti1516_test::RETURN_ERROR_SUBSCRIBE_INTERACTION;
+ } catch (rti1516::InteractionClassNotDefined &e)
+ {
+ // expected
+ std::wcerr << testId << L"E Pass:" << e.what() << std::endl;
+ } catch (rti1516::Exception &e)
+ {
+ std::wcerr << testId << L"N Fail:" << e.what() << std::endl;
+ return certi::rti1516_test::RETURN_ERROR_SUBSCRIBE_INTERACTION;
+ }
+ testId = L"27";
+ try {
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"T Test: Attempting to subscribe to
valid interaction" << std::endl;
+ rtiAmb->subscribeInteractionClass(msgHandle);
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"E Pass: Could subscribe to valid
interaction" << std::endl;
+ } catch (rti1516::Exception &e)
+ {
+ std::wcerr << testId << L"N Fail:" << e.what() << std::endl;
+ return certi::rti1516_test::RETURN_ERROR_SUBSCRIBE_INTERACTION;
+ }
+
+ // unsubscribeInteractionClass
+ testId = L"28";
+ try {
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"T Test: Attempting to unsubscribe
from invalid interaction" << std::endl;
+ rtiAmb->unsubscribeInteractionClass(xMsgHandle);
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"N Fail: Could unsubscribe from
invalid interaction" << std::endl;
+ return certi::rti1516_test::RETURN_ERROR_SUBSCRIBE_INTERACTION;
+ } catch (rti1516::InteractionClassNotDefined &e)
+ {
+ // expected
+ std::wcerr << testId << L"E Pass:" << e.what() << std::endl;
+ } catch (rti1516::Exception &e)
+ {
+ std::wcerr << testId << L"N Fail:" << e.what() << std::endl;
+ return
certi::rti1516_test::RETURN_ERROR_UNSUBSCRIBE_INTERACTION;
+ }
+ testId = L"29";
+ try {
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"T Test: Attempting to unsubscribe
from valid interaction" << std::endl;
+ rtiAmb->unsubscribeInteractionClass(msgHandle);
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"E Pass: Could unsubscribe from valid
interaction" << std::endl;
+ } catch (rti1516::Exception &e)
+ {
+ std::wcerr << testId << L"N Fail:" << e.what() << std::endl;
+ return
certi::rti1516_test::RETURN_ERROR_UNSUBSCRIBE_INTERACTION;
+ }
+
+
///////////////////////////////////////////////////////////////////////////////////////////////
+
///////////////////////////////////////////////////////////////////////////////////////////////
+ std::wcerr << L"Test operations performed. Press enter to continue with
shutdown." << std::endl;
+ getchar();
+
+ try {
+ ////////////////////////////////////////////////
+ std::wcerr << L"Attempting to resign from Federation" <<
std::endl;
+
rtiAmb->resignFederationExecution(rti1516::CANCEL_THEN_DELETE_THEN_DIVEST);
+ std::wcerr << L"Resigned from Federation" << std::endl;
+ std::wcerr << L"Attempting to destroy Federation" << std::endl;
+ rtiAmb->destroyFederationExecution(L"TestFederationName");
+ std::wcerr << L"Destroyed Federation" << std::endl;
+ ////////////////////////////////////////////////
+ // expected
+ std::wcerr << L"Pass" << std::endl;
+ } catch (rti1516::FederatesCurrentlyJoined &)
+ {
+ // expected
+ std::wcerr << L"Pass: Could not destroy federation while
another federate was still connected. This is expected behaviour." << std::endl;
+ } catch (rti1516::Exception &e)
+ {
+ std::wcerr << L"Fail: " << e.what() << std::endl;
+ return certi::rti1516_test::RETURN_ERROR_DESTROYING_FEDERATION;
+ }
+
+ return certi::rti1516_test::RETURN_NO_ERRORS;
+}
Index: 02-HandlesAndNamesTest.hh
===================================================================
RCS file: 02-HandlesAndNamesTest.hh
diff -N 02-HandlesAndNamesTest.hh
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ 02-HandlesAndNamesTest.hh 31 May 2010 14:15:09 -0000 1.1
@@ -0,0 +1,28 @@
+#ifndef FED_EXECUTION_TEST_H
+#define FED_EXECUTION_TEST_H
+
+#include <RTI/NullFederateAmbassador.h>
+
+namespace rti1516 {
+ class RTIambassador;
+}
+
+class TestFedAmb : public rti1516::NullFederateAmbassador
+{
+public:
+ TestFedAmb()
+ throw ();
+ ~TestFedAmb()
+ throw ();
+
+ int execute(int argc, char **argv);
+
+private:
+ rti1516::RTIambassador *rtiAmb;
+ rti1516::FederateHandle fedHandle;
+ std::wstring fedName;
+ std::wstring federationName;
+
+};
+
+#endif // FED_EXECUTION_TEST_H
Index: 01-FederationExecutionTest.cc
===================================================================
RCS file: 01-FederationExecutionTest.cc
diff -N 01-FederationExecutionTest.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ 01-FederationExecutionTest.cc 31 May 2010 14:15:09 -0000 1.1
@@ -0,0 +1,186 @@
+#include "01-FederationExecutionTest.hh"
+#include "ReturnCodes.hh"
+
+#include <RTI/certiRTI1516.h>
+#include <RTI/Enums.h>
+#include <iostream>
+#include <cstdio>
+
+/***************************************
+ * This file is part of the Unit testing done for the HLA1516
+ * functionality in CERTI.
+ *
+ * This test requires that it's FOM file (with .xml extention)
+ * is placed under $BUILD/share/federations/
+ *
+ * Before running this test, start the 'rtig' project.
+ *
+ * The test will pause during it's run to allow the tester to review
+ * the test results. Press <Return> to continue when the test is paused.
+*****************************************/
+
+
+int main(int argc, char** argv)
+{
+ int retCode1 = 0;
+ TestFedAmb *fedAmb = new TestFedAmb();
+
+ retCode1 = fedAmb->execute(argc, argv);
+
+ delete fedAmb;
+
+ if ( retCode1 == certi::rti1516_test::RETURN_NO_ERRORS)
+ {
+ std::wcerr << L"Pass: Test completed" << std::endl;
+ } else
+ {
+ std::wcerr << L"Fail: Test failed with error code: " <<
retCode1 << std::endl;
+
+ }
+
+ // Poor man's 'pause'
+ getchar();
+
+ return retCode1;
+}
+
+TestFedAmb::TestFedAmb() throw()
+: rtiAmb(0)
+, fedHandle()
+{
+}
+
+TestFedAmb::~TestFedAmb() throw()
+{
+ delete rtiAmb;
+}
+
+int TestFedAmb::execute(int argc, char** argv)
+{
+ std::auto_ptr< rti1516::RTIambassadorFactory > rtiAmbFact(new
rti1516::RTIambassadorFactory());
+ std::vector< std::wstring > constructorArgs;
+ try {
+ //////////////////////////////////////////////
+ std::auto_ptr< rti1516::RTIambassador >
rtiAmbP(rtiAmbFact->createRTIambassador(constructorArgs));
+ rtiAmb = rtiAmbP.release();
+ //////////////////////////////////////////////
+ } catch (rti1516::RTIinternalError &e)
+ {
+ std::wcerr << L"01N " << e.what() << std::endl;
+ return certi::rti1516_test::RETURN_ERROR_CREATING_AMBASSADOR;
+ } catch (rti1516::Exception &e)
+ {
+ std::wcerr << L"02N " << e.what() << std::endl;
+ return certi::rti1516_test::RETURN_ERROR_CREATING_AMBASSADOR;
+ }
+
+ getchar();
+
+ try {
+ ////////////////////////////////////////////////
+ std::wcerr << L"Attempting to destroy Federation" << std::endl;
+ rtiAmb->destroyFederationExecution(L"TestFederationName");
+ ////////////////////////////////////////////////
+ std::wcerr << L"03E " << L"Pass: Destroyed federation before
starting rest of test" << std::endl;
+ } catch (rti1516::FederationExecutionDoesNotExist &e)
+ {
+ // expected
+ std::wcerr << L"04E " << e.what() << L"(Pass: No federation to
destroy)" << std::endl;
+ } catch (rti1516::Exception &e)
+ {
+ std::wcerr << L"05N " << e.what() << std::endl;
+ return certi::rti1516_test::RETURN_ERROR_DESTROYING_FEDERATION;
+ }
+
+ getchar();
+
+ try {
+ ///////////////////////////////////////////////
+ std::wcerr << L"Attempting to join non-existant Federation" <<
std::endl;
+ fedHandle =
rtiAmb->joinFederationExecution(L"TestFederateName", L"TestFederationName",
*this);
+ ///////////////////////////////////////////////
+ std::wcerr << L"06N " << L"Fail: Could join federation that
should not exist yet." << std::endl;
+ return
certi::rti1516_test::RETURN_ERROR_JOINING_INVALID_FEDERATION;
+ } catch (rti1516::FederationExecutionDoesNotExist &e)
+ {
+ // expected
+ std::wcerr << L"07E " << e.what() << L"(Pass: Could not join
non-existant federation)" << std::endl;
+ } catch (rti1516::Exception &e)
+ {
+ std::wcerr << L"08N " << e.what() << std::endl;
+ return
certi::rti1516_test::RETURN_ERROR_JOINING_INVALID_FEDERATION;
+ }
+
+ getchar();
+
+ try {
+ ////////////////////////////////////////////////
+ std::wcerr << L"Attempting to create Federation" << std::endl;
+ rtiAmb->createFederationExecution(L"TestFederationName",
L"01.xml");
+ ////////////////////////////////////////////////
+ // expected
+ std::wcerr << L"09E Pass: Created federation" << std::endl;
+ } catch (rti1516::Exception &e)
+ {
+ std::wcerr << L"10N " << e.what() << std::endl;
+ return certi::rti1516_test::RETURN_ERROR_CREATING_FEDERATION;
+ }
+
+ try {
+ ////////////////////////////////////////////////
+ std::wcerr << L"Attempting to join Federation" << std::endl;
+ rtiAmb->joinFederationExecution(L"TestFederateName",
L"TestFederationName", *this);
+ ////////////////////////////////////////////////
+ // expected
+ std::wcerr << L"11E Pass: Joined federation" << std::endl;
+ } catch (rti1516::Exception &e)
+ {
+ std::wcerr << L"12N " << e.what() << std::endl;
+ return certi::rti1516_test::RETURN_ERROR_CREATING_FEDERATION;
+ }
+
+ try {
+ ////////////////////////////////////////////////
+ std::wcerr << L"Attempting to destroy Federation while joined"
<< std::endl;
+ rtiAmb->destroyFederationExecution(L"TestFederationName");
+ ////////////////////////////////////////////////
+ std::wcerr << L"13N " << L"Could destroy federation before
resigning!" << std::endl;
+ return certi::rti1516_test::RETURN_ERROR_DESTROYING_FEDERATION;
+ } catch (rti1516::FederatesCurrentlyJoined &e)
+ {
+ // expected
+ std::wcerr << L"14E " << e.what() << L"(Pass: Could not destroy
federation while still joined)" << std::endl;
+ } catch (rti1516::Exception &e)
+ {
+ std::wcerr << L"15N " << e.what() << std::endl;
+ return certi::rti1516_test::RETURN_ERROR_DESTROYING_FEDERATION;
+ }
+
+ try {
+ ////////////////////////////////////////////////
+ std::wcerr << L"Attempting to resign from Federation" <<
std::endl;
+
rtiAmb->resignFederationExecution(rti1516::CANCEL_THEN_DELETE_THEN_DIVEST);
+ ////////////////////////////////////////////////
+ // expected
+ std::wcerr << L"16E " << L"Pass: Resigned from federation" <<
std::endl;
+ } catch (rti1516::Exception &e)
+ {
+ std::wcerr << L"17N " << e.what() << std::endl;
+ return certi::rti1516_test::RETURN_ERROR_DESTROYING_FEDERATION;
+ }
+
+ try {
+ ////////////////////////////////////////////////
+ std::wcerr << L"Attempting to destroy Federation" << std::endl;
+ rtiAmb->destroyFederationExecution(L"TestFederationName");
+ ////////////////////////////////////////////////
+ // expected
+ std::wcerr << L"18E " << L"Pass: Destroyed federation." <<
std::endl;
+ } catch (rti1516::Exception &e)
+ {
+ std::wcerr << L"19N " << e.what() << std::endl;
+ return certi::rti1516_test::RETURN_ERROR_DESTROYING_FEDERATION;
+ }
+
+ return certi::rti1516_test::RETURN_NO_ERRORS;
+}
Index: 02-HandlesAndNamesTest.cc
===================================================================
RCS file: 02-HandlesAndNamesTest.cc
diff -N 02-HandlesAndNamesTest.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ 02-HandlesAndNamesTest.cc 31 May 2010 14:15:09 -0000 1.1
@@ -0,0 +1,765 @@
+#include "02-HandlesAndNamesTest.hh"
+#include "ReturnCodes.hh"
+
+#include <RTI/certiRTI1516.h>
+#include <RTI/Enums.h>
+#include <iostream>
+#include <sstream>
+#include <cstdlib>
+#include <ctime>
+#include <cstdio>
+
+/***************************************
+ * This file is part of the Unit testing done for the HLA1516
+ * functionality in CERTI.
+ *
+ * This test requires that it's FOM file (with .xml extention)
+ * is placed under $BUILD/share/federations/
+ *
+ * Before running this test, start the 'rtig' project.
+ *
+ * The test will pause during it's run to allow the tester to review
+ * the test results. Press <Return> to continue when the test is paused.
+*****************************************/
+
+
+int main(int argc, char** argv)
+{
+ int retCode1 = 0;
+
+ srand( time(0) );
+
+ TestFedAmb *fedAmb = new TestFedAmb();
+
+ retCode1 = fedAmb->execute(argc, argv);
+
+
+
+ if ( retCode1 == certi::rti1516_test::RETURN_NO_ERRORS)
+ {
+ std::wcerr << L"Pass: Test completed" << std::endl;
+ } else
+ {
+ std::wcerr << L"Fail: Test failed with error code: " <<
retCode1 << std::endl;
+
+ }
+
+ // Poor man's 'pause'
+ std::wcerr << L"Press enter to stop connection to RTI." << std::endl;
+ getchar();
+
+ delete fedAmb;
+
+ // Poor man's 'pause'
+ getchar();
+
+ return retCode1;
+}
+
+TestFedAmb::TestFedAmb() throw()
+: rtiAmb(0)
+, fedHandle()
+, fedName()
+, federationName(L"TestFederationName")
+{
+ int nameVal;
+
+ nameVal = (rand() % 99) + 1;
+
+ std::wstringstream stream;
+ stream << L"TestFederate" << nameVal;
+
+ fedName = stream.str();
+ std::wcerr << L"Federate name:" << fedName << std::endl;
+
+}
+
+TestFedAmb::~TestFedAmb() throw()
+{
+ delete rtiAmb;
+}
+
+int TestFedAmb::execute(int argc, char** argv)
+{
+ std::wcerr << L"01T Test: Attempting to set up test environment (create
and join federation)" << std::endl;
+ std::auto_ptr< rti1516::RTIambassadorFactory > rtiAmbFact(new
rti1516::RTIambassadorFactory());
+ std::vector< std::wstring > constructorArgs;
+
+ // Invalid handles.
+ rti1516::ObjectClassHandle xClassHandle;
+ rti1516::AttributeHandle xAttrHandle;
+ rti1516::AttributeHandleSet xClassAttributes;
+ rti1516::InteractionClassHandle xMsgHandle;
+ rti1516::ParameterHandle xParamHandle;
+ rti1516::ObjectInstanceHandle xObjHandle;
+
+ std::wstring testId(L"00");
+
+ testId = L"01";
+
+ try {
+ //////////////////////////////////////////////
+ // Set up
+ std::auto_ptr< rti1516::RTIambassador >
rtiAmbP(rtiAmbFact->createRTIambassador(constructorArgs));
+ rtiAmb = rtiAmbP.release();
+
+ try {
+ rtiAmb->createFederationExecution(federationName,
L"Certi-Test-02.xml");
+ // expected
+ } catch (rti1516::FederationExecutionAlreadyExists &)
+ {
+ // expected
+ } catch (rti1516::Exception &)
+ {
+ throw;
+ }
+
+ fedHandle = rtiAmb->joinFederationExecution(fedName,
federationName, *this);
+
+ } catch (rti1516::Exception &e)
+ {
+ std::wcerr << testId << L"N Fail:" << e.what() << std::endl;
+ return certi::rti1516_test::RETURN_ERROR_CREATING_AMBASSADOR;
+ }
+
+ std::wcerr << testId << L"E Pass: Federation joined. Press enter to
continue with test." << std::endl;
+ getchar();
+
+ testId = L"02";
+ // CLASS HANDLE
+ try {
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"T Test: Attempting to get handle for
invalid class" << std::endl;
+ rti1516::ObjectClassHandle classHandle =
rtiAmb->getObjectClassHandle(L"InvalidObjectClassName");
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"N Fail: Could get class handle for
invalid object class name" << std::endl;
+ return certi::rti1516_test::RETURN_ERROR_GET_CLASS_HANDLE;
+ } catch (rti1516::NameNotFound &e)
+ {
+ // expected
+ std::wcerr << testId << L"E Pass:" << e.what() << std::endl;
+ } catch (rti1516::Exception &e)
+ {
+ std::wcerr << testId << L"N Fail:" << e.what() << std::endl;
+ return certi::rti1516_test::RETURN_ERROR_GET_CLASS_HANDLE;
+ }
+
+ testId = L"03";
+ try {
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"T Test: Attempting to get handle for
valid class name" << std::endl;
+ rti1516::ObjectClassHandle classHandle =
rtiAmb->getObjectClassHandle(L"TestObjectClass");
+ ////////////////////////////////////////////////
+ // expected
+ if ( classHandle.isValid() )
+ {
+ std::wcerr << testId << L"E Pass: Got class handle for
valid class name" << std::endl;
+ } else
+ {
+ std::wcerr << testId << L"N Fail: Got invalid class
handle for valid class name" << std::endl;
+ return
certi::rti1516_test::RETURN_ERROR_GET_CLASS_HANDLE;
+ }
+ } catch (rti1516::Exception &e)
+ {
+ std::wcerr << testId << L"N Fail:" << e.what() << std::endl;
+ return certi::rti1516_test::RETURN_ERROR_GET_CLASS_HANDLE;
+ }
+
+ // CLASS NAME
+ testId = L"04";
+ try {
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"T Test: Attempting to get name for
invalid class handle" << std::endl;
+ rti1516::ObjectClassHandle classHandle;
+ std::wstring className =
rtiAmb->getObjectClassName(classHandle);
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"N Fail: Could get class name for
invalid class handle. Name returned:" << className << std::endl;
+ return certi::rti1516_test::RETURN_ERROR_GET_CLASS_NAME;
+ } catch (rti1516::InvalidObjectClassHandle &e)
+ {
+ // expected
+ std::wcerr << testId << L"E Pass: " << e.what() << std::endl;
+ } catch (rti1516::Exception &e)
+ {
+ std::wcerr << testId << L"N Fail: " << e.what() << std::endl;
+ return certi::rti1516_test::RETURN_ERROR_GET_CLASS_NAME;
+ }
+
+ testId = L"05";
+ try {
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"T Test: Attempting to get name for
valid class handle" << std::endl;
+ std::wstring className(L"TestObjectClass");
+ rti1516::ObjectClassHandle classHandle =
rtiAmb->getObjectClassHandle(className);
+ std::wstring retClassName =
rtiAmb->getObjectClassName(classHandle);
+ ////////////////////////////////////////////////
+ // expected
+ if ( className != retClassName )
+ {
+ std::wcerr << testId << L"N Fail: Returned classname
does not match expected classname. " <<
+ L"(Expected " << className <<
L", got " << retClassName << L".)" << std::endl;
+ return certi::rti1516_test::RETURN_ERROR_GET_CLASS_NAME;
+ } else
+ {
+ std::wcerr << testId << L"E Pass: Got expected
classname" << std::endl;
+ }
+ } catch (rti1516::Exception &e)
+ {
+ std::wcerr << testId << L"N Fail: " << e.what() << std::endl;
+ return certi::rti1516_test::RETURN_ERROR_GET_CLASS_NAME;
+ }
+
+ // ATTRIBUTE HANDLE
+ testId = L"06";
+ try {
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"T Test: Attempting to get attribute
handle for invalid class" << std::endl;
+ rti1516::ObjectClassHandle classHandle;
+ rti1516::AttributeHandle attrHandle =
rtiAmb->getAttributeHandle(classHandle, L"InvalidAttributeName");
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"N Fail: Could get attribute handle
for invalid class handle" << std::endl;
+ return certi::rti1516_test::RETURN_ERROR_GET_ATTRIBUTE_HANDLE;
+ } catch (rti1516::InvalidObjectClassHandle &e)
+ {
+ // expected
+ std::wcerr << testId << L"E Pass:" << e.what() << std::endl;
+ } catch (rti1516::Exception &e)
+ {
+ std::wcerr << testId << L"N Fail:" << e.what() << std::endl;
+ return certi::rti1516_test::RETURN_ERROR_GET_ATTRIBUTE_HANDLE;
+ }
+
+ testId = L"07";
+ try {
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"T Test: Attempting to get handle for
invalid attribute name" << std::endl;
+ rti1516::ObjectClassHandle classHandle =
rtiAmb->getObjectClassHandle(L"TestObjectClass");
+ rti1516::AttributeHandle attrHandle =
rtiAmb->getAttributeHandle(classHandle, L"InvalidAttributeName");
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"N Fail: Could get attribute handle
for invalid attribute name" << std::endl;
+ return certi::rti1516_test::RETURN_ERROR_GET_ATTRIBUTE_HANDLE;
+ } catch (rti1516::NameNotFound &e)
+ {
+ // expected
+ std::wcerr << testId << L"E Pass:" << e.what() << std::endl;
+ } catch (rti1516::Exception &e)
+ {
+ std::wcerr << testId << L"N Fail:" << e.what() << std::endl;
+ return certi::rti1516_test::RETURN_ERROR_GET_ATTRIBUTE_HANDLE;
+ }
+
+ testId = L"08";
+ try {
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"T Test: Attempting to get handle for
valid attribute class" << std::endl;
+ rti1516::ObjectClassHandle classHandle =
rtiAmb->getObjectClassHandle(L"TestObjectClass");
+ rti1516::AttributeHandle attrHandle =
rtiAmb->getAttributeHandle(classHandle, L"Data");
+ ////////////////////////////////////////////////
+ // expected
+ if ( classHandle.isValid() )
+ {
+ std::wcerr << testId << L"E Pass: Got attribute handle
for valid attribute class & name" << std::endl;
+ } else
+ {
+ std::wcerr << testId << L"N Fail: Got invalid class
handle for valid class name" << std::endl;
+ return
certi::rti1516_test::RETURN_ERROR_GET_ATTRIBUTE_HANDLE;
+ }
+ } catch (rti1516::Exception &e)
+ {
+ std::wcerr << testId << L"N Fail:" << e.what() << std::endl;
+ return certi::rti1516_test::RETURN_ERROR_GET_ATTRIBUTE_HANDLE;
+ }
+
+ // ATTRIBUTE NAME
+ testId = L"09";
+ try {
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"T Test: Attempting to get name for
invalid attribute handle of invalid class" << std::endl;
+ std::wstring attrName = rtiAmb->getAttributeName(xClassHandle,
xAttrHandle);
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"N Fail: Could get name for invalid
attribute handle of invalid class" << std::endl;
+ return certi::rti1516_test::RETURN_ERROR_GET_ATTRIBUTE_NAME;
+ } catch (rti1516::InvalidObjectClassHandle &e)
+ {
+ // expected
+ std::wcerr << testId << L"E Pass: " << e.what() << std::endl;
+ } catch (rti1516::InvalidAttributeHandle &e)
+ {
+ // expected
+ std::wcerr << testId << L"E Pass: " << e.what() << std::endl;
+ } catch (rti1516::Exception &e)
+ {
+ std::wcerr << testId << L"N Fail: " << e.what() << std::endl;
+ return certi::rti1516_test::RETURN_ERROR_GET_ATTRIBUTE_NAME;
+ }
+ testId = L"10";
+ try {
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"T Test: Attempting to get name for
invalid attribute handle of valid class" << std::endl;
+ rti1516::ObjectClassHandle classHandle =
rtiAmb->getObjectClassHandle(L"TestObjectClass");
+ std::wstring attrName = rtiAmb->getAttributeName(classHandle,
xAttrHandle);
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"N Fail: Could get name for invalid
attribute handle of valid class" << std::endl;
+ return certi::rti1516_test::RETURN_ERROR_GET_ATTRIBUTE_NAME;
+ } catch (rti1516::InvalidObjectClassHandle &e)
+ {
+ // expected
+ std::wcerr << testId << L"E Pass: " << e.what() << std::endl;
+ } catch (rti1516::InvalidAttributeHandle &e)
+ {
+ // expected
+ std::wcerr << testId << L"E Pass: " << e.what() << std::endl;
+ } catch (rti1516::Exception &e)
+ {
+ std::wcerr << testId << L"N Fail: " << e.what() << std::endl;
+ return certi::rti1516_test::RETURN_ERROR_GET_ATTRIBUTE_NAME;
+ }
+ testId = L"11";
+ try {
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"T Test: Attempting to get name for
valid attribute handle of invalid class" << std::endl;
+ rti1516::ObjectClassHandle classHandle =
rtiAmb->getObjectClassHandle(L"TestObjectClass");
+ rti1516::AttributeHandle attrHandle =
rtiAmb->getAttributeHandle(classHandle, L"Data");
+ std::wstring attrName = rtiAmb->getAttributeName(xClassHandle,
attrHandle);
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"N Fail: Could get name for invalid
attribute handle of invalid class" << std::endl;
+ return certi::rti1516_test::RETURN_ERROR_GET_ATTRIBUTE_NAME;
+ } catch (rti1516::InvalidObjectClassHandle &e)
+ {
+ // expected
+ std::wcerr << testId << L"E Pass: " << e.what() << std::endl;
+ } catch (rti1516::InvalidAttributeHandle &e)
+ {
+ // expected
+ std::wcerr << testId << L"E Pass: " << e.what() << std::endl;
+ } catch (rti1516::Exception &e)
+ {
+ std::wcerr << testId << L"N Fail: " << e.what() << std::endl;
+ return certi::rti1516_test::RETURN_ERROR_GET_ATTRIBUTE_NAME;
+ }
+ testId = L"12";
+ try {
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"T Test: Attempting to get name for
valid attribute handle" << std::endl;
+ rti1516::ObjectClassHandle classHandle =
rtiAmb->getObjectClassHandle(L"TestObjectClass");
+ std::wstring orgAttrName(L"Data");
+ rti1516::AttributeHandle attrHandle =
rtiAmb->getAttributeHandle(classHandle, orgAttrName);
+ std::wstring attrName = rtiAmb->getAttributeName(classHandle,
attrHandle);
+ ////////////////////////////////////////////////
+ if ( orgAttrName == attrName )
+ {
+ std::wcerr << testId << L"E Pass: Could get name for
invalid attribute handle of valid class" << std::endl;
+ } else
+ {
+ std::wcerr << testId << L"N Fail: Could get name for
invalid attribute handle of valid class, but returned name didn't match" <<
std::endl;
+ return
certi::rti1516_test::RETURN_ERROR_GET_ATTRIBUTE_NAME;
+ }
+ } catch (rti1516::Exception &e)
+ {
+ std::wcerr << testId << L"N Fail: " << e.what() << std::endl;
+ return certi::rti1516_test::RETURN_ERROR_GET_ATTRIBUTE_NAME;
+ }
+
+ // INTERACTION HANDLE
+ testId = L"13";
+ try {
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"T Test: Attempting to get handle for
invalid interaction" << std::endl;
+ rti1516::InteractionClassHandle msgHandle =
rtiAmb->getInteractionClassHandle(L"InvalidInteractionName");
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"N Fail: Could get handle for invalid
interaction name." << std::endl;
+ return certi::rti1516_test::RETURN_ERROR_GET_INTERACTION_HANDLE;
+ } catch (rti1516::NameNotFound &e)
+ {
+ // expected
+ std::wcerr << testId << L"E Pass: " << e.what() << std::endl;
+ } catch (rti1516::Exception &e)
+ {
+ std::wcerr << testId << L"N Fail: " << e.what() << std::endl;
+ return certi::rti1516_test::RETURN_ERROR_GET_INTERACTION_HANDLE;
+ }
+
+ testId = L"14";
+ try {
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"T Test: Attempting to get handle for
valid interaction name" << std::endl;
+ rti1516::InteractionClassHandle msgHandle =
rtiAmb->getInteractionClassHandle(L"Msg");
+ ////////////////////////////////////////////////
+ // expected
+ if (msgHandle.isValid() )
+ {
+ std::wcerr << testId << L"E Pass: Got interaction
handle for valid interaction name" << std::endl;
+ } else
+ {
+ std::wcerr << testId << L"N Fail: Got invalid
interaction handle for valid interaction name" << std::endl;
+ return
certi::rti1516_test::RETURN_ERROR_GET_INTERACTION_HANDLE;
+ }
+ } catch (rti1516::Exception &e)
+ {
+ std::wcerr << testId << L"N Fail:" << e.what() << std::endl;
+ return certi::rti1516_test::RETURN_ERROR_GET_INTERACTION_HANDLE;
+ }
+
+ // INTERACTION NAME
+ testId = L"15";
+ try {
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"T Test: Attempting to get name for
invalid interaction handle" << std::endl;
+ std::wstring name = rtiAmb->getInteractionClassName(xMsgHandle);
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"N Fail: Could get name for invalid
interaction handle: " << name << std::endl;
+ return certi::rti1516_test::RETURN_ERROR_GET_INTERACTION_NAME;
+ } catch (rti1516::InvalidInteractionClassHandle &e)
+ {
+ // expected
+ std::wcerr << testId << L"E Pass: " << e.what() << std::endl;
+ } catch (rti1516::Exception &e)
+ {
+ std::wcerr << testId << L"N Fail: " << e.what() << std::endl;
+ return certi::rti1516_test::RETURN_ERROR_GET_INTERACTION_NAME;
+ }
+
+ testId = L"16";
+ try {
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"T Test: Attempting to get name for
valid interaction handle" << std::endl;
+ std::wstring orgMsgName(L"Msg");
+ rti1516::InteractionClassHandle msgHandle =
rtiAmb->getInteractionClassHandle(orgMsgName);
+ std::wstring msgName =
rtiAmb->getInteractionClassName(msgHandle);
+ ////////////////////////////////////////////////
+ // expected
+ if ( orgMsgName == msgName )
+ {
+ std::wcerr << testId << L"E Pass: Got name for valid
interaction handle" << std::endl;
+ } else
+ {
+ std::wcerr << testId << L"N Fail: Got invalid name for
valid interaction handle" << std::endl;
+ return
certi::rti1516_test::RETURN_ERROR_GET_INTERACTION_NAME;
+ }
+ } catch (rti1516::Exception &e)
+ {
+ std::wcerr << testId << L"N Fail:" << e.what() << std::endl;
+ return certi::rti1516_test::RETURN_ERROR_GET_INTERACTION_NAME;
+ }
+
+ // PARAMETER HANDLE
+ testId = L"17";
+ try {
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"T Test: Attempting to get parameter
handle for invalid interaction and invalid parameter name" << std::endl;
+ rti1516::ParameterHandle parHandle =
rtiAmb->getParameterHandle(xMsgHandle, L"InvalidParameterName");
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"N Fail: Could get parameter handle
for invalid interaction and invalid parameter name" << std::endl;
+ return certi::rti1516_test::RETURN_ERROR_GET_PARAMETER_HANDLE;
+ } catch (rti1516::InvalidInteractionClassHandle &e)
+ {
+ // expected
+ std::wcerr << testId << L"E Pass:" << e.what() << std::endl;
+ } catch (rti1516::NameNotFound &e)
+ {
+ // expected
+ std::wcerr << testId << L"E Pass:" << e.what() << std::endl;
+ } catch (rti1516::Exception &e)
+ {
+ std::wcerr << testId << L"N Fail:" << e.what() << std::endl;
+ return certi::rti1516_test::RETURN_ERROR_GET_PARAMETER_HANDLE;
+ }
+
+ testId = L"18";
+ try {
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"T Test: Attempting to get parameter
handle for invalid interaction and valid parameter name" << std::endl;
+ rti1516::ParameterHandle parHandle =
rtiAmb->getParameterHandle(xMsgHandle, L"MsgData");
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"N Fail: Could get parameter handle
for invalid interaction and valid parameter name" << std::endl;
+ return certi::rti1516_test::RETURN_ERROR_GET_PARAMETER_HANDLE;
+ } catch (rti1516::InvalidInteractionClassHandle &e)
+ {
+ // expected
+ std::wcerr << testId << L"E Pass:" << e.what() << std::endl;
+ } catch (rti1516::NameNotFound &e)
+ {
+ // expected
+ std::wcerr << testId << L"E Pass:" << e.what() << std::endl;
+ } catch (rti1516::Exception &e)
+ {
+ std::wcerr << testId << L"N Fail:" << e.what() << std::endl;
+ return certi::rti1516_test::RETURN_ERROR_GET_PARAMETER_HANDLE;
+ }
+
+ testId = L"19";
+ try {
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"T Test: Attempting to get parameter
handle for valid interaction and invalid parameter name" << std::endl;
+ rti1516::InteractionClassHandle msgHandle =
rtiAmb->getInteractionClassHandle(L"Msg");
+ rti1516::ParameterHandle parHandle =
rtiAmb->getParameterHandle(msgHandle, L"InvalidParameterName");
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"N Fail: Could get parameter handle
for valid interaction and invalid parameter name" << std::endl;
+ return certi::rti1516_test::RETURN_ERROR_GET_PARAMETER_HANDLE;
+ } catch (rti1516::NameNotFound &e)
+ {
+ // expected
+ std::wcerr << testId << L"E Pass:" << e.what() << std::endl;
+ } catch (rti1516::Exception &e)
+ {
+ std::wcerr << testId << L"N Fail:" << e.what() << std::endl;
+ return certi::rti1516_test::RETURN_ERROR_GET_PARAMETER_HANDLE;
+ }
+
+ testId = L"20";
+ try {
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"T Test: Attempting to get parameter
handle for valid interaction and valid parameter name" << std::endl;
+ rti1516::InteractionClassHandle msgHandle =
rtiAmb->getInteractionClassHandle(L"Msg");
+ rti1516::ParameterHandle parHandle =
rtiAmb->getParameterHandle(msgHandle, L"MsgData");
+ ////////////////////////////////////////////////
+ // expected
+ if ( parHandle.isValid() )
+ {
+ std::wcerr << testId << L"E Pass: Got parameter handle
for valid interaction and valid parameter name" << std::endl;
+ } else
+ {
+ std::wcerr << testId << L"N Fail: Got invalid parameter
handle for valid interaction and valid parameter name" << std::endl;
+ return
certi::rti1516_test::RETURN_ERROR_GET_PARAMETER_HANDLE;
+ }
+ } catch (rti1516::Exception &e)
+ {
+ std::wcerr << testId << L"N Fail:" << e.what() << std::endl;
+ return certi::rti1516_test::RETURN_ERROR_GET_PARAMETER_HANDLE;
+ }
+
+ // PARAMETER NAME
+ testId = L"21";
+ try {
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"T Test: Attempting to get parameter
name with invalid interaction and invalid parameter handle" << std::endl;
+ std::wstring paramName = rtiAmb->getParameterName(xMsgHandle,
xParamHandle);
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"N Fail: Could get parameter name with
invalid interaction and invalid parameter handle" << std::endl;
+ return certi::rti1516_test::RETURN_ERROR_GET_PARAMETER_NAME;
+ } catch (rti1516::InvalidInteractionClassHandle &e)
+ {
+ // expected
+ std::wcerr << testId << L"E Pass: " << e.what() << std::endl;
+ } catch (rti1516::InvalidParameterHandle &e)
+ {
+ // expected
+ std::wcerr << testId << L"E Pass: " << e.what() << std::endl;
+ } catch (rti1516::InteractionParameterNotDefined &e)
+ {
+ // expected
+ std::wcerr << testId << L"E Pass: " << e.what() << std::endl;
+ } catch (rti1516::Exception &e)
+ {
+ std::wcerr << testId << L"N Fail: " << e.what() << std::endl;
+ return certi::rti1516_test::RETURN_ERROR_GET_PARAMETER_NAME;
+ }
+ testId = L"22";
+ try {
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"T Test: Attempting to get parameter
name with invalid interaction and valid parameter handle" << std::endl;
+ rti1516::InteractionClassHandle msgHandle =
rtiAmb->getInteractionClassHandle(L"Msg");
+ rti1516::ParameterHandle parHandle =
rtiAmb->getParameterHandle(msgHandle, L"MsgData");
+
+ std::wstring paramName = rtiAmb->getParameterName(xMsgHandle,
parHandle);
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"N Fail: Could get parameter name with
invalid interaction and valid parameter handle" << std::endl;
+ return certi::rti1516_test::RETURN_ERROR_GET_PARAMETER_NAME;
+ } catch (rti1516::InvalidInteractionClassHandle &e)
+ {
+ // expected
+ std::wcerr << testId << L"E Pass: " << e.what() << std::endl;
+ } catch (rti1516::Exception &e)
+ {
+ std::wcerr << testId << L"N Fail: " << e.what() << std::endl;
+ return certi::rti1516_test::RETURN_ERROR_GET_PARAMETER_NAME;
+ }
+ testId = L"23";
+ try {
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"T Test: Attempting to get parameter
name with valid interaction and invalid parameter handle" << std::endl;
+ rti1516::InteractionClassHandle msgHandle =
rtiAmb->getInteractionClassHandle(L"Msg");
+
+ std::wstring paramName = rtiAmb->getParameterName(msgHandle,
xParamHandle);
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"N Fail: Could get parameter name with
valid interaction and invalid parameter handle" << std::endl;
+ return certi::rti1516_test::RETURN_ERROR_GET_PARAMETER_NAME;
+ } catch (rti1516::InvalidParameterHandle &e)
+ {
+ // expected
+ std::wcerr << testId << L"E Pass: " << e.what() << std::endl;
+ } catch (rti1516::InteractionParameterNotDefined &e)
+ {
+ // expected
+ std::wcerr << testId << L"E Pass: " << e.what() << std::endl;
+ } catch (rti1516::Exception &e)
+ {
+ std::wcerr << testId << L"N Fail: " << e.what() << std::endl;
+ return certi::rti1516_test::RETURN_ERROR_GET_PARAMETER_NAME;
+ }
+ testId = L"24";
+ try {
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"T Test: Attempting to get parameter
name with valid interaction and valid parameter handle" << std::endl;
+ rti1516::InteractionClassHandle msgHandle =
rtiAmb->getInteractionClassHandle(L"Msg");
+ rti1516::ParameterHandle parHandle =
rtiAmb->getParameterHandle(msgHandle, L"MsgData");
+ std::wstring orgParamName(L"MsgData");
+
+ std::wstring paramName = rtiAmb->getParameterName(msgHandle,
parHandle);
+ ////////////////////////////////////////////////
+ if ( orgParamName == paramName )
+ {
+ // expected
+ std::wcerr << testId << L"E Pass: Could get parameter
name with valid interaction and valid parameter handle" << std::endl;
+ } else
+ {
+ std::wcerr << testId << L"N Fail: Could get parameter
name with invalid interaction and valid parameter handle, but returned name was
wrong" << std::endl;
+ return
certi::rti1516_test::RETURN_ERROR_GET_PARAMETER_NAME;
+ }
+ } catch (rti1516::Exception &e)
+ {
+ std::wcerr << testId << L"N Fail: " << e.what() << std::endl;
+ return certi::rti1516_test::RETURN_ERROR_GET_PARAMETER_NAME;
+ }
+
+ // OBJECT HANDLE ?
+ int nameVal;
+
+ nameVal = (rand() % 99) + 1;
+
+ std::wstringstream stream;
+ stream << L"TestObject" << nameVal;
+
+ std::wstring objName = stream.str();
+ rti1516::ObjectInstanceHandle objHandle;
+ bool objRegistered = false;
+ try {
+ rti1516::ObjectClassHandle classHandle =
rtiAmb->getObjectClassHandle(L"TestObjectClass");
+ rti1516::AttributeHandle attrHandle =
rtiAmb->getAttributeHandle(classHandle, L"Data");
+ rti1516::AttributeHandleSet attrSet;
+ attrSet.insert(attrHandle);
+ rtiAmb->publishObjectClassAttributes(classHandle, attrSet);
+ objHandle = rtiAmb->registerObjectInstance(classHandle,
objName);
+ objRegistered = true;
+ } catch (rti1516::Exception &e)
+ {
+ std::wcerr << testId << L"Warning: could not register object
instance. Some tests may be skipped. Reason: " << e.what() << std::endl;
+ }
+
+ testId = L"25";
+ try {
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"T Test: Attempting to get object
handle for invalid object instance name" << std::endl;
+ rti1516::ObjectInstanceHandle retObjHandle =
rtiAmb->getObjectInstanceHandle(L"InvalidObjectInstanceName");
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"N Fail: Could get object handle for
invalid object instance name" << std::endl;
+ return certi::rti1516_test::RETURN_ERROR_GET_CLASS_HANDLE;
+ } catch (rti1516::ObjectInstanceNotKnown &e)
+ {
+ // expected
+ std::wcerr << testId << L"E Pass:" << e.what() << std::endl;
+ } catch (rti1516::Exception &e)
+ {
+ std::wcerr << testId << L"N Fail:" << e.what() << std::endl;
+ return certi::rti1516_test::RETURN_ERROR_GET_CLASS_HANDLE;
+ }
+
+ testId = L"26";
+ try {
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"T Test: Attempting to get object
handle for valid object instance name" << std::endl;
+ if ( objRegistered )
+ {
+ rti1516::ObjectInstanceHandle retObjHandle =
rtiAmb->getObjectInstanceHandle(objName);
+ ////////////////////////////////////////////////
+ // expected
+ if ( retObjHandle.isValid() )
+ {
+ std::wcerr << testId << L"E Pass: Got object
handle for valid object instance name" << std::endl;
+ } else
+ {
+ std::wcerr << testId << L"N Fail: Got invalid
object handle for valid object instance name" << std::endl;
+ return
certi::rti1516_test::RETURN_ERROR_GET_CLASS_HANDLE;
+ }
+ } else
+ {
+ std::wcerr << testId << L"E Skip:" << std::endl;
+ }
+ } catch (rti1516::Exception &e)
+ {
+ std::wcerr << testId << L"N Fail:" << e.what() << std::endl;
+ return certi::rti1516_test::RETURN_ERROR_GET_CLASS_HANDLE;
+ }
+
+ // OBJECT NAME ?
+ testId = L"27";
+ try {
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"T Test: Attempting to get name for
invalid object instance handle" << std::endl;
+ std::wstring retObjName =
rtiAmb->getObjectInstanceName(xObjHandle);
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"N Fail: Could get name for invalid
object instance handle. Name returned:" << retObjName << std::endl;
+ return certi::rti1516_test::RETURN_ERROR_GET_CLASS_NAME;
+ } catch (rti1516::ObjectInstanceNotKnown &e)
+ {
+ // expected
+ std::wcerr << testId << L"E Pass: " << e.what() << std::endl;
+ } catch (rti1516::Exception &e)
+ {
+ std::wcerr << testId << L"N Fail: " << e.what() << std::endl;
+ return certi::rti1516_test::RETURN_ERROR_GET_CLASS_NAME;
+ }
+ testId = L"28";
+ try {
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"T Test: Attempting to get name for
valid object instance handle" << std::endl;
+ if ( objRegistered )
+ {
+ std::wstring retObjName =
rtiAmb->getObjectInstanceName(objHandle);
+ ////////////////////////////////////////////////
+ // expected
+ if ( objName != retObjName )
+ {
+ std::wcerr << testId << L"N Fail: Returned
object name does not match expected object name. " <<
+ L"(Expected " <<
objName << L", got " << retObjName << L".)" << std::endl;
+ return
certi::rti1516_test::RETURN_ERROR_GET_CLASS_NAME;
+ } else
+ {
+ std::wcerr << testId << L"E Pass: Got expected
object name" << std::endl;
+ }
+ } else
+ {
+ std::wcerr << testId << L"E Skip:" << std::endl;
+ }
+ } catch (rti1516::Exception &e)
+ {
+ std::wcerr << testId << L"N Fail: " << e.what() << std::endl;
+ return certi::rti1516_test::RETURN_ERROR_GET_CLASS_NAME;
+ }
+
+ std::wcerr << L"Test operations performed. Press enter to continue with
shutdown." << std::endl;
+ getchar();
+
+ try {
+ ////////////////////////////////////////////////
+ std::wcerr << L"Attempting to resign from Federation" <<
std::endl;
+
rtiAmb->resignFederationExecution(rti1516::CANCEL_THEN_DELETE_THEN_DIVEST);
+ std::wcerr << L"Resigned from Federation" << std::endl;
+ std::wcerr << L"Attempting to destroy Federation" << std::endl;
+ rtiAmb->destroyFederationExecution(L"TestFederationName");
+ std::wcerr << L"Destroyed Federation" << std::endl;
+ ////////////////////////////////////////////////
+ // expected
+ std::wcerr << L"Pass" << std::endl;
+ } catch (rti1516::FederatesCurrentlyJoined &)
+ {
+ // expected
+ std::wcerr << L"Pass: Could not destroy federation while
another federate was still connected. This is expected behaviour." << std::endl;
+ } catch (rti1516::Exception &e)
+ {
+ std::wcerr << L"Fail: " << e.what() << std::endl;
+ return certi::rti1516_test::RETURN_ERROR_DESTROYING_FEDERATION;
+ }
+
+ return certi::rti1516_test::RETURN_NO_ERRORS;
+}
Index: 04-NameReservation.hh
===================================================================
RCS file: 04-NameReservation.hh
diff -N 04-NameReservation.hh
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ 04-NameReservation.hh 31 May 2010 14:15:09 -0000 1.1
@@ -0,0 +1,43 @@
+#ifndef FED_EXECUTION_TEST_H
+#define FED_EXECUTION_TEST_H
+
+#include <RTI/NullFederateAmbassador.h>
+
+namespace rti1516 {
+ class RTIambassador;
+}
+
+class TestFedAmb : public rti1516::NullFederateAmbassador
+{
+public:
+ TestFedAmb()
+ throw ();
+ ~TestFedAmb()
+ throw ();
+
+ int execute(int argc, char **argv);
+
+ virtual
+ void
+ objectInstanceNameReservationSucceeded(std::wstring const &
+ theObjectInstanceName)
+ throw (rti1516::UnknownName,
+ rti1516::FederateInternalError);
+
+ virtual
+ void
+ objectInstanceNameReservationFailed(std::wstring const &
+ theObjectInstanceName)
+ throw (rti1516::UnknownName,
+ rti1516::FederateInternalError);
+
+
+private:
+ rti1516::RTIambassador *rtiAmb;
+ rti1516::FederateHandle fedHandle;
+ std::wstring fedName;
+ std::wstring federationName;
+
+};
+
+#endif // FED_EXECUTION_TEST_H
Index: 05-ObjectManagementTest.hh
===================================================================
RCS file: 05-ObjectManagementTest.hh
diff -N 05-ObjectManagementTest.hh
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ 05-ObjectManagementTest.hh 31 May 2010 14:15:09 -0000 1.1
@@ -0,0 +1,184 @@
+#ifndef OBJECT_MANAGEMENT_TEST_H
+#define OBJECT_MANAGEMENT_TEST_H
+
+#include <RTI/NullFederateAmbassador.h>
+
+namespace rti1516 {
+ class RTIambassador;
+}
+
+class TestFedAmbCallbacks : public rti1516::NullFederateAmbassador
+{
+public:
+ TestFedAmbCallbacks()
+ throw ();
+ ~TestFedAmbCallbacks()
+ throw ();
+
+ void execute();
+
+
+ // 6.5
+ virtual void
+ discoverObjectInstance(rti1516::ObjectInstanceHandle theObject,
+ rti1516::ObjectClassHandle theObjectClass,
+ std::wstring const & theObjectInstanceName)
+ throw (rti1516::CouldNotDiscover,
+ rti1516::ObjectClassNotKnown,
+ rti1516::FederateInternalError);
+
+ // 6.7 a
+ virtual void
+ reflectAttributeValues
+ (rti1516::ObjectInstanceHandle theObject,
+ rti1516::AttributeHandleValueMap const & theAttributeValues,
+ rti1516::VariableLengthData const & theUserSuppliedTag,
+ rti1516::OrderType sentOrder,
+ rti1516::TransportationType theType)
+ throw (rti1516::ObjectInstanceNotKnown,
+ rti1516::AttributeNotRecognized,
+ rti1516::AttributeNotSubscribed,
+ rti1516::FederateInternalError);
+
+ // 6.7 b
+ virtual void
+ reflectAttributeValues
+ (rti1516::ObjectInstanceHandle theObject,
+ rti1516::AttributeHandleValueMap const & theAttributeValues,
+ rti1516::VariableLengthData const & theUserSuppliedTag,
+ rti1516::OrderType sentOrder,
+ rti1516::TransportationType theType,
+ rti1516::RegionHandleSet const & theSentRegionHandleSet)
+ throw (rti1516::ObjectInstanceNotKnown,
+ rti1516::AttributeNotRecognized,
+ rti1516::AttributeNotSubscribed,
+ rti1516::FederateInternalError);
+
+ // 6.7 c
+ virtual void
+ reflectAttributeValues
+ (rti1516::ObjectInstanceHandle theObject,
+ rti1516::AttributeHandleValueMap const & theAttributeValues,
+ rti1516::VariableLengthData const & theUserSuppliedTag,
+ rti1516::OrderType sentOrder,
+ rti1516::TransportationType theType,
+ rti1516::LogicalTime const & theTime,
+ rti1516::OrderType receivedOrder)
+ throw (rti1516::ObjectInstanceNotKnown,
+ rti1516::AttributeNotRecognized,
+ rti1516::AttributeNotSubscribed,
+ rti1516::FederateInternalError);
+
+ // 6.7 d
+ virtual void
+ reflectAttributeValues
+ (rti1516::ObjectInstanceHandle theObject,
+ rti1516::AttributeHandleValueMap const & theAttributeValues,
+ rti1516::VariableLengthData const & theUserSuppliedTag,
+ rti1516::OrderType sentOrder,
+ rti1516::TransportationType theType,
+ rti1516::LogicalTime const & theTime,
+ rti1516::OrderType receivedOrder,
+ rti1516::RegionHandleSet const & theSentRegionHandleSet)
+ throw (rti1516::ObjectInstanceNotKnown,
+ rti1516::AttributeNotRecognized,
+ rti1516::AttributeNotSubscribed,
+ rti1516::FederateInternalError);
+
+ // 6.7 e
+ virtual void
+ reflectAttributeValues
+ (rti1516::ObjectInstanceHandle theObject,
+ rti1516::AttributeHandleValueMap const & theAttributeValues,
+ rti1516::VariableLengthData const & theUserSuppliedTag,
+ rti1516::OrderType sentOrder,
+ rti1516::TransportationType theType,
+ rti1516::LogicalTime const & theTime,
+ rti1516::OrderType receivedOrder,
+ rti1516::MessageRetractionHandle theHandle)
+ throw (rti1516::ObjectInstanceNotKnown,
+ rti1516::AttributeNotRecognized,
+ rti1516::AttributeNotSubscribed,
+ rti1516::InvalidLogicalTime,
+ rti1516::FederateInternalError);
+
+ // 6.7 f
+ virtual void
+ reflectAttributeValues
+ (rti1516::ObjectInstanceHandle theObject,
+ rti1516::AttributeHandleValueMap const & theAttributeValues,
+ rti1516::VariableLengthData const & theUserSuppliedTag,
+ rti1516::OrderType sentOrder,
+ rti1516::TransportationType theType,
+ rti1516::LogicalTime const & theTime,
+ rti1516::OrderType receivedOrder,
+ rti1516::MessageRetractionHandle theHandle,
+ rti1516::RegionHandleSet const & theSentRegionHandleSet)
+ throw (rti1516::ObjectInstanceNotKnown,
+ rti1516::AttributeNotRecognized,
+ rti1516::AttributeNotSubscribed,
+ rti1516::InvalidLogicalTime,
+ rti1516::FederateInternalError);
+
+ // 6.11 a
+ virtual void
+ removeObjectInstance(rti1516::ObjectInstanceHandle theObject,
+ rti1516::VariableLengthData const &
theUserSuppliedTag,
+ rti1516::OrderType sentOrder)
+ throw (rti1516::ObjectInstanceNotKnown,
+ rti1516::FederateInternalError);
+
+ // 6.11 b
+ virtual void
+ removeObjectInstance(rti1516::ObjectInstanceHandle theObject,
+ rti1516::VariableLengthData const &
theUserSuppliedTag,
+ rti1516::OrderType sentOrder,
+ rti1516::LogicalTime const & theTime,
+ rti1516::OrderType receivedOrder)
+ throw (rti1516::ObjectInstanceNotKnown,
+ rti1516::FederateInternalError);
+
+ // 6.11 c
+ virtual void
+ removeObjectInstance(rti1516::ObjectInstanceHandle theObject,
+ rti1516::VariableLengthData const &
theUserSuppliedTag,
+ rti1516::OrderType sentOrder,
+ rti1516::LogicalTime const & theTime,
+ rti1516::OrderType receivedOrder,
+ rti1516::MessageRetractionHandle theHandle)
+ throw (rti1516::ObjectInstanceNotKnown,
+ rti1516::InvalidLogicalTime,
+ rti1516::FederateInternalError);
+
+
+private:
+ rti1516::RTIambassador *rtiAmb;
+ rti1516::FederateHandle fedHandle;
+ std::wstring fedName;
+ std::wstring federationName;
+
+};
+
+class TestFedAmb : public rti1516::NullFederateAmbassador
+{
+public:
+ TestFedAmb()
+ throw ();
+ ~TestFedAmb()
+ throw ();
+
+ int execute(int argc, char **argv);
+
+private:
+ rti1516::RTIambassador *rtiAmb;
+ rti1516::FederateHandle fedHandle;
+ std::wstring fedName;
+ std::wstring federationName;
+ TestFedAmbCallbacks *fedAmb2;
+
+};
+
+
+
+
+#endif // OBJECT_MANAGEMENT_TEST_H
Index: 05-ObjectManagementTest.cc
===================================================================
RCS file: 05-ObjectManagementTest.cc
diff -N 05-ObjectManagementTest.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ 05-ObjectManagementTest.cc 31 May 2010 14:15:09 -0000 1.1
@@ -0,0 +1,440 @@
+// 05-ObjectManagementTest.cc : Defines the entry point for the console
application.
+//
+
+#include "05-ObjectManagementTest.hh"
+#include "ReturnCodes.hh"
+
+#include <RTI/certiRTI1516.h>
+#include <RTI/Enums.h>
+#include <iostream>
+#include <sstream>
+#include <cstdlib>
+#include <ctime>
+#include <cstdio>
+
+#include <RTI1516fedTime.h>
+
+int main(int argc, char** argv)
+{
+ int retCode1 = 0;
+
+ srand( time(0) );
+
+ TestFedAmb *fedAmb = new TestFedAmb();
+
+ retCode1 = fedAmb->execute(argc, argv);
+
+
+
+ if ( retCode1 == certi::rti1516_test::RETURN_NO_ERRORS)
+ {
+ std::wcerr << L"Pass: Test completed" << std::endl;
+ } else
+ {
+ std::wcerr << L"Fail: Test failed with error code: " <<
retCode1 << std::endl;
+
+ }
+
+ // Poor man's 'pause'
+ std::wcerr << L"Press enter to stop connection to RTI." << std::endl;
+ getchar();
+
+ delete fedAmb;
+
+ // Poor man's 'pause'
+ getchar();
+
+ return retCode1;
+}
+
+TestFedAmb::TestFedAmb() throw()
+: rtiAmb(0)
+, fedHandle()
+, fedName()
+, federationName(L"TestFederationName")
+, fedAmb2()
+{
+ int nameVal;
+
+ nameVal = (rand() % 99) + 1;
+
+ std::wstringstream stream;
+ stream << L"TestFederate" << nameVal;
+
+ fedName = stream.str();
+ std::wcerr << L"Federate name:" << fedName << std::endl;
+
+}
+
+TestFedAmb::~TestFedAmb() throw()
+{
+ delete rtiAmb;
+}
+
+int TestFedAmb::execute(int argc, char** argv)
+{
+ std::wcerr << L"01T Test: Attempting to set up test environment (create
and join federation)" << std::endl;
+ std::auto_ptr< rti1516::RTIambassadorFactory > rtiAmbFact(new
rti1516::RTIambassadorFactory());
+ std::vector< std::wstring > constructorArgs;
+
+ // handles.
+ rti1516::ObjectClassHandle classHandle;
+ rti1516::AttributeHandle attrHandle;
+ rti1516::AttributeHandleSet classAttributes;
+ rti1516::AttributeHandleValueMap attributeValues;
+ rti1516::AttributeHandle invalidAttrHandle;
+ rti1516::AttributeHandleValueMap invalidAttributes;
+
+ rti1516::VariableLengthData theUserSuppliedTag;
+ std::wstring className(L"TestObjectClass");
+
+ std::wstring testId(L"00");
+
+ testId = L"01";
+
+ try {
+ //////////////////////////////////////////////
+ // Set up
+ std::auto_ptr< rti1516::RTIambassador >
rtiAmbP(rtiAmbFact->createRTIambassador(constructorArgs));
+ rtiAmb = rtiAmbP.release();
+
+ try {
+ rtiAmb->createFederationExecution(federationName,
L"Certi-Test-05.xml");
+ // expected
+ } catch (rti1516::FederationExecutionAlreadyExists &)
+ {
+ // expected
+ } catch (rti1516::Exception &)
+ {
+ throw;
+ }
+
+ fedHandle = rtiAmb->joinFederationExecution(fedName,
federationName, *this);
+
+ classHandle = rtiAmb->getObjectClassHandle(className);
+ attrHandle = rtiAmb->getAttributeHandle(classHandle, L"Data");
+ classAttributes.insert(attrHandle);
+ std::string testString("test string");
+ rti1516::VariableLengthData varData(testString.c_str(),
testString.size());
+ attributeValues.insert(std::pair<rti1516::AttributeHandle,
rti1516::VariableLengthData>(attrHandle, varData));
+ invalidAttributes.insert(std::pair<rti1516::AttributeHandle,
rti1516::VariableLengthData>(invalidAttrHandle, varData));
+ theUserSuppliedTag.setData(testString.c_str(),
testString.size());
+
+ } catch (rti1516::Exception &e)
+ {
+ std::wcerr << testId << L"N Fail:" << e.what() << std::endl;
+ return certi::rti1516_test::RETURN_ERROR_CREATING_AMBASSADOR;
+ }
+
+ std::wcerr << testId << L"E Pass: Federation joined. Press enter to
continue with test." << std::endl;
+ getchar();
+
+
+ // REGISTER OBJECT INSTANCE
+ testId = L"02";
+ try {
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"T Test: Attempting to register an
object class using an invalid class handle" << std::endl;
+ rti1516::ObjectClassHandle invalidClassHandle;
+ rti1516::ObjectInstanceHandle instance =
rtiAmb->registerObjectInstance(invalidClassHandle);
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"N Fail: Could get
ObjectInstanceHandle for invalid class handle. Return value:" << instance <<
std::endl;
+ return certi::rti1516_test::RETURN_UNDEFINED_ERROR;
+ } catch (rti1516::ObjectClassNotDefined &e)
+ {
+ // expected
+ std::wcerr << testId << L"E Pass: " << e.what() << std::endl;
+ } catch (rti1516::Exception &e)
+ {
+ std::wcerr << testId << L"N Fail: " << e.what() << std::endl;
+ return certi::rti1516_test::RETURN_UNDEFINED_ERROR;
+ }
+
+ testId = L"03";
+ try {
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"T Test: Attempting to register an
object class using a class handle of an unpublished Object Class" << std::endl;
+ rti1516::ObjectInstanceHandle instance =
rtiAmb->registerObjectInstance(classHandle);
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"N Fail: Could register an unpublished
Object Class. Return value:" << instance << std::endl;
+ return certi::rti1516_test::RETURN_UNDEFINED_ERROR;
+ } catch (rti1516::ObjectClassNotPublished &e)
+ {
+ // expected
+ std::wcerr << testId << L"E Pass: " << e.what() << std::endl;
+ } catch (rti1516::Exception &e)
+ {
+ std::wcerr << testId << L"N Fail: " << e.what() << std::endl;
+ return certi::rti1516_test::RETURN_UNDEFINED_ERROR;
+ }
+
+ testId = L"04";
+ try {
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"T Test: Attempting to register an
object class using a class handle of an unpublished Object Class" << std::endl;
+
+ rti1516::ObjectInstanceHandle instance =
rtiAmb->registerObjectInstance(classHandle, std::wstring(L"instance1"));
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"N Fail: Could register an unpublished
Object Class. Return value:" << instance << std::endl;
+ return certi::rti1516_test::RETURN_UNDEFINED_ERROR;
+ } catch (rti1516::ObjectClassNotPublished &e)
+ {
+ // expected
+ std::wcerr << testId << L"E Pass: " << e.what() << std::endl;
+ } catch (rti1516::Exception &e)
+ {
+ std::wcerr << testId << L"N Fail: " << e.what() << std::endl;
+ return certi::rti1516_test::RETURN_UNDEFINED_ERROR;
+ }
+
+ testId = L"05";
+ try {
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"T Test: Attempting to register an
object class using a valid and publised class handle" << std::endl;
+ rtiAmb->publishObjectClassAttributes(classHandle,
classAttributes);
+ rti1516::ObjectInstanceHandle instance =
rtiAmb->registerObjectInstance(classHandle);
+ ////////////////////////////////////////////////
+ // expected
+ if ( instance.isValid() )
+ {
+ std::wcerr << testId << L"E Pass: Got object instance
handle for valid and published object class" << std::endl;
+ } else
+ {
+ std::wcerr << testId << L"N Fail: Got invalid object
instance handle for valid and publised object class" << std::endl;
+ return certi::rti1516_test::RETURN_UNDEFINED_ERROR;
+ }
+ } catch (rti1516::Exception &e)
+ {
+ std::wcerr << testId << L"N Fail: " << e.what() << std::endl;
+ return certi::rti1516_test::RETURN_UNDEFINED_ERROR;
+ }
+
+ testId = L"06";
+ try {
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"T Test: Attempting to register an
object class using a valid and publised class handle" << std::endl;
+ rtiAmb->publishObjectClassAttributes(classHandle,
classAttributes);
+ rti1516::ObjectInstanceHandle instance =
rtiAmb->registerObjectInstance(classHandle, std::wstring(L"instance1"));
+ ////////////////////////////////////////////////
+ // expected
+ if ( instance.isValid() )
+ {
+ std::wcerr << testId << L"E Pass: Got object instance
handle for valid and published object class" << std::endl;
+ } else
+ {
+ std::wcerr << testId << L"N Fail: Got invalid object
instance handle for valid and publised object class" << std::endl;
+ return certi::rti1516_test::RETURN_UNDEFINED_ERROR;
+ }
+ } catch (rti1516::Exception &e)
+ {
+ std::wcerr << testId << L"N Fail: " << e.what() << std::endl;
+ return certi::rti1516_test::RETURN_UNDEFINED_ERROR;
+ }
+
+ testId = L"07";
+ try {
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"T Test: Attempting to register
another object class using a valid and publised class handle" << std::endl;
+ rtiAmb->publishObjectClassAttributes(classHandle,
classAttributes);
+ rti1516::ObjectInstanceHandle instance =
rtiAmb->registerObjectInstance(classHandle, std::wstring(L"instance2"));
+ ////////////////////////////////////////////////
+ // expected
+ if ( instance.isValid() )
+ {
+ std::wcerr << testId << L"E Pass: Got object instance
handle for valid and published object class" << std::endl;
+ } else
+ {
+ std::wcerr << testId << L"N Fail: Got invalid object
instance handle for valid and publised object class" << std::endl;
+ return certi::rti1516_test::RETURN_UNDEFINED_ERROR;
+ }
+ } catch (rti1516::Exception &e)
+ {
+ std::wcerr << testId << L"N Fail: " << e.what() << std::endl;
+ return certi::rti1516_test::RETURN_UNDEFINED_ERROR;
+ }
+
+ testId = L"08";
+ try {
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"T Test: Attempting to register an
object class with an instance name that is already in use" << std::endl;
+ rti1516::ObjectInstanceHandle instance =
rtiAmb->registerObjectInstance(classHandle, std::wstring(L"instance2"));
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"N Fail: Could get
ObjectInstanceHandle for an instance name that is already in use. Return
value:" << instance << std::endl;
+ return certi::rti1516_test::RETURN_UNDEFINED_ERROR;
+ } catch (rti1516::ObjectInstanceNameInUse &e)
+ {
+ // expected
+ std::wcerr << testId << L"E Pass: " << e.what() << std::endl;
+ } catch (rti1516::Exception &e)
+ {
+ std::wcerr << testId << L"N Fail: " << e.what() << std::endl;
+ return certi::rti1516_test::RETURN_UNDEFINED_ERROR;
+ }
+
+
+ // UPDATE ATTRIBUTE VALUES
+ testId = L"09";
+ try {
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"T Test: Attempting to update an
attribute on an undefined object instance" << std::endl;
+ rti1516::ObjectInstanceHandle xObjHandle;
+ rtiAmb->updateAttributeValues(xObjHandle, attributeValues,
theUserSuppliedTag);
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"N Fail: Could update an attribute of
an undefined object instance" << std::endl;
+ return certi::rti1516_test::RETURN_UNDEFINED_ERROR;
+ } catch (rti1516::ObjectInstanceNotKnown &e)
+ {
+ // expected
+ std::wcerr << testId << L"E Pass: " << e.what() << std::endl;
+ } catch (rti1516::Exception &e)
+ {
+ std::wcerr << testId << L"N Fail: " << e.what() << std::endl;
+ return certi::rti1516_test::RETURN_UNDEFINED_ERROR;
+ }
+
+ testId = L"10";
+ try {
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"T Test: Attempting to update an
undefined attribute" << std::endl;
+ rti1516::ObjectInstanceHandle instance =
rtiAmb->registerObjectInstance(classHandle);
+ rtiAmb->updateAttributeValues(instance, invalidAttributes,
theUserSuppliedTag);
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"N Fail: Could update an undefined
attribute" << std::endl;
+ return certi::rti1516_test::RETURN_UNDEFINED_ERROR;
+ } catch (rti1516::AttributeNotDefined &e)
+ {
+ // expected
+ std::wcerr << testId << L"E Pass: " << e.what() << std::endl;
+ } catch (rti1516::Exception &e)
+ {
+ std::wcerr << testId << L"N Fail: " << e.what() << std::endl;
+ return certi::rti1516_test::RETURN_UNDEFINED_ERROR;
+ }
+
+ testId = L"11";
+ try {
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"T Test: Attempting to update a
defined attribute on a known object instance" << std::endl;
+ rti1516::ObjectInstanceHandle instance =
rtiAmb->registerObjectInstance(classHandle);
+ rtiAmb->updateAttributeValues(instance, attributeValues,
theUserSuppliedTag);
+ ////////////////////////////////////////////////
+ // expected
+ std::wcerr << testId << L"E Pass: Attribute values updated" <<
std::endl;
+ } catch (rti1516::Exception &e)
+ {
+ std::wcerr << testId << L"N Fail: " << e.what() << std::endl;
+ return certi::rti1516_test::RETURN_UNDEFINED_ERROR;
+ }
+
+ testId = L"12";
+ try {
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"T Test: Attempting to update a
defined attribute on a known object instance with valid logical time" <<
std::endl;
+ rti1516::ObjectInstanceHandle instance =
rtiAmb->registerObjectInstance(classHandle);
+ std::auto_ptr<rti1516::LogicalTimeFactory> factory =
rti1516::LogicalTimeFactoryFactory::makeLogicalTimeFactory(L"certi");
+ std::auto_ptr<rti1516::LogicalTime> time =
factory->makeLogicalTime();
+ rtiAmb->updateAttributeValues(instance, attributeValues,
theUserSuppliedTag, *time);
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"E Pass: Attribute values updated" <<
std::endl;
+ } catch (rti1516::Exception &e)
+ {
+ std::wcerr << testId << L"N Fail: " << e.what() << std::endl;
+ return certi::rti1516_test::RETURN_UNDEFINED_ERROR;
+ }
+
+
+ testId = L"13";
+ try {
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"T Test: Attempting to delete an
object instance" << std::endl;
+ rti1516::ObjectInstanceHandle instance =
rtiAmb->registerObjectInstance(classHandle);
+ std::auto_ptr<rti1516::LogicalTimeFactory> factory =
rti1516::LogicalTimeFactoryFactory::makeLogicalTimeFactory(L"certi");
+ rtiAmb->deleteObjectInstance(instance, theUserSuppliedTag);
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"E Pass: object instance deleted" <<
std::endl;
+ } catch (rti1516::Exception &e)
+ {
+ std::wcerr << testId << L"N Fail: " << e.what() << std::endl;
+ return certi::rti1516_test::RETURN_UNDEFINED_ERROR;
+ }
+
+ testId = L"14";
+ try {
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"T Test: Attempting to delete an
object instance" << std::endl;
+ rti1516::ObjectInstanceHandle instance =
rtiAmb->registerObjectInstance(classHandle);
+ std::auto_ptr<rti1516::LogicalTimeFactory> factory =
rti1516::LogicalTimeFactoryFactory::makeLogicalTimeFactory(L"certi");
+ std::auto_ptr<rti1516::LogicalTime> time =
factory->makeLogicalTime();
+ rtiAmb->updateAttributeValues(instance, attributeValues,
theUserSuppliedTag, *time);
+ rtiAmb->deleteObjectInstance(instance, theUserSuppliedTag);
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"E Pass: object instance deleted" <<
std::endl;
+ } catch (rti1516::Exception &e)
+ {
+ std::wcerr << testId << L"N Fail: " << e.what() << std::endl;
+ return certi::rti1516_test::RETURN_UNDEFINED_ERROR;
+ }
+
+ testId = L"15";
+ try {
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"T Test: Attempting to delete an
object instance" << std::endl;
+ rti1516::ObjectInstanceHandle instance =
rtiAmb->registerObjectInstance(classHandle);
+ std::auto_ptr<rti1516::LogicalTimeFactory> factory =
rti1516::LogicalTimeFactoryFactory::makeLogicalTimeFactory(L"certi");
+ std::auto_ptr<rti1516::LogicalTime> time =
factory->makeLogicalTime();
+ rtiAmb->deleteObjectInstance(instance, theUserSuppliedTag,
*time);
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"E Pass: object instance deleted" <<
std::endl;
+ } catch (rti1516::Exception &e)
+ {
+ std::wcerr << testId << L"N Fail: " << e.what() << std::endl;
+ return certi::rti1516_test::RETURN_UNDEFINED_ERROR;
+ }
+
+
+
+ std::wcerr << L"Test operations performed." << std::endl;
+ std::wcerr << L"Start '05-ObjectManagermentCallbackTest' and press
enter to continue with processing callbacks." << std::endl;
+ getchar();
+
+ try {
+ rti1516::ObjectInstanceHandle instance =
rtiAmb->registerObjectInstance(classHandle);
+ //std::auto_ptr<rti1516::LogicalTimeFactory> factory =
rti1516::LogicalTimeFactoryFactory::makeLogicalTimeFactory(L"certi");
+ //std::auto_ptr<rti1516::LogicalTime> time =
factory->makeLogicalTime();
+ rtiAmb->updateAttributeValues(instance, attributeValues,
theUserSuppliedTag);
+ rtiAmb->deleteObjectInstance(instance, theUserSuppliedTag);
+ } catch (rti1516::Exception &e)
+ {
+ std::wcerr << testId << L"N Fail:" << e.what() << std::endl;
+ return certi::rti1516_test::RETURN_UNDEFINED_ERROR;
+ }
+
+ std::wcerr << L"Press enter in '05-ObjectManagementCallbackTest' to
show the callbacks." << std::endl;
+ std::wcerr << L"Expecting callbacks 'DiscoverObjectInstance' (6.5),
'ReflectAttributeValues' (6.7) and 'RemoveObjectInstance' (6.11)" << std::endl;
+
+ std::wcerr << L"Test operations performed. Press enter to continue with
shutdown." << std::endl;
+ getchar();
+
+ try {
+ ////////////////////////////////////////////////
+ std::wcerr << L"Attempting to resign from Federation" <<
std::endl;
+
rtiAmb->resignFederationExecution(rti1516::CANCEL_THEN_DELETE_THEN_DIVEST);
+ std::wcerr << L"Resigned from Federation" << std::endl;
+ std::wcerr << L"Attempting to destroy Federation" << std::endl;
+ rtiAmb->destroyFederationExecution(L"TestFederationName");
+ std::wcerr << L"Destroyed Federation" << std::endl;
+ ////////////////////////////////////////////////
+ // expected
+ std::wcerr << L"Pass" << std::endl;
+ } catch (rti1516::FederatesCurrentlyJoined &)
+ {
+ // expected
+ std::wcerr << L"Pass: Could not destroy federation while
another federate was still connected. This is expected behaviour." << std::endl;
+ } catch (rti1516::Exception &e)
+ {
+ std::wcerr << L"Fail: " << e.what() << std::endl;
+ return certi::rti1516_test::RETURN_ERROR_DESTROYING_FEDERATION;
+ }
+
+ return certi::rti1516_test::RETURN_NO_ERRORS;
+}
Index: 04-NameReservation.cc
===================================================================
RCS file: 04-NameReservation.cc
diff -N 04-NameReservation.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ 04-NameReservation.cc 31 May 2010 14:15:09 -0000 1.1
@@ -0,0 +1,397 @@
+#include "04-NameReservation.hh"
+#include "ReturnCodes.hh"
+
+#include <RTI/certiRTI1516.h>
+#include <RTI/Enums.h>
+#include <iostream>
+#include <sstream>
+#include <cstdlib>
+#include <ctime>
+#include <cstdio>
+#include <cstring>
+
+#include <RTI1516fedTime.h>
+/***************************************
+ * This file is part of the Unit testing done for the HLA1516
+ * functionality in CERTI.
+ *
+ * This test requires that it's FOM file (with .xml extention)
+ * is placed under $BUILD/share/federations/
+ *
+ * Before running this test, start the 'rtig' project.
+ *
+ * The test will pause during it's run to allow the tester to review
+ * the test results. Press <Return> to continue when the test is paused.
+*****************************************/
+
+// TODO: Test does not test Name reservation yet.
+
+int main(int argc, char** argv)
+{
+ int retCode1 = 0;
+
+ srand( time(0) );
+
+ TestFedAmb *fedAmb = new TestFedAmb();
+
+ retCode1 = fedAmb->execute(argc, argv);
+
+
+
+ if ( retCode1 == certi::rti1516_test::RETURN_NO_ERRORS)
+ {
+ std::wcerr << L"Pass: Test completed" << std::endl;
+ } else
+ {
+ std::wcerr << L"Fail: Test failed with error code: " <<
retCode1 << std::endl;
+
+ }
+
+ // Poor man's 'pause'
+ std::wcerr << L"Press enter to stop connection to RTI." << std::endl;
+ getchar();
+
+ delete fedAmb;
+
+ // Poor man's 'pause'
+ getchar();
+
+ return retCode1;
+}
+
+TestFedAmb::TestFedAmb() throw()
+: rtiAmb(0)
+, fedHandle()
+, fedName()
+, federationName(L"TestFederationName")
+{
+ int nameVal;
+
+ nameVal = (rand() % 99) + 1;
+
+ std::wstringstream stream;
+ stream << L"TestFederate" << nameVal;
+
+ fedName = stream.str();
+ std::wcerr << L"Federate name:" << fedName << std::endl;
+
+}
+
+TestFedAmb::~TestFedAmb() throw()
+{
+ delete rtiAmb;
+}
+
+
+void
+TestFedAmb::objectInstanceNameReservationSucceeded(std::wstring const &
+
theObjectInstanceName)
+
throw (rti1516::UnknownName,
+
rti1516::FederateInternalError)
+{
+ std::wcerr << L"Name reservation for object '" << theObjectInstanceName
<< L"' succeeded." << std::endl;
+}
+
+void
+TestFedAmb::objectInstanceNameReservationFailed(std::wstring const &
+
theObjectInstanceName)
+
throw (rti1516::UnknownName,
+
rti1516::FederateInternalError)
+{
+ std::wcerr << L"Name reservation for object '" << theObjectInstanceName
<< L"' failed." << std::endl;
+}
+
+
+
+int TestFedAmb::execute(int argc, char** argv)
+{
+ std::wcerr << L"01T Test: Attempting to set up test environment (create
and join federation)" << std::endl;
+ std::auto_ptr< rti1516::RTIambassadorFactory > rtiAmbFact(new
rti1516::RTIambassadorFactory());
+ std::vector< std::wstring > constructorArgs;
+
+
+ // valid handles (are initialized in setup phase)
+ rti1516::ObjectClassHandle classHandle;
+ rti1516::AttributeHandle attrHandle;
+ rti1516::AttributeHandleSet classAttributes;
+ rti1516::InteractionClassHandle msgHandle;
+ rti1516::ObjectInstanceHandle objHandle;
+
+ // Invalid handles.
+ rti1516::ObjectClassHandle xClassHandle;
+ rti1516::AttributeHandle xAttrHandle;
+ rti1516::AttributeHandleSet xClassAttributes;
+ xClassAttributes.insert(xAttrHandle);
+ rti1516::InteractionClassHandle xMsgHandle;
+
+ std::wstring testId(L"00");
+ std::wstring testAction(L"Nothing?");
+
+ testId = L"01";
+
+ try {
+ //////////////////////////////////////////////
+ // Set up
+ std::auto_ptr< rti1516::RTIambassador >
rtiAmbP(rtiAmbFact->createRTIambassador(constructorArgs));
+ rtiAmb = rtiAmbP.release();
+
+ try {
+ rtiAmb->createFederationExecution(federationName,
L"Certi-Test-02.xml");
+ // expected
+ } catch (rti1516::FederationExecutionAlreadyExists &)
+ {
+ // expected
+ } catch (rti1516::Exception &)
+ {
+ throw;
+ }
+
+ fedHandle = rtiAmb->joinFederationExecution(fedName,
federationName, *this);
+
+ classHandle = rtiAmb->getObjectClassHandle(L"TestObjectClass");
+ attrHandle = rtiAmb->getAttributeHandle(classHandle, L"Data");
+ classAttributes.insert(attrHandle);
+ msgHandle = rtiAmb->getInteractionClassHandle(L"Msg");
+
+ rtiAmb->publishObjectClassAttributes(classHandle,
classAttributes);
+
+
+ } catch (rti1516::Exception &e)
+ {
+ std::wcerr << testId << L"N Fail:" << e.what() << std::endl;
+ return certi::rti1516_test::RETURN_ERROR_CREATING_AMBASSADOR;
+ }
+
+ std::wcerr << testId << L"E Pass: Federation joined. Press enter to
continue with test." << std::endl;
+ getchar();
+
+ // Name reservation
+ testId = L"02";
+ testAction = L"reserve invalid (empty) name";
+ std::wcerr << testId << L"T Test: Attempting to " << testAction <<
std::endl;
+ try {
+ std::wstring invalidName(L"");
+ ////////////////////////////////////////////////
+ rtiAmb->reserveObjectInstanceName(invalidName);
+ rtiAmb->evokeCallback(0.1);
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"N Fail: Could " << testAction <<
std::endl;
+ return certi::rti1516_test::RETURN_ERROR_SUBSCRIBE_INTERACTION;
+ } catch (rti1516::IllegalName &e)
+ {
+ // expected
+ std::wcerr << testId << L"E Pass:" << e.what() << std::endl;
+ } catch (rti1516::Exception &e)
+ {
+ std::wcerr << testId << L"N Fail:" << e.what() << std::endl;
+ return
certi::rti1516_test::RETURN_ERROR_UNSUBSCRIBE_INTERACTION;
+ }
+
+ testId = L"03";
+ testAction = L"reserve invalid name (begins with 'HLA')";
+ std::wcerr << testId << L"T Test: Attempting to " << testAction <<
std::endl;
+ try {
+ std::wstring invalidName(L"HLA_INVALID_NAME");
+ ////////////////////////////////////////////////
+ rtiAmb->reserveObjectInstanceName(invalidName);
+ rtiAmb->evokeCallback(0.1);
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"N Fail: Could " << testAction <<
std::endl;
+ return certi::rti1516_test::RETURN_ERROR_SUBSCRIBE_INTERACTION;
+ } catch (rti1516::IllegalName &e)
+ {
+ // expected
+ std::wcerr << testId << L"E Pass:" << e.what() << std::endl;
+ } catch (rti1516::Exception &e)
+ {
+ std::wcerr << testId << L"N Fail:" << e.what() << std::endl;
+ return
certi::rti1516_test::RETURN_ERROR_UNSUBSCRIBE_INTERACTION;
+ }
+
+ testId = L"04";
+ testAction = L"reserve valid name";
+ std::wcerr << testId << L"T Test: Attempting to " << testAction <<
std::endl;
+ try {
+ std::wstring validName(L"testObject");
+ ////////////////////////////////////////////////
+ rtiAmb->reserveObjectInstanceName(validName);
+ rtiAmb->evokeCallback(0.1);
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"E Pass: Could " << testAction <<
std::endl;
+ } catch (rti1516::Exception &e)
+ {
+ std::wcerr << testId << L"N Fail:" << e.what() << std::endl;
+ return
certi::rti1516_test::RETURN_ERROR_UNSUBSCRIBE_INTERACTION;
+ }
+
+ testId = L"05";
+ testAction = L"reserve invalid (duplicate) name";
+ std::wcerr << testId << L"T Test: Attempting to " << testAction <<
std::endl;
+ try {
+ std::wstring invalidName(L"testObject");
+ ////////////////////////////////////////////////
+ rtiAmb->reserveObjectInstanceName(invalidName);
+ rtiAmb->evokeCallback(0.1);
+ ////////////////////////////////////////////////
+ // expected
+ std::wcerr << testId << L"E Pass:" << testAction << std::endl;
+ } catch (rti1516::IllegalName &e)
+ {
+ // expected
+ std::wcerr << testId << L"E Pass:" << e.what() << std::endl;
+ } catch (rti1516::Exception &e)
+ {
+ std::wcerr << testId << L"N Fail:" << e.what() << std::endl;
+ return
certi::rti1516_test::RETURN_ERROR_UNSUBSCRIBE_INTERACTION;
+ }
+
+ testId = L"06";
+ testAction = L"create valid object instance with reserved name";
+ std::wcerr << testId << L"T Test: Attempting to " << testAction <<
std::endl;
+ try {
+ std::wstring validName(L"testObject");
+ ////////////////////////////////////////////////
+ objHandle = rtiAmb->registerObjectInstance(classHandle,
validName);
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"E Pass:" << testAction << std::endl;
+ } catch (rti1516::Exception &e)
+ {
+ std::wcerr << testId << L"N Fail:" << e.what() << std::endl;
+ return
certi::rti1516_test::RETURN_ERROR_UNSUBSCRIBE_INTERACTION;
+ }
+
+ testId = L"07";
+ testAction = L"create invalid object instance with (duplicate)
instantiated name";
+ std::wcerr << testId << L"T Test: Attempting to " << testAction <<
std::endl;
+ try {
+ std::wstring validName(L"testObject");
+ ////////////////////////////////////////////////
+ rtiAmb->registerObjectInstance(classHandle, validName);
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"N Fail: Could " << testAction <<
std::endl;
+ return certi::rti1516_test::RETURN_ERROR_SUBSCRIBE_INTERACTION;
+ } catch (rti1516::Exception &e)
+ {
+ // expected
+ std::wcerr << testId << L"E Pass:" << e.what() << std::endl;
+ }
+
+ testId = L"08";
+ testAction = L"reserve invalid (instantiated) name";
+ std::wcerr << testId << L"T Test: Attempting to " << testAction <<
std::endl;
+ try {
+ std::wstring invalidName(L"testObject");
+ ////////////////////////////////////////////////
+ rtiAmb->reserveObjectInstanceName(invalidName);
+ rtiAmb->evokeCallback(0.1);
+ ////////////////////////////////////////////////
+ // expected
+ std::wcerr << testId << L"E Pass:" << testAction << std::endl;
+ } catch (rti1516::IllegalName &e)
+ {
+ // expected
+ std::wcerr << testId << L"E Pass:" << e.what() << std::endl;
+ } catch (rti1516::Exception &e)
+ {
+ std::wcerr << testId << L"N Fail:" << e.what() << std::endl;
+ return
certi::rti1516_test::RETURN_ERROR_UNSUBSCRIBE_INTERACTION;
+ }
+
+ testId = L"09";
+ testAction = L"delete valid object instance";
+ std::wcerr << testId << L"T Test: Attempting to " << testAction <<
std::endl;
+ try {
+ ////////////////////////////////////////////////
+ const char *c_tag = "tag";
+ rti1516::VariableLengthData tag(c_tag, strlen(c_tag));
+ rtiAmb->deleteObjectInstance(objHandle, tag);
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"E Pass:" << testAction << std::endl;
+ } catch (rti1516::Exception &e)
+ {
+ std::wcerr << testId << L"N Fail:" << e.what() << std::endl;
+ return
certi::rti1516_test::RETURN_ERROR_UNSUBSCRIBE_INTERACTION;
+ }
+
+ testId = L"10";
+ testAction = L"reserve valid (released) name";
+ std::wcerr << testId << L"T Test: Attempting to " << testAction <<
std::endl;
+ try {
+ std::wstring validName(L"testObject");
+ ////////////////////////////////////////////////
+ rtiAmb->reserveObjectInstanceName(validName);
+ rtiAmb->evokeCallback(0.1);
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"E Pass:" << testAction << std::endl;
+ } catch (rti1516::Exception &e)
+ {
+ std::wcerr << testId << L"N Fail:" << e.what() << std::endl;
+ return
certi::rti1516_test::RETURN_ERROR_UNSUBSCRIBE_INTERACTION;
+ }
+
+ testId = L"11";
+ testAction = L"create valid object instance with reserved (reused)
name";
+ std::wcerr << testId << L"T Test: Attempting to " << testAction <<
std::endl;
+ try {
+ std::wstring validName(L"testObject");
+ ////////////////////////////////////////////////
+ objHandle = rtiAmb->registerObjectInstance(classHandle,
validName);
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"E Pass:" << testAction << std::endl;
+ } catch (rti1516::Exception &e)
+ {
+ std::wcerr << testId << L"N Fail:" << e.what() << std::endl;
+ return
certi::rti1516_test::RETURN_ERROR_UNSUBSCRIBE_INTERACTION;
+ }
+
+
+ std::wcerr << L"Test operations performed. Press enter to continue with
processing callbacks." << std::endl;
+ getchar();
+
+ testId = L"12";
+ testAction = L"process callbacks";
+ std::wcerr << testId << L"T Test: Attempting to " << testAction <<
std::endl;
+ try {
+ ////////////////////////////////////////////////
+ std::auto_ptr<rti1516::LogicalTimeFactory> factory =
rti1516::LogicalTimeFactoryFactory::makeLogicalTimeFactory(L"certi");
+ std::auto_ptr<rti1516::LogicalTime> logicalTime =
factory->makeLogicalTime();
+
+ RTI1516fedTime fedTime(1.0);
+
+ //rtiAmb->timeAdvanceRequest(*logicalTime);
+ rtiAmb->nextMessageRequestAvailable(fedTime);
+ rtiAmb->evokeMultipleCallbacks(0.0, 1.0);
+ ////////////////////////////////////////////////
+ std::wcerr << testId << L"E Pass:" << testAction << std::endl;
+ } catch (rti1516::Exception &e)
+ {
+ std::wcerr << testId << L"N Fail:" << e.what() << std::endl;
+ return
certi::rti1516_test::RETURN_ERROR_UNSUBSCRIBE_INTERACTION;
+ }
+
+
+ std::wcerr << L"Press enter to continue with shutdown." << std::endl;
+ getchar();
+
+ try {
+ ////////////////////////////////////////////////
+ std::wcerr << L"Attempting to resign from Federation" <<
std::endl;
+
rtiAmb->resignFederationExecution(rti1516::CANCEL_THEN_DELETE_THEN_DIVEST);
+ std::wcerr << L"Resigned from Federation" << std::endl;
+ std::wcerr << L"Attempting to destroy Federation" << std::endl;
+ rtiAmb->destroyFederationExecution(L"TestFederationName");
+ std::wcerr << L"Destroyed Federation" << std::endl;
+ ////////////////////////////////////////////////
+ // expected
+ } catch (rti1516::FederatesCurrentlyJoined &)
+ {
+ // expected
+ std::wcerr << L"Could not destroy federation while another
federate was still connected. This is expected behaviour." << std::endl;
+ } catch (rti1516::Exception &e)
+ {
+ std::wcerr << L"17N " << e.what() << std::endl;
+ return certi::rti1516_test::RETURN_ERROR_DESTROYING_FEDERATION;
+ }
+
+ return certi::rti1516_test::RETURN_NO_ERRORS;
+}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [certi-cvs] applications/HLA_TestsSuite CMakeLists.txt 05-O...,
certi-cvs <=