Search in sources :

Example 16 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 17 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);
    exporter = service.createExporter(HibernateConfigurationExporter.class.getName());
    assertNotNull(exporter);
    target = ((IFacade) exporter).getTarget();
    assertNotNull(target);
    assertTrue(target instanceof HibernateConfigurationExporter);
}
Also used : HibernateConfigurationExporter(org.hibernate.tool.hbm2x.HibernateConfigurationExporter) POJOExporter(org.hibernate.tool.hbm2x.POJOExporter) IExporter(org.jboss.tools.hibernate.runtime.spi.IExporter) IFacade(org.jboss.tools.hibernate.runtime.common.IFacade) Test(org.junit.jupiter.api.Test)

Example 18 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);
    exporter = service.createExporter(HibernateConfigurationExporter.class.getName());
    assertNotNull(exporter);
    target = ((IFacade) exporter).getTarget();
    assertNotNull(target);
    assertTrue(target instanceof HibernateConfigurationExporter);
}
Also used : HibernateConfigurationExporter(org.hibernate.tool.hbm2x.HibernateConfigurationExporter) POJOExporter(org.hibernate.tool.hbm2x.POJOExporter) IExporter(org.jboss.tools.hibernate.runtime.spi.IExporter) IFacade(org.jboss.tools.hibernate.runtime.common.IFacade) Test(org.junit.jupiter.api.Test)

Example 19 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 ExporterFacadeImpl(FACADE_FACTORY, exporterTarget);
    Properties properties = new Properties();
    Configuration configurationTarget = new Configuration();
    configurationTarget.setProperties(properties);
    ConfigurationFacadeImpl configurationFacade1 = new ConfigurationFacadeImpl(FACADE_FACTORY, configurationTarget);
    exporterFacade.setConfiguration(configurationFacade1);
    assertSame(properties, ((HibernateConfigurationExporter) exporterTarget).getCustomProperties());
    Field metadataDescriptorField = AbstractExporter.class.getDeclaredField("metadataDescriptor");
    metadataDescriptorField.setAccessible(true);
    ConfigurationMetadataDescriptor configurationMetadataDescriptor = (ConfigurationMetadataDescriptor) metadataDescriptorField.get(exporterTarget);
    assertNotNull(configurationMetadataDescriptor);
    Field configurationFacadeField = ConfigurationMetadataDescriptor.class.getDeclaredField("configuration");
    configurationFacadeField.setAccessible(true);
    ConfigurationFacadeImpl configurationFacade2 = (ConfigurationFacadeImpl) configurationFacadeField.get(configurationMetadataDescriptor);
    assertNotNull(configurationFacade2);
    assertSame(configurationFacade1, configurationFacade2);
}
Also used : Field(java.lang.reflect.Field) ConfigurationMetadataDescriptor(org.jboss.tools.hibernate.runtime.v_5_4.internal.util.ConfigurationMetadataDescriptor) HibernateConfigurationExporter(org.hibernate.tool.hbm2x.HibernateConfigurationExporter) Configuration(org.hibernate.cfg.Configuration) Properties(java.util.Properties) Test(org.junit.jupiter.api.Test)

Example 20 with HibernateConfigurationExporter

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

the class ExporterFacadeTest method testSetOutput.

@Test
public void testSetOutput() {
    StringWriter stringWriter = new StringWriter();
    exporterFacade.setOutput(stringWriter);
    assertNotSame(stringWriter, ((TestExporter) exporterTarget).writer);
    exporterTarget = new HibernateConfigurationExporter();
    exporterFacade = new ExporterFacadeImpl(FACADE_FACTORY, exporterTarget);
    assertNotSame(stringWriter, ((HibernateConfigurationExporter) exporterTarget).getOutput());
    exporterFacade.setOutput(stringWriter);
    assertSame(stringWriter, ((HibernateConfigurationExporter) exporterTarget).getOutput());
}
Also used : StringWriter(java.io.StringWriter) HibernateConfigurationExporter(org.hibernate.tool.hbm2x.HibernateConfigurationExporter) Test(org.junit.jupiter.api.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