public Builder() { super(); this.requests = 1; this.concurrencyLevel = 1; this.keepAlive = false; this.verbosity = 0; this.headInsteadOfGet = false; this.socketTimeout = Timeout.ofSeconds(60); }
Builder() { this.bufferSize = -1; this.chunkSizeHint = -1; this.waitForContinueTimeout = Timeout.ofSeconds(3); this.maxLineLength = -1; this.maxHeaderCount = -1; this.maxEmptyLineCount = 10; this.initialWindowSize = -1; }
Builder() { this.bufferSize = -1; this.chunkSizeHint = -1; this.waitForContinueTimeout = Timeout.ofSeconds(3); this.maxLineLength = -1; this.maxHeaderCount = -1; this.maxEmptyLineCount = 10; this.initialWindowSize = -1; }
public Builder() { super(); this.requests = 1; this.concurrencyLevel = 1; this.keepAlive = false; this.verbosity = 0; this.headInsteadOfGet = false; this.socketTimeout = Timeout.ofSeconds(60); }
public H1Config build() { return new H1Config( bufferSize > 0 ? bufferSize : 8192, chunkSizeHint, waitForContinueTimeout != null ? waitForContinueTimeout : Timeout.ofSeconds(3), maxLineLength, maxHeaderCount, maxEmptyLineCount, initialWindowSize > 0 ? initialWindowSize : 65535); }
public H1Config build() { return new H1Config( bufferSize > 0 ? bufferSize : 8192, chunkSizeHint, waitForContinueTimeout != null ? waitForContinueTimeout : Timeout.ofSeconds(3), maxLineLength, maxHeaderCount, maxEmptyLineCount, initialWindowSize > 0 ? initialWindowSize : 65535); }
@Override public void close() throws IOException { connectionEvictor.shutdown(); try { connectionEvictor.awaitTermination(Timeout.ofSeconds(1)); } catch (final InterruptedException interrupted) { Thread.currentThread().interrupt(); } }
@Test public void testGetSessionReconnectIfClosed() throws Exception { final AbstractIOSessionPool.PoolEntry entry1 = impl.getPoolEntry("somehost"); Assert.assertThat(entry1, CoreMatchers.notNullValue()); entry1.session = ioSession1; Mockito.when(ioSession1.isClosed()).thenReturn(true); impl.getSession("somehost", Timeout.ofSeconds(123L), null); Mockito.verify(impl).connectSession( ArgumentMatchers.eq("somehost"), ArgumentMatchers.eq(Timeout.ofSeconds(123L)), ArgumentMatchers.<FutureCallback<IOSession>>any()); }
@Test public void testGetSessionReconnectAfterValidate() throws Exception { final AbstractIOSessionPool.PoolEntry entry1 = impl.getPoolEntry("somehost"); Assert.assertThat(entry1, CoreMatchers.notNullValue()); entry1.session = ioSession1; Mockito.when(ioSession1.isClosed()).thenReturn(false); Mockito.doAnswer(new Answer() { @Override public Object answer(final InvocationOnMock invocation) throws Throwable { final Callback<Boolean> callback = invocation.getArgument(1); callback.execute(false); return null; } }).when(impl).validateSession(ArgumentMatchers.<IOSession>any(), ArgumentMatchers.<Callback<Boolean>>any()); impl.getSession("somehost", Timeout.ofSeconds(123L), null); Mockito.verify(impl, Mockito.times(1)).connectSession( ArgumentMatchers.eq("somehost"), ArgumentMatchers.eq(Timeout.ofSeconds(123L)), ArgumentMatchers.<FutureCallback<IOSession>>any()); }
@Test public void testFromString() throws ParseException { Assert.assertEquals(Timeout.ofSeconds(Long.MAX_VALUE), Timeout.parse("9,223,372,036,854,775,807 SECONDS")); Assert.assertEquals(Timeout.ofSeconds(Long.MAX_VALUE), Timeout.parse("9,223,372,036,854,775,807 Seconds")); Assert.assertEquals(Timeout.ofSeconds(Long.MAX_VALUE), Timeout.parse("9,223,372,036,854,775,807 Seconds")); Assert.assertEquals(Timeout.ofSeconds(Long.MAX_VALUE), Timeout.parse("9,223,372,036,854,775,807\tSeconds")); Assert.assertEquals(Timeout.ZERO_MILLISECONDS, Timeout.parse("0 MILLISECONDS")); }
ArgumentMatchers.<FutureCallback<IOSession>>any())).thenReturn(connectFuture); final Future<IOSession> future1 = impl.getSession("somehost", Timeout.ofSeconds(123L), null); Assert.assertThat(future1, CoreMatchers.notNullValue()); Assert.assertThat(future1.isDone(), CoreMatchers.equalTo(false)); ArgumentMatchers.eq(Timeout.ofSeconds(123L)), ArgumentMatchers.<FutureCallback<IOSession>>any()); final Future<IOSession> future2 = impl.getSession("somehost", Timeout.ofSeconds(123L), null); Assert.assertThat(future2, CoreMatchers.notNullValue()); Assert.assertThat(future2.isDone(), CoreMatchers.equalTo(false));
final Future<IOSession> future1 = impl.getSession("somehost", Timeout.ofSeconds(123L), null); Assert.assertThat(future1, CoreMatchers.notNullValue()); Assert.assertThat(future1.isDone(), CoreMatchers.equalTo(false)); ArgumentMatchers.eq(Timeout.ofSeconds(123L)), ArgumentMatchers.<FutureCallback<IOSession>>any()); final Future<IOSession> future2 = impl.getSession("somehost", Timeout.ofSeconds(123L), null); Assert.assertThat(future2, CoreMatchers.notNullValue()); Assert.assertThat(future2.isDone(), CoreMatchers.equalTo(false)); final Future<IOSession> future3 = impl.getSession("somehost", Timeout.ofSeconds(123L), null);
@Test public void testToString() { Assert.assertEquals("9,223,372,036,854,775,807 SECONDS", Timeout.ofSeconds(Long.MAX_VALUE).toString()); Assert.assertEquals("0 MILLISECONDS", Timeout.ZERO_MILLISECONDS.toString()); }