certi-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[certi-cvs] applications/HLA_TestsSuite CMakeLists.txt test...


From: certi-cvs
Subject: [certi-cvs] applications/HLA_TestsSuite CMakeLists.txt test...
Date: Mon, 28 Apr 2008 07:39:57 +0000

CVSROOT:        /sources/certi
Module name:    applications
Changes by:     Eric NOULARD <erk>      08/04/28 07:39:57

Modified files:
        HLA_TestsSuite : CMakeLists.txt 
Added files:
        HLA_TestsSuite : test_CreateJoinResignDestroy.cc 
                         test_CreateJoinResignDestroy.fed 

Log message:
        Add test example which may be used as a pattern
        for other tests

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/applications/HLA_TestsSuite/CMakeLists.txt?cvsroot=certi&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/applications/HLA_TestsSuite/test_CreateJoinResignDestroy.cc?cvsroot=certi&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/applications/HLA_TestsSuite/test_CreateJoinResignDestroy.fed?cvsroot=certi&rev=1.1

Patches:
Index: CMakeLists.txt
===================================================================
RCS file: /sources/certi/applications/HLA_TestsSuite/CMakeLists.txt,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- CMakeLists.txt      27 Apr 2008 13:16:41 -0000      1.1
+++ CMakeLists.txt      28 Apr 2008 07:39:57 -0000      1.2
@@ -95,13 +95,14 @@
 #########################################################################
 # ADD TEST ELEMENTARY PROGRAM
 #########################################################################
-#HLATestSuite_ADD_TEST(test01
-#                      FEDFILE Sample.fed
-#                      SOURCE_FILES test01.cc)
+#HLATestSuite_ADD_TEST(test_CreateJoinResignDestroy
+#                      FEDFILE test_CreateJoinResignDestroy.fed
+#                      SOURCE_FILES test_CreateJoinResignDestroy.cc)
 
-#ADD_EXECUTABLE(test01 test01.cc)
-#TARGET_LINK_LIBRARIES(test01 ${CERTI_LIBRARIES})
-#INSTALL(TARGETS test01 RUNTIME DESTINATION bin)
-#INSTALL(FILES Test01.fed DESTINATION share/federations)
+SET(TESTNAME test_CreateJoinResignDestroy)
+ADD_EXECUTABLE(${TESTNAME} ${TESTNAME}.cc)
+TARGET_LINK_LIBRARIES(${TESTNAME} ${CERTI_LIBRARIES})
+INSTALL(TARGETS ${TESTNAME} RUNTIME DESTINATION bin)
+INSTALL(FILES ${TESTNAME}.fed DESTINATION share/federations)
 
 MESSAGE(STATUS "*** ${CMAKE_PROJECT_NAME} has been successfully configured 
***")

Index: test_CreateJoinResignDestroy.cc
===================================================================
RCS file: test_CreateJoinResignDestroy.cc
diff -N test_CreateJoinResignDestroy.cc
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ test_CreateJoinResignDestroy.cc     28 Apr 2008 07:39:57 -0000      1.1
@@ -0,0 +1,63 @@
+#include <iostream>
+#include <NullFederateAmbassador.hh>
+
+class TestAmbassador : public NullFederateAmbassador
+{
+public:
+  TestAmbassador()
+   : mRtiAmbassador()
+  {}
+  virtual ~TestAmbassador()
+    throw (RTI::FederateInternalError)
+  {}
+
+  int joinAndLeave(const char* federation, const char* model, const char* 
federate);
+  int destroy(const char* federation);
+
+protected:
+  RTI::RTIambassador mRtiAmbassador;
+};
+
+int TestAmbassador::joinAndLeave(
+  const char* federation, const char* model, const char* federate)
+{
+  try
+  {
+    mRtiAmbassador.createFederationExecution(federation, model);
+  }
+  catch (RTI::FederationExecutionAlreadyExists& e)
+  { }
+
+  mRtiAmbassador.joinFederationExecution(federate, federation, this);
+
+  mRtiAmbassador.resignFederationExecution(RTI::NO_ACTION);
+    //RTI::DELETE_OBJECTS_AND_RELEASE_ATTRIBUTES);
+
+  return 0;
+}
+
+int 
+TestAmbassador::destroy(const char* federation)
+{
+  try
+  {
+    mRtiAmbassador.destroyFederationExecution(federation);
+  }
+  catch (RTI::FederationExecutionDoesNotExist& e)
+  { }
+
+  return 0;
+}
+
+
+int main(void)
+{
+  TestAmbassador test;
+  //test.joinAndLeave("Test01", "Test01.fed", "name");
+  std::cout << "OK" << std::endl;
+  test.joinAndLeave("Test01", "Test01.fed", "");
+  //test.destroy("Test01");
+  std::cout << "OK" << std::endl;
+
+  return 0;
+}

Index: test_CreateJoinResignDestroy.fed
===================================================================
RCS file: test_CreateJoinResignDestroy.fed
diff -N test_CreateJoinResignDestroy.fed
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ test_CreateJoinResignDestroy.fed    28 Apr 2008 07:39:57 -0000      1.1
@@ -0,0 +1,16 @@
+;; Test01
+(Fed
+  (Federation Test01)
+  (FedVersion v1.3)
+  (Federate "fed" "Public")
+  (Spaces      
+  )
+  (Objects
+    (Class ObjectRoot
+      (Attribute privilegeToDelete reliable timestamp)
+      (Class RTIprivate)       
+    )
+  )
+  (Interactions    
+  )
+)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]