Пример #1
0
  //////////////////////////////////////////////////////////
  // TEST: (valid) testJoinFederationWithTypeAndModules() //
  //////////////////////////////////////////////////////////
  @Test
  public void testJoinFederationWithTypeAndModules() {
    // join the base federate to the federation
    defaultFederate.quickJoin();

    // validate that we don't have any information about the model the second federate
    // will add when it joins
    defaultFederate.quickOCHandleMissing("HLAobjectRoot.Employee.Waiter");
    defaultFederate.quickICHandleMissing("HLAinteractionRoot.CustomerTransactions.FoodServed");
    defaultFederate.quickOCHandleMissing("HLAobjectRoot.Food.SideDish.Corn");

    try {
      // try and join a federation with mode modules
      URL[] modules =
          new URL[] {
            ClassLoader.getSystemResource("fom/ieee1516e/restaurant/RestaurantProcesses.xml"),
            ClassLoader.getSystemResource("fom/ieee1516e/restaurant/RestaurantFood.xml"),
          };

      secondFederate.rtiamb.joinFederationExecution(
          secondFederate.federateName, secondFederate.simpleName, modules);
    } catch (Exception e) {
      // clean up for the next test //
      defaultFederate.quickResign();
      secondFederate.quickResignTolerant();
      Assert.fail("Failed while testing a valid join request with modules", e);
    }

    defaultFederate.quickTick();
    secondFederate.quickTick();

    // validate that the default federate now fetch information about the extended FOM
    // classes from RestaurantProcess.xml
    int handleA = defaultFederate.quickOCHandle("HLAobjectRoot.Employee.Waiter");
    int handleB = secondFederate.quickOCHandle("HLAobjectRoot.Employee.Waiter");
    Assert.assertEquals(handleB, handleA);

    handleA = defaultFederate.quickICHandle("HLAinteractionRoot.CustomerTransactions.FoodServed");
    handleB = secondFederate.quickICHandle("HLAinteractionRoot.CustomerTransactions.FoodServed");
    Assert.assertEquals(handleB, handleA);

    // classes from RestaurantFood.xml
    handleA = defaultFederate.quickOCHandle("HLAobjectRoot.Food.SideDish.Corn");
    handleB = secondFederate.quickOCHandle("HLAobjectRoot.Food.SideDish.Corn");
    Assert.assertEquals(handleB, handleA);
  }