9
9
import static io .opentelemetry .instrumentation .testing .junit .http .ServerEndpoint .CAPTURE_HEADERS ;
10
10
import static io .opentelemetry .instrumentation .testing .junit .http .ServerEndpoint .ERROR ;
11
11
import static io .opentelemetry .instrumentation .testing .junit .http .ServerEndpoint .EXCEPTION ;
12
+ import static io .opentelemetry .instrumentation .testing .junit .http .ServerEndpoint .ID_PARAMETER_NAME ;
13
+ import static io .opentelemetry .instrumentation .testing .junit .http .ServerEndpoint .INDEXED_CHILD ;
12
14
import static io .opentelemetry .instrumentation .testing .junit .http .ServerEndpoint .NOT_FOUND ;
13
15
import static io .opentelemetry .instrumentation .testing .junit .http .ServerEndpoint .QUERY_PARAM ;
14
16
import static io .opentelemetry .instrumentation .testing .junit .http .ServerEndpoint .REDIRECT ;
31
33
import io .opentelemetry .instrumentation .testing .junit .http .HttpServerTestOptions ;
32
34
import io .opentelemetry .instrumentation .testing .junit .http .ServerEndpoint ;
33
35
import io .opentelemetry .testing .internal .armeria .internal .shaded .guava .collect .ImmutableSet ;
34
- import org .junit .ClassRule ;
35
36
import org .junit .jupiter .api .extension .RegisterExtension ;
36
37
37
38
public class ActivejHttpServerTest extends AbstractHttpServerTest <HttpServer > {
38
39
39
- @ ClassRule public static final EventloopRule eventloopRule = new EventloopRule ();
40
+ @ RegisterExtension static final EventloopExtension eventloopExtension = new EventloopExtension ();
40
41
41
42
@ RegisterExtension
42
43
static final InstrumentationExtension testing = HttpServerInstrumentationExtension .forAgent ();
@@ -58,6 +59,30 @@ protected HttpServer setupServer() throws Exception {
58
59
controller (CAPTURE_HEADERS , () -> httpResponse );
59
60
return httpResponse .toPromise ();
60
61
};
62
+ AsyncServlet indexChildAsyncServlet =
63
+ request -> {
64
+ HttpResponse httpResponse =
65
+ HttpResponse .builder ()
66
+ .withBody (INDEXED_CHILD .getBody ())
67
+ .withCode (INDEXED_CHILD .getStatus ())
68
+ .build ();
69
+ INDEXED_CHILD .collectSpanAttributes (
70
+ id ->
71
+ id .equals (ID_PARAMETER_NAME )
72
+ ? request .getQueryParameter (ID_PARAMETER_NAME )
73
+ : null );
74
+ controller (
75
+ INDEXED_CHILD ,
76
+ () -> {
77
+ INDEXED_CHILD .collectSpanAttributes (
78
+ id ->
79
+ id .equals (ID_PARAMETER_NAME )
80
+ ? request .getQueryParameter (ID_PARAMETER_NAME )
81
+ : null );
82
+ return httpResponse ;
83
+ });
84
+ return httpResponse .toPromise ();
85
+ };
61
86
62
87
RoutingServlet routingServlet =
63
88
RoutingServlet .builder (eventloop )
@@ -68,6 +93,7 @@ protected HttpServer setupServer() throws Exception {
68
93
.with (GET , EXCEPTION .getPath (), request -> prepareResponse (EXCEPTION ))
69
94
.with (GET , REDIRECT .getPath (), request -> prepareResponse (REDIRECT ))
70
95
.with (GET , CAPTURE_HEADERS .getPath (), captureHttpHeadersAsyncServlet )
96
+ .with (GET , INDEXED_CHILD .getPath (), indexChildAsyncServlet )
71
97
.build ();
72
98
73
99
HttpServer server = HttpServer .builder (eventloop , routingServlet ).withListenPort (port ).build ();
@@ -84,11 +110,6 @@ protected void stopServer(HttpServer server) throws Exception {
84
110
thread .join ();
85
111
}
86
112
87
- @ Override
88
- protected void assertHighConcurrency (int count ) {
89
- //
90
- }
91
-
92
113
@ Override
93
114
protected void configure (HttpServerTestOptions options ) {
94
115
options .setTestHttpPipelining (false );
0 commit comments