@Test
  public void testHandlesReferencingOtherLocations() throws Exception {
    MyLocation origLoc = new MyLocation();
    MyEntityReffingOthers origE =
        origApp.createAndManageChild(
            EntitySpec.create(MyEntityReffingOthers.class).configure("locationRef", origLoc));
    origE.setAttribute(MyEntityReffingOthers.LOCATION_REF_SENSOR, origLoc);
    origApp.start(ImmutableList.of(origLoc));

    newApp = rebind();
    MyEntityReffingOthers newE =
        (MyEntityReffingOthers)
            Iterables.find(
                newApp.getChildren(), Predicates.instanceOf(MyEntityReffingOthers.class));
    MyLocation newLoc = (MyLocation) Iterables.getOnlyElement(newApp.getLocations());

    assertAttributeEquals(newE, MyEntityReffingOthers.LOCATION_REF_SENSOR, newLoc);
    assertConfigEquals(newE, MyEntityReffingOthers.LOCATION_REF_CONFIG, newLoc);
  }
  @Test
  public void testHandlesReferencingOtherEntities() throws Exception {
    MyEntity origOtherE = origApp.createAndManageChild(EntitySpec.create(MyEntity.class));
    MyEntityReffingOthers origE =
        origApp.createAndManageChild(
            EntitySpec.create(MyEntityReffingOthers.class).configure("entityRef", origOtherE));
    origE.setAttribute(MyEntityReffingOthers.ENTITY_REF_SENSOR, origOtherE);

    newApp = rebind();
    MyEntityReffingOthers newE =
        (MyEntityReffingOthers)
            Iterables.find(
                newApp.getChildren(), Predicates.instanceOf(MyEntityReffingOthers.class));
    MyEntity newOtherE =
        (MyEntity) Iterables.find(newApp.getChildren(), Predicates.instanceOf(MyEntity.class));

    assertAttributeEquals(newE, MyEntityReffingOthers.ENTITY_REF_SENSOR, newOtherE);
    assertConfigEquals(newE, MyEntityReffingOthers.ENTITY_REF_CONFIG, newOtherE);
  }