use of org.hibernate.boot.registry.BootstrapServiceRegistry in project hibernate-orm by hibernate.
the class FetchProfileTest method testWrongClass.
@Test
public void testWrongClass() {
final MetadataSources metadataSources = new MetadataSources().addAnnotatedClass(Customer3.class).addAnnotatedClass(Order.class).addAnnotatedClass(Country.class);
try {
metadataSources.buildMetadata();
fail();
} catch (MappingException e) {
log.trace("success");
} finally {
ServiceRegistry metaServiceRegistry = metadataSources.getServiceRegistry();
if (metaServiceRegistry instanceof BootstrapServiceRegistry) {
BootstrapServiceRegistryBuilder.destroy(metaServiceRegistry);
}
}
}
use of org.hibernate.boot.registry.BootstrapServiceRegistry in project hibernate-orm by hibernate.
the class FetchProfileTest method testUnsupportedFetchMode.
@Test
public void testUnsupportedFetchMode() {
final MetadataSources metadataSources = new MetadataSources().addAnnotatedClass(Customer4.class).addAnnotatedClass(Order.class).addAnnotatedClass(Country.class);
try {
metadataSources.buildMetadata();
fail();
} catch (MappingException e) {
log.trace("success");
} finally {
ServiceRegistry metaServiceRegistry = metadataSources.getServiceRegistry();
if (metaServiceRegistry instanceof BootstrapServiceRegistry) {
BootstrapServiceRegistryBuilder.destroy(metaServiceRegistry);
}
}
}
use of org.hibernate.boot.registry.BootstrapServiceRegistry in project hibernate-orm by hibernate.
the class CfgXmlResourceNameClosingTest method testStreamClosing.
@Test
public void testStreamClosing() {
BootstrapServiceRegistry bsr = new BootstrapServiceRegistryBuilder().applyClassLoaderService(classLoaderService).build();
StandardServiceRegistry ssr = new StandardServiceRegistryBuilder(bsr).configure("org/hibernate/test/boot/cfgXml/hibernate.cfg.xml").build();
try {
for (InputStreamWrapper openedStream : classLoaderService.openedStreams) {
assertTrue(openedStream.wasClosed);
}
} finally {
StandardServiceRegistryBuilder.destroy(ssr);
}
assertTrue(classLoaderService.stopped);
}
use of org.hibernate.boot.registry.BootstrapServiceRegistry in project hibernate-orm by hibernate.
the class InvalidEnumeratedJavaTypeTest method testInvalidMapping.
@Test
public void testInvalidMapping() {
MetadataSources metadataSources = new MetadataSources().addAnnotatedClass(TheEntity.class);
try {
metadataSources.buildMetadata();
fail("Was expecting failure");
} catch (AnnotationException ignore) {
} finally {
ServiceRegistry metaServiceRegistry = metadataSources.getServiceRegistry();
if (metaServiceRegistry instanceof BootstrapServiceRegistry) {
BootstrapServiceRegistryBuilder.destroy(metaServiceRegistry);
}
}
}
use of org.hibernate.boot.registry.BootstrapServiceRegistry in project hibernate-orm by hibernate.
the class CollectionJoinTableNamingTest method testCollectionJoinTableNamingJpaCompliantStrategy.
@Test
@TestForIssue(jiraKey = "HHH-9908")
public void testCollectionJoinTableNamingJpaCompliantStrategy() {
// Even in 4.3, with JPA compliant naming, Hibernate creates an unusable table...
final MetadataSources metadataSources = new MetadataSources();
try {
metadataSources.addAnnotatedClass(Input.class);
metadataSources.addAnnotatedClass(Ptx.class);
final Metadata metadata = metadataSources.getMetadataBuilder().applyImplicitNamingStrategy(ImplicitNamingStrategyJpaCompliantImpl.INSTANCE).build();
assertSameTableUsed(metadata);
} finally {
ServiceRegistry metaServiceRegistry = metadataSources.getServiceRegistry();
if (metaServiceRegistry instanceof BootstrapServiceRegistry) {
BootstrapServiceRegistryBuilder.destroy(metaServiceRegistry);
}
}
}
Aggregations