use of org.jboss.tools.hibernate.runtime.spi.IHibernateMappingExporter in project jbosstools-hibernate by jbosstools.
the class WripperException method testHbmExportExceptionTest.
public void testHbmExportExceptionTest() throws Exception {
try {
Object[] persClassesInit = getPersistenceClasses(false);
final ConsoleConfiguration consCFG = getConsoleConfig();
IConfiguration config = consCFG.getConfiguration();
// delete old hbm files
assertNotNull(testPackage);
int nDeleted = 0;
if (testPackage.getNonJavaResources().length > 0) {
Object[] ress = testPackage.getNonJavaResources();
for (int i = 0; i < ress.length; i++) {
if (ress[i] instanceof IFile) {
IFile res = (IFile) ress[i];
if (res.getName().endsWith(".hbm.xml")) {
// $NON-NLS-1$
res.delete(true, false, null);
nDeleted++;
}
}
}
}
IHibernateMappingExporter hce = service.newHibernateMappingExporter(config, getSrcFolder());
try {
hce.start();
IArtifactCollector collector = service.newArtifactCollector();
collector.formatFiles();
try {
// build generated configuration
testPackage.getResource().refreshLocal(IResource.DEPTH_INFINITE, null);
testPackage.getJavaProject().getProject().build(IncrementalProjectBuilder.FULL_BUILD, new NullProgressMonitor());
ConsoleConfigUtils.customizeCfgXmlForPack(testPackage);
assertNotNull(consCFG);
consCFG.reset();
consCFG.build();
assertTrue(consCFG.hasConfiguration());
consCFG.getConfiguration().buildMappings();
config = consCFG.getConfiguration();
} catch (CoreException e) {
String out = NLS.bind(ConsoleTestMessages.UpdateConfigurationTest_error_customising_file_for_package, new Object[] { ConsoleConfigUtils.CFG_FILE_NAME, testPackage.getPath(), e.getMessage() });
fail(out);
}
} catch (Exception e) {
throw (Exception) e.getCause();
}
//
Object[] persClassesReInit = getPersistenceClasses(false);
//
int nCreated = 0;
if (testPackage.getNonJavaResources().length > 0) {
Object[] ress = testPackage.getNonJavaResources();
for (int i = 0; i < ress.length; i++) {
if (ress[i] instanceof IFile) {
IFile res = (IFile) ress[i];
if (res.getName().endsWith(".hbm.xml")) {
// $NON-NLS-1$
nCreated++;
}
}
}
}
//
assertTrue(persClassesInit.length == persClassesReInit.length);
assertTrue(nCreated > 0);
assertTrue(nDeleted >= 0 && persClassesInit.length > 0);
assertTrue(nCreated <= persClassesInit.length);
} catch (Exception e) {
// $NON-NLS-1$ //$NON-NLS-2$
String newMessage = "\nPackage " + testPackage.getElementName() + ":";
throw new WripperException(newMessage, e);
}
}
use of org.jboss.tools.hibernate.runtime.spi.IHibernateMappingExporter in project jbosstools-hibernate by jbosstools.
the class FacadeFactoryTest method testCreateHibernateMappingExporter.
@Test
public void testCreateHibernateMappingExporter() {
HibernateMappingExporter hibernateMappingExporter = new HibernateMappingExporter();
IHibernateMappingExporter facade = facadeFactory.createHibernateMappingExporter(hibernateMappingExporter);
Assert.assertSame(hibernateMappingExporter, ((IFacade) facade).getTarget());
}
use of org.jboss.tools.hibernate.runtime.spi.IHibernateMappingExporter in project jbosstools-hibernate by jbosstools.
the class FacadeFactoryTest method testCreateHibernateMappingExporter.
@Test
public void testCreateHibernateMappingExporter() {
HibernateMappingExporter hibernateMappingExporter = new HibernateMappingExporter();
IHibernateMappingExporter facade = facadeFactory.createHibernateMappingExporter(hibernateMappingExporter);
Assert.assertSame(hibernateMappingExporter, ((IFacade) facade).getTarget());
}
use of org.jboss.tools.hibernate.runtime.spi.IHibernateMappingExporter in project jbosstools-hibernate by jbosstools.
the class ServiceImplTest method testNewHibernateMappingExporter.
@Test
public void testNewHibernateMappingExporter() {
IConfiguration configuration = service.newDefaultConfiguration();
File file = new File("");
IHibernateMappingExporter hibernateMappingExporter = service.newHibernateMappingExporter(configuration, file);
Configuration cfg = (Configuration) ((IFacade) configuration).getTarget();
HibernateMappingExporterExtension hmee = (HibernateMappingExporterExtension) ((IFacade) hibernateMappingExporter).getTarget();
Assert.assertSame(file, hmee.getOutputDirectory());
Assert.assertSame(cfg, hmee.getConfiguration());
}
use of org.jboss.tools.hibernate.runtime.spi.IHibernateMappingExporter in project jbosstools-hibernate by jbosstools.
the class ServiceImplTest method testNewHibernateMappingExporter.
@Test
public void testNewHibernateMappingExporter() {
IConfiguration configuration = service.newDefaultConfiguration();
File file = new File("");
IHibernateMappingExporter hibernateMappingExporter = service.newHibernateMappingExporter(configuration, file);
HibernateMappingExporterExtension hmee = (HibernateMappingExporterExtension) ((IFacade) hibernateMappingExporter).getTarget();
Assert.assertSame(file, hmee.getOutputDirectory());
Assert.assertSame(((ConfigurationFacadeImpl) configuration).getMetadata(), hmee.getMetadata());
}
Aggregations