Search in sources :

Example 1 with ClasspathScannerImpl

use of org.apache.tapestry5.ioc.internal.services.ClasspathScannerImpl in project tapestry-5 by apache.

the class HibernateSessionSourceImplTest method startup_without_packages.

@Test
public void startup_without_packages() {
    Collection<String> packageNames = CollectionFactory.newList("org.example.myapp.entities", "org.example.app0.entities");
    HibernateEntityPackageManager packageManager = newMock(HibernateEntityPackageManager.class);
    TestBase.expect(packageManager.getPackageNames()).andReturn(packageNames);
    ClasspathScannerImpl scanner = new ClasspathScannerImpl(new ClasspathURLConverterImpl());
    ClassNameLocatorImpl classNameLocator = new ClassNameLocatorImpl(scanner);
    List<HibernateConfigurer> filters = Arrays.asList(new DefaultHibernateConfigurer(true), new PackageNameHibernateConfigurer(packageManager, classNameLocator));
    replay();
    HibernateSessionSource source = new HibernateSessionSourceImpl(log, filters);
    Session session = source.create();
    Assert.assertNotNull(session);
    // make sure it found the entity in the package
    ClassMetadata meta = session.getSessionFactory().getClassMetadata(User.class);
    Assert.assertEquals(meta.getEntityName(), "org.example.app0.entities.User");
    verify();
}
Also used : ClassMetadata(org.hibernate.metadata.ClassMetadata) HibernateSessionSourceImpl(org.apache.tapestry5.hibernate.internal.HibernateSessionSourceImpl) PackageNameHibernateConfigurer(org.apache.tapestry5.hibernate.internal.PackageNameHibernateConfigurer) DefaultHibernateConfigurer(org.apache.tapestry5.hibernate.internal.DefaultHibernateConfigurer) HibernateSessionSource(org.apache.tapestry5.hibernate.HibernateSessionSource) ClasspathScannerImpl(org.apache.tapestry5.ioc.internal.services.ClasspathScannerImpl) DefaultHibernateConfigurer(org.apache.tapestry5.hibernate.internal.DefaultHibernateConfigurer) PackageNameHibernateConfigurer(org.apache.tapestry5.hibernate.internal.PackageNameHibernateConfigurer) HibernateConfigurer(org.apache.tapestry5.hibernate.HibernateConfigurer) ClasspathURLConverterImpl(org.apache.tapestry5.ioc.internal.services.ClasspathURLConverterImpl) ClassNameLocatorImpl(org.apache.tapestry5.ioc.internal.services.ClassNameLocatorImpl) HibernateEntityPackageManager(org.apache.tapestry5.hibernate.HibernateEntityPackageManager) Session(org.hibernate.Session) Test(org.testng.annotations.Test)

Aggregations

HibernateConfigurer (org.apache.tapestry5.hibernate.HibernateConfigurer)1 HibernateEntityPackageManager (org.apache.tapestry5.hibernate.HibernateEntityPackageManager)1 HibernateSessionSource (org.apache.tapestry5.hibernate.HibernateSessionSource)1 DefaultHibernateConfigurer (org.apache.tapestry5.hibernate.internal.DefaultHibernateConfigurer)1 HibernateSessionSourceImpl (org.apache.tapestry5.hibernate.internal.HibernateSessionSourceImpl)1 PackageNameHibernateConfigurer (org.apache.tapestry5.hibernate.internal.PackageNameHibernateConfigurer)1 ClassNameLocatorImpl (org.apache.tapestry5.ioc.internal.services.ClassNameLocatorImpl)1 ClasspathScannerImpl (org.apache.tapestry5.ioc.internal.services.ClasspathScannerImpl)1 ClasspathURLConverterImpl (org.apache.tapestry5.ioc.internal.services.ClasspathURLConverterImpl)1 Session (org.hibernate.Session)1 ClassMetadata (org.hibernate.metadata.ClassMetadata)1 Test (org.testng.annotations.Test)1