[jbosstools-commits] JBoss Tools SVN: r39556 - in trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hb/ui/bot: suite and 2 other directories.

jbosstools-commits at lists.jboss.org jbosstools-commits at lists.jboss.org
Fri Mar 16 06:58:35 EDT 2012


Author: jpeterka
Date: 2012-03-16 06:58:34 -0400 (Fri, 16 Mar 2012)
New Revision: 39556

Added:
   trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hb/ui/bot/common/ConfigurationFile.java
   trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hb/ui/bot/test/configuration/
   trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hb/ui/bot/test/configuration/CreateConfigurationFileTest.java
   trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hb/ui/bot/test/configuration/EditConfigurationFileTest.java
Removed:
   trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hb/ui/bot/test/ConfigurationFileTest.java
Modified:
   trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hb/ui/bot/suite/ConfigurationFileSuite.java
Log:
Hibernate isolated create/edit configuration file tests added

Added: trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hb/ui/bot/common/ConfigurationFile.java
===================================================================
--- trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hb/ui/bot/common/ConfigurationFile.java	                        (rev 0)
+++ trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hb/ui/bot/common/ConfigurationFile.java	2012-03-16 10:58:34 UTC (rev 39556)
@@ -0,0 +1,20 @@
+package org.jboss.tools.hb.ui.bot.common;
+
+import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
+import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
+import org.jboss.tools.ui.bot.ext.SWTBotExt;
+import org.jboss.tools.ui.bot.ext.SWTOpenExt;
+import org.jboss.tools.ui.bot.ext.gen.ActionItem;
+
+public class ConfigurationFile {
+	
+	public static void open(String... path) {
+		SWTOpenExt open = new SWTOpenExt(new SWTBotExt());
+		SWTBotView pv = open
+				.viewOpen(ActionItem.View.GeneralProjectExplorer.LABEL);
+		
+		Tree.open(pv.bot(), path);
+		SWTWorkbenchBot bot = new SWTWorkbenchBot();
+		bot.editorByTitle(path[path.length - 1]).show();
+	}
+}


Property changes on: trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hb/ui/bot/common/ConfigurationFile.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Modified: trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hb/ui/bot/suite/ConfigurationFileSuite.java
===================================================================
--- trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hb/ui/bot/suite/ConfigurationFileSuite.java	2012-03-16 10:28:27 UTC (rev 39555)
+++ trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hb/ui/bot/suite/ConfigurationFileSuite.java	2012-03-16 10:58:34 UTC (rev 39556)
@@ -1,12 +1,15 @@
 package org.jboss.tools.hb.ui.bot.suite;
 
-import org.jboss.tools.hb.ui.bot.test.ConfigurationFileTest;
+import org.jboss.tools.hb.ui.bot.test.configuration.CreateConfigurationFileTest;
+import org.jboss.tools.hb.ui.bot.test.configuration.EditConfigurationFileTest;
 import org.jboss.tools.ui.bot.ext.RequirementAwareSuite;
 import org.junit.runner.RunWith;
 import org.junit.runners.Suite.SuiteClasses;
 
 @RunWith(RequirementAwareSuite.class)
- at SuiteClasses({ConfigurationFileTest.class})
+//@SuiteClasses({CreateConfigurationFileTest.class})
+//@SuiteClasses({EditConfigurationFileTest.class})
+ at SuiteClasses({CreateConfigurationFileTest.class, EditConfigurationFileTest.class})
 public class ConfigurationFileSuite {
 
 }

