/**
   * Remove from DB the PhyisicalMachines from initPhysical implementation (actually remove
   * DataCenter @see dataCenter, for cascading delete physical machines disapear) Clean from DB the
   * scheduler test virtual datacenter, virtual application, icon and virtual images.
   *
   * @throws PersistenceException
   */
  public void clearCreatedDomainObjects() throws PersistenceException {
    if (dc == null) {
      return;
    }

    factorytest = HibernateDAOFactory.instance();
    DataCenterDAO daoDc = factorytest.getDataCenterDAO();
    VirtualDataCenterDAO daoVdc = factorytest.getVirtualDataCenterDAO();
    IconDAO daoIco = factorytest.getIconDAO();
    VirtualImageDAO daoVi = factorytest.getVirtualImageDAO();

    factorytest.beginConnection();

    log.debug("Cleaning all the created objects ");

    daoDc.makeTransient(dc);
    daoVdc.makeTransient(vdc);

    daoIco.makeTransient(icon);

    // TODO: create the speciphic method by description??
    // Criterion descriptionTest = Restrictions.eq("description", "test");
    // for (VirtualimageHB vi : daoVi.findByCriteria(descriptionTest))
    // {
    // HibernateUtil.getSession().delete(vi); // XXX use DAO
    // }

    factorytest.endConnection();
  }
  private IconHB createIcon() throws PersistenceException {
    factorytest = HibernateDAOFactory.instance();
    IconDAO daoIcon = factorytest.getIconDAO();

    factorytest.beginConnection();

    IconHB icon = new IconHB();
    icon.setName("test");
    icon.setPath("test");
    daoIcon.makePersistent(icon);

    factorytest.endConnection();

    return icon;
  }