mirror of
https://github.com/apache/httpcomponents-client.git
synced 2025-02-27 21:29:12 +00:00
Redundant type declarations
This commit is contained in:
parent
2072651983
commit
8580d7fddf
@ -87,8 +87,8 @@ public void testCachePut() throws Exception {
|
||||
Mockito.when(impl.digestToStorageKey(key)).thenReturn("bar");
|
||||
Mockito.when(impl.store(
|
||||
ArgumentMatchers.eq("bar"),
|
||||
ArgumentMatchers.<byte[]>any(),
|
||||
ArgumentMatchers.<FutureCallback<Boolean>>any())).thenAnswer((Answer<Cancellable>) invocation -> {
|
||||
ArgumentMatchers.any(),
|
||||
ArgumentMatchers.any())).thenAnswer((Answer<Cancellable>) invocation -> {
|
||||
final FutureCallback<Boolean> callback = invocation.getArgument(2);
|
||||
callback.completed(true);
|
||||
return cancellable;
|
||||
@ -97,7 +97,7 @@ public void testCachePut() throws Exception {
|
||||
impl.putEntry(key, value, operationCallback);
|
||||
|
||||
final ArgumentCaptor<byte[]> argumentCaptor = ArgumentCaptor.forClass(byte[].class);
|
||||
Mockito.verify(impl).store(ArgumentMatchers.eq("bar"), argumentCaptor.capture(), ArgumentMatchers.<FutureCallback<Boolean>>any());
|
||||
Mockito.verify(impl).store(ArgumentMatchers.eq("bar"), argumentCaptor.capture(), ArgumentMatchers.any());
|
||||
Assert.assertArrayEquals(serialize(key, value), argumentCaptor.getValue());
|
||||
Mockito.verify(operationCallback).completed(Boolean.TRUE);
|
||||
}
|
||||
@ -107,7 +107,7 @@ public void testCacheGetNullEntry() throws Exception {
|
||||
final String key = "foo";
|
||||
|
||||
Mockito.when(impl.digestToStorageKey(key)).thenReturn("bar");
|
||||
Mockito.when(impl.restore(ArgumentMatchers.eq("bar"), ArgumentMatchers.<FutureCallback<byte[]>>any())).thenAnswer((Answer<Cancellable>) invocation -> {
|
||||
Mockito.when(impl.restore(ArgumentMatchers.eq("bar"), ArgumentMatchers.any())).thenAnswer((Answer<Cancellable>) invocation -> {
|
||||
final FutureCallback<byte[]> callback = invocation.getArgument(1);
|
||||
callback.completed(null);
|
||||
return cancellable;
|
||||
@ -117,7 +117,7 @@ public void testCacheGetNullEntry() throws Exception {
|
||||
final ArgumentCaptor<HttpCacheEntry> argumentCaptor = ArgumentCaptor.forClass(HttpCacheEntry.class);
|
||||
Mockito.verify(cacheEntryCallback).completed(argumentCaptor.capture());
|
||||
Assert.assertThat(argumentCaptor.getValue(), CoreMatchers.nullValue());
|
||||
Mockito.verify(impl).restore(ArgumentMatchers.eq("bar"), ArgumentMatchers.<FutureCallback<byte[]>>any());
|
||||
Mockito.verify(impl).restore(ArgumentMatchers.eq("bar"), ArgumentMatchers.any());
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -126,7 +126,7 @@ public void testCacheGet() throws Exception {
|
||||
final HttpCacheEntry value = HttpTestUtils.makeCacheEntry();
|
||||
|
||||
Mockito.when(impl.digestToStorageKey(key)).thenReturn("bar");
|
||||
Mockito.when(impl.restore(ArgumentMatchers.eq("bar"), ArgumentMatchers.<FutureCallback<byte[]>>any())).thenAnswer((Answer<Cancellable>) invocation -> {
|
||||
Mockito.when(impl.restore(ArgumentMatchers.eq("bar"), ArgumentMatchers.any())).thenAnswer((Answer<Cancellable>) invocation -> {
|
||||
final FutureCallback<byte[]> callback = invocation.getArgument(1);
|
||||
callback.completed(serialize(key, value));
|
||||
return cancellable;
|
||||
@ -137,7 +137,7 @@ public void testCacheGet() throws Exception {
|
||||
Mockito.verify(cacheEntryCallback).completed(argumentCaptor.capture());
|
||||
final HttpCacheEntry resultingEntry = argumentCaptor.getValue();
|
||||
Assert.assertThat(resultingEntry, HttpCacheEntryMatcher.equivalent(value));
|
||||
Mockito.verify(impl).restore(ArgumentMatchers.eq("bar"), ArgumentMatchers.<FutureCallback<byte[]>>any());
|
||||
Mockito.verify(impl).restore(ArgumentMatchers.eq("bar"), ArgumentMatchers.any());
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -145,7 +145,7 @@ public void testCacheGetKeyMismatch() throws Exception {
|
||||
final String key = "foo";
|
||||
final HttpCacheEntry value = HttpTestUtils.makeCacheEntry();
|
||||
Mockito.when(impl.digestToStorageKey(key)).thenReturn("bar");
|
||||
Mockito.when(impl.restore(ArgumentMatchers.eq("bar"), ArgumentMatchers.<FutureCallback<byte[]>>any())).thenAnswer((Answer<Cancellable>) invocation -> {
|
||||
Mockito.when(impl.restore(ArgumentMatchers.eq("bar"), ArgumentMatchers.any())).thenAnswer((Answer<Cancellable>) invocation -> {
|
||||
final FutureCallback<byte[]> callback = invocation.getArgument(1);
|
||||
callback.completed(serialize("not-foo", value));
|
||||
return cancellable;
|
||||
@ -155,7 +155,7 @@ public void testCacheGetKeyMismatch() throws Exception {
|
||||
final ArgumentCaptor<HttpCacheEntry> argumentCaptor = ArgumentCaptor.forClass(HttpCacheEntry.class);
|
||||
Mockito.verify(cacheEntryCallback).completed(argumentCaptor.capture());
|
||||
Assert.assertThat(argumentCaptor.getValue(), CoreMatchers.nullValue());
|
||||
Mockito.verify(impl).restore(ArgumentMatchers.eq("bar"), ArgumentMatchers.<FutureCallback<byte[]>>any());
|
||||
Mockito.verify(impl).restore(ArgumentMatchers.eq("bar"), ArgumentMatchers.any());
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -165,7 +165,7 @@ public void testCacheRemove() throws Exception{
|
||||
Mockito.when(impl.digestToStorageKey(key)).thenReturn("bar");
|
||||
Mockito.when(impl.delete(
|
||||
ArgumentMatchers.eq("bar"),
|
||||
ArgumentMatchers.<FutureCallback<Boolean>>any())).thenAnswer((Answer<Cancellable>) invocation -> {
|
||||
ArgumentMatchers.any())).thenAnswer((Answer<Cancellable>) invocation -> {
|
||||
final FutureCallback<Boolean> callback = invocation.getArgument(1);
|
||||
callback.completed(true);
|
||||
return cancellable;
|
||||
@ -182,15 +182,15 @@ public void testCacheUpdateNullEntry() throws Exception {
|
||||
final HttpCacheEntry updatedValue = HttpTestUtils.makeCacheEntry();
|
||||
|
||||
Mockito.when(impl.digestToStorageKey(key)).thenReturn("bar");
|
||||
Mockito.when(impl.getForUpdateCAS(ArgumentMatchers.eq("bar"), ArgumentMatchers.<FutureCallback<String>>any())).thenAnswer((Answer<Cancellable>) invocation -> {
|
||||
Mockito.when(impl.getForUpdateCAS(ArgumentMatchers.eq("bar"), ArgumentMatchers.any())).thenAnswer((Answer<Cancellable>) invocation -> {
|
||||
final FutureCallback<byte[]> callback = invocation.getArgument(1);
|
||||
callback.completed(null);
|
||||
return cancellable;
|
||||
});
|
||||
Mockito.when(impl.store(
|
||||
ArgumentMatchers.eq("bar"),
|
||||
ArgumentMatchers.<byte[]>any(),
|
||||
ArgumentMatchers.<FutureCallback<Boolean>>any())).thenAnswer((Answer<Cancellable>) invocation -> {
|
||||
ArgumentMatchers.any(),
|
||||
ArgumentMatchers.any())).thenAnswer((Answer<Cancellable>) invocation -> {
|
||||
final FutureCallback<Boolean> callback = invocation.getArgument(2);
|
||||
callback.completed(true);
|
||||
return cancellable;
|
||||
@ -201,8 +201,8 @@ public void testCacheUpdateNullEntry() throws Exception {
|
||||
return updatedValue;
|
||||
}, operationCallback);
|
||||
|
||||
Mockito.verify(impl).getForUpdateCAS(ArgumentMatchers.eq("bar"), ArgumentMatchers.<FutureCallback<String>>any());
|
||||
Mockito.verify(impl).store(ArgumentMatchers.eq("bar"), ArgumentMatchers.<byte[]>any(), ArgumentMatchers.<FutureCallback<Boolean>>any());
|
||||
Mockito.verify(impl).getForUpdateCAS(ArgumentMatchers.eq("bar"), ArgumentMatchers.any());
|
||||
Mockito.verify(impl).store(ArgumentMatchers.eq("bar"), ArgumentMatchers.any(), ArgumentMatchers.any());
|
||||
Mockito.verify(operationCallback).completed(Boolean.TRUE);
|
||||
}
|
||||
|
||||
@ -213,7 +213,7 @@ public void testCacheCASUpdate() throws Exception {
|
||||
final HttpCacheEntry updatedValue = HttpTestUtils.makeCacheEntry();
|
||||
|
||||
Mockito.when(impl.digestToStorageKey(key)).thenReturn("bar");
|
||||
Mockito.when(impl.getForUpdateCAS(ArgumentMatchers.eq("bar"), ArgumentMatchers.<FutureCallback<String>>any())).thenAnswer((Answer<Cancellable>) invocation -> {
|
||||
Mockito.when(impl.getForUpdateCAS(ArgumentMatchers.eq("bar"), ArgumentMatchers.any())).thenAnswer((Answer<Cancellable>) invocation -> {
|
||||
final FutureCallback<String> callback = invocation.getArgument(1);
|
||||
callback.completed("stuff");
|
||||
return cancellable;
|
||||
@ -222,8 +222,8 @@ public void testCacheCASUpdate() throws Exception {
|
||||
Mockito.when(impl.updateCAS(
|
||||
ArgumentMatchers.eq("bar"),
|
||||
ArgumentMatchers.eq("stuff"),
|
||||
ArgumentMatchers.<byte[]>any(),
|
||||
ArgumentMatchers.<FutureCallback<Boolean>>any())).thenAnswer((Answer<Cancellable>) invocation -> {
|
||||
ArgumentMatchers.any(),
|
||||
ArgumentMatchers.any())).thenAnswer((Answer<Cancellable>) invocation -> {
|
||||
final FutureCallback<Boolean> callback = invocation.getArgument(3);
|
||||
callback.completed(true);
|
||||
return cancellable;
|
||||
@ -231,9 +231,9 @@ public void testCacheCASUpdate() throws Exception {
|
||||
|
||||
impl.updateEntry(key, existing -> updatedValue, operationCallback);
|
||||
|
||||
Mockito.verify(impl).getForUpdateCAS(ArgumentMatchers.eq("bar"), ArgumentMatchers.<FutureCallback<String>>any());
|
||||
Mockito.verify(impl).getForUpdateCAS(ArgumentMatchers.eq("bar"), ArgumentMatchers.any());
|
||||
Mockito.verify(impl).getStorageObject("stuff");
|
||||
Mockito.verify(impl).updateCAS(ArgumentMatchers.eq("bar"), ArgumentMatchers.eq("stuff"), ArgumentMatchers.<byte[]>any(), ArgumentMatchers.<FutureCallback<Boolean>>any());
|
||||
Mockito.verify(impl).updateCAS(ArgumentMatchers.eq("bar"), ArgumentMatchers.eq("stuff"), ArgumentMatchers.any(), ArgumentMatchers.any());
|
||||
Mockito.verify(operationCallback).completed(Boolean.TRUE);
|
||||
}
|
||||
|
||||
@ -244,7 +244,7 @@ public void testCacheCASUpdateKeyMismatch() throws Exception {
|
||||
final HttpCacheEntry updatedValue = HttpTestUtils.makeCacheEntry();
|
||||
|
||||
Mockito.when(impl.digestToStorageKey(key)).thenReturn("bar");
|
||||
Mockito.when(impl.getForUpdateCAS(ArgumentMatchers.eq("bar"), ArgumentMatchers.<FutureCallback<String>>any())).thenAnswer(
|
||||
Mockito.when(impl.getForUpdateCAS(ArgumentMatchers.eq("bar"), ArgumentMatchers.any())).thenAnswer(
|
||||
(Answer<Cancellable>) invocation -> {
|
||||
final FutureCallback<String> callback = invocation.getArgument(1);
|
||||
callback.completed("stuff");
|
||||
@ -253,8 +253,8 @@ public void testCacheCASUpdateKeyMismatch() throws Exception {
|
||||
Mockito.when(impl.getStorageObject("stuff")).thenReturn(serialize("not-foo", existingValue));
|
||||
Mockito.when(impl.store(
|
||||
ArgumentMatchers.eq("bar"),
|
||||
ArgumentMatchers.<byte[]>any(),
|
||||
ArgumentMatchers.<FutureCallback<Boolean>>any())).thenAnswer((Answer<Cancellable>) invocation -> {
|
||||
ArgumentMatchers.any(),
|
||||
ArgumentMatchers.any())).thenAnswer((Answer<Cancellable>) invocation -> {
|
||||
final FutureCallback<Boolean> callback = invocation.getArgument(2);
|
||||
callback.completed(true);
|
||||
return cancellable;
|
||||
@ -265,11 +265,11 @@ public void testCacheCASUpdateKeyMismatch() throws Exception {
|
||||
return updatedValue;
|
||||
}, operationCallback);
|
||||
|
||||
Mockito.verify(impl).getForUpdateCAS(ArgumentMatchers.eq("bar"), ArgumentMatchers.<FutureCallback<String>>any());
|
||||
Mockito.verify(impl).getForUpdateCAS(ArgumentMatchers.eq("bar"), ArgumentMatchers.any());
|
||||
Mockito.verify(impl).getStorageObject("stuff");
|
||||
Mockito.verify(impl, Mockito.never()).updateCAS(
|
||||
ArgumentMatchers.eq("bar"), ArgumentMatchers.eq("stuff"), ArgumentMatchers.<byte[]>any(), ArgumentMatchers.<FutureCallback<Boolean>>any());
|
||||
Mockito.verify(impl).store(ArgumentMatchers.eq("bar"), ArgumentMatchers.<byte[]>any(), ArgumentMatchers.<FutureCallback<Boolean>>any());
|
||||
ArgumentMatchers.eq("bar"), ArgumentMatchers.eq("stuff"), ArgumentMatchers.any(), ArgumentMatchers.any());
|
||||
Mockito.verify(impl).store(ArgumentMatchers.eq("bar"), ArgumentMatchers.any(), ArgumentMatchers.any());
|
||||
Mockito.verify(operationCallback).completed(Boolean.TRUE);
|
||||
}
|
||||
|
||||
@ -280,7 +280,7 @@ public void testSingleCacheUpdateRetry() throws Exception {
|
||||
final HttpCacheEntry updatedValue = HttpTestUtils.makeCacheEntry();
|
||||
|
||||
Mockito.when(impl.digestToStorageKey(key)).thenReturn("bar");
|
||||
Mockito.when(impl.getForUpdateCAS(ArgumentMatchers.eq("bar"), ArgumentMatchers.<FutureCallback<String>>any())).thenAnswer(
|
||||
Mockito.when(impl.getForUpdateCAS(ArgumentMatchers.eq("bar"), ArgumentMatchers.any())).thenAnswer(
|
||||
(Answer<Cancellable>) invocation -> {
|
||||
final FutureCallback<String> callback = invocation.getArgument(1);
|
||||
callback.completed("stuff");
|
||||
@ -291,8 +291,8 @@ public void testSingleCacheUpdateRetry() throws Exception {
|
||||
Mockito.when(impl.updateCAS(
|
||||
ArgumentMatchers.eq("bar"),
|
||||
ArgumentMatchers.eq("stuff"),
|
||||
ArgumentMatchers.<byte[]>any(),
|
||||
ArgumentMatchers.<FutureCallback<Boolean>>any())).thenAnswer((Answer<Cancellable>) invocation -> {
|
||||
ArgumentMatchers.any(),
|
||||
ArgumentMatchers.any())).thenAnswer((Answer<Cancellable>) invocation -> {
|
||||
final FutureCallback<Boolean> callback = invocation.getArgument(3);
|
||||
if (count.incrementAndGet() == 1) {
|
||||
callback.completed(false);
|
||||
@ -304,10 +304,10 @@ public void testSingleCacheUpdateRetry() throws Exception {
|
||||
|
||||
impl.updateEntry(key, existing -> updatedValue, operationCallback);
|
||||
|
||||
Mockito.verify(impl, Mockito.times(2)).getForUpdateCAS(ArgumentMatchers.eq("bar"), ArgumentMatchers.<FutureCallback<String>>any());
|
||||
Mockito.verify(impl, Mockito.times(2)).getForUpdateCAS(ArgumentMatchers.eq("bar"), ArgumentMatchers.any());
|
||||
Mockito.verify(impl, Mockito.times(2)).getStorageObject("stuff");
|
||||
Mockito.verify(impl, Mockito.times(2)).updateCAS(
|
||||
ArgumentMatchers.eq("bar"), ArgumentMatchers.eq("stuff"), ArgumentMatchers.<byte[]>any(), ArgumentMatchers.<FutureCallback<Boolean>>any());
|
||||
ArgumentMatchers.eq("bar"), ArgumentMatchers.eq("stuff"), ArgumentMatchers.any(), ArgumentMatchers.any());
|
||||
Mockito.verify(operationCallback).completed(Boolean.TRUE);
|
||||
}
|
||||
|
||||
@ -318,7 +318,7 @@ public void testCacheUpdateFail() throws Exception {
|
||||
final HttpCacheEntry updatedValue = HttpTestUtils.makeCacheEntry();
|
||||
|
||||
Mockito.when(impl.digestToStorageKey(key)).thenReturn("bar");
|
||||
Mockito.when(impl.getForUpdateCAS(ArgumentMatchers.eq("bar"), ArgumentMatchers.<FutureCallback<String>>any())).thenAnswer(
|
||||
Mockito.when(impl.getForUpdateCAS(ArgumentMatchers.eq("bar"), ArgumentMatchers.any())).thenAnswer(
|
||||
(Answer<Cancellable>) invocation -> {
|
||||
final FutureCallback<String> callback = invocation.getArgument(1);
|
||||
callback.completed("stuff");
|
||||
@ -329,8 +329,8 @@ public void testCacheUpdateFail() throws Exception {
|
||||
Mockito.when(impl.updateCAS(
|
||||
ArgumentMatchers.eq("bar"),
|
||||
ArgumentMatchers.eq("stuff"),
|
||||
ArgumentMatchers.<byte[]>any(),
|
||||
ArgumentMatchers.<FutureCallback<Boolean>>any())).thenAnswer((Answer<Cancellable>) invocation -> {
|
||||
ArgumentMatchers.any(),
|
||||
ArgumentMatchers.any())).thenAnswer((Answer<Cancellable>) invocation -> {
|
||||
final FutureCallback<Boolean> callback = invocation.getArgument(3);
|
||||
if (count.incrementAndGet() <= 3) {
|
||||
callback.completed(false);
|
||||
@ -342,10 +342,10 @@ public void testCacheUpdateFail() throws Exception {
|
||||
|
||||
impl.updateEntry(key, existing -> updatedValue, operationCallback);
|
||||
|
||||
Mockito.verify(impl, Mockito.times(3)).getForUpdateCAS(ArgumentMatchers.eq("bar"), ArgumentMatchers.<FutureCallback<String>>any());
|
||||
Mockito.verify(impl, Mockito.times(3)).getForUpdateCAS(ArgumentMatchers.eq("bar"), ArgumentMatchers.any());
|
||||
Mockito.verify(impl, Mockito.times(3)).getStorageObject("stuff");
|
||||
Mockito.verify(impl, Mockito.times(3)).updateCAS(
|
||||
ArgumentMatchers.eq("bar"), ArgumentMatchers.eq("stuff"), ArgumentMatchers.<byte[]>any(), ArgumentMatchers.<FutureCallback<Boolean>>any());
|
||||
ArgumentMatchers.eq("bar"), ArgumentMatchers.eq("stuff"), ArgumentMatchers.any(), ArgumentMatchers.any());
|
||||
Mockito.verify(operationCallback).failed(ArgumentMatchers.<HttpCacheUpdateException>any());
|
||||
}
|
||||
|
||||
@ -363,8 +363,8 @@ public void testBulkGet() throws Exception {
|
||||
when(impl.digestToStorageKey(key2)).thenReturn(storageKey2);
|
||||
|
||||
when(impl.bulkRestore(
|
||||
ArgumentMatchers.<String>anyCollection(),
|
||||
ArgumentMatchers.<FutureCallback<Map<String, byte[]>>>any())).thenAnswer((Answer<Cancellable>) invocation -> {
|
||||
ArgumentMatchers.anyCollection(),
|
||||
ArgumentMatchers.any())).thenAnswer((Answer<Cancellable>) invocation -> {
|
||||
final Collection<String> keys = invocation.getArgument(0);
|
||||
final FutureCallback<Map<String, byte[]>> callback = invocation.getArgument(1);
|
||||
final Map<String, byte[]> resultMap = new HashMap<>();
|
||||
@ -391,7 +391,7 @@ public void testBulkGet() throws Exception {
|
||||
verify(impl, Mockito.times(2)).digestToStorageKey(key2);
|
||||
verify(impl).bulkRestore(
|
||||
ArgumentMatchers.eq(Arrays.asList(storageKey1, storageKey2)),
|
||||
ArgumentMatchers.<FutureCallback<Map<String, byte[]>>>any());
|
||||
ArgumentMatchers.any());
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -408,8 +408,8 @@ public void testBulkGetKeyMismatch() throws Exception {
|
||||
when(impl.digestToStorageKey(key2)).thenReturn(storageKey2);
|
||||
|
||||
when(impl.bulkRestore(
|
||||
ArgumentMatchers.<String>anyCollection(),
|
||||
ArgumentMatchers.<FutureCallback<Map<String, byte[]>>>any())).thenAnswer((Answer<Cancellable>) invocation -> {
|
||||
ArgumentMatchers.anyCollection(),
|
||||
ArgumentMatchers.any())).thenAnswer((Answer<Cancellable>) invocation -> {
|
||||
final Collection<String> keys = invocation.getArgument(0);
|
||||
final FutureCallback<Map<String, byte[]>> callback = invocation.getArgument(1);
|
||||
final Map<String, byte[]> resultMap = new HashMap<>();
|
||||
@ -436,7 +436,7 @@ public void testBulkGetKeyMismatch() throws Exception {
|
||||
verify(impl, Mockito.times(2)).digestToStorageKey(key2);
|
||||
verify(impl).bulkRestore(
|
||||
ArgumentMatchers.eq(Arrays.asList(storageKey1, storageKey2)),
|
||||
ArgumentMatchers.<FutureCallback<Map<String, byte[]>>>any());
|
||||
ArgumentMatchers.any());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -147,7 +147,7 @@ public void testCacheUpdateNullEntry() throws Exception {
|
||||
});
|
||||
|
||||
verify(impl).getForUpdateCAS("bar");
|
||||
verify(impl).store(ArgumentMatchers.eq("bar"), ArgumentMatchers.<byte[]>any());
|
||||
verify(impl).store(ArgumentMatchers.eq("bar"), ArgumentMatchers.any());
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -159,13 +159,13 @@ public void testCacheCASUpdate() throws Exception {
|
||||
when(impl.digestToStorageKey(key)).thenReturn("bar");
|
||||
when(impl.getForUpdateCAS("bar")).thenReturn("stuff");
|
||||
when(impl.getStorageObject("stuff")).thenReturn(serialize(key, existingValue));
|
||||
when(impl.updateCAS(ArgumentMatchers.eq("bar"), ArgumentMatchers.eq("stuff"), ArgumentMatchers.<byte[]>any())).thenReturn(true);
|
||||
when(impl.updateCAS(ArgumentMatchers.eq("bar"), ArgumentMatchers.eq("stuff"), ArgumentMatchers.any())).thenReturn(true);
|
||||
|
||||
impl.updateEntry(key, existing -> updatedValue);
|
||||
|
||||
verify(impl).getForUpdateCAS("bar");
|
||||
verify(impl).getStorageObject("stuff");
|
||||
verify(impl).updateCAS(ArgumentMatchers.eq("bar"), ArgumentMatchers.eq("stuff"), ArgumentMatchers.<byte[]>any());
|
||||
verify(impl).updateCAS(ArgumentMatchers.eq("bar"), ArgumentMatchers.eq("stuff"), ArgumentMatchers.any());
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -177,7 +177,7 @@ public void testCacheCASUpdateKeyMismatch() throws Exception {
|
||||
when(impl.digestToStorageKey(key)).thenReturn("bar");
|
||||
when(impl.getForUpdateCAS("bar")).thenReturn("stuff");
|
||||
when(impl.getStorageObject("stuff")).thenReturn(serialize("not-foo", existingValue));
|
||||
when(impl.updateCAS(ArgumentMatchers.eq("bar"), ArgumentMatchers.eq("stuff"), ArgumentMatchers.<byte[]>any())).thenReturn(true);
|
||||
when(impl.updateCAS(ArgumentMatchers.eq("bar"), ArgumentMatchers.eq("stuff"), ArgumentMatchers.any())).thenReturn(true);
|
||||
|
||||
impl.updateEntry(key, existing -> {
|
||||
Assert.assertThat(existing, CoreMatchers.nullValue());
|
||||
@ -186,7 +186,7 @@ public void testCacheCASUpdateKeyMismatch() throws Exception {
|
||||
|
||||
verify(impl).getForUpdateCAS("bar");
|
||||
verify(impl).getStorageObject("stuff");
|
||||
verify(impl).store(ArgumentMatchers.eq("bar"), ArgumentMatchers.<byte[]>any());
|
||||
verify(impl).store(ArgumentMatchers.eq("bar"), ArgumentMatchers.any());
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -198,13 +198,13 @@ public void testSingleCacheUpdateRetry() throws Exception {
|
||||
when(impl.digestToStorageKey(key)).thenReturn("bar");
|
||||
when(impl.getForUpdateCAS("bar")).thenReturn("stuff");
|
||||
when(impl.getStorageObject("stuff")).thenReturn(serialize(key, existingValue));
|
||||
when(impl.updateCAS(ArgumentMatchers.eq("bar"), ArgumentMatchers.eq("stuff"), ArgumentMatchers.<byte[]>any())).thenReturn(false, true);
|
||||
when(impl.updateCAS(ArgumentMatchers.eq("bar"), ArgumentMatchers.eq("stuff"), ArgumentMatchers.any())).thenReturn(false, true);
|
||||
|
||||
impl.updateEntry(key, existing -> updatedValue);
|
||||
|
||||
verify(impl, Mockito.times(2)).getForUpdateCAS("bar");
|
||||
verify(impl, Mockito.times(2)).getStorageObject("stuff");
|
||||
verify(impl, Mockito.times(2)).updateCAS(ArgumentMatchers.eq("bar"), ArgumentMatchers.eq("stuff"), ArgumentMatchers.<byte[]>any());
|
||||
verify(impl, Mockito.times(2)).updateCAS(ArgumentMatchers.eq("bar"), ArgumentMatchers.eq("stuff"), ArgumentMatchers.any());
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -216,7 +216,7 @@ public void testCacheUpdateFail() throws Exception {
|
||||
when(impl.digestToStorageKey(key)).thenReturn("bar");
|
||||
when(impl.getForUpdateCAS("bar")).thenReturn("stuff");
|
||||
when(impl.getStorageObject("stuff")).thenReturn(serialize(key, existingValue));
|
||||
when(impl.updateCAS(ArgumentMatchers.eq("bar"), ArgumentMatchers.eq("stuff"), ArgumentMatchers.<byte[]>any())).thenReturn(false, false, false, true);
|
||||
when(impl.updateCAS(ArgumentMatchers.eq("bar"), ArgumentMatchers.eq("stuff"), ArgumentMatchers.any())).thenReturn(false, false, false, true);
|
||||
|
||||
try {
|
||||
impl.updateEntry(key, existing -> updatedValue);
|
||||
@ -226,7 +226,7 @@ public void testCacheUpdateFail() throws Exception {
|
||||
|
||||
verify(impl, Mockito.times(3)).getForUpdateCAS("bar");
|
||||
verify(impl, Mockito.times(3)).getStorageObject("stuff");
|
||||
verify(impl, Mockito.times(3)).updateCAS(ArgumentMatchers.eq("bar"), ArgumentMatchers.eq("stuff"), ArgumentMatchers.<byte[]>any());
|
||||
verify(impl, Mockito.times(3)).updateCAS(ArgumentMatchers.eq("bar"), ArgumentMatchers.eq("stuff"), ArgumentMatchers.any());
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -241,7 +241,7 @@ public void testBulkGet() throws Exception {
|
||||
when(impl.digestToStorageKey(key1)).thenReturn(storageKey1);
|
||||
when(impl.digestToStorageKey(key2)).thenReturn(storageKey2);
|
||||
|
||||
when(impl.bulkRestore(ArgumentMatchers.<String>anyCollection())).thenAnswer((Answer<Map<String, byte[]>>) invocation -> {
|
||||
when(impl.bulkRestore(ArgumentMatchers.anyCollection())).thenAnswer((Answer<Map<String, byte[]>>) invocation -> {
|
||||
final Collection<String> keys = invocation.getArgument(0);
|
||||
final Map<String, byte[]> resultMap = new HashMap<>();
|
||||
if (keys.contains(storageKey1)) {
|
||||
@ -275,7 +275,7 @@ public void testBulkGetKeyMismatch() throws Exception {
|
||||
when(impl.digestToStorageKey(key1)).thenReturn(storageKey1);
|
||||
when(impl.digestToStorageKey(key2)).thenReturn(storageKey2);
|
||||
|
||||
when(impl.bulkRestore(ArgumentMatchers.<String>anyCollection())).thenAnswer((Answer<Map<String, byte[]>>) invocation -> {
|
||||
when(impl.bulkRestore(ArgumentMatchers.anyCollection())).thenAnswer((Answer<Map<String, byte[]>>) invocation -> {
|
||||
final Collection<String> keys = invocation.getArgument(0);
|
||||
final Map<String, byte[]> resultMap = new HashMap<>();
|
||||
if (keys.contains(storageKey1)) {
|
||||
|
@ -87,7 +87,7 @@ public void testMarkCompleteRemovesIdentifier() {
|
||||
impl.scheduleRevalidation(cacheKey, mockOperation);
|
||||
|
||||
verify(mockSchedulingStrategy).schedule(0);
|
||||
verify(mockScheduledExecutor).schedule(ArgumentMatchers.<Runnable>any(), ArgumentMatchers.eq(TimeValue.ofSeconds(3)));
|
||||
verify(mockScheduledExecutor).schedule(ArgumentMatchers.any(), ArgumentMatchers.eq(TimeValue.ofSeconds(3)));
|
||||
|
||||
Assert.assertEquals(1, impl.getScheduledIdentifiers().size());
|
||||
Assert.assertTrue(impl.getScheduledIdentifiers().contains(cacheKey));
|
||||
@ -100,13 +100,13 @@ public void testMarkCompleteRemovesIdentifier() {
|
||||
@Test
|
||||
public void testRevalidateCacheEntryDoesNotPopulateIdentifierOnRejectedExecutionException() {
|
||||
when(mockSchedulingStrategy.schedule(ArgumentMatchers.anyInt())).thenReturn(TimeValue.ofSeconds(2));
|
||||
doThrow(new RejectedExecutionException()).when(mockScheduledExecutor).schedule(ArgumentMatchers.<Runnable>any(), ArgumentMatchers.<TimeValue>any());
|
||||
doThrow(new RejectedExecutionException()).when(mockScheduledExecutor).schedule(ArgumentMatchers.any(), ArgumentMatchers.any());
|
||||
|
||||
final String cacheKey = "blah";
|
||||
impl.scheduleRevalidation(cacheKey, mockOperation);
|
||||
|
||||
Assert.assertEquals(0, impl.getScheduledIdentifiers().size());
|
||||
verify(mockScheduledExecutor).schedule(ArgumentMatchers.<Runnable>any(), ArgumentMatchers.eq(TimeValue.ofSeconds(2)));
|
||||
verify(mockScheduledExecutor).schedule(ArgumentMatchers.any(), ArgumentMatchers.eq(TimeValue.ofSeconds(2)));
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -119,7 +119,7 @@ public void testRevalidateCacheEntryProperlyCollapsesRequest() {
|
||||
impl.scheduleRevalidation(cacheKey, mockOperation);
|
||||
|
||||
verify(mockSchedulingStrategy).schedule(ArgumentMatchers.anyInt());
|
||||
verify(mockScheduledExecutor).schedule(ArgumentMatchers.<Runnable>any(), ArgumentMatchers.eq(TimeValue.ofSeconds(2)));
|
||||
verify(mockScheduledExecutor).schedule(ArgumentMatchers.any(), ArgumentMatchers.eq(TimeValue.ofSeconds(2)));
|
||||
|
||||
Assert.assertEquals(1, impl.getScheduledIdentifiers().size());
|
||||
}
|
||||
|
@ -82,7 +82,7 @@ public void setUp() {
|
||||
now = new Date();
|
||||
tenSecondsAgo = new Date(now.getTime() - 10 * 1000L);
|
||||
|
||||
when(cacheKeyResolver.resolve(ArgumentMatchers.<URI>any())).thenAnswer((Answer<String>) invocation -> {
|
||||
when(cacheKeyResolver.resolve(ArgumentMatchers.any())).thenAnswer((Answer<String>) invocation -> {
|
||||
final URI uri = invocation.getArgument(0);
|
||||
return HttpCacheSupport.normalize(uri).toASCIIString();
|
||||
});
|
||||
@ -104,8 +104,8 @@ public void testInvalidatesRequestsThatArentGETorHEAD() throws Exception {
|
||||
impl.flushCacheEntriesInvalidatedByRequest(host, request, cacheKeyResolver, mockStorage, operationCallback);
|
||||
|
||||
verify(mockEntry).getVariantMap();
|
||||
verify(mockStorage).getEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<HttpCacheEntry>>any());
|
||||
verify(mockStorage).removeEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<Boolean>>any());
|
||||
verify(mockStorage).getEntry(ArgumentMatchers.eq(key), ArgumentMatchers.any());
|
||||
verify(mockStorage).removeEntry(ArgumentMatchers.eq(key), ArgumentMatchers.any());
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -125,9 +125,9 @@ public void testInvalidatesUrisInContentLocationHeadersOnPUTs() throws Exception
|
||||
impl.flushCacheEntriesInvalidatedByRequest(host, request, cacheKeyResolver, mockStorage, operationCallback);
|
||||
|
||||
verify(mockEntry).getVariantMap();
|
||||
verify(mockStorage).getEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<HttpCacheEntry>>any());
|
||||
verify(mockStorage).removeEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<Boolean>>any());
|
||||
verify(mockStorage).removeEntry(ArgumentMatchers.eq("http://foo.example.com:80/content"), ArgumentMatchers.<FutureCallback<Boolean>>any());
|
||||
verify(mockStorage).getEntry(ArgumentMatchers.eq(key), ArgumentMatchers.any());
|
||||
verify(mockStorage).removeEntry(ArgumentMatchers.eq(key), ArgumentMatchers.any());
|
||||
verify(mockStorage).removeEntry(ArgumentMatchers.eq("http://foo.example.com:80/content"), ArgumentMatchers.any());
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -147,9 +147,9 @@ public void testInvalidatesUrisInLocationHeadersOnPUTs() throws Exception {
|
||||
impl.flushCacheEntriesInvalidatedByRequest(host, request, cacheKeyResolver, mockStorage, operationCallback);
|
||||
|
||||
verify(mockEntry).getVariantMap();
|
||||
verify(mockStorage).getEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<HttpCacheEntry>>any());
|
||||
verify(mockStorage).removeEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<Boolean>>any());
|
||||
verify(mockStorage).removeEntry(ArgumentMatchers.eq("http://foo.example.com:80/content"), ArgumentMatchers.<FutureCallback<Boolean>>any());
|
||||
verify(mockStorage).getEntry(ArgumentMatchers.eq(key), ArgumentMatchers.any());
|
||||
verify(mockStorage).removeEntry(ArgumentMatchers.eq(key), ArgumentMatchers.any());
|
||||
verify(mockStorage).removeEntry(ArgumentMatchers.eq("http://foo.example.com:80/content"), ArgumentMatchers.any());
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -169,9 +169,9 @@ public void testInvalidatesRelativeUrisInContentLocationHeadersOnPUTs() throws E
|
||||
impl.flushCacheEntriesInvalidatedByRequest(host, request, cacheKeyResolver, mockStorage, operationCallback);
|
||||
|
||||
verify(mockEntry).getVariantMap();
|
||||
verify(mockStorage).getEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<HttpCacheEntry>>any());
|
||||
verify(mockStorage).removeEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<Boolean>>any());
|
||||
verify(mockStorage).removeEntry(ArgumentMatchers.eq("http://foo.example.com:80/content"), ArgumentMatchers.<FutureCallback<Boolean>>any());
|
||||
verify(mockStorage).getEntry(ArgumentMatchers.eq(key), ArgumentMatchers.any());
|
||||
verify(mockStorage).removeEntry(ArgumentMatchers.eq(key), ArgumentMatchers.any());
|
||||
verify(mockStorage).removeEntry(ArgumentMatchers.eq("http://foo.example.com:80/content"), ArgumentMatchers.any());
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -191,8 +191,8 @@ public void testDoesNotInvalidateUrisInContentLocationHeadersOnPUTsToDifferentHo
|
||||
impl.flushCacheEntriesInvalidatedByRequest(host, request, cacheKeyResolver, mockStorage, operationCallback);
|
||||
|
||||
verify(mockEntry).getVariantMap();
|
||||
verify(mockStorage).getEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<HttpCacheEntry>>any());
|
||||
verify(mockStorage).removeEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<Boolean>>any());
|
||||
verify(mockStorage).getEntry(ArgumentMatchers.eq(key), ArgumentMatchers.any());
|
||||
verify(mockStorage).removeEntry(ArgumentMatchers.eq(key), ArgumentMatchers.any());
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -200,7 +200,7 @@ public void testDoesNotInvalidateGETRequest() throws Exception {
|
||||
final HttpRequest request = new BasicHttpRequest("GET","/");
|
||||
impl.flushCacheEntriesInvalidatedByRequest(host, request, cacheKeyResolver, mockStorage, operationCallback);
|
||||
|
||||
verify(mockStorage).getEntry(ArgumentMatchers.eq("http://foo.example.com:80/"), ArgumentMatchers.<FutureCallback<HttpCacheEntry>>any());
|
||||
verify(mockStorage).getEntry(ArgumentMatchers.eq("http://foo.example.com:80/"), ArgumentMatchers.any());
|
||||
verifyNoMoreInteractions(mockStorage);
|
||||
}
|
||||
|
||||
@ -209,7 +209,7 @@ public void testDoesNotInvalidateHEADRequest() throws Exception {
|
||||
final HttpRequest request = new BasicHttpRequest("HEAD","/");
|
||||
impl.flushCacheEntriesInvalidatedByRequest(host, request, cacheKeyResolver, mockStorage, operationCallback);
|
||||
|
||||
verify(mockStorage).getEntry(ArgumentMatchers.eq("http://foo.example.com:80/"), ArgumentMatchers.<FutureCallback<HttpCacheEntry>>any());
|
||||
verify(mockStorage).getEntry(ArgumentMatchers.eq("http://foo.example.com:80/"), ArgumentMatchers.any());
|
||||
verifyNoMoreInteractions(mockStorage);
|
||||
}
|
||||
|
||||
@ -227,8 +227,8 @@ public void testInvalidatesHEADCacheEntryIfSubsequentGETRequestsAreMadeToTheSame
|
||||
|
||||
verify(mockEntry).getRequestMethod();
|
||||
verify(mockEntry).getVariantMap();
|
||||
verify(mockStorage).getEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<HttpCacheEntry>>any());
|
||||
verify(mockStorage).removeEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<Boolean>>any());
|
||||
verify(mockStorage).getEntry(ArgumentMatchers.eq(key), ArgumentMatchers.any());
|
||||
verify(mockStorage).removeEntry(ArgumentMatchers.eq(key), ArgumentMatchers.any());
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -248,9 +248,9 @@ public void testInvalidatesVariantHEADCacheEntriesIfSubsequentGETRequestsAreMade
|
||||
|
||||
verify(mockEntry).getRequestMethod();
|
||||
verify(mockEntry).getVariantMap();
|
||||
verify(mockStorage).getEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<HttpCacheEntry>>any());
|
||||
verify(mockStorage).removeEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<Boolean>>any());
|
||||
verify(mockStorage).removeEntry(ArgumentMatchers.eq(theVariantURI), ArgumentMatchers.<FutureCallback<Boolean>>any());
|
||||
verify(mockStorage).getEntry(ArgumentMatchers.eq(key), ArgumentMatchers.any());
|
||||
verify(mockStorage).removeEntry(ArgumentMatchers.eq(key), ArgumentMatchers.any());
|
||||
verify(mockStorage).removeEntry(ArgumentMatchers.eq(theVariantURI), ArgumentMatchers.any());
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -263,7 +263,7 @@ public void testDoesNotInvalidateHEADCacheEntry() throws Exception {
|
||||
|
||||
impl.flushCacheEntriesInvalidatedByRequest(host, request, cacheKeyResolver, mockStorage, operationCallback);
|
||||
|
||||
verify(mockStorage).getEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<HttpCacheEntry>>any());
|
||||
verify(mockStorage).getEntry(ArgumentMatchers.eq(key), ArgumentMatchers.any());
|
||||
verifyNoMoreInteractions(mockStorage);
|
||||
}
|
||||
|
||||
@ -277,7 +277,7 @@ public void testDoesNotInvalidateHEADCacheEntryIfSubsequentHEADRequestsAreMadeTo
|
||||
|
||||
impl.flushCacheEntriesInvalidatedByRequest(host, request, cacheKeyResolver, mockStorage, operationCallback);
|
||||
|
||||
verify(mockStorage).getEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<HttpCacheEntry>>any());
|
||||
verify(mockStorage).getEntry(ArgumentMatchers.eq(key), ArgumentMatchers.any());
|
||||
verifyNoMoreInteractions(mockStorage);
|
||||
}
|
||||
|
||||
@ -293,7 +293,7 @@ public void testDoesNotInvalidateGETCacheEntryIfSubsequentGETRequestsAreMadeToTh
|
||||
impl.flushCacheEntriesInvalidatedByRequest(host, request, cacheKeyResolver, mockStorage, operationCallback);
|
||||
|
||||
verify(mockEntry).getRequestMethod();
|
||||
verify(mockStorage).getEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<HttpCacheEntry>>any());
|
||||
verify(mockStorage).getEntry(ArgumentMatchers.eq(key), ArgumentMatchers.any());
|
||||
verifyNoMoreInteractions(mockStorage);
|
||||
}
|
||||
|
||||
@ -304,7 +304,7 @@ public void testDoesNotInvalidateRequestsWithClientCacheControlHeaders() throws
|
||||
|
||||
impl.flushCacheEntriesInvalidatedByRequest(host, request, cacheKeyResolver, mockStorage, operationCallback);
|
||||
|
||||
verify(mockStorage).getEntry(ArgumentMatchers.eq("http://foo.example.com:80/"), ArgumentMatchers.<FutureCallback<HttpCacheEntry>>any());
|
||||
verify(mockStorage).getEntry(ArgumentMatchers.eq("http://foo.example.com:80/"), ArgumentMatchers.any());
|
||||
verifyNoMoreInteractions(mockStorage);
|
||||
}
|
||||
|
||||
@ -315,7 +315,7 @@ public void testDoesNotInvalidateRequestsWithClientPragmaHeaders() throws Except
|
||||
|
||||
impl.flushCacheEntriesInvalidatedByRequest(host, request, cacheKeyResolver, mockStorage, operationCallback);
|
||||
|
||||
verify(mockStorage).getEntry(ArgumentMatchers.eq("http://foo.example.com:80/"), ArgumentMatchers.<FutureCallback<HttpCacheEntry>>any());
|
||||
verify(mockStorage).getEntry(ArgumentMatchers.eq("http://foo.example.com:80/"), ArgumentMatchers.any());
|
||||
verifyNoMoreInteractions(mockStorage);
|
||||
}
|
||||
|
||||
@ -332,10 +332,10 @@ public void testVariantURIsAreFlushedAlso() throws Exception {
|
||||
|
||||
impl.flushCacheEntriesInvalidatedByRequest(host, request, cacheKeyResolver, mockStorage, operationCallback);
|
||||
|
||||
verify(mockStorage).getEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<HttpCacheEntry>>any());
|
||||
verify(mockStorage).getEntry(ArgumentMatchers.eq(key), ArgumentMatchers.any());
|
||||
verify(mockEntry).getVariantMap();
|
||||
verify(mockStorage).removeEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<Boolean>>any());
|
||||
verify(mockStorage).removeEntry(ArgumentMatchers.eq(variantUri), ArgumentMatchers.<FutureCallback<Boolean>>any());
|
||||
verify(mockStorage).removeEntry(ArgumentMatchers.eq(key), ArgumentMatchers.any());
|
||||
verify(mockStorage).removeEntry(ArgumentMatchers.eq(variantUri), ArgumentMatchers.any());
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -365,8 +365,8 @@ public void flushesEntryIfFresherAndSpecifiedByContentLocation() throws Exceptio
|
||||
|
||||
impl.flushCacheEntriesInvalidatedByExchange(host, request, response, cacheKeyResolver, mockStorage, operationCallback);
|
||||
|
||||
verify(mockStorage).getEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<HttpCacheEntry>>any());
|
||||
verify(mockStorage).removeEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<Boolean>>any());
|
||||
verify(mockStorage).getEntry(ArgumentMatchers.eq(key), ArgumentMatchers.any());
|
||||
verify(mockStorage).removeEntry(ArgumentMatchers.eq(key), ArgumentMatchers.any());
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -387,8 +387,8 @@ public void flushesEntryIfFresherAndSpecifiedByLocation() throws Exception {
|
||||
|
||||
impl.flushCacheEntriesInvalidatedByExchange(host, request, response, cacheKeyResolver, mockStorage, operationCallback);
|
||||
|
||||
verify(mockStorage).getEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<HttpCacheEntry>>any());
|
||||
verify(mockStorage).removeEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<Boolean>>any());
|
||||
verify(mockStorage).getEntry(ArgumentMatchers.eq(key), ArgumentMatchers.any());
|
||||
verify(mockStorage).removeEntry(ArgumentMatchers.eq(key), ArgumentMatchers.any());
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -423,8 +423,8 @@ public void flushesEntryIfFresherAndSpecifiedByNonCanonicalContentLocation() thr
|
||||
|
||||
impl.flushCacheEntriesInvalidatedByExchange(host, request, response, cacheKeyResolver, mockStorage, operationCallback);
|
||||
|
||||
verify(mockStorage).getEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<HttpCacheEntry>>any());
|
||||
verify(mockStorage).removeEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<Boolean>>any());
|
||||
verify(mockStorage).getEntry(ArgumentMatchers.eq(key), ArgumentMatchers.any());
|
||||
verify(mockStorage).removeEntry(ArgumentMatchers.eq(key), ArgumentMatchers.any());
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -445,8 +445,8 @@ public void flushesEntryIfFresherAndSpecifiedByRelativeContentLocation() throws
|
||||
|
||||
impl.flushCacheEntriesInvalidatedByExchange(host, request, response, cacheKeyResolver, mockStorage, operationCallback);
|
||||
|
||||
verify(mockStorage).getEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<HttpCacheEntry>>any());
|
||||
verify(mockStorage).removeEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<Boolean>>any());
|
||||
verify(mockStorage).getEntry(ArgumentMatchers.eq(key), ArgumentMatchers.any());
|
||||
verify(mockStorage).removeEntry(ArgumentMatchers.eq(key), ArgumentMatchers.any());
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -487,7 +487,7 @@ public void doesNotFlushEntrySpecifiedByContentLocationIfEtagsMatch() throws Exc
|
||||
cacheReturnsEntryForUri(key, entry);
|
||||
impl.flushCacheEntriesInvalidatedByExchange(host, request, response, cacheKeyResolver, mockStorage, operationCallback);
|
||||
|
||||
verify(mockStorage).getEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<HttpCacheEntry>>any());
|
||||
verify(mockStorage).getEntry(ArgumentMatchers.eq(key), ArgumentMatchers.any());
|
||||
verifyNoMoreInteractions(mockStorage);
|
||||
}
|
||||
|
||||
@ -509,7 +509,7 @@ public void doesNotFlushEntrySpecifiedByContentLocationIfOlder() throws Exceptio
|
||||
|
||||
impl.flushCacheEntriesInvalidatedByExchange(host, request, response, cacheKeyResolver, mockStorage, operationCallback);
|
||||
|
||||
verify(mockStorage).getEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<HttpCacheEntry>>any());
|
||||
verify(mockStorage).getEntry(ArgumentMatchers.eq(key), ArgumentMatchers.any());
|
||||
verifyNoMoreInteractions(mockStorage);
|
||||
}
|
||||
|
||||
@ -526,7 +526,7 @@ public void doesNotFlushEntryIfNotInCache() throws Exception {
|
||||
|
||||
impl.flushCacheEntriesInvalidatedByExchange(host, request, response, cacheKeyResolver, mockStorage, operationCallback);
|
||||
|
||||
verify(mockStorage).getEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<HttpCacheEntry>>any());
|
||||
verify(mockStorage).getEntry(ArgumentMatchers.eq(key), ArgumentMatchers.any());
|
||||
verifyNoMoreInteractions(mockStorage);
|
||||
}
|
||||
|
||||
@ -548,7 +548,7 @@ public void doesNotFlushEntrySpecifiedByContentLocationIfResponseHasNoEtag() thr
|
||||
|
||||
impl.flushCacheEntriesInvalidatedByExchange(host, request, response, cacheKeyResolver, mockStorage, operationCallback);
|
||||
|
||||
verify(mockStorage).getEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<HttpCacheEntry>>any());
|
||||
verify(mockStorage).getEntry(ArgumentMatchers.eq(key), ArgumentMatchers.any());
|
||||
verifyNoMoreInteractions(mockStorage);
|
||||
}
|
||||
|
||||
@ -569,7 +569,7 @@ public void doesNotFlushEntrySpecifiedByContentLocationIfEntryHasNoEtag() throws
|
||||
|
||||
impl.flushCacheEntriesInvalidatedByExchange(host, request, response, cacheKeyResolver, mockStorage, operationCallback);
|
||||
|
||||
verify(mockStorage).getEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<HttpCacheEntry>>any());
|
||||
verify(mockStorage).getEntry(ArgumentMatchers.eq(key), ArgumentMatchers.any());
|
||||
verifyNoMoreInteractions(mockStorage);
|
||||
}
|
||||
|
||||
@ -591,8 +591,8 @@ public void flushesEntrySpecifiedByContentLocationIfResponseHasNoDate() throws E
|
||||
|
||||
impl.flushCacheEntriesInvalidatedByExchange(host, request, response, cacheKeyResolver, mockStorage, operationCallback);
|
||||
|
||||
verify(mockStorage).getEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<HttpCacheEntry>>any());
|
||||
verify(mockStorage).removeEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<Boolean>>any());
|
||||
verify(mockStorage).getEntry(ArgumentMatchers.eq(key), ArgumentMatchers.any());
|
||||
verify(mockStorage).removeEntry(ArgumentMatchers.eq(key), ArgumentMatchers.any());
|
||||
verifyNoMoreInteractions(mockStorage);
|
||||
}
|
||||
|
||||
@ -613,8 +613,8 @@ public void flushesEntrySpecifiedByContentLocationIfEntryHasNoDate() throws Exce
|
||||
|
||||
impl.flushCacheEntriesInvalidatedByExchange(host, request, response, cacheKeyResolver, mockStorage, operationCallback);
|
||||
|
||||
verify(mockStorage).getEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<HttpCacheEntry>>any());
|
||||
verify(mockStorage).removeEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<Boolean>>any());
|
||||
verify(mockStorage).getEntry(ArgumentMatchers.eq(key), ArgumentMatchers.any());
|
||||
verify(mockStorage).removeEntry(ArgumentMatchers.eq(key), ArgumentMatchers.any());
|
||||
verifyNoMoreInteractions(mockStorage);
|
||||
}
|
||||
|
||||
@ -636,8 +636,8 @@ public void flushesEntrySpecifiedByContentLocationIfResponseHasMalformedDate() t
|
||||
|
||||
impl.flushCacheEntriesInvalidatedByExchange(host, request, response, cacheKeyResolver, mockStorage, operationCallback);
|
||||
|
||||
verify(mockStorage).getEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<HttpCacheEntry>>any());
|
||||
verify(mockStorage).removeEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<Boolean>>any());
|
||||
verify(mockStorage).getEntry(ArgumentMatchers.eq(key), ArgumentMatchers.any());
|
||||
verify(mockStorage).removeEntry(ArgumentMatchers.eq(key), ArgumentMatchers.any());
|
||||
verifyNoMoreInteractions(mockStorage);
|
||||
}
|
||||
|
||||
@ -659,8 +659,8 @@ public void flushesEntrySpecifiedByContentLocationIfEntryHasMalformedDate() thro
|
||||
|
||||
impl.flushCacheEntriesInvalidatedByExchange(host, request, response, cacheKeyResolver, mockStorage, operationCallback);
|
||||
|
||||
verify(mockStorage).getEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<HttpCacheEntry>>any());
|
||||
verify(mockStorage).removeEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<Boolean>>any());
|
||||
verify(mockStorage).getEntry(ArgumentMatchers.eq(key), ArgumentMatchers.any());
|
||||
verify(mockStorage).removeEntry(ArgumentMatchers.eq(key), ArgumentMatchers.any());
|
||||
verifyNoMoreInteractions(mockStorage);
|
||||
}
|
||||
|
||||
@ -673,7 +673,7 @@ private void cacheEntryHasVariantMap(final Map<String,String> variantMap) {
|
||||
private void cacheReturnsEntryForUri(final String key, final HttpCacheEntry cacheEntry) {
|
||||
Mockito.when(mockStorage.getEntry(
|
||||
ArgumentMatchers.eq(key),
|
||||
ArgumentMatchers.<FutureCallback<HttpCacheEntry>>any())).thenAnswer((Answer<Cancellable>) invocation -> {
|
||||
ArgumentMatchers.any())).thenAnswer((Answer<Cancellable>) invocation -> {
|
||||
final FutureCallback<HttpCacheEntry> callback = invocation.getArgument(1);
|
||||
callback.completed(cacheEntry);
|
||||
return cancellable;
|
||||
|
@ -76,7 +76,7 @@ public void setUp() {
|
||||
now = new Date();
|
||||
tenSecondsAgo = new Date(now.getTime() - 10 * 1000L);
|
||||
|
||||
when(cacheKeyResolver.resolve(ArgumentMatchers.<URI>any())).thenAnswer((Answer<String>) invocation -> {
|
||||
when(cacheKeyResolver.resolve(ArgumentMatchers.any())).thenAnswer((Answer<String>) invocation -> {
|
||||
final URI uri = invocation.getArgument(0);
|
||||
return HttpCacheSupport.normalize(uri).toASCIIString();
|
||||
});
|
||||
|
@ -26,6 +26,11 @@
|
||||
*/
|
||||
package org.apache.hc.client5.testing.async;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import org.apache.hc.client5.http.async.methods.SimpleHttpResponse;
|
||||
import org.apache.hc.client5.http.async.methods.SimpleRequestBuilder;
|
||||
import org.apache.hc.client5.http.config.RequestConfig;
|
||||
@ -34,7 +39,6 @@
|
||||
import org.apache.hc.client5.http.impl.async.HttpAsyncClientBuilder;
|
||||
import org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManager;
|
||||
import org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManagerBuilder;
|
||||
import org.apache.hc.core5.function.Decorator;
|
||||
import org.apache.hc.core5.function.Resolver;
|
||||
import org.apache.hc.core5.http.HttpHost;
|
||||
import org.apache.hc.core5.http.HttpRequest;
|
||||
@ -42,7 +46,6 @@
|
||||
import org.apache.hc.core5.http.HttpVersion;
|
||||
import org.apache.hc.core5.http.URIScheme;
|
||||
import org.apache.hc.core5.http.config.Http1Config;
|
||||
import org.apache.hc.core5.http.nio.AsyncServerExchangeHandler;
|
||||
import org.apache.hc.core5.http2.HttpVersionPolicy;
|
||||
import org.apache.hc.core5.http2.config.H2Config;
|
||||
import org.apache.hc.core5.util.TimeValue;
|
||||
@ -54,11 +57,6 @@
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
@RunWith(Parameterized.class)
|
||||
public class TestHttp1RequestReExecution extends AbstractIntegrationTestBase<CloseableHttpAsyncClient> {
|
||||
|
||||
@ -131,23 +129,9 @@ public TimeValue resolve(final HttpRequest request) {
|
||||
};
|
||||
|
||||
if (version.greaterEquals(HttpVersion.HTTP_2)) {
|
||||
return super.start(null, new Decorator<AsyncServerExchangeHandler>() {
|
||||
|
||||
@Override
|
||||
public AsyncServerExchangeHandler decorate(final AsyncServerExchangeHandler handler) {
|
||||
return new ServiceUnavailableAsyncDecorator(handler, serviceAvailabilityResolver);
|
||||
}
|
||||
|
||||
}, H2Config.DEFAULT);
|
||||
return super.start(null, handler -> new ServiceUnavailableAsyncDecorator(handler, serviceAvailabilityResolver), H2Config.DEFAULT);
|
||||
} else {
|
||||
return super.start(null, new Decorator<AsyncServerExchangeHandler>() {
|
||||
|
||||
@Override
|
||||
public AsyncServerExchangeHandler decorate(final AsyncServerExchangeHandler handler) {
|
||||
return new ServiceUnavailableAsyncDecorator(handler, serviceAvailabilityResolver);
|
||||
}
|
||||
|
||||
}, Http1Config.DEFAULT);
|
||||
return super.start(null, handler -> new ServiceUnavailableAsyncDecorator(handler, serviceAvailabilityResolver), Http1Config.DEFAULT);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -35,8 +35,8 @@
|
||||
import org.apache.hc.client5.http.auth.AuthScope;
|
||||
import org.apache.hc.client5.http.auth.Credentials;
|
||||
import org.apache.hc.client5.http.auth.KerberosConfig;
|
||||
import org.apache.hc.client5.http.classic.methods.HttpGet;
|
||||
import org.apache.hc.client5.http.auth.StandardAuthScheme;
|
||||
import org.apache.hc.client5.http.classic.methods.HttpGet;
|
||||
import org.apache.hc.client5.http.impl.auth.BasicCredentialsProvider;
|
||||
import org.apache.hc.client5.http.impl.auth.SPNegoScheme;
|
||||
import org.apache.hc.client5.http.impl.classic.HttpClients;
|
||||
@ -53,10 +53,8 @@
|
||||
import org.apache.hc.core5.http.message.BasicHeader;
|
||||
import org.apache.hc.core5.http.protocol.HttpContext;
|
||||
import org.ietf.jgss.GSSContext;
|
||||
import org.ietf.jgss.GSSCredential;
|
||||
import org.ietf.jgss.GSSManager;
|
||||
import org.ietf.jgss.GSSName;
|
||||
import org.ietf.jgss.Oid;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.mockito.ArgumentMatchers;
|
||||
@ -98,14 +96,14 @@ private static class NegotiateSchemeWithMockGssManager extends SPNegoScheme {
|
||||
NegotiateSchemeWithMockGssManager() throws Exception {
|
||||
super(KerberosConfig.DEFAULT, SystemDefaultDnsResolver.INSTANCE);
|
||||
Mockito.when(context.initSecContext(
|
||||
ArgumentMatchers.<byte[]>any(), ArgumentMatchers.anyInt(), ArgumentMatchers.anyInt()))
|
||||
ArgumentMatchers.any(), ArgumentMatchers.anyInt(), ArgumentMatchers.anyInt()))
|
||||
.thenReturn("12345678".getBytes());
|
||||
Mockito.when(manager.createName(
|
||||
ArgumentMatchers.anyString(), ArgumentMatchers.<Oid>any()))
|
||||
ArgumentMatchers.anyString(), ArgumentMatchers.any()))
|
||||
.thenReturn(name);
|
||||
Mockito.when(manager.createContext(
|
||||
ArgumentMatchers.<GSSName>any(), ArgumentMatchers.<Oid>any(),
|
||||
ArgumentMatchers.<GSSCredential>any(), ArgumentMatchers.anyInt()))
|
||||
ArgumentMatchers.any(), ArgumentMatchers.any(),
|
||||
ArgumentMatchers.any(), ArgumentMatchers.anyInt()))
|
||||
.thenReturn(context);
|
||||
}
|
||||
|
||||
|
@ -141,8 +141,7 @@ public HttpRoute(final HttpHost target, final InetAddress local, final HttpHost
|
||||
* {@code false} otherwise
|
||||
*/
|
||||
public HttpRoute(final HttpHost target, final InetAddress local, final boolean secure) {
|
||||
this(target, local, Collections.<HttpHost>emptyList(), secure,
|
||||
TunnelType.PLAIN, LayerType.PLAIN);
|
||||
this(target, local, Collections.emptyList(), secure, TunnelType.PLAIN, LayerType.PLAIN);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -151,8 +150,7 @@ public HttpRoute(final HttpHost target, final InetAddress local, final boolean s
|
||||
* @param target the host to which to route
|
||||
*/
|
||||
public HttpRoute(final HttpHost target) {
|
||||
this(target, null, Collections.<HttpHost>emptyList(), false,
|
||||
TunnelType.PLAIN, LayerType.PLAIN);
|
||||
this(target, null, Collections.emptyList(), false, TunnelType.PLAIN, LayerType.PLAIN);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -58,7 +58,7 @@ public MimeField(final String name, final String value, final List<NameValuePair
|
||||
this.name = name;
|
||||
this.value = value;
|
||||
this.parameters = parameters != null ?
|
||||
Collections.unmodifiableList(new ArrayList<>(parameters)) : Collections.<NameValuePair>emptyList();
|
||||
Collections.unmodifiableList(new ArrayList<>(parameters)) : Collections.emptyList();
|
||||
}
|
||||
|
||||
public MimeField(final MimeField from) {
|
||||
|
@ -229,7 +229,7 @@ MultipartFormEntity buildEntity() {
|
||||
}
|
||||
}
|
||||
final List<MultipartPart> multipartPartsCopy = multipartParts != null ? new ArrayList<>(multipartParts) :
|
||||
Collections.<MultipartPart>emptyList();
|
||||
Collections.emptyList();
|
||||
final HttpMultipartMode modeCopy = mode != null ? mode : HttpMultipartMode.STRICT;
|
||||
final AbstractMultipartFormat form;
|
||||
switch (modeCopy) {
|
||||
|
@ -180,7 +180,7 @@ public final List<Cookie> parse(final Header header, final CookieOrigin origin)
|
||||
}
|
||||
}
|
||||
|
||||
return Collections.<Cookie>singletonList(cookie);
|
||||
return Collections.singletonList(cookie);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -56,7 +56,7 @@ public final class PublicSuffixList {
|
||||
public PublicSuffixList(final DomainType type, final List<String> rules, final List<String> exceptions) {
|
||||
this.type = Args.notNull(type, "Domain type");
|
||||
this.rules = Collections.unmodifiableList(Args.notNull(rules, "Domain suffix rules"));
|
||||
this.exceptions = Collections.unmodifiableList(exceptions != null ? exceptions : Collections.<String>emptyList());
|
||||
this.exceptions = Collections.unmodifiableList(exceptions != null ? exceptions : Collections.emptyList());
|
||||
}
|
||||
|
||||
public PublicSuffixList(final List<String> rules, final List<String> exceptions) {
|
||||
|
@ -71,7 +71,7 @@ public void testCompressionDecompression() throws Exception {
|
||||
@Test
|
||||
public void testCompressionIOExceptionLeavesOutputStreamOpen() throws Exception {
|
||||
final HttpEntity in = Mockito.mock(HttpEntity.class);
|
||||
Mockito.doThrow(new IOException("Ooopsie")).when(in).writeTo(ArgumentMatchers.<OutputStream>any());
|
||||
Mockito.doThrow(new IOException("Ooopsie")).when(in).writeTo(ArgumentMatchers.any());
|
||||
final GzipCompressingEntity gzipe = new GzipCompressingEntity(in);
|
||||
final OutputStream out = Mockito.mock(OutputStream.class);
|
||||
try {
|
||||
|
@ -65,7 +65,7 @@ public void testMultipartFormStringParts() throws Exception {
|
||||
"field3",
|
||||
new StringBody("all kind of stuff", ContentType.DEFAULT_TEXT)).build();
|
||||
final HttpStrictMultipart multipart = new HttpStrictMultipart(null, "foo",
|
||||
Arrays.<MultipartPart>asList(p1, p2, p3));
|
||||
Arrays.asList(p1, p2, p3));
|
||||
|
||||
final ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
multipart.writeTo(out);
|
||||
@ -102,7 +102,7 @@ public void testMultipartFormCustomContentType() throws Exception {
|
||||
"field2",
|
||||
new StringBody("that stuff", ContentType.parse("stuff/plain; param=value"))).build();
|
||||
final HttpStrictMultipart multipart = new HttpStrictMultipart(null, "foo",
|
||||
Arrays.<MultipartPart>asList(p1, p2));
|
||||
Arrays.asList(p1, p2));
|
||||
|
||||
final ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
multipart.writeTo(out);
|
||||
@ -140,7 +140,7 @@ public void testMultipartFormBinaryParts() throws Exception {
|
||||
"field2",
|
||||
new InputStreamBody(new FileInputStream(tmpfile), "file.tmp")).build();
|
||||
final HttpStrictMultipart multipart = new HttpStrictMultipart(null, "foo",
|
||||
Arrays.<MultipartPart>asList(p1, p2));
|
||||
Arrays.asList(p1, p2));
|
||||
|
||||
final ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
multipart.writeTo(out);
|
||||
@ -183,7 +183,7 @@ public void testMultipartFormStrict() throws Exception {
|
||||
"field3",
|
||||
new InputStreamBody(new FileInputStream(tmpfile), "file.tmp")).build();
|
||||
final HttpStrictMultipart multipart = new HttpStrictMultipart(null, "foo",
|
||||
Arrays.<MultipartPart>asList(p1, p2, p3));
|
||||
Arrays.asList(p1, p2, p3));
|
||||
|
||||
final ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
multipart.writeTo(out);
|
||||
@ -232,7 +232,7 @@ public void testMultipartFormRFC6532() throws Exception {
|
||||
"field3",
|
||||
new InputStreamBody(new FileInputStream(tmpfile), "file.tmp")).build();
|
||||
final HttpRFC6532Multipart multipart = new HttpRFC6532Multipart(null, "foo",
|
||||
Arrays.<MultipartPart>asList(p1, p2, p3));
|
||||
Arrays.asList(p1, p2, p3));
|
||||
|
||||
final ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
multipart.writeTo(out);
|
||||
@ -302,7 +302,7 @@ public void testMultipartFormBrowserCompatibleNonASCIIHeaders() throws Exception
|
||||
new InputStreamBody(new FileInputStream(tmpfile), s2 + ".tmp")).build();
|
||||
final LegacyMultipart multipart = new LegacyMultipart(
|
||||
StandardCharsets.UTF_8, "foo",
|
||||
Arrays.<MultipartPart>asList(p1, p2));
|
||||
Arrays.asList(p1, p2));
|
||||
|
||||
final ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
multipart.writeTo(out);
|
||||
@ -339,7 +339,7 @@ public void testMultipartFormStringPartsMultiCharsets() throws Exception {
|
||||
"field2",
|
||||
new StringBody(s2, ContentType.create("text/plain", Charset.forName("KOI8-R")))).build();
|
||||
final HttpStrictMultipart multipart = new HttpStrictMultipart(null, "foo",
|
||||
Arrays.<MultipartPart>asList(p1, p2));
|
||||
Arrays.asList(p1, p2));
|
||||
|
||||
final ByteArrayOutputStream out1 = new ByteArrayOutputStream();
|
||||
multipart.writeTo(out1);
|
||||
|
@ -62,7 +62,7 @@ public void testMultipartPartStringParts() throws Exception {
|
||||
final MultipartPart p3 = MultipartPartBuilder.create(
|
||||
new StringBody("all kind of stuff", ContentType.DEFAULT_TEXT)).build();
|
||||
final HttpStrictMultipart multipart = new HttpStrictMultipart(null, "foo",
|
||||
Arrays.<MultipartPart>asList(p1, p2, p3));
|
||||
Arrays.asList(p1, p2, p3));
|
||||
|
||||
final ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
multipart.writeTo(out);
|
||||
@ -94,7 +94,7 @@ public void testMultipartPartCustomContentType() throws Exception {
|
||||
final MultipartPart p2 = MultipartPartBuilder.create(
|
||||
new StringBody("that stuff", ContentType.parse("stuff/plain; param=value"))).build();
|
||||
final HttpStrictMultipart multipart = new HttpStrictMultipart(null, "foo",
|
||||
Arrays.<MultipartPart>asList(p1, p2));
|
||||
Arrays.asList(p1, p2));
|
||||
|
||||
final ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
multipart.writeTo(out);
|
||||
@ -128,7 +128,7 @@ public void testMultipartPartBinaryParts() throws Exception {
|
||||
final MultipartPart p2 = MultipartPartBuilder.create(
|
||||
new InputStreamBody(new FileInputStream(tmpfile), "file.tmp")).build();
|
||||
final HttpStrictMultipart multipart = new HttpStrictMultipart(null, "foo",
|
||||
Arrays.<MultipartPart>asList(p1, p2));
|
||||
Arrays.asList(p1, p2));
|
||||
|
||||
final ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
multipart.writeTo(out);
|
||||
@ -164,7 +164,7 @@ public void testMultipartPartStrict() throws Exception {
|
||||
final MultipartPart p3 = MultipartPartBuilder.create(
|
||||
new InputStreamBody(new FileInputStream(tmpfile), "file.tmp")).build();
|
||||
final HttpStrictMultipart multipart = new HttpStrictMultipart(null, "foo",
|
||||
Arrays.<MultipartPart>asList(p1, p2, p3));
|
||||
Arrays.asList(p1, p2, p3));
|
||||
|
||||
final ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
multipart.writeTo(out);
|
||||
@ -204,7 +204,7 @@ public void testMultipartPartRFC6532() throws Exception {
|
||||
final MultipartPart p3 = MultipartPartBuilder.create(
|
||||
new InputStreamBody(new FileInputStream(tmpfile), "file.tmp")).build();
|
||||
final HttpRFC6532Multipart multipart = new HttpRFC6532Multipart(null, "foo",
|
||||
Arrays.<MultipartPart>asList(p1, p2, p3));
|
||||
Arrays.asList(p1, p2, p3));
|
||||
|
||||
final ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
multipart.writeTo(out);
|
||||
@ -266,7 +266,7 @@ public void testMultipartPartBrowserCompatibleNonASCIIHeaders() throws Exception
|
||||
new InputStreamBody(new FileInputStream(tmpfile), s2 + ".tmp")).build();
|
||||
final LegacyMultipart multipart = new LegacyMultipart(
|
||||
StandardCharsets.UTF_8, "foo",
|
||||
Arrays.<MultipartPart>asList(p1, p2));
|
||||
Arrays.asList(p1, p2));
|
||||
|
||||
final ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
multipart.writeTo(out);
|
||||
@ -297,7 +297,7 @@ public void testMultipartPartStringPartsMultiCharsets() throws Exception {
|
||||
final MultipartPart p2 = MultipartPartBuilder.create(
|
||||
new StringBody(s2, ContentType.create("text/plain", Charset.forName("KOI8-R")))).build();
|
||||
final HttpStrictMultipart multipart = new HttpStrictMultipart(null, "foo",
|
||||
Arrays.<MultipartPart>asList(p1, p2));
|
||||
Arrays.asList(p1, p2));
|
||||
|
||||
final ByteArrayOutputStream out1 = new ByteArrayOutputStream();
|
||||
multipart.writeTo(out1);
|
||||
|
@ -37,8 +37,8 @@
|
||||
import org.apache.hc.client5.http.auth.AuthSchemeFactory;
|
||||
import org.apache.hc.client5.http.auth.AuthScope;
|
||||
import org.apache.hc.client5.http.auth.ChallengeType;
|
||||
import org.apache.hc.client5.http.auth.UsernamePasswordCredentials;
|
||||
import org.apache.hc.client5.http.auth.StandardAuthScheme;
|
||||
import org.apache.hc.client5.http.auth.UsernamePasswordCredentials;
|
||||
import org.apache.hc.client5.http.config.RequestConfig;
|
||||
import org.apache.hc.client5.http.impl.auth.BasicCredentialsProvider;
|
||||
import org.apache.hc.client5.http.impl.auth.BasicScheme;
|
||||
@ -63,7 +63,7 @@ public void testSelectInvalidInput() throws Exception {
|
||||
final DefaultAuthenticationStrategy authStrategy = new DefaultAuthenticationStrategy();
|
||||
final HttpClientContext context = HttpClientContext.create();
|
||||
try {
|
||||
authStrategy.select(null, Collections.<String, AuthChallenge>emptyMap(), context);
|
||||
authStrategy.select(null, Collections.emptyMap(), context);
|
||||
Assert.fail("NullPointerException expected");
|
||||
} catch (final NullPointerException ex) {
|
||||
}
|
||||
@ -73,7 +73,7 @@ public void testSelectInvalidInput() throws Exception {
|
||||
} catch (final NullPointerException ex) {
|
||||
}
|
||||
try {
|
||||
authStrategy.select(ChallengeType.TARGET, Collections.<String, AuthChallenge>emptyMap(), null);
|
||||
authStrategy.select(ChallengeType.TARGET, Collections.emptyMap(), null);
|
||||
Assert.fail("NullPointerException expected");
|
||||
} catch (final NullPointerException ex) {
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ public void testEvictExpiredOnly() throws Exception {
|
||||
Thread.sleep(1000);
|
||||
|
||||
Mockito.verify(cm, Mockito.atLeast(1)).closeExpired();
|
||||
Mockito.verify(cm, Mockito.never()).closeIdle(ArgumentMatchers.<TimeValue>any());
|
||||
Mockito.verify(cm, Mockito.never()).closeIdle(ArgumentMatchers.any());
|
||||
|
||||
Assert.assertTrue(connectionEvictor.isRunning());
|
||||
|
||||
|
@ -39,8 +39,8 @@
|
||||
import org.apache.hc.client5.http.auth.ChallengeType;
|
||||
import org.apache.hc.client5.http.auth.Credentials;
|
||||
import org.apache.hc.client5.http.auth.CredentialsProvider;
|
||||
import org.apache.hc.client5.http.auth.UsernamePasswordCredentials;
|
||||
import org.apache.hc.client5.http.auth.StandardAuthScheme;
|
||||
import org.apache.hc.client5.http.auth.UsernamePasswordCredentials;
|
||||
import org.apache.hc.client5.http.impl.DefaultAuthenticationStrategy;
|
||||
import org.apache.hc.client5.http.protocol.HttpClientContext;
|
||||
import org.apache.hc.core5.http.HttpHeaders;
|
||||
@ -170,8 +170,8 @@ public void testAuthentication() throws Exception {
|
||||
response.addHeader(new BasicHeader(HttpHeaders.WWW_AUTHENTICATE, "whatever realm=\"realm1\", stuff=\"1234\""));
|
||||
|
||||
final Credentials credentials = new UsernamePasswordCredentials("user", "pass".toCharArray());
|
||||
Mockito.when(this.credentialsProvider.getCredentials(Mockito.<AuthScope>any(),
|
||||
Mockito.<HttpContext>any())).thenReturn(credentials);
|
||||
Mockito.when(this.credentialsProvider.getCredentials(Mockito.any(),
|
||||
Mockito.any())).thenReturn(credentials);
|
||||
|
||||
final DefaultAuthenticationStrategy authStrategy = new DefaultAuthenticationStrategy();
|
||||
|
||||
@ -200,7 +200,7 @@ public void testAuthenticationCredentialsForBasic() throws Exception {
|
||||
|
||||
final Credentials credentials = new UsernamePasswordCredentials("user", "pass".toCharArray());
|
||||
Mockito.when(this.credentialsProvider.getCredentials(Mockito.eq(new AuthScope(host, "test", StandardAuthScheme.BASIC)),
|
||||
Mockito.<HttpContext>any())).thenReturn(credentials);
|
||||
Mockito.any())).thenReturn(credentials);
|
||||
|
||||
final DefaultAuthenticationStrategy authStrategy = new DefaultAuthenticationStrategy();
|
||||
|
||||
@ -336,7 +336,7 @@ public void testAuthenticationNoMatchingChallenge() throws Exception {
|
||||
|
||||
final Credentials credentials = new UsernamePasswordCredentials("user", "pass".toCharArray());
|
||||
Mockito.when(this.credentialsProvider.getCredentials(Mockito.eq(new AuthScope(host, "realm1", StandardAuthScheme.DIGEST)),
|
||||
Mockito.<HttpContext>any())).thenReturn(credentials);
|
||||
Mockito.any())).thenReturn(credentials);
|
||||
|
||||
final DefaultAuthenticationStrategy authStrategy = new DefaultAuthenticationStrategy();
|
||||
|
||||
|
@ -32,9 +32,9 @@
|
||||
import java.net.PasswordAuthentication;
|
||||
import java.net.URL;
|
||||
|
||||
import org.apache.hc.client5.http.auth.StandardAuthScheme;
|
||||
import org.apache.hc.client5.http.auth.AuthScope;
|
||||
import org.apache.hc.client5.http.auth.Credentials;
|
||||
import org.apache.hc.client5.http.auth.StandardAuthScheme;
|
||||
import org.apache.hc.client5.http.classic.methods.HttpGet;
|
||||
import org.apache.hc.core5.http.protocol.HttpCoreContext;
|
||||
import org.junit.Assert;
|
||||
@ -128,10 +128,10 @@ public void testSystemCredentialsProviderNoContext() throws Exception {
|
||||
private AuthenticatorDelegate installAuthenticator(final PasswordAuthentication returedAuthentication) {
|
||||
final AuthenticatorDelegate authenticatorDelegate = Mockito.mock(AuthenticatorDelegate.class);
|
||||
Mockito.when(authenticatorDelegate.getPasswordAuthentication(ArgumentMatchers.anyString(),
|
||||
ArgumentMatchers.<InetAddress>any(), ArgumentMatchers.anyInt(),
|
||||
ArgumentMatchers.any(), ArgumentMatchers.anyInt(),
|
||||
ArgumentMatchers.anyString(), ArgumentMatchers.anyString(),
|
||||
ArgumentMatchers.anyString(), ArgumentMatchers.<URL>any(),
|
||||
ArgumentMatchers.<RequestorType>any())).thenReturn(returedAuthentication);
|
||||
ArgumentMatchers.anyString(), ArgumentMatchers.any(),
|
||||
ArgumentMatchers.any())).thenReturn(returedAuthentication);
|
||||
Authenticator.setDefault(new DelegatedAuthenticator(authenticatorDelegate));
|
||||
return authenticatorDelegate;
|
||||
}
|
||||
|
@ -29,13 +29,10 @@
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.hc.client5.http.AuthenticationStrategy;
|
||||
import org.apache.hc.client5.http.HttpRoute;
|
||||
import org.apache.hc.client5.http.RouteInfo;
|
||||
import org.apache.hc.client5.http.auth.AuthChallenge;
|
||||
import org.apache.hc.client5.http.auth.AuthScheme;
|
||||
import org.apache.hc.client5.http.auth.AuthScope;
|
||||
import org.apache.hc.client5.http.auth.ChallengeType;
|
||||
import org.apache.hc.client5.http.auth.StandardAuthScheme;
|
||||
@ -55,7 +52,6 @@
|
||||
import org.apache.hc.core5.http.HttpHeaders;
|
||||
import org.apache.hc.core5.http.HttpHost;
|
||||
import org.apache.hc.core5.http.HttpRequest;
|
||||
import org.apache.hc.core5.http.HttpResponse;
|
||||
import org.apache.hc.core5.http.HttpVersion;
|
||||
import org.apache.hc.core5.http.io.entity.StringEntity;
|
||||
import org.apache.hc.core5.http.message.BasicClassicHttpResponse;
|
||||
@ -121,7 +117,7 @@ public void testEstablishDirectRoute() throws Exception {
|
||||
final ClassicHttpRequest request = new HttpGet("http://bar/test");
|
||||
|
||||
final ConnectionState connectionState = new ConnectionState();
|
||||
Mockito.doAnswer(connectionState.connectAnswer()).when(execRuntime).connectEndpoint(Mockito.<HttpClientContext>any());
|
||||
Mockito.doAnswer(connectionState.connectAnswer()).when(execRuntime).connectEndpoint(Mockito.any());
|
||||
Mockito.when(execRuntime.isEndpointConnected()).thenAnswer(connectionState.isConnectedAnswer());
|
||||
|
||||
final ExecChain.Scope scope = new ExecChain.Scope("test", route, request, execRuntime, context);
|
||||
@ -130,8 +126,8 @@ public void testEstablishDirectRoute() throws Exception {
|
||||
Mockito.verify(execRuntime).connectEndpoint(context);
|
||||
Mockito.verify(execRuntime, Mockito.never()).execute(
|
||||
Mockito.anyString(),
|
||||
Mockito.<ClassicHttpRequest>any(),
|
||||
Mockito.<HttpClientContext>any());
|
||||
Mockito.any(),
|
||||
Mockito.any());
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -141,7 +137,7 @@ public void testEstablishRouteDirectProxy() throws Exception {
|
||||
final ClassicHttpRequest request = new HttpGet("http://bar/test");
|
||||
|
||||
final ConnectionState connectionState = new ConnectionState();
|
||||
Mockito.doAnswer(connectionState.connectAnswer()).when(execRuntime).connectEndpoint(Mockito.<HttpClientContext>any());
|
||||
Mockito.doAnswer(connectionState.connectAnswer()).when(execRuntime).connectEndpoint(Mockito.any());
|
||||
Mockito.when(execRuntime.isEndpointConnected()).thenAnswer(connectionState.isConnectedAnswer());
|
||||
|
||||
final ExecChain.Scope scope = new ExecChain.Scope("test", route, request, execRuntime, context);
|
||||
@ -150,8 +146,8 @@ public void testEstablishRouteDirectProxy() throws Exception {
|
||||
Mockito.verify(execRuntime).connectEndpoint(context);
|
||||
Mockito.verify(execRuntime, Mockito.never()).execute(
|
||||
Mockito.anyString(),
|
||||
Mockito.<ClassicHttpRequest>any(),
|
||||
Mockito.<HttpClientContext>any());
|
||||
Mockito.any(),
|
||||
Mockito.any());
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -162,12 +158,12 @@ public void testEstablishRouteViaProxyTunnel() throws Exception {
|
||||
final ClassicHttpResponse response = new BasicClassicHttpResponse(200, "OK");
|
||||
|
||||
final ConnectionState connectionState = new ConnectionState();
|
||||
Mockito.doAnswer(connectionState.connectAnswer()).when(execRuntime).connectEndpoint(Mockito.<HttpClientContext>any());
|
||||
Mockito.doAnswer(connectionState.connectAnswer()).when(execRuntime).connectEndpoint(Mockito.any());
|
||||
Mockito.when(execRuntime.isEndpointConnected()).thenAnswer(connectionState.isConnectedAnswer());
|
||||
Mockito.when(execRuntime.execute(
|
||||
Mockito.anyString(),
|
||||
Mockito.<ClassicHttpRequest>any(),
|
||||
Mockito.<HttpClientContext>any())).thenReturn(response);
|
||||
Mockito.any(),
|
||||
Mockito.any())).thenReturn(response);
|
||||
|
||||
final ExecChain.Scope scope = new ExecChain.Scope("test", route, request, execRuntime, context);
|
||||
exec.execute(request, scope, execChain);
|
||||
@ -193,12 +189,12 @@ public void testEstablishRouteViaProxyTunnelUnexpectedResponse() throws Exceptio
|
||||
final ClassicHttpResponse response = new BasicClassicHttpResponse(101, "Lost");
|
||||
|
||||
final ConnectionState connectionState = new ConnectionState();
|
||||
Mockito.doAnswer(connectionState.connectAnswer()).when(execRuntime).connectEndpoint(Mockito.<HttpClientContext>any());
|
||||
Mockito.doAnswer(connectionState.connectAnswer()).when(execRuntime).connectEndpoint(Mockito.any());
|
||||
Mockito.when(execRuntime.isEndpointConnected()).thenAnswer(connectionState.isConnectedAnswer());
|
||||
Mockito.when(execRuntime.execute(
|
||||
Mockito.anyString(),
|
||||
Mockito.<ClassicHttpRequest>any(),
|
||||
Mockito.<HttpClientContext>any())).thenReturn(response);
|
||||
Mockito.any(),
|
||||
Mockito.any())).thenReturn(response);
|
||||
|
||||
final ExecChain.Scope scope = new ExecChain.Scope("test", route, request, execRuntime, context);
|
||||
exec.execute(request, scope, execChain);
|
||||
@ -213,12 +209,12 @@ public void testEstablishRouteViaProxyTunnelFailure() throws Exception {
|
||||
response.setEntity(new StringEntity("Ka-boom"));
|
||||
|
||||
final ConnectionState connectionState = new ConnectionState();
|
||||
Mockito.doAnswer(connectionState.connectAnswer()).when(execRuntime).connectEndpoint(Mockito.<HttpClientContext>any());
|
||||
Mockito.doAnswer(connectionState.connectAnswer()).when(execRuntime).connectEndpoint(Mockito.any());
|
||||
Mockito.when(execRuntime.isEndpointConnected()).thenAnswer(connectionState.isConnectedAnswer());
|
||||
Mockito.when(execRuntime.execute(
|
||||
Mockito.anyString(),
|
||||
Mockito.<ClassicHttpRequest>any(),
|
||||
Mockito.<HttpClientContext>any())).thenReturn(response);
|
||||
Mockito.any(),
|
||||
Mockito.any())).thenReturn(response);
|
||||
|
||||
final ExecChain.Scope scope = new ExecChain.Scope("test", route, request, execRuntime, context);
|
||||
try {
|
||||
@ -249,21 +245,21 @@ public void testEstablishRouteViaProxyTunnelRetryOnAuthChallengePersistentConnec
|
||||
context.setCredentialsProvider(credentialsProvider);
|
||||
|
||||
final ConnectionState connectionState = new ConnectionState();
|
||||
Mockito.doAnswer(connectionState.connectAnswer()).when(execRuntime).connectEndpoint(Mockito.<HttpClientContext>any());
|
||||
Mockito.doAnswer(connectionState.connectAnswer()).when(execRuntime).connectEndpoint(Mockito.any());
|
||||
Mockito.when(execRuntime.isEndpointConnected()).thenAnswer(connectionState.isConnectedAnswer());
|
||||
Mockito.when(reuseStrategy.keepAlive(
|
||||
Mockito.same(request),
|
||||
Mockito.<HttpResponse>any(),
|
||||
Mockito.any(),
|
||||
Mockito.<HttpClientContext>any())).thenReturn(Boolean.TRUE);
|
||||
Mockito.when(execRuntime.execute(
|
||||
Mockito.anyString(),
|
||||
Mockito.<ClassicHttpRequest>any(),
|
||||
Mockito.<HttpClientContext>any())).thenReturn(response1, response2);
|
||||
Mockito.any(),
|
||||
Mockito.any())).thenReturn(response1, response2);
|
||||
|
||||
Mockito.when(proxyAuthStrategy.select(
|
||||
Mockito.eq(ChallengeType.PROXY),
|
||||
Mockito.<Map<String, AuthChallenge>>any(),
|
||||
Mockito.<HttpClientContext>any())).thenReturn(Collections.<AuthScheme>singletonList(new BasicScheme()));
|
||||
Mockito.any(),
|
||||
Mockito.<HttpClientContext>any())).thenReturn(Collections.singletonList(new BasicScheme()));
|
||||
|
||||
final ExecChain.Scope scope = new ExecChain.Scope("test", route, request, execRuntime, context);
|
||||
exec.execute(request, scope, execChain);
|
||||
@ -290,21 +286,21 @@ public void testEstablishRouteViaProxyTunnelRetryOnAuthChallengeNonPersistentCon
|
||||
context.setCredentialsProvider(credentialsProvider);
|
||||
|
||||
final ConnectionState connectionState = new ConnectionState();
|
||||
Mockito.doAnswer(connectionState.connectAnswer()).when(execRuntime).connectEndpoint(Mockito.<HttpClientContext>any());
|
||||
Mockito.doAnswer(connectionState.connectAnswer()).when(execRuntime).connectEndpoint(Mockito.any());
|
||||
Mockito.when(execRuntime.isEndpointConnected()).thenAnswer(connectionState.isConnectedAnswer());
|
||||
Mockito.when(reuseStrategy.keepAlive(
|
||||
Mockito.same(request),
|
||||
Mockito.<HttpResponse>any(),
|
||||
Mockito.any(),
|
||||
Mockito.<HttpClientContext>any())).thenReturn(Boolean.FALSE);
|
||||
Mockito.when(execRuntime.execute(
|
||||
Mockito.anyString(),
|
||||
Mockito.<ClassicHttpRequest>any(),
|
||||
Mockito.<HttpClientContext>any())).thenReturn(response1, response2);
|
||||
Mockito.any(),
|
||||
Mockito.any())).thenReturn(response1, response2);
|
||||
|
||||
Mockito.when(proxyAuthStrategy.select(
|
||||
Mockito.eq(ChallengeType.PROXY),
|
||||
Mockito.<Map<String, AuthChallenge>>any(),
|
||||
Mockito.<HttpClientContext>any())).thenReturn(Collections.<AuthScheme>singletonList(new BasicScheme()));
|
||||
Mockito.any(),
|
||||
Mockito.<HttpClientContext>any())).thenReturn(Collections.singletonList(new BasicScheme()));
|
||||
|
||||
final ExecChain.Scope scope = new ExecChain.Scope("test", route, request, execRuntime, context);
|
||||
exec.execute(request, scope, execChain);
|
||||
@ -324,7 +320,7 @@ public void testEstablishRouteViaProxyTunnelMultipleHops() throws Exception {
|
||||
final ClassicHttpRequest request = new HttpGet("http://bar/test");
|
||||
|
||||
final ConnectionState connectionState = new ConnectionState();
|
||||
Mockito.doAnswer(connectionState.connectAnswer()).when(execRuntime).connectEndpoint(Mockito.<HttpClientContext>any());
|
||||
Mockito.doAnswer(connectionState.connectAnswer()).when(execRuntime).connectEndpoint(Mockito.any());
|
||||
Mockito.when(execRuntime.isEndpointConnected()).thenAnswer(connectionState.isConnectedAnswer());
|
||||
|
||||
final ExecChain.Scope scope = new ExecChain.Scope("test", route, request, execRuntime, context);
|
||||
|
@ -43,10 +43,7 @@
|
||||
import org.apache.hc.core5.http.ClassicHttpResponse;
|
||||
import org.apache.hc.core5.http.Header;
|
||||
import org.apache.hc.core5.http.HttpHost;
|
||||
import org.apache.hc.core5.http.HttpRequest;
|
||||
import org.apache.hc.core5.http.HttpResponse;
|
||||
import org.apache.hc.core5.http.io.support.ClassicRequestBuilder;
|
||||
import org.apache.hc.core5.http.protocol.HttpContext;
|
||||
import org.apache.hc.core5.util.TimeValue;
|
||||
import org.apache.hc.core5.util.Timeout;
|
||||
import org.junit.Assert;
|
||||
@ -88,21 +85,21 @@ public void testFundamentals1() throws Exception {
|
||||
|
||||
Mockito.when(chain.proceed(
|
||||
Mockito.same(request),
|
||||
Mockito.<ExecChain.Scope>any())).thenReturn(response);
|
||||
Mockito.any())).thenReturn(response);
|
||||
Mockito.when(retryStrategy.retryRequest(
|
||||
Mockito.<HttpResponse>any(),
|
||||
Mockito.any(),
|
||||
Mockito.anyInt(),
|
||||
Mockito.<HttpContext>any())).thenReturn(Boolean.TRUE, Boolean.FALSE);
|
||||
Mockito.any())).thenReturn(Boolean.TRUE, Boolean.FALSE);
|
||||
Mockito.when(retryStrategy.getRetryInterval(
|
||||
Mockito.<HttpResponse>any(),
|
||||
Mockito.any(),
|
||||
Mockito.anyInt(),
|
||||
Mockito.<HttpContext>any())).thenReturn(TimeValue.ZERO_MILLISECONDS);
|
||||
Mockito.any())).thenReturn(TimeValue.ZERO_MILLISECONDS);
|
||||
|
||||
final ExecChain.Scope scope = new ExecChain.Scope("test", route, request, endpoint, context);
|
||||
retryExec.execute(request, scope, chain);
|
||||
|
||||
Mockito.verify(chain, Mockito.times(2)).proceed(
|
||||
Mockito.<ClassicHttpRequest>any(),
|
||||
Mockito.any(),
|
||||
Mockito.same(scope));
|
||||
Mockito.verify(response, Mockito.times(1)).close();
|
||||
}
|
||||
@ -120,21 +117,21 @@ public void testRetryIntervalGreaterResponseTimeout() throws Exception {
|
||||
|
||||
Mockito.when(chain.proceed(
|
||||
Mockito.same(request),
|
||||
Mockito.<ExecChain.Scope>any())).thenReturn(response);
|
||||
Mockito.any())).thenReturn(response);
|
||||
Mockito.when(retryStrategy.retryRequest(
|
||||
Mockito.<HttpResponse>any(),
|
||||
Mockito.any(),
|
||||
Mockito.anyInt(),
|
||||
Mockito.<HttpContext>any())).thenReturn(Boolean.TRUE, Boolean.FALSE);
|
||||
Mockito.any())).thenReturn(Boolean.TRUE, Boolean.FALSE);
|
||||
Mockito.when(retryStrategy.getRetryInterval(
|
||||
Mockito.<HttpResponse>any(),
|
||||
Mockito.any(),
|
||||
Mockito.anyInt(),
|
||||
Mockito.<HttpContext>any())).thenReturn(TimeValue.ofSeconds(5));
|
||||
Mockito.any())).thenReturn(TimeValue.ofSeconds(5));
|
||||
|
||||
final ExecChain.Scope scope = new ExecChain.Scope("test", route, request, endpoint, context);
|
||||
retryExec.execute(request, scope, chain);
|
||||
|
||||
Mockito.verify(chain, Mockito.times(1)).proceed(
|
||||
Mockito.<ClassicHttpRequest>any(),
|
||||
Mockito.any(),
|
||||
Mockito.same(scope));
|
||||
Mockito.verify(response, Mockito.times(0)).close();
|
||||
}
|
||||
@ -152,21 +149,21 @@ public void testRetryIntervalResponseTimeoutNull() throws Exception {
|
||||
|
||||
Mockito.when(chain.proceed(
|
||||
Mockito.same(request),
|
||||
Mockito.<ExecChain.Scope>any())).thenReturn(response);
|
||||
Mockito.any())).thenReturn(response);
|
||||
Mockito.when(retryStrategy.retryRequest(
|
||||
Mockito.<HttpResponse>any(),
|
||||
Mockito.any(),
|
||||
Mockito.anyInt(),
|
||||
Mockito.<HttpContext>any())).thenReturn(Boolean.TRUE, Boolean.FALSE);
|
||||
Mockito.any())).thenReturn(Boolean.TRUE, Boolean.FALSE);
|
||||
Mockito.when(retryStrategy.getRetryInterval(
|
||||
Mockito.<HttpResponse>any(),
|
||||
Mockito.any(),
|
||||
Mockito.anyInt(),
|
||||
Mockito.<HttpContext>any())).thenReturn(TimeValue.ofSeconds(1));
|
||||
Mockito.any())).thenReturn(TimeValue.ofSeconds(1));
|
||||
|
||||
final ExecChain.Scope scope = new ExecChain.Scope("test", route, request, endpoint, context);
|
||||
retryExec.execute(request, scope, chain);
|
||||
|
||||
Mockito.verify(chain, Mockito.times(2)).proceed(
|
||||
Mockito.<ClassicHttpRequest>any(),
|
||||
Mockito.any(),
|
||||
Mockito.same(scope));
|
||||
Mockito.verify(response, Mockito.times(1)).close();
|
||||
}
|
||||
@ -179,12 +176,12 @@ public void testStrategyRuntimeException() throws Exception {
|
||||
|
||||
final ClassicHttpResponse response = Mockito.mock(ClassicHttpResponse.class);
|
||||
Mockito.when(chain.proceed(
|
||||
Mockito.<ClassicHttpRequest>any(),
|
||||
Mockito.<ExecChain.Scope>any())).thenReturn(response);
|
||||
Mockito.any(),
|
||||
Mockito.any())).thenReturn(response);
|
||||
Mockito.doThrow(new RuntimeException("Ooopsie")).when(retryStrategy).retryRequest(
|
||||
Mockito.<HttpResponse>any(),
|
||||
Mockito.any(),
|
||||
Mockito.anyInt(),
|
||||
Mockito.<HttpContext>any());
|
||||
Mockito.any());
|
||||
final ExecChain.Scope scope = new ExecChain.Scope("test", route, request, endpoint, context);
|
||||
try {
|
||||
retryExec.execute(request, scope, chain);
|
||||
@ -206,8 +203,8 @@ public void testNonRepeatableEntityResponseReturnedImmediately() throws Exceptio
|
||||
|
||||
final ClassicHttpResponse response = Mockito.mock(ClassicHttpResponse.class);
|
||||
Mockito.when(chain.proceed(
|
||||
Mockito.<ClassicHttpRequest>any(),
|
||||
Mockito.<ExecChain.Scope>any())).thenReturn(response);
|
||||
Mockito.any(),
|
||||
Mockito.any())).thenReturn(response);
|
||||
|
||||
final ExecChain.Scope scope = new ExecChain.Scope("test", route, request, endpoint, context);
|
||||
final ClassicHttpResponse finalResponse = retryExec.execute(request, scope, chain);
|
||||
@ -225,8 +222,8 @@ public void testFundamentals2() throws Exception {
|
||||
final HttpClientContext context = HttpClientContext.create();
|
||||
|
||||
Mockito.when(chain.proceed(
|
||||
Mockito.<ClassicHttpRequest>any(),
|
||||
Mockito.<ExecChain.Scope>any())).thenAnswer(invocationOnMock -> {
|
||||
Mockito.any(),
|
||||
Mockito.any())).thenAnswer(invocationOnMock -> {
|
||||
final Object[] args = invocationOnMock.getArguments();
|
||||
final ClassicHttpRequest wrapper = (ClassicHttpRequest) args[0];
|
||||
final Header[] headers = wrapper.getHeaders();
|
||||
@ -237,17 +234,17 @@ public void testFundamentals2() throws Exception {
|
||||
throw new IOException("Ka-boom");
|
||||
});
|
||||
Mockito.when(retryStrategy.retryRequest(
|
||||
Mockito.<HttpRequest>any(),
|
||||
Mockito.<IOException>any(),
|
||||
Mockito.any(),
|
||||
Mockito.any(),
|
||||
Mockito.eq(1),
|
||||
Mockito.<HttpContext>any())).thenReturn(Boolean.TRUE);
|
||||
Mockito.any())).thenReturn(Boolean.TRUE);
|
||||
final ExecChain.Scope scope = new ExecChain.Scope("test", route, originalRequest, endpoint, context);
|
||||
final ClassicHttpRequest request = ClassicRequestBuilder.copy(originalRequest).build();
|
||||
try {
|
||||
retryExec.execute(request, scope, chain);
|
||||
} catch (final IOException ex) {
|
||||
Mockito.verify(chain, Mockito.times(2)).proceed(
|
||||
Mockito.<ClassicHttpRequest>any(),
|
||||
Mockito.any(),
|
||||
Mockito.same(scope));
|
||||
throw ex;
|
||||
}
|
||||
@ -261,8 +258,8 @@ public void testAbortedRequest() throws Exception {
|
||||
final HttpClientContext context = HttpClientContext.create();
|
||||
|
||||
Mockito.when(chain.proceed(
|
||||
Mockito.<ClassicHttpRequest>any(),
|
||||
Mockito.<ExecChain.Scope>any())).thenThrow(new IOException("Ka-boom"));
|
||||
Mockito.any(),
|
||||
Mockito.any())).thenThrow(new IOException("Ka-boom"));
|
||||
Mockito.when(endpoint.isExecutionAborted()).thenReturn(true);
|
||||
|
||||
final ExecChain.Scope scope = new ExecChain.Scope("test", route, originalRequest, endpoint, context);
|
||||
@ -274,10 +271,10 @@ public void testAbortedRequest() throws Exception {
|
||||
Mockito.same(request),
|
||||
Mockito.same(scope));
|
||||
Mockito.verify(retryStrategy, Mockito.never()).retryRequest(
|
||||
Mockito.<HttpRequest>any(),
|
||||
Mockito.<IOException>any(),
|
||||
Mockito.any(),
|
||||
Mockito.any(),
|
||||
Mockito.anyInt(),
|
||||
Mockito.<HttpContext>any());
|
||||
Mockito.any());
|
||||
|
||||
throw ex;
|
||||
}
|
||||
@ -293,8 +290,8 @@ public void testNonRepeatableRequest() throws Exception {
|
||||
final HttpClientContext context = HttpClientContext.create();
|
||||
|
||||
Mockito.when(chain.proceed(
|
||||
Mockito.<ClassicHttpRequest>any(),
|
||||
Mockito.<ExecChain.Scope>any())).thenAnswer(invocationOnMock -> {
|
||||
Mockito.any(),
|
||||
Mockito.any())).thenAnswer(invocationOnMock -> {
|
||||
final Object[] args = invocationOnMock.getArguments();
|
||||
final ClassicHttpRequest req = (ClassicHttpRequest) args[0];
|
||||
req.getEntity().writeTo(new ByteArrayOutputStream());
|
||||
|
@ -36,7 +36,6 @@
|
||||
import org.apache.hc.client5.http.io.HttpClientConnectionManager;
|
||||
import org.apache.hc.client5.http.io.LeaseRequest;
|
||||
import org.apache.hc.client5.http.protocol.HttpClientContext;
|
||||
import org.apache.hc.core5.concurrent.Cancellable;
|
||||
import org.apache.hc.core5.concurrent.CancellableDependency;
|
||||
import org.apache.hc.core5.http.ConnectionRequestTimeoutException;
|
||||
import org.apache.hc.core5.http.HttpHost;
|
||||
@ -89,9 +88,9 @@ public void testAcquireEndpoint() throws Exception {
|
||||
context.setRequestConfig(config);
|
||||
final HttpRoute route = new HttpRoute(new HttpHost("host", 80));
|
||||
|
||||
Mockito.when(mgr.lease(Mockito.eq("some-id"), Mockito.eq(route), Mockito.<Timeout>any(), Mockito.any()))
|
||||
Mockito.when(mgr.lease(Mockito.eq("some-id"), Mockito.eq(route), Mockito.any(), Mockito.any()))
|
||||
.thenReturn(leaseRequest);
|
||||
Mockito.when(leaseRequest.get(Mockito.<Timeout>any())).thenReturn(connectionEndpoint);
|
||||
Mockito.when(leaseRequest.get(Mockito.any())).thenReturn(connectionEndpoint);
|
||||
|
||||
execRuntime.acquireEndpoint("some-id", route, null, context);
|
||||
|
||||
@ -103,16 +102,16 @@ public void testAcquireEndpoint() throws Exception {
|
||||
Mockito.verify(leaseRequest).get(Timeout.ofMilliseconds(345));
|
||||
Mockito.verify(cancellableDependency, Mockito.times(1)).setDependency(leaseRequest);
|
||||
Mockito.verify(cancellableDependency, Mockito.times(1)).setDependency(execRuntime);
|
||||
Mockito.verify(cancellableDependency, Mockito.times(2)).setDependency(Mockito.<Cancellable>any());
|
||||
Mockito.verify(cancellableDependency, Mockito.times(2)).setDependency(Mockito.any());
|
||||
}
|
||||
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void testAcquireEndpointAlreadyAcquired() throws Exception {
|
||||
final HttpClientContext context = HttpClientContext.create();
|
||||
|
||||
Mockito.when(mgr.lease(Mockito.eq("some-id"), Mockito.eq(route), Mockito.<Timeout>any(), Mockito.any()))
|
||||
Mockito.when(mgr.lease(Mockito.eq("some-id"), Mockito.eq(route), Mockito.any(), Mockito.any()))
|
||||
.thenReturn(leaseRequest);
|
||||
Mockito.when(leaseRequest.get(Mockito.<Timeout>any())).thenReturn(connectionEndpoint);
|
||||
Mockito.when(leaseRequest.get(Mockito.any())).thenReturn(connectionEndpoint);
|
||||
|
||||
execRuntime.acquireEndpoint("some-id", route, null, context);
|
||||
|
||||
@ -126,9 +125,9 @@ public void testAcquireEndpointAlreadyAcquired() throws Exception {
|
||||
public void testAcquireEndpointLeaseRequestTimeout() throws Exception {
|
||||
final HttpClientContext context = HttpClientContext.create();
|
||||
|
||||
Mockito.when(mgr.lease(Mockito.eq("some-id"), Mockito.eq(route), Mockito.<Timeout>any(), Mockito.any()))
|
||||
Mockito.when(mgr.lease(Mockito.eq("some-id"), Mockito.eq(route), Mockito.any(), Mockito.any()))
|
||||
.thenReturn(leaseRequest);
|
||||
Mockito.when(leaseRequest.get(Mockito.<Timeout>any())).thenThrow(new TimeoutException("timeout"));
|
||||
Mockito.when(leaseRequest.get(Mockito.any())).thenThrow(new TimeoutException("timeout"));
|
||||
|
||||
execRuntime.acquireEndpoint("some-id", route, null, context);
|
||||
}
|
||||
@ -137,9 +136,9 @@ public void testAcquireEndpointLeaseRequestTimeout() throws Exception {
|
||||
public void testAcquireEndpointLeaseRequestFailure() throws Exception {
|
||||
final HttpClientContext context = HttpClientContext.create();
|
||||
|
||||
Mockito.when(mgr.lease(Mockito.eq("some-id"), Mockito.eq(route), Mockito.<Timeout>any(), Mockito.any()))
|
||||
Mockito.when(mgr.lease(Mockito.eq("some-id"), Mockito.eq(route), Mockito.any(), Mockito.any()))
|
||||
.thenReturn(leaseRequest);
|
||||
Mockito.when(leaseRequest.get(Mockito.<Timeout>any())).thenThrow(new ExecutionException(new IllegalStateException()));
|
||||
Mockito.when(leaseRequest.get(Mockito.any())).thenThrow(new ExecutionException(new IllegalStateException()));
|
||||
|
||||
execRuntime.acquireEndpoint("some-id", route, null, context);
|
||||
}
|
||||
@ -147,9 +146,9 @@ public void testAcquireEndpointLeaseRequestFailure() throws Exception {
|
||||
@Test
|
||||
public void testAbortEndpoint() throws Exception {
|
||||
final HttpClientContext context = HttpClientContext.create();
|
||||
Mockito.when(mgr.lease(Mockito.eq("some-id"), Mockito.eq(route), Mockito.<Timeout>any(), Mockito.any()))
|
||||
Mockito.when(mgr.lease(Mockito.eq("some-id"), Mockito.eq(route), Mockito.any(), Mockito.any()))
|
||||
.thenReturn(leaseRequest);
|
||||
Mockito.when(leaseRequest.get(Mockito.<Timeout>any())).thenReturn(connectionEndpoint);
|
||||
Mockito.when(leaseRequest.get(Mockito.any())).thenReturn(connectionEndpoint);
|
||||
|
||||
execRuntime.acquireEndpoint("some-id", new HttpRoute(new HttpHost("host", 80)), null, context);
|
||||
Assert.assertTrue(execRuntime.isEndpointAcquired());
|
||||
@ -164,18 +163,18 @@ public void testAbortEndpoint() throws Exception {
|
||||
|
||||
Mockito.verify(connectionEndpoint, Mockito.times(1)).close(CloseMode.IMMEDIATE);
|
||||
Mockito.verify(mgr, Mockito.times(1)).release(
|
||||
Mockito.<ConnectionEndpoint>any(),
|
||||
Mockito.any(),
|
||||
Mockito.<TimeValue>any());
|
||||
Mockito.any(),
|
||||
Mockito.any());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCancell() throws Exception {
|
||||
final HttpClientContext context = HttpClientContext.create();
|
||||
|
||||
Mockito.when(mgr.lease(Mockito.eq("some-id"), Mockito.eq(route), Mockito.<Timeout>any(), Mockito.any()))
|
||||
Mockito.when(mgr.lease(Mockito.eq("some-id"), Mockito.eq(route), Mockito.any(), Mockito.any()))
|
||||
.thenReturn(leaseRequest);
|
||||
Mockito.when(leaseRequest.get(Mockito.<Timeout>any())).thenReturn(connectionEndpoint);
|
||||
Mockito.when(leaseRequest.get(Mockito.any())).thenReturn(connectionEndpoint);
|
||||
|
||||
execRuntime.acquireEndpoint("some-id", route, null, context);
|
||||
Assert.assertTrue(execRuntime.isEndpointAcquired());
|
||||
@ -191,18 +190,18 @@ public void testCancell() throws Exception {
|
||||
|
||||
Mockito.verify(connectionEndpoint, Mockito.times(1)).close(CloseMode.IMMEDIATE);
|
||||
Mockito.verify(mgr, Mockito.times(1)).release(
|
||||
Mockito.<ConnectionEndpoint>any(),
|
||||
Mockito.any(),
|
||||
Mockito.<TimeValue>any());
|
||||
Mockito.any(),
|
||||
Mockito.any());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReleaseEndpointReusable() throws Exception {
|
||||
final HttpClientContext context = HttpClientContext.create();
|
||||
|
||||
Mockito.when(mgr.lease(Mockito.eq("some-id"), Mockito.eq(route), Mockito.<Timeout>any(), Mockito.any()))
|
||||
Mockito.when(mgr.lease(Mockito.eq("some-id"), Mockito.eq(route), Mockito.any(), Mockito.any()))
|
||||
.thenReturn(leaseRequest);
|
||||
Mockito.when(leaseRequest.get(Mockito.<Timeout>any())).thenReturn(connectionEndpoint);
|
||||
Mockito.when(leaseRequest.get(Mockito.any())).thenReturn(connectionEndpoint);
|
||||
|
||||
execRuntime.acquireEndpoint("some-id", route, null, context);
|
||||
Assert.assertTrue(execRuntime.isEndpointAcquired());
|
||||
@ -219,18 +218,18 @@ public void testReleaseEndpointReusable() throws Exception {
|
||||
execRuntime.releaseEndpoint();
|
||||
|
||||
Mockito.verify(mgr, Mockito.times(1)).release(
|
||||
Mockito.<ConnectionEndpoint>any(),
|
||||
Mockito.any(),
|
||||
Mockito.<TimeValue>any());
|
||||
Mockito.any(),
|
||||
Mockito.any());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReleaseEndpointNonReusable() throws Exception {
|
||||
final HttpClientContext context = HttpClientContext.create();
|
||||
|
||||
Mockito.when(mgr.lease(Mockito.eq("some-id"), Mockito.eq(route), Mockito.<Timeout>any(), Mockito.any()))
|
||||
Mockito.when(mgr.lease(Mockito.eq("some-id"), Mockito.eq(route), Mockito.any(), Mockito.any()))
|
||||
.thenReturn(leaseRequest);
|
||||
Mockito.when(leaseRequest.get(Mockito.<Timeout>any())).thenReturn(connectionEndpoint);
|
||||
Mockito.when(leaseRequest.get(Mockito.any())).thenReturn(connectionEndpoint);
|
||||
|
||||
execRuntime.acquireEndpoint("some-id", route, null, context);
|
||||
Assert.assertTrue(execRuntime.isEndpointAcquired());
|
||||
@ -248,9 +247,9 @@ public void testReleaseEndpointNonReusable() throws Exception {
|
||||
execRuntime.releaseEndpoint();
|
||||
|
||||
Mockito.verify(mgr, Mockito.times(1)).release(
|
||||
Mockito.<ConnectionEndpoint>any(),
|
||||
Mockito.any(),
|
||||
Mockito.<TimeValue>any());
|
||||
Mockito.any(),
|
||||
Mockito.any());
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -262,9 +261,9 @@ public void testConnectEndpoint() throws Exception {
|
||||
.build();
|
||||
context.setRequestConfig(config);
|
||||
|
||||
Mockito.when(mgr.lease(Mockito.eq("some-id"), Mockito.eq(route), Mockito.<Timeout>any(), Mockito.any()))
|
||||
Mockito.when(mgr.lease(Mockito.eq("some-id"), Mockito.eq(route), Mockito.any(), Mockito.any()))
|
||||
.thenReturn(leaseRequest);
|
||||
Mockito.when(leaseRequest.get(Mockito.<Timeout>any())).thenReturn(connectionEndpoint);
|
||||
Mockito.when(leaseRequest.get(Mockito.any())).thenReturn(connectionEndpoint);
|
||||
|
||||
execRuntime.acquireEndpoint("some-id", route, null, context);
|
||||
Assert.assertTrue(execRuntime.isEndpointAcquired());
|
||||
@ -281,9 +280,9 @@ public void testConnectEndpoint() throws Exception {
|
||||
public void testDisonnectEndpoint() throws Exception {
|
||||
final HttpClientContext context = HttpClientContext.create();
|
||||
|
||||
Mockito.when(mgr.lease(Mockito.eq("some-id"), Mockito.eq(route), Mockito.<Timeout>any(), Mockito.any()))
|
||||
Mockito.when(mgr.lease(Mockito.eq("some-id"), Mockito.eq(route), Mockito.any(), Mockito.any()))
|
||||
.thenReturn(leaseRequest);
|
||||
Mockito.when(leaseRequest.get(Mockito.<Timeout>any())).thenReturn(connectionEndpoint);
|
||||
Mockito.when(leaseRequest.get(Mockito.any())).thenReturn(connectionEndpoint);
|
||||
|
||||
execRuntime.acquireEndpoint("some-id", route, null, context);
|
||||
Assert.assertTrue(execRuntime.isEndpointAcquired());
|
||||
@ -294,7 +293,7 @@ public void testDisonnectEndpoint() throws Exception {
|
||||
execRuntime.connectEndpoint(context);
|
||||
|
||||
Mockito.verify(mgr, Mockito.never()).connect(
|
||||
Mockito.same(connectionEndpoint), Mockito.<TimeValue>any(), Mockito.<HttpClientContext>any());
|
||||
Mockito.same(connectionEndpoint), Mockito.any(), Mockito.<HttpClientContext>any());
|
||||
|
||||
execRuntime.disconnectEndpoint();
|
||||
|
||||
|
@ -34,7 +34,6 @@
|
||||
import org.apache.hc.client5.http.HttpRoute;
|
||||
import org.apache.hc.client5.http.auth.AuthSchemeFactory;
|
||||
import org.apache.hc.client5.http.auth.CredentialsProvider;
|
||||
import org.apache.hc.client5.http.classic.ExecChain;
|
||||
import org.apache.hc.client5.http.classic.ExecChainHandler;
|
||||
import org.apache.hc.client5.http.classic.methods.HttpGet;
|
||||
import org.apache.hc.client5.http.config.RequestConfig;
|
||||
@ -43,7 +42,6 @@
|
||||
import org.apache.hc.client5.http.io.HttpClientConnectionManager;
|
||||
import org.apache.hc.client5.http.protocol.HttpClientContext;
|
||||
import org.apache.hc.client5.http.routing.HttpRoutePlanner;
|
||||
import org.apache.hc.core5.http.ClassicHttpRequest;
|
||||
import org.apache.hc.core5.http.HttpException;
|
||||
import org.apache.hc.core5.http.HttpHost;
|
||||
import org.apache.hc.core5.http.config.Lookup;
|
||||
@ -108,9 +106,9 @@ public void testExecute() throws Exception {
|
||||
client.execute(httpget);
|
||||
|
||||
Mockito.verify(execChain).execute(
|
||||
Mockito.<ClassicHttpRequest>any(),
|
||||
Mockito.<ExecChain.Scope>any(),
|
||||
Mockito.<ExecChain>any());
|
||||
Mockito.any(),
|
||||
Mockito.any(),
|
||||
Mockito.any());
|
||||
}
|
||||
|
||||
@Test(expected=ClientProtocolException.class)
|
||||
@ -122,9 +120,9 @@ public void testExecuteHttpException() throws Exception {
|
||||
Mockito.eq(new HttpHost("somehost")),
|
||||
Mockito.<HttpClientContext>any())).thenReturn(route);
|
||||
Mockito.when(execChain.execute(
|
||||
Mockito.<ClassicHttpRequest>any(),
|
||||
Mockito.<ExecChain.Scope>any(),
|
||||
Mockito.<ExecChain>any())).thenThrow(new HttpException());
|
||||
Mockito.any(),
|
||||
Mockito.any(),
|
||||
Mockito.any())).thenThrow(new HttpException());
|
||||
|
||||
client.execute(httpget);
|
||||
}
|
||||
|
@ -93,7 +93,7 @@ public void testExecRequestNonPersistentConnection() throws Exception {
|
||||
Mockito.when(endpoint.execute(
|
||||
Mockito.anyString(),
|
||||
Mockito.same(request),
|
||||
Mockito.<HttpClientContext>any())).thenReturn(response);
|
||||
Mockito.any())).thenReturn(response);
|
||||
Mockito.when(reuseStrategy.keepAlive(
|
||||
Mockito.same(request),
|
||||
Mockito.same(response),
|
||||
@ -121,7 +121,7 @@ public void testExecRequestNonPersistentConnectionNoResponseEntity() throws Exce
|
||||
Mockito.when(endpoint.execute(
|
||||
Mockito.anyString(),
|
||||
Mockito.same(request),
|
||||
Mockito.<HttpClientContext>any())).thenReturn(response);
|
||||
Mockito.any())).thenReturn(response);
|
||||
Mockito.when(reuseStrategy.keepAlive(
|
||||
Mockito.same(request),
|
||||
Mockito.same(response),
|
||||
@ -153,7 +153,7 @@ public void testExecRequestPersistentConnection() throws Exception {
|
||||
Mockito.when(endpoint.execute(
|
||||
Mockito.anyString(),
|
||||
Mockito.same(request),
|
||||
Mockito.<HttpClientContext>any())).thenReturn(response);
|
||||
Mockito.any())).thenReturn(response);
|
||||
Mockito.when(reuseStrategy.keepAlive(
|
||||
Mockito.same(request),
|
||||
Mockito.same(response),
|
||||
@ -183,7 +183,7 @@ public void testExecRequestPersistentConnectionNoResponseEntity() throws Excepti
|
||||
Mockito.when(endpoint.execute(
|
||||
Mockito.anyString(),
|
||||
Mockito.same(request),
|
||||
Mockito.<HttpClientContext>any())).thenReturn(response);
|
||||
Mockito.any())).thenReturn(response);
|
||||
Mockito.when(reuseStrategy.keepAlive(
|
||||
Mockito.same(request),
|
||||
Mockito.same(response),
|
||||
@ -217,7 +217,7 @@ public void testExecRequestConnectionRelease() throws Exception {
|
||||
Mockito.when(endpoint.execute(
|
||||
Mockito.anyString(),
|
||||
Mockito.same(request),
|
||||
Mockito.<HttpClientContext>any())).thenReturn(response);
|
||||
Mockito.any())).thenReturn(response);
|
||||
Mockito.when(reuseStrategy.keepAlive(
|
||||
Mockito.same(request),
|
||||
Mockito.same(response),
|
||||
@ -246,7 +246,7 @@ public void testExecConnectionShutDown() throws Exception {
|
||||
Mockito.when(endpoint.execute(
|
||||
Mockito.anyString(),
|
||||
Mockito.same(request),
|
||||
Mockito.<HttpClientContext>any())).thenThrow(new ConnectionShutdownException());
|
||||
Mockito.any())).thenThrow(new ConnectionShutdownException());
|
||||
|
||||
final ExecChain.Scope scope = new ExecChain.Scope("test", route, request, endpoint, context);
|
||||
try {
|
||||
@ -266,7 +266,7 @@ public void testExecRuntimeException() throws Exception {
|
||||
Mockito.when(endpoint.execute(
|
||||
Mockito.anyString(),
|
||||
Mockito.same(request),
|
||||
Mockito.<HttpClientContext>any())).thenThrow(new RuntimeException("Ka-boom"));
|
||||
Mockito.any())).thenThrow(new RuntimeException("Ka-boom"));
|
||||
|
||||
final ExecChain.Scope scope = new ExecChain.Scope("test", route, request, endpoint, context);
|
||||
try {
|
||||
@ -286,7 +286,7 @@ public void testExecHttpException() throws Exception {
|
||||
Mockito.when(endpoint.execute(
|
||||
Mockito.anyString(),
|
||||
Mockito.same(request),
|
||||
Mockito.<HttpClientContext>any())).thenThrow(new HttpException("Ka-boom"));
|
||||
Mockito.any())).thenThrow(new HttpException("Ka-boom"));
|
||||
|
||||
final ExecChain.Scope scope = new ExecChain.Scope("test", route, request, endpoint, context);
|
||||
try {
|
||||
@ -306,7 +306,7 @@ public void testExecIOException() throws Exception {
|
||||
Mockito.when(endpoint.execute(
|
||||
Mockito.anyString(),
|
||||
Mockito.same(request),
|
||||
Mockito.<HttpClientContext>any())).thenThrow(new IOException("Ka-boom"));
|
||||
Mockito.any())).thenThrow(new IOException("Ka-boom"));
|
||||
|
||||
final ExecChain.Scope scope = new ExecChain.Scope("test", route, request, endpoint, context);
|
||||
try {
|
||||
|
@ -32,13 +32,10 @@
|
||||
import java.io.InputStream;
|
||||
import java.net.URI;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.hc.client5.http.AuthenticationStrategy;
|
||||
import org.apache.hc.client5.http.HttpRoute;
|
||||
import org.apache.hc.client5.http.auth.AuthChallenge;
|
||||
import org.apache.hc.client5.http.auth.AuthExchange;
|
||||
import org.apache.hc.client5.http.auth.AuthScheme;
|
||||
import org.apache.hc.client5.http.auth.AuthScope;
|
||||
import org.apache.hc.client5.http.auth.ChallengeType;
|
||||
import org.apache.hc.client5.http.auth.Credentials;
|
||||
@ -56,13 +53,11 @@
|
||||
import org.apache.hc.client5.http.protocol.HttpClientContext;
|
||||
import org.apache.hc.core5.http.ClassicHttpRequest;
|
||||
import org.apache.hc.core5.http.ClassicHttpResponse;
|
||||
import org.apache.hc.core5.http.EntityDetails;
|
||||
import org.apache.hc.core5.http.HttpException;
|
||||
import org.apache.hc.core5.http.HttpHeaders;
|
||||
import org.apache.hc.core5.http.HttpHost;
|
||||
import org.apache.hc.core5.http.HttpResponse;
|
||||
import org.apache.hc.core5.http.message.BasicClassicHttpResponse;
|
||||
import org.apache.hc.core5.http.protocol.HttpContext;
|
||||
import org.apache.hc.core5.http.protocol.HttpProcessor;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
@ -108,8 +103,8 @@ public void testFundamentals() throws Exception {
|
||||
final ClassicHttpResponse response = Mockito.mock(ClassicHttpResponse.class);
|
||||
|
||||
Mockito.when(chain.proceed(
|
||||
Mockito.<ClassicHttpRequest>any(),
|
||||
Mockito.<ExecChain.Scope>any())).thenReturn(response);
|
||||
Mockito.any(),
|
||||
Mockito.any())).thenReturn(response);
|
||||
|
||||
final ExecChain.Scope scope = new ExecChain.Scope("test", route, request, execRuntime, context);
|
||||
protocolExec.execute(request, scope, chain);
|
||||
@ -132,8 +127,8 @@ public void testUserInfoInRequestURI() throws Exception {
|
||||
|
||||
final ClassicHttpResponse response = Mockito.mock(ClassicHttpResponse.class);
|
||||
Mockito.when(chain.proceed(
|
||||
Mockito.<ClassicHttpRequest>any(),
|
||||
Mockito.<ExecChain.Scope>any())).thenReturn(response);
|
||||
Mockito.any(),
|
||||
Mockito.any())).thenReturn(response);
|
||||
|
||||
final ExecChain.Scope scope = new ExecChain.Scope("test", route, request, execRuntime, context);
|
||||
protocolExec.execute(request, scope, chain);
|
||||
@ -153,10 +148,10 @@ public void testPostProcessHttpException() throws Exception {
|
||||
final ClassicHttpResponse response = Mockito.mock(ClassicHttpResponse.class);
|
||||
|
||||
Mockito.when(chain.proceed(
|
||||
Mockito.<ClassicHttpRequest>any(),
|
||||
Mockito.<ExecChain.Scope>any())).thenReturn(response);
|
||||
Mockito.any(),
|
||||
Mockito.any())).thenReturn(response);
|
||||
Mockito.doThrow(new HttpException("Ooopsie")).when(httpProcessor).process(
|
||||
Mockito.same(response), Mockito.<EntityDetails>isNull(), Mockito.<HttpContext>any());
|
||||
Mockito.same(response), Mockito.isNull(), Mockito.any());
|
||||
final ExecChain.Scope scope = new ExecChain.Scope("test", route, request, execRuntime, context);
|
||||
try {
|
||||
protocolExec.execute(request, scope, chain);
|
||||
@ -174,10 +169,10 @@ public void testPostProcessIOException() throws Exception {
|
||||
|
||||
final ClassicHttpResponse response = Mockito.mock(ClassicHttpResponse.class);
|
||||
Mockito.when(chain.proceed(
|
||||
Mockito.<ClassicHttpRequest>any(),
|
||||
Mockito.<ExecChain.Scope>any())).thenReturn(response);
|
||||
Mockito.any(),
|
||||
Mockito.any())).thenReturn(response);
|
||||
Mockito.doThrow(new IOException("Ooopsie")).when(httpProcessor).process(
|
||||
Mockito.same(response), Mockito.<EntityDetails>isNull(), Mockito.<HttpContext>any());
|
||||
Mockito.same(response), Mockito.isNull(), Mockito.any());
|
||||
final ExecChain.Scope scope = new ExecChain.Scope("test", route, request, execRuntime, context);
|
||||
try {
|
||||
protocolExec.execute(request, scope, chain);
|
||||
@ -195,10 +190,10 @@ public void testPostProcessRuntimeException() throws Exception {
|
||||
|
||||
final ClassicHttpResponse response = Mockito.mock(ClassicHttpResponse.class);
|
||||
Mockito.when(chain.proceed(
|
||||
Mockito.<ClassicHttpRequest>any(),
|
||||
Mockito.<ExecChain.Scope>any())).thenReturn(response);
|
||||
Mockito.any(),
|
||||
Mockito.any())).thenReturn(response);
|
||||
Mockito.doThrow(new RuntimeException("Ooopsie")).when(httpProcessor).process(
|
||||
Mockito.same(response), Mockito.<EntityDetails>isNull(), Mockito.<HttpContext>any());
|
||||
Mockito.same(response), Mockito.isNull(), Mockito.any());
|
||||
final ExecChain.Scope scope = new ExecChain.Scope("test", route, request, execRuntime, context);
|
||||
try {
|
||||
protocolExec.execute(request, scope, chain);
|
||||
@ -231,11 +226,11 @@ public void testExecRequestRetryOnAuthChallenge() throws Exception {
|
||||
|
||||
Mockito.when(chain.proceed(
|
||||
Mockito.same(request),
|
||||
Mockito.<ExecChain.Scope>any())).thenReturn(response1, response2);
|
||||
Mockito.any())).thenReturn(response1, response2);
|
||||
Mockito.when(targetAuthStrategy.select(
|
||||
Mockito.eq(ChallengeType.TARGET),
|
||||
Mockito.<Map<String, AuthChallenge>>any(),
|
||||
Mockito.<HttpClientContext>any())).thenReturn(Collections.<AuthScheme>singletonList(new BasicScheme()));
|
||||
Mockito.any(),
|
||||
Mockito.<HttpClientContext>any())).thenReturn(Collections.singletonList(new BasicScheme()));
|
||||
Mockito.when(execRuntime.isConnectionReusable()).thenReturn(true);
|
||||
|
||||
final ExecChain.Scope scope = new ExecChain.Scope("test", route, request, execRuntime, context);
|
||||
@ -277,12 +272,12 @@ public void testExecEntityEnclosingRequestRetryOnAuthChallenge() throws Exceptio
|
||||
|
||||
Mockito.when(chain.proceed(
|
||||
Mockito.same(request),
|
||||
Mockito.<ExecChain.Scope>any())).thenReturn(response1, response2);
|
||||
Mockito.any())).thenReturn(response1, response2);
|
||||
|
||||
Mockito.when(targetAuthStrategy.select(
|
||||
Mockito.eq(ChallengeType.TARGET),
|
||||
Mockito.<Map<String, AuthChallenge>>any(),
|
||||
Mockito.<HttpClientContext>any())).thenReturn(Collections.<AuthScheme>singletonList(new BasicScheme()));
|
||||
Mockito.any(),
|
||||
Mockito.<HttpClientContext>any())).thenReturn(Collections.singletonList(new BasicScheme()));
|
||||
|
||||
final ExecChain.Scope scope = new ExecChain.Scope("test", route, request, execRuntime, context);
|
||||
final ClassicHttpResponse finalResponse = protocolExec.execute(request, scope, chain);
|
||||
@ -317,7 +312,7 @@ public void testExecEntityEnclosingRequest() throws Exception {
|
||||
|
||||
Mockito.when(chain.proceed(
|
||||
Mockito.same(request),
|
||||
Mockito.<ExecChain.Scope>any())).thenAnswer((Answer<HttpResponse>) invocationOnMock -> {
|
||||
Mockito.any())).thenAnswer((Answer<HttpResponse>) invocationOnMock -> {
|
||||
final Object[] args = invocationOnMock.getArguments();
|
||||
final ClassicHttpRequest requestEE = (ClassicHttpRequest) args[0];
|
||||
requestEE.getEntity().writeTo(new ByteArrayOutputStream());
|
||||
|
@ -113,10 +113,10 @@ public void testFundamentals() throws Exception {
|
||||
|
||||
Mockito.when(chain.proceed(
|
||||
ArgumentMatchers.same(request),
|
||||
ArgumentMatchers.<ExecChain.Scope>any())).thenReturn(response1);
|
||||
ArgumentMatchers.any())).thenReturn(response1);
|
||||
Mockito.when(chain.proceed(
|
||||
HttpRequestMatcher.matchesRequestUri(redirect),
|
||||
ArgumentMatchers.<ExecChain.Scope>any())).thenReturn(response2);
|
||||
ArgumentMatchers.any())).thenReturn(response2);
|
||||
|
||||
final ExecChain.Scope scope = new ExecChain.Scope("test", route, request, endpoint, context);
|
||||
redirectExec.execute(request, scope, chain);
|
||||
@ -150,7 +150,7 @@ public void testMaxRedirect() throws Exception {
|
||||
final URI redirect = new URI("http://localhost:80/redirect");
|
||||
response1.setHeader(HttpHeaders.LOCATION, redirect.toASCIIString());
|
||||
|
||||
Mockito.when(chain.proceed(ArgumentMatchers.<ClassicHttpRequest>any(), ArgumentMatchers.<ExecChain.Scope>any())).thenReturn(response1);
|
||||
Mockito.when(chain.proceed(ArgumentMatchers.any(), ArgumentMatchers.any())).thenReturn(response1);
|
||||
|
||||
final ExecChain.Scope scope = new ExecChain.Scope("test", route, request, endpoint, context);
|
||||
redirectExec.execute(request, scope, chain);
|
||||
@ -167,7 +167,7 @@ public void testRelativeRedirect() throws Exception {
|
||||
response1.setHeader(HttpHeaders.LOCATION, redirect.toASCIIString());
|
||||
Mockito.when(chain.proceed(
|
||||
ArgumentMatchers.same(request),
|
||||
ArgumentMatchers.<ExecChain.Scope>any())).thenReturn(response1);
|
||||
ArgumentMatchers.any())).thenReturn(response1);
|
||||
|
||||
final ExecChain.Scope scope = new ExecChain.Scope("test", route, request, endpoint, context);
|
||||
redirectExec.execute(request, scope, chain);
|
||||
@ -197,10 +197,10 @@ public void testCrossSiteRedirect() throws Exception {
|
||||
final HttpHost otherHost = new HttpHost("otherhost", 8888);
|
||||
Mockito.when(chain.proceed(
|
||||
ArgumentMatchers.same(request),
|
||||
ArgumentMatchers.<ExecChain.Scope>any())).thenReturn(response1);
|
||||
ArgumentMatchers.any())).thenReturn(response1);
|
||||
Mockito.when(chain.proceed(
|
||||
HttpRequestMatcher.matchesRequestUri(redirect),
|
||||
ArgumentMatchers.<ExecChain.Scope>any())).thenReturn(response2);
|
||||
ArgumentMatchers.any())).thenReturn(response2);
|
||||
Mockito.when(httpRoutePlanner.determineRoute(
|
||||
ArgumentMatchers.eq(otherHost),
|
||||
ArgumentMatchers.<HttpClientContext>any())).thenReturn(new HttpRoute(otherHost));
|
||||
@ -241,13 +241,13 @@ public void testAllowCircularRedirects() throws Exception {
|
||||
|
||||
Mockito.when(chain.proceed(
|
||||
HttpRequestMatcher.matchesRequestUri(uri),
|
||||
ArgumentMatchers.<ExecChain.Scope>any())).thenReturn(response1);
|
||||
ArgumentMatchers.any())).thenReturn(response1);
|
||||
Mockito.when(chain.proceed(
|
||||
HttpRequestMatcher.matchesRequestUri(uri1),
|
||||
ArgumentMatchers.<ExecChain.Scope>any())).thenReturn(response2, response4);
|
||||
ArgumentMatchers.any())).thenReturn(response2, response4);
|
||||
Mockito.when(chain.proceed(
|
||||
HttpRequestMatcher.matchesRequestUri(uri2),
|
||||
ArgumentMatchers.<ExecChain.Scope>any())).thenReturn(response3);
|
||||
ArgumentMatchers.any())).thenReturn(response3);
|
||||
Mockito.when(httpRoutePlanner.determineRoute(
|
||||
ArgumentMatchers.eq(new HttpHost("localhost")),
|
||||
ArgumentMatchers.<HttpClientContext>any())).thenReturn(route);
|
||||
@ -285,13 +285,13 @@ public void testGetLocationUriDisallowCircularRedirects() throws Exception {
|
||||
|
||||
Mockito.when(chain.proceed(
|
||||
HttpRequestMatcher.matchesRequestUri(uri),
|
||||
ArgumentMatchers.<ExecChain.Scope>any())).thenReturn(response1);
|
||||
ArgumentMatchers.any())).thenReturn(response1);
|
||||
Mockito.when(chain.proceed(
|
||||
HttpRequestMatcher.matchesRequestUri(uri1),
|
||||
ArgumentMatchers.<ExecChain.Scope>any())).thenReturn(response2);
|
||||
ArgumentMatchers.any())).thenReturn(response2);
|
||||
Mockito.when(chain.proceed(
|
||||
HttpRequestMatcher.matchesRequestUri(uri2),
|
||||
ArgumentMatchers.<ExecChain.Scope>any())).thenReturn(response3);
|
||||
ArgumentMatchers.any())).thenReturn(response3);
|
||||
|
||||
final ExecChain.Scope scope = new ExecChain.Scope("test", route, request, endpoint, context);
|
||||
redirectExec.execute(request, scope, chain);
|
||||
@ -308,7 +308,7 @@ public void testRedirectRuntimeException() throws Exception {
|
||||
response1.setHeader(HttpHeaders.LOCATION, redirect.toASCIIString());
|
||||
Mockito.when(chain.proceed(
|
||||
ArgumentMatchers.same(request),
|
||||
ArgumentMatchers.<ExecChain.Scope>any())).thenReturn(response1);
|
||||
ArgumentMatchers.any())).thenReturn(response1);
|
||||
Mockito.doThrow(new RuntimeException("Oppsie")).when(redirectStrategy).getLocationURI(
|
||||
ArgumentMatchers.<ClassicHttpRequest>any(),
|
||||
ArgumentMatchers.<ClassicHttpResponse>any(),
|
||||
@ -339,7 +339,7 @@ public void testRedirectProtocolException() throws Exception {
|
||||
response1.setEntity(entity1);
|
||||
Mockito.when(chain.proceed(
|
||||
ArgumentMatchers.same(request),
|
||||
ArgumentMatchers.<ExecChain.Scope>any())).thenReturn(response1);
|
||||
ArgumentMatchers.any())).thenReturn(response1);
|
||||
Mockito.doThrow(new ProtocolException("Oppsie")).when(redirectStrategy).getLocationURI(
|
||||
ArgumentMatchers.<ClassicHttpRequest>any(),
|
||||
ArgumentMatchers.<ClassicHttpResponse>any(),
|
||||
|
@ -35,7 +35,6 @@
|
||||
import org.apache.hc.client5.http.cookie.Cookie;
|
||||
import org.apache.hc.client5.http.cookie.CookieOrigin;
|
||||
import org.apache.hc.client5.http.cookie.MalformedCookieException;
|
||||
import org.apache.hc.client5.http.cookie.SetCookie;
|
||||
import org.apache.hc.core5.http.Header;
|
||||
import org.apache.hc.core5.http.message.BasicHeader;
|
||||
import org.junit.Assert;
|
||||
@ -67,8 +66,8 @@ public void testParseCookieBasics() throws Exception {
|
||||
Assert.assertEquals("stuff", cookie.getAttribute("this"));
|
||||
Assert.assertEquals(null, cookie.getAttribute("that"));
|
||||
|
||||
Mockito.verify(h1).parse(ArgumentMatchers.<SetCookie>any(), ArgumentMatchers.eq("stuff"));
|
||||
Mockito.verify(h2, Mockito.never()).parse(ArgumentMatchers.<SetCookie>any(), ArgumentMatchers.anyString());
|
||||
Mockito.verify(h1).parse(ArgumentMatchers.any(), ArgumentMatchers.eq("stuff"));
|
||||
Mockito.verify(h2, Mockito.never()).parse(ArgumentMatchers.any(), ArgumentMatchers.anyString());
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -298,8 +297,8 @@ public void testParseCookieMultipleAttributes() throws Exception {
|
||||
final CookieOrigin origin = new CookieOrigin("host", 80, "/path/", true);
|
||||
cookiespec.parse(header, origin);
|
||||
|
||||
Mockito.verify(h1).parse(ArgumentMatchers.<SetCookie>any(), ArgumentMatchers.eq("morestuff"));
|
||||
Mockito.verify(h1, Mockito.times(1)).parse(ArgumentMatchers.<SetCookie>any(), ArgumentMatchers.anyString());
|
||||
Mockito.verify(h1).parse(ArgumentMatchers.any(), ArgumentMatchers.eq("morestuff"));
|
||||
Mockito.verify(h1, Mockito.times(1)).parse(ArgumentMatchers.any(), ArgumentMatchers.anyString());
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -315,8 +314,8 @@ public void testParseCookieMaxAgeOverExpires() throws Exception {
|
||||
final CookieOrigin origin = new CookieOrigin("host", 80, "/path/", true);
|
||||
cookiespec.parse(header, origin);
|
||||
|
||||
Mockito.verify(h1, Mockito.never()).parse(ArgumentMatchers.<SetCookie>any(), ArgumentMatchers.anyString());
|
||||
Mockito.verify(h2).parse(ArgumentMatchers.<SetCookie>any(), ArgumentMatchers.eq("otherstuff"));
|
||||
Mockito.verify(h1, Mockito.never()).parse(ArgumentMatchers.any(), ArgumentMatchers.anyString());
|
||||
Mockito.verify(h2).parse(ArgumentMatchers.any(), ArgumentMatchers.eq("otherstuff"));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -44,7 +44,6 @@
|
||||
import org.apache.hc.core5.http.config.Lookup;
|
||||
import org.apache.hc.core5.http.io.HttpConnectionFactory;
|
||||
import org.apache.hc.core5.http.io.SocketConfig;
|
||||
import org.apache.hc.core5.http.protocol.HttpContext;
|
||||
import org.apache.hc.core5.io.CloseMode;
|
||||
import org.apache.hc.core5.util.TimeValue;
|
||||
import org.apache.hc.core5.util.Timeout;
|
||||
@ -90,7 +89,7 @@ public void testLeaseReleaseNonReusable() throws Exception {
|
||||
final HttpHost target = new HttpHost("localhost", 80);
|
||||
final HttpRoute route = new HttpRoute(target);
|
||||
|
||||
Mockito.when(connFactory.createConnection(Mockito.<Socket>any())).thenReturn(conn);
|
||||
Mockito.when(connFactory.createConnection(Mockito.any())).thenReturn(conn);
|
||||
|
||||
final LeaseRequest connRequest1 = mgr.lease("some-id", route, null);
|
||||
final ConnectionEndpoint endpoint1 = connRequest1.get(Timeout.ZERO_MILLISECONDS);
|
||||
@ -107,7 +106,7 @@ public void testLeaseReleaseNonReusable() throws Exception {
|
||||
Assert.assertNotNull(conn2);
|
||||
Assert.assertFalse(conn2.isConnected());
|
||||
|
||||
Mockito.verify(connFactory, Mockito.times(2)).createConnection(Mockito.<Socket>any());
|
||||
Mockito.verify(connFactory, Mockito.times(2)).createConnection(Mockito.any());
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -115,13 +114,13 @@ public void testLeaseReleaseReusable() throws Exception {
|
||||
final HttpHost target = new HttpHost("somehost", 80);
|
||||
final HttpRoute route = new HttpRoute(target);
|
||||
|
||||
Mockito.when(connFactory.createConnection(Mockito.<Socket>any())).thenReturn(conn);
|
||||
Mockito.when(connFactory.createConnection(Mockito.any())).thenReturn(conn);
|
||||
|
||||
final LeaseRequest connRequest1 = mgr.lease("some-id", route, null);
|
||||
final ConnectionEndpoint endpoint1 = connRequest1.get(Timeout.ZERO_MILLISECONDS);
|
||||
Assert.assertNotNull(endpoint1);
|
||||
|
||||
Mockito.verify(connFactory, Mockito.times(1)).createConnection(Mockito.<Socket>any());
|
||||
Mockito.verify(connFactory, Mockito.times(1)).createConnection(Mockito.any());
|
||||
|
||||
Mockito.when(conn.isOpen()).thenReturn(Boolean.TRUE);
|
||||
|
||||
@ -135,7 +134,7 @@ public void testLeaseReleaseReusable() throws Exception {
|
||||
Assert.assertNotNull(conn2);
|
||||
Assert.assertTrue(conn2.isConnected());
|
||||
|
||||
Mockito.verify(connFactory, Mockito.times(1)).createConnection(Mockito.<Socket>any());
|
||||
Mockito.verify(connFactory, Mockito.times(1)).createConnection(Mockito.any());
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -143,13 +142,13 @@ public void testLeaseReleaseReusableWithState() throws Exception {
|
||||
final HttpHost target = new HttpHost("somehost", 80);
|
||||
final HttpRoute route = new HttpRoute(target);
|
||||
|
||||
Mockito.when(connFactory.createConnection(Mockito.<Socket>any())).thenReturn(conn);
|
||||
Mockito.when(connFactory.createConnection(Mockito.any())).thenReturn(conn);
|
||||
|
||||
final LeaseRequest connRequest1 = mgr.lease("some-id", route, "some state");
|
||||
final ConnectionEndpoint endpoint1 = connRequest1.get(Timeout.ZERO_MILLISECONDS);
|
||||
Assert.assertNotNull(endpoint1);
|
||||
|
||||
Mockito.verify(connFactory, Mockito.times(1)).createConnection(Mockito.<Socket>any());
|
||||
Mockito.verify(connFactory, Mockito.times(1)).createConnection(Mockito.any());
|
||||
|
||||
Mockito.when(conn.isOpen()).thenReturn(Boolean.TRUE);
|
||||
|
||||
@ -163,7 +162,7 @@ public void testLeaseReleaseReusableWithState() throws Exception {
|
||||
Assert.assertNotNull(conn2);
|
||||
Assert.assertTrue(conn2.isConnected());
|
||||
|
||||
Mockito.verify(connFactory, Mockito.times(1)).createConnection(Mockito.<Socket>any());
|
||||
Mockito.verify(connFactory, Mockito.times(1)).createConnection(Mockito.any());
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -171,13 +170,13 @@ public void testLeaseDifferentRoute() throws Exception {
|
||||
final HttpHost target1 = new HttpHost("somehost", 80);
|
||||
final HttpRoute route1 = new HttpRoute(target1);
|
||||
|
||||
Mockito.when(connFactory.createConnection(Mockito.<Socket>any())).thenReturn(conn);
|
||||
Mockito.when(connFactory.createConnection(Mockito.any())).thenReturn(conn);
|
||||
|
||||
final LeaseRequest connRequest1 = mgr.lease("some-id", route1, null);
|
||||
final ConnectionEndpoint endpoint1 = connRequest1.get(Timeout.ZERO_MILLISECONDS);
|
||||
Assert.assertNotNull(endpoint1);
|
||||
|
||||
Mockito.verify(connFactory, Mockito.times(1)).createConnection(Mockito.<Socket>any());
|
||||
Mockito.verify(connFactory, Mockito.times(1)).createConnection(Mockito.any());
|
||||
|
||||
Mockito.when(conn.isOpen()).thenReturn(Boolean.TRUE, Boolean.FALSE);
|
||||
|
||||
@ -194,7 +193,7 @@ public void testLeaseDifferentRoute() throws Exception {
|
||||
Assert.assertFalse(conn2.isConnected());
|
||||
|
||||
Mockito.verify(conn).close(CloseMode.GRACEFUL);
|
||||
Mockito.verify(connFactory, Mockito.times(2)).createConnection(Mockito.<Socket>any());
|
||||
Mockito.verify(connFactory, Mockito.times(2)).createConnection(Mockito.any());
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -202,13 +201,13 @@ public void testLeaseExpired() throws Exception {
|
||||
final HttpHost target = new HttpHost("somehost", 80);
|
||||
final HttpRoute route = new HttpRoute(target);
|
||||
|
||||
Mockito.when(connFactory.createConnection(Mockito.<Socket>any())).thenReturn(conn);
|
||||
Mockito.when(connFactory.createConnection(Mockito.any())).thenReturn(conn);
|
||||
|
||||
final LeaseRequest connRequest1 = mgr.lease("some-id", route, null);
|
||||
final ConnectionEndpoint endpoint1 = connRequest1.get(Timeout.ZERO_MILLISECONDS);
|
||||
Assert.assertNotNull(endpoint1);
|
||||
|
||||
Mockito.verify(connFactory, Mockito.times(1)).createConnection(Mockito.<Socket>any());
|
||||
Mockito.verify(connFactory, Mockito.times(1)).createConnection(Mockito.any());
|
||||
|
||||
Mockito.when(conn.isOpen()).thenReturn(Boolean.TRUE, Boolean.FALSE);
|
||||
|
||||
@ -225,7 +224,7 @@ public void testLeaseExpired() throws Exception {
|
||||
Assert.assertFalse(conn2.isConnected());
|
||||
|
||||
Mockito.verify(conn).close(CloseMode.GRACEFUL);
|
||||
Mockito.verify(connFactory, Mockito.times(2)).createConnection(Mockito.<Socket>any());
|
||||
Mockito.verify(connFactory, Mockito.times(2)).createConnection(Mockito.any());
|
||||
}
|
||||
|
||||
@Test(expected=NullPointerException.class)
|
||||
@ -244,13 +243,13 @@ public void testShutdown() throws Exception {
|
||||
final HttpHost target = new HttpHost("somehost", 80);
|
||||
final HttpRoute route = new HttpRoute(target);
|
||||
|
||||
Mockito.when(connFactory.createConnection(Mockito.<Socket>any())).thenReturn(conn);
|
||||
Mockito.when(connFactory.createConnection(Mockito.any())).thenReturn(conn);
|
||||
|
||||
final LeaseRequest connRequest1 = mgr.lease("some-id", route, null);
|
||||
final ConnectionEndpoint endpoint1 = connRequest1.get(Timeout.ZERO_MILLISECONDS);
|
||||
Assert.assertNotNull(endpoint1);
|
||||
|
||||
Mockito.verify(connFactory, Mockito.times(1)).createConnection(Mockito.<Socket>any());
|
||||
Mockito.verify(connFactory, Mockito.times(1)).createConnection(Mockito.any());
|
||||
|
||||
Mockito.when(conn.isOpen()).thenReturn(Boolean.TRUE);
|
||||
|
||||
@ -280,13 +279,13 @@ public void testCloseExpired() throws Exception {
|
||||
final HttpHost target = new HttpHost("somehost", 80);
|
||||
final HttpRoute route = new HttpRoute(target);
|
||||
|
||||
Mockito.when(connFactory.createConnection(Mockito.<Socket>any())).thenReturn(conn);
|
||||
Mockito.when(connFactory.createConnection(Mockito.any())).thenReturn(conn);
|
||||
|
||||
final LeaseRequest connRequest1 = mgr.lease("some-id", route, null);
|
||||
final ConnectionEndpoint endpoint1 = connRequest1.get(Timeout.ZERO_MILLISECONDS);
|
||||
Assert.assertNotNull(endpoint1);
|
||||
|
||||
Mockito.verify(connFactory, Mockito.times(1)).createConnection(Mockito.<Socket>any());
|
||||
Mockito.verify(connFactory, Mockito.times(1)).createConnection(Mockito.any());
|
||||
|
||||
Mockito.when(conn.isOpen()).thenReturn(Boolean.TRUE, Boolean.FALSE);
|
||||
|
||||
@ -307,13 +306,13 @@ public void testCloseIdle() throws Exception {
|
||||
final HttpHost target = new HttpHost("somehost", 80);
|
||||
final HttpRoute route = new HttpRoute(target);
|
||||
|
||||
Mockito.when(connFactory.createConnection(Mockito.<Socket>any())).thenReturn(conn);
|
||||
Mockito.when(connFactory.createConnection(Mockito.any())).thenReturn(conn);
|
||||
|
||||
final LeaseRequest connRequest1 = mgr.lease("some-id", route, null);
|
||||
final ConnectionEndpoint endpoint1 = connRequest1.get(Timeout.ZERO_MILLISECONDS);
|
||||
Assert.assertNotNull(endpoint1);
|
||||
|
||||
Mockito.verify(connFactory, Mockito.times(1)).createConnection(Mockito.<Socket>any());
|
||||
Mockito.verify(connFactory, Mockito.times(1)).createConnection(Mockito.any());
|
||||
|
||||
Mockito.when(conn.isOpen()).thenReturn(Boolean.TRUE, Boolean.FALSE);
|
||||
|
||||
@ -334,7 +333,7 @@ public void testAlreadyLeased() throws Exception {
|
||||
final HttpHost target = new HttpHost("somehost", 80);
|
||||
final HttpRoute route = new HttpRoute(target);
|
||||
|
||||
Mockito.when(connFactory.createConnection(Mockito.<Socket>any())).thenReturn(conn);
|
||||
Mockito.when(connFactory.createConnection(Mockito.any())).thenReturn(conn);
|
||||
|
||||
final LeaseRequest connRequest1 = mgr.lease("some-id", route, null);
|
||||
final ConnectionEndpoint endpoint1 = connRequest1.get(Timeout.ZERO_MILLISECONDS);
|
||||
@ -352,7 +351,7 @@ public void testTargetConnect() throws Exception {
|
||||
final InetAddress local = InetAddress.getByAddress(new byte[] {127, 0, 0, 1});
|
||||
final HttpRoute route = new HttpRoute(target, local, true);
|
||||
|
||||
Mockito.when(connFactory.createConnection(Mockito.<Socket>any())).thenReturn(conn);
|
||||
Mockito.when(connFactory.createConnection(Mockito.any())).thenReturn(conn);
|
||||
|
||||
final LeaseRequest connRequest1 = mgr.lease("some-id", route, null);
|
||||
final ConnectionEndpoint endpoint1 = connRequest1.get(Timeout.ZERO_MILLISECONDS);
|
||||
@ -366,14 +365,14 @@ public void testTargetConnect() throws Exception {
|
||||
Mockito.when(dnsResolver.resolve("somehost")).thenReturn(new InetAddress[] {remote});
|
||||
Mockito.when(schemePortResolver.resolve(target)).thenReturn(8443);
|
||||
Mockito.when(socketFactoryRegistry.lookup("https")).thenReturn(plainSocketFactory);
|
||||
Mockito.when(plainSocketFactory.createSocket(Mockito.<HttpContext>any())).thenReturn(socket);
|
||||
Mockito.when(plainSocketFactory.createSocket(Mockito.any())).thenReturn(socket);
|
||||
Mockito.when(plainSocketFactory.connectSocket(
|
||||
Mockito.<TimeValue>any(),
|
||||
Mockito.any(),
|
||||
Mockito.eq(socket),
|
||||
Mockito.<HttpHost>any(),
|
||||
Mockito.<InetSocketAddress>any(),
|
||||
Mockito.<InetSocketAddress>any(),
|
||||
Mockito.<HttpContext>any())).thenReturn(socket);
|
||||
Mockito.any(),
|
||||
Mockito.any(),
|
||||
Mockito.any(),
|
||||
Mockito.any())).thenReturn(socket);
|
||||
|
||||
mgr.connect(endpoint1, TimeValue.ofMilliseconds(123), context);
|
||||
|
||||
@ -393,7 +392,7 @@ public void testProxyConnectAndUpgrade() throws Exception {
|
||||
final InetAddress local = InetAddress.getByAddress(new byte[] {127, 0, 0, 1});
|
||||
final HttpRoute route = new HttpRoute(target, local, proxy, true);
|
||||
|
||||
Mockito.when(connFactory.createConnection(Mockito.<Socket>any())).thenReturn(conn);
|
||||
Mockito.when(connFactory.createConnection(Mockito.any())).thenReturn(conn);
|
||||
|
||||
final LeaseRequest connRequest1 = mgr.lease("some-id", route, null);
|
||||
final ConnectionEndpoint endpoint1 = connRequest1.get(Timeout.ZERO_MILLISECONDS);
|
||||
@ -409,14 +408,14 @@ public void testProxyConnectAndUpgrade() throws Exception {
|
||||
Mockito.when(schemePortResolver.resolve(target)).thenReturn(8443);
|
||||
Mockito.when(socketFactoryRegistry.lookup("http")).thenReturn(plainSocketFactory);
|
||||
Mockito.when(socketFactoryRegistry.lookup("https")).thenReturn(sslSocketFactory);
|
||||
Mockito.when(plainSocketFactory.createSocket(Mockito.<HttpContext>any())).thenReturn(socket);
|
||||
Mockito.when(plainSocketFactory.createSocket(Mockito.any())).thenReturn(socket);
|
||||
Mockito.when(plainSocketFactory.connectSocket(
|
||||
Mockito.<TimeValue>any(),
|
||||
Mockito.any(),
|
||||
Mockito.eq(socket),
|
||||
Mockito.<HttpHost>any(),
|
||||
Mockito.<InetSocketAddress>any(),
|
||||
Mockito.<InetSocketAddress>any(),
|
||||
Mockito.<HttpContext>any())).thenReturn(socket);
|
||||
Mockito.any(),
|
||||
Mockito.any(),
|
||||
Mockito.any(),
|
||||
Mockito.any())).thenReturn(socket);
|
||||
|
||||
mgr.connect(endpoint1, TimeValue.ofMilliseconds(123), context);
|
||||
|
||||
|
@ -88,14 +88,14 @@ public void testConnect() throws Exception {
|
||||
Mockito.when(dnsResolver.resolve("somehost")).thenReturn(new InetAddress[] { ip1, ip2 });
|
||||
Mockito.when(socketFactoryRegistry.lookup("http")).thenReturn(plainSocketFactory);
|
||||
Mockito.when(schemePortResolver.resolve(host)).thenReturn(80);
|
||||
Mockito.when(plainSocketFactory.createSocket(Mockito.<HttpContext>any())).thenReturn(socket);
|
||||
Mockito.when(plainSocketFactory.createSocket(Mockito.any())).thenReturn(socket);
|
||||
Mockito.when(plainSocketFactory.connectSocket(
|
||||
Mockito.<TimeValue>any(),
|
||||
Mockito.<Socket>any(),
|
||||
Mockito.<HttpHost>any(),
|
||||
Mockito.<InetSocketAddress>any(),
|
||||
Mockito.<InetSocketAddress>any(),
|
||||
Mockito.<HttpContext>any())).thenReturn(socket);
|
||||
Mockito.any(),
|
||||
Mockito.any(),
|
||||
Mockito.any(),
|
||||
Mockito.any(),
|
||||
Mockito.any(),
|
||||
Mockito.any())).thenReturn(socket);
|
||||
|
||||
final SocketConfig socketConfig = SocketConfig.custom()
|
||||
.setSoKeepAlive(true)
|
||||
@ -133,14 +133,14 @@ public void testConnectTimeout() throws Exception {
|
||||
Mockito.when(dnsResolver.resolve("somehost")).thenReturn(new InetAddress[] { ip1, ip2 });
|
||||
Mockito.when(socketFactoryRegistry.lookup("http")).thenReturn(plainSocketFactory);
|
||||
Mockito.when(schemePortResolver.resolve(host)).thenReturn(80);
|
||||
Mockito.when(plainSocketFactory.createSocket(Mockito.<HttpContext>any())).thenReturn(socket);
|
||||
Mockito.when(plainSocketFactory.createSocket(Mockito.any())).thenReturn(socket);
|
||||
Mockito.when(plainSocketFactory.connectSocket(
|
||||
Mockito.<TimeValue>any(),
|
||||
Mockito.<Socket>any(),
|
||||
Mockito.<HttpHost>any(),
|
||||
Mockito.<InetSocketAddress>any(),
|
||||
Mockito.<InetSocketAddress>any(),
|
||||
Mockito.<HttpContext>any())).thenThrow(new SocketTimeoutException());
|
||||
Mockito.any(),
|
||||
Mockito.any(),
|
||||
Mockito.any(),
|
||||
Mockito.any(),
|
||||
Mockito.any(),
|
||||
Mockito.any())).thenThrow(new SocketTimeoutException());
|
||||
|
||||
connectionOperator.connect(conn, host, null, TimeValue.ofMilliseconds(1000), SocketConfig.DEFAULT, context);
|
||||
}
|
||||
@ -155,14 +155,14 @@ public void testConnectFailure() throws Exception {
|
||||
Mockito.when(dnsResolver.resolve("somehost")).thenReturn(new InetAddress[] { ip1, ip2 });
|
||||
Mockito.when(socketFactoryRegistry.lookup("http")).thenReturn(plainSocketFactory);
|
||||
Mockito.when(schemePortResolver.resolve(host)).thenReturn(80);
|
||||
Mockito.when(plainSocketFactory.createSocket(Mockito.<HttpContext>any())).thenReturn(socket);
|
||||
Mockito.when(plainSocketFactory.createSocket(Mockito.any())).thenReturn(socket);
|
||||
Mockito.when(plainSocketFactory.connectSocket(
|
||||
Mockito.<TimeValue>any(),
|
||||
Mockito.<Socket>any(),
|
||||
Mockito.<HttpHost>any(),
|
||||
Mockito.<InetSocketAddress>any(),
|
||||
Mockito.<InetSocketAddress>any(),
|
||||
Mockito.<HttpContext>any())).thenThrow(new ConnectException());
|
||||
Mockito.any(),
|
||||
Mockito.any(),
|
||||
Mockito.any(),
|
||||
Mockito.any(),
|
||||
Mockito.any(),
|
||||
Mockito.any())).thenThrow(new ConnectException());
|
||||
|
||||
connectionOperator.connect(conn, host, null, TimeValue.ofMilliseconds(1000), SocketConfig.DEFAULT, context);
|
||||
}
|
||||
@ -178,21 +178,21 @@ public void testConnectFailover() throws Exception {
|
||||
Mockito.when(dnsResolver.resolve("somehost")).thenReturn(new InetAddress[] { ip1, ip2 });
|
||||
Mockito.when(socketFactoryRegistry.lookup("http")).thenReturn(plainSocketFactory);
|
||||
Mockito.when(schemePortResolver.resolve(host)).thenReturn(80);
|
||||
Mockito.when(plainSocketFactory.createSocket(Mockito.<HttpContext>any())).thenReturn(socket);
|
||||
Mockito.when(plainSocketFactory.createSocket(Mockito.any())).thenReturn(socket);
|
||||
Mockito.when(plainSocketFactory.connectSocket(
|
||||
Mockito.<TimeValue>any(),
|
||||
Mockito.<Socket>any(),
|
||||
Mockito.<HttpHost>any(),
|
||||
Mockito.any(),
|
||||
Mockito.any(),
|
||||
Mockito.any(),
|
||||
Mockito.eq(new InetSocketAddress(ip1, 80)),
|
||||
Mockito.<InetSocketAddress>any(),
|
||||
Mockito.<HttpContext>any())).thenThrow(new ConnectException());
|
||||
Mockito.any(),
|
||||
Mockito.any())).thenThrow(new ConnectException());
|
||||
Mockito.when(plainSocketFactory.connectSocket(
|
||||
Mockito.<TimeValue>any(),
|
||||
Mockito.<Socket>any(),
|
||||
Mockito.<HttpHost>any(),
|
||||
Mockito.any(),
|
||||
Mockito.any(),
|
||||
Mockito.any(),
|
||||
Mockito.eq(new InetSocketAddress(ip2, 80)),
|
||||
Mockito.<InetSocketAddress>any(),
|
||||
Mockito.<HttpContext>any())).thenReturn(socket);
|
||||
Mockito.any(),
|
||||
Mockito.any())).thenReturn(socket);
|
||||
|
||||
final InetSocketAddress localAddress = new InetSocketAddress(local, 0);
|
||||
connectionOperator.connect(conn, host, localAddress, TimeValue.ofMilliseconds(1000), SocketConfig.DEFAULT, context);
|
||||
@ -216,14 +216,14 @@ public void testConnectExplicitAddress() throws Exception {
|
||||
|
||||
Mockito.when(socketFactoryRegistry.lookup("http")).thenReturn(plainSocketFactory);
|
||||
Mockito.when(schemePortResolver.resolve(host)).thenReturn(80);
|
||||
Mockito.when(plainSocketFactory.createSocket(Mockito.<HttpContext>any())).thenReturn(socket);
|
||||
Mockito.when(plainSocketFactory.createSocket(Mockito.any())).thenReturn(socket);
|
||||
Mockito.when(plainSocketFactory.connectSocket(
|
||||
Mockito.<TimeValue>any(),
|
||||
Mockito.<Socket>any(),
|
||||
Mockito.<HttpHost>any(),
|
||||
Mockito.<InetSocketAddress>any(),
|
||||
Mockito.<InetSocketAddress>any(),
|
||||
Mockito.<HttpContext>any())).thenReturn(socket);
|
||||
Mockito.any(),
|
||||
Mockito.any(),
|
||||
Mockito.any(),
|
||||
Mockito.any(),
|
||||
Mockito.any(),
|
||||
Mockito.any())).thenReturn(socket);
|
||||
|
||||
final InetSocketAddress localAddress = new InetSocketAddress(local, 0);
|
||||
connectionOperator.connect(conn, host, localAddress, TimeValue.ofMilliseconds(1000), SocketConfig.DEFAULT, context);
|
||||
@ -248,12 +248,12 @@ public void testUpgrade() throws Exception {
|
||||
Mockito.when(conn.getSocket()).thenReturn(socket);
|
||||
Mockito.when(socketFactoryRegistry.lookup("https")).thenReturn(sslSocketFactory);
|
||||
Mockito.when(schemePortResolver.resolve(host)).thenReturn(443);
|
||||
Mockito.when(sslSocketFactory.createSocket(Mockito.<HttpContext>any())).thenReturn(socket);
|
||||
Mockito.when(sslSocketFactory.createSocket(Mockito.any())).thenReturn(socket);
|
||||
Mockito.when(sslSocketFactory.createLayeredSocket(
|
||||
Mockito.<Socket>any(),
|
||||
Mockito.any(),
|
||||
Mockito.eq("somehost"),
|
||||
Mockito.eq(443),
|
||||
Mockito.<HttpContext>any())).thenReturn(socket);
|
||||
Mockito.any())).thenReturn(socket);
|
||||
|
||||
connectionOperator.upgrade(conn, host, context);
|
||||
|
||||
|
@ -44,11 +44,9 @@
|
||||
import org.apache.hc.client5.http.protocol.HttpClientContext;
|
||||
import org.apache.hc.client5.http.socket.ConnectionSocketFactory;
|
||||
import org.apache.hc.client5.http.socket.LayeredConnectionSocketFactory;
|
||||
import org.apache.hc.core5.concurrent.FutureCallback;
|
||||
import org.apache.hc.core5.http.HttpHost;
|
||||
import org.apache.hc.core5.http.config.Lookup;
|
||||
import org.apache.hc.core5.http.io.SocketConfig;
|
||||
import org.apache.hc.core5.http.protocol.HttpContext;
|
||||
import org.apache.hc.core5.pool.PoolEntry;
|
||||
import org.apache.hc.core5.pool.StrictConnPool;
|
||||
import org.apache.hc.core5.util.TimeValue;
|
||||
@ -111,8 +109,8 @@ public void testLeaseRelease() throws Exception {
|
||||
Mockito.when(pool.lease(
|
||||
Mockito.eq(route),
|
||||
Mockito.eq(null),
|
||||
Mockito.<Timeout>any(),
|
||||
Mockito.<FutureCallback<PoolEntry<HttpRoute, ManagedHttpClientConnection>>>eq(null)))
|
||||
Mockito.any(),
|
||||
Mockito.eq(null)))
|
||||
.thenReturn(future);
|
||||
|
||||
final LeaseRequest connRequest1 = mgr.lease("some-id", route, null);
|
||||
@ -139,8 +137,8 @@ public void testReleaseRouteIncomplete() throws Exception {
|
||||
Mockito.when(pool.lease(
|
||||
Mockito.eq(route),
|
||||
Mockito.eq(null),
|
||||
Mockito.<Timeout>any(),
|
||||
Mockito.<FutureCallback<PoolEntry<HttpRoute, ManagedHttpClientConnection>>>eq(null)))
|
||||
Mockito.any(),
|
||||
Mockito.eq(null)))
|
||||
.thenReturn(future);
|
||||
|
||||
final LeaseRequest connRequest1 = mgr.lease("some-id", route, null);
|
||||
@ -166,8 +164,8 @@ public void testLeaseFutureCancelled() throws Exception {
|
||||
Mockito.when(pool.lease(
|
||||
Mockito.eq(route),
|
||||
Mockito.eq(null),
|
||||
Mockito.<Timeout>any(),
|
||||
Mockito.<FutureCallback<PoolEntry<HttpRoute, ManagedHttpClientConnection>>>eq(null)))
|
||||
Mockito.any(),
|
||||
Mockito.eq(null)))
|
||||
.thenReturn(future);
|
||||
|
||||
final LeaseRequest connRequest1 = mgr.lease("some-id", route, null);
|
||||
@ -183,8 +181,8 @@ public void testLeaseFutureTimeout() throws Exception {
|
||||
Mockito.when(pool.lease(
|
||||
Mockito.eq(route),
|
||||
Mockito.eq(null),
|
||||
Mockito.<Timeout>any(),
|
||||
Mockito.<FutureCallback<PoolEntry<HttpRoute, ManagedHttpClientConnection>>>eq(null)))
|
||||
Mockito.any(),
|
||||
Mockito.eq(null)))
|
||||
.thenReturn(future);
|
||||
|
||||
final LeaseRequest connRequest1 = mgr.lease("some-id", route, null);
|
||||
@ -204,8 +202,8 @@ public void testReleaseReusable() throws Exception {
|
||||
Mockito.when(pool.lease(
|
||||
Mockito.eq(route),
|
||||
Mockito.eq(null),
|
||||
Mockito.<Timeout>any(),
|
||||
Mockito.<FutureCallback<PoolEntry<HttpRoute, ManagedHttpClientConnection>>>eq(null)))
|
||||
Mockito.any(),
|
||||
Mockito.eq(null)))
|
||||
.thenReturn(future);
|
||||
Mockito.when(conn.isOpen()).thenReturn(true);
|
||||
Mockito.when(conn.isConsistent()).thenReturn(true);
|
||||
@ -234,8 +232,8 @@ public void testReleaseNonReusable() throws Exception {
|
||||
Mockito.when(pool.lease(
|
||||
Mockito.eq(route),
|
||||
Mockito.eq(null),
|
||||
Mockito.<Timeout>any(),
|
||||
Mockito.<FutureCallback<PoolEntry<HttpRoute, ManagedHttpClientConnection>>>eq(null)))
|
||||
Mockito.any(),
|
||||
Mockito.eq(null)))
|
||||
.thenReturn(future);
|
||||
Mockito.when(conn.isOpen()).thenReturn(Boolean.FALSE);
|
||||
|
||||
@ -267,8 +265,8 @@ public void testTargetConnect() throws Exception {
|
||||
Mockito.when(pool.lease(
|
||||
Mockito.eq(route),
|
||||
Mockito.eq(null),
|
||||
Mockito.<Timeout>any(),
|
||||
Mockito.<FutureCallback<PoolEntry<HttpRoute, ManagedHttpClientConnection>>>eq(null)))
|
||||
Mockito.any(),
|
||||
Mockito.eq(null)))
|
||||
.thenReturn(future);
|
||||
|
||||
final LeaseRequest connRequest1 = mgr.lease("some-id", route, null);
|
||||
@ -283,14 +281,14 @@ public void testTargetConnect() throws Exception {
|
||||
Mockito.when(dnsResolver.resolve("somehost")).thenReturn(new InetAddress[]{remote});
|
||||
Mockito.when(schemePortResolver.resolve(target)).thenReturn(8443);
|
||||
Mockito.when(socketFactoryRegistry.lookup("https")).thenReturn(plainSocketFactory);
|
||||
Mockito.when(plainSocketFactory.createSocket(Mockito.<HttpContext>any())).thenReturn(socket);
|
||||
Mockito.when(plainSocketFactory.createSocket(Mockito.any())).thenReturn(socket);
|
||||
Mockito.when(plainSocketFactory.connectSocket(
|
||||
Mockito.<TimeValue>any(),
|
||||
Mockito.any(),
|
||||
Mockito.eq(socket),
|
||||
Mockito.<HttpHost>any(),
|
||||
Mockito.<InetSocketAddress>any(),
|
||||
Mockito.<InetSocketAddress>any(),
|
||||
Mockito.<HttpContext>any())).thenReturn(socket);
|
||||
Mockito.any(),
|
||||
Mockito.any(),
|
||||
Mockito.any(),
|
||||
Mockito.any())).thenReturn(socket);
|
||||
|
||||
mgr.connect(endpoint1, TimeValue.ofMilliseconds(123), context);
|
||||
|
||||
@ -320,8 +318,8 @@ public void testProxyConnectAndUpgrade() throws Exception {
|
||||
Mockito.when(pool.lease(
|
||||
Mockito.eq(route),
|
||||
Mockito.eq(null),
|
||||
Mockito.<Timeout>any(),
|
||||
Mockito.<FutureCallback<PoolEntry<HttpRoute, ManagedHttpClientConnection>>>eq(null)))
|
||||
Mockito.any(),
|
||||
Mockito.eq(null)))
|
||||
.thenReturn(future);
|
||||
|
||||
final LeaseRequest connRequest1 = mgr.lease("some-id", route, null);
|
||||
@ -341,14 +339,14 @@ public void testProxyConnectAndUpgrade() throws Exception {
|
||||
Mockito.when(schemePortResolver.resolve(target)).thenReturn(8443);
|
||||
Mockito.when(socketFactoryRegistry.lookup("http")).thenReturn(plainsf);
|
||||
Mockito.when(socketFactoryRegistry.lookup("https")).thenReturn(sslsf);
|
||||
Mockito.when(plainsf.createSocket(Mockito.<HttpContext>any())).thenReturn(mockSock);
|
||||
Mockito.when(plainsf.createSocket(Mockito.any())).thenReturn(mockSock);
|
||||
Mockito.when(plainsf.connectSocket(
|
||||
Mockito.<TimeValue>any(),
|
||||
Mockito.any(),
|
||||
Mockito.eq(mockSock),
|
||||
Mockito.<HttpHost>any(),
|
||||
Mockito.<InetSocketAddress>any(),
|
||||
Mockito.<InetSocketAddress>any(),
|
||||
Mockito.<HttpContext>any())).thenReturn(mockSock);
|
||||
Mockito.any(),
|
||||
Mockito.any(),
|
||||
Mockito.any(),
|
||||
Mockito.any())).thenReturn(mockSock);
|
||||
|
||||
mgr.connect(endpoint1, TimeValue.ofMilliseconds(123), context);
|
||||
|
||||
|
@ -65,7 +65,7 @@ public void testDirect() throws Exception {
|
||||
Assert.assertEquals(target, route.getTargetHost());
|
||||
Assert.assertEquals(1, route.getHopCount());
|
||||
Assert.assertFalse(route.isSecure());
|
||||
Mockito.verify(schemePortResolver, Mockito.never()).resolve(Mockito.<HttpHost>any());
|
||||
Mockito.verify(schemePortResolver, Mockito.never()).resolve(Mockito.any());
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -94,7 +94,7 @@ public void testViaProxy() throws Exception {
|
||||
Assert.assertEquals(proxy, route.getProxyHost());
|
||||
Assert.assertEquals(2, route.getHopCount());
|
||||
Assert.assertFalse(route.isSecure());
|
||||
Mockito.verify(schemePortResolver, Mockito.never()).resolve(Mockito.<HttpHost>any());
|
||||
Mockito.verify(schemePortResolver, Mockito.never()).resolve(Mockito.any());
|
||||
}
|
||||
|
||||
@Test(expected= ProtocolException.class)
|
||||
|
@ -73,7 +73,7 @@ public void testDirect() throws Exception {
|
||||
Assert.assertEquals(target, route.getTargetHost());
|
||||
Assert.assertEquals(1, route.getHopCount());
|
||||
Assert.assertFalse(route.isSecure());
|
||||
Mockito.verify(schemePortResolver, Mockito.never()).resolve(ArgumentMatchers.<HttpHost>any());
|
||||
Mockito.verify(schemePortResolver, Mockito.never()).resolve(ArgumentMatchers.any());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -31,13 +31,13 @@
|
||||
import org.apache.hc.client5.http.HttpRoute;
|
||||
import org.apache.hc.client5.http.RouteInfo.LayerType;
|
||||
import org.apache.hc.client5.http.RouteInfo.TunnelType;
|
||||
import org.apache.hc.client5.http.cookie.StandardCookieSpec;
|
||||
import org.apache.hc.client5.http.config.RequestConfig;
|
||||
import org.apache.hc.client5.http.cookie.BasicCookieStore;
|
||||
import org.apache.hc.client5.http.cookie.CookieOrigin;
|
||||
import org.apache.hc.client5.http.cookie.CookieSpec;
|
||||
import org.apache.hc.client5.http.cookie.CookieSpecFactory;
|
||||
import org.apache.hc.client5.http.cookie.CookieStore;
|
||||
import org.apache.hc.client5.http.cookie.StandardCookieSpec;
|
||||
import org.apache.hc.client5.http.impl.cookie.BasicClientCookie;
|
||||
import org.apache.hc.client5.http.impl.cookie.IgnoreCookieSpecFactory;
|
||||
import org.apache.hc.client5.http.impl.cookie.RFC6265CookieSpecFactory;
|
||||
@ -344,7 +344,7 @@ public void testExcludeExpiredCookies() throws Exception {
|
||||
Assert.assertEquals(1, headers.length);
|
||||
Assert.assertEquals("name1=value1; name2=value2", headers[0].getValue());
|
||||
|
||||
Mockito.verify(this.cookieStore, Mockito.times(1)).clearExpired(ArgumentMatchers.<Date>any());
|
||||
Mockito.verify(this.cookieStore, Mockito.times(1)).clearExpired(ArgumentMatchers.any());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
Loading…
x
Reference in New Issue
Block a user