public void setUp() throws Exception {
    Configuration conf =
        new Configuration()
            .configure("/org/compass/gps/device/hibernate/cascade/one/hibernate.cfg.xml")
            .setProperty(Environment.HBM2DDL_AUTO, "create");
    sessionFactory = conf.buildSessionFactory();

    // set the session factory for the Hibernate transcation factory BEFORE we construct the compass
    // instnace
    HibernateSyncTransactionFactory.setSessionFactory(sessionFactory);

    final ObjectContext theObjectContext = ObjectContextFactory.create();

    theObjectContext.add(Foundations.class);
    theObjectContext.add(House.class);
    theObjectContext.add(Roof.class);

    //        CompassConfiguration cpConf = new CompassConfiguration()
    //                .configure(getCompassConfigLocation());
    //        cpConf.getSettings().setBooleanSetting(CompassEnvironment.DEBUG, true);
    compass =
        ElasticSearchTests.mockSimpleCompass(
            "10.10.10.101", theObjectContext); // cpConf.buildCompass();

    fileHandlerMonitor = FileHandlerMonitor.getFileHandlerMonitor(compass);
    fileHandlerMonitor.verifyNoHandlers();

    ElasticSearchTests.deleteAllIndexes(compass);
    ElasticSearchTests.verifyAllIndexes(compass);

    //        HibernateEntityLifecycleInjector lifecycleInjector = new
    // org.compass.gps.device.hibernate.lifecycle.DefaultHibernateEntityCollectionLifecycleInjector(true);

    HibernateGpsDevice compassGpsDevice = new HibernateGpsDevice();
    compassGpsDevice.setName("hibernate");
    compassGpsDevice.setSessionFactory(sessionFactory);
    compassGpsDevice.setFetchCount(5000);
    //        compassGpsDevice.setLifecycleInjector(lifecycleInjector);

    SingleCompassGps compassGps = new SingleCompassGps();
    compassGps.setCompass(compass);
    compassGps.setGpsDevices(new CompassGpsDevice[] {compassGpsDevice});

    compassGps.start();

    SessionFactoryImpl sessionFactoryImpl = (SessionFactoryImpl) sessionFactory;

    EventListenerRegistry theRegistry = null; // (AGR_OSEM) Hib4

    EventListenerGroup<PostInsertEventListener> theGroup =
        theRegistry.getEventListenerGroup(EventType.POST_INSERT);

    for (PostInsertEventListener listener : theGroup.listeners()) {
      if (listener instanceof HibernateEventListener) {
        hibernateEventListener = (HibernateEventListener) listener;
        break;
      }
    }
  }
 @BeforeMethod()
 public void doStart() {
   context = ObjectContextFactory.create();
   // Starting node
   ImmutableSettings.Builder settings = NodeBuilder.nodeBuilder().settings();
   settings.put("gateway.type", "none");
   settings.put("path.data", "build/tmp/data");
   // Manual refresh
   settings.put("index.refreshInterval", "-1");
   node = NodeBuilder.nodeBuilder().settings(settings).build();
   node.start();
 }