jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject svn commit: r391041 - /jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/nodetype/PredefinedNodeTypeTest.java
Date Mon, 03 Apr 2006 13:25:13 GMT
Author: stefan
Date: Mon Apr  3 06:25:10 2006
New Revision: 391041

URL: http://svn.apache.org/viewcvs?rev=391041&view=rev
Log:
JCR-285: Line-separator differences cause PredefinedNodeTypeTest to fail on different operating
systems.

Modified:
    jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/nodetype/PredefinedNodeTypeTest.java

Modified: jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/nodetype/PredefinedNodeTypeTest.java
URL: http://svn.apache.org/viewcvs/jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/nodetype/PredefinedNodeTypeTest.java?rev=391041&r1=391040&r2=391041&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/nodetype/PredefinedNodeTypeTest.java
(original)
+++ jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/nodetype/PredefinedNodeTypeTest.java
Mon Apr  3 06:25:10 2006
@@ -220,10 +220,13 @@
             }
 
             NodeType type = manager.getNodeType(name);
-            assertEquals(
-                    "Predefined node type " + name,
-                    spec.toString(),
-                    getNodeTypeSpec(type));
+            String current = getNodeTypeSpec(type);
+            if (!System.getProperty("line.separator").equals("\n")) {
+                current = normalizeLineSeparators(current);
+            }
+            String expected = normalizeLineSeparators(spec.toString());
+
+            assertEquals("Predefined node type " + name, expected, current);
         } catch (IOException e) {
             fail(e.getMessage());
         } catch (NoSuchNodeTypeException e) {
@@ -382,6 +385,22 @@
         writer.println("  Multiple " + property.isMultiple());
 
         return buffer.toString();
+    }
+
+    /**
+     * Replaces platform-dependant line-separators in <code>stringValue</code>
+     * with "\n".
+     *
+     * @param stringValue string to normalize
+     * @return the normalized string
+     */
+    private String normalizeLineSeparators(String stringValue) {
+        // Replace "\r\n" (Windows format) with "\n" (Unix format)
+        stringValue = stringValue.replaceAll("\r\n", "\n");
+        // Replace "\r" (Mac format) with "\n" (Unix format)
+        stringValue = stringValue.replaceAll("\r", "\n");
+
+        return stringValue;
     }
 
     /**



Mime
View raw message