From 99def6ddf75d44a8c8c02144cb49b346a82bdaf6 Mon Sep 17 00:00:00 2001 From: Lianhao Lu Date: Wed, 10 Apr 2019 14:40:11 +0800 Subject: Add multi-thread support in FileSystemReceptionHander By adding multi-thread support in FileSystemReceptionHander, we can have a more thorough s3p test to test performance & stablity in multithread situations. Change-Id: Id263435531e26dcbadfbda6f82b26ac54a72ba1a Issue-ID: POLICY-1274 Signed-off-by: Lianhao Lu --- .../reception/handling/file/TestFileSystemReceptionHandler.java | 8 +++++--- ...TestFileSystemReceptionHandlerConfigurationParameterGroup.java | 3 ++- 2 files changed, 7 insertions(+), 4 deletions(-) (limited to 'plugins/reception-plugins/src/test/java') diff --git a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/file/TestFileSystemReceptionHandler.java b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/file/TestFileSystemReceptionHandler.java index fdb01007..556b1d6d 100644 --- a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/file/TestFileSystemReceptionHandler.java +++ b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/file/TestFileSystemReceptionHandler.java @@ -93,7 +93,8 @@ public class TestFileSystemReceptionHandler { @Test public final void testInit() throws IOException, InterruptedException { final FileSystemReceptionHandler sypHandler = Mockito.spy(fileSystemHandler); - Mockito.doNothing().when(sypHandler).initFileWatcher(Mockito.isA(String.class)); + Mockito.doNothing().when(sypHandler).initFileWatcher(Mockito.isA(String.class), + Mockito.anyInt()); try { sypHandler.initializeReception(pssdConfigParameters.getName()); } catch (final Exception exp) { @@ -106,7 +107,8 @@ public class TestFileSystemReceptionHandler { public final void testDestroy() throws IOException { try { final FileSystemReceptionHandler sypHandler = Mockito.spy(fileSystemHandler); - Mockito.doNothing().when(sypHandler).initFileWatcher(Mockito.isA(String.class)); + Mockito.doNothing().when(sypHandler).initFileWatcher(Mockito.isA(String.class), + Mockito.anyInt()); sypHandler.initializeReception(pssdConfigParameters.getName()); sypHandler.destroy(); } catch (final Exception exp) { @@ -141,7 +143,7 @@ public class TestFileSystemReceptionHandler { final Thread th = new Thread(() -> { try { - sypHandler.initFileWatcher(watchPath); + sypHandler.initFileWatcher(watchPath, 2); } catch (final IOException ex) { LOGGER.error("testMain failed", ex); } diff --git a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/file/TestFileSystemReceptionHandlerConfigurationParameterGroup.java b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/file/TestFileSystemReceptionHandlerConfigurationParameterGroup.java index 92d9443e..1d32b191 100644 --- a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/file/TestFileSystemReceptionHandlerConfigurationParameterGroup.java +++ b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/file/TestFileSystemReceptionHandlerConfigurationParameterGroup.java @@ -53,7 +53,7 @@ public class TestFileSystemReceptionHandlerConfigurationParameterGroup { validPath = tempFolder.getRoot().getAbsolutePath(); final FileSystemReceptionHandlerConfigurationParameterBuilder builder = - new FileSystemReceptionHandlerConfigurationParameterBuilder().setWatchPath(validPath); + new FileSystemReceptionHandlerConfigurationParameterBuilder().setWatchPath(validPath).setMaxThread(2); configParameters = new FileSystemReceptionHandlerConfigurationParameterGroup(builder); } catch (final Exception e) { fail("test should not thrown an exception here: " + e.getMessage()); @@ -61,6 +61,7 @@ public class TestFileSystemReceptionHandlerConfigurationParameterGroup { final GroupValidationResult validationResult = configParameters.validate(); assertTrue(validationResult.isValid()); assertEquals(validPath, configParameters.getWatchPath()); + assertEquals(2, configParameters.getMaxThread()); } @Test -- cgit 1.2.3-korg