You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@zookeeper.apache.org by GitBox <gi...@apache.org> on 2020/02/26 04:52:32 UTC

[GitHub] [zookeeper] ctest-team commented on a change in pull request #1266: ZOOKEEPER-3721: Making the boolean configuration parameters consistent

ctest-team commented on a change in pull request #1266: ZOOKEEPER-3721: Making the boolean configuration parameters consistent
URL: https://github.com/apache/zookeeper/pull/1266#discussion_r384273838
 
 

 ##########
 File path: zookeeper-server/src/test/java/org/apache/zookeeper/server/quorum/QuorumPeerConfigTest.java
 ##########
 @@ -164,6 +164,31 @@ public void testJvmPauseMonitorConfigured() throws IOException, ConfigException
         assertTrue(quorumPeerConfig.isJvmPauseMonitorToRun());
     }
 
+    /**
+     * Test case for https://issues.apache.org/jira/browse/ZOOKEEPER-3721
+     */
+    @Test
+    public void testParseBoolean() throws IOException, ConfigException {
+        QuorumPeerConfig quorumPeerConfig = new QuorumPeerConfig();
+        Properties zkProp = getDefaultZKProperties();
+
+        zkProp.setProperty("localSessionsEnabled", "true");
+        quorumPeerConfig.parseProperties(zkProp);
+        assertEquals(true, quorumPeerConfig.areLocalSessionsEnabled());
+
+        zkProp.setProperty("localSessionsEnabled", "false");
+        quorumPeerConfig.parseProperties(zkProp);
+        assertEquals(false, quorumPeerConfig.areLocalSessionsEnabled());
+
+        zkProp.setProperty("localSessionsEnabled", "yes");
+        try {
+            quorumPeerConfig.parseProperties(zkProp);
+            fail("Must throw exception as 'yes' is not accpetable for parseBoolean!");
 
 Review comment:
   Do you mean things like:
   ```
   zkProp.setProperty("localSessionsEnabled", "True");
   quorumPeerConfig.parseProperties(zkProp);
   assertEquals(true, quorumPeerConfig.areLocalSessionsEnabled());
   
   zkProp.setProperty("localSessionsEnabled", "False");
   quorumPeerConfig.parseProperties(zkProp);
   assertEquals(false, quorumPeerConfig.areLocalSessionsEnabled());
   ```
   to test whether ignoring case can work?

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services