summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCaspar De Groot2011-02-15 22:33:21 (EST)
committerCaspar De Groot2011-02-15 22:33:21 (EST)
commit3e6cd4ecad66a789bf6d160b475ea7f69153a8a9 (patch)
tree0477e352a35d7fbc0bb989664a1158c4f9e4bd11
parent8c4a98473e40531f1b636fe56233debe96381e55 (diff)
downloadcdo-3e6cd4ecad66a789bf6d160b475ea7f69153a8a9.zip
cdo-3e6cd4ecad66a789bf6d160b475ea7f69153a8a9.tar.gz
cdo-3e6cd4ecad66a789bf6d160b475ea7f69153a8a9.tar.bz2
[Bug 337196] [DB] Use qualified table names in DB tests
https://bugs.eclipse.org/bugs/show_bug.cgi?id=337196
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/CustomTypeMappingTest.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/DBAnnotationsTest.java35
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/DBStoreRepositoryConfig.java11
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/SQLQueryTest.java20
4 files changed, 43 insertions, 25 deletions
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/CustomTypeMappingTest.java b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/CustomTypeMappingTest.java
index 8f0c383..30461fa 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/CustomTypeMappingTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/CustomTypeMappingTest.java
@@ -96,7 +96,7 @@ public class CustomTypeMappingTest extends AbstractCDOTest
try
{
stmt = getStatement();
- rset = stmt.executeQuery("SELECT bar FROM foo");
+ rset = stmt.executeQuery("SELECT bar FROM underscoreTest_foo");
assertEquals("java.lang.String", rset.getMetaData().getColumnClassName(1));
rset.next();
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/DBAnnotationsTest.java b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/DBAnnotationsTest.java
index c448331..afafc3b 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/DBAnnotationsTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/DBAnnotationsTest.java
@@ -114,7 +114,7 @@ public class DBAnnotationsTest extends AbstractCDOTest
skipConfig(AllTestsDBPsql.Psql.INSTANCE);
msg("Opening session");
- EPackage model1 = createModel();
+ final EPackage model1 = createModel();
addLengthAnnotation(model1, "8");
CDOSession session = openSession();
@@ -141,7 +141,8 @@ public class DBAnnotationsTest extends AbstractCDOTest
@Override
protected void doVerify() throws Exception
{
- ResultSet rset = getMetaData().getColumns(null, null, "PRODUCT1", "NAME");
+ String tableName = model1.getName().toUpperCase() + "_PRODUCT1";
+ ResultSet rset = getMetaData().getColumns(null, null, tableName, "NAME");
rset.next();
assertEquals("8", rset.getString(7));
}
@@ -158,7 +159,7 @@ public class DBAnnotationsTest extends AbstractCDOTest
skipConfig(AllTestsDBHsqldbNonAudit.HsqldbNonAudit.INSTANCE);
msg("Opening session");
- EPackage model1 = createModel();
+ final EPackage model1 = createModel();
addTypeAnnotation(model1, "CLOB");
CDOSession session = openSession();
@@ -168,7 +169,7 @@ public class DBAnnotationsTest extends AbstractCDOTest
CDOTransaction transaction = session.openTransaction();
msg("Creating resource");
- CDOResource resource = transaction.createResource("/test1");
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
msg("Commit a category.");
EClass eClass = (EClass)model1.getEClassifier("Category");
@@ -185,7 +186,8 @@ public class DBAnnotationsTest extends AbstractCDOTest
@Override
protected void doVerify() throws Exception
{
- ResultSet rset = getMetaData().getColumns(null, null, "CATEGORY", "NAME");
+ String tableName = model1.getName().toUpperCase() + "_CATEGORY";
+ ResultSet rset = getMetaData().getColumns(null, null, tableName, "NAME");
rset.next();
assertEquals("CLOB", rset.getString(6));
}
@@ -238,7 +240,7 @@ public class DBAnnotationsTest extends AbstractCDOTest
skipConfig(AllTestsDBPsql.Psql.INSTANCE);
msg("Opening session");
- EPackage model1 = createModel();
+ final EPackage model1 = createModel();
addColumnNameAnnotation(model1, "TOPIC");
CDOSession session = openSession();
@@ -265,7 +267,8 @@ public class DBAnnotationsTest extends AbstractCDOTest
@Override
protected void doVerify() throws Exception
{
- ResultSet rset = getMetaData().getColumns(null, null, "CATEGORY", "TOPIC");
+ String tableName = model1.getName().toUpperCase() + "_CATEGORY";
+ ResultSet rset = getMetaData().getColumns(null, null, tableName, "TOPIC");
rset.next();
assertEquals("TOPIC", rset.getString(4));
}
@@ -282,7 +285,7 @@ public class DBAnnotationsTest extends AbstractCDOTest
skipConfig(AllTestsDBPsql.Psql.INSTANCE);
msg("Opening session");
- EPackage model1 = createModel();
+ final EPackage model1 = createModel();
addColumnNameAndTypeAnnoation(model1, "TOPIC", "CLOB");
CDOSession session = openSession();
@@ -309,7 +312,8 @@ public class DBAnnotationsTest extends AbstractCDOTest
@Override
protected void doVerify() throws Exception
{
- ResultSet rset = getMetaData().getColumns(null, null, "CATEGORY", "TOPIC");
+ String tableName = model1.getName().toUpperCase() + "_CATEGORY";
+ ResultSet rset = getMetaData().getColumns(null, null, tableName, "TOPIC");
rset.next();
assertEquals("TOPIC", rset.getString(4));
assertEquals("CLOB", rset.getString(6));
@@ -320,7 +324,7 @@ public class DBAnnotationsTest extends AbstractCDOTest
public void testTableMappingAnnotationByMetaData() throws CommitException
{
msg("Opening session");
- EPackage model1 = createModel();
+ final EPackage model1 = createModel();
addTableMappingAnnotation(model1, "OrderDetail", "Company");
CDOSession session = openSession();
@@ -353,18 +357,19 @@ public class DBAnnotationsTest extends AbstractCDOTest
boolean companyTableCreated = false;
boolean categoryTableCreated = false;
+ String prefix = model1.getName().toUpperCase() + '_';
while (rset.next())
{
String tableName = rset.getString(3);
- if ("ORDERDETAIL".equalsIgnoreCase(tableName))
+ if ((prefix + "ORDERDETAIL").equalsIgnoreCase(tableName))
{
orderDetailTableCreated = true;
}
- else if ("COMPANY".equalsIgnoreCase(tableName))
+ else if ((prefix + "COMPANY").equalsIgnoreCase(tableName))
{
companyTableCreated = true;
}
- else if ("CATEGORY".equalsIgnoreCase(tableName))
+ else if ((prefix + "CATEGORY").equalsIgnoreCase(tableName))
{
categoryTableCreated = true;
}
@@ -380,7 +385,9 @@ public class DBAnnotationsTest extends AbstractCDOTest
private EPackage createModel()
{
EPackage ePackage = EcoreUtil.copy(getModel1Package());
- ePackage.setNsURI(ePackage.getNsURI() + "-dynamic" + modelCounter++);
+ String suffix = "_dynamic" + modelCounter++;
+ ePackage.setNsURI(ePackage.getNsURI() + suffix);
+ ePackage.setName(ePackage.getName() + suffix);
return ePackage;
}
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/DBStoreRepositoryConfig.java b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/DBStoreRepositoryConfig.java
index d825231..e54429a 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/DBStoreRepositoryConfig.java
+++ b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/DBStoreRepositoryConfig.java
@@ -23,6 +23,9 @@ import org.eclipse.net4j.util.container.IPluginContainer;
import javax.sql.DataSource;
+import java.util.HashMap;
+import java.util.Map;
+
/**
* @author Eike Stepper
*/
@@ -47,11 +50,19 @@ public abstract class DBStoreRepositoryConfig extends RepositoryConfig
public IStore createStore(String repoName)
{
IMappingStrategy mappingStrategy = createMappingStrategy();
+ mappingStrategy.setProperties(createMappingStrategyProperties());
IDBAdapter dbAdapter = createDBAdapter();
DataSource dataSource = createDataSource(repoName);
return CDODBUtil.createStore(mappingStrategy, dbAdapter, DBUtil.createConnectionProvider(dataSource));
}
+ protected Map<String, String> createMappingStrategyProperties()
+ {
+ Map<String, String> props = new HashMap<String, String>();
+ props.put(IMappingStrategy.PROP_QUALIFIED_NAMES, "true");
+ return props;
+ }
+
protected abstract IMappingStrategy createMappingStrategy();
protected abstract IDBAdapter createDBAdapter();
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/SQLQueryTest.java b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/SQLQueryTest.java
index 66bd930..9e30daa 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/SQLQueryTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/SQLQueryTest.java
@@ -67,7 +67,7 @@ public class SQLQueryTest extends AbstractCDOTest
{
msg("Query for products with a specific name");
- CDOQuery cdoQuery = transaction.createQuery("sql", "SELECT CDO_ID FROM PRODUCT1 WHERE name=:name");
+ CDOQuery cdoQuery = transaction.createQuery("sql", "SELECT CDO_ID FROM MODEL1_PRODUCT1 WHERE name=:name");
cdoQuery.setParameter("name", "" + 1);
final List<Product1> products = cdoQuery.getResult(Product1.class);
assertEquals(1, products.size());
@@ -75,14 +75,14 @@ public class SQLQueryTest extends AbstractCDOTest
{
msg("Query for Customers");
- CDOQuery cdoQuery = transaction.createQuery("sql", "SELECT CDO_ID FROM CUSTOMER");
+ CDOQuery cdoQuery = transaction.createQuery("sql", "SELECT CDO_ID FROM MODEL1_CUSTOMER");
final List<Customer> customers = cdoQuery.getResult(Customer.class);
assertEquals(NUM_OF_CUSTOMERS, customers.size());
}
{
msg("Query for products with VAT15");
- CDOQuery cdoQuery = transaction.createQuery("sql", "SELECT CDO_ID FROM PRODUCT1 WHERE VAT =:vat");
+ CDOQuery cdoQuery = transaction.createQuery("sql", "SELECT CDO_ID FROM MODEL1_PRODUCT1 WHERE VAT =:vat");
cdoQuery.setParameter("vat", VAT.VAT15.getValue());
final List<Product1> products = cdoQuery.getResult(Product1.class);
assertEquals(10, products.size());
@@ -108,7 +108,7 @@ public class SQLQueryTest extends AbstractCDOTest
{
msg("Count products");
- CDOQuery cdoQuery = transaction.createQuery("sql", "SELECT COUNT(*) from PRODUCT1");
+ CDOQuery cdoQuery = transaction.createQuery("sql", "SELECT COUNT(*) from MODEL1_PRODUCT1");
cdoQuery.setParameter(SQLQueryHandler.CDO_OBJECT_QUERY, false);
// we need to handle objects, because different DBs produce either
@@ -147,12 +147,12 @@ public class SQLQueryTest extends AbstractCDOTest
{
msg("Query for customers");
- CDOQuery customerQuery = transaction.createQuery("sql", "SELECT CDO_ID FROM CUSTOMER ORDER BY NAME");
+ CDOQuery customerQuery = transaction.createQuery("sql", "SELECT CDO_ID FROM MODEL1_CUSTOMER ORDER BY NAME");
final List<Customer> customers = customerQuery.getResult(Customer.class);
assertEquals(NUM_OF_CUSTOMERS, customers.size());
msg("Query for products");
- CDOQuery productQuery = transaction.createQuery("sql", "SELECT CDO_ID FROM PRODUCT1");
+ CDOQuery productQuery = transaction.createQuery("sql", "SELECT CDO_ID FROM MODEL1_PRODUCT1");
final List<Product1> products = productQuery.getResult(Product1.class);
assertEquals(NUM_OF_PRODUCTS, products.size());
}
@@ -178,7 +178,7 @@ public class SQLQueryTest extends AbstractCDOTest
final List<Product1> allProducts = new ArrayList<Product1>();
for (int page = 0; page < numOfPages; page++)
{
- CDOQuery productQuery = transaction.createQuery("sql", "SELECT CDO_ID FROM PRODUCT1");
+ CDOQuery productQuery = transaction.createQuery("sql", "SELECT CDO_ID FROM MODEL1_PRODUCT1");
productQuery.setMaxResults(pageSize);
productQuery.setParameter(SQLQueryHandler.FIRST_RESULT, page * pageSize);
final List<Product1> queriedProducts = productQuery.getResult(Product1.class);
@@ -211,7 +211,7 @@ public class SQLQueryTest extends AbstractCDOTest
{
msg("Query for products");
- CDOQuery productQuery = transaction.createQuery("sql", "SELECT CDO_ID FROM PRODUCT1");
+ CDOQuery productQuery = transaction.createQuery("sql", "SELECT CDO_ID FROM MODEL1_PRODUCT1");
final CloseableIterator<Product1> iterator = productQuery.getResultAsync(Product1.class);
int counter = 0;
while (iterator.hasNext())
@@ -243,7 +243,7 @@ public class SQLQueryTest extends AbstractCDOTest
{
msg("Query for customer street strings.");
- CDOQuery cdoQuery = transaction.createQuery("sql", "SELECT STREET FROM CUSTOMER");
+ CDOQuery cdoQuery = transaction.createQuery("sql", "SELECT STREET FROM MODEL1_CUSTOMER");
cdoQuery.setParameter("cdoObjectQuery", false);
List<String> streets = new ArrayList<String>(cdoQuery.getResult(String.class));
for (int i = 0; i < 5; i++)
@@ -265,7 +265,7 @@ public class SQLQueryTest extends AbstractCDOTest
{
msg("Query for customer city strings.");
- CDOQuery cdoQuery = transaction.createQuery("sql", "SELECT CITY FROM CUSTOMER");
+ CDOQuery cdoQuery = transaction.createQuery("sql", "SELECT CITY FROM MODEL1_CUSTOMER");
cdoQuery.setParameter("cdoObjectQuery", false);
List<String> cities = new ArrayList<String>(cdoQuery.getResult(String.class));