summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPetya Sabeva2013-04-11 01:54:28 (EDT)
committerPetya Sabeva2013-04-11 01:54:28 (EDT)
commitfbf8686da1fff6c8bf0916ef3c5a1b5b1f2aa63a (patch)
tree213268cbc2870fd48788f26847e7b3a15ecc2b02
parentd175cc17569ea3d92458d6ef370ededd52f50743 (diff)
downloadwebtools.dali-fbf8686da1fff6c8bf0916ef3c5a1b5b1f2aa63a.zip
webtools.dali-fbf8686da1fff6c8bf0916ef3c5a1b5b1f2aa63a.tar.gz
webtools.dali-fbf8686da1fff6c8bf0916ef3c5a1b5b1f2aa63a.tar.bz2
Fix tests.
-rw-r--r--jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/internal/AbstractSwtBotEditorTest.java80
-rw-r--r--jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/utils/EditorProxy.java9
2 files changed, 53 insertions, 36 deletions
diff --git a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/internal/AbstractSwtBotEditorTest.java b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/internal/AbstractSwtBotEditorTest.java
index dbd0ad9..e9fe53a 100644
--- a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/internal/AbstractSwtBotEditorTest.java
+++ b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/internal/AbstractSwtBotEditorTest.java
@@ -8,6 +8,7 @@ import java.util.Iterator;
import junit.framework.ComparisonFailure;
import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jpt.jpa.core.JpaProject;
@@ -59,38 +60,12 @@ public class AbstractSwtBotEditorTest extends SWTBotGefTestCase{
}
private static void createJPa20Project(String name, String version, boolean withOrmXml) throws Exception{
- SWTBotPreferences.TIMEOUT = 1000;
- try {
- bot.viewByTitle("Welcome").close();
- } catch (Exception e) {
- // ignore
- } finally {
- SWTBotPreferences.TIMEOUT = 5000;
- }
- workbenchBot.perspectiveByLabel("JPA").activate();
- bot.closeAllEditors();
+ closeWelcomeScreen();
- factory = JPACreateFactory.instance();
- if(version.equals("1.0")){
- jpaProject = factory.createJPAProject(name);
- } else {
- jpaProject = factory.createJPA20Project(name);
- }
- assertNotNull(jpaProject);
- assertEquals(name, jpaProject.getName());
- editorProxy = new EditorProxy(workbenchBot, bot);
+ createProject(name, version);
if(withOrmXml) {
- JPACreateFactory.waitNonSystemJobs();
- jpaDiagramEditorPropertiesPage(jpaProject.getName());
-
- JPACreateFactory.waitNonSystemJobs();
-
- jpaProject.getProject().refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
- //assert that the orm.xml file exists.
- ormXml = getOrmXMl(jpaProject);
- assertNotNull(ormXml);
- editorProxy.setOrmXml(ormXml);
+ setOrmXml();
}
jpaDiagramEditor = editorProxy.openDiagramOnJPAProjectNode(
@@ -105,6 +80,45 @@ public class AbstractSwtBotEditorTest extends SWTBotGefTestCase{
Thread.sleep(2000);
}
+
+ private static void setOrmXml() throws InterruptedException, CoreException {
+ JPACreateFactory.waitNonSystemJobs();
+ jpaDiagramEditorPropertiesPage(jpaProject.getName());
+
+ JPACreateFactory.waitNonSystemJobs();
+
+ jpaProject.getProject().refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
+ //assert that the orm.xml file exists.
+ ormXml = getOrmXMl(jpaProject);
+ assertNotNull(ormXml);
+ editorProxy.setOrmXml(ormXml);
+ }
+
+ private static void createProject(String name, String version)
+ throws CoreException {
+ factory = JPACreateFactory.instance();
+ if(version.equals("1.0")){
+ jpaProject = factory.createJPAProject(name);
+ } else {
+ jpaProject = factory.createJPA20Project(name);
+ }
+ assertNotNull(jpaProject);
+ assertEquals(name, jpaProject.getName());
+ editorProxy = new EditorProxy(workbenchBot, bot);
+ }
+
+ private static void closeWelcomeScreen() {
+ SWTBotPreferences.TIMEOUT = 1000;
+ try {
+ bot.viewByTitle("Welcome").close();
+ } catch (Exception e) {
+ // ignore
+ } finally {
+ SWTBotPreferences.TIMEOUT = 5000;
+ }
+ workbenchBot.perspectiveByLabel("JPA").activate();
+ bot.closeAllEditors();
+ }
private static void jpaDiagramEditorPropertiesPage(String name) {
SWTBot propertiesPageBot = ContextMenuHelper.openProjectProperties(workbenchBot, name);
@@ -218,21 +232,15 @@ public class AbstractSwtBotEditorTest extends SWTBotGefTestCase{
editorProxy.deleteResources(jpaProject, ormXml!=null);
}
- private static OrmXml getOrmXMl(JpaProject jpaProject){
- jpaProject.getContextModelRoot().synchronizeWithResourceModel();
-
+ private static OrmXml getOrmXMl(JpaProject jpaProject){
try {
JPACreateFactory.waitNonSystemJobs();
} catch (InterruptedException e) {
- // TODO Auto-generated catch block
e.printStackTrace();
}
PersistenceUnit unit = JpaArtifactFactory.instance().getPersistenceUnit(jpaProject);
assertNotNull(unit);
- unit.synchronizeWithResourceModel();
- unit.update();
-
assertTrue(unit.getMappingFileRefsSize() > 0);
if(unit.getMappingFileRefsSize() == 0)
diff --git a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/utils/EditorProxy.java b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/utils/EditorProxy.java
index fd3389b..05961a7 100644
--- a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/utils/EditorProxy.java
+++ b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/utils/EditorProxy.java
@@ -147,13 +147,22 @@ public class EditorProxy {
}
public SWTBotGefEditor openDiagramOnJPAProjectNode(String name) {
+ JPACreateFactory.waitBuildAndRerfreshJobs();
+ try {
+ JPACreateFactory.waitNonSystemJobs();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+
SWTBotTree projectTree = workbenchBot.viewByTitle("Project Explorer")
.bot().tree();
projectTree.getTreeItem(name).select();
ContextMenuHelper.clickContextMenu(projectTree, "JPA Tools",
"Open Diagram");
+ waitASecond();
SWTBotGefEditor jpaDiagramEditor = bot.gefEditor(name);
+ assertNotNull(jpaDiagramEditor);
assertFalse("Editor must not be dirty!", jpaDiagramEditor.isDirty());
return jpaDiagramEditor;
}