incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdelacre...@apache.org
Subject svn commit: r681061 - /incubator/sling/trunk/scripting/jst/src/test/java/org/apache/sling/scripting/jst/StringUtil.java
Date Wed, 30 Jul 2008 14:17:14 GMT
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 */



Mime
View raw message