diff options
Diffstat (limited to 'jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal')
12 files changed, 0 insertions, 2750 deletions
diff --git a/jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/JptDbTests.java b/jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/JptDbTests.java deleted file mode 100644 index f8c0ca49cc..0000000000 --- a/jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/JptDbTests.java +++ /dev/null @@ -1,35 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2008 Oracle. All rights reserved. - * This program and the accompanying materials are 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. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.db.tests.internal; - -import org.eclipse.jpt.db.tests.internal.platforms.AllPlatformTests; - -import junit.framework.Test; -import junit.framework.TestSuite; - -/** - * JPT DB Tests - */ -public class JptDbTests { - - public static Test suite() { - TestSuite suite = new TestSuite(JptDbTests.class.getPackage().getName()); - - suite.addTest( AllPlatformTests.suite()); - - return suite; - } - - private JptDbTests() { - super(); - throw new UnsupportedOperationException(); - } - -} diff --git a/jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/JptDbTestsPlugin.java b/jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/JptDbTestsPlugin.java deleted file mode 100644 index 11c2a7e84a..0000000000 --- a/jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/JptDbTestsPlugin.java +++ /dev/null @@ -1,56 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2008 Oracle. All rights reserved. - * This program and the accompanying materials are 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. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.db.tests.internal; - -import org.eclipse.core.runtime.Plugin; -import org.osgi.framework.BundleContext; - -/** - * JptDbTestsPlugin - */ -public class JptDbTestsPlugin extends Plugin { - - // The shared instance - private static JptDbTestsPlugin plugin; - - public static final String BUNDLE_ID = "org.eclipse.jpt.db.tests"; //$NON-NLS-1$ - - /** - * Returns the shared instance - */ - public static JptDbTestsPlugin getDefault() { - return plugin; - } - - /** - * The constructor - */ - public JptDbTestsPlugin() { - super(); - plugin = this; - } - - /** - * This method is called upon plug-in activation - */ - @Override - public void start(BundleContext context) throws Exception { - super.start(context); - } - - /** - * This method is called when the plug-in is stopped - */ - @Override - public void stop(BundleContext context) throws Exception { - plugin = null; - super.stop(context); - } -} diff --git a/jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/platforms/AllPlatformTests.java b/jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/platforms/AllPlatformTests.java deleted file mode 100644 index 0b5de9abea..0000000000 --- a/jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/platforms/AllPlatformTests.java +++ /dev/null @@ -1,41 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2007 Oracle. All rights reserved. - * This program and the accompanying materials are 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. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.db.tests.internal.platforms; - -import junit.framework.Test; -import junit.framework.TestSuite; - -/** - * AllPlatformTests - */ -public class AllPlatformTests { - - public static Test suite() { - TestSuite suite = new TestSuite(AllPlatformTests.class.getPackage().getName()); - -// TODO - Uncomment the platform to test. -// suite.addTestSuite(DerbyTests.class); -// suite.addTestSuite(MySQLTests.class); -// suite.addTestSuite(Oracle10gTests.class); -// suite.addTestSuite(Oracle10gXETests.class); -// suite.addTestSuite(Oracle9iTests.class); -// suite.addTestSuite(PostgreSQLTests.class); -// suite.addTestSuite(SQLServerTests.class); -// suite.addTestSuite(SybaseTests.class); - - return suite; - } - - private AllPlatformTests() { - super(); - throw new UnsupportedOperationException(); - } - -} diff --git a/jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/platforms/DTPPlatformTests.java b/jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/platforms/DTPPlatformTests.java deleted file mode 100644 index 3379574f57..0000000000 --- a/jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/platforms/DTPPlatformTests.java +++ /dev/null @@ -1,868 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2008 Oracle. All rights reserved. - * This program and the accompanying materials are 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. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.db.tests.internal.platforms; - -import java.io.File; -import java.io.IOException; -import java.io.OutputStreamWriter; -import java.net.URL; -import java.sql.Connection; -import java.sql.ResultSet; -import java.sql.ResultSetMetaData; -import java.sql.SQLException; -import java.sql.Statement; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.Properties; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Platform; -import org.eclipse.datatools.connectivity.ConnectionProfileException; -import org.eclipse.datatools.connectivity.IConnectionProfile; -import org.eclipse.datatools.connectivity.IManagedConnection; -import org.eclipse.datatools.connectivity.ProfileManager; -import org.eclipse.datatools.connectivity.drivers.IDriverMgmtConstants; -import org.eclipse.datatools.connectivity.drivers.IPropertySet; -import org.eclipse.datatools.connectivity.drivers.PropertySetImpl; -import org.eclipse.datatools.connectivity.drivers.XMLFileManager; -import org.eclipse.datatools.connectivity.drivers.jdbc.IJDBCDriverDefinitionConstants; -import org.eclipse.datatools.connectivity.internal.ConnectivityPlugin; -import org.eclipse.datatools.connectivity.sqm.core.connection.ConnectionInfo; -import org.eclipse.datatools.connectivity.sqm.core.rte.ICatalogObject; -import org.eclipse.jpt.db.Catalog; -import org.eclipse.jpt.db.Column; -import org.eclipse.jpt.db.ConnectionListener; -import org.eclipse.jpt.db.ConnectionProfile; -import org.eclipse.jpt.db.ConnectionProfileFactory; -import org.eclipse.jpt.db.ConnectionProfileListener; -import org.eclipse.jpt.db.Database; -import org.eclipse.jpt.db.DatabaseFinder; -import org.eclipse.jpt.db.ForeignKey; -import org.eclipse.jpt.db.JptDbPlugin; -import org.eclipse.jpt.db.Schema; -import org.eclipse.jpt.db.SchemaContainer; -import org.eclipse.jpt.db.Sequence; -import org.eclipse.jpt.db.Table; -import org.eclipse.jpt.db.ForeignKey.ColumnPair; -import org.eclipse.jpt.db.tests.internal.JptDbTestsPlugin; -import org.eclipse.jpt.utility.internal.ClassTools; -import org.eclipse.jpt.utility.internal.IndentingPrintWriter; -import org.eclipse.jpt.utility.internal.StringTools; -import org.eclipse.jpt.utility.internal.iterators.ResultSetIterator; - -import junit.framework.TestCase; - -/** - * Base class for testing DTP wrappers on various databases. - */ -@SuppressWarnings("nls") -public abstract class DTPPlatformTests extends TestCase { - - /** - * The platform properties are loaded from a Java properties file in the - * 'org.eclipse.jpt.db.tests/config' directory. Each database platform has - * its own properties file (e.g. 'derby101.properties'). - */ - private Properties platformProperties; - - /** - * This is the Dali connection profile wrapper. - */ - protected ConnectionProfile connectionProfile; - - - // ********** constants ********** - - private static final String PLATFORM_CONFIG_DIRECTORY = "config"; - - private static final String DB_USER_ID_PROPERTY = "userID"; - private static final String DB_USER_ID_DEFAULT = "user"; - - private static final String DB_PASSWORD_PROPERTY = "password"; - private static final String DB_PASSWORD_DEFAULT = ""; - - private static final String DB_DRIVER_JARS_PROPERTY = "jars"; - // required - no default - - private static final String DB_URL_PROPERTY = "url"; - // required - no default - - private static final String DB_DATABASE_PROPERTY = "database"; - private static final String DB_DATABASE_DEFAULT = "testdb"; - - - - // ********** constructor ********** - - protected DTPPlatformTests(String name) { - super(name); - } - - - // ********** set-up/tear-down ********** - - @Override - protected void setUp() throws Exception { - super.setUp(); - - this.platformProperties = this.loadPlatformProperties(); - this.buildDTPDriverDefinitionFile(); - this.buildDTPConnectionProfile(); - this.connectionProfile = this.getConnectionProfileFactory().buildConnectionProfile(this.getProfileName(), DatabaseFinder.Default.instance()); - } - - @Override - protected void tearDown() throws Exception { - this.connectionProfile = null; - this.platformProperties = null; - - super.tearDown(); - } - - // ***** platform properties file - private Properties loadPlatformProperties() throws IOException { - Properties p = new Properties(); - p.load(this.buildPlatformPropertiesFileURL().openStream()); - return p; - } - - private URL buildPlatformPropertiesFileURL() { - return Platform.getBundle(this.getTestPluginBundleID()).getEntry(this.getPlatformPropertiesFilePath()); - } - - private String getTestPluginBundleID() { - return JptDbTestsPlugin.BUNDLE_ID; - } - - private String getPlatformPropertiesFilePath() { - return this.getPlatformPropertiesDirectoryName() + '/' + this.getPlatformPropertiesFileName(); - } - - private String getPlatformPropertiesDirectoryName() { - return PLATFORM_CONFIG_DIRECTORY; - } - - /** - * Each database platform has a separate properties file in the 'config' - * directory that must be customized by whomever is executing the tests. - */ - protected abstract String getPlatformPropertiesFileName(); - - // ***** driver definition file - private void buildDTPDriverDefinitionFile() throws CoreException { - XMLFileManager.setStorageLocation(this.getDTPDriverDefinitionLocation()); - XMLFileManager.setFileName(this.getDTPDriverFileName()); - - IPropertySet[] sets = XMLFileManager.loadPropertySets(); - for (IPropertySet set : sets) { - if (set.getID().equals(this.getDriverDefinitionID())) { - return; // property sets live across tests - } - } - - XMLFileManager.saveNamedPropertySet(this.buildDTPDriverDefinitionPropertySets()); - - // verify the file was created: - File driverDefinitioneFile = this.getDTPDriverDefinitionLocation().append(this.getDTPDriverFileName()).toFile(); - assertTrue(driverDefinitioneFile.exists()); - } - - private IPath getDTPDriverDefinitionLocation() { - return ConnectivityPlugin.getDefault().getStateLocation(); - } - - private String getDTPDriverFileName() { - return IDriverMgmtConstants.DRIVER_FILE; - } - - private IPropertySet[] buildDTPDriverDefinitionPropertySets() { - IPropertySet[] propertySets = new IPropertySet[1]; - PropertySetImpl propertySet = new PropertySetImpl(this.getDriverName(), this.getDriverDefinitionID()); - propertySet.setProperties(this.getDriverDefinitionID(), this.buildDTPDriverDefinitionProperties()); - propertySets[0] = propertySet; - return propertySets; - } - - protected abstract String getDriverName(); - - protected abstract String getDriverDefinitionID(); - - private Properties buildDTPDriverDefinitionProperties() { - Properties p = new Properties(); - p.setProperty(ConnectionProfile.DRIVER_DEFINITION_TYPE_PROP_ID, this.getDriverDefinitionType()); - p.setProperty(ConnectionProfile.DRIVER_JAR_LIST_PROP_ID, this.getJDBCDriverJarList()); - p.setProperty(IJDBCDriverDefinitionConstants.DATABASE_VENDOR_PROP_ID, this.getDatabaseVendor()); - p.setProperty(IJDBCDriverDefinitionConstants.DATABASE_VERSION_PROP_ID, this.getDatabaseVersion()); - p.setProperty(IJDBCDriverDefinitionConstants.DRIVER_CLASS_PROP_ID, this.getDriverClass()); - p.setProperty(IJDBCDriverDefinitionConstants.URL_PROP_ID, this.getJDBCURL()); - p.setProperty(IJDBCDriverDefinitionConstants.USERNAME_PROP_ID, this.getUserID()); - p.setProperty(IJDBCDriverDefinitionConstants.PASSWORD_PROP_ID, this.getPassword()); - p.setProperty(IJDBCDriverDefinitionConstants.DATABASE_NAME_PROP_ID, this.getDatabaseName()); - return p; - } - - protected abstract String getDriverDefinitionType(); - - /** - * The JAR list is workspace-specific and is set in the properties file. - */ - private String getJDBCDriverJarList() { - return this.getRequiredPlatformProperty(DB_DRIVER_JARS_PROPERTY); - } - - protected abstract String getDatabaseVendor(); - - protected abstract String getDatabaseVersion(); - - protected abstract String getDriverClass(); - - /** - * The database URL is workspace-specific and is set in the properties file - * for some databases. - */ - private String getJDBCURL() { - return this.platformProperties.getProperty(DB_URL_PROPERTY, this.getDefaultJDBCURL()); - } - - protected String getDefaultJDBCURL() { - return ""; - } - - /** - * The user ID is optional and can be set in the properties file. - */ - protected String getUserID() { - return this.platformProperties.getProperty(DB_USER_ID_PROPERTY, DB_USER_ID_DEFAULT); - } - - /** - * The password is optional and can be set in the properties file. - */ - private String getPassword() { - return this.platformProperties.getProperty(DB_PASSWORD_PROPERTY, DB_PASSWORD_DEFAULT); - } - - /** - * The database name is optional and can be set in the properties file. - */ - protected String getDatabaseName() { - return this.platformProperties.getProperty(DB_DATABASE_PROPERTY, DB_DATABASE_DEFAULT); - } - - // ***** DTP connection profile - private void buildDTPConnectionProfile() throws ConnectionProfileException { - if (this.getDTPProfileManager().getProfileByName(this.getProfileName()) != null) { - return; // profiles live across tests - } - this.createProfile(this.getProfileName()); - assertNotNull(this.getDTPProfileManager().getProfileByName(this.getProfileName())); - } - - protected void createProfile(String profileName) throws ConnectionProfileException { - this.getDTPProfileManager().createProfile( - profileName, - this.getProfileDescription(), - this.getProviderID(), - this.buildDTPConnectionProfileProperties() - ); - } - - protected abstract String getProfileName(); - - protected abstract String getProfileDescription(); - - protected String getProviderID() { - return ConnectionProfile.CONNECTION_PROFILE_TYPE; - } - - private Properties buildDTPConnectionProfileProperties() { - Properties p = new Properties(); - p.setProperty(IJDBCDriverDefinitionConstants.DATABASE_NAME_PROP_ID, this.getDatabaseName()); - p.setProperty(IJDBCDriverDefinitionConstants.USERNAME_PROP_ID, this.getUserID()); - p.setProperty(IJDBCDriverDefinitionConstants.PASSWORD_PROP_ID, this.getPassword()); - p.setProperty(ConnectionProfile.DRIVER_DEFINITION_PROP_ID, this.getDriverDefinitionID()); - - p.setProperty(IJDBCDriverDefinitionConstants.DRIVER_CLASS_PROP_ID, this.getDriverClass()); - p.setProperty(IJDBCDriverDefinitionConstants.URL_PROP_ID, this.getJDBCURL()); - p.setProperty(IJDBCDriverDefinitionConstants.DATABASE_VENDOR_PROP_ID, this.getDatabaseVendor()); - p.setProperty(IJDBCDriverDefinitionConstants.DATABASE_VERSION_PROP_ID, this.getDatabaseVersion()); - - p.setProperty(ConnectionProfile.DATABASE_SAVE_PWD_PROP_ID, this.passwordIsSaved()); - return p; - } - - private String passwordIsSaved() { - return "true"; - } - - - // ********** tests ********** - - public void testConnectionProfileListener() throws ConnectionProfileException { - TestConnectionProfileListener listener = new TestConnectionProfileListener(); - this.getConnectionProfileFactory().addConnectionProfileListener(listener); - - String cpName1 = this.getProfileName() + "1"; - this.createProfile(cpName1); - IConnectionProfile dtpCP = this.getDTPProfileManager().getProfileByName(cpName1); - assertNotNull(dtpCP); - - assertEquals(cpName1, listener.addedName); - listener.clear(); - - String cpName2 = this.getProfileName() + "2"; - this.getDTPProfileManager().modifyProfile(dtpCP, cpName2, null); - assertEquals(cpName1, listener.renamedOldName); - assertEquals(cpName2, listener.renamedNewName); - listener.clear(); - - ConnectionProfile cp = this.getConnectionProfileFactory().buildConnectionProfile(cpName2); - assertNotNull(cp); - - this.getDTPProfileManager().deleteProfile(dtpCP); - assertEquals(cpName2, listener.removedName); - listener.clear(); - - cp = this.getConnectionProfileFactory().buildConnectionProfile(cpName2); - assertNull(cp); - - this.getConnectionProfileFactory().removeConnectionProfileListener(listener); - } - - public void testName() { - assertEquals(this.getProfileName(), this.connectionProfile.getName()); - } - - public void testConnection() throws Exception { - assertTrue(this.connectionProfile.isInactive()); - assertTrue(this.connectionProfile.isDisconnected()); - this.connectionProfile.connect(); - assertTrue(this.connectionProfile.isActive()); - assertTrue(this.connectionProfile.isConnected()); - - this.verifyDatabaseVersionNumber(); - this.verifyDatabaseVendor(); - this.verifyDatabaseContent(); - - this.connectionProfile.disconnect(); - assertTrue(this.connectionProfile.isInactive()); - assertTrue(this.connectionProfile.isDisconnected()); - } - - private void verifyDatabaseVersionNumber() { - Database database = this.connectionProfile.getDatabase(); - assertNotNull(database); - - String actual = database.getVersion(); - String expected = this.getDatabaseVersion(); - String errorMessage = "expected: " + expected + " - actual: " + actual; - // partial match is good enough - assertTrue(errorMessage, actual.indexOf(expected) != -1); - } - - private void verifyDatabaseVendor() { - Database database = this.connectionProfile.getDatabase(); - String actual = database.getVendor(); - String expected = this.getDatabaseVendor(); - assertEquals(expected, actual); - } - - private void verifyDatabaseContent() { - Database database = this.connectionProfile.getDatabase(); - assertTrue(database.schemataSize() > 0); - - Schema schema = database.getDefaultSchema(); - if (schema != null) { - if (schema.tablesSize() > 0) { - Table table = schema.tables().next(); - assertTrue(table.columnsSize() >= 0); - assertTrue(table.primaryKeyColumnsSize() >= 0); - assertTrue(table.foreignKeysSize() >= 0); - } - } - } - - public void testOffline() { - if ( ! this.connectionProfile.supportsWorkOfflineMode()) { - return; - } - - this.prepareForOfflineWork(); - - IStatus status = this.connectionProfile.workOffline(); - assertTrue(status.isOK()); - assertTrue(this.connectionProfile.isActive()); - assertTrue(this.connectionProfile.isWorkingOffline()); - - this.connectionProfile.disconnect(); - assertTrue(this.connectionProfile.isInactive()); - assertTrue(this.connectionProfile.isDisconnected()); - } - - protected void prepareForOfflineWork() { - if ( ! this.connectionProfile.canWorkOffline()) { - this.connectionProfile.connect(); - IStatus status = this.connectionProfile.saveWorkOfflineData(); - assertTrue(status.isOK()); - this.connectionProfile.disconnect(); - assertTrue(this.connectionProfile.canWorkOffline()); - } - } - - public void testConnectionListenerConnect() { - assertTrue(this.connectionProfileHasNoListeners()); - TestConnectionListener listener = new TestConnectionListener(); - this.connectionProfile.addConnectionListener(listener); - assertTrue(this.connectionProfileHasAnyListeners()); - - this.connectionProfile.connect(); - assertSame(this.connectionProfile, listener.openedProfile); - listener.clear(); - - this.connectionProfile.disconnect(); - assertSame(this.connectionProfile, listener.okToCloseProfile); - assertSame(this.connectionProfile, listener.aboutToCloseProfile); - assertSame(this.connectionProfile, listener.closedProfile); - - this.connectionProfile.removeConnectionListener(listener); - assertTrue(this.connectionProfileHasNoListeners()); - } - - public void testConnectionListenerOffline() { - TestConnectionListener listener = new TestConnectionListener(); - this.connectionProfile.addConnectionListener(listener); - - this.prepareForOfflineWork(); - listener.clear(); - - this.connectionProfile.workOffline(); - assertSame(this.connectionProfile, listener.openedProfile); - listener.clear(); - - this.connectionProfile.disconnect(); - assertSame(this.connectionProfile, listener.okToCloseProfile); - assertSame(this.connectionProfile, listener.aboutToCloseProfile); - assertSame(this.connectionProfile, listener.closedProfile); - listener.clear(); - - this.connectionProfile.removeConnectionListener(listener); - } - - public void testConnectionListenerDatabase() { - this.connectionProfile.connect(); - TestConnectionListener listener = new TestConnectionListener(); - this.connectionProfile.addConnectionListener(listener); - - ((ICatalogObject) this.getDTPDatabase()).refresh(); - assertSame(this.connectionProfile.getDatabase(), listener.changedDatabase); - - this.connectionProfile.removeConnectionListener(listener); - this.connectionProfile.disconnect(); - } - - public void testConnectionListenerCatalog() { - this.connectionProfile.connect(); - if ( ! this.connectionProfile.getDatabase().supportsCatalogs()) { - this.connectionProfile.disconnect(); - return; - } - - TestConnectionListener listener = new TestConnectionListener(); - this.connectionProfile.addConnectionListener(listener); - - // take the first catalog - org.eclipse.datatools.modelbase.sql.schema.Catalog dtpCatalog = this.getFirstDTPCatalog(); - Catalog catalog = this.connectionProfile.getDatabase().getCatalogNamed(dtpCatalog.getName()); - ((ICatalogObject) dtpCatalog).refresh(); - assertSame(catalog, listener.changedCatalog); - - this.connectionProfile.removeConnectionListener(listener); - this.connectionProfile.disconnect(); - } - - public void testConnectionListenerSchema() { - this.connectionProfile.connect(); - TestConnectionListener listener = new TestConnectionListener(); - this.connectionProfile.addConnectionListener(listener); - - org.eclipse.datatools.modelbase.sql.schema.Schema dtpSchema = null; - Schema schema = null; - if (this.connectionProfile.getDatabase().supportsCatalogs()) { - org.eclipse.datatools.modelbase.sql.schema.Catalog dtpCatalog = this.getFirstDTPCatalog(); - dtpSchema = (org.eclipse.datatools.modelbase.sql.schema.Schema) dtpCatalog.getSchemas().get(0); - schema = this.connectionProfile.getDatabase().getCatalogNamed(dtpCatalog.getName()).getSchemaNamed(dtpSchema.getName()); - } else { - dtpSchema = (org.eclipse.datatools.modelbase.sql.schema.Schema) this.getDTPDatabase().getSchemas().get(0); - schema = this.connectionProfile.getDatabase().getSchemaNamed(dtpSchema.getName()); - } - ((ICatalogObject) dtpSchema).refresh(); - assertSame(schema, listener.changedSchema); - - this.connectionProfile.removeConnectionListener(listener); - this.connectionProfile.disconnect(); - } - - - // ********** convenience methods ********** - - protected ConnectionProfileFactory getConnectionProfileFactory() { - return JptDbPlugin.instance().getConnectionProfileFactory(); - } - - protected ConnectionProfile getConnectionProfile() { - return this.connectionProfile; - } - - protected Database getDatabase() { - return this.connectionProfile.getDatabase(); - } - - protected Catalog getCatalogNamed(String catalogName) { - return this.connectionProfile.getDatabase().getCatalogNamed(catalogName); - } - - protected Schema getSchemaNamed(String schemaName) { - return this.connectionProfile.getDatabase().getSchemaNamed(schemaName); - } - - protected String getRequiredPlatformProperty(String propertyKey) { - String propertyValue = this.platformProperties.getProperty(propertyKey); - if (StringTools.stringIsEmpty(propertyValue)) { - throw new IllegalArgumentException("The database platform properties file '" + this.getPlatformPropertiesFilePath() - + "' is missing a value for the property '" + propertyKey + "'."); - } - return propertyValue; - } - - protected boolean connectionProfileHasAnyListeners() { - return connectionProfileHasAnyListeners(this.connectionProfile); - } - - protected static boolean connectionProfileHasAnyListeners(ConnectionProfile cp) { - return ((Boolean) ClassTools.executeMethod(cp, "hasAnyListeners")).booleanValue(); - } - - protected boolean connectionProfileHasNoListeners() { - return connectionProfileHasNoListeners(this.connectionProfile); - } - - protected static boolean connectionProfileHasNoListeners(ConnectionProfile cp) { - return ((Boolean) ClassTools.executeMethod(cp, "hasNoListeners")).booleanValue(); - } - - - // ********** DTP model ********** - - protected ProfileManager getDTPProfileManager() { - return ProfileManager.getInstance(); - } - - protected IConnectionProfile getDTPConnectionProfile() { - return getDTPConnectionProfile(this.connectionProfile); - } - - protected static IConnectionProfile getDTPConnectionProfile(ConnectionProfile cp) { - return (IConnectionProfile) ClassTools.fieldValue(cp, "dtpConnectionProfile"); - } - - protected IManagedConnection getDTPManagedConnection() { - return (IManagedConnection) ClassTools.fieldValue(this.connectionProfile, "dtpManagedConnection"); - } - - protected org.eclipse.datatools.modelbase.sql.schema.Database getDTPDatabase() { - return getDTPDatabase(this.connectionProfile.getDatabase()); - } - - protected static org.eclipse.datatools.modelbase.sql.schema.Database getDTPDatabase(Database database) { - return (org.eclipse.datatools.modelbase.sql.schema.Database) ClassTools.fieldValue(database, "dtpDatabase"); - } - - protected org.eclipse.datatools.modelbase.sql.schema.Catalog getFirstDTPCatalog() { - return (org.eclipse.datatools.modelbase.sql.schema.Catalog) this.getDTPDatabase().getCatalogs().get(0); - } - - protected org.eclipse.datatools.modelbase.sql.schema.Catalog getDTPCatalogNamed(String name) { - return getDTPCatalog(this.getDatabase().getCatalogNamed(name)); - } - - protected static org.eclipse.datatools.modelbase.sql.schema.Catalog getDTPCatalog(Catalog catalog) { - return (org.eclipse.datatools.modelbase.sql.schema.Catalog) ClassTools.fieldValue(catalog, "dtpCatalog"); - } - - protected org.eclipse.datatools.modelbase.sql.schema.Schema getDTPSchemaNamed(String name) { - return getDTPSchema(this.getDatabase().getSchemaNamed(name)); - } - - protected static org.eclipse.datatools.modelbase.sql.schema.Schema getDTPSchema(Schema schema) { - return (org.eclipse.datatools.modelbase.sql.schema.Schema) ClassTools.fieldValue(schema, "dtpSchema"); - } - - - // ********** execute SQL ********** - - /** - * ignore any errors (useful for dropping database objects that might - * not be there) - */ - protected void executeUpdateIgnoreErrors(String sql) { - try { - this.executeUpdate(sql); - } catch (Exception ex) { - // ignore - } - } - - protected void executeUpdate(String sql) throws SQLException { - Statement jdbcStatement = this.createJDBCStatement(); - jdbcStatement.executeUpdate(sql); - jdbcStatement.close(); - } - - protected List<Object[]> execute(String sql) throws SQLException { - Statement jdbcStatement = this.createJDBCStatement(); - jdbcStatement.execute(sql); - ResultSet resultSet = jdbcStatement.getResultSet(); - ResultSetMetaData metaData = resultSet.getMetaData(); - int columnCount = metaData.getColumnCount(); - ArrayList<Object[]> rows = new ArrayList<Object[]>(); - for (Iterator<Object[]> stream = new ResultSetIterator<Object[]>(resultSet, new LocalResultSetIteratorAdapter(columnCount)); stream.hasNext(); ) { - rows.add(stream.next()); - } - jdbcStatement.close(); - return rows; - } - - public class LocalResultSetIteratorAdapter implements ResultSetIterator.Adapter<Object[]> { - private int columnCount; - public LocalResultSetIteratorAdapter(int columnCount) { - super(); - this.columnCount = columnCount; - } - public Object[] buildNext(ResultSet rs) throws SQLException { - Object[] row = new Object[this.columnCount]; - for (int i = 0; i < row.length; i++) { - row[i] = rs.getObject(i + 1); - } - return row; - } - } - - protected Statement createJDBCStatement() throws SQLException { - return this.getJDBCConnection().createStatement(); - } - - protected Connection getJDBCConnection() { - return ((ConnectionInfo) this.getDTPManagedConnection().getConnection().getRawConnection()).getSharedConnection(); - } - - - // ********** dump database schema ********** - - /** - * dump all the database metadata to the console - */ - protected void dumpDatabase() { - IndentingPrintWriter pw = new IndentingPrintWriter(new OutputStreamWriter(System.out)); - // synchronize the console so everything is contiguous - synchronized (System.out) { - this.dumpDatabaseOn(pw); - } - pw.flush(); - } - - protected void dumpDatabaseOn(IndentingPrintWriter pw) { - Database database = this.connectionProfile.getDatabase(); - pw.print("database: "); - pw.println(database.getName()); - if (database.supportsCatalogs()) { - for (Iterator<Catalog> stream = database.catalogs(); stream.hasNext(); ) { - this.dumpCatalogOn(stream.next(), pw); - } - } else { - this.dumpSchemaOnContainerOn(database, pw); - } - } - - protected void dumpCatalogOn(Catalog catalog, IndentingPrintWriter pw) { - pw.print("catalog: "); - pw.println(catalog.getName()); - pw.indent(); - this.dumpSchemaOnContainerOn(catalog, pw); - pw.undent(); - } - - protected void dumpSchemaOnContainerOn(SchemaContainer schemaContainer, IndentingPrintWriter pw) { - for (Iterator<Schema> stream = schemaContainer.schemata(); stream.hasNext(); ) { - this.dumpSchemaOn(stream.next(), pw); - } - } - - protected void dumpSchemaOn(Schema schema, IndentingPrintWriter pw) { - pw.print("schema: "); - pw.println(schema.getName()); - pw.indent(); - for (Iterator<Table> stream = schema.tables(); stream.hasNext(); ) { - this.dumpTableOn(stream.next(), pw); - } - for (Iterator<Sequence> stream = schema.sequences(); stream.hasNext(); ) { - this.dumpSequenceOn(stream.next(), pw); - } - pw.undent(); - } - - protected void dumpTableOn(Table table, IndentingPrintWriter pw) { - pw.print("table: "); - pw.println(table.getName()); - pw.indent(); - for (Iterator<Column> stream = table.columns(); stream.hasNext(); ) { - this.dumpColumnOn(stream.next(), pw); - } - for (Iterator<ForeignKey> stream = table.foreignKeys(); stream.hasNext(); ) { - this.dumpForeignKeyOn(stream.next(), pw); - } - pw.undent(); - } - - protected void dumpColumnOn(Column column, IndentingPrintWriter pw) { - pw.print("column: "); - pw.print(column.getName()); - pw.print(" : "); - pw.print(column.getDataTypeName()); - if (column.isPrimaryKeyColumn()) { - pw.print(" [primary key]"); - } - pw.println(); - } - - protected void dumpForeignKeyOn(ForeignKey foreignKey, IndentingPrintWriter pw) { - pw.print("foreign key: "); - pw.print(foreignKey.getName()); - pw.print("=>"); - pw.print(foreignKey.getReferencedTable().getName()); - pw.print(" ("); - for (Iterator<ColumnPair> stream = foreignKey.columnPairs(); stream.hasNext(); ) { - ColumnPair cp = stream.next(); - pw.print(cp.getBaseColumn().getName()); - pw.print("=>"); - pw.print(cp.getReferencedColumn().getName()); - if (stream.hasNext()) { - pw.print(", "); - } - } - pw.print(')'); - pw.println(); - } - - protected void dumpSequenceOn(Sequence sequence, IndentingPrintWriter pw) { - pw.print("sequence: "); - pw.println(sequence.getName()); - } - - - // ********** connection profile listener ********** - - protected class TestConnectionProfileListener implements ConnectionProfileListener { - public String addedName; - public String removedName; - public String renamedOldName; - public String renamedNewName; - - public void connectionProfileAdded(String name) { - this.addedName = name; - } - public void connectionProfileRemoved(String name) { - this.removedName = name; - } - public void connectionProfileRenamed(String oldName, String newName) { - this.renamedOldName = oldName; - this.renamedNewName = newName; - } - public void clear() { - this.addedName = null; - this.removedName = null; - this.renamedOldName = null; - this.renamedNewName = null; - } - } - - - // ********** connection listener ********** - - protected class TestConnectionListener implements ConnectionListener { - public ConnectionProfile openedProfile; - public ConnectionProfile modifiedProfile; - public ConnectionProfile okToCloseProfile; - public ConnectionProfile aboutToCloseProfile; - public ConnectionProfile closedProfile; - public Database changedDatabase; - public Catalog changedCatalog; - public Schema changedSchema; - public Sequence changedSequence; - public Table changedTable; - public Column changedColumn; - public ForeignKey changedForeignKey; - - public void opened(ConnectionProfile profile) { - this.openedProfile = profile; - } - public void modified(ConnectionProfile profile) { - this.modifiedProfile = profile; - } - public boolean okToClose(ConnectionProfile profile) { - this.okToCloseProfile = profile; - return true; - } - public void aboutToClose(ConnectionProfile profile) { - this.aboutToCloseProfile = profile; - } - public void closed(ConnectionProfile profile) { - this.closedProfile = profile; - } - public void databaseChanged(ConnectionProfile profile, Database database) { - this.changedDatabase = database; - } - public void catalogChanged(ConnectionProfile profile, Catalog catalog) { - this.changedCatalog = catalog; - } - public void schemaChanged(ConnectionProfile profile, Schema schema) { - this.changedSchema = schema; - } - public void sequenceChanged(ConnectionProfile profile, Sequence sequence) { - this.changedSequence = sequence; - } - public void tableChanged(ConnectionProfile profile, Table table) { - this.changedTable = table; - } - public void columnChanged(ConnectionProfile profile, Column column) { - this.changedColumn = column; - } - public void foreignKeyChanged(ConnectionProfile profile, ForeignKey foreignKey) { - this.changedForeignKey = foreignKey; - } - public void clear() { - this.openedProfile = null; - this.modifiedProfile = null; - this.okToCloseProfile = null; - this.aboutToCloseProfile = null; - this.closedProfile = null; - this.changedDatabase = null; - this.changedCatalog = null; - this.changedSchema = null; - this.changedSequence = null; - this.changedTable = null; - this.changedColumn = null; - this.changedForeignKey = null; - } - } - -} diff --git a/jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/platforms/DerbyTests.java b/jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/platforms/DerbyTests.java deleted file mode 100644 index dd5e46b91a..0000000000 --- a/jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/platforms/DerbyTests.java +++ /dev/null @@ -1,395 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2008 Oracle. All rights reserved. - * This program and the accompanying materials are 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. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.db.tests.internal.platforms; - -import org.eclipse.datatools.connectivity.sqm.core.rte.ICatalogObject; -import org.eclipse.jpt.db.Catalog; -import org.eclipse.jpt.db.Column; -import org.eclipse.jpt.db.ForeignKey; -import org.eclipse.jpt.db.Schema; -import org.eclipse.jpt.db.Table; - -/** - * Derby 10.1 Embedded Driver Test - */ -@SuppressWarnings("nls") -public class DerbyTests extends DTPPlatformTests { - - public DerbyTests(String name) { - super(name); - } - - @Override - protected void setUp() throws Exception { - super.setUp(); - } - - @Override - protected void tearDown() throws Exception { - super.tearDown(); - } - - @Override - protected String getPlatformPropertiesFileName() { - return "derby.properties"; - } - - @Override - protected String getDriverName() { - return "Derby Embedded JDBC Driver"; - } - - @Override - protected String getDriverDefinitionID() { - return "DriverDefn.Derby Embedded JDBC Driver"; - } - - @Override - protected String getDriverDefinitionType() { - return "org.eclipse.datatools.connectivity.db.derby101.genericDriverTemplate"; - } - - @Override - protected String getDatabaseVendor() { - return "Derby"; - } - - @Override - protected String getDatabaseVersion() { - return "10.1"; - } - - @Override - protected String getDriverClass() { - return "org.apache.derby.jdbc.EmbeddedDriver"; - } - - @Override - protected String getProfileName() { - return "Derby_10.1_Embedded"; - } - - @Override - protected String getProfileDescription() { - return "Derby 10.1 Embedded JDBC Profile [Test]"; - } - - @Override - protected String getProviderID() { - return "org.eclipse.datatools.connectivity.db.derby.embedded.connectionProfile"; - } - - public void testSchema() throws Exception { - this.connectionProfile.connect(); - TestConnectionListener listener = new TestConnectionListener(); - this.connectionProfile.addConnectionListener(listener); - - this.dropSchema("TEST1"); - this.dropSchema("TEST2"); - - this.executeUpdate("CREATE SCHEMA TEST1"); - ((ICatalogObject) this.getDTPDatabase()).refresh(); - - Schema schema1 = this.getDatabase().getSchemaNamed("TEST1"); - assertNotNull(schema1); - Catalog catalog = this.getDatabase().getCatalogNamed(""); // Derby's only catalog - Schema schema1a = catalog.getSchemaNamed("TEST1"); - assertNotNull(schema1a); - assertSame(schema1, schema1a); // same schema should be returned by both database and catalog - - this.executeUpdate("CREATE SCHEMA TEST2"); - Schema schema2 = this.getDatabase().getSchemaNamed("TEST2"); - assertNull(schema2); // should be null until refresh - - ((ICatalogObject) getDTPCatalog(catalog)).refresh(); - assertSame(catalog, listener.changedCatalog); - assertSame(catalog, this.getDatabase().getCatalogNamed("")); - - schema2 = this.getDatabase().getSchemaNamed("TEST2"); - assertNotNull(schema2); - Schema schema2a = catalog.getSchemaNamed("TEST2"); - assertNotNull(schema2a); - assertSame(schema2, schema2a); - assertNotSame(schema1, catalog.getSchemaNamed("TEST1")); // we should have a new schema after the refresh - - this.dropSchema("TEST2"); - this.dropSchema("TEST1"); - this.connectionProfile.removeConnectionListener(listener); - this.connectionProfile.disconnect(); - } - - public void testSchemaLookup() throws Exception { - this.connectionProfile.connect(); - TestConnectionListener listener = new TestConnectionListener(); - this.connectionProfile.addConnectionListener(listener); - - this.dropSchema("LOOKUP_TEST"); - this.dropSchema("\"lookup_TEST\""); - - this.executeUpdate("CREATE SCHEMA LOOKUP_TEST"); - ((ICatalogObject) this.getDTPDatabase()).refresh(); - - assertNotNull(this.getDatabase().getSchemaNamed("LOOKUP_TEST")); - assertNotNull(this.getDatabase().getSchemaNamed("lookup_test")); - assertNotNull(this.getDatabase().getSchemaNamed("lookup_TEST")); - assertNotNull(this.getDatabase().getSchemaNamed("\"LOOKUP_TEST\"")); - assertNull(this.getDatabase().getSchemaNamed("\"lookup_TEST\"")); - - this.dropSchema("LOOKUP_TEST"); - - this.executeUpdate("CREATE SCHEMA \"lookup_TEST\""); - ((ICatalogObject) this.getDTPDatabase()).refresh(); - - assertNull(this.getDatabase().getSchemaNamed("LOOKUP_TEST")); - assertNull(this.getDatabase().getSchemaNamed("lookup_test")); - assertNull(this.getDatabase().getSchemaNamed("lookup_TEST")); - assertNull(this.getDatabase().getSchemaNamed("\"LOOKUP_TEST\"")); - assertNotNull(this.getDatabase().getSchemaNamed("\"lookup_TEST\"")); - - this.dropSchema("\"lookup_TEST\""); - - this.connectionProfile.removeConnectionListener(listener); - this.connectionProfile.disconnect(); - } - - public void testSchemaAnnotationIdentifier() throws Exception { - this.connectionProfile.connect(); - TestConnectionListener listener = new TestConnectionListener(); - this.connectionProfile.addConnectionListener(listener); - - this.dropSchema("LOOKUP_TEST"); - this.dropSchema("\"lookup_TEST\""); - - this.executeUpdate("CREATE SCHEMA lookup_test"); // this gets folded to uppercase - this.executeUpdate("CREATE SCHEMA \"lookup_TEST\""); - ((ICatalogObject) this.getDTPDatabase()).refresh(); - - Schema schema = this.getDatabase().getSchemaNamed("LOOKUP_TEST"); - assertEquals("LOOKUP_TEST", schema.getAnnotationIdentifier()); - assertEquals("LOOKUP_TEST", schema.getAnnotationIdentifier("LookupTest")); - assertNull(schema.getAnnotationIdentifier("Lookup_Test")); - - schema = this.getDatabase().getSchemaNamed("lookup_test"); - assertEquals("LOOKUP_TEST", schema.getAnnotationIdentifier()); - - schema = this.getDatabase().getSchemaNamed("\"lookup_TEST\""); - assertEquals("\"lookup_TEST\"", schema.getAnnotationIdentifier()); - assertEquals("\"lookup_TEST\"", schema.getAnnotationIdentifier("lookup_TEST")); - - this.dropSchema("\"lookup_TEST\""); - this.dropSchema("LOOKUP_TEST"); - - this.connectionProfile.removeConnectionListener(listener); - this.connectionProfile.disconnect(); - } - - public void testTable() throws Exception { - this.connectionProfile.connect(); - TestConnectionListener listener = new TestConnectionListener(); - this.connectionProfile.addConnectionListener(listener); - - this.dropTable("TABLE_TEST", "FOO_BAZ"); - this.dropTable("TABLE_TEST", "BAZ"); - this.dropTable("TABLE_TEST", "FOO"); - this.dropTable("TABLE_TEST", "BAR"); - this.dropSchema("TABLE_TEST"); - - this.executeUpdate("CREATE SCHEMA TABLE_TEST"); - this.executeUpdate("SET SCHEMA = TABLE_TEST"); - - this.executeUpdate(this.buildBarDDL()); - this.executeUpdate(this.buildFooDDL()); - this.executeUpdate(this.buildBazDDL()); - this.executeUpdate(this.buildFooBazDDL()); - ((ICatalogObject) this.getDTPDatabase()).refresh(); - - Schema schema = this.getDatabase().getSchemaNamed("TABLE_TEST"); - - // FOO - Table fooTable = schema.getTableNamed("FOO"); - assertEquals(3, fooTable.columnsSize()); - assertEquals(1, fooTable.primaryKeyColumnsSize()); - assertEquals(1, fooTable.foreignKeysSize()); - - Column pkColumn = fooTable.getPrimaryKeyColumn(); - assertEquals("ID", pkColumn.getName()); - Column idColumn = fooTable.getColumnNamed("ID"); - assertSame(pkColumn, idColumn); - assertEquals("INTEGER", idColumn.getDataTypeName()); - assertSame(fooTable, idColumn.getTable()); - assertTrue(idColumn.isPrimaryKeyColumn()); - assertFalse(idColumn.isForeignKeyColumn()); - assertEquals("int", idColumn.getJavaTypeDeclaration()); - - Column nameColumn = fooTable.getColumnNamed("NAME"); - assertEquals("VARCHAR", nameColumn.getDataTypeName()); - assertEquals("java.lang.String", nameColumn.getJavaTypeDeclaration()); - assertFalse(nameColumn.isPrimaryKeyColumn()); - - Column barColumn = fooTable.getColumnNamed("BAR_ID"); - assertEquals("INTEGER", barColumn.getDataTypeName()); - assertTrue(barColumn.isForeignKeyColumn()); - assertFalse(barColumn.isPrimaryKeyColumn()); - - ForeignKey barFK = fooTable.foreignKeys().next(); // there should only be 1 foreign key - assertEquals(1, barFK.columnPairsSize()); - assertEquals("BAR", barFK.getAttributeName()); - assertNull(barFK.getJoinColumnAnnotationIdentifier("bar")); - assertEquals("BAR_ID", barFK.getJoinColumnAnnotationIdentifier("primaryBar")); - assertSame(fooTable, barFK.getBaseTable()); - - assertFalse(fooTable.isPossibleJoinTable()); - assertSame(schema, fooTable.getSchema()); - - // BAR - Table barTable = schema.getTableNamed("BAR"); - assertEquals(2, barTable.columnsSize()); - assertEquals(1, barTable.primaryKeyColumnsSize()); - assertEquals(0, barTable.foreignKeysSize()); - assertEquals("ID", barTable.getPrimaryKeyColumn().getName()); - assertFalse(barTable.isPossibleJoinTable()); - assertEquals("BLOB", barTable.getColumnNamed("CHUNK").getDataTypeName()); - assertEquals("byte[]", barTable.getColumnNamed("CHUNK").getJavaTypeDeclaration()); - assertTrue(barTable.getColumnNamed("CHUNK").dataTypeIsLOB()); - assertSame(barTable, barFK.getReferencedTable()); - - // FOO_BAZ - Table foo_bazTable = schema.getTableNamed("FOO_BAZ"); - assertEquals(2, foo_bazTable.columnsSize()); - assertEquals(0, foo_bazTable.primaryKeyColumnsSize()); - assertEquals(2, foo_bazTable.foreignKeysSize()); - assertTrue(foo_bazTable.isPossibleJoinTable()); - assertTrue(foo_bazTable.joinTableNameIsDefault()); - assertTrue(foo_bazTable.getColumnNamed("FOO_ID").isForeignKeyColumn()); - - this.dropTable("TABLE_TEST", "FOO_BAZ"); - this.dropTable("TABLE_TEST", "BAZ"); - this.dropTable("TABLE_TEST", "FOO"); - this.dropTable("TABLE_TEST", "BAR"); - this.dropSchema("TABLE_TEST"); - - this.connectionProfile.removeConnectionListener(listener); - this.connectionProfile.disconnect(); - } - - private static final String CR = System.getProperty("line.separator"); //$NON-NLS-1$ - - private String buildBarDDL() { - StringBuilder sb = new StringBuilder(200); - sb.append("CREATE TABLE BAR (").append(CR); - sb.append(" ID INT PRIMARY KEY,").append(CR); - sb.append(" CHUNK BLOB(100K)").append(CR); - sb.append(")").append(CR); - return sb.toString(); - } - - private String buildFooDDL() { - StringBuilder sb = new StringBuilder(200); - sb.append("CREATE TABLE FOO (").append(CR); - sb.append(" ID INT PRIMARY KEY,").append(CR); - sb.append(" NAME VARCHAR(20),").append(CR); - sb.append(" BAR_ID INT REFERENCES BAR(ID)").append(CR); - sb.append(")").append(CR); - return sb.toString(); - } - - private String buildBazDDL() { - StringBuilder sb = new StringBuilder(200); - sb.append("CREATE TABLE BAZ (").append(CR); - sb.append(" ID INT PRIMARY KEY,").append(CR); - sb.append(" NAME VARCHAR(20)").append(CR); - sb.append(")").append(CR); - return sb.toString(); - } - - private String buildFooBazDDL() { - StringBuilder sb = new StringBuilder(200); - sb.append("CREATE TABLE FOO_BAZ (").append(CR); - sb.append(" FOO_ID INT REFERENCES FOO(ID),").append(CR); - sb.append(" BAZ_ID INT REFERENCES BAZ(ID)").append(CR); - sb.append(")").append(CR); - return sb.toString(); - } - - public void testColumnLookup() throws Exception { - this.connectionProfile.connect(); - TestConnectionListener listener = new TestConnectionListener(); - this.connectionProfile.addConnectionListener(listener); - - this.dropTable("TABLE_TEST", "test"); - this.dropSchema("TABLE_TEST"); - - this.executeUpdate("CREATE SCHEMA TABLE_TEST"); - this.executeUpdate("SET SCHEMA = TABLE_TEST"); - - // lowercase - this.executeUpdate("CREATE TABLE test (id INTEGER, name VARCHAR(20))"); - ((ICatalogObject) this.getDTPDatabase()).refresh(); - - Table table = this.getDatabase().getSchemaNamed("TABLE_TEST").getTableNamed("test"); - assertNotNull(table.getColumnNamed("id")); - assertNotNull(table.getColumnNamed("name")); - - this.dropTable("TABLE_TEST", "test"); - - // uppercase - this.executeUpdate("CREATE TABLE test (ID INTEGER, NAME VARCHAR(20))"); - ((ICatalogObject) this.getDTPDatabase()).refresh(); - - table = this.getDatabase().getSchemaNamed("TABLE_TEST").getTableNamed("test"); - assertNotNull(table.getColumnNamed("ID")); - assertNotNull(table.getColumnNamed("NAME")); - - this.dropTable("TABLE_TEST", "test"); - - // mixed case - this.executeUpdate("CREATE TABLE test (Id INTEGER, Name VARCHAR(20))"); - ((ICatalogObject) this.getDTPDatabase()).refresh(); - - table = this.getDatabase().getSchemaNamed("TABLE_TEST").getTableNamed("test"); - assertNotNull(table.getColumnNamed("Id")); - assertNotNull(table.getColumnNamed("Name")); - - this.dropTable("TABLE_TEST", "test"); - - // delimited - this.executeUpdate("CREATE TABLE test (\"Id\" INTEGER, \"Name\" VARCHAR(20))"); - ((ICatalogObject) this.getDTPDatabase()).refresh(); - - table = this.getDatabase().getSchemaNamed("TABLE_TEST").getTableNamed("test"); - assertNotNull(table.getColumnNamed("\"Id\"")); - assertNotNull(table.getColumnNamed("\"Name\"")); - - this.dropTable("TABLE_TEST", "test"); - this.dropSchema("TABLE_TEST"); - - this.connectionProfile.removeConnectionListener(listener); - this.connectionProfile.disconnect(); - } - - private void dropTable(String schemaName, String tableName) throws Exception { - Schema schema= this.getSchemaNamed(schemaName); - if (schema != null) { - if (schema.getTableNamed(tableName) != null) { - this.executeUpdate("DROP TABLE " + schemaName + '.' + tableName); - } - } - } - - /** - * NB: A Derby schema must be empty before it can be dropped. - */ - private void dropSchema(String name) throws Exception { - if (this.getSchemaNamed(name) != null) { - this.executeUpdate("DROP SCHEMA " + name + " RESTRICT"); - } - } - -} diff --git a/jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/platforms/MySQLTests.java b/jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/platforms/MySQLTests.java deleted file mode 100644 index 85e0e36750..0000000000 --- a/jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/platforms/MySQLTests.java +++ /dev/null @@ -1,340 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2008 Oracle. All rights reserved. - * This program and the accompanying materials are 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. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.db.tests.internal.platforms; - -import org.eclipse.datatools.connectivity.sqm.core.rte.ICatalogObject; -import org.eclipse.jpt.db.Column; -import org.eclipse.jpt.db.ForeignKey; -import org.eclipse.jpt.db.Schema; -import org.eclipse.jpt.db.Table; - - -/** - * SQL Server 2005 Driver Test - * - * Notes: - * - We can only get database objects from the database associated with our - * connection profile. - * - We can reference objects across multiple databases, so they are sorta like - * schemas.... - * - Foreign keys must be defined as table-level constraints; they cannot be - * defined as part of the column clause. - * - Case-sensitivity and -folding is whacked on MySQL.... - */ -@SuppressWarnings("nls") -public class MySQLTests extends DTPPlatformTests { - - public MySQLTests( String name) { - super(name); - } - - @Override - protected String getPlatformPropertiesFileName() { - return "mysql.properties"; - } - - @Override - protected String getDriverName() { - return "MySQL JDBC Driver"; - } - - @Override - protected String getDriverDefinitionID() { - return "DriverDefn.MySQL JDBC Driver"; - } - - @Override - protected String getDriverDefinitionType() { - return "org.eclipse.datatools.enablement.mysql.4_1.driverTemplate"; - } - - @Override - protected String getDatabaseVendor() { - return "MySql"; - } - - @Override - protected String getDatabaseVersion() { - return "4.1"; - } - - @Override - protected String getDriverClass() { - return "com.mysql.jdbc.Driver"; - } - - @Override - protected String getDefaultJDBCURL() { - return "jdbc:mysql://localhost:3306"; - } - - @Override - protected String getProfileName() { - return "MySQL_4.1"; - } - - @Override - protected String getProfileDescription() { - return "MySQL 4.1 JDBC Profile [Test]"; - } - - public void testDatabase() throws Exception { - this.connectionProfile.connect(); - TestConnectionListener listener = new TestConnectionListener(); - this.connectionProfile.addConnectionListener(listener); - - // MySQL has a single schema with the same name as the database - Schema schema = this.getDatabase().getSchemaNamed(this.getDatabaseName()); - assertNotNull(schema); - assertSame(this.getDatabase().getDefaultSchema(), schema); - - this.connectionProfile.removeConnectionListener(listener); - this.connectionProfile.disconnect(); - } - - public void testTable() throws Exception { - this.connectionProfile.connect(); - TestConnectionListener listener = new TestConnectionListener(); - this.connectionProfile.addConnectionListener(listener); - -// this.dropDatabase("table_test"); - -// this.executeUpdate("CREATE DATABASE table_test"); - - // we must execute a USE statement before defining our tables - this.executeUpdate("USE " + this.getDatabaseName()); - - this.dropTable(this.getDatabaseName(), "foo_baz"); - this.dropTable(this.getDatabaseName(), "baz"); - this.dropTable(this.getDatabaseName(), "foo"); - this.dropTable(this.getDatabaseName(), "bar"); - - this.executeUpdate(this.buildBarDDL()); - this.executeUpdate(this.buildFooDDL()); - this.executeUpdate(this.buildBazDDL()); - this.executeUpdate(this.buildFooBazDDL()); - ((ICatalogObject) this.getDTPDatabase()).refresh(); - - Schema schema = this.getDatabase().getDefaultSchema(); - - // foo - Table fooTable = schema.getTableNamed("foo"); - assertEquals(3, fooTable.columnsSize()); - assertEquals(1, fooTable.primaryKeyColumnsSize()); - assertEquals(1, fooTable.foreignKeysSize()); - - Column pkColumn = fooTable.getPrimaryKeyColumn(); - assertEquals("id", pkColumn.getName()); - Column idColumn = fooTable.getColumnNamed("id"); - assertSame(pkColumn, idColumn); - assertEquals("INT", idColumn.getDataTypeName()); - assertSame(fooTable, idColumn.getTable()); - assertTrue(idColumn.isPrimaryKeyColumn()); - assertFalse(idColumn.isForeignKeyColumn()); - assertEquals("int", idColumn.getJavaTypeDeclaration()); - - Column nameColumn = fooTable.getColumnNamed("name"); - assertEquals("VARCHAR", nameColumn.getDataTypeName()); - assertEquals("java.lang.String", nameColumn.getJavaTypeDeclaration()); - assertFalse(nameColumn.isPrimaryKeyColumn()); - - Column barColumn = fooTable.getColumnNamed("bar_id"); - assertEquals("INT", barColumn.getDataTypeName()); - assertTrue(barColumn.isForeignKeyColumn()); - assertFalse(barColumn.isPrimaryKeyColumn()); - - ForeignKey barFK = fooTable.foreignKeys().next(); // there should only be 1 foreign key - assertEquals(1, barFK.columnPairsSize()); - assertEquals("bar", barFK.getAttributeName()); - assertNull(barFK.getJoinColumnAnnotationIdentifier("bar")); - assertEquals("bar_id", barFK.getJoinColumnAnnotationIdentifier("primaryBar")); - assertSame(fooTable, barFK.getBaseTable()); - - assertFalse(fooTable.isPossibleJoinTable()); - assertSame(schema, fooTable.getSchema()); - - // BAR - Table barTable = schema.getTableNamed("bar"); - assertEquals(2, barTable.columnsSize()); - assertEquals(1, barTable.primaryKeyColumnsSize()); - assertEquals(0, barTable.foreignKeysSize()); - assertEquals("id", barTable.getPrimaryKeyColumn().getName()); - assertFalse(barTable.isPossibleJoinTable()); - assertEquals("BLOB", barTable.getColumnNamed("chunk").getDataTypeName()); - assertEquals("byte[]", barTable.getColumnNamed("chunk").getJavaTypeDeclaration()); - assertTrue(barTable.getColumnNamed("chunk").dataTypeIsLOB()); - assertSame(barTable, barFK.getReferencedTable()); - - // FOO_BAZ - Table foo_bazTable = schema.getTableNamed("foo_baz"); - assertEquals(2, foo_bazTable.columnsSize()); - assertEquals(0, foo_bazTable.primaryKeyColumnsSize()); - assertEquals(2, foo_bazTable.foreignKeysSize()); - assertTrue(foo_bazTable.isPossibleJoinTable()); - assertTrue(foo_bazTable.joinTableNameIsDefault()); - assertTrue(foo_bazTable.getColumnNamed("foo_id").isForeignKeyColumn()); - - this.dropTable(this.getDatabaseName(), "foo_baz"); - this.dropTable(this.getDatabaseName(), "baz"); - this.dropTable(this.getDatabaseName(), "foo"); - this.dropTable(this.getDatabaseName(), "bar"); - -// this.dropDatabase("table_test"); - - this.connectionProfile.removeConnectionListener(listener); - this.connectionProfile.disconnect(); - } - - private static final String CR = System.getProperty("line.separator"); //$NON-NLS-1$ - - private String buildBarDDL() { - StringBuilder sb = new StringBuilder(200); - sb.append("CREATE TABLE bar (").append(CR); - sb.append(" id INTEGER PRIMARY KEY,").append(CR); - sb.append(" chunk BLOB").append(CR); - sb.append(")").append(CR); - return sb.toString(); - } - - private String buildFooDDL() { - StringBuilder sb = new StringBuilder(200); - sb.append("CREATE TABLE foo (").append(CR); - sb.append(" id INTEGER PRIMARY KEY,").append(CR); - sb.append(" name VARCHAR(20),").append(CR); - sb.append(" bar_id INTEGER,").append(CR); - sb.append(" FOREIGN KEY (bar_id) REFERENCES bar(id)").append(CR); - sb.append(")").append(CR); - return sb.toString(); - } - - private String buildBazDDL() { - StringBuilder sb = new StringBuilder(200); - sb.append("CREATE TABLE baz (").append(CR); - sb.append(" id INTEGER PRIMARY KEY,").append(CR); - sb.append(" name VARCHAR(20)").append(CR); - sb.append(")").append(CR); - return sb.toString(); - } - - private String buildFooBazDDL() { - StringBuilder sb = new StringBuilder(200); - sb.append("CREATE TABLE foo_baz (").append(CR); - sb.append(" foo_id INT,").append(CR); - sb.append(" baz_id INT,").append(CR); - sb.append(" FOREIGN KEY (foo_id) REFERENCES foo(id),").append(CR); - sb.append(" FOREIGN KEY (baz_id) REFERENCES baz(id)").append(CR); - sb.append(")").append(CR); - return sb.toString(); - } - - /** - * On Windows, table names get folded to lowercase by default; - * even if the name is delimited (apparently). - */ - public void testTableLookup() throws Exception { - this.connectionProfile.connect(); - TestConnectionListener listener = new TestConnectionListener(); - this.connectionProfile.addConnectionListener(listener); - - // we must execute a USE statement before defining our tables - this.executeUpdate("USE " + this.getDatabaseName()); - - this.dropTable(this.getDatabaseName(), "test1"); - this.dropTable(this.getDatabaseName(), "TEST2"); - this.dropTable(this.getDatabaseName(), "`TEST3`"); - - this.executeUpdate("CREATE TABLE test1 (id INTEGER, name VARCHAR(20))"); - this.executeUpdate("CREATE TABLE TEST2 (id INTEGER, name VARCHAR(20))"); - this.executeUpdate("CREATE TABLE `TEST3` (id INTEGER, name VARCHAR(20))"); - ((ICatalogObject) this.getDTPDatabase()).refresh(); - - Schema schema = this.getDatabase().getDefaultSchema(); - - Table test1Table = schema.getTableNamed("test1"); - assertNotNull(test1Table); - - // this probably only works on Windows - Table test2Table = schema.getTableNamed("test2"); - assertNotNull(test2Table); - - // this probably only works on Windows - Table test3Table = schema.getTableNamed("`test3`"); - assertNotNull(test3Table); - - this.dropTable(this.getDatabaseName(), "test1"); - this.dropTable(this.getDatabaseName(), "TEST2"); - this.dropTable(this.getDatabaseName(), "`TEST3`"); - - this.connectionProfile.removeConnectionListener(listener); - this.connectionProfile.disconnect(); - } - - public void testColumnLookup() throws Exception { - this.connectionProfile.connect(); - TestConnectionListener listener = new TestConnectionListener(); - this.connectionProfile.addConnectionListener(listener); - - // we must execute a USE statement before defining our tables - this.executeUpdate("USE " + this.getDatabaseName()); - this.dropTable(this.getDatabaseName(), "test"); - - // lowercase - this.executeUpdate("CREATE TABLE test (id INTEGER, name VARCHAR(20))"); - ((ICatalogObject) this.getDTPDatabase()).refresh(); - - Table table = this.getDatabase().getDefaultSchema().getTableNamed("test"); - assertNotNull(table.getColumnNamed("id")); - assertNotNull(table.getColumnNamed("name")); - - this.dropTable(this.getDatabaseName(), "test"); - - // uppercase - this.executeUpdate("CREATE TABLE test (ID INTEGER, NAME VARCHAR(20))"); - ((ICatalogObject) this.getDTPDatabase()).refresh(); - - table = this.getDatabase().getDefaultSchema().getTableNamed("test"); - assertNotNull(table.getColumnNamed("ID")); - assertNotNull(table.getColumnNamed("NAME")); - - this.dropTable(this.getDatabaseName(), "test"); - - // mixed case - this.executeUpdate("CREATE TABLE test (Id INTEGER, Name VARCHAR(20))"); - ((ICatalogObject) this.getDTPDatabase()).refresh(); - - table = this.getDatabase().getDefaultSchema().getTableNamed("test"); - assertNotNull(table.getColumnNamed("Id")); - assertNotNull(table.getColumnNamed("Name")); - - this.dropTable(this.getDatabaseName(), "test"); - - // delimited - this.executeUpdate("CREATE TABLE test (`Id` INTEGER, `Name` VARCHAR(20))"); - ((ICatalogObject) this.getDTPDatabase()).refresh(); - - table = this.getDatabase().getDefaultSchema().getTableNamed("test"); - assertNotNull(table.getColumnNamed("`Id`")); - assertNotNull(table.getColumnNamed("`Name`")); - - this.dropTable(this.getDatabaseName(), "test"); - - this.connectionProfile.removeConnectionListener(listener); - this.connectionProfile.disconnect(); - } - - private void dropTable(String dbName, String tableName) throws Exception { - this.executeUpdate("DROP TABLE IF EXISTS " + dbName + '.' + tableName); - } - -// private void dropDatabase(String name) throws Exception { -// this.executeUpdate("DROP DATABASE IF EXISTS " + name); -// } -// -} diff --git a/jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/platforms/Oracle10gTests.java b/jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/platforms/Oracle10gTests.java deleted file mode 100644 index e38a46fecc..0000000000 --- a/jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/platforms/Oracle10gTests.java +++ /dev/null @@ -1,314 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2008 Oracle. All rights reserved. - * This program and the accompanying materials are 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. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.db.tests.internal.platforms; - -import org.eclipse.datatools.connectivity.sqm.core.rte.ICatalogObject; -import org.eclipse.jpt.db.Column; -import org.eclipse.jpt.db.ForeignKey; -import org.eclipse.jpt.db.Schema; -import org.eclipse.jpt.db.Table; - -/** - * Oracle 10g Thin Driver Test - */ -@SuppressWarnings("nls") -public class Oracle10gTests extends DTPPlatformTests { - - public Oracle10gTests( String name) { - super( name); - } - - @Override - protected String getPlatformPropertiesFileName() { - return "oracle10g.properties"; - } - - @Override - protected String getDriverName() { - return "Oracle 10g Thin Driver"; - } - - @Override - protected String getDriverDefinitionID() { - return "DriverDefn.Oracle Thin Driver"; - } - - @Override - protected String getDriverDefinitionType() { - return "org.eclipse.datatools.enablement.oracle.10.driverTemplate"; - } - - @Override - protected String getDatabaseVendor() { - return "Oracle"; - } - - @Override - protected String getDatabaseVersion() { - return "10"; - } - - @Override - protected String getDriverClass() { - return "oracle.jdbc.OracleDriver"; - } - - @Override - protected String getProfileName() { - return "Oracle10g_10.1.0.4"; - } - - @Override - protected String getProfileDescription() { - return "Oracle10g (10.1.0.4) JDBC Profile [Test]"; - } - - @Override - public void testOffline() { - // working offline is pretty ugly - } - - @Override - public void testConnectionListenerOffline() { - // working offline is pretty ugly - } - - public void testDatabase() throws Exception { - this.connectionProfile.connect(); - TestConnectionListener listener = new TestConnectionListener(); - this.connectionProfile.addConnectionListener(listener); - - // Oracle should have a schema with the same name as the user - Schema schema = this.getDatabase().getSchemaNamed(this.getUserID()); - assertNotNull(schema); - assertSame(this.getDatabase().getDefaultSchema(), schema); - - this.connectionProfile.removeConnectionListener(listener); - this.connectionProfile.disconnect(); - } - - public void testTable() throws Exception { - this.connectionProfile.connect(); - TestConnectionListener listener = new TestConnectionListener(); - this.connectionProfile.addConnectionListener(listener); - - this.dropTable("foo_baz"); - this.dropTable("baz"); - this.dropTable("foo"); - this.dropTable("bar"); - - this.executeUpdate(this.buildBarDDL()); - this.executeUpdate(this.buildFooDDL()); - this.executeUpdate(this.buildBazDDL()); - this.executeUpdate(this.buildFooBazDDL()); - ((ICatalogObject) this.getDTPDatabase()).refresh(); - - Schema schema = this.getDatabase().getDefaultSchema(); - - // foo - Table fooTable = schema.getTableNamed("foo"); - assertEquals(3, fooTable.columnsSize()); - assertEquals(1, fooTable.primaryKeyColumnsSize()); - assertEquals(1, fooTable.foreignKeysSize()); - - Column pkColumn = fooTable.getPrimaryKeyColumn(); - assertEquals("ID", pkColumn.getName()); - Column idColumn = fooTable.getColumnNamed("id"); - assertSame(pkColumn, idColumn); - assertEquals("NUMBER", idColumn.getDataTypeName()); - assertSame(fooTable, idColumn.getTable()); - assertTrue(idColumn.isPrimaryKeyColumn()); - assertFalse(idColumn.isForeignKeyColumn()); - assertEquals("java.math.BigDecimal", idColumn.getJavaTypeDeclaration()); - - Column nameColumn = fooTable.getColumnNamed("name"); - assertEquals("VARCHAR2", nameColumn.getDataTypeName()); - assertEquals("java.lang.String", nameColumn.getJavaTypeDeclaration()); - assertFalse(nameColumn.isPrimaryKeyColumn()); - - Column barColumn = fooTable.getColumnNamed("bar_id"); - assertEquals("NUMBER", barColumn.getDataTypeName()); - assertTrue(barColumn.isForeignKeyColumn()); - assertFalse(barColumn.isPrimaryKeyColumn()); - - ForeignKey barFK = fooTable.foreignKeys().next(); // there should only be 1 foreign key - assertEquals(1, barFK.columnPairsSize()); - assertEquals("BAR", barFK.getAttributeName()); - assertNull(barFK.getJoinColumnAnnotationIdentifier("bar")); - assertEquals("BAR_ID", barFK.getJoinColumnAnnotationIdentifier("primaryBar")); - assertSame(fooTable, barFK.getBaseTable()); - - assertFalse(fooTable.isPossibleJoinTable()); - assertSame(schema, fooTable.getSchema()); - - // BAR - Table barTable = schema.getTableNamed("bar"); - assertEquals(2, barTable.columnsSize()); - assertEquals(1, barTable.primaryKeyColumnsSize()); - assertEquals(0, barTable.foreignKeysSize()); - assertEquals("ID", barTable.getPrimaryKeyColumn().getName()); - assertFalse(barTable.isPossibleJoinTable()); - assertEquals("BLOB", barTable.getColumnNamed("chunk").getDataTypeName()); - assertEquals("byte[]", barTable.getColumnNamed("chunk").getJavaTypeDeclaration()); - assertTrue(barTable.getColumnNamed("chunk").dataTypeIsLOB()); - assertSame(barTable, barFK.getReferencedTable()); - - // FOO_BAZ - Table foo_bazTable = schema.getTableNamed("foo_baz"); - assertEquals(2, foo_bazTable.columnsSize()); - assertEquals(0, foo_bazTable.primaryKeyColumnsSize()); - assertEquals(2, foo_bazTable.foreignKeysSize()); - assertTrue(foo_bazTable.isPossibleJoinTable()); - assertTrue(foo_bazTable.joinTableNameIsDefault()); - assertTrue(foo_bazTable.getColumnNamed("foo_id").isForeignKeyColumn()); - - this.dropTable("foo_baz"); - this.dropTable("baz"); - this.dropTable("foo"); - this.dropTable("bar"); - - this.connectionProfile.removeConnectionListener(listener); - this.connectionProfile.disconnect(); - } - - private static final String CR = System.getProperty("line.separator"); //$NON-NLS-1$ - - private String buildBarDDL() { - StringBuilder sb = new StringBuilder(200); - sb.append("CREATE TABLE bar (").append(CR); - sb.append(" id NUMBER(10) PRIMARY KEY,").append(CR); - sb.append(" chunk BLOB").append(CR); - sb.append(")").append(CR); - return sb.toString(); - } - - private String buildFooDDL() { - StringBuilder sb = new StringBuilder(200); - sb.append("CREATE TABLE foo (").append(CR); - sb.append(" id NUMBER(10) PRIMARY KEY,").append(CR); - sb.append(" name VARCHAR2(20),").append(CR); - sb.append(" bar_id REFERENCES bar(id)").append(CR); - sb.append(")").append(CR); - return sb.toString(); - } - - private String buildBazDDL() { - StringBuilder sb = new StringBuilder(200); - sb.append("CREATE TABLE baz (").append(CR); - sb.append(" id NUMBER(10) PRIMARY KEY,").append(CR); - sb.append(" name VARCHAR2(20)").append(CR); - sb.append(")").append(CR); - return sb.toString(); - } - - private String buildFooBazDDL() { - StringBuilder sb = new StringBuilder(200); - sb.append("CREATE TABLE foo_baz (").append(CR); - sb.append(" foo_id NUMBER(10) REFERENCES foo(id),").append(CR); - sb.append(" baz_id NUMBER(10) REFERENCES baz(id)").append(CR); - sb.append(")").append(CR); - return sb.toString(); - } - - public void testTableLookup() throws Exception { - this.connectionProfile.connect(); - TestConnectionListener listener = new TestConnectionListener(); - this.connectionProfile.addConnectionListener(listener); - - this.dropTable("test1"); - this.dropTable("TEST2"); - this.dropTable("\"test3\""); - - this.executeUpdate("CREATE TABLE test1 (id NUMBER(10), name VARCHAR2(20))"); - this.executeUpdate("CREATE TABLE TEST2 (id NUMBER(10), name VARCHAR2(20))"); - this.executeUpdate("CREATE TABLE \"test3\" (id NUMBER(10), name VARCHAR2(20))"); - ((ICatalogObject) this.getDTPDatabase()).refresh(); - - Schema schema = this.getDatabase().getDefaultSchema(); - - Table test1Table = schema.getTableNamed("test1"); - assertNotNull(test1Table); - test1Table = schema.getTableNamed("TEST1"); - assertNotNull(test1Table); - - Table test2Table = schema.getTableNamed("test2"); - assertNotNull(test2Table); - test2Table = schema.getTableNamed("TEST2"); - assertNotNull(test2Table); - - Table test3Table = schema.getTableNamed("\"test3\""); - assertNotNull(test3Table); - test3Table = schema.getTableNamed("test3"); - assertNull(test3Table); - - this.dropTable("test1"); - this.dropTable("TEST2"); - this.dropTable("\"test3\""); - - this.connectionProfile.removeConnectionListener(listener); - this.connectionProfile.disconnect(); - } - - public void testColumnLookup() throws Exception { - this.connectionProfile.connect(); - TestConnectionListener listener = new TestConnectionListener(); - this.connectionProfile.addConnectionListener(listener); - - this.dropTable("test"); - - // lowercase - this.executeUpdate("CREATE TABLE test (id NUMBER(10), name VARCHAR2(20))"); - ((ICatalogObject) this.getDTPDatabase()).refresh(); - - Table table = this.getDatabase().getDefaultSchema().getTableNamed("test"); - assertNotNull(table.getColumnNamed("id")); - assertNotNull(table.getColumnNamed("name")); - - this.dropTable("test"); - - // uppercase - this.executeUpdate("CREATE TABLE test (ID NUMBER(10), NAME VARCHAR2(20))"); - ((ICatalogObject) this.getDTPDatabase()).refresh(); - - table = this.getDatabase().getDefaultSchema().getTableNamed("test"); - assertNotNull(table.getColumnNamed("ID")); - assertNotNull(table.getColumnNamed("NAME")); - - this.dropTable("test"); - - // mixed case - this.executeUpdate("CREATE TABLE test (Id NUMBER(10), Name VARCHAR2(20))"); - ((ICatalogObject) this.getDTPDatabase()).refresh(); - - table = this.getDatabase().getDefaultSchema().getTableNamed("test"); - assertNotNull(table.getColumnNamed("Id")); - assertNotNull(table.getColumnNamed("Name")); - - this.dropTable("test"); - - // delimited - this.executeUpdate("CREATE TABLE test (\"Id\" NUMBER(10), \"Name\" VARCHAR2(20))"); - ((ICatalogObject) this.getDTPDatabase()).refresh(); - - table = this.getDatabase().getDefaultSchema().getTableNamed("test"); - assertNotNull(table.getColumnNamed("\"Id\"")); - assertNotNull(table.getColumnNamed("\"Name\"")); - - this.dropTable("test"); - - this.connectionProfile.removeConnectionListener(listener); - this.connectionProfile.disconnect(); - } - - private void dropTable(String tableName) throws Exception { - this.executeUpdateIgnoreErrors("DROP TABLE " + tableName + " CASCADE CONSTRAINTS"); - } - -} diff --git a/jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/platforms/Oracle10gXETests.java b/jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/platforms/Oracle10gXETests.java deleted file mode 100644 index 3ffb7dbc77..0000000000 --- a/jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/platforms/Oracle10gXETests.java +++ /dev/null @@ -1,68 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2008 Oracle. All rights reserved. - * This program and the accompanying materials are 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. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.db.tests.internal.platforms; - - -/** - * Oracle 10g Thin Driver Test - */ -@SuppressWarnings("nls") -public class Oracle10gXETests extends DTPPlatformTests { - - public Oracle10gXETests( String name) { - super( name); - } - - @Override - protected String getPlatformPropertiesFileName() { - return "oracle10gXE.properties"; - } - - @Override - protected String getDriverName() { - return "Oracle 10g Thin Driver"; - } - - @Override - protected String getDriverDefinitionID() { - return "DriverDefn.Oracle Thin Driver"; - } - - @Override - protected String getDriverDefinitionType() { - return "org.eclipse.datatools.enablement.oracle.10.driverTemplate"; - } - - @Override - protected String getDatabaseVendor() { - return "Oracle"; - } - - @Override - protected String getDatabaseVersion() { - return "10"; - } - - @Override - protected String getDriverClass() { - return "oracle.jdbc.OracleDriver"; - } - - @Override - protected String getProfileName() { - return "Oracle10g_XE"; - } - - @Override - protected String getProfileDescription() { - return "Oracle10g XE Release 2 (10.2) JDBC Profile [Test]"; - } - -} diff --git a/jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/platforms/Oracle9iTests.java b/jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/platforms/Oracle9iTests.java deleted file mode 100644 index 8efa20bd80..0000000000 --- a/jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/platforms/Oracle9iTests.java +++ /dev/null @@ -1,68 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2008 Oracle. All rights reserved. - * This program and the accompanying materials are 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. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.db.tests.internal.platforms; - - -/** - * Oracle 9i Thin Driver Test - */ -@SuppressWarnings("nls") -public class Oracle9iTests extends DTPPlatformTests { - - public Oracle9iTests( String name) { - super( name); - } - - @Override - protected String getPlatformPropertiesFileName() { - return "oracle9i.properties"; - } - - @Override - protected String getDriverName() { - return "Oracle 9i Thin Driver"; - } - - @Override - protected String getDriverDefinitionID() { - return "DriverDefn.Oracle Thin Driver"; - } - - @Override - protected String getDriverDefinitionType() { - return "org.eclipse.datatools.enablement.oracle.9.driverTemplate"; - } - - @Override - protected String getDatabaseVendor() { - return "Oracle"; - } - - @Override - protected String getDatabaseVersion() { - return "9"; - } - - @Override - protected String getDriverClass() { - return "oracle.jdbc.OracleDriver"; - } - - @Override - protected String getProfileName() { - return "Oracle9i"; - } - - @Override - protected String getProfileDescription() { - return "Oracle9i JDBC Profile [Test]"; - } - -} diff --git a/jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/platforms/PostgreSQLTests.java b/jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/platforms/PostgreSQLTests.java deleted file mode 100644 index 6f32c77daa..0000000000 --- a/jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/platforms/PostgreSQLTests.java +++ /dev/null @@ -1,424 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2008 Oracle. All rights reserved. - * This program and the accompanying materials are 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. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.db.tests.internal.platforms; - -import org.eclipse.datatools.connectivity.sqm.core.rte.ICatalogObject; -import org.eclipse.jpt.db.Column; -import org.eclipse.jpt.db.ForeignKey; -import org.eclipse.jpt.db.Schema; -import org.eclipse.jpt.db.Table; - - -/** - * Oracle 10g Thin Driver Test - */ -@SuppressWarnings("nls") -public class PostgreSQLTests extends DTPPlatformTests { - - public PostgreSQLTests( String name) { - super( name); - } - - @Override - protected String getPlatformPropertiesFileName() { - return "postgresql.properties"; - } - - @Override - protected String getDriverName() { - return "PostgreSQL JDBC Driver"; - } - - @Override - protected String getDriverDefinitionID() { - return "DriverDefn.PostgreSQL JDBC Driver"; - } - - @Override - protected String getDriverDefinitionType() { - return "org.eclipse.datatools.enablement.postgresql.postgresqlDriverTemplate"; - } - - @Override - protected String getDatabaseVendor() { - return "postgres"; - } - - @Override - protected String getDatabaseVersion() { - return "8.x"; - } - - @Override - protected String getDriverClass() { - return "org.postgresql.Driver"; - } - - @Override - protected String getDefaultJDBCURL() { - return "jdbc:postgresql"; - } - - @Override - protected String getProfileName() { - return "PostgreSQL"; - } - - @Override - protected String getProfileDescription() { - return "PostgreSQL 8.2 JDBC Profile [Test]"; - } - - @Override - public void testOffline() { - // DTP does not support PostgreSQL off-line - see 226704/241558 - } - - @Override - public void testConnectionListenerOffline() { - // DTP does not support PostgreSQL off-line - see 226704/241558 - } - - public void testSchema() throws Exception { - this.connectionProfile.connect(); - TestConnectionListener listener = new TestConnectionListener(); - this.connectionProfile.addConnectionListener(listener); - - this.dropSchema("TEST1"); - this.dropSchema("TEST2"); - - this.executeUpdate("CREATE SCHEMA TEST1"); - ((ICatalogObject) this.getDTPDatabase()).refresh(); - - Schema schema1 = this.getDatabase().getSchemaNamed("TEST1"); - assertNotNull(schema1); - - this.executeUpdate("CREATE SCHEMA TEST2"); - Schema schema2 = this.getDatabase().getSchemaNamed("TEST2"); - assertNull(schema2); // should be null until refresh - - ((ICatalogObject) this.getDTPDatabase()).refresh(); - assertSame(this.getDatabase(), listener.changedDatabase); - - schema2 = this.getDatabase().getSchemaNamed("TEST2"); - assertNotNull(schema2); - assertNotSame(schema1, this.getDatabase().getSchemaNamed("TEST1")); // we should have a new schema after the refresh - - this.dropSchema("TEST2"); - this.dropSchema("TEST1"); - this.connectionProfile.removeConnectionListener(listener); - this.connectionProfile.disconnect(); - } - - public void testSchemaLookup() throws Exception { - this.connectionProfile.connect(); - TestConnectionListener listener = new TestConnectionListener(); - this.connectionProfile.addConnectionListener(listener); - - this.dropSchema("LOOKUP_TEST"); - this.dropSchema("\"lookup_TEST\""); - - this.executeUpdate("CREATE SCHEMA LOOKUP_TEST"); - ((ICatalogObject) this.getDTPDatabase()).refresh(); - - assertNotNull(this.getDatabase().getSchemaNamed("LOOKUP_TEST")); - assertNotNull(this.getDatabase().getSchemaNamed("lookup_test")); - assertNotNull(this.getDatabase().getSchemaNamed("lookup_TEST")); - assertNotNull(this.getDatabase().getSchemaNamed("\"lookup_test\"")); - assertNull(this.getDatabase().getSchemaNamed("\"lookup_TEST\"")); - assertNull(this.getDatabase().getSchemaNamed("\"LOOKUP_TEST\"")); - - this.dropSchema("LOOKUP_TEST"); - - this.executeUpdate("CREATE SCHEMA \"lookup_TEST\""); - ((ICatalogObject) this.getDTPDatabase()).refresh(); - - assertNull(this.getDatabase().getSchemaNamed("LOOKUP_TEST")); - assertNull(this.getDatabase().getSchemaNamed("lookup_test")); - assertNull(this.getDatabase().getSchemaNamed("lookup_TEST")); - assertNull(this.getDatabase().getSchemaNamed("\"LOOKUP_TEST\"")); - assertNotNull(this.getDatabase().getSchemaNamed("\"lookup_TEST\"")); - - this.dropSchema("\"lookup_TEST\""); - - this.connectionProfile.removeConnectionListener(listener); - this.connectionProfile.disconnect(); - } - - public void testSchemaAnnotationIdentifier() throws Exception { - this.connectionProfile.connect(); - TestConnectionListener listener = new TestConnectionListener(); - this.connectionProfile.addConnectionListener(listener); - - this.dropSchema("LOOKUP_TEST"); - this.dropSchema("\"lookup_TEST\""); - - this.executeUpdate("CREATE SCHEMA lookup_test"); // this gets folded to uppercase - this.executeUpdate("CREATE SCHEMA \"lookup_TEST\""); - ((ICatalogObject) this.getDTPDatabase()).refresh(); - - Schema schema = this.getDatabase().getSchemaNamed("LOOKUP_TEST"); - assertEquals("lookup_test", schema.getAnnotationIdentifier()); - assertEquals("lookup_test", schema.getAnnotationIdentifier("LookupTest")); - assertNull(schema.getAnnotationIdentifier("Lookup_Test")); - - schema = this.getDatabase().getSchemaNamed("lookup_test"); - assertEquals("lookup_test", schema.getAnnotationIdentifier()); - - schema = this.getDatabase().getSchemaNamed("\"lookup_TEST\""); - assertEquals("\"lookup_TEST\"", schema.getAnnotationIdentifier()); - assertEquals("\"lookup_TEST\"", schema.getAnnotationIdentifier("lookup_TEST")); - - this.dropSchema("\"lookup_TEST\""); - this.dropSchema("LOOKUP_TEST"); - - this.connectionProfile.removeConnectionListener(listener); - this.connectionProfile.disconnect(); - } - - public void testTable() throws Exception { - this.connectionProfile.connect(); - TestConnectionListener listener = new TestConnectionListener(); - this.connectionProfile.addConnectionListener(listener); - - this.dropTable("TABLE_TEST", "FOO_BAZ"); - this.dropTable("TABLE_TEST", "BAZ"); - this.dropTable("TABLE_TEST", "FOO"); - this.dropTable("TABLE_TEST", "BAR"); - this.dropSchema("TABLE_TEST"); - - this.executeUpdate("CREATE SCHEMA TABLE_TEST"); - this.executeUpdate("SET search_path TO TABLE_TEST"); - - this.executeUpdate(this.buildBarDDL()); - this.executeUpdate(this.buildFooDDL()); - this.executeUpdate(this.buildBazDDL()); - this.executeUpdate(this.buildFooBazDDL()); - ((ICatalogObject) this.getDTPDatabase()).refresh(); - - Schema schema = this.getDatabase().getSchemaNamed("TABLE_TEST"); - - // FOO - Table fooTable = schema.getTableNamed("FOO"); - assertEquals(3, fooTable.columnsSize()); - assertEquals(1, fooTable.primaryKeyColumnsSize()); - assertEquals(1, fooTable.foreignKeysSize()); - - Column pkColumn = fooTable.getPrimaryKeyColumn(); - assertEquals("id", pkColumn.getName()); - Column idColumn = fooTable.getColumnNamed("ID"); - assertSame(pkColumn, idColumn); - assertEquals("INT4", idColumn.getDataTypeName()); - assertSame(fooTable, idColumn.getTable()); - assertTrue(idColumn.isPrimaryKeyColumn()); - assertFalse(idColumn.isForeignKeyColumn()); - assertEquals("java.lang.Integer", idColumn.getJavaTypeDeclaration()); - - Column nameColumn = fooTable.getColumnNamed("NAME"); - assertEquals("VARCHAR", nameColumn.getDataTypeName()); - assertEquals("java.lang.String", nameColumn.getJavaTypeDeclaration()); - assertFalse(nameColumn.isPrimaryKeyColumn()); - - Column barColumn = fooTable.getColumnNamed("BAR_ID"); - assertEquals("INT4", barColumn.getDataTypeName()); - assertTrue(barColumn.isForeignKeyColumn()); - assertFalse(barColumn.isPrimaryKeyColumn()); - - ForeignKey barFK = fooTable.foreignKeys().next(); // there should only be 1 foreign key - assertEquals(1, barFK.columnPairsSize()); - assertEquals("bar", barFK.getAttributeName()); - assertNull(barFK.getJoinColumnAnnotationIdentifier("bar")); - assertEquals("bar_id", barFK.getJoinColumnAnnotationIdentifier("primaryBar")); - assertSame(fooTable, barFK.getBaseTable()); - - assertFalse(fooTable.isPossibleJoinTable()); - assertSame(schema, fooTable.getSchema()); - - // BAR - Table barTable = schema.getTableNamed("BAR"); - assertEquals(2, barTable.columnsSize()); - assertEquals(1, barTable.primaryKeyColumnsSize()); - assertEquals(0, barTable.foreignKeysSize()); - assertEquals("id", barTable.getPrimaryKeyColumn().getName()); - assertFalse(barTable.isPossibleJoinTable()); - assertEquals("BYTEA", barTable.getColumnNamed("CHUNK").getDataTypeName()); - assertEquals("byte[]", barTable.getColumnNamed("CHUNK").getJavaTypeDeclaration()); - // assertTrue(barTable.getColumnNamed("CHUNK").dataTypeIsLOB()); - assertSame(barTable, barFK.getReferencedTable()); - - // FOO_BAZ - Table foo_bazTable = schema.getTableNamed("FOO_BAZ"); - assertEquals(2, foo_bazTable.columnsSize()); - assertEquals(0, foo_bazTable.primaryKeyColumnsSize()); - assertEquals(2, foo_bazTable.foreignKeysSize()); - assertTrue(foo_bazTable.isPossibleJoinTable()); - assertTrue(foo_bazTable.joinTableNameIsDefault()); - assertTrue(foo_bazTable.getColumnNamed("FOO_ID").isForeignKeyColumn()); - - this.dropTable("TABLE_TEST", "FOO_BAZ"); - this.dropTable("TABLE_TEST", "BAZ"); - this.dropTable("TABLE_TEST", "FOO"); - this.dropTable("TABLE_TEST", "BAR"); - this.dropSchema("TABLE_TEST"); - - this.connectionProfile.removeConnectionListener(listener); - this.connectionProfile.disconnect(); - } - - private static final String CR = System.getProperty("line.separator"); //$NON-NLS-1$ - - private String buildBarDDL() { - StringBuilder sb = new StringBuilder(200); - sb.append("CREATE TABLE BAR (").append(CR); - sb.append(" ID integer PRIMARY KEY,").append(CR); - sb.append(" CHUNK bytea").append(CR); - sb.append(")").append(CR); - return sb.toString(); - } - - private String buildFooDDL() { - StringBuilder sb = new StringBuilder(200); - sb.append("CREATE TABLE FOO (").append(CR); - sb.append(" ID integer PRIMARY KEY,").append(CR); - sb.append(" NAME varchar(20),").append(CR); - sb.append(" BAR_ID integer REFERENCES BAR(ID)").append(CR); - sb.append(")").append(CR); - return sb.toString(); - } - - private String buildBazDDL() { - StringBuilder sb = new StringBuilder(200); - sb.append("CREATE TABLE BAZ (").append(CR); - sb.append(" ID integer PRIMARY KEY,").append(CR); - sb.append(" NAME varchar(20)").append(CR); - sb.append(")").append(CR); - return sb.toString(); - } - - private String buildFooBazDDL() { - StringBuilder sb = new StringBuilder(200); - sb.append("CREATE TABLE FOO_BAZ (").append(CR); - sb.append(" FOO_ID int REFERENCES FOO(ID),").append(CR); - sb.append(" BAZ_ID int REFERENCES BAZ(ID)").append(CR); - sb.append(")").append(CR); - return sb.toString(); - } - - public void testColumnLookup() throws Exception { - this.connectionProfile.connect(); - TestConnectionListener listener = new TestConnectionListener(); - this.connectionProfile.addConnectionListener(listener); - - this.dropTable("TABLE_TEST", "test"); - this.dropSchema("TABLE_TEST"); - - this.executeUpdate("CREATE SCHEMA TABLE_TEST"); - this.executeUpdate("SET search_path TO TABLE_TEST"); - - // lowercase - this.executeUpdate("CREATE TABLE test (id int, name varchar(20))"); - ((ICatalogObject) this.getDTPDatabase()).refresh(); - - Table table = this.getDatabase().getSchemaNamed("TABLE_TEST").getTableNamed("test"); - assertNotNull(table.getColumnNamed("id")); - assertNotNull(table.getColumnNamed("name")); - - this.dropTable("TABLE_TEST", "test"); - - // uppercase - this.executeUpdate("CREATE TABLE test (ID int, NAME varchar(20))"); - ((ICatalogObject) this.getDTPDatabase()).refresh(); - - table = this.getDatabase().getSchemaNamed("TABLE_TEST").getTableNamed("test"); - assertNotNull(table.getColumnNamed("ID")); - assertNotNull(table.getColumnNamed("NAME")); - - this.dropTable("TABLE_TEST", "test"); - - // mixed case - this.executeUpdate("CREATE TABLE test (Id int, Name varchar(20))"); - ((ICatalogObject) this.getDTPDatabase()).refresh(); - - table = this.getDatabase().getSchemaNamed("TABLE_TEST").getTableNamed("test"); - assertNotNull(table.getColumnNamed("Id")); - assertNotNull(table.getColumnNamed("Name")); - - this.dropTable("TABLE_TEST", "test"); - - // delimited - this.executeUpdate("CREATE TABLE test (\"Id\" int, \"Name\" varchar(20))"); - ((ICatalogObject) this.getDTPDatabase()).refresh(); - - table = this.getDatabase().getSchemaNamed("TABLE_TEST").getTableNamed("test"); - assertNotNull(table.getColumnNamed("\"Id\"")); - assertNotNull(table.getColumnNamed("\"Name\"")); - - this.dropTable("TABLE_TEST", "test"); - this.dropSchema("TABLE_TEST"); - - this.connectionProfile.removeConnectionListener(listener); - this.connectionProfile.disconnect(); - } - - private void dropTable(String schemaName, String tableName) throws Exception { - Schema schema= this.getSchemaNamed(schemaName); - if (schema != null) { - if (schema.getTableNamed(tableName) != null) { - this.executeUpdate("DROP TABLE " + schemaName + '.' + tableName); - } - } - } - - private void dropSchema(String name) throws Exception { - if (this.getSchemaNamed(name) != null) { - this.executeUpdate("DROP SCHEMA " + name + " CASCADE"); - } - } - -// see 241578/241557 -// public void testSequence() throws Exception { -// this.connectionProfile.connect(); -// TestConnectionListener listener = new TestConnectionListener(); -// this.connectionProfile.addConnectionListener(listener); -// -// this.dropSequence("SEQUENCE_TEST", "FOO"); -// this.dropSchema("SEQUENCE_TEST"); -// -// this.executeUpdate("CREATE SCHEMA SEQUENCE_TEST"); -// this.executeUpdate("SET search_path TO SEQUENCE_TEST"); -// -// this.executeUpdate(this.buildBarDDL()); -// this.executeUpdate("CREATE SEQUENCE FOO START 1"); -//// List<Object[]> list = this.execute("SELECT nextval('foo')"); -//// System.out.println(list); -// ((ICatalogObject) this.getDTPDatabase()).refresh(); -// -// Schema schema = this.getDatabase().getSchemaNamed("SEQUENCE_TEST"); -// Sequence sequence = schema.getSequenceNamed("FOO"); -// assertNotNull(sequence); -// assertEquals("foo_seq", sequence.getName()); -// -// this.dropSequence("SEQUENCE_TEST", "FOO"); -// this.dropSchema("SEQUENCE_TEST"); -// -// this.connectionProfile.removeConnectionListener(listener); -// this.connectionProfile.disconnect(); -// } -// -// private void dropSequence(String schemaName, String sequenceName) throws Exception { -// Schema schema= this.getSchemaNamed(schemaName); -// if (schema != null) { -// if (schema.getSequenceNamed(sequenceName) != null) { -// this.executeUpdate("DROP SEQUENCE " + schemaName + '.' + sequenceName); -// } -// } -// } -// -} diff --git a/jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/platforms/SQLServerTests.java b/jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/platforms/SQLServerTests.java deleted file mode 100644 index 16603b3343..0000000000 --- a/jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/platforms/SQLServerTests.java +++ /dev/null @@ -1,73 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2008 Oracle. All rights reserved. - * This program and the accompanying materials are 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. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.db.tests.internal.platforms; - - -/** - * SQL Server 2005 Driver Test - */ -@SuppressWarnings("nls") -public class SQLServerTests extends DTPPlatformTests { - - public SQLServerTests( String name) { - super( name); - } - - @Override - protected String getPlatformPropertiesFileName() { - return "sqlserver.properties"; - } - - @Override - protected String getDriverName() { - return "Microsoft SQL Server 2005 JDBC Driver"; - } - - @Override - protected String getDriverDefinitionID() { - return "DriverDefn.Microsoft SQL Server 2005 JDBC Driver"; - } - - @Override - protected String getDriverDefinitionType() { - return "org.eclipse.datatools.enablement.msft.sqlserver.2005.driverTemplate"; - } - - @Override - protected String getDatabaseVendor() { - return "SQLServer"; - } - - @Override - protected String getDatabaseVersion() { - return "2005"; - } - - @Override - protected String getDriverClass() { - return "com.microsoft.sqlserver.jdbc.SQLServerDriver"; - } - - @Override - protected String getProfileName() { - return "SQLServer_2005"; - } - - @Override - protected String getProfileDescription() { - return "Microsoft SQL Server 2005 JDBC Profile [Test]"; - } - - @Override - protected String getProviderID() { - return "org.eclipse.datatools.connectivity.db.generic.connectionProfile"; - } - -} diff --git a/jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/platforms/SybaseTests.java b/jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/platforms/SybaseTests.java deleted file mode 100644 index fc16e2ca9a..0000000000 --- a/jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/platforms/SybaseTests.java +++ /dev/null @@ -1,68 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2008 Oracle. All rights reserved. - * This program and the accompanying materials are 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. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.db.tests.internal.platforms; - - -/** - * Oracle 10g Thin Driver Test - */ -@SuppressWarnings("nls") -public class SybaseTests extends DTPPlatformTests { - - public SybaseTests( String name) { - super( name); - } - - @Override - protected String getPlatformPropertiesFileName() { - return "sybase.properties"; - } - - @Override - protected String getDriverName() { - return "Sybase JDBC Driver"; - } - - @Override - protected String getDriverDefinitionID() { - return "DriverDefn.Sybase JDBC Driver"; - } - - @Override - protected String getDriverDefinitionType() { - return "org.eclipse.datatools.enablement.sybase.ase.12_x.driverTemplate"; - } - - @Override - protected String getDatabaseVendor() { - return "Sybase"; - } - - @Override - protected String getDatabaseVersion() { - return "12.x"; - } - - @Override - protected String getDriverClass() { - return "com.sybase.jdbc3.jdbc.SybDriver"; - } - - @Override - protected String getProfileName() { - return "Sybase_12"; - } - - @Override - protected String getProfileDescription() { - return "Sybase 12 jConnect JDBC Profile [Test]"; - } - -} |