Author: jpeterka
Date: 2010-03-25 08:24:52 -0400 (Thu, 25 Mar 2010)
New Revision: 21017
Modified:
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hibernate/ui/bot/testcase/DaliTest.java
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hibernate/ui/bot/testsuite/HibernateTest.java
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hibernate/ui/bot/testsuite/Project.java
Log:
JPA bot tests update (DDL generation, perspective check,... )
Modified:
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hibernate/ui/bot/testcase/DaliTest.java
===================================================================
---
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hibernate/ui/bot/testcase/DaliTest.java 2010-03-25
11:49:06 UTC (rev 21016)
+++
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hibernate/ui/bot/testcase/DaliTest.java 2010-03-25
12:24:52 UTC (rev 21017)
@@ -1,18 +1,21 @@
- /*******************************************************************************
- * Copyright (c) 2007-2009 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at
http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributor:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
+/*******************************************************************************
+ * Copyright (c) 2007-2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
package org.jboss.tools.hibernate.ui.bot.testcase;
+import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
import org.jboss.tools.hibernate.ui.bot.testsuite.HibernateTest;
import org.jboss.tools.hibernate.ui.bot.testsuite.Project;
+import org.jboss.tools.ui.bot.ext.helper.ContextMenuHelper;
import org.jboss.tools.ui.bot.ext.types.EntityType;
import org.jboss.tools.ui.bot.ext.types.IDELabel;
import org.jboss.tools.ui.bot.ext.types.PerspectiveType;
@@ -24,75 +27,108 @@
@RunWith(SWTBotJunit4ClassRunner.class)
public class DaliTest extends HibernateTest {
-
- static boolean projectCreated = false;
-
+
+ private static boolean projectCreated = false;
+
@BeforeClass
public static void prepare() {
- bot.viewByTitle("Welcome").close();
+ bot.viewByTitle("Welcome").close();
eclipse.openPerspective(PerspectiveType.JPA);
util.waitForNonIgnoredJobs();
}
-
+
/**
- * TC 22
+ * TC 22 - Test creates JPA Project
*/
@Test
public void createJPAProject() {
- if (projectCreated) return;
-
- EntityType type = EntityType.JPA_PROJECT;
+ if (projectCreated)
+ return;
+
+ EntityType type = EntityType.JPA_PROJECT;
eclipse.createNew(type);
-
+
// JPA Project Page
eclipse.waitForShell("New JPA Project");
bot.textWithLabel("Project name:").setText(Project.JPA_PRJ_NAME);
bot.button(IDELabel.Button.NEXT).click();
-
+
// Java Page
bot.button(IDELabel.Button.NEXT).click();
-
- // JPA Facet Page
+
+ // JPA Facet Page
bot.comboBoxInGroup("Platform").setSelection("Hibernate");
// Finish
bot.button(IDELabel.Button.FINISH).click();
eclipse.waitForClosedShell(bot.shell("New JPA Project"));
util.waitForNonIgnoredJobs();
-
+
projectCreated = true;
}
-
- @Test
+ /**
+ * Test open persistence.xml of JPA project
+ */
+ @Test
public void openPersitenceXML() {
ProjectExplorer explorer = new ProjectExplorer();
- explorer.openFile(Project.JPA_PRJ_NAME, "JPA Content",
"persistence.xml");
+ explorer.openFile(Project.JPA_PRJ_NAME, "JPA Content",
+ "persistence.xml");
}
-
+
/**
- * TC 24
+ * TC 24 - Test generates DDL file
*/
@Test
public void generateDDL() {
-
+ // Select project
+ SWTBotView viewBot = bot.viewByTitle(IDELabel.View.PROJECT_EXPLORER);
+ SWTBotTree tree = viewBot.bot().tree().select(Project.JPA_PRJ_NAME);
+ // JPA Tools -> Generate Tables From Entities
+ ContextMenuHelper.clickContextMenu(tree, "JPA Tools",
+ "Generate Tables from Entities...");
+
+ // DDL Generation Dialog
+ String outputDir = Project.JPA_PRJ_NAME + "/" + Project.DDL_OUTPUT;
+ bot.textWithLabel("Output directory:").setText(outputDir);
+ bot.textWithLabel("File name").setText(Project.DDL_OUTPUT);
+
+ bot.button(IDELabel.Button.FINISH).click();
+
+ // Check file
+ ProjectExplorer explorer = new ProjectExplorer();
+ explorer.openFile(Project.JPA_PRJ_NAME, Project.DDL_OUTPUT,
+ Project.DDL_FILENAME);
}
/**
- * TC 24
+ * TC 24 - Test for generating Entities from Tables
*/
@Test
public void generateEntities() {
+ // Select project
+ SWTBotView viewBot = bot.viewByTitle(IDELabel.View.PROJECT_EXPLORER);
+ SWTBotTree tree = viewBot.bot().tree().select(Project.JPA_PRJ_NAME);
+ // JPA Tools -> Generate Tables From Entities
+ ContextMenuHelper.clickContextMenu(tree, "JPA Tools",
+ "Generate Entities from Tables...");
+
+ // Generation Entities dialog
+ bot.textWithLabel("Package:").setText(Project.ENTITIES_PACKAGE);
+ bot.button(IDELabel.Button.FINISH).click();
}
/**
- * TC 23
+ * TC 23 - Check JPA perspective views
*/
@Test
public void checkJPAPerspective() {
-
+ bot.viewByTitle("JPA Structure").setFocus();
+ bot.viewByTitle("JPA Details").setFocus();
+ bot.viewByTitle("Data Source Explorer").setFocus();
}
/**
@@ -100,7 +136,9 @@
*/
@Test
public void checkCAInConfigurationEditor() {
+ bot.editorByTitle("persistence.xml").show();
+ // TODO - Multipage editor bot support needed first
}
/**
@@ -108,19 +146,13 @@
*/
@Test
public void checkCAInMappingEditor() {
+ // TODO - Multipage editor bot support needed first
}
-
- public static boolean isPRojectCreated() {
- if (projectCreated) {
- log.info("JPA Project is already created");
- }
- return projectCreated;
- }
@AfterClass
public static void cleanup() {
-
+ log.info("JPA DaliTest cleanup");
+ bot.sleep(TIME_5S);
}
-
}
Modified:
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hibernate/ui/bot/testsuite/HibernateTest.java
===================================================================
---
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hibernate/ui/bot/testsuite/HibernateTest.java 2010-03-25
11:49:06 UTC (rev 21016)
+++
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hibernate/ui/bot/testsuite/HibernateTest.java 2010-03-25
12:24:52 UTC (rev 21017)
@@ -11,7 +11,6 @@
package org.jboss.tools.hibernate.ui.bot.testsuite;
import static org.eclipse.swtbot.eclipse.finder.matchers.WithPartName.withPartName;
-import static org.junit.Assert.fail;
import java.io.File;
import java.io.FileInputStream;
Modified:
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hibernate/ui/bot/testsuite/Project.java
===================================================================
---
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hibernate/ui/bot/testsuite/Project.java 2010-03-25
11:49:06 UTC (rev 21016)
+++
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hibernate/ui/bot/testsuite/Project.java 2010-03-25
12:24:52 UTC (rev 21017)
@@ -30,4 +30,7 @@
// JPA Project
public static final String JPA_PRJ_NAME = "jpatest1";
+ public static final String DDL_OUTPUT = "src";
+ public static final String DDL_FILENAME = "test_schema.dll";
+ public static final String ENTITIES_PACKAGE = "org.entities";
}