Skip to content

Commit 52e0719

Browse files
authored
GH-370: Enable ScriptProcessor tests back (#419)
* GH-370: Enable ScriptProcessor tests back Fixes #370 * Update dependencies for `script-processor` * Add `maven-surefire-plugin` to `script-processor` POM and specify `--add-opens` for Ruby requirements * Mark all JavaScript tests with `@EnabledIfSystemProperty` against `org.graalvm.language.js.home` which is available only if GraalVM with `js` component enabled * Fix `NewlineAtEndOfFile` rule for Checkstyle since on Windows the line end is `crlf` * Add `components: 'js'` to GraalVM installation steps for all the GH action scripts * * Add dependencies for `graal-sdk` and `org.graalvm.js` to make JavaScript working on a plain JVM
1 parent 14390fe commit 52e0719

File tree

5 files changed

+37
-21
lines changed

5 files changed

+37
-21
lines changed

.github/workflows/ci-pr.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
with:
3535
version: 'latest'
3636
java-version: '17'
37-
# components: 'native-image' # add when starting native builds.
37+
components: 'js'
3838
github-token: ${{ secrets.GITHUB_TOKEN }}
3939
- name: 'Configure: cache for maven dependencies'
4040
uses: actions/cache@v3

.github/workflows/common.yml

+5-5
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ jobs:
186186
with:
187187
version: 'latest'
188188
java-version: ${{ needs.parameters.outputs.jdk_build }}
189-
# components: 'native-image' # add when starting native builds.
189+
components: 'js'
190190
github-token: ${{ secrets.GITHUB_TOKEN }}
191191
- name: 'Configure: cache for maven dependencies'
192192
uses: actions/cache@v3
@@ -277,7 +277,7 @@ jobs:
277277
with:
278278
version: 'latest'
279279
java-version: ${{ needs.parameters.outputs.jdk_build }}
280-
# components: 'native-image' # add when starting native builds.
280+
components: 'js'
281281
github-token: ${{ secrets.GITHUB_TOKEN }}
282282
- name: 'Configure: cache for maven dependencies'
283283
uses: actions/cache@v3
@@ -357,7 +357,7 @@ jobs:
357357
with:
358358
version: 'latest'
359359
java-version: ${{ needs.parameters.outputs.jdk_build }}
360-
# components: 'native-image' # add when starting native builds.
360+
components: 'js'
361361
github-token: ${{ secrets.GITHUB_TOKEN }}
362362
- name: 'Configure: cache for maven dependencies'
363363
uses: actions/cache@v3
@@ -437,7 +437,7 @@ jobs:
437437
with:
438438
version: 'latest'
439439
java-version: ${{ needs.parameters.outputs.jdk_build }}
440-
# components: 'native-image' # add when starting native builds.
440+
components: 'js'
441441
github-token: ${{ secrets.GITHUB_TOKEN }}
442442
- name: 'Configure: cache for maven dependencies'
443443
uses: actions/cache@v3
@@ -514,7 +514,7 @@ jobs:
514514
with:
515515
version: 'latest'
516516
java-version: ${{ needs.parameters.outputs.jdk_build }}
517-
# components: 'native-image' # add when starting native builds.
517+
components: 'js'
518518
github-token: ${{ secrets.GITHUB_TOKEN }}
519519
- name: 'Configure: cache for maven dependencies'
520520
uses: actions/cache@v3

applications/processor/script-processor/pom.xml

+25-2
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@
1515
</parent>
1616

1717
<properties>
18-
<jruby-complete.version>9.0.5.0</jruby-complete.version>
19-
<jython-standalone.version>2.7.2</jython-standalone.version>
18+
<jruby-complete.version>9.3.9.0</jruby-complete.version>
19+
<jython-standalone.version>2.7.3</jython-standalone.version>
2020
<apache-ivy.version>2.5.1</apache-ivy.version>
21+
<graalvm.version>22.3.0</graalvm.version>
2122
</properties>
2223

2324
<dependencies>
@@ -26,6 +27,17 @@
2627
<artifactId>spring-integration-groovy</artifactId>
2728
</dependency>
2829

30+
<dependency>
31+
<groupId>org.graalvm.sdk</groupId>
32+
<artifactId>graal-sdk</artifactId>
33+
<version>${graalvm.version}</version>
34+
</dependency>
35+
<dependency>
36+
<groupId>org.graalvm.js</groupId>
37+
<artifactId>js</artifactId>
38+
<version>${graalvm.version}</version>
39+
</dependency>
40+
2941
<dependency>
3042
<groupId>org.apache.groovy</groupId>
3143
<artifactId>groovy-json</artifactId>
@@ -78,6 +90,17 @@
7890

7991
<build>
8092
<plugins>
93+
<plugin>
94+
<groupId>org.apache.maven.plugins</groupId>
95+
<artifactId>maven-surefire-plugin</artifactId>
96+
<configuration>
97+
<argLine>
98+
--add-opens java.base/sun.nio.ch=ALL-UNNAMED
99+
--add-opens java.base/java.io=ALL-UNNAMED
100+
</argLine>
101+
</configuration>
102+
</plugin>
103+
81104
<plugin>
82105
<groupId>org.apache.maven.plugins</groupId>
83106
<artifactId>maven-deploy-plugin</artifactId>

applications/processor/script-processor/src/test/java/org/springframework/cloud/stream/app/processor/script/ScriptProcessorIntegrationTests.java

+4-10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2015-2022 the original author or authors.
2+
* Copyright 2015-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -19,7 +19,6 @@
1919
import java.io.IOException;
2020

2121
import com.fasterxml.jackson.databind.ObjectMapper;
22-
import org.junit.jupiter.api.Disabled;
2322
import org.junit.jupiter.api.Test;
2423

2524
import org.springframework.boot.WebApplicationType;
@@ -46,7 +45,6 @@
4645
*/
4746
public class ScriptProcessorIntegrationTests {
4847

49-
@Disabled
5048
@Test
5149
public void testJavascriptFunctions() throws IOException {
5250
try (ConfigurableApplicationContext context = new SpringApplicationBuilder(
@@ -68,7 +66,6 @@ public void testJavascriptFunctions() throws IOException {
6866
}
6967
}
7068

71-
@Disabled
7269
@Test
7370
public void testJavascriptVariableTake1() {
7471
try (ConfigurableApplicationContext context = new SpringApplicationBuilder(
@@ -88,7 +85,6 @@ public void testJavascriptVariableTake1() {
8885
}
8986
}
9087

91-
@Disabled
9288
@Test
9389
public void testJavascriptVariableTake2() {
9490
try (ConfigurableApplicationContext context = new SpringApplicationBuilder(
@@ -104,7 +100,7 @@ public void testJavascriptVariableTake2() {
104100

105101
processorInput.send(new GenericMessage<>(9));
106102
Message<byte[]> sourceMessage = processorOutput.receive(10000, "scriptProcessorFunction-out-0");
107-
assertThat(new String(sourceMessage.getPayload())).isEqualTo("45.0");
103+
assertThat(new String(sourceMessage.getPayload())).isEqualTo("45");
108104
}
109105
}
110106

@@ -146,7 +142,6 @@ public void testGroovyComplex() {
146142
}
147143
}
148144

149-
@Disabled
150145
@Test
151146
public void testRubyScript() {
152147
try (ConfigurableApplicationContext context = new SpringApplicationBuilder(
@@ -165,7 +160,6 @@ public void testRubyScript() {
165160
}
166161
}
167162

168-
@Disabled
169163
@Test
170164
public void testRubyScriptComplex() {
171165
try (ConfigurableApplicationContext context = new SpringApplicationBuilder(
@@ -220,7 +214,6 @@ public void testPythonComplex() {
220214
}
221215
}
222216

223-
@Disabled
224217
@Test
225218
public void testGroovyToJavascript() {
226219
try (ConfigurableApplicationContext context = new SpringApplicationBuilder(
@@ -241,7 +234,8 @@ public void testGroovyToJavascript() {
241234
}
242235

243236
@EnableAutoConfiguration
244-
@Import({ScriptProcessorConfiguration.class})
237+
@Import(ScriptProcessorConfiguration.class)
245238
public static class ScriptProcessorTestConfiguration {
246239
}
240+
247241
}

etc/checkstyle/checkstyle.xml

+2-3
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,8 @@
2020
<property name="headerFile" value="${checkstyle.header.file}"/>
2121
<property name="fileExtensions" value="java,groovy"/>
2222
</module>
23-
<module name="com.puppycrawl.tools.checkstyle.checks.NewlineAtEndOfFileCheck">
24-
<property name="lineSeparator" value="lf"/>
25-
</module>
23+
24+
<module name="NewlineAtEndOfFile"/>
2625

2726
<!-- TreeWalker Checks -->
2827
<module name="com.puppycrawl.tools.checkstyle.TreeWalker">

0 commit comments

Comments
 (0)