Author: jpeterka
Date: 2010-12-21 04:30:55 -0500 (Tue, 21 Dec 2010)
New Revision: 27628
Modified:
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hibernate/ui/bot/testcase/CodeGenerationLauncherTest.java
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hibernate/ui/bot/testcase/ConfigurationContextTest.java
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hibernate/ui/bot/testcase/ConfigurationFileTest.java
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hibernate/ui/bot/testcase/ConsolePerspectiveTest.java
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hibernate/ui/bot/testcase/ConsoleTest.java
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hibernate/ui/bot/testcase/CriteriaEditorsTest.java
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/JIRATest.java
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hibernate/ui/bot/testcase/MappingFileTest.java
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hibernate/ui/bot/testcase/MappingsDiagramTest.java
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hibernate/ui/bot/testcase/ReverseEngineerFileTest.java
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hibernate/ui/bot/testcase/ViewsTest.java
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hibernate/ui/bot/testsuite/HibernateAllTests.java
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hibernate/ui/bot/testsuite/HibernateTest.java
Log:
Hibernate bot tests transfered to multi-db configurations
Modified:
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hibernate/ui/bot/testcase/CodeGenerationLauncherTest.java
===================================================================
---
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hibernate/ui/bot/testcase/CodeGenerationLauncherTest.java 2010-12-21
09:19:27 UTC (rev 27627)
+++
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hibernate/ui/bot/testcase/CodeGenerationLauncherTest.java 2010-12-21
09:30:55 UTC (rev 27628)
@@ -12,22 +12,22 @@
import org.eclipse.swt.widgets.Button;
import org.eclipse.swtbot.eclipse.finder.matchers.WidgetMatcherFactory;
-import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotCheckBox;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
import org.hamcrest.Matcher;
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.config.Annotations.DB;
+import org.jboss.tools.ui.bot.ext.config.Annotations.SWTBotTestRequires;
import org.jboss.tools.ui.bot.ext.gen.ActionItem;
import org.jboss.tools.ui.bot.ext.types.IDELabel;
import org.jboss.tools.ui.bot.ext.types.PerspectiveType;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
-import org.junit.runner.RunWith;
-(a)RunWith(SWTBotJunit4ClassRunner.class)
+@SWTBotTestRequires( db=@DB, perspective="Hibernate")
public class CodeGenerationLauncherTest extends HibernateTest {
SWTBotShell mainShell = null;
@@ -44,7 +44,6 @@
prepareProject();
prepareConsole();
- prepareDatabase();
util.waitForNonIgnoredJobs();
}
Modified:
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hibernate/ui/bot/testcase/ConfigurationContextTest.java
===================================================================
---
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hibernate/ui/bot/testcase/ConfigurationContextTest.java 2010-12-21
09:19:27 UTC (rev 27627)
+++
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hibernate/ui/bot/testcase/ConfigurationContextTest.java 2010-12-21
09:30:55 UTC (rev 27628)
@@ -10,12 +10,11 @@
******************************************************************************/
package org.jboss.tools.hibernate.ui.bot.testcase;
-import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
import org.jboss.tools.hibernate.ui.bot.testsuite.HibernateTest;
+import org.jboss.tools.ui.bot.ext.config.Annotations.SWTBotTestRequires;
import org.junit.Test;
-import org.junit.runner.RunWith;
-(a)RunWith(SWTBotJunit4ClassRunner.class)
+@SWTBotTestRequires( clearProjects = false, perspective="Hibernate")
public class ConfigurationContextTest extends HibernateTest {
/**
Modified:
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hibernate/ui/bot/testcase/ConfigurationFileTest.java
===================================================================
---
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hibernate/ui/bot/testcase/ConfigurationFileTest.java 2010-12-21
09:19:27 UTC (rev 27627)
+++
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hibernate/ui/bot/testcase/ConfigurationFileTest.java 2010-12-21
09:30:55 UTC (rev 27628)
@@ -1,13 +1,13 @@
- /*******************************************************************************
- * 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 java.io.IOException;
@@ -20,7 +20,6 @@
import org.eclipse.swtbot.eclipse.finder.matchers.WidgetMatcherFactory;
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor;
import org.eclipse.swtbot.swt.finder.SWTBot;
-import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotCheckBox;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
@@ -28,54 +27,61 @@
import org.hamcrest.Matcher;
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.config.Annotations.SWTBotTestRequires;
+import org.jboss.tools.ui.bot.ext.config.TestConfigurator;
import org.jboss.tools.ui.bot.ext.helper.ContextMenuHelper;
+import org.jboss.tools.ui.bot.ext.helper.DatabaseHelper;
import org.jboss.tools.ui.bot.ext.parts.ObjectMultiPageEditorBot;
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;
-import org.junit.runner.RunWith;
import org.xml.sax.SAXException;
-(a)RunWith(SWTBotJunit4ClassRunner.class)
+@SWTBotTestRequires(clearProjects = false, perspective="Hibernate")
public class ConfigurationFileTest extends HibernateTest {
@BeforeClass
public static void setUpTest() {
HibernateTest.prepareProject();
}
-
+
@AfterClass
- public static void tearDownTest() {
+ public static void tearDownTest() {
HibernateTest.clean();
- }
-
+ }
+
/**
* TC 02 - Create Hibernate Configuration file with predefined variables
*/
@Test
public void createFile() {
eclipse.createNew(EntityType.HIBERNATE_CONFIGURATION_FILE);
-
- eclipse.selectTreeLocation(Project.PROJECT_NAME,"src");
- bot.textWithLabel(IDELabel.HBConfigurationWizard.FILE_NAME).setText(Project.CONF_FILE_NAME2);
+
+ eclipse.selectTreeLocation(Project.PROJECT_NAME, "src");
+ bot.textWithLabel(IDELabel.HBConfigurationWizard.FILE_NAME).setText(
+ Project.CONF_FILE_NAME2);
bot.button(IDELabel.Button.NEXT).click();
// Create new configuration file
- bot.comboBoxWithLabel(IDELabel.HBConsoleWizard.DATABASE_DIALECT).setSelection(Project.DB_DIALECT);
- bot.comboBoxWithLabel(IDELabel.HBConsoleWizard.DRIVER_CLASS).setSelection(Project.DRIVER_CLASS);
- bot.comboBoxWithLabel(IDELabel.HBConsoleWizard.CONNECTION_URL).setText(Project.JDBC_STRING);
+ 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);
-
+ 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();
+
+ SWTBotShell shell = bot.activeShell();
log.info("Active shell:" + shell.getText());
bot.button(IDELabel.Button.FINISH).click();
eclipse.waitForClosedShell(shell);
@@ -84,97 +90,96 @@
/**
* TC 13
- * @throws ParserConfigurationException
- * @throws IOException
- * @throws SAXException
- * @throws XPathExpressionException
+ *
+ * @throws ParserConfigurationException
+ * @throws IOException
+ * @throws SAXException
+ * @throws XPathExpressionException
*/
@Test
/*
- * Edit Configuration file testcase. It checks: 1. Configuration file editor tabs
availability,...
+ * Edit Configuration file testcase. It checks: 1. Configuration file editor
+ * tabs availability,...
*/
- public void editFile() throws ParserConfigurationException, SAXException, IOException,
XPathExpressionException {
-
- SWTBotEditor editor = eclipse.openFile(Project.PROJECT_NAME, "src",
Project.CONF_FILE_NAME2);
- ObjectMultiPageEditorBot multiBot = new
ObjectMultiPageEditorBot(Project.CONF_FILE_NAME2);
+ public void editFile() throws ParserConfigurationException, SAXException,
+ IOException, XPathExpressionException {
- // 1. Tabs availability
- String[] pages = {"Session
Factory","Security","Source"};
- for ( String page : pages ) {
+ SWTBotEditor editor = eclipse.openFile(Project.PROJECT_NAME, "src",
+ Project.CONF_FILE_NAME2);
+ ObjectMultiPageEditorBot multiBot = new ObjectMultiPageEditorBot(
+ Project.CONF_FILE_NAME2);
+
+ // 1. Tabs availability
+ String[] pages = { "Session Factory", "Security",
"Source" };
+ for (String page : pages) {
multiBot.selectPage(page);
bot.sleep(TIME_500MS);
}
-
+
// 2. Test creating elements and properties
// TODO creating element impl.
-
- // 3. Create new security element
+
+ // 3. Create new security element
SWTBot localBot = editor.bot();
multiBot.selectPage(pages[1]);
SWTBotTree secTree = localBot.tree().select("Security");
ContextMenuHelper.clickContextMenu(secTree, "New", "Grant...");
-
+
// Fillin 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();
+
+ 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();
-
+
// XMLPath
/*
- // Convert editor text into InputStreamReader
- StringBuilder builder = new StringBuilder();
- for (String line : lines ) {
- builder.append(line);
- builder.append("\n");
- }
- ByteArrayInputStream bs = new ByteArrayInputStream(builder.toString().getBytes());
-
- DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
- dbf.setNamespaceAware(true);
- DocumentBuilder db;
- db = dbf.newDocumentBuilder();
- Document doc = db.parse(bs);
- XPath xpath = XPathFactory.newInstance().newXPath();
- XPathExpression expr = xpath.compile("/person/security/grant");
- Object result = expr.evaluate(doc, XPathConstants.NODESET);
- NodeList nodes = (NodeList) result;
- for ( int i = 0; i < nodes.getLength(); i++ )
- System.out.println(nodes.item(i).getNodeValue());
+ * // Convert editor text into InputStreamReader StringBuilder builder =
+ * new StringBuilder(); for (String line : lines ) {
+ * builder.append(line); builder.append("\n"); } ByteArrayInputStream bs
+ * = new ByteArrayInputStream(builder.toString().getBytes());
+ *
+ * DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ * dbf.setNamespaceAware(true); DocumentBuilder db; db =
+ * dbf.newDocumentBuilder(); Document doc = db.parse(bs); XPath xpath =
+ * XPathFactory.newInstance().newXPath(); XPathExpression expr =
+ * xpath.compile("/person/security/grant"); Object result =
+ * expr.evaluate(doc, XPathConstants.NODESET); NodeList nodes =
+ * (NodeList) result; for ( int i = 0; i < nodes.getLength(); i++ )
+ * System.out.println(nodes.item(i).getNodeValue());
+ */
+ // Search for security grant
- */
- // Search for security grant
-
boolean found = false;
- String wanted = "<grant actions=\"*\" entity-name=\"" +
entityName + "\" role=\"" + roleName + "\"/>";
+ 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);
+ }
+ }
+
+ editor.saveAndClose();
+ assertTrue("Security element not found in xml", found);
}
}
Modified:
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hibernate/ui/bot/testcase/ConsolePerspectiveTest.java
===================================================================
---
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hibernate/ui/bot/testcase/ConsolePerspectiveTest.java 2010-12-21
09:19:27 UTC (rev 27627)
+++
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hibernate/ui/bot/testcase/ConsolePerspectiveTest.java 2010-12-21
09:30:55 UTC (rev 27628)
@@ -10,14 +10,13 @@
******************************************************************************/
package org.jboss.tools.hibernate.ui.bot.testcase;
-import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
import org.jboss.tools.hibernate.ui.bot.testsuite.HibernateTest;
+import org.jboss.tools.ui.bot.ext.config.Annotations.SWTBotTestRequires;
import org.jboss.tools.ui.bot.ext.gen.ActionItem;
import org.jboss.tools.ui.bot.ext.types.IDELabel;
import org.junit.Test;
-import org.junit.runner.RunWith;
-(a)RunWith(SWTBotJunit4ClassRunner.class)
+@SWTBotTestRequires(clearProjects = false, perspective="Hibernate")
public class ConsolePerspectiveTest extends HibernateTest {
/**
Modified:
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hibernate/ui/bot/testcase/ConsoleTest.java
===================================================================
---
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hibernate/ui/bot/testcase/ConsoleTest.java 2010-12-21
09:19:27 UTC (rev 27627)
+++
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hibernate/ui/bot/testcase/ConsoleTest.java 2010-12-21
09:30:55 UTC (rev 27628)
@@ -11,22 +11,24 @@
package org.jboss.tools.hibernate.ui.bot.testcase;
import org.eclipse.swtbot.swt.finder.SWTBot;
-import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
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.SWTEclipseExt;
+import org.jboss.tools.ui.bot.ext.config.Annotations.DB;
+import org.jboss.tools.ui.bot.ext.config.Annotations.SWTBotTestRequires;
+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.jboss.tools.ui.bot.ext.types.ViewType;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
-import org.junit.runner.RunWith;
-(a)RunWith(SWTBotJunit4ClassRunner.class)
+@SWTBotTestRequires( clearProjects = false, db=@DB, perspective="Hibernate")
public class ConsoleTest extends HibernateTest {
@BeforeClass
@@ -83,10 +85,14 @@
bot.button(IDELabel.HBConsoleWizard.CREATE_NEW_BUTTON).click();
eclipse.selectTreeLocation(Project.PROJECT_NAME, "src");
bot.button(IDELabel.Button.NEXT).click();
- bot.comboBoxWithLabel(IDELabel.HBConsoleWizard.DATABASE_DIALECT).setSelection(Project.DB_DIALECT);
- bot.comboBoxWithLabel(IDELabel.HBConsoleWizard.DRIVER_CLASS).setSelection(Project.DRIVER_CLASS);
- bot.comboBoxWithLabel(IDELabel.HBConsoleWizard.CONNECTION_URL).setText(Project.JDBC_STRING);
+ 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);
+
SWTBotShell shell = bot.activeShell();
bot.button(IDELabel.Button.FINISH).click();
eclipse.waitForClosedShell(shell);
@@ -102,8 +108,8 @@
mainShell.activate();
bot.cTabItem(IDELabel.HBConsoleWizard.OPTIONS_TAB).activate();
-
- bot.comboBoxWithLabelInGroup("",
IDELabel.HBConsoleWizard.DATABASE_DIALECT).setSelection(Project.DB_DIALECT);
+ String dialect =
DatabaseHelper.getDialect(TestConfigurator.currentConfig.getDB().dbType);
+ bot.comboBoxWithLabelInGroup("",
IDELabel.HBConsoleWizard.DATABASE_DIALECT).setSelection(dialect);
log.info("HB Console Option tab DONE");
bot.sleep(TIME_1S);
}
Modified:
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hibernate/ui/bot/testcase/CriteriaEditorsTest.java
===================================================================
---
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hibernate/ui/bot/testcase/CriteriaEditorsTest.java 2010-12-21
09:19:27 UTC (rev 27627)
+++
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hibernate/ui/bot/testcase/CriteriaEditorsTest.java 2010-12-21
09:30:55 UTC (rev 27628)
@@ -10,12 +10,11 @@
******************************************************************************/
package org.jboss.tools.hibernate.ui.bot.testcase;
-import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
import org.jboss.tools.hibernate.ui.bot.testsuite.HibernateTest;
+import org.jboss.tools.ui.bot.ext.config.Annotations.SWTBotTestRequires;
import org.junit.Test;
-import org.junit.runner.RunWith;
-(a)RunWith(SWTBotJunit4ClassRunner.class)
+@SWTBotTestRequires(clearProjects = false, perspective="Hibernate")
public class CriteriaEditorsTest extends HibernateTest {
/**
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-12-21
09:19:27 UTC (rev 27627)
+++
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hibernate/ui/bot/testcase/DaliTest.java 2010-12-21
09:30:55 UTC (rev 27628)
@@ -10,12 +10,23 @@
******************************************************************************/
package org.jboss.tools.hibernate.ui.bot.testcase;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor;
+import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotMultiPageEditor;
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.config.Annotations.DB;
+import org.jboss.tools.ui.bot.ext.config.Annotations.SWTBotTestRequires;
+import org.jboss.tools.ui.bot.ext.config.Annotations.Server;
+import org.jboss.tools.ui.bot.ext.config.Annotations.ServerState;
+import org.jboss.tools.ui.bot.ext.config.TestConfigurator;
import org.jboss.tools.ui.bot.ext.helper.ContextMenuHelper;
+import org.jboss.tools.ui.bot.ext.helper.DatabaseHelper;
+import org.jboss.tools.ui.bot.ext.helper.StringHelper;
+import org.jboss.tools.ui.bot.ext.parts.ContentAssistBot;
+import org.jboss.tools.ui.bot.ext.parts.SWTBotEditorExt;
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;
@@ -23,10 +34,9 @@
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
-import org.junit.runner.RunWith;
import org.osgi.framework.Version;
-(a)RunWith(SWTBotJunit4ClassRunner.class)
+@SWTBotTestRequires( clearProjects = false, db=@DB, perspective="JPA" ,
server=@Server(state = ServerState.Present))
public class DaliTest extends HibernateTest {
private static boolean projectCreated = false;
@@ -37,7 +47,7 @@
eclipse.openPerspective(PerspectiveType.JPA);
util.waitForNonIgnoredJobs();
}
-
+
/**
* TC 22 - Test creates JPA Project
*/
@@ -51,7 +61,10 @@
// JPA Project Page
eclipse.waitForShell("New JPA Project");
- bot.textWithLabel("Project name:").setText(Project.JPA_PRJ_NAME);
+ bot.textWithLabel("Project name:").setText(Project.JPA_PRJ_NAME);
+ bot.comboBoxInGroup("Target
runtime").setSelection(TestConfigurator.currentConfig.getServer().getName());
+
+
bot.button(IDELabel.Button.NEXT).click();
// Java Page
@@ -64,7 +77,8 @@
else
bot.comboBoxInGroup("Platform").setSelection("Hibernate (JPA
2.x)");
- bot.comboBoxInGroup("JPA implementation").setSelection("Disable Library
Configuration");
+ bot.comboBoxInGroup("JPA implementation").setSelection("Library Provided
by Target Runtime");
+ bot.comboBoxInGroup("Connection").setSelection(TestConfigurator.currentConfig.getDB().name);
// Finish
bot.button(IDELabel.Button.FINISH).click();
@@ -103,10 +117,6 @@
bot.textWithLabel("File name").setText(Project.DDL_OUTPUT);
bot.button(IDELabel.Button.FINISH).click();
-
- // TODO
- // Check file
- // packageExplorer.openFile(Project.JPA_PRJ_NAME, Project.DDL_OUTPUT,
Project.DDL_FILENAME);
}
/**
@@ -125,6 +135,10 @@
// Generation Entities dialog
bot.textWithLabel("Package:").setText(Project.ENTITIES_PACKAGE);
bot.button(IDELabel.Button.FINISH).click();
+ util.waitForNonIgnoredJobs();
+
+ // Check generated entities
+ packageExplorer.openFile(Project.JPA_PRJ_NAME, "src",
Project.ENTITIES_PACKAGE, "Customers.java");
}
/**
@@ -137,28 +151,63 @@
bot.viewByTitle("Data Source Explorer").setFocus();
}
+
/**
- * TC 25
+ * TC 25 - Checking coding configuration in persistence.xml editor on xml page
*/
@Test
- public void checkCAInConfigurationEditor() {
- bot.editorByTitle("persistence.xml").show();
-
- // TODO - Multipage editor bot support needed first
+ public void checkCAInConfigurationEditorXML() {
+ SWTBotEditor editor = bot.editorByTitle("persistence.xml");
+ editor.show();
+ SWTBotMultiPageEditor mpe = new SWTBotMultiPageEditor(editor.getReference(), bot);
+ mpe.activatePage("Source");
+
+ // Code completion
+ String text = mpe.toTextEditor().getText();
+ StringHelper helper = new StringHelper(text);
+ Point p = helper.getPositionBefore("</persistence-unit>");
+ editor.toTextEditor().selectRange(p.y, p.x, 0);
+ editor.save();
+ SWTBotEditorExt editorExt = new SWTBotEditorExt(editor.getReference(), bot);
+ ContentAssistBot ca = new ContentAssistBot(editorExt);
+ ca.useProposal("class");
}
+
/**
- * TC 25
+ * TC 25 - Filling hibernate page on persistence.xml editor
*/
@Test
- public void checkCAInMappingEditor() {
- // TODO - Multipage editor bot support needed first
+ public void fillHibernatePage() {
+ SWTBotEditor editor = bot.editorByTitle("persistence.xml");
+ editor.show();
+ SWTBotMultiPageEditor mpe = new SWTBotMultiPageEditor(editor.getReference(), bot);
+ mpe.activatePage("Hibernate");
+ // Fill in
+ 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);
+ bot.textWithLabel("Username:").setText("sa");
+
+ editor.save();
+ mpe.activatePage("Source");
+
+ // Check xml content
+ String text = mpe.toTextEditor().getText();
+ StringHelper helper = new StringHelper(text);
+ String str = "<property name=\"hibernate.dialect\"
value=\"org.hibernate.dialect.HSQLDialect\"/>";
+ helper.getPositionBefore(str);
+ str = "<property name=\"hibernate.connection.driver_class\"
value=\"org.hsqldb.jdbcDriver\"/>";
+ helper.getPositionBefore(str);
+ bot.sleep(TIME_10S);
}
-
+
@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/testcase/JIRATest.java
===================================================================
---
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hibernate/ui/bot/testcase/JIRATest.java 2010-12-21
09:19:27 UTC (rev 27627)
+++
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hibernate/ui/bot/testcase/JIRATest.java 2010-12-21
09:30:55 UTC (rev 27628)
@@ -10,12 +10,12 @@
******************************************************************************/
package org.jboss.tools.hibernate.ui.bot.testcase;
-import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
import org.jboss.tools.hibernate.ui.bot.testsuite.HibernateTest;
+import org.jboss.tools.ui.bot.ext.config.Annotations.DB;
+import org.jboss.tools.ui.bot.ext.config.Annotations.SWTBotTestRequires;
import org.junit.Test;
-import org.junit.runner.RunWith;
-(a)RunWith(SWTBotJunit4ClassRunner.class)
+@SWTBotTestRequires( clearProjects = false, db=@DB, perspective="Hibernate")
public class JIRATest extends HibernateTest {
/**
Modified:
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hibernate/ui/bot/testcase/MappingFileTest.java
===================================================================
---
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hibernate/ui/bot/testcase/MappingFileTest.java 2010-12-21
09:19:27 UTC (rev 27627)
+++
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hibernate/ui/bot/testcase/MappingFileTest.java 2010-12-21
09:30:55 UTC (rev 27628)
@@ -13,10 +13,10 @@
import java.util.List;
import org.eclipse.swtbot.swt.finder.SWTBot;
-import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
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.config.Annotations.SWTBotTestRequires;
import org.jboss.tools.ui.bot.ext.parts.ObjectMultiPageEditorBot;
import org.jboss.tools.ui.bot.ext.parts.SWTBotEditorExt;
import org.jboss.tools.ui.bot.ext.types.EntityType;
@@ -24,9 +24,8 @@
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
-import org.junit.runner.RunWith;
-(a)RunWith(SWTBotJunit4ClassRunner.class)
+@SWTBotTestRequires( clearProjects = false, perspective="Hibernate")
public class MappingFileTest extends HibernateTest {
@BeforeClass
Modified:
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hibernate/ui/bot/testcase/MappingsDiagramTest.java
===================================================================
---
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hibernate/ui/bot/testcase/MappingsDiagramTest.java 2010-12-21
09:19:27 UTC (rev 27627)
+++
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hibernate/ui/bot/testcase/MappingsDiagramTest.java 2010-12-21
09:30:55 UTC (rev 27628)
@@ -10,12 +10,11 @@
******************************************************************************/
package org.jboss.tools.hibernate.ui.bot.testcase;
-import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
import org.jboss.tools.hibernate.ui.bot.testsuite.HibernateTest;
+import org.jboss.tools.ui.bot.ext.config.Annotations.SWTBotTestRequires;
import org.junit.Test;
-import org.junit.runner.RunWith;
-(a)RunWith(SWTBotJunit4ClassRunner.class)
+@SWTBotTestRequires(clearProjects = false, perspective="Hibernate")
public class MappingsDiagramTest extends HibernateTest {
/**
Modified:
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hibernate/ui/bot/testcase/ReverseEngineerFileTest.java
===================================================================
---
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hibernate/ui/bot/testcase/ReverseEngineerFileTest.java 2010-12-21
09:19:27 UTC (rev 27627)
+++
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hibernate/ui/bot/testcase/ReverseEngineerFileTest.java 2010-12-21
09:30:55 UTC (rev 27628)
@@ -10,17 +10,16 @@
******************************************************************************/
package org.jboss.tools.hibernate.ui.bot.testcase;
-import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
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.config.Annotations.SWTBotTestRequires;
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;
-import org.junit.runner.RunWith;
-(a)RunWith(SWTBotJunit4ClassRunner.class)
+@SWTBotTestRequires(clearProjects = false, perspective="Hibernate")
public class ReverseEngineerFileTest extends HibernateTest {
@BeforeClass
Modified:
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hibernate/ui/bot/testcase/ViewsTest.java
===================================================================
---
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hibernate/ui/bot/testcase/ViewsTest.java 2010-12-21
09:19:27 UTC (rev 27627)
+++
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hibernate/ui/bot/testcase/ViewsTest.java 2010-12-21
09:30:55 UTC (rev 27628)
@@ -10,12 +10,12 @@
******************************************************************************/
package org.jboss.tools.hibernate.ui.bot.testcase;
-import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
import org.jboss.tools.hibernate.ui.bot.testsuite.HibernateTest;
+import org.jboss.tools.ui.bot.ext.config.Annotations.DB;
+import org.jboss.tools.ui.bot.ext.config.Annotations.SWTBotTestRequires;
import org.junit.Test;
-import org.junit.runner.RunWith;
-(a)RunWith(SWTBotJunit4ClassRunner.class)
+@SWTBotTestRequires( db=@DB, perspective="Hibernate")
public class ViewsTest extends HibernateTest {
/**
Modified:
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hibernate/ui/bot/testsuite/HibernateAllTests.java
===================================================================
---
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hibernate/ui/bot/testsuite/HibernateAllTests.java 2010-12-21
09:19:27 UTC (rev 27627)
+++
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hibernate/ui/bot/testsuite/HibernateAllTests.java 2010-12-21
09:30:55 UTC (rev 27628)
@@ -1,13 +1,13 @@
- /*******************************************************************************
- * 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.testsuite;
import org.jboss.tools.hibernate.ui.bot.testcase.CodeGenerationLauncherTest;
@@ -22,26 +22,20 @@
import org.jboss.tools.hibernate.ui.bot.testcase.MappingsDiagramTest;
import org.jboss.tools.hibernate.ui.bot.testcase.ReverseEngineerFileTest;
import org.jboss.tools.hibernate.ui.bot.testcase.ViewsTest;
+import org.jboss.tools.ui.bot.ext.RequirementAwareSuite;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;
-(a)RunWith(Suite.class)
+(a)RunWith(RequirementAwareSuite.class)
+@SuiteClasses({ CodeGenerationLauncherTest.class,
+ ConfigurationContextTest.class, ConfigurationFileTest.class,
+ ConsolePerspectiveTest.class, ConsoleTest.class,
+ CriteriaEditorsTest.class, DaliTest.class, JIRATest.class,
+ MappingFileTest.class, MappingsDiagramTest.class,
+ ReverseEngineerFileTest.class, ViewsTest.class })
-@SuiteClasses( { CodeGenerationLauncherTest.class,
- ConfigurationContextTest.class,
- ConfigurationFileTest.class,
- ConsolePerspectiveTest.class,
- ConsoleTest.class,
- CriteriaEditorsTest.class,
- DaliTest.class,
- JIRATest.class,
- MappingFileTest.class,
- MappingsDiagramTest.class,
- ReverseEngineerFileTest.class,
- ViewsTest.class})
public class HibernateAllTests extends HibernateTest {
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-12-21
09:19:27 UTC (rev 27627)
+++
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hibernate/ui/bot/testsuite/HibernateTest.java 2010-12-21
09:30:55 UTC (rev 27628)
@@ -10,40 +10,26 @@
******************************************************************************/
package org.jboss.tools.hibernate.ui.bot.testsuite;
-import static org.eclipse.swtbot.eclipse.finder.matchers.WithPartName.withPartName;
-
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.channels.FileChannel;
-import java.sql.Connection;
-import java.sql.DriverManager;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
import org.eclipse.core.runtime.Platform;
-import org.eclipse.datatools.connectivity.ConnectionProfileException;
-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.SWTBotMenu;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
-import org.eclipse.ui.IViewReference;
-import org.hamcrest.Matcher;
-import org.hsqldb.Server;
import org.jboss.tools.hibernate.ui.bot.testcase.Activator;
import org.jboss.tools.hibernate.ui.bot.testcase.ConsoleTest;
import org.jboss.tools.ui.bot.ext.SWTEclipseExt;
import org.jboss.tools.ui.bot.ext.SWTTestExt;
+import org.jboss.tools.ui.bot.ext.config.TestConfigurator;
import org.jboss.tools.ui.bot.ext.entity.JavaClassEntity;
import org.jboss.tools.ui.bot.ext.entity.JavaProjectEntity;
import org.jboss.tools.ui.bot.ext.helper.ContextMenuHelper;
-import org.jboss.tools.ui.bot.ext.helper.DatabaseHelper;
-import org.jboss.tools.ui.bot.ext.types.DriverEntity;
import org.jboss.tools.ui.bot.ext.types.IDELabel;
import org.jboss.tools.ui.bot.ext.types.PerspectiveType;
import org.jboss.tools.ui.bot.ext.types.ViewType;
@@ -53,13 +39,7 @@
private static boolean classesCreated = false;
private static boolean projectCreated = false;
- private static boolean databasePrepared = false;
- private static boolean dbRunning = false;
- private static Thread hsqlThread = null;
-
- //private static Properties properties;
-
/**
* Prepare project and classes
*/
@@ -67,6 +47,7 @@
public static void prepare() {
log.info("Hibernate All Test Started");
jbt.closeReportUsageWindowIfOpened(true);
+ util.waitForNonIgnoredJobs();
}
/**
@@ -76,7 +57,6 @@
if (classesCreated) return;
-
// Package Explorer
SWTBot viewBot = eclipse.showView(ViewType.PACKAGE_EXPLORER);
SWTEclipseExt.selectTreeLocation(viewBot, Project.PROJECT_NAME,"src");
@@ -111,7 +91,6 @@
System.out.println("View Activated");
// Show perspective and view
- //open.viewClose(view)
eclipse.closeView(IDELabel.View.WELCOME);
eclipse.openPerspective(PerspectiveType.JAVA);
@@ -165,12 +144,18 @@
bot.tabItem("Libraries").activate();
bot.button("Add JARs...").click();
bot.sleep(TIME_500MS);
-
bot.tree().expandNode(Project.PROJECT_NAME).expandNode("hsqldb.jar").select();
+ String file = getDriverFileName(TestConfigurator.currentConfig.getDB().driverPath);
+ bot.tree().expandNode(Project.PROJECT_NAME).expandNode(file).select();
bot.button(IDELabel.Button.OK).click();
bot.sleep(TIME_1S);
bot.button(IDELabel.Button.OK).click();
bot.sleep(TIME_1S);
+ }
+
+ public static String getDriverFileName(String filePath) {
+ String[] fragments = filePath.split(File.separator);
+ return fragments[fragments.length - 1];
}
/**
@@ -179,7 +164,14 @@
* @throws IOException
*/
public static void addDriverIntoProject() throws FileNotFoundException, IOException {
- File in = util.getResourceFile(Activator.PLUGIN_ID,
"drv","hsqldb.jar");
+ File in = null;
+ if (TestConfigurator.currentConfig.getDB().internal) {
+ in = util.getResourceFile(Activator.PLUGIN_ID,
"drv","hsqldb.jar");
+ }
+ else {
+ in = util.getResourceFile(TestConfigurator.currentConfig.getDB().driverPath);
+ }
+
File out = new File(Platform.getLocation() + File.separator + Project.PROJECT_NAME +
File.separator + "hsqldb.jar");
FileChannel inChannel = null;
@@ -192,7 +184,7 @@
if (inChannel != null) inChannel.close();
if (outChannel != null) outChannel.close();
- log.info("Driver hsqldb.jar copied");
+ log.info("JDBC Driver copied");
}
/**
@@ -209,114 +201,4 @@
ConsoleTest consoleTest = new ConsoleTest();
consoleTest.createConsole();
}
-
- /**
- * Prepares database and insert test data by using connection profile and sql scrapbook
- */
- public static void prepareDatabase() {
- if (databasePrepared) return;
-
- runHSQLDBServer(Project.DB_FILE,Project.DB_NAME);
-
- StringBuilder stringBuilder = new StringBuilder();
- stringBuilder.append(Platform.getLocation());
- stringBuilder.append(File.separator);
- stringBuilder.append(Project.PROJECT_NAME);
- stringBuilder.append(File.separator);
- stringBuilder.append("hsqldb.jar");
-
- try {
- DriverEntity entity = new DriverEntity();
- entity.setDrvPath(stringBuilder.toString());
- entity.setJdbcString("jdbc:hsqldb:hsql://localhost/xdb");
- DatabaseHelper.createDriver(entity);
- } catch (ConnectionProfileException e) {
- log.error("Unable to create HSQL Driver" + e);
- fail();
- }
-
- eclipse.openPerspective(PerspectiveType.DB_DEVELOPMENT);
- eclipse.showView(ViewType.DATA_SOURCE_EXPLORER);
-
- bot.sleep(TIME_1S);
-
- //bot.activetree().expandNode("Database Connections").select();
-
- Matcher<IViewReference> matcher = withPartName("Data Source
Explorer");
- SWTBotView view = bot.view(matcher);
-
- bot.sleep(TIME_1S);
- SWTBotTree tree = view.bot().tree();
-
- // Open SQL Scrapbook
- SWTBotTreeItem item = tree.expandNode("Database
Connections").expandNode("DefaultDS");
- item.contextMenu("Connect").click();
- item.contextMenu("Open SQL Scrapbook").click();
-
- // Set SQL Scrapbook
- SWTBotEditor editor = bot.editorByTitle("SQL Scrapbook 0");
- editor.setFocus();
- bot.comboBoxWithLabelInGroup("Type:","Connection
profile").setSelection("HSQLDB_1.8");
- bot.comboBoxWithLabelInGroup("Name:","Connection
profile").setSelection("DefaultDS");
- bot.comboBoxWithLabelInGroup("Database:","Connection
profile").setSelection("Default");
-
- // Insert SQL script into editor
- eclipse.setClassContentFromResource(false, Activator.PLUGIN_ID, "sql",
"SQL Scrapbook 0");
-
- // Execute Script and close
- bot.editorByTitle("SQL Scrapbook 0").toTextEditor().contextMenu("Execute
All").click();
- editor.close();
-
- bot.sleep(TIME_5S);
- }
-
- /**
- * Run HSQLDB database in server mode
- * @param file
- * @param dbname
- */
- public static void runHSQLDBServer(final String file, final String dbname) {
- if (dbRunning) return;
-
- log.info("Starting HSQLDB");
- Runnable runable = new Runnable() {
-
- public void run() {
- Server.main(new String[] {"-database.0","file:" +
file,"-dbname.0",dbname });
- }
- };
-
- hsqlThread = new Thread(runable);
- hsqlThread.start();
- log.info("HSQLDB started");
- dbRunning = true;
- }
-
- /**
- * Stop HSQL Database by sending SHUTDOWN command
- */
- public static void stopHSQLDBServer() {
-
- try {
- Class.forName("org.hsqldb.jdbcDriver");
-
- Connection connection =
DriverManager.getConnection("jdbc:hsqldb:hsql://localhost/xdb");
-
- Statement statement = connection.createStatement();
- ResultSet resultset = statement.executeQuery("SHUTDOWN");
-
- resultset.close();
- statement.close();
- connection.close();
-
-
- } catch (SQLException e) {
-
- }
- catch (ClassNotFoundException e) {
- log.error("Unable to stop HSQLDB " + e);
- }
-
-
- }
}
\ No newline at end of file