public class JNDIReferenceTest extends OgmTestCase {
@Test
public void testGetReferenceImplementation() throws Exception {
final Session session = openSession();
SessionFactory factory = session.getSessionFactory();
assertThat( factory.getClass() ).isEqualTo( OgmSessionFactoryImpl.class );
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() );
session.close();
}