public void testUpateNonExistenceFlightPlanObject() {

    // create a flight plan

    FlightPlan flightPlanNotAdded = null;

    try {
      flightPlanNotAdded = new FlightPlan(tailNumber, callSign);
    } catch (MuthurException e) {
      fail(e.getLocalizedMessage());
    }

    flightPlanNotAdded.setSource(source);
    flightPlanNotAdded.setAircraftType(aircraftType);
    flightPlanNotAdded.setPlannedDepartureTimeMSecs(System.currentTimeMillis());
    flightPlanNotAdded.setPlannedArrivalTimeMSecs(System.currentTimeMillis() + 30000);
    flightPlanNotAdded.setCruiseSpeedKts(cruiseSpeedKts);
    flightPlanNotAdded.setCruiseAltitudeFt(cruiseAltitudeFeet);
    flightPlanNotAdded.setRoutePlan(route);
    flightPlanNotAdded.setDepartureCenter(departureCenter);
    flightPlanNotAdded.setArrivalCenter(arrivalCenter);
    flightPlanNotAdded.setDepartureFix(departureFix);
    flightPlanNotAdded.setArrivalFix(arrivalFix);
    flightPlanNotAdded.setPhysicalAircraftClass(physicalClass);
    flightPlanNotAdded.setWeightAircraftClass(weightClass);
    flightPlanNotAdded.setUserAircraftClass(userClass);
    flightPlanNotAdded.setNumOfAircraft(1);
    flightPlanNotAdded.setAirborneEquipmentQualifier(airborneEquipmentQualifier);

    try {
      objectService.updateObject(federationExecutionID, flightPlanNotAdded);
      fail("Should have thrown an exception trying to update a non-existent object.");
    } catch (MuthurException e) {
    }
  }
  @Test
  public void testPauseFederationRequest() {

    PauseFederationRequest req = new PauseFederationRequest();

    req.setTimeToLiveSecs(10);
    req.setSourceOfEvent("Muthur");
    req.setTimeToLiveSecs(10);
    req.setLengthOfPauseMSecs(10000); // 10 secs

    assertNotNull(req);

    String objectAsXML = req.serialize();

    assertNotNull(objectAsXML);
    assertFalse("".equals(objectAsXML));

    writeToFile(req, false);

    PauseFederationRequest reqFromXML = new PauseFederationRequest();

    try {
      reqFromXML.initialization(objectAsXML);
    } catch (MuthurException e) {
      fail(e.getLocalizedMessage());
    }

    assertTrue(reqFromXML.equals(req));
  }
  public void testAddAircraftObjectThatAlreadyExists() {

    try {
      objectService.addDataObject(federationExecutionID, aircraft);
      fail("Should have thrown an exception for " + "attempting to add a duplicate object");
    } catch (MuthurException e) {
      System.out.println(e.getLocalizedMessage());
    }
  }
  public void testDeleteAircraftObject() {

    try {
      objectService.deleteDataObject(federationExecutionID, aircraft.getDataObjectUUID());
    } catch (MuthurException e) {
      fail(e.getLocalizedMessage());
    }

    assertObjectDeleted(aircraft);
  }
 @Override
 public void startOfElement(String currentElementName) {
   // signals that a new element has begun
   if ("fedExecModel".equalsIgnoreCase(currentElementName)) {
     try {
       currentFEM = new FederationExecutionModel(currentElementName);
     } catch (MuthurException e) {
       LOG.error(e.getLocalizedMessage());
     }
   }
 }
  /**
   * Uses the {@link IBaseDataObject#getDataObjectUUID()} from bdo to attempt to retrieve the object
   * from the {@link ObjectService}. If the object is retrieved then it is check for null and
   * equality.
   */
  private void assertObjectDeleted(final IBaseDataObject bdo) {

    IBaseDataObject retrievedDataObject = null;

    try {
      retrievedDataObject = getObject(bdo.getDataObjectUUID());
    } catch (MuthurException e) {
      fail(e.getLocalizedMessage());
    }

    assert (retrievedDataObject == null);
  }
  /**
   * Uses the {@link IBaseDataObject#getDataObjectUUID()} from bdo to attempt to retrieve the object
   * from the {@link ObjectService}. If the object is retrieved then it is check for null and
   * equality.
   */
  private void assertObjectExists(final IBaseDataObject bdo) {

    IBaseDataObject retrievedDataObject = null;

    try {
      retrievedDataObject = getObject(bdo.getDataObjectUUID());
    } catch (MuthurException e) {
      fail(e.getLocalizedMessage());
    }

    assert (retrievedDataObject != null);
    assertTrue(retrievedDataObject.equals(bdo));
  }
  /** @throws java.lang.Exception */
  @BeforeClass
  public static void setUpBeforeClass() throws Exception {

    commonsService = new CommonsServiceImpl();

    commonsService.start();

    configurationService = new MockConfigurationServerImpl();

    int availablePort = commonsService.findAvailablePort(6000, 7000);

    assert (availablePort != -1);

    configurationService.setMessagingPort(availablePort);

    /** create model service and set it inside the object service impl */
    modelService = new ModelServiceImpl();

    modelService.start();

    objectService = new ObjectServiceImpl();

    ownershipService = new OwnershipServiceImpl();

    ownershipService.setConfigurationService(configurationService);

    ownershipService.start();

    // set the services into the object service impl

    objectService.setConfigurationService(configurationService);
    objectService.setModelService(modelService);
    objectService.setCommonsService(commonsService);

    federationExecutionID =
        commonsService.createFederationExecutionID(
            UUID.randomUUID().toString(), UUID.randomUUID().toString());

    try {
      objectOwnershipID =
          commonsService.createObjectOwnershipID(
              UUID.randomUUID().toString(), federationExecutionID);
    } catch (MuthurException e1) {
      fail(e1.getLocalizedMessage());
    }

    assertTrue(objectOwnershipID != null);

    objectService.createFederationDataObjectContainer(federationExecutionID);
  }
  public void testGetAircraftObjectGraphWhenAircraftNotExists() {

    Set<IBaseDataObject> aircraftObjectGraph = null;

    try {
      aircraftObjectGraph =
          objectService.getAircraftObjectGraph(federationExecutionID, aircraft.getDataObjectUUID());
    } catch (MuthurException e) {
      fail(e.getLocalizedMessage());
    }

    assertTrue(aircraftObjectGraph != null);
    int size = aircraftObjectGraph.size();
    assertTrue(size == 0);
  }
  public void testUpdateAircraftDepartureObject() {

    aircraftDeparture.setActualDepartureTimeMSecs(System.currentTimeMillis());
    aircraftDeparture.setDepartureAirportCode(newDepartureAirportCode);
    aircraftDeparture.setDepartureRunway(newDepartureRunwayName);

    // add the aircraft departure

    try {
      objectService.updateObject(federationExecutionID, aircraftDeparture);
    } catch (MuthurException e) {
      fail(e.getLocalizedMessage());
    }

    assertObjectExists(aircraftDeparture);
  }
  public void testAddAircraftObject() {

    aircraft = null;

    try {
      aircraft = new Aircraft(tailNumber, callSign);
    } catch (MuthurException e) {
      fail(e.getLocalizedMessage());
    }

    try {
      objectService.addDataObject(federationExecutionID, aircraft);
    } catch (MuthurException e) {
      fail(e.getLocalizedMessage());
    }
  }
  public void testAddAirportObject() {

    airportConfiguration = null;

    try {
      airportConfiguration = new AirportConfiguration(airportCode);
    } catch (MuthurException e) {
      fail(e.getLocalizedMessage());
    }

    try {
      objectService.addDataObject(federationExecutionID, airportConfiguration);
    } catch (MuthurException e) {
      fail(e.getLocalizedMessage());
    }
  }
  public void testUpateFlightPositionObject() {

    // set the attributes to be updated
    //
    flightPosition.setLatitudeDegrees(newLatitudeDegrees);
    flightPosition.setLongitudeDegrees(newLongitudeDegrees);
    flightPosition.setAltitudeFt(newAltitudeFeet);

    try {
      objectService.updateObject(federationExecutionID, flightPosition);
    } catch (MuthurException e) {
      fail(e.getLocalizedMessage());
    }

    // will retrieve the updated object from the object service and compare
    // it
    // to the object which should accurately test whether the update was
    // applied

    assertObjectExists(flightPosition);
  }
  public void testAddFlightPlanObject() {

    // create a flight plan

    flightPlan = null;

    try {
      flightPlan = new FlightPlan(tailNumber, callSign);
    } catch (MuthurException e) {
      fail(e.getLocalizedMessage());
    }

    flightPlan.setSource(source);
    flightPlan.setAircraftType(aircraftType);
    flightPlan.setPlannedDepartureTimeMSecs(System.currentTimeMillis());
    flightPlan.setPlannedArrivalTimeMSecs(System.currentTimeMillis() + 30000);
    flightPlan.setCruiseSpeedKts(cruiseSpeedKts);
    flightPlan.setCruiseAltitudeFt(cruiseAltitudeFeet);
    flightPlan.setRoutePlan(route);
    flightPlan.setDepartureCenter(departureCenter);
    flightPlan.setArrivalCenter(arrivalCenter);
    flightPlan.setDepartureFix(departureFix);
    flightPlan.setArrivalFix(arrivalFix);
    flightPlan.setPhysicalAircraftClass(physicalClass);
    flightPlan.setWeightAircraftClass(weightClass);
    flightPlan.setUserAircraftClass(userClass);
    flightPlan.setNumOfAircraft(1);
    flightPlan.setAirborneEquipmentQualifier(airborneEquipmentQualifier);

    // add the flight plan

    try {
      objectService.addDataObject(federationExecutionID, flightPlan);
    } catch (MuthurException e) {
      fail(e.getLocalizedMessage());
    }

    assertObjectExists(flightPlan);
  }
  public void testUpateAircraftArrivalObjectAttributes() {

    // set the attributes to be updated
    //
    AircraftArrival newAircraftArrival = new AircraftArrival();

    // NOTE: Used only since the unit testing is conducted in the VM.
    // Changing
    // this emulates what would happen if the objects were residing on
    // separate
    // machines and thus address spaces.

    newAircraftArrival.setDataObjectUUID(aircraftArrival.getDataObjectUUID());

    newAircraftArrival.setCallSign(callSign);
    newAircraftArrival.setTailNumber(tailNumber);

    newAircraftArrival.setActualArrivalTimeMSecs(System.currentTimeMillis());
    newAircraftArrival.setArrivalRunway(arrivalRunwayName);
    newAircraftArrival.setArrivalAirportCode(arrivalAirportCode);

    Set<String> fieldsToUpdate = new HashSet<String>();
    fieldsToUpdate.add(EventAttributeName.arrivalRunway.toString());
    fieldsToUpdate.add(EventAttributeName.arrivalAirportCode.toString());

    try {
      objectService.updateObjectAttributes(
          federationExecutionID, newAircraftArrival, fieldsToUpdate);
    } catch (MuthurException e) {
      fail(e.getLocalizedMessage());
    }

    // will retrieve the updated object from the object service and compare
    // it
    // to the object which should accurately test whether the update was
    // applied

    assertObjectExists(aircraftArrival);
  }
  public void testUpateFlightPlanObject() {

    // set the attributes to be updated
    //
    flightPlan.setPlannedDepartureTimeMSecs(System.currentTimeMillis());
    flightPlan.setPlannedArrivalTimeMSecs(System.currentTimeMillis() + 30000);
    flightPlan.setCruiseSpeedKts(newCruiseSpeedKts);
    flightPlan.setCruiseAltitudeFt(newCruiseAltitudeFeet);

    try {
      objectService.updateObject(federationExecutionID, flightPlan);
    } catch (MuthurException e) {
      fail(e.getLocalizedMessage());
    }

    // will retrieve the updated object from the object service and compare
    // it
    // to the object which should accurately test whether the update was
    // applied

    assertObjectExists(flightPlan);
  }
  public void testAddAircraftTaxiOutObject() {

    aircraftTaxiOut = null;

    try {
      aircraftTaxiOut = new AircraftTaxiOut(tailNumber, callSign);
    } catch (MuthurException e) {
      fail(e.getLocalizedMessage());
    }

    aircraftTaxiOut.setTaxiOutTimeMSecs(System.currentTimeMillis());
    aircraftTaxiOut.setTaxiOutGate(taxiOutGate);

    // add the aircraft taxi in

    try {
      objectService.addDataObject(federationExecutionID, aircraftTaxiOut);
    } catch (MuthurException e) {
      fail(e.getLocalizedMessage());
    }

    assertObjectExists(aircraftTaxiOut);
  }
  public void testAddFlightPositionObject() {

    flightPosition = null;

    try {
      flightPosition = new FlightPosition(tailNumber, callSign);
    } catch (MuthurException e) {
      fail(e.getLocalizedMessage());
    }

    flightPosition.setLatitudeDegrees(latitudeDegrees);
    flightPosition.setLongitudeDegrees(longitudeDegrees);
    flightPosition.setAltitudeFt(altitudeFeet);
    flightPosition.setGroundspeedKts(groundSpeedKts);
    flightPosition.setHeadingDegrees(headingDegrees);
    flightPosition.setAirspeedKts(airSpeedKts);
    flightPosition.setPitchDegrees(pitchDegrees);
    flightPosition.setRollDegrees(rollDegrees);
    flightPosition.setYawDegrees(yawDegrees);
    flightPosition.setSector(sectorName);
    flightPosition.setCenter(centerName);
    flightPosition.setVerticalspeedKts(verticalspeedKts);
    flightPosition.setAircraftOnGround(true);
    flightPosition.setAircraftTransmissionFrequency(aircraftTransmissionFrequency);
    flightPosition.setSquawkCode(squawkCode);
    flightPosition.setIdent(true);

    // add the flight position

    try {
      objectService.addDataObject(federationExecutionID, flightPosition);
    } catch (MuthurException e) {
      fail(e.getLocalizedMessage());
    }

    assertObjectExists(flightPosition);
  }
  public void testAddAircraftDepartureObject() {

    aircraftDeparture = null;

    try {
      aircraftDeparture = new AircraftDeparture(tailNumber, callSign);
    } catch (MuthurException e) {
      fail(e.getLocalizedMessage());
    }

    aircraftDeparture.setActualDepartureTimeMSecs(System.currentTimeMillis());
    aircraftDeparture.setDepartureAirportCode(departureAirportCode);
    aircraftDeparture.setDepartureRunway(departureRunwayName);

    // add the aircraft departure

    try {
      objectService.addDataObject(federationExecutionID, aircraftDeparture);
    } catch (MuthurException e) {
      fail(e.getLocalizedMessage());
    }

    assertObjectExists(aircraftDeparture);
  }
  public void testAddAircraftArrivalObject() {

    aircraftArrival = null;

    try {
      aircraftArrival = new AircraftArrival(tailNumber, callSign);
    } catch (MuthurException e) {
      fail(e.getLocalizedMessage());
    }

    aircraftArrival.setActualArrivalTimeMSecs(System.currentTimeMillis());
    aircraftArrival.setArrivalAirportCode(arrivalAirportCode);
    aircraftArrival.setArrivalRunway(arrivalRunwayName);

    // add the aircraft arrival

    try {
      objectService.addDataObject(federationExecutionID, aircraftArrival);
    } catch (MuthurException e) {
      fail(e.getLocalizedMessage());
    }

    assertObjectExists(aircraftArrival);
  }
  @Test
  public void testCreateOrUpdateObjectRequestWithFlightPositionObject() {

    FlightPosition flightPosition = null;

    try {
      flightPosition = new FlightPosition(tailNumber, acid);
    } catch (Exception e) {
      fail(e.getLocalizedMessage());
    }

    assertNotNull(flightPosition);

    assertEquals(flightPosition.getCallSign(), acid);
    assertEquals(flightPosition.getTailNumber(), tailNumber);
    assertNotNull(flightPosition.getDataObjectUUID());
    assertFalse(flightPosition.getDataObjectUUID().equalsIgnoreCase(""));
    assertTrue(flightPosition.getObjectCreateTimeMSecs() != 0L);

    // position data

    flightPosition.setLatitudeDegrees(42.65);
    flightPosition.setLongitudeDegrees(-76.72);
    flightPosition.setAltitudeFt(30000);
    flightPosition.setGroundspeedKts(400);
    flightPosition.setHeadingDegrees(90);
    flightPosition.setAirspeedKts(444);
    flightPosition.setPitchDegrees(0.5);
    flightPosition.setRollDegrees(0);
    flightPosition.setYawDegrees(0);
    flightPosition.setSector("ZOB48");
    flightPosition.setCenter("ZOB");

    flightPosition.setVerticalspeedKts(verticalspeedKts);
    flightPosition.setAircraftOnGround(aircraftOnGround);
    flightPosition.setAircraftTransmissionFrequency(aircraftTransmissionFrequency);
    flightPosition.setSquawkCode(squawkCode);
    flightPosition.setIdent(ident);

    // create a CreateOrUpdateObjectRequest

    CreateOrUpdateObjectRequest cor = new CreateOrUpdateObjectRequest();
    assertNotNull(cor);

    cor.setFederationExecutionHandle(UUID.randomUUID().toString());
    cor.setFederateRegistrationHandle(UUID.randomUUID().toString());
    cor.setFederationExecutionModelHandle(UUID.randomUUID().toString());
    cor.setSourceOfEvent("NexSim");
    cor.setDataObject(flightPosition);

    // serialize the object

    String corAsXML = cor.serialize();

    // do standard validation

    assertNotNull(corAsXML);
    assertFalse(corAsXML.equals(""));

    // create another object from previous object's serialized form

    CreateOrUpdateObjectRequest objectFromXML = new CreateOrUpdateObjectRequest();

    try {
      objectFromXML.initialization(corAsXML);
    } catch (MuthurException e) {
      fail(e.getLocalizedMessage());
    }

    // ensure that the two objects are equal

    assertTrue(objectFromXML.equals(cor));

    // get the serialized version of the new object

    String newObjSerializedAsXML = objectFromXML.serialize();

    assertNotNull(newObjSerializedAsXML);
    assertFalse(newObjSerializedAsXML.equals(""));

    IBaseDataObject bdo = objectFromXML.getDataObject();

    assertNotNull(bdo);
    assertTrue(bdo instanceof FlightPosition);

    /** Initialize the internal data object from the serialized containing object */
    try {
      bdo.initialization(newObjSerializedAsXML);
    } catch (MuthurException e) {
      fail(e.getLocalizedMessage());
    }

    // check the serialized form of the data object
    String bdoSerialized = bdo.serialize();
    assertNotNull(bdoSerialized);
  }
  public void testUpateFlightPositionObjectAttributes() {

    // set the attributes to be updated
    //
    FlightPosition newFlightPosition = new FlightPosition();

    // NOTE: Used only since the unit testing is conducted in the VM.
    // Changing
    // this emulates what would happen if the objects were residing on
    // separate
    // machines and thus address spaces.

    newFlightPosition.setDataObjectUUID(flightPosition.getDataObjectUUID());

    newFlightPosition.setLatitudeDegrees(latitudeDegrees);
    newFlightPosition.setLongitudeDegrees(longitudeDegrees);
    newFlightPosition.setAltitudeFt(altitudeFeet);
    newFlightPosition.setGroundspeedKts(groundSpeedKts);
    newFlightPosition.setHeadingDegrees(headingDegrees);
    newFlightPosition.setAirspeedKts(airSpeedKts);
    newFlightPosition.setPitchDegrees(pitchDegrees);
    newFlightPosition.setRollDegrees(rollDegrees);
    newFlightPosition.setYawDegrees(yawDegrees);
    newFlightPosition.setSector(sectorName);
    newFlightPosition.setCenter(centerName);
    newFlightPosition.setVerticalspeedKts(verticalspeedKts);
    newFlightPosition.setAircraftOnGround(true);
    newFlightPosition.setAircraftTransmissionFrequency(aircraftTransmissionFrequency);
    newFlightPosition.setSquawkCode(squawkCode);
    newFlightPosition.setIdent(true);

    Set<String> fieldsToUpdate = new HashSet<String>();
    fieldsToUpdate.add(EventAttributeName.longitudeDegrees.toString());
    fieldsToUpdate.add(EventAttributeName.latitudeDegrees.toString());
    fieldsToUpdate.add(EventAttributeName.altitudeFt.toString());
    fieldsToUpdate.add(EventAttributeName.groundspeedKts.toString());
    fieldsToUpdate.add(EventAttributeName.headingDegrees.toString());
    fieldsToUpdate.add(EventAttributeName.airspeedKts.toString());
    fieldsToUpdate.add(EventAttributeName.pitchDegrees.toString());
    fieldsToUpdate.add(EventAttributeName.rollDegrees.toString());
    fieldsToUpdate.add(EventAttributeName.yawDegrees.toString());
    fieldsToUpdate.add(EventAttributeName.sector.toString());
    fieldsToUpdate.add(EventAttributeName.center.toString());
    fieldsToUpdate.add(EventAttributeName.verticalspeedKts.toString());
    fieldsToUpdate.add(EventAttributeName.aircraftOnGround.toString());
    fieldsToUpdate.add(EventAttributeName.aircraftTransmissionFrequency.toString());
    fieldsToUpdate.add(EventAttributeName.squawkCode.toString());
    fieldsToUpdate.add(EventAttributeName.ident.toString());

    try {
      objectService.updateObjectAttributes(
          federationExecutionID, newFlightPosition, fieldsToUpdate);
    } catch (MuthurException e) {
      fail(e.getLocalizedMessage());
    }

    // will retrieve the updated object from the object service and compare
    // it
    // to the object which should accurately test whether the update was
    // applied

    assertObjectExists(flightPosition);
  }
  @Test
  public void testCreateOrUpdateObjectRequestWithFlightPlanObject() {

    FlightPlan flightPlan = null;

    try {
      flightPlan = new FlightPlan(tailNumber, acid);
    } catch (MuthurException e) {
      fail(e.getLocalizedMessage());
    }

    assertNotNull(flightPlan);

    assertEquals(flightPlan.getCallSign(), acid);
    assertEquals(flightPlan.getTailNumber(), tailNumber);
    assertNotNull(flightPlan.getDataObjectUUID());
    assertFalse(flightPlan.getDataObjectUUID().equalsIgnoreCase(""));
    assertTrue(flightPlan.getObjectCreateTimeMSecs() != 0L);

    // flight plan data

    flightPlan.setSource("Flight");
    flightPlan.setAircraftType("B771");
    flightPlan.setPlannedDepartureTimeMSecs(System.currentTimeMillis() + 10);
    flightPlan.setPlannedDepartureRunway("1R");
    flightPlan.setPlannedTaxiOutGate("D31");
    flightPlan.setDepartureFix("DEFIX");
    flightPlan.setDepartureCenter("ZID");

    flightPlan.setPlannedArrivalTimeMSecs(System.currentTimeMillis() + 20);
    flightPlan.setPlannedArrivalRunway("8L");
    flightPlan.setPlannedTaxiInGate("C11");
    flightPlan.setArrivalCenter("ZBW");
    flightPlan.setArrivalFix("ARFIX");

    flightPlan.setCruiseSpeedKts(400);
    flightPlan.setCruiseAltitudeFt(330);
    flightPlan.setRoutePlan("IND..ROD.J29.PLB.J595.BGR..BGR");
    flightPlan.setPhysicalAircraftClass("J");
    flightPlan.setWeightAircraftClass("H");
    flightPlan.setUserAircraftClass("C");
    flightPlan.setNumOfAircraft(1);
    flightPlan.setAirborneEquipmentQualifier("R");
    flightPlan.setFlightPlanStatus(FlightPlanStatus.CANCELLED);

    // create a CreateOrUpdateObjectRequest

    CreateOrUpdateObjectRequest cor = new CreateOrUpdateObjectRequest();
    assertNotNull(cor);

    cor.setFederationExecutionHandle(UUID.randomUUID().toString());
    cor.setFederateRegistrationHandle(UUID.randomUUID().toString());
    cor.setFederationExecutionModelHandle(UUID.randomUUID().toString());
    cor.setSourceOfEvent("NexSim");
    cor.setDataObject(flightPlan);

    // serialize the object

    String corAsXML = cor.serialize();

    writeToFile(cor, false);

    // do standard validation

    assertNotNull(corAsXML);
    assertFalse(corAsXML.equals(""));

    // create another object from previous object's serialized form

    CreateOrUpdateObjectRequest objectFromXML = new CreateOrUpdateObjectRequest();

    try {
      objectFromXML.initialization(corAsXML);
    } catch (MuthurException e) {
      fail(e.getLocalizedMessage());
    }

    // ensure that the two objects are equal

    assertTrue(objectFromXML.equals(cor));

    // get the serialized version of the new object

    String newObjSerializedAsXML = objectFromXML.serialize();

    assertNotNull(newObjSerializedAsXML);
    assertFalse(newObjSerializedAsXML.equals(""));

    IBaseDataObject bdo = objectFromXML.getDataObject();

    assertNotNull(bdo);
    assertTrue(bdo instanceof FlightPlan);

    /** Initialize the internal data object from the serialized containing object */
    try {
      bdo.initialization(newObjSerializedAsXML);
    } catch (MuthurException e) {
      fail(e.getLocalizedMessage());
    }

    // check the serialized form of the data object
    String bdoSerialized = bdo.serialize();
    assertNotNull(bdoSerialized);
  }
  public void testUpateFlightPlanObjectAttributes() {

    // set the attributes to be updated
    //
    FlightPlan newFlightPlan = new FlightPlan();

    // NOTE: Used only since the unit testing is conducted in the VM.
    // Changing
    // this emulates what would happen if the objects were residing on
    // separate
    // machines and thus address spaces.

    newFlightPlan.setDataObjectUUID(flightPlan.getDataObjectUUID());

    newFlightPlan.setSource(source);
    newFlightPlan.setAircraftType(aircraftType);
    newFlightPlan.setCruiseSpeedKts(cruiseSpeedKts);
    newFlightPlan.setCruiseAltitudeFt(cruiseAltitudeFeet);
    newFlightPlan.setRoutePlan(route);
    newFlightPlan.setPlannedDepartureTimeMSecs(System.currentTimeMillis());
    newFlightPlan.setDepartureCenter(departureCenter);
    newFlightPlan.setDepartureFix(departureFix);
    newFlightPlan.setPlannedArrivalTimeMSecs(System.currentTimeMillis());
    newFlightPlan.setArrivalCenter(arrivalCenter);
    newFlightPlan.setArrivalFix(arrivalFix);
    newFlightPlan.setPhysicalAircraftClass(physicalClass);
    newFlightPlan.setWeightAircraftClass(weightClass);
    newFlightPlan.setUserAircraftClass(userClass);
    newFlightPlan.setNumOfAircraft(1);
    newFlightPlan.setAirborneEquipmentQualifier(airborneEquipmentQualifier);

    Set<String> fieldsToUpdate = new HashSet<String>();
    fieldsToUpdate.add(EventAttributeName.source.toString());
    fieldsToUpdate.add(EventAttributeName.aircraftType.toString());
    fieldsToUpdate.add(EventAttributeName.cruiseSpeedKts.toString());
    fieldsToUpdate.add(EventAttributeName.cruiseAltitudeFt.toString());
    fieldsToUpdate.add(EventAttributeName.routePlan.toString());
    fieldsToUpdate.add(EventAttributeName.plannedDepartureTimeMSecs.toString());
    fieldsToUpdate.add(EventAttributeName.departureCenter.toString());
    fieldsToUpdate.add(EventAttributeName.departureFix.toString());
    fieldsToUpdate.add(EventAttributeName.plannedArrivalTimeMSecs.toString());
    fieldsToUpdate.add(EventAttributeName.arrivalCenter.toString());
    fieldsToUpdate.add(EventAttributeName.arrivalFix.toString());
    fieldsToUpdate.add(EventAttributeName.physicalAircraftClass.toString());
    fieldsToUpdate.add(EventAttributeName.weightAircraftClass.toString());
    fieldsToUpdate.add(EventAttributeName.userAircraftClass.toString());
    fieldsToUpdate.add(EventAttributeName.numOfAircraft.toString());
    fieldsToUpdate.add(EventAttributeName.airborneEquipmentQualifier.toString());

    try {
      objectService.updateObjectAttributes(federationExecutionID, newFlightPlan, fieldsToUpdate);
    } catch (MuthurException e) {
      fail(e.getLocalizedMessage());
    }

    // will retrieve the updated object from the object service and compare
    // it
    // to the object which should accurately test whether the update was
    // applied

    assertObjectExists(flightPlan);
  }
  @Test
  public void testCreateOrUpdateObjectRequestWithAircraftTaxOutObject() {

    AircraftTaxiOut atod = null;

    try {
      atod = new AircraftTaxiOut(tailNumber, acid);
    } catch (Exception e) {
      fail(e.getLocalizedMessage());
    }

    assertNotNull(atod);

    assertEquals(atod.getCallSign(), acid);
    assertEquals(atod.getTailNumber(), tailNumber);
    assertNotNull(atod.getDataObjectUUID());
    assertFalse(atod.getDataObjectUUID().equalsIgnoreCase(""));
    assertTrue(atod.getObjectCreateTimeMSecs() != 0L);

    // gate taxiing from

    atod.setTaxiOutGate("C17");

    // taxi out data

    atod.setTaxiOutTimeMSecs(System.currentTimeMillis() + 30);

    // create a CreateOrUpdateObjectRequest

    CreateOrUpdateObjectRequest cor = new CreateOrUpdateObjectRequest();
    assertNotNull(cor);

    cor.setFederationExecutionHandle(UUID.randomUUID().toString());
    cor.setFederateRegistrationHandle(UUID.randomUUID().toString());
    cor.setFederationExecutionModelHandle(UUID.randomUUID().toString());
    cor.setSourceOfEvent("NexSim");
    cor.setDataObject(atod);

    // serialize the object

    String corAsXML = cor.serialize();

    // do standard validation

    assertNotNull(corAsXML);
    assertFalse(corAsXML.equals(""));

    // create another object from previous object's serialized form

    CreateOrUpdateObjectRequest objectFromXML = new CreateOrUpdateObjectRequest();

    try {
      objectFromXML.initialization(corAsXML);
    } catch (MuthurException e) {
      fail(e.getLocalizedMessage());
    }

    // ensure that the two objects are equal

    assertTrue(objectFromXML.equals(cor));

    // get the serialized version of the new object

    String newObjSerializedAsXML = objectFromXML.serialize();

    assertNotNull(newObjSerializedAsXML);
    assertFalse(newObjSerializedAsXML.equals(""));

    IBaseDataObject bdo = objectFromXML.getDataObject();

    assertNotNull(bdo);
    assertTrue(bdo instanceof AircraftTaxiOut);

    /** Initialize the internal data object from the serialized containing object */
    try {
      bdo.initialization(newObjSerializedAsXML);
    } catch (MuthurException e) {
      fail(e.getLocalizedMessage());
    }

    // check the serialized form of the data object
    String bdoSerialized = bdo.serialize();
    assertNotNull(bdoSerialized);
  }
  @Override
  public void run() {

    try {

      setServerSocket(new ServerSocket(portNumber));

    } catch (IOException e) {
      LOG.error(
          "Error starting FederationDataChannelServerImpl. ["
              + e.getLocalizedMessage()
              + "] on port ["
              + portNumber
              + "]");
      return;
    }

    LOG.info("FederationDataChannelServerImpl is listening on port [" + portNumber + "]");

    try {

      while (isListening()) {

        Socket s = serverSocket.accept();

        socketList.add(s);

        FederationDataChannelImpl fdc =
            new FederationDataChannelImpl(s, dataChannelListenerFactory.createListener());

        dataChannelPool.execute(fdc);
      }

    } catch (MuthurException e) {
      LOG.error("Error creating FederationDataChannel [" + e.getLocalizedMessage() + "]");
    } catch (IOException e) {
      LOG.debug("IO exception on federation server socket [" + e.getLocalizedMessage() + "]");
    }

    LOG.info("FederationDataChannelServerImpl listening on port [" + portNumber + "] is exiting");

    if ((socketList != null) && (socketList.size() > 0)) {

      for (Socket thisSocket : socketList) {

        if (thisSocket != null) {
          try {
            LOG.debug(
                "Closing data channel to host ["
                    + thisSocket.getInetAddress()
                    + "] at port ["
                    + thisSocket.getPort()
                    + "]");
            thisSocket.close();
            LOG.info(
                "Closed data channel to host ["
                    + thisSocket.getInetAddress()
                    + "] at port ["
                    + thisSocket.getPort()
                    + "]");
          } catch (IOException e) {
            LOG.warn(
                "IO Exception closing data channel to host ["
                    + thisSocket.getInetAddress()
                    + "] at port ["
                    + thisSocket.getPort()
                    + "]");
          }
        }
      }
    }

    /*
     * Shut down the data channel listener thread pool
     */
    if (dataChannelPool != null) {

      if (!dataChannelPool.isShutdown()) {
        shutdownAndAwaitTermination(dataChannelPool);
      }
    }
  }