////////////////////////////////////////// // TEST: testTSODeleteObjectBelowLBTS() // ////////////////////////////////////////// @Test public void testTSODeleteObjectBelowLBTS() { try { LogicalTime time = TypeFactory.createTime(1.0); defaultFederate.rtiamb.deleteObjectInstance(getObjectHandle(oHandle), tag, time); expectedException(InvalidLogicalTime.class); } catch (InvalidLogicalTime ilt) { // success! } catch (Exception e) { wrongException(e, InvalidLogicalTime.class); } }
///////////////////////////////////////////////// // TEST: testRODeleteObjectWithInvalidHandle() // ///////////////////////////////////////////////// @Test public void testRODeleteObjectWithInvalidHandle() { // try and delete and object that doesn't exist try { defaultFederate.rtiamb.deleteObjectInstance(getObjectHandle(111111), tag); expectedException(ObjectInstanceNotKnown.class); } catch (ObjectInstanceNotKnown onk) { // success! } catch (Exception e) { wrongException(e, ObjectInstanceNotKnown.class); } }
////////////////////////////////////////////////// // TEST: testTSODeleteObjectWithInvalidHandle() // ////////////////////////////////////////////////// @Test public void testTSODeleteObjectWithInvalidHandle() { // try and delete and object that doesn't exist try { LogicalTime time = TypeFactory.createTime(5.0); defaultFederate.rtiamb.deleteObjectInstance(getObjectHandle(111111), tag, time); expectedException(ObjectInstanceNotKnown.class); } catch (ObjectInstanceNotKnown oink) { // success! } catch (Exception e) { wrongException(e, ObjectInstanceNotKnown.class); } }
///////////////////////////////////////////// // TEST: testRODeleteObjectThatIsUnowned() // ///////////////////////////////////////////// @Test public void testRODeleteObjectThatIsUnowned() { // try and delete an object that doesn't belong to the federate try { // delete it with the second federate, where the defaultFederate is the owner secondFederate.rtiamb.deleteObjectInstance(getObjectHandle(oHandle), tag); expectedException(DeletePrivilegeNotHeld.class); } catch (DeletePrivilegeNotHeld dpnh) { // success! } catch (Exception e) { wrongException(e, DeletePrivilegeNotHeld.class); } }
/////////////////////////////////////// // TEST: testTSODeleteObjectInPast() // /////////////////////////////////////// @Test public void testTSODeleteObjectInPast() { // advance the federate a bit, so that we can delete them in the past defaultFederate.quickAdvanceAndWait(20.0); try { LogicalTime time = TypeFactory.createTime(10.0); defaultFederate.rtiamb.deleteObjectInstance(getObjectHandle(oHandle), tag, time); expectedException(InvalidLogicalTime.class); } catch (InvalidLogicalTime ilt) { // success! } catch (Exception e) { wrongException(e, InvalidLogicalTime.class); } }
////////////////////////////////////////////// // TEST: testTSODeleteObjectThatIsUnowned() // ////////////////////////////////////////////// @Test public void testTSODeleteObjectThatIsUnowned() { // delete it with the second federate, where the defaultFederate is the owner // enable regulating so that the time isn't just disregarded as a matter of course secondFederate.quickEnableRegulating(1.0); try { LogicalTime time = TypeFactory.createTime(5.0); secondFederate.rtiamb.deleteObjectInstance(getObjectHandle(oHandle), tag, time); expectedException(DeletePrivilegeNotHeld.class); } catch (DeletePrivilegeNotHeld dpnh) { // success! } catch (Exception e) { wrongException(e, DeletePrivilegeNotHeld.class); } }
//////////////////////////////////////////// // TEST: testRODeleteObjectUndiscovered() // //////////////////////////////////////////// @Test public void testRODeleteObjectUndiscovered() { // try and delete and object that hasn't been discovered // this will require a new federate that doesn't subscribe to ObjectRoot.A or below TestFederate fourthFederate = new TestFederate("fourthFederate", this); fourthFederate.quickJoin(); try { fourthFederate.rtiamb.deleteObjectInstance(getObjectHandle(oHandle), tag); expectedException(ObjectInstanceNotKnown.class); } catch (ObjectInstanceNotKnown oink) { // success! } catch (Exception e) { wrongException(e, ObjectInstanceNotKnown.class); } finally { // clean up after ourselves fourthFederate.quickResign(); } }
///////////////////////////////////////////// // TEST: testTSODeleteObjectUndiscovered() // ///////////////////////////////////////////// @Test public void testTSODeleteObjectUndiscovered() { // try and delete and object that hasn't been discovered // this will require a new federate that doesn't subscribe to ObjectRoot.A or below // it also needs to be regulating so that the time isn't disregarded as a matter of course TestFederate fourthFederate = new TestFederate("fourthFederate", this); fourthFederate.quickJoin(); fourthFederate.quickEnableRegulating(5.0); try { LogicalTime time = TypeFactory.createTime(5.0); fourthFederate.rtiamb.deleteObjectInstance(getObjectHandle(oHandle), tag, time); expectedException(ObjectInstanceNotKnown.class); } catch (ObjectInstanceNotKnown onk) { // success! } catch (Exception e) { wrongException(e, ObjectInstanceNotKnown.class); } finally { // clean up after ourselves fourthFederate.quickResign(); } }