Search in sources :

Example 26 with HibernateConfigurationExporter

use of org.hibernate.tool.hbm2x.HibernateConfigurationExporter in project jbosstools-hibernate by jbosstools.

the class ExporterFacadeTest method testSetConfiguration.

@Test
public void testSetConfiguration() throws Exception {
    exporterTarget = new HibernateConfigurationExporter();
    exporterFacade = new AbstractExporterFacade(FACADE_FACTORY, exporterTarget) {
    };
    Properties properties = new Properties();
    Configuration configurationTarget = new Configuration();
    configurationTarget.setProperties(properties);
    assertNotSame(properties, exporterTarget.getProperties());
    assertNotSame(configurationTarget, exporterTarget.getConfiguration());
    ConfigurationFacadeImpl configurationFacade = new ConfigurationFacadeImpl(FACADE_FACTORY, configurationTarget);
    exporterFacade.setConfiguration(configurationFacade);
    assertSame(properties, exporterTarget.getProperties());
    assertSame(configurationTarget, exporterTarget.getConfiguration());
}
Also used : HibernateConfigurationExporter(org.hibernate.tool.hbm2x.HibernateConfigurationExporter) Configuration(org.hibernate.cfg.Configuration) Properties(java.util.Properties) AbstractExporterFacade(org.jboss.tools.hibernate.runtime.common.AbstractExporterFacade) Test(org.junit.jupiter.api.Test)

Example 27 with HibernateConfigurationExporter

use of org.hibernate.tool.hbm2x.HibernateConfigurationExporter in project jbosstools-hibernate by jbosstools.

the class ExporterFacadeTest method testSetConfiguration.

@Test
public void testSetConfiguration() throws Exception {
    exporterTarget = new HibernateConfigurationExporter();
    exporterFacade = new AbstractExporterFacade(FACADE_FACTORY, exporterTarget) {
    };
    Properties properties = new Properties();
    Configuration configurationTarget = new Configuration();
    configurationTarget.setProperties(properties);
    assertNotSame(properties, exporterTarget.getProperties());
    assertNotSame(configurationTarget, exporterTarget.getConfiguration());
    ConfigurationFacadeImpl configurationFacade = new ConfigurationFacadeImpl(FACADE_FACTORY, configurationTarget);
    exporterFacade.setConfiguration(configurationFacade);
    assertSame(properties, exporterTarget.getProperties());
    assertSame(configurationTarget, exporterTarget.getConfiguration());
}
Also used : HibernateConfigurationExporter(org.hibernate.tool.hbm2x.HibernateConfigurationExporter) Configuration(org.hibernate.cfg.Configuration) Properties(java.util.Properties) AbstractExporterFacade(org.jboss.tools.hibernate.runtime.common.AbstractExporterFacade) Test(org.junit.jupiter.api.Test)

Example 28 with HibernateConfigurationExporter

use of org.hibernate.tool.hbm2x.HibernateConfigurationExporter in project jbosstools-hibernate by jbosstools.

the class ServiceImplTest method testCreateExporter.

@Test
public void testCreateExporter() throws Exception {
    IExporter exporter = service.createExporter(POJOExporter.class.getName());
    assertNotNull(exporter);
    Object target = ((IFacade) exporter).getTarget();
    assertNotNull(target);
    assertTrue(target instanceof POJOExporter);
    Field metadataDescriptorField = AbstractExporter.class.getDeclaredField("metadataDescriptor");
    metadataDescriptorField.setAccessible(true);
    MetadataDescriptor metadataDescriptor = (MetadataDescriptor) metadataDescriptorField.get(target);
    // Normal metadata descriptor
    assertNotNull(metadataDescriptor.getProperties());
    exporter = service.createExporter(HibernateConfigurationExporter.class.getName());
    assertNotNull(exporter);
    target = ((IFacade) exporter).getTarget();
    assertNotNull(target);
    assertTrue(target instanceof HibernateConfigurationExporter);
    metadataDescriptor = (MetadataDescriptor) metadataDescriptorField.get(target);
    // Dummy metadata descriptor
    assertNull(metadataDescriptor.getProperties());
}
Also used : Field(java.lang.reflect.Field) HibernateConfigurationExporter(org.hibernate.tool.hbm2x.HibernateConfigurationExporter) POJOExporter(org.hibernate.tool.hbm2x.POJOExporter) MetadataDescriptor(org.hibernate.tool.api.metadata.MetadataDescriptor) IExporter(org.jboss.tools.hibernate.runtime.spi.IExporter) IFacade(org.jboss.tools.hibernate.runtime.common.IFacade) Test(org.junit.jupiter.api.Test)

Example 29 with HibernateConfigurationExporter

use of org.hibernate.tool.hbm2x.HibernateConfigurationExporter in project jbosstools-hibernate by jbosstools.

the class ExporterFacadeTest method testSetCustomProperties.

