@Test
  public void containmentRootReplacer() {
    final Command command =
        new RecordingCommand(ResourceAccess.getTransactionalEditingDomain()) {
          @Override
          protected void doExecute() {
            try {
              final Resource resource = ResourceAccess.getResourceOfFirstSchool();
              final EList<EObject> toplevel = resource.getContents();

              assertEquals(1, toplevel.size());
              assertEquals(2, countYears());
              final EObject root = toplevel.get(0);
              assertTrue(root instanceof School);
              School school = ((School) root);

              toplevel.clear();
              assertEquals(0, toplevel.size());
              assertEquals(0, countYears());

              final Year tempRootYear = SchoolFactory.eINSTANCE.createYear();
              tempRootYear.setStartingDate(YEAR_DATE);
              final SchoolClass fakeSchoolClass = SchoolFactory.eINSTANCE.createSchoolClass();
              fakeSchoolClass.setCode(CLASS_CODE);
              tempRootYear.getSchoolClasses().add(fakeSchoolClass);
              toplevel.add(tempRootYear);
              assertEquals(1, toplevel.size());
              assertEquals(1, countYears());

              toplevel.add(school);
              assertEquals(2, toplevel.size());
              assertEquals(3, countYears());

              registerListener();
              try {
                school.getYears().add(tempRootYear);
                assertEquals(1, toplevel.size());
                assertEquals(3, countYears());
              } finally {
                unregisterListener();
              }

            } catch (RuntimeException ex) {
              Assert.fail("Exception: " + ex.getMessage());
              throw ex;
            }
          }
        };
    try {
      ResourceAccess.getTransactionalEditingDomain().getCommandStack().execute(command);
    } finally {
      ResourceAccess.getTransactionalEditingDomain().getCommandStack().undo();
    }
  }
 /** @param notifier */
 public ContainmentManglingTest() {
   super(ResourceAccess.getResourceOfFirstSchool(), true, false);
 }