Search in sources :

Example 6 with ISchemaExport

use of org.jboss.tools.hibernate.runtime.spi.ISchemaExport 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);
    ISchemaExport schemaExportFacade = FACADE_FACTORY.createSchemaExport(new SchemaExport(configuration));
    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) 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 7 with ISchemaExport

use of org.jboss.tools.hibernate.runtime.spi.ISchemaExport in project jbosstools-hibernate by jbosstools.

the class SchemaExportFacadeTest method testGetExceptions.

@Test
public void testGetExceptions() throws Throwable {
    String urlString = "jdbc:h2:tcp://localhost/~/some_weird_unexistant_location";
    configuration.setProperty(Environment.URL, urlString);
    SchemaExport schemaExport = new SchemaExport(configuration);
    ISchemaExport schemaExportFacade = FACADE_FACTORY.createSchemaExport(schemaExport);
    Assert.assertTrue(schemaExportFacade.getExceptions().isEmpty());
    schemaExport.create(false, true);
    Assert.assertFalse(schemaExportFacade.getExceptions().isEmpty());
}
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)

Example 8 with ISchemaExport

use of org.jboss.tools.hibernate.runtime.spi.ISchemaExport in project jbosstools-hibernate by jbosstools.

the class SchemaExportFacadeTest method testGetExceptions.

@SuppressWarnings("unchecked")
@Test
public void testGetExceptions() throws Throwable {
    String urlString = "jdbc:h2:mem:create_test";
    configuration.setProperty(Environment.URL, urlString);
    MetadataImplementor metadataImplementor = (MetadataImplementor) MetadataHelper.getMetadata(configuration);
    SchemaExport schemaExport = new SchemaExport(metadataImplementor);
    ISchemaExport schemaExportFacade = FACADE_FACTORY.createSchemaExport(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) MetadataImplementor(org.hibernate.boot.spi.MetadataImplementor) ISchemaExport(org.jboss.tools.hibernate.runtime.spi.ISchemaExport) SchemaExport(org.hibernate.tool.hbm2ddl.SchemaExport) Test(org.junit.Test)

Example 9 with ISchemaExport

use of org.jboss.tools.hibernate.runtime.spi.ISchemaExport 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 10 with ISchemaExport

use of org.jboss.tools.hibernate.runtime.spi.ISchemaExport in project jbosstools-hibernate by jbosstools.

the class SchemaExportFacadeTest method testGetExceptions.

@Test
public void testGetExceptions() throws Throwable {
    String urlString = "jdbc:h2:tcp://localhost/~/some_weird_unexistant_location";
    configuration.setProperty(Environment.URL, urlString);
    SchemaExport schemaExport = new SchemaExport(configuration);
    ISchemaExport schemaExportFacade = FACADE_FACTORY.createSchemaExport(schemaExport);
    Assert.assertTrue(schemaExportFacade.getExceptions().isEmpty());
    schemaExport.create(false, true);
    Assert.assertFalse(schemaExportFacade.getExceptions().isEmpty());
}
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

ISchemaExport (org.jboss.tools.hibernate.runtime.spi.ISchemaExport)30 SchemaExport (org.hibernate.tool.hbm2ddl.SchemaExport)25 Test (org.junit.Test)24 IConfiguration (org.jboss.tools.hibernate.runtime.spi.IConfiguration)13 Configuration (org.hibernate.cfg.Configuration)8 Connection (java.sql.Connection)5 IFacade (org.jboss.tools.hibernate.runtime.common.IFacade)5 MetadataImplementor (org.hibernate.boot.spi.MetadataImplementor)3 HibernateException (org.jboss.tools.hibernate.runtime.spi.HibernateException)3 Iterator (java.util.Iterator)1 JDBCMetaDataConfiguration (org.hibernate.cfg.JDBCMetaDataConfiguration)1 ConsoleConfiguration (org.hibernate.console.ConsoleConfiguration)1 Command (org.hibernate.console.execution.ExecutionContext.Command)1 IService (org.jboss.tools.hibernate.runtime.spi.IService)1