Deleted: trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hb/ui/bot/test/ConfigurationFileTest.java
===================================================================
--- trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hb/ui/bot/test/ConfigurationFileTest.java	2012-03-16 10:28:27 UTC (rev 39555)
+++ trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hb/ui/bot/test/ConfigurationFileTest.java	2012-03-16 10:58:34 UTC (rev 39556)
@@ -1,105 +0,0 @@
-package org.jboss.tools.hb.ui.bot.test;
-
-import static org.eclipse.swtbot.swt.finder.waits.Conditions.shellCloses;
-
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swtbot.eclipse.finder.matchers.WidgetMatcherFactory;
-import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotCheckBox;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
-import org.hamcrest.Matcher;
-import org.jboss.tools.hb.ui.bot.common.Tree;
-import org.jboss.tools.ui.bot.ext.config.Annotations.Require;
-import org.jboss.tools.ui.bot.ext.config.TestConfigurator;
-import org.jboss.tools.ui.bot.ext.gen.ActionItem;
-import org.jboss.tools.ui.bot.ext.helper.DatabaseHelper;
-import org.jboss.tools.ui.bot.ext.types.EntityType;
-import org.jboss.tools.ui.bot.ext.types.IDELabel;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-/**
- * Hibernate configuration ui bot test
- * @author jpeterka
- *
- */
- at Require
-public class ConfigurationFileTest extends HibernateBaseTest {
-
-	@BeforeClass
-	public static void beforeClass() {
-		eclipse.closeView(IDELabel.View.WELCOME);
-		eclipse.closeView(IDELabel.View.JBOSS_CENTRAL);
-		eclipse.closeAllEditors();
-		util.waitForAll();
-	}
-
-	@Test
-	public void emptyTest() {
-		assertTrue(true);
-	}
-
-	@Test
-	public void configurationFileTest() {
-		emptyErrorLog();
-		importTestProject("/resources/prj/hibernate35");
-		createHBConfiguration();
-		openHBConfiguration();
-		checkErrorLog();
-	}
-
-	private void createHBConfiguration() {
-		SWTBotView pv = open
-				.viewOpen(ActionItem.View.GeneralProjectExplorer.LABEL);
-		Tree.select(pv.bot(), "hibernate35", "cfg");
-
-		eclipse.createNew(EntityType.HIBERNATE_CONFIGURATION_FILE);
-		bot.textWithLabel(IDELabel.HBConfigurationWizard.FILE_NAME).setText(
-				"hibernate.cfg.xml");
-		bot.button(IDELabel.Button.NEXT).click();
-
-		// Create new configuration file
-		String dialect = DatabaseHelper
-				.getDialect(TestConfigurator.currentConfig.getDB().dbType);
-		bot.comboBoxWithLabel(IDELabel.HBConsoleWizard.DATABASE_DIALECT)
-				.setSelection(dialect);
-		String drvClass = DatabaseHelper
-				.getDriverClass(TestConfigurator.currentConfig.getDB().dbType);
-		bot.comboBoxWithLabel(IDELabel.HBConsoleWizard.DRIVER_CLASS)
-				.setSelection(drvClass);
-		String jdbc = TestConfigurator.currentConfig.getDB().jdbcString;
-		bot.comboBoxWithLabel(IDELabel.HBConsoleWizard.CONNECTION_URL).setText(
-				jdbc);
-
-		// Create console configuration
-		Matcher<Button> matcher = WidgetMatcherFactory
-				.withText(IDELabel.HBConsoleWizard.CREATE_CONSOLE_CONFIGURATION);
-		Button button = bot.widget(matcher);
-		SWTBotCheckBox cb = new SWTBotCheckBox(button);
-
-		if (!cb.isChecked())
-			cb.click();
-
-		SWTBotShell shell = bot.activeShell();
-		log.info("Active shell:" + shell.getText());
-		bot.button(IDELabel.Button.FINISH).click();
-
-		bot.waitUntil(shellCloses(shell));
-	}
-
-	private void openHBConfiguration() {
-
-		SWTBotView pv = open
-				.viewOpen(ActionItem.View.GeneralProjectExplorer.LABEL);
-		Tree.select(pv.bot(), "hibernate35", "cfg", "hibernate.cfg.xml");
-		bot.editorByTitle("hibernate.cfg.xml").show();
-
-	}
-
-	@AfterClass
-	public static void afterClass() {
-		// wait for all jobs
-		util.waitForAll();
-	}
-}
\ No newline at end of file

