cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r794201 - in /cayenne/main/trunk: ./ docs/doc/src/main/resources/ framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/db2/ framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/
Date Wed, 15 Jul 2009 08:58:29 GMT
Author: aadamchik
Date: Wed Jul 15 08:58:29 2009
New Revision: 794201

URL: http://svn.apache.org/viewvc?rev=794201&view=rev
Log:
CAY-1229 Fixing DB2 Tests

patch by Olga Tkachova TestInDB2.txt ... removed one noop hunk that was giving trouble

Modified:
    cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/db2/DB2PkGenerator.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/AbstractAccessStack.java
    cayenne/main/trunk/pom.xml

Modified: cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt?rev=794201&r1=794200&r2=794201&view=diff
==============================================================================
--- cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt (original)
+++ cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt Wed Jul 15 08:58:29 2009
@@ -25,6 +25,7 @@
 
 CAY-1169 Weird behavior when adding entity via merging
 CAY-1224 reverse engineering partially changed schema shows empty error messge window
+CAY-1229 Fixing DB2 Tests
 CAY-1232 Unit tests failing on Sybase
 CAY-1240 Schema generation dialog has "uncheck all tables" checkbox incorrectly checked by
default
 

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/db2/DB2PkGenerator.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/db2/DB2PkGenerator.java?rev=794201&r1=794200&r2=794201&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/db2/DB2PkGenerator.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/db2/DB2PkGenerator.java
Wed Jul 15 08:58:29 2009
@@ -33,7 +33,9 @@
 import org.apache.cayenne.dba.JdbcAdapter;
 import org.apache.cayenne.dba.JdbcPkGenerator;
 import org.apache.cayenne.dba.QuotingStrategy;
+import org.apache.cayenne.map.DataMap;
 import org.apache.cayenne.map.DbEntity;
+import org.omg.PortableServer.AdapterActivator;
 
 /**
  * A sequence-based PK generator used by {@link DB2Adapter}.
@@ -165,7 +167,18 @@
         Collection<String> sequences = getExistingSequences(node);
 
         for (DbEntity ent : dbEntities) {
-            if (sequences.contains(sequenceName(ent))) {
+            String name;
+            if(ent.getDataMap().isQuotingSQLIdentifiers()){
+                DbEntity tempEnt = new DbEntity();
+                DataMap dm = new DataMap();                
+                dm.setQuotingSQLIdentifiers(false);
+                tempEnt.setDataMap(dm);
+                tempEnt.setName(ent.getName());
+                name = sequenceName(tempEnt);
+            } else {
+                name = sequenceName(ent);
+            }    
+            if (sequences.contains(name)) {
                 runUpdate(node, dropSequenceString(ent));
             }
         }
@@ -236,21 +249,21 @@
         String seqName = _SEQUENCE_PREFIX + entName;
 
         if (entity.getSchema() != null && entity.getSchema().length() > 0) {
-            if(getAdapter()!=null){
+            if(context!=null){
                 seqName = context.quoteString(entity.getSchema()) +
                  "." + context.quoteString(seqName);
            } else {
                 seqName = entity.getSchema() + "." + seqName;
            }
         }
-        return seqName;
+        
+        return context.quoteString(seqName);
     }
 
     /**
      * Returns DROP SEQUENCE statement.
      */
-    protected String dropSequenceString(DbEntity entity) {
-         
+    protected String dropSequenceString(DbEntity entity) {       
         return "DROP SEQUENCE " + sequenceName(entity) + " RESTRICT ";
     }
 

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/AbstractAccessStack.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/AbstractAccessStack.java?rev=794201&r1=794200&r2=794201&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/AbstractAccessStack.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/AbstractAccessStack.java
Wed Jul 15 08:58:29 2009
@@ -27,6 +27,7 @@
 import java.sql.Types;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collection;
 import java.util.Collections;
 import java.util.Iterator;
 import java.util.List;
@@ -164,11 +165,21 @@
                     stmt.executeUpdate(deleteSql);
                 }
                 catch (SQLException e) {
-                    throw new CayenneRuntimeException(
-                            "Error deleting test data for entity '"
-                                    + ent.getName()
-                                    + "': "
-                                    + e.getLocalizedMessage());
+                    try {
+                        Collection<String> deleteTableSql = node
+                                .getAdapter()
+                                .dropTableStatements(ent);
+                        stmt.executeUpdate(deleteTableSql.iterator().next());
+                        String createTableSql = node.getAdapter().createTable(ent);
+                        stmt.executeUpdate(createTableSql);
+                    }
+                    catch (SQLException e1) {
+                        throw new CayenneRuntimeException(
+                                "Error deleting test data for entity '"
+                                        + ent.getName()
+                                        + "': "
+                                        + e.getLocalizedMessage());
+                    }
                 }
             }
             conn.commit();

Modified: cayenne/main/trunk/pom.xml
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/pom.xml?rev=794201&r1=794200&r2=794201&view=diff
==============================================================================
--- cayenne/main/trunk/pom.xml (original)
+++ cayenne/main/trunk/pom.xml Wed Jul 15 08:58:29 2009
@@ -832,6 +832,23 @@
 				</dependency>
 			</dependencies>
 		</profile>
+		<profile>
+			<id>db2</id>
+			<activation>
+				<property>
+					<name>cayenne.test.connection</name>
+					<value>db2</value>					
+				</property>
+			</activation>
+			<dependencies>
+				<dependency>
+					<groupId>com.ibm.db2</groupId>
+					<artifactId>db2-driver</artifactId>
+					<version>1.0</version>
+                                        <scope>test</scope>
+				</dependency>
+			</dependencies>
+		</profile>
 	</profiles>
 </project>
 



Mime
View raw message