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 2019/12/19 09:12:04 UTC

[GitHub] [zookeeper] sujithsimon22 opened a new pull request #1190: ZOOKEEPER-3613: ZKConfig fails to return proper value on getBoolean()when user accidentally includes spaces at the end of the value

sujithsimon22 opened a new pull request #1190: ZOOKEEPER-3613: ZKConfig fails to return proper value on getBoolean()when user accidentally includes spaces at the end of the value
URL: https://github.com/apache/zookeeper/pull/1190
 
 
   

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

[GitHub] [zookeeper] sujithsimon22 commented on a change in pull request #1190: ZOOKEEPER-3613: ZKConfig fails to return proper value on getBoolean()when user accidentally includes spaces at the end of the value

Posted by GitBox <gi...@apache.org>.
sujithsimon22 commented on a change in pull request #1190: ZOOKEEPER-3613: ZKConfig fails to return proper value on getBoolean()when user accidentally includes spaces at the end of the value
URL: https://github.com/apache/zookeeper/pull/1190#discussion_r364641959
 
 

 ##########
 File path: zookeeper-server/src/test/java/org/apache/zookeeper/common/ZKConfigTest.java
 ##########
 @@ -0,0 +1,107 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.zookeeper.common;
+
+
+import static org.junit.Assert.assertEquals;
+import java.io.File;
+import java.util.concurrent.TimeUnit;
+import org.junit.BeforeClass;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.Timeout;
+
+
+
+public class ZKConfigTest {
+
+    private static final File testData = new File(System.getProperty("test.data.dir", "src/test/resources/data"));
+    X509Util x509Util;
+    @Rule
+    public Timeout timeout = new Timeout(10, TimeUnit.SECONDS);
+
+    @BeforeClass
+    public static void init() {
+        if (!testData.exists()) {
+            testData.mkdirs();
+        }
+    }
+
+    // property is not set we should get the default value
+    @Test
+    public void testBooleanRetrievalFromPropertyDefault() {
+        ZKConfig conf = new ZKConfig();
+        String prop = "UnSetProperty" + System.currentTimeMillis();
+        boolean defaultValue = false;
+        boolean result = conf.getBoolean(prop, defaultValue);
+        assertEquals(defaultValue, result);
+    }
+
+    // property is set to an valid boolean, we should get the set value
+    @Test
+    public void testBooleanRetrievalFromProperty() {
+        boolean value = true;
+        boolean defaultValue = false;
+        x509Util = new ClientX509Util();
+        System.setProperty(x509Util.getSslProtocolProperty(), Boolean.toString(value));
+        ZKConfig conf = new ZKConfig();
+        boolean result = conf.getBoolean(x509Util.getSslProtocolProperty(), defaultValue);
+        assertEquals(value, result);
+        System.clearProperty(x509Util.getSslProtocolProperty());
 
 Review comment:
   Done, thanks

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

[GitHub] [zookeeper] sujithsimon22 commented on a change in pull request #1190: ZOOKEEPER-3613: ZKConfig fails to return proper value on getBoolean()when user accidentally includes spaces at the end of the value

Posted by GitBox <gi...@apache.org>.
sujithsimon22 commented on a change in pull request #1190: ZOOKEEPER-3613: ZKConfig fails to return proper value on getBoolean()when user accidentally includes spaces at the end of the value
URL: https://github.com/apache/zookeeper/pull/1190#discussion_r364641702
 
 

 ##########
 File path: zookeeper-server/src/test/java/org/apache/zookeeper/common/ZKConfigTest.java
 ##########
 @@ -0,0 +1,107 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.zookeeper.common;
+
+
+import static org.junit.Assert.assertEquals;
+import java.io.File;
+import java.util.concurrent.TimeUnit;
+import org.junit.BeforeClass;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.Timeout;
+
+
+
+public class ZKConfigTest {
+
+    private static final File testData = new File(System.getProperty("test.data.dir", "src/test/resources/data"));
 
 Review comment:
   Done, thanks

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

[GitHub] [zookeeper] arshadmohammad commented on a change in pull request #1190: ZOOKEEPER-3613: ZKConfig fails to return proper value on getBoolean()when user accidentally includes spaces at the end of the value

Posted by GitBox <gi...@apache.org>.
arshadmohammad commented on a change in pull request #1190: ZOOKEEPER-3613: ZKConfig fails to return proper value on getBoolean()when user accidentally includes spaces at the end of the value
URL: https://github.com/apache/zookeeper/pull/1190#discussion_r361331900
 
 

 ##########
 File path: zookeeper-server/src/test/java/org/apache/zookeeper/common/ZKConfigTest.java
 ##########
 @@ -0,0 +1,107 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.zookeeper.common;
+
+
+import static org.junit.Assert.assertEquals;
+import java.io.File;
+import java.util.concurrent.TimeUnit;
+import org.junit.BeforeClass;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.Timeout;
+
+
+
+public class ZKConfigTest {
+
+    private static final File testData = new File(System.getProperty("test.data.dir", "src/test/resources/data"));
+    X509Util x509Util;
+    @Rule
+    public Timeout timeout = new Timeout(10, TimeUnit.SECONDS);
+
+    @BeforeClass
+    public static void init() {
+        if (!testData.exists()) {
+            testData.mkdirs();
+        }
+    }
+
+    // property is not set we should get the default value
+    @Test
+    public void testBooleanRetrievalFromPropertyDefault() {
+        ZKConfig conf = new ZKConfig();
+        String prop = "UnSetProperty" + System.currentTimeMillis();
+        boolean defaultValue = false;
+        boolean result = conf.getBoolean(prop, defaultValue);
+        assertEquals(defaultValue, result);
+    }
+
+    // property is set to an valid boolean, we should get the set value
+    @Test
+    public void testBooleanRetrievalFromProperty() {
+        boolean value = true;
+        boolean defaultValue = false;
+        x509Util = new ClientX509Util();
+        System.setProperty(x509Util.getSslProtocolProperty(), Boolean.toString(value));
+        ZKConfig conf = new ZKConfig();
+        boolean result = conf.getBoolean(x509Util.getSslProtocolProperty(), defaultValue);
+        assertEquals(value, result);
+        System.clearProperty(x509Util.getSslProtocolProperty());
 
 Review comment:
   Clear properties in tearDown method
   @After    
   public void tearDown() throws Exception {       }

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

[GitHub] [zookeeper] asfgit closed pull request #1190: ZOOKEEPER-3613: ZKConfig fails to return proper value on getBoolean()when user accidentally includes spaces at the end of the value

Posted by GitBox <gi...@apache.org>.
asfgit closed pull request #1190: ZOOKEEPER-3613: ZKConfig fails to return proper value on getBoolean()when user accidentally includes spaces at the end of the value
URL: https://github.com/apache/zookeeper/pull/1190
 
 
   

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

[GitHub] [zookeeper] arshadmohammad commented on issue #1190: ZOOKEEPER-3613: ZKConfig fails to return proper value on getBoolean()when user accidentally includes spaces at the end of the value

Posted by GitBox <gi...@apache.org>.
arshadmohammad commented on issue #1190: ZOOKEEPER-3613: ZKConfig fails to return proper value on getBoolean()when user accidentally includes spaces at the end of the value
URL: https://github.com/apache/zookeeper/pull/1190#issuecomment-575471237
 
 
   +1
   I will merge it in master branch-3.6 and branch-3.5

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

[GitHub] [zookeeper] arshadmohammad commented on a change in pull request #1190: ZOOKEEPER-3613: ZKConfig fails to return proper value on getBoolean()when user accidentally includes spaces at the end of the value

Posted by GitBox <gi...@apache.org>.
arshadmohammad commented on a change in pull request #1190: ZOOKEEPER-3613: ZKConfig fails to return proper value on getBoolean()when user accidentally includes spaces at the end of the value
URL: https://github.com/apache/zookeeper/pull/1190#discussion_r361331795
 
 

 ##########
 File path: zookeeper-server/src/test/java/org/apache/zookeeper/common/ZKConfigTest.java
 ##########
 @@ -0,0 +1,107 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.zookeeper.common;
+
+
+import static org.junit.Assert.assertEquals;
+import java.io.File;
+import java.util.concurrent.TimeUnit;
+import org.junit.BeforeClass;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.Timeout;
+
+
+
+public class ZKConfigTest {
+
+    private static final File testData = new File(System.getProperty("test.data.dir", "src/test/resources/data"));
 
 Review comment:
   I think this is not required. you can delete it . init method also can be deleted.

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