use of org.jboss.tools.hibernate.ui.bot.test.XPathHelper in project jbosstools-hibernate by jbosstools.
the class MappingFileTest method createMappingFileFromPackage.
@Test
public void createMappingFileFromPackage() {
ProjectUtils.getPackage(PRJ, PCKG).select();
NewHibernateMappingFileWizard wizard = new NewHibernateMappingFileWizard();
wizard.open();
NewHibernateMappingElementsSelectionPage2 selPage = new NewHibernateMappingElementsSelectionPage2(wizard);
selPage.selectItem(PCKG);
wizard.next();
NewHibernateMappingFilePage files = new NewHibernateMappingFilePage(wizard);
assertEquals(2, files.getClasses().size());
wizard.next();
NewHibernateMappingPreviewPage preview = new NewHibernateMappingPreviewPage(wizard);
assertTrue("Preview text cannot be empty", !preview.getPreviewText().equals(""));
wizard.finish();
ProjectExplorer pe = new ProjectExplorer();
pe.open();
assertTrue("Hbm.xml not generated: Known issue(s): JBIDE-18769, JBIDE-20042", containsItem(PCKG, "Dog.hbm.xml"));
ProjectUtils.getItem(PRJ, PCKG, "Dog.hbm.xml").open();
Hibernate3CompoundEditor hme = new Hibernate3CompoundEditor("Dog.hbm.xml");
hme.activateSourceTab();
String sourceText = hme.getSourceText();
XPathHelper xph = XPathHelper.getInstance();
String table = xph.getMappingFileTable(PCKG + ".Dog", sourceText);
assertTrue(table.equals("DOG"));
ProjectUtils.getItem(PRJ, PCKG, "Owner.hbm.xml").open();
hme = new Hibernate3CompoundEditor("Owner.hbm.xml");
hme.activateSourceTab();
sourceText = hme.getSourceText();
table = xph.getMappingFileTable(PCKG + ".Owner", sourceText);
assertEquals("OWNER", table);
}
use of org.jboss.tools.hibernate.ui.bot.test.XPathHelper in project jbosstools-hibernate by jbosstools.
the class MappingFileTest method createMappingFileFromFile.
@Test
public void createMappingFileFromFile() {
ProjectUtils.getItem(PRJ, PCKG_CLZ, "Owner.java").select();
NewHibernateMappingFileWizard wizard = new NewHibernateMappingFileWizard();
wizard.open();
NewHibernateMappingElementsSelectionPage2 selPage = new NewHibernateMappingElementsSelectionPage2(wizard);
selPage.selectItem("Owner");
wizard.next();
NewHibernateMappingFilePage files = new NewHibernateMappingFilePage(wizard);
files.selectClasses("Owner");
wizard.next();
NewHibernateMappingPreviewPage preview = new NewHibernateMappingPreviewPage(wizard);
assertTrue("Preview text cannot be empty", !preview.getPreviewText().equals(""));
wizard.finish();
ProjectExplorer pe = new ProjectExplorer();
pe.open();
assertTrue("Hbm.xml not generated: Known issue(s): JBIDE-18769, JBIDE-20042", containsItem(PCKG_CLZ, "Owner.hbm.xml"));
ProjectUtils.getItem(PRJ, PCKG_CLZ, "Owner.hbm.xml").open();
String fileName = "Owner.hbm.xml";
Hibernate3CompoundEditor hme = new Hibernate3CompoundEditor(fileName);
hme.activateSourceTab();
String sourceText = hme.getSourceText();
XPathHelper xph = XPathHelper.getInstance();
String table = xph.getMappingFileTable(PCKG_CLZ + ".Owner", sourceText);
assertEquals("OWNER", table);
}
use of org.jboss.tools.hibernate.ui.bot.test.XPathHelper in project jbosstools-hibernate by jbosstools.
the class PersistenceXMLFileTest method editPersistenceXMLFile.
@Test
public void editPersistenceXMLFile() {
prepare();
ProjectExplorer pe = new ProjectExplorer();
pe.open();
pe.getProject(prj).getProjectItem("src", "META-INF", "persistence.xml").open();
JpaXmlEditor pexml = new JpaXmlEditor();
pexml.setHibernateUsername("sa");
pexml.setHibernateDialect("H2");
pexml.save();
String usernameProp = "hibernate.connection.username";
String dialectProp = "hibernate.dialect";
String usernameExpected = "sa";
String dialectExpected = "org.hibernate.dialect.H2Dialect";
XPathHelper xh = XPathHelper.getInstance();
String text = pexml.getSourceText();
String usrnameVal = xh.getPersistencePropertyValue(usernameProp, text);
assertTrue("sa value is expected", usrnameVal.equals(usernameExpected));
String dialectVal = xh.getPersistencePropertyValue(dialectProp, text);
assertTrue("H2 value is expected", dialectVal.equals(dialectExpected));
}
Aggregations