use of org.jboss.tools.hibernate.runtime.spi.ISession in project jbosstools-hibernate by jbosstools.
the class SessionFactoryFacadeTest method testOpenSession.
@Test
public void testOpenSession() {
Configuration configuration = new Configuration();
SessionFactory sessionFactory = configuration.buildSessionFactory(new StandardServiceRegistryBuilder().build());
ISessionFactory sessionFactoryFacade = FACADE_FACTORY.createSessionFactory(sessionFactory);
ISession sessionFacade = sessionFactoryFacade.openSession();
Session session = (Session) ((IFacade) sessionFacade).getTarget();
Assert.assertSame(sessionFactory, session.getSessionFactory());
}
use of org.jboss.tools.hibernate.runtime.spi.ISession in project jbosstools-hibernate by jbosstools.
the class SessionFactoryFacadeTest method testOpenSession.
@Test
public void testOpenSession() {
Configuration configuration = new Configuration();
SessionFactory sessionFactory = configuration.buildSessionFactory(new StandardServiceRegistryBuilder().build());
ISessionFactory sessionFactoryFacade = FACADE_FACTORY.createSessionFactory(sessionFactory);
ISession sessionFacade = sessionFactoryFacade.openSession();
Session session = (Session) ((IFacade) sessionFacade).getTarget();
Assert.assertSame(sessionFactory, session.getSessionFactory());
}
use of org.jboss.tools.hibernate.runtime.spi.ISession in project jbosstools-hibernate by jbosstools.
the class ClassMetadataFacadeTest method testGetIdentifier.
@Test
public void testGetIdentifier() {
ClassLoader cl = FACADE_FACTORY.getClassLoader();
final SessionImplementor sessionTarget = (SessionImplementor) Proxy.newProxyInstance(cl, new Class[] { SessionImplementor.class }, new TestInvocationHandler());
ISession session = (ISession) Proxy.newProxyInstance(cl, new Class[] { ISession.class, IFacade.class }, new InvocationHandler() {
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
return sessionTarget;
}
});
Object object = Integer.MAX_VALUE;
Assert.assertSame(object, classMetadata.getIdentifier(object, session));
Assert.assertEquals("getIdentifier", methodName);
Assert.assertArrayEquals(new Object[] { object, sessionTarget }, arguments);
}
use of org.jboss.tools.hibernate.runtime.spi.ISession in project jbosstools-hibernate by jbosstools.
the class ClassMetadataFacadeTest method testGetIdentifier.
@Test
public void testGetIdentifier() {
ClassLoader cl = FACADE_FACTORY.getClassLoader();
final SessionImplementor sessionTarget = (SessionImplementor) Proxy.newProxyInstance(cl, new Class[] { SessionImplementor.class }, new TestInvocationHandler());
ISession session = (ISession) Proxy.newProxyInstance(cl, new Class[] { ISession.class, IFacade.class }, new InvocationHandler() {
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
return sessionTarget;
}
});
Object object = Integer.MAX_VALUE;
Assert.assertSame(object, classMetadata.getIdentifier(object, session));
Assert.assertEquals("getIdentifier", methodName);
Assert.assertArrayEquals(new Object[] { object, sessionTarget }, arguments);
}
use of org.jboss.tools.hibernate.runtime.spi.ISession in project jbosstools-hibernate by jbosstools.
the class FacadeFactoryTest method testCreateSession.
@Test
public void testCreateSession() {
Session session = (Session) Proxy.newProxyInstance(facadeFactory.getClassLoader(), new Class[] { Session.class }, new TestInvocationHandler());
ISession facade = facadeFactory.createSession(session);
Assert.assertSame(session, ((IFacade) facade).getTarget());
}
Aggregations