Search in sources :

Example 1 with HibernateConfigurationExporter

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

the class ExporterFacadeTest method testSetCustomProperties.

@Test
public void testSetCustomProperties() {
    Properties properties = new Properties();
    exporterFacade.setCustomProperties(properties);
    assertNotSame(properties, ((TestExporter) exporterTarget).getProperties());
    exporterTarget = new HibernateConfigurationExporter();
    exporterFacade = new ExporterFacadeImpl(FACADE_FACTORY, exporterTarget);
    assertNotSame(properties, ((HibernateConfigurationExporter) exporterTarget).getCustomProperties());
    exporterFacade.setCustomProperties(properties);
    assertSame(properties, ((HibernateConfigurationExporter) exporterTarget).getCustomProperties());
}
Also used : HibernateConfigurationExporter(org.hibernate.tool.hbm2x.HibernateConfigurationExporter) Properties(java.util.Properties) Test(org.junit.jupiter.api.Test)

Example 2 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)

Example 3 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 4 with HibernateConfigurationExporter

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

the class ExporterFacadeTest method testSetCustomProperties.

@Test
public void testSetCustomProperties() {
    Properties properties = new Properties();
    exporterFacade.setCustomProperties(properties);
    assertNotSame(properties, ((TestExporter) exporterTarget).getProperties());
    exporterTarget = new HibernateConfigurationExporter();
    exporterFacade = new ExporterFacadeImpl(FACADE_FACTORY, exporterTarget);
    assertNotSame(properties, ((HibernateConfigurationExporter) exporterTarget).getCustomProperties());
    exporterFacade.setCustomProperties(properties);
    assertSame(properties, ((HibernateConfigurationExporter) exporterTarget).getCustomProperties());
}
Also used : HibernateConfigurationExporter(org.hibernate.tool.hbm2x.HibernateConfigurationExporter) Properties(java.util.Properties) Test(org.junit.jupiter.api.Test)

Example 5 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 AbstractExporterFacade(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) AbstractExporterFacade(org.jboss.tools.hibernate.runtime.common.AbstractExporterFacade) 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