Package org.apache.http.message

Examples of org.apache.http.message.BasicListHeaderIterator


  protected NexusConnectionKeepAliveStrategy subject;

  @Before
  public void prepare() {
    subject = new NexusConnectionKeepAliveStrategy(5000l);
    Mockito.when(httpResponse.headerIterator(Mockito.anyString())).thenReturn(new BasicListHeaderIterator(
        Collections.<Header>emptyList(), null));
  }
View Full Code Here


  public void keepAliveServerValueIfLess() {
    // server response says 3s
    // server wins
    final List<Header> headers = new ArrayList<Header>(1);
    headers.add(new BasicHeader("Keep-Alive", "timeout=3"));
    Mockito.when(httpResponse.headerIterator(Mockito.anyString())).thenReturn(new BasicListHeaderIterator(
        headers, null));
    final long keepAlive =
        subject.getKeepAliveDuration(httpResponse, httpContext);
    MatcherAssert.assertThat(keepAlive, Matchers.is(3000l));
  }
View Full Code Here

  public void keepAliveServerValueIfLessWithMaxConnCount() {
    // server response says 3s
    // server wins
    final List<Header> headers = new ArrayList<Header>(1);
    headers.add(new BasicHeader("Keep-Alive", "timeout=3, max=100"));
    Mockito.when(httpResponse.headerIterator(Mockito.anyString())).thenReturn(new BasicListHeaderIterator(
        headers, null));
    final long keepAlive =
        subject.getKeepAliveDuration(httpResponse, httpContext);
    MatcherAssert.assertThat(keepAlive, Matchers.is(3000l));
  }
View Full Code Here

  public void keepAliveDefaultValueIfMore() {
    // server response says 8s
    // nexus wins (is capped)
    final List<Header> headers = new ArrayList<Header>(1);
    headers.add(new BasicHeader("Keep-Alive", "timeout=8"));
    Mockito.when(httpResponse.headerIterator(Mockito.anyString())).thenReturn(new BasicListHeaderIterator(
        headers, null));
    final long keepAlive =
        subject.getKeepAliveDuration(httpResponse, httpContext);
    MatcherAssert.assertThat(keepAlive, Matchers.is(5000l));
  }
View Full Code Here

        final Field field = FieldUtils.getField(httpClientBuilderClass, "keepAliveStrategy", true);
        final DefaultConnectionKeepAliveStrategy strategy = (DefaultConnectionKeepAliveStrategy) field.get(apacheBuilder);
        final HttpContext context = mock(HttpContext.class);
        final HttpResponse response = mock(HttpResponse.class);
        final HeaderIterator iterator = new BasicListHeaderIterator(
                ImmutableList.<Header>of(new BasicHeader(HttpHeaders.CONNECTION, "timeout=50")),
                HttpHeaders.CONNECTION
        );
        when(response.headerIterator(HTTP.CONN_KEEP_ALIVE)).thenReturn(iterator);
View Full Code Here

TOP

Related Classes of org.apache.http.message.BasicListHeaderIterator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.