Explorar o código

ZOOKEEPER-1628. Documented list of allowable characters in ZK doc not in line with code (Gabriel Reid via phunt)

git-svn-id: https://svn.apache.org/repos/asf/zookeeper/trunk@1438356 13f79535-47bb-0310-9956-ffa450edef68
Patrick D. Hunt %!s(int64=12) %!d(string=hai) anos
pai
achega
d9dae9ae9d

+ 3 - 0
CHANGES.txt

@@ -311,6 +311,9 @@ BUGFIXES:
   ZK-1504) opens selectors but never closes them
   (Thawan Kooburat via phunt)
 
+  ZOOKEEPER-1628. Documented list of allowable characters in ZK doc
+  not in line with code (Gabriel Reid via phunt)
+
 IMPROVEMENTS:
 
   ZOOKEEPER-1170. Fix compiler (eclipse) warnings: unused imports,

BIN=BIN
docs/index.pdf


BIN=BIN
docs/javaExample.pdf


BIN=BIN
docs/linkmap.pdf


BIN=BIN
docs/recipes.pdf


BIN=BIN
docs/releasenotes.pdf


BIN=BIN
docs/zookeeperAdmin.pdf


BIN=BIN
docs/zookeeperHierarchicalQuorums.pdf


BIN=BIN
docs/zookeeperInternals.pdf


BIN=BIN
docs/zookeeperJMX.pdf


BIN=BIN
docs/zookeeperObservers.pdf


BIN=BIN
docs/zookeeperOver.pdf


+ 3 - 3
docs/zookeeperProgrammers.html

@@ -443,7 +443,7 @@ document.write("Last Published: " + document.lastModified);
 <li>
         
 <p>The following characters can't be used because they don't
-        display well, or render in confusing ways: \u0001 - \u0019 and \u007F
+        display well, or render in confusing ways: \u0001 - \u001F and \u007F
         - \u009F.</p>
       
 </li>
@@ -451,8 +451,8 @@ document.write("Last Published: " + document.lastModified);
       
 <li>
         
-<p>The following characters are not allowed: \ud800 -uF8FFF,
-        \uFFF0-uFFFF, \uXFFFE - \uXFFFF (where X is a digit 1 - E), \uF0000 -
+<p>The following characters are not allowed: \ud800 - uF8FF,
+        \uFFF0 - uFFFF, \uXFFFE - \uXFFFF (where X is a digit 1 - E), \uF0000 -
         \uFFFFF.</p>
       
 </li>

BIN=BIN
docs/zookeeperProgrammers.pdf


BIN=BIN
docs/zookeeperQuotas.pdf


BIN=BIN
docs/zookeeperStarted.pdf


BIN=BIN
docs/zookeeperTutorial.pdf


+ 3 - 3
src/docs/src/documentation/content/xdocs/zookeeperProgrammers.xml

@@ -133,13 +133,13 @@
 
       <listitem>
         <para>The following characters can't be used because they don't
-        display well, or render in confusing ways: \u0001 - \u0019 and \u007F
+        display well, or render in confusing ways: \u0001 - \u001F and \u007F
         - \u009F.</para>
       </listitem>
 
       <listitem>
-        <para>The following characters are not allowed: \ud800 -uF8FFF,
-        \uFFF0-uFFFF, \uXFFFE - \uXFFFF (where X is a digit 1 - E), \uF0000 -
+        <para>The following characters are not allowed: \ud800 - uF8FF,
+        \uFFF0 - uFFFF, \uXFFFE - \uXFFFF (where X is a digit 1 - E), \uF0000 -
         \uFFFFF.</para>
       </listitem>
 

+ 4 - 4
src/java/main/org/apache/zookeeper/common/PathUtils.java

@@ -86,10 +86,10 @@ public class PathUtils {
                     reason = "relative paths not allowed @" + i;
                     break;
                 }
