Author: jpeterka
Date: 2009-12-10 12:30:34 -0500 (Thu, 10 Dec 2009)
New Revision: 19196
Added:
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/lib/
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/lib/hsqldb.jar
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/DriverEntity.java
Modified:
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/.classpath
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/META-INF/MANIFEST.MF
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/build.properties
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/ConsoleTest.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
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTEclipseExt.java
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTTestExt.java
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTUtilExt.java
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/helper/DatabaseHelper.java
Log:
Hibernate bot test ongoing update - embedded hsql server added, generated java code
check, etc. BotExt methods improved
Modified: trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/.classpath
===================================================================
--- trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/.classpath 2009-12-10
17:15:34 UTC (rev 19195)
+++ trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/.classpath 2009-12-10
17:30:34 UTC (rev 19196)
@@ -3,7 +3,6 @@
<classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
<classpathentry kind="con"
path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
- <classpathentry combineaccessrules="false" kind="src"
path="/org.jboss.tools.ui.bot.ext"/>
- <classpathentry kind="con"
path="org.eclipse.jdt.USER_LIBRARY/HSQLDB"/>
+ <classpathentry exported="true" kind="lib"
path="lib/hsqldb.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
Modified:
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/META-INF/MANIFEST.MF
===================================================================
---
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/META-INF/MANIFEST.MF 2009-12-10
17:15:34 UTC (rev 19195)
+++
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/META-INF/MANIFEST.MF 2009-12-10
17:30:34 UTC (rev 19196)
@@ -21,3 +21,5 @@
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Eclipse-RegisterBuddy: org.apache.log4j
Import-Package: org.eclipse.jdt.internal.ui
+Bundle-ClassPath: lib/hsqldb.jar,
+ .
Modified:
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/build.properties
===================================================================
---
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/build.properties 2009-12-10
17:15:34 UTC (rev 19195)
+++
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/build.properties 2009-12-10
17:30:34 UTC (rev 19196)
@@ -2,4 +2,5 @@
resources/
output.. = bin/
bin.includes = META-INF/,\
- .
+ .,\
+ lib/hsqldb.jar
Added: trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/lib/hsqldb.jar
===================================================================
(Binary files differ)
Property changes on:
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/lib/hsqldb.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
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 2009-12-10
17:15:34 UTC (rev 19195)
+++
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hibernate/ui/bot/testcase/CodeGenerationLauncherTest.java 2009-12-10
17:30:34 UTC (rev 19196)
@@ -12,15 +12,18 @@
import org.eclipse.swt.widgets.Button;
import org.eclipse.swtbot.eclipse.finder.matchers.WidgetMatcherFactory;
+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.SWTBotMenu;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
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.types.IDELabel;
import org.jboss.tools.ui.bot.ext.types.PerspectiveType;
+import org.jboss.tools.ui.bot.ext.types.ViewType;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -32,6 +35,9 @@
public static boolean generationDone = false;
@BeforeClass
+ /**
+ * Setup prerequisites for this test
+ */
public static void setUp() {
prepareProject();
@@ -58,8 +64,34 @@
bot.button(IDELabel.Button.RUN).click();
log.info("HB Code Generation FINISHED");
+ util.waitForNonIgnoredJobs();
+
+ checkGeneratedFiles();
+
generationDone = true;
}
+ /**
+ * Checks existence generated files after code generation
+ */
+ private void checkGeneratedFiles() {
+
+ SWTBot viewBot = eclipse.showView(ViewType.PROJECT_EXPLORER);
+ SWTBotTreeItem item;
+
+ item = eclipse.selectTreeLocation(viewBot,
Project.PROJECT_NAME,"gen","org","test","Customers.java");
+ item.doubleClick();
+ item = eclipse.selectTreeLocation(viewBot,
Project.PROJECT_NAME,"gen","org","test","Employees.java");
+ item.doubleClick();
+ item = eclipse.selectTreeLocation(viewBot,
Project.PROJECT_NAME,"gen","org","test","Offices.java");
+ item.doubleClick();
+
+ log.info("Generated files check DONE");
+ bot.sleep(TIME_10S);
+ }
+
+ /**
+ *
+ */
private void createNewHibernateCodeGenerationConfiguration() {
SWTBotMenu menu = null;
menu = bot.menu("Run");
@@ -68,7 +100,7 @@
mainShell = bot.activeShell();
}
-
+
/**
* TC 09
*/
@@ -138,5 +170,4 @@
log.info("HB Code Generation Common 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/ConsoleTest.java
===================================================================
---
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hibernate/ui/bot/testcase/ConsoleTest.java 2009-12-10
17:15:34 UTC (rev 19195)
+++
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hibernate/ui/bot/testcase/ConsoleTest.java 2009-12-10
17:30:34 UTC (rev 19196)
@@ -76,7 +76,7 @@
bot.buttonInGroup(IDELabel.HBConsoleWizard.SETUP_BUTTON,IDELabel.HBConsoleWizard.CONFIGURATION_FILE_GROUP).click();
bot.button(IDELabel.HBConsoleWizard.CREATE_NEW_BUTTON).click();
eclipse.selectTreeLocation(Project.PROJECT_NAME, "src");
- eclipse.button(IDELabel.Button.NEXT).click();
+ 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);
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 2009-12-10
17:15:34 UTC (rev 19195)
+++
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hibernate/ui/bot/testsuite/HibernateTest.java 2009-12-10
17:30:34 UTC (rev 19196)
@@ -19,6 +19,11 @@
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;
@@ -30,6 +35,7 @@
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.SWTTestExt;
@@ -37,6 +43,7 @@
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;
@@ -47,14 +54,23 @@
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
+ */
public static void prepare() {
prepareProject();
prepareClasses();
}
+ /**
+ * Create testing classes for the project
+ */
public static void prepareClasses() {
if (classesCreated) return;
@@ -75,6 +91,9 @@
classesCreated = true;
}
+ /**
+ * Create Java project for testing hibernate features
+ */
public static void prepareProject() {
if (projectCreated) return;
@@ -100,6 +119,9 @@
projectCreated = true;
}
+ /**
+ * Copy driver into project and add to classpath
+ */
public static void addDriver() {
try {
addDriverIntoProject();
@@ -110,7 +132,10 @@
}
addDriverClassPath();
}
-
+
+ /**
+ * Add Driver to classpath
+ */
public static void addDriverClassPath() {
eclipse.showView(ViewType.PROJECT_EXPLORER);
@@ -161,21 +186,31 @@
log.info("Driver hsqldb.jar copied");
}
+ /**
+ * Clean after tests
+ */
public static void clean() {
if (finished) return;
log.info("Clean finished");
}
+ /**
+ * Run's console tests (prerequisite for other tests to be able to execute them
separately)
+ */
public static void prepareConsole() {
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);
@@ -184,10 +219,13 @@
stringBuilder.append("hsqldb.jar");
try {
- DatabaseHelper.createDriver(stringBuilder.toString());
+ DriverEntity entity = new DriverEntity();
+ entity.setDrvPath(stringBuilder.toString());
+ entity.setJdbcString("jdbc:hsqldb:hsql://localhost/xdb");
+ DatabaseHelper.createDriver(entity);
} catch (ConnectionProfileException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
+ log.error("Unable to create HSQL Driver" + e);
+ fail();
}
eclipse.openPerspective(PerspectiveType.DB_DEVELOPMENT);
@@ -209,7 +247,7 @@
item.contextMenu("Open SQL Scrapbook").click();
// Set SQL Scrapbook
- SWTBotEditor editor = eclipse.editorByTitle("SQL Scrapbook 0");
+ 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");
@@ -224,4 +262,54 @@
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
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 2009-12-10
17:15:34 UTC (rev 19195)
+++
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hibernate/ui/bot/testsuite/Project.java 2009-12-10
17:30:34 UTC (rev 19196)
@@ -25,5 +25,6 @@
public static final String JDBC_STRING = "jdbc:hsqldb:hsql://localhost/xdb";
public static final String HSQLDB_PATH = "/home/jpeterka/lib/hsqldb";
public static final String CONF_FILE_NAME2 = "hibernate2.cfg.xml";
-
+ public static final String DB_FILE = "mydb";
+ public static final String DB_NAME = "xdb";
}
Modified:
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTEclipseExt.java
===================================================================
---
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTEclipseExt.java 2009-12-10
17:15:34 UTC (rev 19195)
+++
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTEclipseExt.java 2009-12-10
17:30:34 UTC (rev 19196)
@@ -37,12 +37,17 @@
* @author jpeterka
*
*/
-public class SWTEclipseExt extends SWTBotExt{
+public class SWTEclipseExt {
- SWTBotExt bot = new SWTBotExt();
- SWTUtilExt util = new SWTUtilExt();
+ SWTBotExt bot;
+ SWTUtilExt util;
Logger log = Logger.getLogger(SWTEclipseExt.class);
-
+
+ public SWTEclipseExt(SWTBotExt bot) {
+ this.bot = bot;
+ util = new SWTUtilExt(bot);
+ }
+
// ------------------------------------------------------------
// View related methods
// ------------------------------------------------------------
@@ -58,11 +63,14 @@
*
* @param type
*/
- public void showView(ViewType type) {
+ public SWTBot showView(ViewType type) {
bot.menu(IDELabel.Menu.WINDOW).menu(IDELabel.Menu.SHOW_VIEW).menu(
IDELabel.Menu.OTHER).click();
bot.tree().expandNode(type.getGroupLabel()).expandNode(type.getViewLabel()).select();
bot.button(IDELabel.Button.OK).click();
+
+ SWTBot viewBot = bot.viewByTitle(type.getViewLabel()).bot();
+ return viewBot;
}
// ------------------------------------------------------------
// Perspective related methods
@@ -184,12 +192,22 @@
* Select element in tree
* @return
*/
- public SWTBotTreeItem selectTreeLocation(String... path) {
+ public SWTBotTreeItem selectTreeLocation(String... path) {
+ return selectTreeLocation(bot, path);
+ }
+ /**
+ * Select element in tree with given bot
+ * @return
+ */
+ public SWTBotTreeItem selectTreeLocation(SWTBot bot, String... path) {
+
+ SWTBot viewBot = bot;
+
SWTBotTreeItem item = null;
// Go through path
for ( String nodeName: path ) {
if ( item == null ) {
- item = bot.tree().expandNode(nodeName);
+ item = viewBot.tree().expandNode(nodeName);
} else {
item = item.expandNode(nodeName);
}
@@ -197,8 +215,7 @@
}
return item.select();
}
-
-
+
// ------------------------------------------------------------
// Subroutines
// ------------------------------------------------------------
Modified:
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTTestExt.java
===================================================================
---
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTTestExt.java 2009-12-10
17:15:34 UTC (rev 19195)
+++
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTTestExt.java 2009-12-10
17:30:34 UTC (rev 19196)
@@ -24,8 +24,8 @@
public static final Logger log = Logger.getLogger(SWTTestExt.class);
public static final SWTBotExt bot = new SWTBotExt();
- public static final SWTUtilExt util = new SWTUtilExt();
- public static final SWTEclipseExt eclipse = new SWTEclipseExt();
+ public static final SWTUtilExt util = new SWTUtilExt(bot);
+ public static final SWTEclipseExt eclipse = new SWTEclipseExt(bot);
// Views
public static final PackageExplorer packageExplorer = new PackageExplorer();
Modified:
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTUtilExt.java
===================================================================
---
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTUtilExt.java 2009-12-10
17:15:34 UTC (rev 19195)
+++
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTUtilExt.java 2009-12-10
17:30:34 UTC (rev 19196)
@@ -39,8 +39,12 @@
public class SWTUtilExt extends SWTUtils {
private Logger log = Logger.getLogger(SWTUtilExt.class);
- protected SWTBotExt bot = new SWTBotExt();
+ protected SWTBotExt bot;
+ public SWTUtilExt(SWTBotExt bot) {
+ this.bot = bot;
+ }
+
// ------------------------------------------------------------
// Waiting methods
// ------------------------------------------------------------
Modified:
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/helper/DatabaseHelper.java
===================================================================
---
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/helper/DatabaseHelper.java 2009-12-10
17:15:34 UTC (rev 19195)
+++
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/helper/DatabaseHelper.java 2009-12-10
17:30:34 UTC (rev 19196)
@@ -19,30 +19,31 @@
import org.eclipse.datatools.connectivity.drivers.PropertySetImpl;
import org.eclipse.datatools.connectivity.drivers.models.TemplateDescriptor;
import org.jboss.tools.ui.bot.ext.Activator;
+import org.jboss.tools.ui.bot.ext.types.DriverEntity;
public class DatabaseHelper {
-
+
/**
* Create HSQLDB Driver
* @throws ConnectionProfileException
* @return driver instance
*/
- public static void createDriver(String path) throws ConnectionProfileException {
+ public static void createDriver(DriverEntity entity) throws ConnectionProfileException
{
String driverPath;
try {
- driverPath = new File(path).getCanonicalPath(); //$NON-NLS-1$
+ driverPath = new File(entity.getDrvPath()).getCanonicalPath(); //$NON-NLS-1$
} catch (IOException e) {
Activator.getDefault().getLog().log(new Status(IStatus.ERROR,
Activator.PLUGIN_ID, "Can't create driver", e));
return;
}
- DriverInstance driver =
DriverManager.getInstance().getDriverInstanceByName("Hypersonic DB");
+ DriverInstance driver =
DriverManager.getInstance().getDriverInstanceByName(entity.getInstanceName());
if (driver == null) {
TemplateDescriptor descr =
TemplateDescriptor.getDriverTemplateDescriptor("org.eclipse.datatools.enablement.hsqldb.1_8.driver");
- IPropertySet instance = new PropertySetImpl("Hypersonic DB",
"DriverDefn.Hypersonic DB");
- instance.setName("Hypersonic DB");
+ IPropertySet instance = new PropertySetImpl(entity.getInstanceName(),
"DriverDefn.Hypersonic DB");
+ instance.setName(entity.getInstanceName());
instance.setID("DriverDefn.Hypersonic DB");
Properties props = new Properties();
@@ -55,7 +56,7 @@
props.setProperty(id, value == null ? "" : value); //$NON-NLS-1$
}
//props.setProperty("org.eclipse.datatools.connectivity.db.URL",
"jdbc:hsqldb:file:testdb"); //$NON-NLS-1$
- props.setProperty("org.eclipse.datatools.connectivity.db.URL",
"jdbc:hsqldb:hsql://localhost/xdb");
+ props.setProperty("org.eclipse.datatools.connectivity.db.URL",
entity.getJdbcString());
props.setProperty(IDriverMgmtConstants.PROP_DEFN_TYPE, descr.getId());
props.setProperty(IDriverMgmtConstants.PROP_DEFN_JARLIST, driverPath);
@@ -65,7 +66,7 @@
DriverManager.getInstance().addDriverInstance(instance);
}
- driver = DriverManager.getInstance().getDriverInstanceByName("Hypersonic
DB");
+ driver =
DriverManager.getInstance().getDriverInstanceByName(entity.getInstanceName());
if (driver != null &&
ProfileManager.getInstance().getProfileByName("DefaultDS") == null) {
//$NON-NLS-1$
// create profile
Properties props = new Properties();
@@ -74,13 +75,13 @@
props.setProperty(IDBDriverDefinitionConstants.DRIVER_CLASS_PROP_ID,
driver.getProperty(IDBDriverDefinitionConstants.DRIVER_CLASS_PROP_ID));
props.setProperty(IDBDriverDefinitionConstants.DATABASE_VENDOR_PROP_ID, driver.getProperty(IDBDriverDefinitionConstants.DATABASE_VENDOR_PROP_ID));
props.setProperty(IDBDriverDefinitionConstants.DATABASE_VERSION_PROP_ID,
driver.getProperty(IDBDriverDefinitionConstants.DATABASE_VERSION_PROP_ID));
- props.setProperty(IDBDriverDefinitionConstants.DATABASE_NAME_PROP_ID,
"Default"); //$NON-NLS-1$
+ props.setProperty(IDBDriverDefinitionConstants.DATABASE_NAME_PROP_ID,
entity.getDatabaseName()); //$NON-NLS-1$
props.setProperty(IDBDriverDefinitionConstants.PASSWORD_PROP_ID, "");
//$NON-NLS-1$
props.setProperty(IDBConnectionProfileConstants.SAVE_PASSWORD_PROP_ID,
"false"); //$NON-NLS-1$
props.setProperty(IDBDriverDefinitionConstants.USERNAME_PROP_ID,
driver.getProperty(IDBDriverDefinitionConstants.USERNAME_PROP_ID));
props.setProperty(IDBDriverDefinitionConstants.URL_PROP_ID,
driver.getProperty(IDBDriverDefinitionConstants.URL_PROP_ID));
- ProfileManager.getInstance().createProfile("DefaultDS", "Hypersonic
embedded database", IDBConnectionProfileConstants.CONNECTION_PROFILE_ID, props,
"", false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ ProfileManager.getInstance().createProfile(entity.getProfileName(), entity.getProfileDescription(),
IDBConnectionProfileConstants.CONNECTION_PROFILE_ID, props, "", false);
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
}
}
Added:
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/DriverEntity.java
===================================================================
---
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/DriverEntity.java
(rev 0)
+++
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/DriverEntity.java 2009-12-10
17:30:34 UTC (rev 19196)
@@ -0,0 +1,64 @@
+ /*******************************************************************************
+ * 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.ui.bot.ext.types;
+
+/**
+ * Driver entity for usage for DatabaseHelper
+ * @author jpeterka
+ *
+ */
+public class DriverEntity {
+ String instanceName = "Hypersonic DB";
+ String drvPath = "";
+ String jdbcString = "";
+ String profileName = "DefaultDS";
+ String profileDescription = "Hypersonic embedded database";
+ String databaseName = "Default";
+
+ public String getInstanceName() {
+ return instanceName;
+ }
+ public void setInstanceName(String instanceName) {
+ this.instanceName = instanceName;
+ }
+ public String getDrvPath() {
+ return drvPath;
+ }
+ public void setDrvPath(String drvPath) {
+ this.drvPath = drvPath;
+ }
+ public String getJdbcString() {
+ return jdbcString;
+ }
+ public void setJdbcString(String jdbcString) {
+ this.jdbcString = jdbcString;
+ }
+ public String getProfileName() {
+ return profileName;
+ }
+ public void setProfileName(String profileName) {
+ this.profileName = profileName;
+ }
+ public String getProfileDescription() {
+ return profileDescription;
+ }
+ public void setProfileDescription(String profileDescription) {
+ this.profileDescription = profileDescription;
+ }
+ public String getDatabaseName() {
+ return databaseName;
+ }
+ public void setDatabaseName(String databaseName) {
+ this.databaseName = databaseName;
+ }
+
+
+}
Property changes on:
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/DriverEntity.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain