File tree Expand file tree Collapse file tree 3 files changed +18
-9
lines changed
sdk/spring/spring-cloud-azure-starter-monitor-test
src/test/java/com/azure/spring/cloud/autoconfigure/monitor Expand file tree Collapse file tree 3 files changed +18
-9
lines changed Original file line number Diff line number Diff line change 6767 <version >4.0.2</version > <!-- {x-version-update;springboot4_org.springframework.boot:spring-boot-resttestclient;external_dependency} -->
6868 <scope >test</scope >
6969 </dependency >
70+ <dependency >
71+ <groupId >org.springframework.boot</groupId >
72+ <artifactId >spring-boot-restclient</artifactId >
73+ <version >4.0.2</version > <!-- {x-version-update;springboot4_org.springframework.boot:spring-boot-restclient;external_dependency} -->
74+ <scope >test</scope >
75+ </dependency >
7076 <dependency >
7177 <groupId >com.azure</groupId >
7278 <artifactId >azure-core-test</artifactId >
Original file line number Diff line number Diff line change 66import com .azure .core .http .HttpPipelineNextPolicy ;
77import com .azure .core .http .HttpResponse ;
88import com .azure .core .http .policy .HttpPipelinePolicy ;
9+ import com .azure .core .test .http .MockHttpResponse ;
910import com .azure .core .util .FluxUtil ;
1011import com .azure .json .JsonProviders ;
1112import com .azure .json .JsonReader ;
@@ -33,14 +34,17 @@ final class CustomValidationPolicy implements HttpPipelinePolicy {
3334
3435 @ Override
3536 public Mono <HttpResponse > process (HttpPipelineCallContext context , HttpPipelineNextPolicy next ) {
36- url = context .getHttpRequest ().getUrl ();
37- Mono <byte []> asyncBytes = FluxUtil .collectBytesInByteBufferStream (context .getHttpRequest ().getBody ())
38- .map (LocalStorageTelemetryPipelineListener ::ungzip );
39- asyncBytes .subscribe (value -> {
40- actualTelemetryItems .addAll (deserialize (value ));
41- countDown .countDown ();
42- });
43- return next .process ();
37+ URL requestUrl = context .getHttpRequest ().getUrl ();
38+ if (requestUrl .getPath ().contains ("/v2.1/track" )) {
39+ url = requestUrl ;
40+ Mono <byte []> asyncBytes = FluxUtil .collectBytesInByteBufferStream (context .getHttpRequest ().getBody ())
41+ .map (LocalStorageTelemetryPipelineListener ::ungzip );
42+ asyncBytes .subscribe (value -> {
43+ actualTelemetryItems .addAll (deserialize (value ));
44+ countDown .countDown ();
45+ });
46+ }
47+ return Mono .just (new MockHttpResponse (context .getHttpRequest (), 200 ));
4448 }
4549
4650 // Copied from com.azure.monitor.opentelemetry.exporter.implementation.utils.TestUtils.java
Original file line number Diff line number Diff line change 3838 classes = {Application .class , SpringMonitorTest .TestConfig .class },
3939 webEnvironment = SpringBootTest .WebEnvironment .RANDOM_PORT )
4040@ AutoConfigureTestRestTemplate
41- @ Disabled ("Needs to be fixed for Spring 7" )
4241class SpringMonitorTest {
4342
4443 private static CountDownLatch countDownLatch ;
You can’t perform that action at this time.
0 commit comments