Search in sources :

Example 11 with StandardServiceRegistry

use of org.hibernate.boot.registry.StandardServiceRegistry in project hibernate-orm by hibernate.

the class JndiInfinispanRegionFactoryTestCase method testConstruction.

@Test
public void testConstruction() {
    StandardServiceRegistry ssr = new StandardServiceRegistryBuilder().applySetting(AvailableSettings.CACHE_REGION_FACTORY, JndiInfinispanRegionFactory.class.getName()).build();
    try {
        RegionFactory regionFactory = ssr.getService(RegionFactory.class);
        assertTyping(JndiInfinispanRegionFactory.class, regionFactory);
    } finally {
        StandardServiceRegistryBuilder.destroy(ssr);
    }
}
Also used : StandardServiceRegistryBuilder(org.hibernate.boot.registry.StandardServiceRegistryBuilder) RegionFactory(org.hibernate.cache.spi.RegionFactory) JndiInfinispanRegionFactory(org.hibernate.cache.infinispan.JndiInfinispanRegionFactory) StandardServiceRegistry(org.hibernate.boot.registry.StandardServiceRegistry) Test(org.junit.Test)

Example 12 with StandardServiceRegistry

use of org.hibernate.boot.registry.StandardServiceRegistry in project hibernate-orm by hibernate.

the class ProxoolConnectionProviderTest method testPoolsClosed.

@Test
public void testPoolsClosed() {
    // zero-length-vararg used as parameter
    assertDefinedPools();
    StandardServiceRegistry serviceRegistry = buildServiceRegistry("pool-one");
    ConnectionProvider providerOne = serviceRegistry.getService(ConnectionProvider.class);
    assertDefinedPools("pool-one");
    StandardServiceRegistry serviceRegistryTwo = buildServiceRegistry("pool-two");
    ConnectionProvider providerTwo = serviceRegistryTwo.getService(ConnectionProvider.class);
    assertDefinedPools("pool-one", "pool-two");
    StandardServiceRegistryBuilder.destroy(serviceRegistry);
    assertDefinedPools("pool-two");
    StandardServiceRegistryBuilder.destroy(serviceRegistryTwo);
    assertDefinedPools();
}
Also used : StandardServiceRegistry(org.hibernate.boot.registry.StandardServiceRegistry) ProxoolConnectionProvider(org.hibernate.proxool.internal.ProxoolConnectionProvider) ConnectionProvider(org.hibernate.engine.jdbc.connections.spi.ConnectionProvider) Test(org.junit.Test)

Example 13 with StandardServiceRegistry

use of org.hibernate.boot.registry.StandardServiceRegistry in project hibernate-orm by hibernate.

the class ServiceRegistryClosingCascadeTest method testSessionFactoryClosing.

@Test
public void testSessionFactoryClosing() {
    BootstrapServiceRegistry bsr = new BootstrapServiceRegistryBuilder().build();
    StandardServiceRegistry sr = new StandardServiceRegistryBuilder(bsr).build();
    assertTrue(((BootstrapServiceRegistryImpl) bsr).isActive());
    Configuration config = new Configuration();
    SessionFactory sf = config.buildSessionFactory(sr);
    sf.close();
    assertFalse(((BootstrapServiceRegistryImpl) bsr).isActive());
}
Also used : SessionFactory(org.hibernate.SessionFactory) BootstrapServiceRegistryBuilder(org.hibernate.boot.registry.BootstrapServiceRegistryBuilder) StandardServiceRegistryBuilder(org.hibernate.boot.registry.StandardServiceRegistryBuilder) Configuration(org.hibernate.cfg.Configuration) BootstrapServiceRegistry(org.hibernate.boot.registry.BootstrapServiceRegistry) StandardServiceRegistry(org.hibernate.boot.registry.StandardServiceRegistry) Test(org.junit.Test)

Example 14 with StandardServiceRegistry

use of org.hibernate.boot.registry.StandardServiceRegistry in project hibernate-orm by hibernate.

the class CollectionAsBasicTest method testCollectionAsBasic.

