This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new c4ed2034e10e CAMEL-27424: camel-groovy - test the validation index for
a script with CR line ends, and replace CRLF in testMarshalDOM (#30653)
c4ed2034e10e is described below
commit c4ed2034e10e1f33963ddda374a4fc1f9cfef684
Author: Saravanakumar Selvaraj <[email protected]>
AuthorDate: Mon Nov 23 12:13:46 2026 +0000
CAMEL-27424: camel-groovy - test the validation index for a script with CR
line ends, and replace CRLF in testMarshalDOM (#30653)
The reviews of CAMEL-27401 and CAMEL-27408 each made one optional proposal.
This change takes both. Only test code changes.
testValidateExpressionIndexWithLineEnds (renamed from
testValidateExpressionIndexWithLfAndCrLf) of GroovyLanguageTest checks one more
script, with CR line ends only. The Groovy compiler counts a new line only
after LF, so it reports the syntax error of that script in line 1. The case
guards the rule that the fix of CAMEL-27401 relies on.
testMarshalDOM of GroovyXmlDataFormatTest now replaces CRLF with LF instead
of the platform line separator, so the result is the same on Windows and on
Linux.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
.../java/org/apache/camel/groovy/xml/GroovyXmlDataFormatTest.java | 2 +-
.../java/org/apache/camel/language/groovy/GroovyLanguageTest.java | 4 +++-
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git
a/components/camel-groovy/src/test/java/org/apache/camel/groovy/xml/GroovyXmlDataFormatTest.java
b/components/camel-groovy/src/test/java/org/apache/camel/groovy/xml/GroovyXmlDataFormatTest.java
index 4c1681bd16a1..b5962e820a75 100644
---
a/components/camel-groovy/src/test/java/org/apache/camel/groovy/xml/GroovyXmlDataFormatTest.java
+++
b/components/camel-groovy/src/test/java/org/apache/camel/groovy/xml/GroovyXmlDataFormatTest.java
@@ -181,7 +181,7 @@ public class GroovyXmlDataFormatTest extends
CamelTestSupport {
String xml = context.getTypeConverter().convertTo(String.class, out);
// the JDK serializer ends the lines of the document with the platform
line separator, except the last line
- xml = xml.replace(System.lineSeparator(), "\n") + "\n";
+ xml = xml.replace("\r\n", "\n") + "\n";
Assertions.assertEquals(BOOKS, xml);
MockEndpoint.assertIsSatisfied(context);
diff --git
a/components/camel-groovy/src/test/java/org/apache/camel/language/groovy/GroovyLanguageTest.java
b/components/camel-groovy/src/test/java/org/apache/camel/language/groovy/GroovyLanguageTest.java
index 5aab6855c80d..c162b631439a 100644
---
a/components/camel-groovy/src/test/java/org/apache/camel/language/groovy/GroovyLanguageTest.java
+++
b/components/camel-groovy/src/test/java/org/apache/camel/language/groovy/GroovyLanguageTest.java
@@ -77,7 +77,7 @@ public class GroovyLanguageTest extends LanguageTestSupport {
}
@Test
- public void testValidateExpressionIndexWithLfAndCrLf() throws Exception {
+ public void testValidateExpressionIndexWithLineEnds() throws Exception {
try (GroovyLanguage g = new GroovyLanguage()) {
g.setCamelContext(context);
@@ -85,6 +85,8 @@ public class GroovyLanguageTest extends LanguageTestSupport {
assertIndexOfError(g, "var a = 123;\nprintln a */ 2;\n");
assertIndexOfError(g, "var a = 123;\r\nprintln a */ 2;\r\n");
assertIndexOfError(g, "var a = 123;\r\nvar b = 4;\nprintln a */
2;\n");
+ // CR line ends: the Groovy compiler counts no new line after \r,
so it reports the error in line 1
+ assertIndexOfError(g, "var a = 123;\rprintln a */ 2;\r");
}
}