use of com.microsoft.applicationinsights.agent.internal.MockHttpResponse in project ApplicationInsights-Java by microsoft.
the class QuickPulseDataFetcherTests method endpointChangesWithRedirectHeaderAndGetNewPingInterval.
@Test
void endpointChangesWithRedirectHeaderAndGetNewPingInterval() {
Map<String, String> headers = new HashMap<>();
headers.put("x-ms-qps-service-polling-interval-hint", "1000");
headers.put("x-ms-qps-service-endpoint-redirect", "https://new.endpoint.com");
headers.put("x-ms-qps-subscribed", "true");
HttpHeaders httpHeaders = new HttpHeaders(headers);
TelemetryClient telemetryClient = TelemetryClient.createForTest();
telemetryClient.setInstrumentationKey("fake-key");
HttpPipeline httpPipeline = new HttpPipelineBuilder().httpClient(request -> Mono.just(new MockHttpResponse(request, 200, httpHeaders))).build();
QuickPulsePingSender quickPulsePingSender = new QuickPulsePingSender(httpPipeline, telemetryClient, "machine1", "instance1", "qpid123");
QuickPulseHeaderInfo quickPulseHeaderInfo = quickPulsePingSender.ping(null);
assertThat(QuickPulseStatus.QP_IS_ON).isEqualTo(quickPulseHeaderInfo.getQuickPulseStatus());
assertThat(1000).isEqualTo(quickPulseHeaderInfo.getQpsServicePollingInterval());
assertThat("https://new.endpoint.com").isEqualTo(quickPulseHeaderInfo.getQpsServiceEndpointRedirect());
}
use of com.microsoft.applicationinsights.agent.internal.MockHttpResponse in project ApplicationInsights-Java by microsoft.
the class QuickPulsePingSenderTests method endpointChangesWithRedirectHeaderAndGetNewPingInterval.
@Test
void endpointChangesWithRedirectHeaderAndGetNewPingInterval() {
Map<String, String> headers = new HashMap<>();
headers.put("x-ms-qps-service-polling-interval-hint", "1000");
headers.put("x-ms-qps-service-endpoint-redirect", "https://new.endpoint.com");
headers.put("x-ms-qps-subscribed", "true");
HttpHeaders httpHeaders = new HttpHeaders(headers);
TelemetryClient telemetryClient = TelemetryClient.createForTest();
telemetryClient.setInstrumentationKey("fake-ikey");
HttpPipeline httpPipeline = new HttpPipelineBuilder().httpClient(request -> Mono.just(new MockHttpResponse(request, 200, httpHeaders))).build();
QuickPulsePingSender quickPulsePingSender = new QuickPulsePingSender(httpPipeline, telemetryClient, "machine1", "instance1", "qpid123");
QuickPulseHeaderInfo quickPulseHeaderInfo = quickPulsePingSender.ping(null);
assertThat(QuickPulseStatus.QP_IS_ON).isEqualTo(quickPulseHeaderInfo.getQuickPulseStatus());
assertThat(1000).isEqualTo(quickPulseHeaderInfo.getQpsServicePollingInterval());
assertThat("https://new.endpoint.com").isEqualTo(quickPulseHeaderInfo.getQpsServiceEndpointRedirect());
}
Aggregations