Copied: trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hb/ui/bot/test/configuration/CreateConfigurationFileTest.java (from rev 39553, trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hb/ui/bot/test/ConfigurationFileTest.java)
===================================================================
--- trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hb/ui/bot/test/configuration/CreateConfigurationFileTest.java	                        (rev 0)
+++ trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hb/ui/bot/test/configuration/CreateConfigurationFileTest.java	2012-03-16 10:58:34 UTC (rev 39556)
@@ -0,0 +1,83 @@
+package org.jboss.tools.hb.ui.bot.test.configuration;
+
+import static org.eclipse.swtbot.swt.finder.waits.Conditions.shellCloses;
+
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swtbot.eclipse.finder.matchers.WidgetMatcherFactory;
+import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotCheckBox;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
+import org.hamcrest.Matcher;
+import org.jboss.tools.hb.ui.bot.common.ConfigurationFile;
+import org.jboss.tools.hb.ui.bot.common.Tree;
+import org.jboss.tools.hb.ui.bot.test.HibernateBaseTest;
+import org.jboss.tools.ui.bot.ext.config.Annotations.Require;
+import org.jboss.tools.ui.bot.ext.config.TestConfigurator;
+import org.jboss.tools.ui.bot.ext.gen.ActionItem;
+import org.jboss.tools.ui.bot.ext.helper.DatabaseHelper;
+import org.jboss.tools.ui.bot.ext.types.EntityType;
+import org.jboss.tools.ui.bot.ext.types.IDELabel;
+import org.junit.Test;
+
+/**
+ * Hibernate create configuration ui bot test
+ * 
+ * @author jpeterka
+ * 
+ */
+ at Require
+public class CreateConfigurationFileTest extends HibernateBaseTest {
+
+	@Test
+	public void configurationFileTest() {
+		emptyErrorLog();
+		importTestProject("/resources/prj/hibernate35");
+		createHBConfiguration();
+		openHBConfiguration();
+		checkErrorLog();
+	}
+
+	private void createHBConfiguration() {
+		SWTBotView pv = open
+				.viewOpen(ActionItem.View.GeneralProjectExplorer.LABEL);
+		Tree.select(pv.bot(), "hibernate35", "cfg");
+
+		eclipse.createNew(EntityType.HIBERNATE_CONFIGURATION_FILE);
+		bot.textWithLabel(IDELabel.HBConfigurationWizard.FILE_NAME).setText(
+				"hibernate.cfg.xml");
+		bot.button(IDELabel.Button.NEXT).click();
+
+		// Create new configuration file
+		String dialect = DatabaseHelper
+				.getDialect(TestConfigurator.currentConfig.getDB().dbType);
+		bot.comboBoxWithLabel(IDELabel.HBConsoleWizard.DATABASE_DIALECT)
+				.setSelection(dialect);
+		String drvClass = DatabaseHelper
+				.getDriverClass(TestConfigurator.currentConfig.getDB().dbType);
+		bot.comboBoxWithLabel(IDELabel.HBConsoleWizard.DRIVER_CLASS)
+				.setSelection(drvClass);
+		String jdbc = TestConfigurator.currentConfig.getDB().jdbcString;
+		bot.comboBoxWithLabel(IDELabel.HBConsoleWizard.CONNECTION_URL).setText(
+				jdbc);
+
+		// Create console configuration
+		Matcher<Button> matcher = WidgetMatcherFactory
+				.withText(IDELabel.HBConsoleWizard.CREATE_CONSOLE_CONFIGURATION);
+		Button button = bot.widget(matcher);
+		SWTBotCheckBox cb = new SWTBotCheckBox(button);
+
+		if (!cb.isChecked())
+			cb.click();
+
+		SWTBotShell shell = bot.activeShell();
+		log.info("Active shell:" + shell.getText());
+		bot.button(IDELabel.Button.FINISH).click();
+
+		bot.waitUntil(shellCloses(shell));
+	}
+
+	private void openHBConfiguration() {
+		ConfigurationFile.open("hibernate35", "cfg", "hibernate.cfg.xml");
+	}
+
+}
\ No newline at end of file


