@Test
  public void testJNDIReference() throws Exception {
    final EntityManagerFactory emf =
        Persistence.createEntityManagerFactory("ogm", TestHelper.getEnvironmentProperties());
    SessionFactory factory = ((HibernateEntityManagerFactory) emf).getSessionFactory();
    Reference reference = factory.getReference();
    assertThat(reference.getClassName()).isEqualTo(OgmSessionFactoryImpl.class.getName());
    assertThat(reference.getFactoryClassName())
        .isEqualTo(OgmSessionFactoryObjectFactory.class.getName());
    assertThat(reference.get(0)).isNotNull();
    assertThat(reference.getFactoryClassLocation()).isNull();

    OgmSessionFactoryObjectFactory objFactory = new OgmSessionFactoryObjectFactory();
    SessionFactory factoryFromRegistry =
        (SessionFactory) objFactory.getObjectInstance(reference, null, null, null);
    assertThat(factoryFromRegistry.getClass()).isEqualTo(OgmSessionFactoryImpl.class);
    assertThat(factoryFromRegistry.getReference()).isEqualTo(factory.getReference());

    emf.close();
  }
  @Test
  public void testJNDIReference() throws Exception {
    buildArchive();

    final EntityManagerFactory emf = Persistence.createEntityManagerFactory("jpajtastandalone");
    SessionFactory factory = ((HibernateEntityManagerFactory) emf).getSessionFactory();
    Reference reference = factory.getReference();
    assertThat(reference.getClassName()).isEqualTo(OgmSessionFactory.class.getName());
    assertThat(reference.getFactoryClassName())
        .isEqualTo(OgmSessionFactoryObjectFactory.class.getName());
    assertThat(reference.get(0)).isNotNull();
    assertThat(reference.getFactoryClassLocation()).isNull();

    OgmSessionFactoryObjectFactory objFactory = new OgmSessionFactoryObjectFactory();
    SessionFactory factoryFromRegistry =
        (SessionFactory) objFactory.getObjectInstance(reference, null, null, null);
    assertThat(factoryFromRegistry.getClass()).isEqualTo(OgmSessionFactory.class);
    assertThat(factoryFromRegistry.getReference()).isEqualTo(factory.getReference());

    emf.close();
  }