From 52e0719f17afce0eda78307ca803812b862fea71 Mon Sep 17 00:00:00 2001 From: Artem Bilan Date: Wed, 11 Jan 2023 12:16:09 -0500 Subject: [PATCH] GH-370: Enable ScriptProcessor tests back (#419) * GH-370: Enable ScriptProcessor tests back Fixes https://github.com/spring-cloud/stream-applications/issues/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 --- .github/workflows/ci-pr.yml | 2 +- .github/workflows/common.yml | 10 +++---- .../processor/script-processor/pom.xml | 27 +++++++++++++++++-- .../ScriptProcessorIntegrationTests.java | 14 +++------- etc/checkstyle/checkstyle.xml | 5 ++-- 5 files changed, 37 insertions(+), 21 deletions(-) diff --git a/.github/workflows/ci-pr.yml b/.github/workflows/ci-pr.yml index 58ae90a5..b1863d61 100644 --- a/.github/workflows/ci-pr.yml +++ b/.github/workflows/ci-pr.yml @@ -34,7 +34,7 @@ jobs: with: version: 'latest' java-version: '17' - # components: 'native-image' # add when starting native builds. + components: 'js' github-token: ${{ secrets.GITHUB_TOKEN }} - name: 'Configure: cache for maven dependencies' uses: actions/cache@v3 diff --git a/.github/workflows/common.yml b/.github/workflows/common.yml index 4a517f85..bd18c066 100644 --- a/.github/workflows/common.yml +++ b/.github/workflows/common.yml @@ -186,7 +186,7 @@ jobs: with: version: 'latest' java-version: ${{ needs.parameters.outputs.jdk_build }} -# components: 'native-image' # add when starting native builds. + components: 'js' github-token: ${{ secrets.GITHUB_TOKEN }} - name: 'Configure: cache for maven dependencies' uses: actions/cache@v3 @@ -277,7 +277,7 @@ jobs: with: version: 'latest' java-version: ${{ needs.parameters.outputs.jdk_build }} -# components: 'native-image' # add when starting native builds. + components: 'js' github-token: ${{ secrets.GITHUB_TOKEN }} - name: 'Configure: cache for maven dependencies' uses: actions/cache@v3 @@ -357,7 +357,7 @@ jobs: with: version: 'latest' java-version: ${{ needs.parameters.outputs.jdk_build }} -# components: 'native-image' # add when starting native builds. + components: 'js' github-token: ${{ secrets.GITHUB_TOKEN }} - name: 'Configure: cache for maven dependencies' uses: actions/cache@v3 @@ -437,7 +437,7 @@ jobs: with: version: 'latest' java-version: ${{ needs.parameters.outputs.jdk_build }} -# components: 'native-image' # add when starting native builds. + components: 'js' github-token: ${{ secrets.GITHUB_TOKEN }} - name: 'Configure: cache for maven dependencies' uses: actions/cache@v3 @@ -514,7 +514,7 @@ jobs: with: version: 'latest' java-version: ${{ needs.parameters.outputs.jdk_build }} - # components: 'native-image' # add when starting native builds. + components: 'js' github-token: ${{ secrets.GITHUB_TOKEN }} - name: 'Configure: cache for maven dependencies' uses: actions/cache@v3 diff --git a/applications/processor/script-processor/pom.xml b/applications/processor/script-processor/pom.xml index 9669d9d3..d57dc44c 100644 --- a/applications/processor/script-processor/pom.xml +++ b/applications/processor/script-processor/pom.xml @@ -15,9 +15,10 @@ - 9.0.5.0 - 2.7.2 + 9.3.9.0 + 2.7.3 2.5.1 + 22.3.0 @@ -26,6 +27,17 @@ spring-integration-groovy + + org.graalvm.sdk + graal-sdk + ${graalvm.version} + + + org.graalvm.js + js + ${graalvm.version} + + org.apache.groovy groovy-json @@ -78,6 +90,17 @@ + + org.apache.maven.plugins + maven-surefire-plugin + + + --add-opens java.base/sun.nio.ch=ALL-UNNAMED + --add-opens java.base/java.io=ALL-UNNAMED + + + + org.apache.maven.plugins maven-deploy-plugin diff --git a/applications/processor/script-processor/src/test/java/org/springframework/cloud/stream/app/processor/script/ScriptProcessorIntegrationTests.java b/applications/processor/script-processor/src/test/java/org/springframework/cloud/stream/app/processor/script/ScriptProcessorIntegrationTests.java index fb27a86f..b2fb418a 100644 --- a/applications/processor/script-processor/src/test/java/org/springframework/cloud/stream/app/processor/script/ScriptProcessorIntegrationTests.java +++ b/applications/processor/script-processor/src/test/java/org/springframework/cloud/stream/app/processor/script/ScriptProcessorIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2022 the original author or authors. + * Copyright 2015-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,7 +19,6 @@ package org.springframework.cloud.stream.app.processor.script; import java.io.IOException; import com.fasterxml.jackson.databind.ObjectMapper; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.springframework.boot.WebApplicationType; @@ -46,7 +45,6 @@ import static org.assertj.core.api.Assertions.assertThat; */ public class ScriptProcessorIntegrationTests { - @Disabled @Test public void testJavascriptFunctions() throws IOException { try (ConfigurableApplicationContext context = new SpringApplicationBuilder( @@ -68,7 +66,6 @@ public class ScriptProcessorIntegrationTests { } } - @Disabled @Test public void testJavascriptVariableTake1() { try (ConfigurableApplicationContext context = new SpringApplicationBuilder( @@ -88,7 +85,6 @@ public class ScriptProcessorIntegrationTests { } } - @Disabled @Test public void testJavascriptVariableTake2() { try (ConfigurableApplicationContext context = new SpringApplicationBuilder( @@ -104,7 +100,7 @@ public class ScriptProcessorIntegrationTests { processorInput.send(new GenericMessage<>(9)); Message sourceMessage = processorOutput.receive(10000, "scriptProcessorFunction-out-0"); - assertThat(new String(sourceMessage.getPayload())).isEqualTo("45.0"); + assertThat(new String(sourceMessage.getPayload())).isEqualTo("45"); } } @@ -146,7 +142,6 @@ public class ScriptProcessorIntegrationTests { } } - @Disabled @Test public void testRubyScript() { try (ConfigurableApplicationContext context = new SpringApplicationBuilder( @@ -165,7 +160,6 @@ public class ScriptProcessorIntegrationTests { } } - @Disabled @Test public void testRubyScriptComplex() { try (ConfigurableApplicationContext context = new SpringApplicationBuilder( @@ -220,7 +214,6 @@ public class ScriptProcessorIntegrationTests { } } - @Disabled @Test public void testGroovyToJavascript() { try (ConfigurableApplicationContext context = new SpringApplicationBuilder( @@ -241,7 +234,8 @@ public class ScriptProcessorIntegrationTests { } @EnableAutoConfiguration - @Import({ScriptProcessorConfiguration.class}) + @Import(ScriptProcessorConfiguration.class) public static class ScriptProcessorTestConfiguration { } + } diff --git a/etc/checkstyle/checkstyle.xml b/etc/checkstyle/checkstyle.xml index f3661933..ab23c11d 100644 --- a/etc/checkstyle/checkstyle.xml +++ b/etc/checkstyle/checkstyle.xml @@ -20,9 +20,8 @@ - - - + +