use of org.hibernate.tool.hbm2x.Cfg2HbmTool in project jbosstools-hibernate by jbosstools.
the class HibernateMappingExporterFacadeTest method testExportPOJO.
@Test
public void testExportPOJO() throws Exception {
RootClass persistentClass = new RootClass();
Table rootTable = new Table();
rootTable.setName("FOO");
persistentClass.setTable(rootTable);
persistentClass.setEntityName("Foo");
persistentClass.setClassName("Foo");
IPOJOClass pojoClass = FACADE_FACTORY.createPOJOClass(new EntityPOJOClass(persistentClass, new Cfg2JavaTool()));
Map<Object, Object> additionalContext = new HashMap<Object, Object>();
Cfg2HbmTool c2h = new Cfg2HbmTool();
additionalContext.put("date", new Date().toString());
additionalContext.put("version", Version.getDefault().toString());
additionalContext.put("c2h", c2h);
hibernateMappingExporter.setOutputDirectory(outputDir);
Method setTemplateHelperMethod = AbstractExporter.class.getDeclaredMethod("setTemplateHelper", new Class[] { TemplateHelper.class });
setTemplateHelperMethod.setAccessible(true);
TemplateHelper templateHelper = new TemplateHelper();
templateHelper.init(null, new String[0]);
setTemplateHelperMethod.invoke(hibernateMappingExporter, new Object[] { templateHelper });
final File fooHbmXml = new File(outputDir, "Foo.hbm.xml");
Assert.assertFalse(fooHbmXml.exists());
hibernateMappingExporterFacade.exportPOJO(additionalContext, pojoClass);
Assert.assertTrue(fooHbmXml.exists());
fooHbmXml.delete();
outputDir.delete();
}
use of org.hibernate.tool.hbm2x.Cfg2HbmTool in project jbosstools-hibernate by jbosstools.
the class Cfg2HbmToolFacadeTest method setUp.
@Before
public void setUp() {
cfg2HbmTool = new Cfg2HbmTool();
cfg2HbmToolFacade = new AbstractCfg2HbmToolFacade(FACADE_FACTORY, cfg2HbmTool) {
};
}
use of org.hibernate.tool.hbm2x.Cfg2HbmTool in project jbosstools-hibernate by jbosstools.
the class FacadeFactoryTest method testCreateCfg2HbmTool.
@Test
public void testCreateCfg2HbmTool() {
Cfg2HbmTool cfg2HbmTool = new Cfg2HbmTool();
ICfg2HbmTool facade = facadeFactory.createCfg2HbmTool(cfg2HbmTool);
Assert.assertSame(cfg2HbmTool, ((IFacade) facade).getTarget());
}
use of org.hibernate.tool.hbm2x.Cfg2HbmTool in project jbosstools-hibernate by jbosstools.
the class Cfg2HbmToolFacadeTest method setUp.
@Before
public void setUp() {
cfg2HbmTool = new Cfg2HbmTool();
cfg2HbmToolFacade = new AbstractCfg2HbmToolFacade(FACADE_FACTORY, cfg2HbmTool) {
};
}
use of org.hibernate.tool.hbm2x.Cfg2HbmTool in project jbosstools-hibernate by jbosstools.
the class HibernateMappingExporterFacadeTest method testExportPOJO.
@Test
public void testExportPOJO() throws Exception {
RootClass persistentClass = new RootClass(null);
Table rootTable = new Table();
rootTable.setName("FOO");
persistentClass.setTable(rootTable);
persistentClass.setEntityName("Foo");
persistentClass.setClassName("Foo");
IPOJOClass pojoClass = FACADE_FACTORY.createPOJOClass(new EntityPOJOClass(persistentClass, new Cfg2JavaTool()));
Map<Object, Object> additionalContext = new HashMap<Object, Object>();
Cfg2HbmTool c2h = new Cfg2HbmTool();
additionalContext.put("date", new Date().toString());
additionalContext.put("version", Version.getDefault().toString());
additionalContext.put("c2h", c2h);
hibernateMappingExporter.setOutputDirectory(outputDir);
Method setTemplateHelperMethod = AbstractExporter.class.getDeclaredMethod("setTemplateHelper", new Class[] { TemplateHelper.class });
setTemplateHelperMethod.setAccessible(true);
TemplateHelper templateHelper = new TemplateHelper();
templateHelper.init(null, new String[0]);
setTemplateHelperMethod.invoke(hibernateMappingExporter, new Object[] { templateHelper });
final File fooHbmXml = new File(outputDir, "Foo.hbm.xml");
Assert.assertFalse(fooHbmXml.exists());
hibernateMappingExporterFacade.exportPOJO(additionalContext, pojoClass);
Assert.assertTrue(fooHbmXml.exists());
fooHbmXml.delete();
outputDir.delete();
}
Aggregations