Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(core): demonstrate behavior of SpEL expression evaluation #4762

Merged
merged 1 commit into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ subprojects {
}
}

// This is required for some SpEL expressions to evaluate properly with java
// 17. It works with java 11 as well, but isn't required there.
tasks.withType(Test).configureEach {
jvmArgs += '--add-opens=java.base/java.util=ALL-UNNAMED'
}

if (name != "orca-bom" && name != "orca-api") {
apply plugin: "java-library"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,23 @@ class PipelineExpressionEvaluatorSpec extends Specification {
'${status == "SUCCEEDED"}' | false
}

def "allows calling toString on an UnmodifiableMap"() {
given:
// This fails under java 17 without something like
// --add-opens=java.base/java.util=ALL-UNNAMED as an argument ot the jvm.
def source = [test: '${ {"foo": "bar"}.toString() }']
PipelineExpressionEvaluator evaluator = new PipelineExpressionEvaluator([], pluginManager, expressionProperties)

when:
ExpressionEvaluationSummary evaluationSummary = new ExpressionEvaluationSummary()
def result = evaluator.evaluate(source, [status: ExecutionStatus.TERMINAL], evaluationSummary, true)

then:
evaluationSummary.expressionResult.isEmpty()
evaluationSummary.failureCount == 0
result.test == '{foo=bar}'
}

static ExpressionFunctionProvider buildExpressionFunctionProvider(String providerName) {
new ExpressionFunctionProvider() {
@Override
Expand Down