azotcsit commented on a change in pull request #1213:
URL: https://github.com/apache/cassandra/pull/1213#discussion_r723005060



##########
File path: test/unit/org/apache/cassandra/config/DatabaseDescriptorTest.java
##########
@@ -590,4 +591,32 @@ public void 
testApplyTokensConfigInitialTokensOneNumTokensNotSet()
         Assert.assertEquals(Integer.valueOf(1), config.num_tokens);
         Assert.assertEquals(1, 
DatabaseDescriptor.tokensFromString(config.initial_token).size());
     }
+
+    @Test
+    public void testDenylistInvalidValuesRejected()
+    {
+        DatabaseDescriptor.loadConfig();
+
+        
expectIllegalArgumentException(DatabaseDescriptor::setDenylistRefreshSeconds, 
0);
+        
expectIllegalArgumentException(DatabaseDescriptor::setDenylistRefreshSeconds, 
-1);
+
+        
expectIllegalArgumentException(DatabaseDescriptor::setDenylistKeysPerTableMax, 
0);
+        
expectIllegalArgumentException(DatabaseDescriptor::setDenylistKeysPerTableMax, 
-1);
+
+        
expectIllegalArgumentException(DatabaseDescriptor::setDenylistKeysTotalMax, 0);
+        
expectIllegalArgumentException(DatabaseDescriptor::setDenylistKeysTotalMax, -1);
+    }
+
+    private void expectIllegalArgumentException(Consumer<Integer> c, int val)

Review comment:
       I feel we need to use `assertThatThrownBy`, easily lets to check not 
only that an exception was thrown, but also its message. It could help you to 
catch this issue for example: 
https://github.com/apache/cassandra/pull/1213#discussion_r722979906




-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to