Assert.assertEquals("name1=value; name2=value; name3=value", headers1[0].getValue());
}
@Test
public void testAddSpecVersionHeader() throws Exception {
HttpRequest request = new BasicHttpRequest("GET", "/");
this.cookieStore.clear();
BasicClientCookie cookie1 = new BasicClientCookie("name1", "value1");
cookie1.setVersion(0);
cookie1.setDomain("localhost.local");
cookie1.setPath("/");
this.cookieStore.addCookie(cookie1);
BasicClientCookie cookie2 = new BasicClientCookie("name2", "value2");
cookie2.setVersion(0);
cookie2.setDomain("localhost.local");
cookie2.setPath("/");
this.cookieStore.addCookie(cookie2);
HttpRoute route = new HttpRoute(this.target, null, false);
HttpRoutedConnection conn = Mockito.mock(HttpRoutedConnection.class);
Mockito.when(conn.getRoute()).thenReturn(route);
Mockito.when(conn.isSecure()).thenReturn(Boolean.FALSE);
HttpContext context = new BasicHttpContext();
context.setAttribute(ExecutionContext.HTTP_TARGET_HOST, this.target);
context.setAttribute(ExecutionContext.HTTP_CONNECTION, conn);
context.setAttribute(ClientContext.COOKIE_STORE, this.cookieStore);
context.setAttribute(ClientContext.COOKIESPEC_REGISTRY, this.cookieSpecRegistry);
HttpRequestInterceptor interceptor = new RequestAddCookies();
interceptor.process(request, context);
Header[] headers1 = request.getHeaders(SM.COOKIE);
Assert.assertNotNull(headers1);
Assert.assertEquals(1, headers1.length);
Assert.assertEquals("name1=value1; name2=value2", headers1[0].getValue());
Header[] headers2 = request.getHeaders(SM.COOKIE2);
Assert.assertNotNull(headers2);
Assert.assertEquals(1, headers2.length);
Assert.assertEquals("$Version=1", headers2[0].getValue());
}