@Test public void lifecycleStopShutsDownPool() { // given ItemSourcePool pool = mock(ItemSourcePool.class); PooledItemSourceFactory.Builder sourceFactoryConfig = spy(createDefaultTestSourceFactoryConfig()); when(sourceFactoryConfig.configuredBufferedItemSourcePool()).thenReturn(pool); PooledItemSourceFactory factory = sourceFactoryConfig.build(); // when factory.stop(1000, TimeUnit.MILLISECONDS); // then verify(pool).shutdown(); }
builder.build();
@Test public void builderThrowsOnItemSizeInBytesZero() { // given PooledItemSourceFactory.Builder builder = createDefaultTestSourceFactoryConfig() .withItemSizeInBytes(0); expectedException.expect(ConfigurationException.class); expectedException.expectMessage("itemSizeInBytes must be higher than 0"); expectedException.expectMessage(PooledItemSourceFactory.PLUGIN_NAME); // when builder.build(); }
@Test public void builderThrowsOnInitialPoolSizeLessThanZero() { // given PooledItemSourceFactory.Builder builder = createDefaultTestSourceFactoryConfig() .withInitialPoolSize(-1); expectedException.expect(ConfigurationException.class); expectedException.expectMessage("initialPoolSize must be higher than 0"); expectedException.expectMessage(PooledItemSourceFactory.PLUGIN_NAME); // when builder.build(); }
@Test public void builderBuildsSuccessfully() { // given PooledItemSourceFactory.Builder builder = createDefaultTestSourceFactoryConfig(); // when PooledItemSourceFactory factory = builder.build(); // then Assert.assertNotNull(factory); }
@Test public void builderThrowsOnItemSizeInBytesLessThanZero() { // given PooledItemSourceFactory.Builder builder = createDefaultTestSourceFactoryConfig() .withItemSizeInBytes(-1); expectedException.expect(ConfigurationException.class); expectedException.expectMessage("itemSizeInBytes must be higher than 0"); expectedException.expectMessage(PooledItemSourceFactory.PLUGIN_NAME); // when builder.build(); }
@Test public void builderThrowsOnInitialPoolSizeZero() { // given PooledItemSourceFactory.Builder builder = createDefaultTestSourceFactoryConfig() .withInitialPoolSize(0); expectedException.expect(ConfigurationException.class); expectedException.expectMessage("initialPoolSize must be higher than 0"); expectedException.expectMessage(PooledItemSourceFactory.PLUGIN_NAME); // when builder.build(); }