44
55package io .prometheus .wls .rest ;
66
7- import org .hamcrest .Matcher ;
8- import org .junit .Before ;
9- import org .junit .Test ;
10-
11- import javax .servlet .ServletException ;
12- import javax .servlet .annotation .WebServlet ;
13- import javax .servlet .http .HttpServlet ;
147import java .io .IOException ;
158import java .lang .reflect .Modifier ;
169import java .util .stream .IntStream ;
10+ import javax .servlet .ServletException ;
11+ import javax .servlet .annotation .WebServlet ;
12+ import javax .servlet .http .HttpServlet ;
13+
14+ import org .hamcrest .Matcher ;
15+ import org .junit .Before ;
16+ import org .junit .Test ;
1717
18- import static io .prometheus .wls .rest .MessagesServlet .MAX_EXCHANGES ;
1918import static io .prometheus .wls .rest .HttpServletRequestStub .createGetRequest ;
2019import static io .prometheus .wls .rest .HttpServletResponseStub .createServletResponse ;
21- import static org .hamcrest .Matchers .*;
20+ import static io .prometheus .wls .rest .MessagesServlet .MAX_EXCHANGES ;
21+ import static org .hamcrest .Matchers .arrayContaining ;
22+ import static org .hamcrest .Matchers .both ;
23+ import static org .hamcrest .Matchers .contains ;
24+ import static org .hamcrest .Matchers .containsString ;
25+ import static org .hamcrest .Matchers .hasItem ;
26+ import static org .hamcrest .Matchers .instanceOf ;
27+ import static org .hamcrest .Matchers .is ;
28+ import static org .hamcrest .Matchers .notNullValue ;
2229import static org .hamcrest .junit .MatcherAssert .assertThat ;
2330
2431public class MessagesServletTest {
2532 private static final int EXCESS_EXCHANGES = 3 ;
33+ private static final String URL = "http://localhost:7001" ;
2634 private MessagesServlet servlet = new MessagesServlet ();
2735 private HttpServletRequestStub request = createGetRequest ();
2836 private HttpServletResponseStub response = createServletResponse ();
@@ -56,7 +64,7 @@ public void servletAnnotationIndicatesMetricsPage() {
5664
5765 @ Test
5866 public void afterExchangeAdded_retrieveExchange () {
59- MessagesServlet .addExchange ("request 1" , "response1" );
67+ MessagesServlet .addExchange (URL , "request 1" , "response1" );
6068
6169 assertThat (MessagesServlet .getMessages (), hasItem (both (containsString ("request 1" )).and (containsString ("response1" ))));
6270 }
@@ -69,7 +77,7 @@ public void afterMaximumExchangesAdded_retrieveAllExchanges() {
6977 }
7078
7179 private void addTestExchange (int i ) {
72- MessagesServlet .addExchange ("request " + i , "response " + i );
80+ MessagesServlet .addExchange (URL , "request " + i , "response " + i );
7381 }
7482
7583 @ SuppressWarnings ("unchecked" )
0 commit comments