@Test
public void testCollectionAsBasic() {
    StandardServiceRegistry ssr = new StandardServiceRegistryBuilder().build();
    try {
        Metadata metadata = new MetadataSources(ssr).addAnnotatedClass(Post.class).getMetadataBuilder().applyBasicType(new DelimitedStringsType()).build();
        PersistentClass postBinding = metadata.getEntityBinding(Post.class.getName());
        Property tagsAttribute = postBinding.getProperty("tags");
    } finally {
        StandardServiceRegistryBuilder.destroy(ssr);
    }
}
Also used : StandardServiceRegistryBuilder(org.hibernate.boot.registry.StandardServiceRegistryBuilder) Metadata(org.hibernate.boot.Metadata) MetadataSources(org.hibernate.boot.MetadataSources) Property(org.hibernate.mapping.Property) StandardServiceRegistry(org.hibernate.boot.registry.StandardServiceRegistry) PersistentClass(org.hibernate.mapping.PersistentClass) Test(org.junit.Test)

Example 15 with StandardServiceRegistry

use of org.hibernate.boot.registry.StandardServiceRegistry in project hibernate-orm by hibernate.

the class OrmXmlEnumTypeTest method testOrmXmlDefinedEnumType.

@Test
public void testOrmXmlDefinedEnumType() {
    StandardServiceRegistry ssr = ServiceRegistryBuilder.buildServiceRegistry();
    try {
        MetadataSources ms = new MetadataSources(ssr);
        ms.addResource("org/hibernate/test/annotations/enumerated/ormXml/orm.xml");
        Metadata metadata = ms.buildMetadata();
        Type bindingPropertyType = metadata.getEntityBinding(BookWithOrmEnum.class.getName()).getProperty("bindingStringEnum").getType();
        CustomType customType = ExtraAssertions.assertTyping(CustomType.class, bindingPropertyType);
        EnumType enumType = ExtraAssertions.assertTyping(EnumType.class, customType.getUserType());
        assertFalse(enumType.isOrdinal());
    } finally {
        ServiceRegistryBuilder.destroy(ssr);
    }
}
Also used : CustomType(org.hibernate.type.CustomType) CustomType(org.hibernate.type.CustomType) EnumType(org.hibernate.type.EnumType) Type(org.hibernate.type.Type) EnumType(org.hibernate.type.EnumType) MetadataSources(org.hibernate.boot.MetadataSources) Metadata(org.hibernate.boot.Metadata) StandardServiceRegistry(org.hibernate.boot.registry.StandardServiceRegistry) Test(org.junit.Test)

Aggregations

StandardServiceRegistry (org.hibernate.boot.registry.StandardServiceRegistry)169 StandardServiceRegistryBuilder (org.hibernate.boot.registry.StandardServiceRegistryBuilder)152 Test (org.junit.Test)121 MetadataSources (org.hibernate.boot.MetadataSources)118 Metadata (org.hibernate.boot.Metadata)56 MetadataImplementor (org.hibernate.boot.spi.MetadataImplementor)39 PersistentClass (org.hibernate.mapping.PersistentClass)39 SessionFactoryImplementor (org.hibernate.engine.spi.SessionFactoryImplementor)25 TestForIssue (org.hibernate.testing.TestForIssue)24 BootstrapServiceRegistryBuilder (org.hibernate.boot.registry.BootstrapServiceRegistryBuilder)23 Properties (java.util.Properties)20 BootstrapServiceRegistry (org.hibernate.boot.registry.BootstrapServiceRegistry)20 SchemaUpdate (org.hibernate.tool.hbm2ddl.SchemaUpdate)15 SessionFactory (org.hibernate.SessionFactory)14 Column (org.hibernate.mapping.Column)14 Property (org.hibernate.mapping.Property)14 Session (org.hibernate.Session)13 SchemaExport (org.hibernate.tool.hbm2ddl.SchemaExport)12 IdentifierGenerator (org.hibernate.id.IdentifierGenerator)11 RootClass (org.hibernate.mapping.RootClass)11