@Test
public void testSetCustomProperties() {
    Exporter exporter = new GenericExporter();
    exporterFacade = FACADE_FACTORY.createExporter(exporter);
    Properties properties = new Properties();
    exporterFacade.setCustomProperties(properties);
    exporter = new HibernateConfigurationExporter();
    exporterFacade = FACADE_FACTORY.createExporter(exporter);
    exporterFacade.setCustomProperties(properties);
    Assert.assertSame(properties, ((HibernateConfigurationExporter) exporter).getCustomProperties());
}
Also used : GenericExporter(org.hibernate.tool.hbm2x.GenericExporter) IGenericExporter(org.jboss.tools.hibernate.runtime.spi.IGenericExporter) HibernateConfigurationExporter(org.hibernate.tool.hbm2x.HibernateConfigurationExporter) GenericExporter(org.hibernate.tool.hbm2x.GenericExporter) Exporter(org.hibernate.tool.hbm2x.Exporter) QueryExporter(org.hibernate.tool.hbm2x.QueryExporter) HibernateConfigurationExporter(org.hibernate.tool.hbm2x.HibernateConfigurationExporter) Hbm2DDLExporter(org.hibernate.tool.hbm2x.Hbm2DDLExporter) IQueryExporter(org.jboss.tools.hibernate.runtime.spi.IQueryExporter) IHbm2DDLExporter(org.jboss.tools.hibernate.runtime.spi.IHbm2DDLExporter) IExporter(org.jboss.tools.hibernate.runtime.spi.IExporter) IGenericExporter(org.jboss.tools.hibernate.runtime.spi.IGenericExporter) Properties(java.util.Properties) Test(org.junit.Test)

Example 30 with HibernateConfigurationExporter

use of org.hibernate.tool.hbm2x.HibernateConfigurationExporter in project jbosstools-hibernate by jbosstools.

the class ExporterFacadeTest method testSetOutput.

@Test
public void testSetOutput() {
    Exporter exporter = new GenericExporter();
    exporterFacade = FACADE_FACTORY.createExporter(exporter);
    StringWriter stringWriter = new StringWriter();
    exporterFacade.setOutput(stringWriter);
    exporter = new HibernateConfigurationExporter();
    exporterFacade = FACADE_FACTORY.createExporter(exporter);
    exporterFacade.setOutput(stringWriter);
    Assert.assertSame(stringWriter, ((HibernateConfigurationExporter) exporter).getOutput());
}
Also used : GenericExporter(org.hibernate.tool.hbm2x.GenericExporter) IGenericExporter(org.jboss.tools.hibernate.runtime.spi.IGenericExporter) StringWriter(java.io.StringWriter) HibernateConfigurationExporter(org.hibernate.tool.hbm2x.HibernateConfigurationExporter) GenericExporter(org.hibernate.tool.hbm2x.GenericExporter) Exporter(org.hibernate.tool.hbm2x.Exporter) QueryExporter(org.hibernate.tool.hbm2x.QueryExporter) HibernateConfigurationExporter(org.hibernate.tool.hbm2x.HibernateConfigurationExporter) Hbm2DDLExporter(org.hibernate.tool.hbm2x.Hbm2DDLExporter) IQueryExporter(org.jboss.tools.hibernate.runtime.spi.IQueryExporter) IHbm2DDLExporter(org.jboss.tools.hibernate.runtime.spi.IHbm2DDLExporter) IExporter(org.jboss.tools.hibernate.runtime.spi.IExporter) IGenericExporter(org.jboss.tools.hibernate.runtime.spi.IGenericExporter) Test(org.junit.Test)

Aggregations

HibernateConfigurationExporter (org.hibernate.tool.hbm2x.HibernateConfigurationExporter)42 Test (org.junit.jupiter.api.Test)40 Properties (java.util.Properties)21 AbstractExporterFacade (org.jboss.tools.hibernate.runtime.common.AbstractExporterFacade)18 IExporter (org.jboss.tools.hibernate.runtime.spi.IExporter)12 StringWriter (java.io.StringWriter)11 Configuration (org.hibernate.cfg.Configuration)10 POJOExporter (org.hibernate.tool.hbm2x.POJOExporter)10 IFacade (org.jboss.tools.hibernate.runtime.common.IFacade)10 Field (java.lang.reflect.Field)8 MetadataDescriptor (org.hibernate.tool.api.metadata.MetadataDescriptor)4 Exporter (org.hibernate.tool.hbm2x.Exporter)2 GenericExporter (org.hibernate.tool.hbm2x.GenericExporter)2 Hbm2DDLExporter (org.hibernate.tool.hbm2x.Hbm2DDLExporter)2 QueryExporter (org.hibernate.tool.hbm2x.QueryExporter)2 IGenericExporter (org.jboss.tools.hibernate.runtime.spi.IGenericExporter)2 IHbm2DDLExporter (org.jboss.tools.hibernate.runtime.spi.IHbm2DDLExporter)2 IQueryExporter (org.jboss.tools.hibernate.runtime.spi.IQueryExporter)2 Test (org.junit.Test)2 AbstractConfigurationFacade (org.jboss.tools.hibernate.runtime.common.AbstractConfigurationFacade)1