33 * SPDX-License-Identifier: Apache-2.0
44 */
55
6+ import static org .junit .jupiter .api .Assumptions .assumeTrue ;
7+
68import io .opentelemetry .api .GlobalOpenTelemetry ;
79import io .opentelemetry .api .trace .SpanKind ;
810import io .opentelemetry .api .trace .Tracer ;
911import io .opentelemetry .instrumentation .testing .junit .AgentInstrumentationExtension ;
1012import io .opentelemetry .instrumentation .testing .junit .InstrumentationExtension ;
13+ import java .lang .reflect .Method ;
1114import java .util .concurrent .Callable ;
1215import java .util .concurrent .CountDownLatch ;
1316import org .junit .jupiter .api .Test ;
@@ -22,6 +25,23 @@ class SimpleAsyncTaskExecutorInstrumentationTest {
2225
2326 private static final SimpleAsyncTaskExecutor EXECUTOR = new SimpleAsyncTaskExecutor ();
2427
28+ private static final Method submitListenableRunnable ;
29+ private static final Method submitListenableCallable ;
30+
31+ static {
32+ // removed in spring 7
33+ submitListenableRunnable = findMethod ("submitListenable" , Runnable .class );
34+ submitListenableCallable = findMethod ("submitListenable" , Callable .class );
35+ }
36+
37+ private static Method findMethod (String name , Class <?>... parameterTypes ) {
38+ try {
39+ return SimpleAsyncTaskExecutor .class .getMethod (name , parameterTypes );
40+ } catch (Exception e ) {
41+ return null ;
42+ }
43+ }
44+
2545 @ Test
2646 void executeRunnable () {
2747 executeTwoTasks (EXECUTOR ::execute );
@@ -39,12 +59,14 @@ void submitCallable() {
3959
4060 @ Test
4161 void submitListenableRunnable () {
42- executeTwoTasks (task -> EXECUTOR .submitListenable ((Runnable ) task ));
62+ assumeTrue (submitListenableRunnable != null );
63+ executeTwoTasks (task -> submitListenableRunnable .invoke (EXECUTOR , task ));
4364 }
4465
4566 @ Test
4667 void submitListenableCallable () {
47- executeTwoTasks (task -> EXECUTOR .submitListenable ((Callable <?>) task ));
68+ assumeTrue (submitListenableCallable != null );
69+ executeTwoTasks (task -> submitListenableCallable .invoke (EXECUTOR , task ));
4870 }
4971
5072 private static void executeTwoTasks (ThrowingConsumer <AsyncTask > task ) {
0 commit comments