jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r650566 - in /jackrabbit/branches/1.4/jackrabbit-core/src: main/java/org/apache/jackrabbit/core/nodetype/compact/ test/java/org/apache/jackrabbit/core/nodetype/compact/ test/resources/
Date Tue, 22 Apr 2008 16:14:18 GMT
Author: jukka
Date: Tue Apr 22 09:14:08 2008
New Revision: 650566

URL: http://svn.apache.org/viewvc?rev=650566&view=rev
Log:
1.4: Merged revision 650562 (JCR-1515)

Modified:
    jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/compact/CompactNodeTypeDefWriter.java
    jackrabbit/branches/1.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/nodetype/compact/CompactNodeTypeDefTest.java
    jackrabbit/branches/1.4/jackrabbit-core/src/test/resources/cnd-reader-test-input.cnd

Modified: jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/compact/CompactNodeTypeDefWriter.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/compact/CompactNodeTypeDefWriter.java?rev=650566&r1=650565&r2=650566&view=diff
==============================================================================
--- jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/compact/CompactNodeTypeDefWriter.java
(original)
+++ jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/compact/CompactNodeTypeDefWriter.java
Tue Apr 22 09:14:08 2008
@@ -234,7 +234,14 @@
      */
     private void writePropDef(NodeTypeDef ntd, PropDef pd) throws IOException {
         out.write("\n" + INDENT + "- ");
-        writeItemDefName(pd.getName());
+
+
+        Name name = pd.getName();
+        if (name.equals(ItemDef.ANY_NAME)) {
+            out.write('*');
+        } else {
+            writeItemDefName(name);
+        }
         out.write(" (");
         out.write(PropertyType.nameFromValue(pd.getRequiredType()).toLowerCase());
         out.write(")");

Modified: jackrabbit/branches/1.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/nodetype/compact/CompactNodeTypeDefTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/nodetype/compact/CompactNodeTypeDefTest.java?rev=650566&r1=650565&r2=650566&view=diff
==============================================================================
--- jackrabbit/branches/1.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/nodetype/compact/CompactNodeTypeDefTest.java
(original)
+++ jackrabbit/branches/1.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/nodetype/compact/CompactNodeTypeDefTest.java
Tue Apr 22 09:14:08 2008
@@ -116,7 +116,6 @@
             new CompactNodeTypeDefReader(reader, TEST_FILE);
         List ntdList = cndReader.getNodeTypeDefs();
         NamespaceMapping nsm = cndReader.getNamespaceMapping();
-        NamePathResolver resolver = new DefaultNamePathResolver(nsm);
         NodeTypeDef ntd = (NodeTypeDef)ntdList.get(0);
 
         // Test CND Reader by comparing imported NTD with model NTD.
@@ -124,19 +123,42 @@
         if (diff.isModified()){
             fail("Imported node type definition is not identical to model definition");
         }
+    }
+
+    public void testCompactNodeTypeDefs() throws Exception {
+
+        // Read in node type def from test file
+        Reader reader = new InputStreamReader(
+            getClass().getClassLoader().getResourceAsStream(TEST_FILE));
+        CompactNodeTypeDefReader cndReader =
+            new CompactNodeTypeDefReader(reader, TEST_FILE);
+        List ntdList1 = cndReader.getNodeTypeDefs();
+        NamespaceMapping nsm = cndReader.getNamespaceMapping();
+        NamePathResolver resolver = new DefaultNamePathResolver(nsm);
 
         // Put imported node type def back into CND form with CND writer
         StringWriter sw = new StringWriter();
-        CompactNodeTypeDefWriter.write(ntdList, nsm, resolver, sw);
+        CompactNodeTypeDefWriter.write(ntdList1, nsm, resolver, sw);
 
         // Rerun the reader on the product of the writer
         cndReader = new CompactNodeTypeDefReader(new StringReader(sw.toString()), TEST_FILE);
-        ntdList = cndReader.getNodeTypeDefs();
-        ntd = (NodeTypeDef)ntdList.get(0);
+        List ntdList2 = cndReader.getNodeTypeDefs();
 
-        diff = NodeTypeDefDiff.create(modelNodeTypeDef, ntd);
-        if (diff.isModified()){
+        if (ntdList1.size() != ntdList2.size())
             fail("Exported node type definition was not successfully read back in");
-        }
+        else
+            for(int k = 0; k < ntdList1.size(); k++) {
+                NodeTypeDef ntd1 = (NodeTypeDef) ntdList1.get(k);
+                NodeTypeDef ntd2 = (NodeTypeDef) ntdList2.get(k);
+
+                NodeTypeDefDiff diff = NodeTypeDefDiff.create(ntd1, ntd2);
+                if (diff.isModified() && !diff.isTrivial()){
+                    fail("Exported node type definition was not successfully read back in.
"
+                            + ntd2.getName() + "differs from original");
+                }
+            }
+
+
     }
+
 }

Modified: jackrabbit/branches/1.4/jackrabbit-core/src/test/resources/cnd-reader-test-input.cnd
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.4/jackrabbit-core/src/test/resources/cnd-reader-test-input.cnd?rev=650566&r1=650565&r2=650566&view=diff
==============================================================================
--- jackrabbit/branches/1.4/jackrabbit-core/src/test/resources/cnd-reader-test-input.cnd (original)
+++ jackrabbit/branches/1.4/jackrabbit-core/src/test/resources/cnd-reader-test-input.cnd Tue
Apr 22 09:14:08 2008
@@ -15,7 +15,24 @@
  * limitations under the License.
  */
 <ex = "http://example.org/jackrabbit/example">
+<nt = "http://www.jcp.org/jcr/nt/1.0">
+
 [ex:NodeType] > ex:ParentNodeType1, ex:ParentNodeType2
   orderable mixin
   - ex:property (long) = '1', '2' primary mandatory autocreated protected multiple version
< '[1,10]'
   + ex:node (ex:RequiredNodeType1, ex:RequiredNodeType2) = ex:RequiredNodeType1 mandatory
autocreated protected multiple version
+
+[ex:AnotherNodeType] > ex:NodeType
+  - * (string) = 'a residual property' multiple
+  + * (ex:RequiredNodeType1) multiple
+  
+[ex:Reference]
+  - ex:ref (reference) mandatory protected < 'ex:ref'
+  
+[ex:Name]
+  - ex:name (name) < 'ex:name'
+  
+[ex:Path]
+  - ex:path (path) < 'ex:a/ex:b'  
+
+[ex:Empty]  
\ No newline at end of file



Mime
View raw message