Search in sources :

Example 6 with ConfigurationFacadeImpl

use of org.jboss.tools.hibernate.runtime.v_5_6.internal.ConfigurationFacadeImpl in project jbosstools-hibernate by jbosstools.

the class ConfigurationFacadeTest method beforeEach.

@BeforeEach
public void beforeEach() {
    configuration = new Configuration();
    configuration.setProperty(AvailableSettings.DIALECT, MockDialect.class.getName());
    configuration.setProperty(AvailableSettings.CONNECTION_PROVIDER, MockConnectionProvider.class.getName());
    configurationFacade = new ConfigurationFacadeImpl(FACADE_FACTORY, configuration);
}
Also used : MockConnectionProvider(org.jboss.tools.hibernate.runtime.v_5_6.internal.util.MockConnectionProvider) Configuration(org.hibernate.cfg.Configuration) IConfiguration(org.jboss.tools.hibernate.runtime.spi.IConfiguration) JdbcMetadataConfiguration(org.jboss.tools.hibernate.runtime.v_5_6.internal.util.JdbcMetadataConfiguration) MockDialect(org.jboss.tools.hibernate.runtime.v_5_6.internal.util.MockDialect) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 7 with ConfigurationFacadeImpl

use of org.jboss.tools.hibernate.runtime.v_5_6.internal.ConfigurationFacadeImpl in project jbosstools-hibernate by jbosstools.

the class ConfigurationMetadataDescriptorTest method testCreateMetadata.

@Test
public void testCreateMetadata() {
    MetadataSources metadataSources = new MetadataSources();
    metadataSources.addInputStream(new ByteArrayInputStream(TEST_HBM_XML_STRING.getBytes()));
    Configuration configuration = new Configuration(metadataSources);
    configuration.setProperty(AvailableSettings.DIALECT, MockDialect.class.getName());
    configuration.setProperty(AvailableSettings.CONNECTION_PROVIDER, MockConnectionProvider.class.getName());
    configurationFacade = new ConfigurationFacadeImpl(FACADE_FACTORY, configuration);
    PersistentClass persistentClass = new RootClass(null);
    persistentClass.setEntityName("Bar");
    IPersistentClass persistentClassFacade = FACADE_FACTORY.createPersistentClass(persistentClass);
    configurationFacade.addClass(persistentClassFacade);
    configurationMetadataDescriptor = new ConfigurationMetadataDescriptor(configurationFacade);
    Metadata metadata = configurationMetadataDescriptor.createMetadata();
    assertNotNull(metadata.getEntityBinding(Foo.class.getName()));
    assertNotNull(metadata.getEntityBinding("Bar"));
}
Also used : RootClass(org.hibernate.mapping.RootClass) Configuration(org.hibernate.cfg.Configuration) ByteArrayInputStream(java.io.ByteArrayInputStream) MetadataSources(org.hibernate.boot.MetadataSources) Metadata(org.hibernate.boot.Metadata) ConfigurationFacadeImpl(org.jboss.tools.hibernate.runtime.v_5_5.internal.ConfigurationFacadeImpl) IPersistentClass(org.jboss.tools.hibernate.runtime.spi.IPersistentClass) IPersistentClass(org.jboss.tools.hibernate.runtime.spi.IPersistentClass) PersistentClass(org.hibernate.mapping.PersistentClass) Test(org.junit.jupiter.api.Test)

Example 8 with ConfigurationFacadeImpl

use of org.jboss.tools.hibernate.runtime.v_5_6.internal.ConfigurationFacadeImpl in project jbosstools-hibernate by jbosstools.

the class ConfigurationMetadataDescriptorTest method beforeEach.

@BeforeEach
public void beforeEach() {
    configurationTarget = new Configuration();
    configurationFacade = new ConfigurationFacadeImpl(FACADE_FACTORY, configurationTarget);
    configurationMetadataDescriptor = new ConfigurationMetadataDescriptor(configurationFacade);
}
Also used : Configuration(org.hibernate.cfg.Configuration) ConfigurationFacadeImpl(org.jboss.tools.hibernate.runtime.v_5_5.internal.ConfigurationFacadeImpl) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 9 with ConfigurationFacadeImpl

use of org.jboss.tools.hibernate.runtime.v_5_6.internal.ConfigurationFacadeImpl in project jbosstools-hibernate by jbosstools.

