Search in sources :

Example 76 with SchemaExport

use of org.hibernate.tool.hbm2ddl.SchemaExport in project jbosstools-hibernate by jbosstools.

the class FacadeFactoryTest method testCreateSchemaExport.

@Test
public void testCreateSchemaExport() {
    Configuration configuration = new Configuration();
    configuration.setProperty("hibernate.dialect", "org.hibernate.dialect.H2Dialect");
    SchemaExport schemaExport = new SchemaExport(configuration);
    ISchemaExport facade = facadeFactory.createSchemaExport(schemaExport);
    Assert.assertSame(schemaExport, ((IFacade) facade).getTarget());
}
Also used : Configuration(org.hibernate.cfg.Configuration) IConfiguration(org.jboss.tools.hibernate.runtime.spi.IConfiguration) ISchemaExport(org.jboss.tools.hibernate.runtime.spi.ISchemaExport) ISchemaExport(org.jboss.tools.hibernate.runtime.spi.ISchemaExport) SchemaExport(org.hibernate.tool.hbm2ddl.SchemaExport) Test(org.junit.Test)

Example 77 with SchemaExport

use of org.hibernate.tool.hbm2ddl.SchemaExport in project jbosstools-hibernate by jbosstools.

the class FacadeFactoryTest method testCreateSchemaExport.

@Test
public void testCreateSchemaExport() {
    Configuration configuration = new Configuration();
    configuration.setProperty("hibernate.dialect", "org.hibernate.dialect.H2Dialect");
    SchemaExport schemaExport = new SchemaExport();
    ISchemaExport facade = facadeFactory.createSchemaExport(schemaExport);
    Assert.assertTrue(facade instanceof SchemaExportFacadeImpl);
    Assert.assertSame(schemaExport, ((IFacade) facade).getTarget());
}
Also used : IConfiguration(org.jboss.tools.hibernate.runtime.spi.IConfiguration) Configuration(org.hibernate.cfg.Configuration) ISchemaExport(org.jboss.tools.hibernate.runtime.spi.ISchemaExport) ISchemaExport(org.jboss.tools.hibernate.runtime.spi.ISchemaExport) SchemaExport(org.hibernate.tool.hbm2ddl.SchemaExport) Test(org.junit.Test)

Example 78 with SchemaExport

use of org.hibernate.tool.hbm2ddl.SchemaExport in project jbosstools-hibernate by jbosstools.

the class SchemaExportFacadeTest method testGetExceptions.

@SuppressWarnings("unchecked")
@Test
public void testGetExceptions() throws Throwable {
    SchemaExport schemaExport = new SchemaExport();
    ISchemaExport schemaExportFacade = new SchemaExportFacadeImpl(FACADE_FACTORY, schemaExport);
    Assert.assertTrue(schemaExportFacade.getExceptions().isEmpty());
    schemaExport.getExceptions().add(new HibernateException("blah"));
    Assert.assertFalse(schemaExportFacade.getExceptions().isEmpty());
}
Also used : HibernateException(org.jboss.tools.hibernate.runtime.spi.HibernateException) ISchemaExport(org.jboss.tools.hibernate.runtime.spi.ISchemaExport) ISchemaExport(org.jboss.tools.hibernate.runtime.spi.ISchemaExport) SchemaExport(org.hibernate.tool.hbm2ddl.SchemaExport) Test(org.junit.Test)

Example 79 with SchemaExport

use of org.hibernate.tool.hbm2ddl.SchemaExport in project jbosstools-hibernate by jbosstools.

the class SchemaExportFacadeTest method testCreate.

@Test
public void testCreate() throws Exception {
    String urlString = "jdbc:h2:mem:create_test";
    Connection connection = DriverManager.getConnection(urlString);
    configuration.setProperty(Environment.URL, urlString);
    IConfiguration configurationFacade = FACADE_FACTORY.createConfiguration(configuration);
    SchemaExport schemaExport = new SchemaExport();
    SchemaExportFacadeImpl schemaExportFacade = new SchemaExportFacadeImpl(FACADE_FACTORY, schemaExport);
    schemaExportFacade.setConfiguration(configurationFacade);
    Assert.assertFalse(connection.getMetaData().getTables(null, null, "FOO", null).next());
    schemaExportFacade.create();
    Assert.assertTrue(connection.getMetaData().getTables(null, null, "FOO", null).next());
}
Also used : Connection(java.sql.Connection) IConfiguration(org.jboss.tools.hibernate.runtime.spi.IConfiguration) ISchemaExport(org.jboss.tools.hibernate.runtime.spi.ISchemaExport) SchemaExport(org.hibernate.tool.hbm2ddl.SchemaExport) Test(org.junit.Test)

Example 80 with SchemaExport

use of org.hibernate.tool.hbm2ddl.SchemaExport in project jbosstools-hibernate by jbosstools.

the class FacadeFactoryTest method testCreateSchemaExport.

@Test
public void testCreateSchemaExport() {
    SchemaExport schemaExport = new SchemaExport();
    ISchemaExport facade = facadeFactory.createSchemaExport(schemaExport);
    Assert.assertTrue(facade instanceof SchemaExportFacadeImpl);
    Assert.assertSame(schemaExport, ((IFacade) facade).getTarget());
}
Also used : ISchemaExport(org.jboss.tools.hibernate.runtime.spi.ISchemaExport) ISchemaExport(org.jboss.tools.hibernate.runtime.spi.ISchemaExport) SchemaExport(org.hibernate.tool.hbm2ddl.SchemaExport) Test(org.junit.Test)

Aggregations

SchemaExport (org.hibernate.tool.hbm2ddl.SchemaExport)90 Test (org.junit.Test)45 MetadataSources (org.hibernate.boot.MetadataSources)42 StandardServiceRegistryBuilder (org.hibernate.boot.registry.StandardServiceRegistryBuilder)28 ISchemaExport (org.jboss.tools.hibernate.runtime.spi.ISchemaExport)27 MetadataImplementor (org.hibernate.boot.spi.MetadataImplementor)22 TestForIssue (org.hibernate.testing.TestForIssue)13 StandardServiceRegistry (org.hibernate.boot.registry.StandardServiceRegistry)12 Configuration (org.hibernate.cfg.Configuration)12 Connection (java.sql.Connection)10 IConfiguration (org.jboss.tools.hibernate.runtime.spi.IConfiguration)10 After (org.junit.After)10 SchemaUpdate (org.hibernate.tool.hbm2ddl.SchemaUpdate)9 File (java.io.File)8 Before (org.junit.Before)8 HashMap (java.util.HashMap)5 Metadata (org.hibernate.boot.Metadata)5 IFacade (org.jboss.tools.hibernate.runtime.common.IFacade)5 SQLException (java.sql.SQLException)4 Entity (javax.persistence.Entity)4