BAEL-12 userAgent header value in one place

This commit is contained in:
Tomasz Lelek 2017-02-14 09:59:12 +01:00
parent 34bfeed011
commit 3eb0575708
1 changed files with 2 additions and 2 deletions

View File

@ -38,12 +38,12 @@ public class HttpClientAdvancedConfiguration {
@Test
public void givenClientWithCustomUserAgentHeader_whenExecuteRequest_shouldReturn200() throws IOException {
//given
String userAgent = "BaeldungAgent/1.0";
serviceMock.stubFor(get(urlEqualTo("/detail"))
.withHeader("User-Agent", equalTo("BaeldungAgent/1.0"))
.withHeader("User-Agent", equalTo(userAgent))
.willReturn(aResponse()
.withStatus(200)));
String userAgent = "BaeldungAgent/1.0";
HttpClient httpClient = HttpClients.createDefault();
final HttpGet httpGet = new HttpGet("http://localhost:8089/detail");
httpGet.setHeader(HttpHeaders.USER_AGENT, userAgent);