the class ConfigurationFacadeTest method testGetClassMapping.

@Test
public void testGetClassMapping() throws Exception {
    configuration.setProperty("hibernate.dialect", TestDialect.class.getName());
    PersistentClass persistentClass = new RootClass(null);
    persistentClass.setEntityName("Foo");
    IPersistentClass persistentClassFacade = FACADE_FACTORY.createPersistentClass(persistentClass);
    configurationFacade = new ConfigurationFacadeImpl(FACADE_FACTORY, configuration);
    assertNull(configurationFacade.getClassMapping("Foo"));
    configurationFacade = new ConfigurationFacadeImpl(FACADE_FACTORY, configuration);
    Field addedClassesField = ConfigurationFacadeImpl.class.getDeclaredField("addedClasses");
    addedClassesField.setAccessible(true);
    @SuppressWarnings("unchecked") List<IPersistentClass> addedClasses = (List<IPersistentClass>) addedClassesField.get(configurationFacade);
    addedClasses.add(persistentClassFacade);
    assertSame(configurationFacade.getClassMapping("Foo"), persistentClassFacade);
}
Also used : RootClass(org.hibernate.mapping.RootClass) Field(java.lang.reflect.Field) List(java.util.List) ArrayList(java.util.ArrayList) TestDialect(org.jboss.tools.hibernate.runtime.v_5_6.internal.util.ConfigurationMetadataDescriptorTest.TestDialect) IPersistentClass(org.jboss.tools.hibernate.runtime.spi.IPersistentClass) PersistentClass(org.hibernate.mapping.PersistentClass) IPersistentClass(org.jboss.tools.hibernate.runtime.spi.IPersistentClass) Test(org.junit.jupiter.api.Test)

Example 10 with ConfigurationFacadeImpl

use of org.jboss.tools.hibernate.runtime.v_5_6.internal.ConfigurationFacadeImpl in project jbosstools-hibernate by jbosstools.

the class ConfigurationMetadataDescriptorTest method beforeEach.

@BeforeEach
public void beforeEach() {
    configurationTarget = new Configuration();
    configurationFacade = new ConfigurationFacadeImpl(FACADE_FACTORY, configurationTarget);
    configurationMetadataDescriptor = new ConfigurationMetadataDescriptor(configurationFacade);
}
Also used : Configuration(org.hibernate.cfg.Configuration) ConfigurationFacadeImpl(org.jboss.tools.hibernate.runtime.v_6_0.internal.ConfigurationFacadeImpl) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

Test (org.junit.jupiter.api.Test)14 Configuration (org.hibernate.cfg.Configuration)13 PersistentClass (org.hibernate.mapping.PersistentClass)12 IPersistentClass (org.jboss.tools.hibernate.runtime.spi.IPersistentClass)12 Field (java.lang.reflect.Field)8 Metadata (org.hibernate.boot.Metadata)7 RootClass (org.hibernate.mapping.RootClass)7 BeforeEach (org.junit.jupiter.api.BeforeEach)6 ByteArrayInputStream (java.io.ByteArrayInputStream)5 MetadataSources (org.hibernate.boot.MetadataSources)5 JdbcMetadataConfiguration (org.jboss.tools.hibernate.runtime.v_5_6.internal.util.JdbcMetadataConfiguration)5 HashMap (java.util.HashMap)4 MetadataImpl (org.hibernate.boot.internal.MetadataImpl)4 ConfigurationFacadeImpl (org.jboss.tools.hibernate.runtime.v_5_3.internal.ConfigurationFacadeImpl)3 ConfigurationFacadeImpl (org.jboss.tools.hibernate.runtime.v_5_4.internal.ConfigurationFacadeImpl)3 ConfigurationFacadeImpl (org.jboss.tools.hibernate.runtime.v_5_5.internal.ConfigurationFacadeImpl)3 ConfigurationFacadeImpl (org.jboss.tools.hibernate.runtime.v_5_6.internal.ConfigurationFacadeImpl)3 MockConnectionProvider (org.jboss.tools.hibernate.runtime.v_5_6.internal.util.MockConnectionProvider)3 MockDialect (org.jboss.tools.hibernate.runtime.v_5_6.internal.util.MockDialect)3 Connection (java.sql.Connection)2