use of org.jboss.tools.hibernate.reddeer.editor.JpaXmlEditor 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));
}
use of org.jboss.tools.hibernate.reddeer.editor.JpaXmlEditor in project jbosstools-hibernate by jbosstools.
the class ProjectConfigurationFactory method checkPersistenceXML.
/**
* Check persistence.xml
* @param prj project name
*/
public static void checkPersistenceXML(String prj) {
log.info("Open persistence xml file");
ProjectExplorer pe = new ProjectExplorer();
pe.open();
pe.getProject(prj).getProjectItem("JPA Content", "persistence.xml").open();
log.info("In editor set some hibernate properties on hibernate tab");
JpaXmlEditor pexml = new JpaXmlEditor();
String sourceText = pexml.getSourceText();
pexml.close();
assertTrue("persistence.xml cannot be empty", sourceText.length() > 0);
}
Aggregations