Example usage for org.apache.http.message BasicListHeaderIterator BasicListHeaderIterator

List of usage examples for org.apache.http.message BasicListHeaderIterator BasicListHeaderIterator

Introduction

In this page you can find the example usage for org.apache.http.message BasicListHeaderIterator BasicListHeaderIterator.

Prototype

public BasicListHeaderIterator(List<Header> list, String str) 

Source Link

Usage

From source file:org.sonatype.nexus.apachehttpclient.NexusConnectionKeepAliveStrategyTest.java

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

From source file:org.sonatype.nexus.apachehttpclient.NexusConnectionKeepAliveStrategyTest.java

@Test
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));
}

From source file:org.sonatype.nexus.apachehttpclient.NexusConnectionKeepAliveStrategyTest.java

@Test
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));
}

From source file:org.sonatype.nexus.apachehttpclient.NexusConnectionKeepAliveStrategyTest.java

@Test
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));
}