Search in sources :

Example 6 with MetadataDescriptor

use of org.hibernate.tool.api.metadata.MetadataDescriptor 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)

Aggregations

MetadataDescriptor (org.hibernate.tool.api.metadata.MetadataDescriptor)6 IFacade (org.jboss.tools.hibernate.runtime.common.IFacade)6 Test (org.junit.jupiter.api.Test)6 Field (java.lang.reflect.Field)5 IExporter (org.jboss.tools.hibernate.runtime.spi.IExporter)5 HibernateConfigurationExporter (org.hibernate.tool.hbm2x.HibernateConfigurationExporter)4 POJOExporter (org.hibernate.tool.hbm2x.POJOExporter)4 File (java.io.File)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Properties (java.util.Properties)1 CfgExporter (org.hibernate.tool.internal.export.cfg.CfgExporter)1 JavaExporter (org.hibernate.tool.internal.export.java.JavaExporter)1 IExportPOJODelegate (org.jboss.tools.hibernate.runtime.spi.IExportPOJODelegate)1 IPOJOClass (org.jboss.tools.hibernate.runtime.spi.IPOJOClass)1