Search in sources :

Example 1 with CfgExporter

use of org.hibernate.tool.internal.export.cfg.CfgExporter 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).properties);
    exporterTarget = new CfgExporter();
    exporterFacade = new ExporterFacadeImpl(FACADE_FACTORY, exporterTarget);
    assertNotSame(properties, ((CfgExporter) exporterTarget).getCustomProperties());
    exporterFacade.setCustomProperties(properties);
    assertSame(properties, ((CfgExporter) exporterTarget).getCustomProperties());
}
Also used : CfgExporter(org.hibernate.tool.internal.export.cfg.CfgExporter) Properties(java.util.Properties) Test(org.junit.jupiter.api.Test)

Example 2 with CfgExporter

use of org.hibernate.tool.internal.export.cfg.CfgExporter 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 CfgExporter();
    exporterFacade = new ExporterFacadeImpl(FACADE_FACTORY, exporterTarget);
    exporterFacade.setOutput(stringWriter);
    assertSame(stringWriter, ((CfgExporter) exporterTarget).getOutput());
}
Also used : StringWriter(java.io.StringWriter) CfgExporter(org.hibernate.tool.internal.export.cfg.CfgExporter) Test(org.junit.jupiter.api.Test)

Example 3 with CfgExporter

use of org.hibernate.tool.internal.export.cfg.CfgExporter in project jbosstools-hibernate by jbosstools.

the class ExporterFacadeTest method testSetConfiguration.

@Test
public void testSetConfiguration() throws Exception {
    exporterTarget = new CfgExporter();
    exporterFacade = new ExporterFacadeImpl(FACADE_FACTORY, exporterTarget);
    Properties properties = new Properties();
    Configuration configurationTarget = new Configuration();
    configurationTarget.setProperties(properties);
    ConfigurationFacadeImpl configurationFacade = new ConfigurationFacadeImpl(FACADE_FACTORY, configurationTarget);
    exporterFacade.setConfiguration(configurationFacade);
    assertSame(properties, ((CfgExporter) exporterTarget).getCustomProperties());
    Object object = exporterTarget.getProperties().get(ExporterConstants.METADATA_DESCRIPTOR);
    assertNotNull(object);
    assertTrue(object instanceof ConfigurationMetadataDescriptor);
    ConfigurationMetadataDescriptor configurationMetadataDescriptor = (ConfigurationMetadataDescriptor) object;
    Field field = ConfigurationMetadataDescriptor.class.getDeclaredField("configurationFacade");
    field.setAccessible(true);
    object = field.get(configurationMetadataDescriptor);
    assertNotNull(object);
    assertTrue(object instanceof ConfigurationFacadeImpl);
    assertSame(object, configurationFacade);
}
Also used : Field(java.lang.reflect.Field) ConfigurationMetadataDescriptor(org.jboss.tools.hibernate.runtime.v_6_0.internal.util.ConfigurationMetadataDescriptor) Configuration(org.hibernate.cfg.Configuration) CfgExporter(org.hibernate.tool.internal.export.cfg.CfgExporter) Properties(java.util.Properties) Test(org.junit.jupiter.api.Test)

Example 4 with CfgExporter

use of org.hibernate.tool.internal.export.cfg.CfgExporter in project jbosstools-hibernate by jbosstools.

the class ServiceImplTest method testCreateExporter.

@Test
public void testCreateExporter() {
    IExporter exporter = service.createExporter(JavaExporter.class.getName());
    assertNotNull(exporter);
    Object target = ((IFacade) exporter).getTarget();
    assertNotNull(target);
    assertTrue(target instanceof JavaExporter);
    MetadataDescriptor metadataDescriptor = (MetadataDescriptor) ((JavaExporter) target).getProperties().get(ExporterConstants.METADATA_DESCRIPTOR);
    // Normal metadata descriptor
    assertNotNull(metadataDescriptor.getProperties());
    exporter = service.createExporter(CfgExporter.class.getName());
    assertNotNull(exporter);
    target = ((IFacade) exporter).getTarget();
    assertNotNull(target);
    assertTrue(target instanceof CfgExporter);
    metadataDescriptor = (MetadataDescriptor) ((CfgExporter) target).getProperties().get(ExporterConstants.METADATA_DESCRIPTOR);
    // Dummy metadata descriptor
    assertNull(metadataDescriptor.getProperties());
}
Also used : JavaExporter(org.hibernate.tool.internal.export.java.JavaExporter) CfgExporter(org.hibernate.tool.internal.export.cfg.CfgExporter) 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)

Aggregations

CfgExporter (org.hibernate.tool.internal.export.cfg.CfgExporter)4 Test (org.junit.jupiter.api.Test)4 Properties (java.util.Properties)2 StringWriter (java.io.StringWriter)1 Field (java.lang.reflect.Field)1 Configuration (org.hibernate.cfg.Configuration)1 MetadataDescriptor (org.hibernate.tool.api.metadata.MetadataDescriptor)1 JavaExporter (org.hibernate.tool.internal.export.java.JavaExporter)1 IFacade (org.jboss.tools.hibernate.runtime.common.IFacade)1 IExporter (org.jboss.tools.hibernate.runtime.spi.IExporter)1 ConfigurationMetadataDescriptor (org.jboss.tools.hibernate.runtime.v_6_0.internal.util.ConfigurationMetadataDescriptor)1