List of usage examples for org.apache.http.message BasicListHeaderIterator BasicListHeaderIterator
public BasicListHeaderIterator(List<Header> list, String str)
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)); }