/codebase/src-cpp/test/ng6/ownership/DivestOwnershipTest.cpp

https://github.com/graeme-muller/portico · C++ · 617 lines · 411 code · 45 blank · 161 comment · 2 complexity · 990a7806de85d2ddb6df284fc83bf404 MD5 · raw file

  1. /*
  2. * Copyright 2009 The Portico Project
  3. *
  4. * This file is part of portico.
  5. *
  6. * portico is free software; you can redistribute it and/or modify
  7. * it under the terms of the Common Developer and Distribution License (CDDL)
  8. * as published by Sun Microsystems. For more information see the LICENSE file.
  9. *
  10. * Use of this software is strictly AT YOUR OWN RISK!!!
  11. * If something bad happens you do not have permission to come crying to me.
  12. * (that goes for your lawyer as well)
  13. *
  14. */
  15. #include "DivestOwnershipTest.h"
  16. // Register test suite with the global repository
  17. CPPUNIT_TEST_SUITE_REGISTRATION( DivestOwnershipTest );
  18. CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( DivestOwnershipTest, "DivestOwnershipTest" );
  19. CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( DivestOwnershipTest, "ownershipManagement" );
  20. /////////////////////////////////////////////////////////////////////////////////////////////
  21. ////////////////////////////////// Constructors/Destructors /////////////////////////////////
  22. /////////////////////////////////////////////////////////////////////////////////////////////
  23. DivestOwnershipTest::DivestOwnershipTest()
  24. {
  25. this->defaultFederate = new TestNG6Federate( "defaultFederate" );
  26. this->secondFederate = new TestNG6Federate( "secondFederate" );
  27. this->ahs = NULL;
  28. this->tag = new char[8];
  29. strcpy( this->tag, "eltaggo" );
  30. }
  31. DivestOwnershipTest::~DivestOwnershipTest()
  32. {
  33. delete this->defaultFederate;
  34. delete this->secondFederate;
  35. delete this->tag;
  36. }
  37. /////////////////////////////////////////////////////////////////////////////////////////////
  38. /////////////////////////////// Test Setup and Helper Methods ///////////////////////////////
  39. /////////////////////////////////////////////////////////////////////////////////////////////
  40. void DivestOwnershipTest::setUp()
  41. {
  42. this->defaultFederate->quickCreate();
  43. this->defaultFederate->quickJoin();
  44. this->secondFederate->quickJoin();
  45. // cache some handle information
  46. this->ahs = NULL;
  47. this->aa = defaultFederate->quickACHandle( "ObjectRoot.A", "aa" );
  48. this->ab = defaultFederate->quickACHandle( "ObjectRoot.A", "ab" );
  49. this->ac = defaultFederate->quickACHandle( "ObjectRoot.A", "ac" );
  50. this->ba = defaultFederate->quickACHandle( "ObjectRoot.A.B", "ba" );
  51. this->bb = defaultFederate->quickACHandle( "ObjectRoot.A.B", "bb" );
  52. this->bc = defaultFederate->quickACHandle( "ObjectRoot.A.B", "bc" );
  53. // publish and subscribe
  54. defaultFederate->quickPublish( "ObjectRoot.A.B", 3, "aa", "ab", "ac" );
  55. secondFederate->quickSubscribe( "ObjectRoot.A.B", 6, "aa", "ab", "ac", "ba", "bb", "bc" );
  56. secondFederate->quickPublish( "ObjectRoot.A.B", 6, "aa", "ab", "ac", "ba", "bb", "bc" );
  57. // register and discover the object
  58. this->theObject = defaultFederate->quickRegister( "ObjectRoot.A.B" );
  59. this->secondFederate->fedamb->waitForDiscovery( theObject );
  60. }
  61. void DivestOwnershipTest::tearDown()
  62. {
  63. if( this->ahs != NULL )
  64. delete this->ahs;
  65. this->secondFederate->quickResign();
  66. this->defaultFederate->quickResign();
  67. this->defaultFederate->quickDestroy();
  68. }
  69. /////////////////////////////////////////////////////////////////////////////////////////////
  70. ///////////////////////////// Unconditional Divest Test Methods /////////////////////////////
  71. /////////////////////////////////////////////////////////////////////////////////////////////
  72. // void unconditionalAttributeOwnershipDivestiture (
  73. // ObjectHandle theObject, // supplied C1
  74. // const AttributeHandleSet& theAttributes ) // supplied C4
  75. // throw ( ObjectNotKnown,
  76. // AttributeNotDefined,
  77. // AttributeNotOwned,
  78. // FederateNotExecutionMember,
  79. // ConcurrentAccessAttempted,
  80. // SaveInProgress,
  81. // RestoreInProgress,
  82. // RTIinternalError );
  83. /////////////////////////////////////////////
  84. // TEST: (valid) testUnconditionalDivest() //
  85. /////////////////////////////////////////////
  86. void DivestOwnershipTest::testUnconditionalDivest()
  87. {
  88. try
  89. {
  90. this->ahs = defaultFederate->populatedAHS( 3, aa, ab, ac );
  91. defaultFederate->rtiamb->unconditionalAttributeOwnershipDivestiture( theObject, *ahs );
  92. }
  93. catch( RTI::Exception& e )
  94. {
  95. failTest( "Unexpected exception while starting unconditional ownership release: %s",
  96. e._reason );
  97. }
  98. // wait for the acquisition notification
  99. secondFederate->fedamb->waitForOwnershipOffered( theObject, 3, aa, ab, ac );
  100. }
  101. //////////////////////////////////////////////////////
  102. // TEST: testUnconditionalDivestWithInvalidObject() //
  103. //////////////////////////////////////////////////////
  104. void DivestOwnershipTest::testUnconditionalDivestWithInvalidObject()
  105. {
  106. try
  107. {
  108. this->ahs = defaultFederate->populatedAHS( 3, aa, ab, ac );
  109. defaultFederate->rtiamb->unconditionalAttributeOwnershipDivestiture( 100000, *ahs );
  110. failTestMissingException( "ObjectNotKnown",
  111. "unconditional ownership release with unknown object" );
  112. }
  113. catch( RTI::ObjectNotKnown& onk )
  114. {
  115. // success!
  116. }
  117. catch( RTI::Exception& e )
  118. {
  119. failTestWrongException( "ObjectNotKnown", e,
  120. "unconditional ownership release with unknown object" );
  121. }
  122. }
  123. //////////////////////////////////////////////////////
  124. // TEST: testUnconditionalDivestWithUnknownObject() //
  125. //////////////////////////////////////////////////////
  126. void DivestOwnershipTest::testUnconditionalDivestWithUnknownObject()
  127. {
  128. // create a second object that isn't discovered by the original federate, so it's a valid
  129. // handle in the federation, just not known by the seocnd federate
  130. RTI::ObjectHandle secondObject = secondFederate->quickRegister( "ObjectRoot.A.B" );
  131. try
  132. {
  133. this->ahs = defaultFederate->populatedAHS( 3, aa, ab, ac );
  134. defaultFederate->rtiamb->unconditionalAttributeOwnershipDivestiture( secondObject, *ahs );
  135. failTestMissingException( "ObjectNotKnown",
  136. "unconditional ownership release with undiscovered object" );
  137. }
  138. catch( RTI::ObjectNotKnown& onk )
  139. {
  140. // success!
  141. }
  142. catch( RTI::Exception& e )
  143. {
  144. failTestWrongException( "ObjectNotKnown", e,
  145. "unconditional ownership release with undiscovered object" );
  146. }
  147. }
  148. /////////////////////////////////////////////////////////
  149. // TEST: testUnconditionalDivestWithInvalidAttribute() //
  150. /////////////////////////////////////////////////////////
  151. void DivestOwnershipTest::testUnconditionalDivestWithInvalidAttribute()
  152. {
  153. try
  154. {
  155. this->ahs = defaultFederate->populatedAHS( 3, aa, ab, 10000 );
  156. defaultFederate->rtiamb->unconditionalAttributeOwnershipDivestiture( theObject, *ahs );
  157. failTestMissingException( "AttributeNotDefined",
  158. "unconditional ownership release with invalid attribute" );
  159. }
  160. catch( RTI::AttributeNotDefined& anotd )
  161. {
  162. // success!
  163. }
  164. catch( RTI::Exception& e )
  165. {
  166. failTestWrongException( "AttributeNotDefined", e,
  167. "unconditional ownership release with invalid attribute" );
  168. }
  169. }
  170. /////////////////////////////////////////////////////////
  171. // TEST: testUnconditionalDivestWithUnownedAttribute() //
  172. /////////////////////////////////////////////////////////
  173. void DivestOwnershipTest::testUnconditionalDivestWithUnownedAttribute()
  174. {
  175. try
  176. {
  177. this->ahs = defaultFederate->populatedAHS( 1, ba );
  178. defaultFederate->rtiamb->unconditionalAttributeOwnershipDivestiture( theObject, *ahs );
  179. failTestMissingException( "AttributeNotOwned",
  180. "unconditional ownership release with unowned attribute" );
  181. }
  182. catch( RTI::AttributeNotOwned& ano )
  183. {
  184. // success!
  185. }
  186. catch( RTI::Exception& e )
  187. {
  188. failTestWrongException( "AttributeNotOwned", e,
  189. "unconditional ownership release with unowned attribute" );
  190. }
  191. }
  192. //////////////////////////////////////////////////
  193. // TEST: testUnconditionalDivestWhenNotJoined() //
  194. //////////////////////////////////////////////////
  195. void DivestOwnershipTest::testUnconditionalDivestWhenNotJoined()
  196. {
  197. defaultFederate->quickResign();
  198. try
  199. {
  200. this->ahs = defaultFederate->populatedAHS( 3, aa, ab, ac );
  201. defaultFederate->rtiamb->unconditionalAttributeOwnershipDivestiture( theObject, *ahs );
  202. failTestMissingException( "FederateNotExecutionMember",
  203. "unconditional ownership release when not joined" );
  204. }
  205. catch( RTI::FederateNotExecutionMember& fnem )
  206. {
  207. // success!
  208. }
  209. catch( RTI::Exception& e )
  210. {
  211. failTestWrongException( "FederateNotExecutionMember", e,
  212. "unconditional ownership release when not joined" );
  213. }
  214. }
  215. /////////////////////////////////////////////////////////////////////////////////////////////
  216. ////////////////////////////// Negotiated Divest Test Methods ///////////////////////////////
  217. /////////////////////////////////////////////////////////////////////////////////////////////
  218. // void negotiatedAttributeOwnershipDivestiture (
  219. // ObjectHandle theObject, // supplied C1
  220. // const AttributeHandleSet& theAttributes, // supplied C4
  221. // const char *theTag) // supplied C4
  222. // throw( ObjectNotKnown,
  223. // AttributeNotDefined,
  224. // AttributeNotOwned,
  225. // AttributeAlreadyBeingDivested,
  226. // FederateNotExecutionMember,
  227. // ConcurrentAccessAttempted,
  228. // SaveInProgress,
  229. // RestoreInProgress,
  230. // RTIinternalError );
  231. //////////////////////////////////////////
  232. // TEST: (valid) testNegotiatedDivest() //
  233. //////////////////////////////////////////
  234. void DivestOwnershipTest::testNegotiatedDivest()
  235. {
  236. try
  237. {
  238. this->ahs = defaultFederate->populatedAHS( 3, aa, ab, ac );
  239. defaultFederate->rtiamb->negotiatedAttributeOwnershipDivestiture( theObject, *ahs, "NA" );
  240. }
  241. catch( RTI::Exception& e )
  242. {
  243. failTest( "Unexpected exception while starting negotiated ownership release: %s",
  244. e._reason );
  245. }
  246. // wait for the acquisition notification
  247. secondFederate->fedamb->waitForOwnershipOffered( theObject, 3, aa, ab, ac );
  248. secondFederate->quickAcquireRequest( theObject, 3, aa, ab, ac );
  249. defaultFederate->quickTick();
  250. secondFederate->fedamb->waitForOwnershipAcquistion( theObject, 3, aa, ab, ac );
  251. defaultFederate->fedamb->waitForOwnershipDivested( theObject, 3, aa, ab, ac );
  252. }
  253. ///////////////////////////////////////////////////
  254. // TEST: testNegotiatedDivestWithInvalidObject() //
  255. ///////////////////////////////////////////////////
  256. void DivestOwnershipTest::testNegotiatedDivestWithInvalidObject()
  257. {
  258. try
  259. {
  260. this->ahs = defaultFederate->populatedAHS( 3, aa, ab, ac );
  261. defaultFederate->rtiamb->negotiatedAttributeOwnershipDivestiture( 100000, *ahs, tag );
  262. failTestMissingException( "ObjectNotKnown",
  263. "negotiated ownership release with invalid object" );
  264. }
  265. catch( RTI::ObjectNotKnown& onk )
  266. {
  267. // success!
  268. }
  269. catch( RTI::Exception& e )
  270. {
  271. failTestWrongException( "ObjectNotKnown", e,
  272. "negotiated ownership release with invalid object" );
  273. }
  274. }
  275. ///////////////////////////////////////////////////
  276. // TEST: testNegotiatedDivestWithUnknownObject() //
  277. ///////////////////////////////////////////////////
  278. void DivestOwnershipTest::testNegotiatedDivestWithUnknownObject()
  279. {
  280. // create a second object that isn't discovered by the original federate, so it's a valid
  281. // handle in the federation, just not known by the seocnd federate
  282. RTI::ObjectHandle secondObject = secondFederate->quickRegister( "ObjectRoot.A.B" );
  283. try
  284. {
  285. this->ahs = defaultFederate->populatedAHS( 3, aa, ab, ac );
  286. defaultFederate->rtiamb->negotiatedAttributeOwnershipDivestiture( secondObject, *ahs, tag );
  287. failTestMissingException( "ObjectNotKnown",
  288. "negotiated ownership release with undiscovered object" );
  289. }
  290. catch( RTI::ObjectNotKnown& onk )
  291. {
  292. // success!
  293. }
  294. catch( RTI::Exception& e )
  295. {
  296. failTestWrongException( "ObjectNotKnown", e,
  297. "negotiated ownership release with undiscovered object" );
  298. }
  299. }
  300. //////////////////////////////////////////////////////
  301. // TEST: testNegotiatedDivestWithInvalidAttribute() //
  302. //////////////////////////////////////////////////////
  303. void DivestOwnershipTest::testNegotiatedDivestWithInvalidAttribute()
  304. {
  305. try
  306. {
  307. this->ahs = defaultFederate->populatedAHS( 3, aa, ab, 10000 );
  308. defaultFederate->rtiamb->negotiatedAttributeOwnershipDivestiture( theObject, *ahs, tag );
  309. failTestMissingException( "AttributeNotDefined",
  310. "negotiated ownership release with invalid attribute" );
  311. }
  312. catch( RTI::AttributeNotDefined& anotd )
  313. {
  314. // success!
  315. }
  316. catch( RTI::Exception& e )
  317. {
  318. failTestWrongException( "AttributeNotDefined", e,
  319. "negotiated ownership release with invalid attribute" );
  320. }
  321. }
  322. /////////////////////////////////////////////////////////
  323. // TEST: testUnconditionalDivestWithUnownedAttribute() //
  324. /////////////////////////////////////////////////////////
  325. void DivestOwnershipTest::testNegotiatedDivestWithUnownedAttribute()
  326. {
  327. try
  328. {
  329. this->ahs = defaultFederate->populatedAHS( 1, ba );
  330. defaultFederate->rtiamb->negotiatedAttributeOwnershipDivestiture( theObject, *ahs, tag );
  331. failTestMissingException( "AttributeNotOwned",
  332. "negotiated ownership release with unowned attribute" );
  333. }
  334. catch( RTI::AttributeNotOwned& ano )
  335. {
  336. // success!
  337. }
  338. catch( RTI::Exception& e )
  339. {
  340. failTestWrongException( "AttributeNotOwned", e,
  341. "negotiated ownership release with unowned attribute" );
  342. }
  343. }
  344. ///////////////////////////////////////////////////////////////////
  345. // TEST: testNegotiatedDivestWithAttributeAlreadyBeingDivested() //
  346. ///////////////////////////////////////////////////////////////////
  347. void DivestOwnershipTest::testNegotiatedDivestWithAttributeAlreadyBeingDivested()
  348. {
  349. // kick off the divest process
  350. defaultFederate->quickNegotiatedRelease( theObject, 3, aa, ab, ac );
  351. try
  352. {
  353. this->ahs = defaultFederate->populatedAHS( 3, aa, ab, ac );
  354. defaultFederate->rtiamb->negotiatedAttributeOwnershipDivestiture( theObject, *ahs, tag );
  355. failTestMissingException( "AttributeAlreadyBeingDivested",
  356. "negotiated ownership release with unowned attribute" );
  357. }
  358. catch( RTI::AttributeAlreadyBeingDivested& aabd )
  359. {
  360. // success!
  361. }
  362. catch( RTI::Exception& e )
  363. {
  364. failTestWrongException( "AttributeAlreadyBeingDivested", e,
  365. "negotiated ownership release with unowned attribute" );
  366. }
  367. }
  368. ///////////////////////////////////////////////
  369. // TEST: testNegotiatedDivestWhenNotJoined() //
  370. ///////////////////////////////////////////////
  371. void DivestOwnershipTest::testNegotiatedDivestWhenNotJoined()
  372. {
  373. defaultFederate->quickResign();
  374. try
  375. {
  376. this->ahs = defaultFederate->populatedAHS( 3, aa, ab, ac );
  377. defaultFederate->rtiamb->negotiatedAttributeOwnershipDivestiture( theObject, *ahs, tag );
  378. failTestMissingException( "FederateNotExecutionMember",
  379. "negotiated ownership release when not joined" );
  380. }
  381. catch( RTI::FederateNotExecutionMember& fnem )
  382. {
  383. // success!
  384. }
  385. catch( RTI::Exception& e )
  386. {
  387. failTestWrongException( "FederateNotExecutionMember", e,
  388. "negotiated ownership release when not joined" );
  389. }
  390. }
  391. /////////////////////////////////////////////////////////////////////////////////////////////
  392. /////////////////////////// Cancel Negoriated Divest Test Methods ///////////////////////////
  393. /////////////////////////////////////////////////////////////////////////////////////////////
  394. // void cancelNegotiatedAttributeOwnershipDivestiture (
  395. // ObjectHandle theObject, // supplied C1
  396. // const AttributeHandleSet& theAttributes ) // supplied C4
  397. // throw( ObjectNotKnown,
  398. // AttributeNotDefined,
  399. // AttributeNotOwned,
  400. // AttributeDivestitureWasNotRequested,
  401. // FederateNotExecutionMember,
  402. // ConcurrentAccessAttempted,
  403. // SaveInProgress,
  404. // RestoreInProgress,
  405. // RTIinternalError );
  406. ////////////////////////////////////////////////
  407. // TEST: (valid) testCancelNegotiatedDivest() //
  408. ////////////////////////////////////////////////
  409. void DivestOwnershipTest::testCancelNegotiatedDivest()
  410. {
  411. // kick off a divest
  412. defaultFederate->quickNegotiatedRelease( theObject, 3, aa, ab, ac );
  413. secondFederate->fedamb->waitForOwnershipOffered( theObject, 3, aa, ab, ac );
  414. try
  415. {
  416. this->ahs = defaultFederate->populatedAHS( 3, aa, ab, ac );
  417. defaultFederate->rtiamb->cancelNegotiatedAttributeOwnershipDivestiture( theObject, *ahs );
  418. }
  419. catch( RTI::Exception& e )
  420. {
  421. failTest( "Unexpected exception while cancelling negotiated ownership release: %s",
  422. e._reason );
  423. }
  424. // try and obtain the attributes in the second federate
  425. secondFederate->quickAcquireRequest( theObject, 3, aa, ab, ac );
  426. // if the divest was outstanding, defaultFederate would hand it off right away, but
  427. // as it isn't, this request should cause a callback requesting the default fed to release
  428. defaultFederate->fedamb->waitForOwnershipRequest( theObject, 3, aa, ab, ac );
  429. }
  430. /////////////////////////////////////////////////////////
  431. // TEST: testCancelNegotiatedDivestWithInvalidObject() //
  432. /////////////////////////////////////////////////////////
  433. void DivestOwnershipTest::testCancelNegotiatedDivestWithInvalidObject()
  434. {
  435. try
  436. {
  437. this->ahs = defaultFederate->populatedAHS( 3, aa, ab, ac );
  438. defaultFederate->rtiamb->cancelNegotiatedAttributeOwnershipDivestiture( 100000, *ahs );
  439. failTestMissingException( "ObjectNotKnown",
  440. "cancel negotiated ownership divest with invalid object" );
  441. }
  442. catch( RTI::ObjectNotKnown& onk )
  443. {
  444. // success!
  445. }
  446. catch( RTI::Exception& e )
  447. {
  448. failTestWrongException( "ObjectNotKnown", e,
  449. "cancel negotiated ownership divest with invalid object" );
  450. }
  451. }
  452. /////////////////////////////////////////////////////////
  453. // TEST: testCancelNegotiatedDivestWithUnknownObject() //
  454. /////////////////////////////////////////////////////////
  455. void DivestOwnershipTest::testCancelNegotiatedDivestWithUnknownObject()
  456. {
  457. // create a second object that isn't discovered by the original federate, so it's a valid
  458. // handle in the federation, just not known by the seocnd federate
  459. RTI::ObjectHandle secondObject = secondFederate->quickRegister( "ObjectRoot.A.B" );
  460. try
  461. {
  462. this->ahs = defaultFederate->populatedAHS( 3, aa, ab, ac );
  463. defaultFederate->rtiamb->cancelNegotiatedAttributeOwnershipDivestiture( secondObject, *ahs );
  464. failTestMissingException( "ObjectNotKnown",
  465. "cancel negotiated ownership divest with unknown object" );
  466. }
  467. catch( RTI::ObjectNotKnown& onk )
  468. {
  469. // success!
  470. }
  471. catch( RTI::Exception& e )
  472. {
  473. failTestWrongException( "ObjectNotKnown", e,
  474. "cancel negotiated ownership divest with unknown object" );
  475. }
  476. }
  477. ////////////////////////////////////////////////////////////
  478. // TEST: testCancelNegotiatedDivestWithInvalidAttribute() //
  479. ////////////////////////////////////////////////////////////
  480. void DivestOwnershipTest::testCancelNegotiatedDivestWithInvalidAttribute()
  481. {
  482. try
  483. {
  484. this->ahs = defaultFederate->populatedAHS( 1, 10000 );
  485. defaultFederate->rtiamb->cancelNegotiatedAttributeOwnershipDivestiture( theObject, *ahs );
  486. failTestMissingException( "AttributeNotDefined",
  487. "cancel negotiated ownership divest with invalid attribute" );
  488. }
  489. catch( RTI::AttributeNotDefined& anotd )
  490. {
  491. // success!
  492. }
  493. catch( RTI::Exception& e )
  494. {
  495. failTestWrongException( "AttributeNotDefined", e,
  496. "cancel negotiated ownership divest with invalid attribute" );
  497. }
  498. }
  499. ////////////////////////////////////////////////////////////
  500. // TEST: testCancelNegotiatedDivestWithUnownedAttribute() //
  501. ////////////////////////////////////////////////////////////
  502. void DivestOwnershipTest::testCancelNegotiatedDivestWithUnownedAttribute()
  503. {
  504. // start the transfer off, have it transferred but not confirmed to the default federate,
  505. // otherwise we'd get an error saying there was no outstanding request
  506. defaultFederate->quickNegotiatedRelease( theObject, 3, aa, ab, ac );
  507. secondFederate->fedamb->waitForOwnershipOffered( theObject, 3, aa, ab, ac );
  508. secondFederate->quickAcquireRequest( theObject, 3, aa, ab, ac );
  509. defaultFederate->quickTick();
  510. secondFederate->fedamb->waitForOwnershipAcquistion( theObject, 3, aa, ab, ac );
  511. try
  512. {
  513. this->ahs = defaultFederate->populatedAHS( 3, aa, ab, ac );
  514. defaultFederate->rtiamb->cancelNegotiatedAttributeOwnershipDivestiture( theObject, *ahs );
  515. failTestMissingException( "AttributeNotOwned",
  516. "cancel negotiated ownership divest after exchange completed" );
  517. }
  518. catch( RTI::AttributeNotOwned& ano )
  519. {
  520. // success!
  521. }
  522. catch( RTI::Exception& e )
  523. {
  524. failTestWrongException( "AttributeNotOwned", e,
  525. "cancel negotiated ownership divest after exchange completed" );
  526. }
  527. }
  528. /////////////////////////////////////////////////////////////////
  529. // TEST: testCancelNegotiatedDivestWithoutOutstandingRequest() //
  530. /////////////////////////////////////////////////////////////////
  531. void DivestOwnershipTest::testCancelNegotiatedDivestWithoutOutstandingRequest()
  532. {
  533. try
  534. {
  535. this->ahs = defaultFederate->populatedAHS( 3, aa, ab, ac );
  536. defaultFederate->rtiamb->cancelNegotiatedAttributeOwnershipDivestiture( theObject, *ahs );
  537. failTestMissingException( "AttributeDivestitureWasNotRequested",
  538. "cancel negotiated ownership divest when none was requested" );
  539. }
  540. catch( RTI::AttributeDivestitureWasNotRequested& anotd )
  541. {
  542. // success!
  543. }
  544. catch( RTI::Exception& e )
  545. {
  546. failTestWrongException( "AttributeDivestitureWasNotRequested", e,
  547. "cancel negotiated ownership divest when none was requested" );
  548. }
  549. }
  550. /////////////////////////////////////////////////////
  551. // TEST: testCancelNegotiatedDivestWhenNotJoined() //
  552. /////////////////////////////////////////////////////
  553. void DivestOwnershipTest::testCancelNegotiatedDivestWhenNotJoined()
  554. {
  555. defaultFederate->quickResign();
  556. try
  557. {
  558. this->ahs = defaultFederate->populatedAHS( 3, aa, ab, ac );
  559. defaultFederate->rtiamb->cancelNegotiatedAttributeOwnershipDivestiture( theObject, *ahs );
  560. failTestMissingException( "FederateNotExecutionMember",
  561. "cancel negotiated ownership divest when not joined" );
  562. }
  563. catch( RTI::FederateNotExecutionMember& fnem )
  564. {
  565. // success!
  566. }
  567. catch( RTI::Exception& e )
  568. {
  569. failTestWrongException( "FederateNotExecutionMember", e,
  570. "cancel negotiated ownership divest when not joined" );
  571. }
  572. }