ItemSourcePool configuredBufferedItemSourcePool() { return new BufferedItemSourcePool( poolName, new UnpooledByteBufAllocator(false, false, false), resizePolicy, resizeTimeout, monitored, monitorTaskInterval, initialPoolSize, itemSizeInBytes ); }
ItemSourcePool configuredBufferedItemSourcePool() { return new BufferedItemSourcePool( poolName, new UnpooledByteBufAllocator(false, false, false), resizePolicy, resizeTimeout, monitored, monitorTaskInterval, initialPoolSize, itemSizeInBytes ); }
public static BufferedItemSourcePool createDefaultTestBufferedItemSourcePool(int initialSize, boolean monitored) { return new BufferedItemSourcePool( DEFAULT_TEST_ITEM_POOL_NAME, byteBufAllocator, UnlimitedResizePolicy.newBuilder().build(), DEFAULT_TEST_RESIZE_TIMEOUT, monitored, DEFAULT_TEST_MONITOR_TASK_INTERVAL, initialSize, DEFAULT_TEST_ITEM_SIZE_IN_BYTES); }
@Test public void removeReturnFalseInsteadOofThrowingAfterUnderlyingPoolResourceException () { ResizePolicy resizePolicy = mock(ResizePolicy.class); when(resizePolicy.increase(any())).thenThrow(PoolResourceException.class); BufferedItemSourcePool pool = new BufferedItemSourcePool( DEFAULT_TEST_ITEM_POOL_NAME, byteBufAllocator, resizePolicy, 0, false, DEFAULT_TEST_MONITOR_TASK_INTERVAL, 0, DEFAULT_TEST_ITEM_SIZE_IN_BYTES); // when boolean resized = pool.remove(); // then assertFalse(resized); }
@Test public void throwsWhenResizePolicyDoesNotResize() throws PoolResourceException { // given ResizePolicy resizePolicy = mock(ResizePolicy.class); when(resizePolicy.increase(any())).thenReturn(false); BufferedItemSourcePool pool = new BufferedItemSourcePool( DEFAULT_TEST_ITEM_POOL_NAME, byteBufAllocator, resizePolicy, 0, false, DEFAULT_TEST_MONITOR_TASK_INTERVAL, 0, DEFAULT_TEST_ITEM_SIZE_IN_BYTES); expectedException.expect(PoolResourceException.class); expectedException.expectMessage("Unable to resize. Creation of ItemSource was unsuccessful"); // when pool.getPooled(); }
BufferedItemSourcePool pool = spy(new BufferedItemSourcePool( DEFAULT_TEST_ITEM_POOL_NAME, byteBufAllocator,
BufferedItemSourcePool pool = spy(new BufferedItemSourcePool( DEFAULT_TEST_ITEM_POOL_NAME, byteBufAllocator,
@Test public void throwsWhenNoMorePooledElementsAvailableAndResizePolicyDoesNotCopeWithTheLoad() throws PoolResourceException { // given ResizePolicy resizePolicy = mock(ResizePolicy.class); when(resizePolicy.increase(any())).thenReturn(true); BufferedItemSourcePool pool = new BufferedItemSourcePool( DEFAULT_TEST_ITEM_POOL_NAME, byteBufAllocator, resizePolicy, 0, false, DEFAULT_TEST_MONITOR_TASK_INTERVAL, 0, DEFAULT_TEST_ITEM_SIZE_IN_BYTES); expectedException.expect(PoolResourceException.class); expectedException.expectMessage("has to be reconfigured to handle current load"); expectedException.expectMessage(DEFAULT_TEST_ITEM_POOL_NAME); // when pool.getPooled(); }
@Test public void poolCreatesScheduledExecutor() { // when BufferedItemSourcePool pool = spy(new BufferedItemSourcePool( DEFAULT_TEST_ITEM_POOL_NAME, byteBufAllocator, UnlimitedResizePolicy.newBuilder().withResizeFactor(1).build(), DEFAULT_TEST_RESIZE_TIMEOUT, false, DEFAULT_TEST_MONITOR_TASK_INTERVAL, 1, DEFAULT_TEST_ITEM_SIZE_IN_BYTES)); // then assertNotNull(pool.executor); }