Search in sources :

Example 1 with InMemoryHttpTraceRepository

use of org.springframework.boot.actuate.trace.http.InMemoryHttpTraceRepository in project spring-cloud-netflix by spring-cloud.

the class ProxyRequestHelperTests method debug.

@Test
public void debug() throws Exception {
    MockHttpServletRequest request = new MockHttpServletRequest("POST", "/");
    request.setContent("{}".getBytes());
    request.addHeader("singleName", "singleValue");
    request.addHeader("multiName", "multiValue1");
    request.addHeader("multiName", "multiValue2");
    RequestContext.getCurrentContext().setRequest(request);
    TraceProxyRequestHelper helper = new TraceProxyRequestHelper();
    this.traceRepository = new InMemoryHttpTraceRepository();
    helper.setTraces(this.traceRepository);
    MultiValueMap<String, String> headers = helper.buildZuulRequestHeaders(request);
    helper.debug("POST", "http://example.com", headers, new LinkedMultiValueMap<>(), request.getInputStream());
    HttpTrace actual = this.traceRepository.findAll().get(0);
    Assertions.assertThat(actual.getRequest().getHeaders()).containsKeys("singleName", "multiName");
}
Also used : HttpTrace(org.springframework.boot.actuate.trace.http.HttpTrace) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) InMemoryHttpTraceRepository(org.springframework.boot.actuate.trace.http.InMemoryHttpTraceRepository) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 HttpTrace (org.springframework.boot.actuate.trace.http.HttpTrace)1 InMemoryHttpTraceRepository (org.springframework.boot.actuate.trace.http.InMemoryHttpTraceRepository)1 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)1