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("configurationFacade");
configurationFacadeField.setAccessible(true);
ConfigurationFacadeImpl configurationFacade2 = (ConfigurationFacadeImpl) configurationFacadeField.get(configurationMetadataDescriptor);
assertNotNull(configurationFacade2);
assertSame(configurationFacade1, configurationFacade2);
}
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());
}
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 AbstractExporterFacade(FACADE_FACTORY, exporterTarget) {
};
assertNotSame(properties, ((HibernateConfigurationExporter) exporterTarget).getCustomProperties());
exporterFacade.setCustomProperties(properties);
assertSame(properties, ((HibernateConfigurationExporter) exporterTarget).getCustomProperties());
}
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());
}
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 AbstractExporterFacade(FACADE_FACTORY, exporterTarget) {
};
assertNotSame(properties, ((HibernateConfigurationExporter) exporterTarget).getCustomProperties());
exporterFacade.setCustomProperties(properties);
assertSame(properties, ((HibernateConfigurationExporter) exporterTarget).getCustomProperties());
}
Aggregations