|
|
|
@ -1,5 +1,5 @@
|
|
|
|
|
/*
|
|
|
|
|
* Copyright 2012-2015 the original author or authors.
|
|
|
|
|
* Copyright 2012-2016 the original author or authors.
|
|
|
|
|
*
|
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
@ -38,6 +38,9 @@ import org.springframework.mock.web.MockHttpServletRequest;
|
|
|
|
|
import org.springframework.mock.web.MockHttpServletResponse;
|
|
|
|
|
|
|
|
|
|
import static org.assertj.core.api.Assertions.assertThat;
|
|
|
|
|
import static org.mockito.Mockito.spy;
|
|
|
|
|
import static org.mockito.Mockito.times;
|
|
|
|
|
import static org.mockito.Mockito.verify;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Tests for {@link WebRequestTraceFilter}.
|
|
|
|
@ -45,6 +48,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|
|
|
|
* @author Dave Syer
|
|
|
|
|
* @author Wallace Wadge
|
|
|
|
|
* @author Phillip Webb
|
|
|
|
|
* @author Andy Wilkinson
|
|
|
|
|
*/
|
|
|
|
|
public class WebRequestTraceFilterTests {
|
|
|
|
|
|
|
|
|
@ -58,13 +62,14 @@ public class WebRequestTraceFilterTests {
|
|
|
|
|
@Test
|
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
|
|
public void filterAddsTraceWithDefaultIncludes() {
|
|
|
|
|
MockHttpServletRequest request = new MockHttpServletRequest("GET", "/foo");
|
|
|
|
|
MockHttpServletRequest request = spy(new MockHttpServletRequest("GET", "/foo"));
|
|
|
|
|
request.addHeader("Accept", "application/json");
|
|
|
|
|
Map<String, Object> trace = this.filter.getTrace(request);
|
|
|
|
|
assertThat(trace.get("method")).isEqualTo("GET");
|
|
|
|
|
assertThat(trace.get("path")).isEqualTo("/foo");
|
|
|
|
|
Map<String, Object> map = (Map<String, Object>) trace.get("headers");
|
|
|
|
|
assertThat(map.get("request").toString()).isEqualTo("{Accept=application/json}");
|
|
|
|
|
verify(request, times(0)).getParameterMap();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|