You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by bd...@apache.org on 2008/07/30 16:17:14 UTC

svn commit: r681061 - /incubator/sling/trunk/scripting/jst/src/test/java/org/apache/sling/scripting/jst/StringUtil.java

Author: bdelacretaz
Date: Wed Jul 30 07:17:13 2008
New Revision: 681061

URL: http://svn.apache.org/viewvc?rev=681061&view=rev
Log:
SLING-582 - JsCodeGeneratorTest was broken under Cygwin on Windows - contributed by Craig L. Ching, thanks!

Modified:
    incubator/sling/trunk/scripting/jst/src/test/java/org/apache/sling/scripting/jst/StringUtil.java

Modified: incubator/sling/trunk/scripting/jst/src/test/java/org/apache/sling/scripting/jst/StringUtil.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/scripting/jst/src/test/java/org/apache/sling/scripting/jst/StringUtil.java?rev=681061&r1=681060&r2=681061&view=diff
==============================================================================
--- incubator/sling/trunk/scripting/jst/src/test/java/org/apache/sling/scripting/jst/StringUtil.java (original)
+++ incubator/sling/trunk/scripting/jst/src/test/java/org/apache/sling/scripting/jst/StringUtil.java Wed Jul 30 07:17:13 2008
@@ -23,9 +23,23 @@
 
 /** Test utilities */
 class StringUtil {
+
+    static private final String NATIVE_LINE_SEP = System.getProperty("line.separator");
+
     /** Replace \n with . in strings to make it easier to compare visually for testing */
     static String flatten(String str) {
-        return str.replace('\n', '.');
+
+        // First replace native line-endings
+        if(str.indexOf(NATIVE_LINE_SEP) >= 0) {
+            str = str.replace(NATIVE_LINE_SEP, ".");
+        }
+
+        // Now find non-native line-endings, e.g. cygwin needs this
+        if(str.indexOf('\n') >= 0) {
+            str = str.replace('\n', '.');
+        }
+
+        return str;
     }
     
     /** Read given Class resource */