jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject svn commit: r384767 - in /incubator/jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/nodetype: PredefinedNodeTypeTest.java spec/nt-unstructured.txt
Date Fri, 10 Mar 2006 11:28:51 GMT
Author: stefan
Date: Fri Mar 10 03:28:45 2006
New Revision: 384767

URL: http://svn.apache.org/viewcvs?rev=384767&view=rev
Log:
JCR-333: Fixed a test case that depended on random ordering of equally-named property definitions.

Modified:
    incubator/jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/nodetype/PredefinedNodeTypeTest.java
    incubator/jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/nodetype/spec/nt-unstructured.txt

Modified: incubator/jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/nodetype/PredefinedNodeTypeTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/nodetype/PredefinedNodeTypeTest.java?rev=384767&r1=384766&r2=384767&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/nodetype/PredefinedNodeTypeTest.java
(original)
+++ incubator/jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/nodetype/PredefinedNodeTypeTest.java
Fri Mar 10 03:28:45 2006
@@ -273,12 +273,12 @@
         writer.println("PrimaryItemName");
         writer.println("  " + type.getPrimaryItemName());
         NodeDefinition[] nodes = type.getDeclaredChildNodeDefinitions();
-        Arrays.sort(nodes, ITEM_DEF_COMPARATOR);
+        Arrays.sort(nodes, NODE_DEF_COMPARATOR);
         for (int i = 0; i < nodes.length; i++) {
             writer.print(getChildNodeDefSpec(nodes[i]));
         }
         PropertyDefinition[] properties = type.getDeclaredPropertyDefinitions();
-        Arrays.sort(properties, ITEM_DEF_COMPARATOR);
+        Arrays.sort(properties, PROPERTY_DEF_COMPARATOR);
         for (int i = 0; i < properties.length; i++) {
             writer.print(getPropertyDefSpec(properties[i]));
         }
@@ -386,20 +386,47 @@
     }
 
     /**
-     * Comparator for ordering property and node definition arrays. Item
-     * definitions are ordered by name, with the wildcard item definition
-     * ("*") ordered last.
+     * Comparator for ordering node definition arrays. Node definitions are
+     * ordered by name, with the wildcard item definition ("*") ordered last.
      */
-    private static final Comparator ITEM_DEF_COMPARATOR = new Comparator() {
+    private static final Comparator NODE_DEF_COMPARATOR = new Comparator() {
         public int compare(Object a, Object b) {
-            ItemDefinition ida = (ItemDefinition) a;
-            ItemDefinition idb = (ItemDefinition) b;
-            if (ida.getName().equals("*") && !idb.getName().equals("*")) {
+            NodeDefinition nda = (NodeDefinition) a;
+            NodeDefinition ndb = (NodeDefinition) b;
+            if (nda.getName().equals("*") && !ndb.getName().equals("*")) {
                 return 1;
-            } else if (!ida.getName().equals("*") && idb.getName().equals("*")) {
+            } else if (!nda.getName().equals("*") && ndb.getName().equals("*")) {
                 return -1;
             } else {
-                return ida.getName().compareTo(idb.getName());
+                return nda.getName().compareTo(ndb.getName());
+            }
+        }
+    };
+
+    /**
+     * Comparator for ordering property definition arrays. Property definitions
+     * are ordered by name, with the wildcard item definition ("*") ordered
+     * last, and isMultiple flag, with <code>isMultiple==true</code> ordered
last.
+     */
+    private static final Comparator PROPERTY_DEF_COMPARATOR = new Comparator() {
+        public int compare(Object a, Object b) {
+            PropertyDefinition pda = (PropertyDefinition) a;
+            PropertyDefinition pdb = (PropertyDefinition) b;
+            if (pda.getName().equals("*") && !pdb.getName().equals("*")) {
+                return 1;
+            } else if (!pda.getName().equals("*") && pdb.getName().equals("*")) {
+                return -1;
+            }
+            int result = pda.getName().compareTo(pdb.getName());
+            if (result != 0) {
+                return result;
+            }
+            if (pda.isMultiple() && !pdb.isMultiple()) {
+                return 1;
+            } else if (!pda.isMultiple() && pdb.isMultiple()) {
+                return -1;
+            } else {
+                return 0;
             }
         }
     };

Modified: incubator/jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/nodetype/spec/nt-unstructured.txt
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/nodetype/spec/nt-unstructured.txt?rev=384767&r1=384766&r2=384767&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/nodetype/spec/nt-unstructured.txt
(original)
+++ incubator/jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/nodetype/spec/nt-unstructured.txt
Fri Mar 10 03:28:45 2006
@@ -26,7 +26,7 @@
   Mandatory false
   OnParentVersion COPY
   Protected false
-  Multiple true
+  Multiple false
 PropertyDefinition
   Name "*"
   RequiredType UNDEFINED
@@ -36,4 +36,4 @@
   Mandatory false
   OnParentVersion COPY
   Protected false
-  Multiple false
+  Multiple true



Mime
View raw message