exceptionfactory commented on a change in pull request #4847:
URL: https://github.com/apache/nifi/pull/4847#discussion_r583915058
##########
File path:
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestListenHTTP.java
##########
@@ -405,6 +409,84 @@ public void
testSecureServerRejectsUnsupportedTlsProtocolVersion() throws Except
assertThrows(SSLHandshakeException.class, sslSocket::startHandshake);
}
+ @Test
+ public void testMaxThreadPoolSizeTooLow() {
+ // GIVEN, WHEN
+ runner.setProperty(ListenHTTP.PORT, Integer.toString(availablePort));
+ runner.setProperty(ListenHTTP.BASE_PATH, HTTP_BASE_PATH);
+ runner.setProperty(ListenHTTP.MAX_THREAD_POOL_SIZE, "7");
+
+ // THEN
+ runner.assertNotValid();
+ }
+
+ @Test
+ public void testMaxThreadPoolSizeTooHigh() {
+ // GIVEN, WHEN
+ runner.setProperty(ListenHTTP.PORT, Integer.toString(availablePort));
+ runner.setProperty(ListenHTTP.BASE_PATH, HTTP_BASE_PATH);
+ runner.setProperty(ListenHTTP.MAX_THREAD_POOL_SIZE, "1001");
+
+ // THEN
+ runner.assertNotValid();
+ }
+
+ @Test
+ public void testMaxThreadPoolSizeOkLowerBound() {
+ // GIVEN, WHEN
+ runner.setProperty(ListenHTTP.PORT, Integer.toString(availablePort));
+ runner.setProperty(ListenHTTP.BASE_PATH, HTTP_BASE_PATH);
+ runner.setProperty(ListenHTTP.MAX_THREAD_POOL_SIZE, "8");
+
+ // THEN
+ runner.assertValid();
+ }
+
+ @Test
+ public void testMaxThreadPoolSizeOkUpperBound() {
+ // GIVEN, WHEN
+ runner.setProperty(ListenHTTP.PORT, Integer.toString(availablePort));
+ runner.setProperty(ListenHTTP.BASE_PATH, HTTP_BASE_PATH);
+ runner.setProperty(ListenHTTP.MAX_THREAD_POOL_SIZE, "1000");
+
+ // THEN
+ runner.assertValid();
+ }
+
+ @Test
+ public void
testWhenServerIsStartedCreateQueuedThreadPoolIsCalledWithMaxThreadPoolSize() {
+ // GIVEN
+ int maxThreadPoolSize = 200;
+ runner.setProperty(ListenHTTP.PORT, Integer.toString(availablePort));
+ runner.setProperty(ListenHTTP.BASE_PATH, HTTP_BASE_PATH);
+ runner.setProperty(ListenHTTP.MAX_THREAD_POOL_SIZE,
Integer.toString(maxThreadPoolSize));
+
+ // WHEN
+ startWebServer();
+
+ // THEN
+ Mockito.verify(proc).createQueuedThreadPool(maxThreadPoolSize);
+ }
+
+ @Test
+ public void
testWhenServerIsStartedCreateCreateServerIsCalledWithTheRightQueuedThreadPool()
{
+ // GIVEN
+ int maxThreadPoolSize = 200;
+ QueuedThreadPool queuedThreadPool = new
QueuedThreadPool(maxThreadPoolSize);
+
+ runner.setProperty(ListenHTTP.PORT, Integer.toString(availablePort));
+ runner.setProperty(ListenHTTP.BASE_PATH, HTTP_BASE_PATH);
+ runner.setProperty(ListenHTTP.MAX_THREAD_POOL_SIZE,
Integer.toString(maxThreadPoolSize));
+
+
Mockito.when(proc.createQueuedThreadPool(maxThreadPoolSize)).thenReturn(queuedThreadPool);
Review comment:
Thanks for the explanation @pgyori, that makes sense.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]