package com.ankurm.vthreads; import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; /** * Confirms the finalized JDK 25 ScopedValue API (JEP 506) compiles and runs with no * --enable-preview flag, and that ScopedValue.where(...).call(...) actually threads the value * through to a method called from inside the scope. Output: * docs/output/03c-scoped-value-finalized.txt. */ class ScopedValueTest { @Test void whereRunThreadsContextThroughToCalledMethod() { Transcript t = Transcript.start("03c-scoped-value-finalized.txt", "ScopedValue (JEP 506, finalized JDK 25), JDK " + System.getProperty("java.version")); String result = ScopedValueDemo.runWithContext("req-42"); t.line("ScopedValue.where(CTX, ctx).call(ScopedValueDemo::processRequest) -> " + result); t.line("no --enable-preview flag used on this run"); t.save(); assertThat(result).isEqualTo("handled req-42"); } }