Search in sources :

Example 1 with JpaXmlEditor

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));
}
Also used : ProjectExplorer(org.eclipse.reddeer.eclipse.ui.navigator.resources.ProjectExplorer) XPathHelper(org.jboss.tools.hibernate.ui.bot.test.XPathHelper) JpaXmlEditor(org.jboss.tools.hibernate.reddeer.editor.JpaXmlEditor) Test(org.junit.Test)

Example 2 with JpaXmlEditor

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);
}
Also used : ProjectExplorer(org.eclipse.reddeer.eclipse.ui.navigator.resources.ProjectExplorer) JpaXmlEditor(org.jboss.tools.hibernate.reddeer.editor.JpaXmlEditor)

Aggregations

ProjectExplorer (org.eclipse.reddeer.eclipse.ui.navigator.resources.ProjectExplorer)2 JpaXmlEditor (org.jboss.tools.hibernate.reddeer.editor.JpaXmlEditor)2 XPathHelper (org.jboss.tools.hibernate.ui.bot.test.XPathHelper)1 Test (org.junit.Test)1