Skip to content

Commit

Permalink
test(pipelinetriggers): demonstrate behavior of SpEL expression evalu…
Browse files Browse the repository at this point in the history
…ation (#1434)

that uses a non-public constructor/method, and so requires special treatment under java 17.
  • Loading branch information
dbyron-sf committed Jul 9, 2024
1 parent d97ff35 commit d2d30df
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
6 changes: 6 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ subprojects {
jvmArgs '-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8189'
}
}

// 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 != "echo-bom" && name != "echo-api") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,29 @@ class ExpectedArtifactExpressionEvaluationPostProcessorSpec extends Specificatio
then:
noExceptionThrown()
}

def 'allows calling toString on an UnmodifiableMap'() {
given:
def artifact = ExpectedArtifact.builder()
.matchArtifact(
Artifact.builder()
// This fails under java 17 without something like
// --add-opens=java.base/java.util=ALL-UNNAMED as an argument to the jvm.
.name('${ {"foo": "bar"}.toString() }')
.version('77')
.type('maven/file')
.build())
.id('goodId')
.build()

def inputPipeline = createPipelineWith([artifact], trigger).withTrigger(trigger)

when:
def outputPipeline = artifactPostProcessor.processPipeline(inputPipeline)
def evaluatedArtifact = outputPipeline.expectedArtifacts[0].matchArtifact

then:
evaluatedArtifact.name == '{foo=bar}'
evaluatedArtifact.version == '77'
}
}

0 comments on commit d2d30df

Please sign in to comment.