Property changes on: trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hb/ui/bot/test/configuration/CreateConfigurationFileTest.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Added: trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hb/ui/bot/test/configuration/EditConfigurationFileTest.java
===================================================================
--- trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hb/ui/bot/test/configuration/EditConfigurationFileTest.java	                        (rev 0)
+++ trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hb/ui/bot/test/configuration/EditConfigurationFileTest.java	2012-03-16 10:58:34 UTC (rev 39556)
@@ -0,0 +1,109 @@
+package org.jboss.tools.hb.ui.bot.test.configuration;
+
+import java.util.List;
+
+import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor;
+import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
+import org.eclipse.swtbot.swt.finder.SWTBot;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
+import org.jboss.tools.hb.ui.bot.common.Tree;
+import org.jboss.tools.hb.ui.bot.test.HibernateBaseTest;
+import org.jboss.tools.ui.bot.ext.config.Annotations.Require;
+import org.jboss.tools.ui.bot.ext.gen.ActionItem;
+import org.jboss.tools.ui.bot.ext.helper.ContextMenuHelper;
+import org.jboss.tools.ui.bot.ext.parts.ObjectMultiPageEditorBot;
+import org.jboss.tools.ui.bot.ext.types.IDELabel;
+import org.junit.Test;
+
+/**
+ * Hibernate edit configuration ui bot test
+ * 
+ * @author jpeterka
+ * 
+ */
+ at Require(clearWorkspace = true, clearProjects = true)
+public class EditConfigurationFileTest extends HibernateBaseTest {
+
+	private final String hbcfg = "hibernate.cfg.xml";
+
+	@Test
+	public void emptyTest() {
+		assertTrue(true);
+	}
+
+	@Test
+	public void configurationFileTest() {
+		emptyErrorLog();
+		importTestProject("/resources/prj/hibernate35");
+		openHBConfiguration();
+		editHBConfiguration();
+		checkErrorLog();
+	}
+
+	private void openHBConfiguration() {
+
+		SWTBotView pv = open
+				.viewOpen(ActionItem.View.GeneralProjectExplorer.LABEL);
+		Tree.open(pv.bot(), "hibernate35", "src", hbcfg);
+		bot.editorByTitle(hbcfg).show();
+
+	}
+
+	private void editHBConfiguration() {
+		SWTBotEditor editor = bot.editorByTitle(hbcfg);
+		ObjectMultiPageEditorBot multiBot = new ObjectMultiPageEditorBot(hbcfg);
+
+		// Tabs availability
+		String[] pages = { "Session Factory", "Security", "Source" };
+		for (String page : pages) {
+			multiBot.selectPage(page);
+		}
+
+		// Create new security element
+		SWTBot localBot = editor.bot();
+		multiBot.selectPage(pages[1]);
+		SWTBotTree secTree = localBot.tree().select("Security");
+
+		ContextMenuHelper.clickContextMenu(secTree, "New", "Grant...");
+
+		// Filling Role, Entity-Name and Check action All *
+		String roleName = "role1";
+		String entityName = "entity1";
+
+		bot.textWithLabel("Role:*").setText("role1");
+		bot.textWithLabel("Entity-Name:*").setText("entity1");
+		SWTBotShell shell = bot.shell("Add Grant");
+
+		assertNotNull(shell);
+		SWTBot shellBot = new SWTBot(shell.widget);
+
+		SWTBotTree tree = shellBot.tree();
+		SWTBotTreeItem[] items = tree.getAllItems();
+		items[0].check();
+
+		shellBot.button(IDELabel.Button.FINISH).click();
+
+		// Click on Source tab for check
+		multiBot.selectPage(pages[2]);
+		List<String> lines = editor.toTextEditor().getLines();
+
+		boolean found = false;
+		String wanted = "<grant actions=\"*\" entity-name=\"" + entityName
+				+ "\" role=\"" + roleName + "\"/>";
+		System.out.println("Looking for:" + wanted);
+
+		for (String line : lines) {
+			System.out.println(line);
+			if (line.trim().equals(wanted)) {
+				found = true;
+				System.out.println("Found");
+			}
+		}
+
+		editor.saveAndClose();
+		assertTrue("Security element not found in xml", found);
+	}
+
+}
\ No newline at end of file


Property changes on: trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hb/ui/bot/test/configuration/EditConfigurationFileTest.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain



More information about the jbosstools-commits mailing list