-            } else if (c > '\u0000' && c < '\u001f'
-                    || c > '\u007f' && c < '\u009F'
-                    || c > '\ud800' && c < '\uf8ff'
-                    || c > '\ufff0' && c < '\uffff') {
+            } else if (c > '\u0000' && c <= '\u001f'
+                    || c >= '\u007f' && c <= '\u009F'
+                    || c >= '\ud800' && c <= '\uf8ff'
+                    || c >= '\ufff0' && c <= '\uffff') {
                 reason = "invalid charater @" + i;
                 break;
             }

+ 128 - 0
src/java/test/org/apache/zookeeper/common/PathUtilsTest.java

@@ -0,0 +1,128 @@
+/**
+ * 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 org.junit.Test;
+
+public class PathUtilsTest {
+
+    @Test
+    public void testValidatePath_ValidPath() {
+        PathUtils.validatePath("/this is / a valid/path");
+    }
+
+    @Test(expected=IllegalArgumentException.class)
+    public void testValidatePath_Null() {
+        PathUtils.validatePath(null);
+    }
+    
+
+    @Test(expected=IllegalArgumentException.class)
+    public void testValidatePath_EmptyString() {
+        PathUtils.validatePath("");
+    }
+
+    @Test(expected=IllegalArgumentException.class)
+    public void testValidatePath_NotAbsolutePath() {
+        PathUtils.validatePath("not/valid");
+    }
+
+    @Test(expected=IllegalArgumentException.class)
+    public void testValidatePath_EndsWithSlash() {
+        PathUtils.validatePath("/ends/with/slash/");
+    }
+    
+    @Test(expected=IllegalArgumentException.class)
+    public void testValidatePath_ContainsNullCharacter() {
+        PathUtils.validatePath("/test\u0000");
+    }
+    
+    @Test(expected=IllegalArgumentException.class)
+    public void testValidatePath_DoubleSlash() {
+        PathUtils.validatePath("/double//slash");
+    }
+    
+    @Test(expected=IllegalArgumentException.class)
+    public void testValidatePath_SinglePeriod() {
+        PathUtils.validatePath("/single/./period");
+    }
+    
+    @Test(expected=IllegalArgumentException.class)
+    public void testValidatePath_DoublePeriod() {
+        PathUtils.validatePath("/double/../period");
+    }
+    
+    @Test
+    public void testValidatePath_NameContainingPeriod() {
+        // A period that isn't on its own is ok
+        PathUtils.validatePath("/name/with.period.");
+    }
+    
+    @Test(expected=IllegalArgumentException.class)
+    public void testValidatePath_0x01() {
+        PathUtils.validatePath("/test\u0001");
+    }
+    
+    @Test(expected=IllegalArgumentException.class)
+    public void testValidatePath_0x1F() {
+        PathUtils.validatePath("/test\u001F");
+    }
+    
+    @Test // The first allowable character
+    public void testValidatePath_0x20() {
+        PathUtils.validatePath("/test\u0020");
+    }
+    
+    @Test 
+    public void testValidatePath_0x7e() {
+        // The last valid ASCII character
+        PathUtils.validatePath("/test\u007e");
+    }
+    
+    @Test(expected=IllegalArgumentException.class)
+    public void testValidatePath_0x7f() {
+        PathUtils.validatePath("/test\u007f");
+    }
+    
+    @Test(expected=IllegalArgumentException.class) 
+    public void testValidatePath_0x9f() {
+        PathUtils.validatePath("/test\u009f");
+    }
+    
+    @Test(expected=IllegalArgumentException.class)
+    public void testValidatePath_ud800() {
+        PathUtils.validatePath("/test\ud800");
+    }
+
+    @Test(expected=IllegalArgumentException.class)
+    public void testValidatePath_uf8ff() {
+        PathUtils.validatePath("/test\uf8ff");
+    }
+    
+    @Test
+    public void testValidatePath_HighestAllowableChar() {
+        PathUtils.validatePath("/test\uffef");
+    }
+    
+    @Test(expected=IllegalArgumentException.class)
+    public void testValidatePath_SupplementaryChar() {
+        PathUtils.validatePath("/test\ufff0");
+    }
+
+}