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 HibernateMappingExporterExtensionTest method testExportPOJO.
@Test
public void testExportPOJO() throws Exception {
// first without a delegate exporter
ArtifactCollector artifactCollector = new ArtifactCollector();
hibernateMappingExporterExtension.setArtifactCollector(artifactCollector);
File[] hbmXmlFiles = artifactCollector.getFiles("hbm.xml");
Assert.assertTrue(hbmXmlFiles.length == 0);
Assert.assertFalse(new File("foo" + File.separator + "Bar.hbm.xml").exists());
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);
hibernateMappingExporterExtension.exportPOJO(additionalContext, pojoClass);
hbmXmlFiles = artifactCollector.getFiles("hbm.xml");
Assert.assertTrue(hbmXmlFiles.length == 1);
Assert.assertEquals("foo" + File.separator + "Bar.hbm.xml", hbmXmlFiles[0].getPath());
Assert.assertTrue(new File("foo" + File.separator + "Bar.hbm.xml").exists());
Assert.assertNull(methodName);
Assert.assertNull(arguments);
// then with a delegate exporter
artifactCollector = new ArtifactCollector();
hibernateMappingExporterExtension.setArtifactCollector(artifactCollector);
hbmXmlFiles = artifactCollector.getFiles("hbm.xml");
Assert.assertTrue(hbmXmlFiles.length == 0);
Field delegateField = HibernateMappingExporterExtension.class.getDeclaredField("delegateExporter");
delegateField.setAccessible(true);
delegateField.set(hibernateMappingExporterExtension, exportPojoDelegate);
hibernateMappingExporterExtension.exportPOJO(additionalContext, pojoClass);
Assert.assertTrue(hbmXmlFiles.length == 0);
Assert.assertEquals("exportPOJO", methodName);
Assert.assertSame(additionalContext, arguments[0]);
Assert.assertSame(pojoClass, ((IFacade) arguments[1]).getTarget());
}
use of org.hibernate.tool.hbm2x.Cfg2HbmTool in project jbosstools-hibernate by jbosstools.
the class HibernateMappingExporterExtensionTest method testSuperExportPOJO.
@Test
public void testSuperExportPOJO() {
ArtifactCollector artifactCollector = new ArtifactCollector();
hibernateMappingExporterExtension.setArtifactCollector(artifactCollector);
File[] hbmXmlFiles = artifactCollector.getFiles("hbm.xml");
Assert.assertTrue(hbmXmlFiles.length == 0);
Assert.assertFalse(new File("foo" + File.separator + "Bar.hbm.xml").exists());
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);
hibernateMappingExporterExtension.superExportPOJO(additionalContext, pojoClass);
hbmXmlFiles = artifactCollector.getFiles("hbm.xml");
Assert.assertTrue(hbmXmlFiles.length == 1);
Assert.assertEquals("foo" + File.separator + "Bar.hbm.xml", hbmXmlFiles[0].getPath());
Assert.assertTrue(new File("foo" + File.separator + "Bar.hbm.xml").exists());
}
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 HibernateMappingExporterExtensionTest method testSuperExportPOJO.
@Test
public void testSuperExportPOJO() {
ArtifactCollector artifactCollector = new ArtifactCollector();
hibernateMappingExporterExtension.setArtifactCollector(artifactCollector);
File[] hbmXmlFiles = artifactCollector.getFiles("hbm.xml");
Assert.assertTrue(hbmXmlFiles.length == 0);
Assert.assertFalse(new File("foo" + File.separator + "Bar.hbm.xml").exists());
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);
hibernateMappingExporterExtension.superExportPOJO(additionalContext, pojoClass);
hbmXmlFiles = artifactCollector.getFiles("hbm.xml");
Assert.assertTrue(hbmXmlFiles.length == 1);
Assert.assertEquals("foo" + File.separator + "Bar.hbm.xml", hbmXmlFiles[0].getPath());
Assert.assertTrue(new File("foo" + File.separator + "Bar.hbm.xml").exists());
}
Aggregations