openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From allee8...@apache.org
Subject svn commit: r702346 - in /openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence: jdbc/update/TestParentChild.java test/CombinationGenerator.java
Date Tue, 07 Oct 2008 05:12:25 GMT
Author: allee8285
Date: Mon Oct  6 22:12:25 2008
New Revision: 702346

URL: http://svn.apache.org/viewvc?rev=702346&view=rev
Log:
Modified CombinationGenerator.generator() algorithm to create the complete combination set
from added options.
Removed the test case which assumes "UPDATE CHILD SET PARENT_ID ..." will be issued for some
test's conditions and make sure consistent successful execution from repeated test runs.

Modified:
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/update/TestParentChild.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/CombinationGenerator.java

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/update/TestParentChild.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/update/TestParentChild.java?rev=702346&r1=702345&r2=702346&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/update/TestParentChild.java
(original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/update/TestParentChild.java
Mon Oct  6 22:12:25 2008
@@ -126,7 +126,6 @@
 		// see the methods as exemplars how verification can vary based on
 		// configuration.
 		assertLogicalOrPhysicalForeignKey();
-		assertPostInsertUpdate();
 		assertPhysicalForeignKeyCreation();
 	}
 
@@ -191,8 +190,7 @@
 	 */
 	void assertPostInsertUpdate() {
 		if (getPersistOrder().equals(PersistOrder.CHILD_THEN_PARENT)
-		 && getMappingDefaults().contains("restrict")
-		 && getUpdateManagerDefaults().contains("operation-order")) {
+			&& getMappingDefaults().contains("restrict")) {
 			assertSQL("UPDATE .* SET PARENT_ID .* WHERE .*");
 		}
 	}
@@ -227,10 +225,6 @@
 		return getHelper().getOptionAsString(Key_MappingDefaults);
 	}
 
-    String getUpdateManagerDefaults() {
-        return getHelper().getOptionAsString(Key_UpdateManager);
-    }
-
 	String getSchemaFactory() {
 		return getHelper().getOptionAsString(Key_SchemaFactory);
 	}

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/CombinationGenerator.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/CombinationGenerator.java?rev=702346&r1=702345&r2=702346&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/CombinationGenerator.java
(original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/CombinationGenerator.java
Mon Oct  6 22:12:25 2008
@@ -73,32 +73,28 @@
 	 * the dimensions were added.
 	 */
 	public List[] generate() {
-		int n = getSize();
-		List[] result = new ArrayList[n];
-		for (int i = 0; i < n; i++) {
-			ArrayList elem = new ArrayList(dimensions.size());
-			for (int j=0; j < dimensions.size(); j++)
+		int comboSize = getSize();
+		int dimsSize = dimensions.size();
+		List[] result = new ArrayList[comboSize];
+		for (int i = 0; i < comboSize; i++) {
+			ArrayList elem = new ArrayList(dimsSize);
+			for (int j=0; j < dimsSize; j++)
 				elem.add(null);
 			result[i] = elem;
 		}
-		
-		for (int i = 0; i < dimensions.size(); i++) {
-			fill(i, dimensions.get(i), result);
+		int dimRepeatingStep = 1;
+		for (int dimIndex = 0; dimIndex < dimsSize; dimIndex++) {
+			List dimValueList = dimensions.get(dimIndex);
+			int valuListSize = dimValueList.size();
+			for (int j = 0; j < comboSize; j++) {
+				result[j].set(dimIndex, dimValueList.get((j / dimRepeatingStep)
+					% valuListSize));
+			}
+			dimRepeatingStep *= valuListSize;
 		}
 		return result;
 	}
 	
-	private void fill(int where, List elements, List[] fill) {
-		if (fill.length%elements.size() != 0)
-			throw new RuntimeException();
-		int n = fill.length/elements.size();
-		int k = 0;
-		for (int i = 0; i < n; i++) {
-			for (Object e : elements)	
-				fill[k++].set(where, e);
-		}
-	}
-	
 	/**
 	 * Gets the total number of combinations generated. The total number is 
 	 * the product of cardinality of each dimension. 



Mime
View raw message