jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r415667 - in /jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/util: TestAll.java TextTest.java
Date Tue, 20 Jun 2006 14:40:09 GMT
Author: jukka
Date: Tue Jun 20 07:40:09 2006
New Revision: 415667

URL: http://svn.apache.org/viewvc?rev=415667&view=rev
Log:
Added test cases for the JCR name escape method.

Added:
    jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/util/TextTest.java
Modified:
    jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/util/TestAll.java

Modified: jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/util/TestAll.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/util/TestAll.java?rev=415667&r1=415666&r2=415667&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/util/TestAll.java (original)
+++ jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/util/TestAll.java Tue
Jun 20 07:40:09 2006
@@ -36,6 +36,7 @@
         TestSuite suite = new TestSuite("util tests");
 
         suite.addTestSuite(ISO9075Test.class);
+        suite.addTestSuite(TextTest.class);
 
         return suite;
     }

Added: jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/util/TextTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/util/TextTest.java?rev=415667&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/util/TextTest.java (added)
+++ jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/util/TextTest.java Tue
Jun 20 07:40:09 2006
@@ -0,0 +1,58 @@
+/*
+ * 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.jackrabbit.util;
+
+import junit.framework.TestCase;
+
+/**
+ * Test cases for the Text utility class.
+ */
+public class TextTest extends TestCase {
+
+    private void checkEscape(String name) {
+        String escaped = Text.escapeIllegalJcrChars(name);
+        assertEquals(name, Text.unescapeIllegalJcrChars(escaped));
+    }
+
+    public void testEscape() {
+        // Handling of normal names
+        checkEscape("foobar");
+        // Handling of short names
+        checkEscape("x");
+        checkEscape("xx");
+        checkEscape("xxx");
+        // Handling of spaces
+        checkEscape("x x");
+        checkEscape("x x x");
+        checkEscape(" ");
+        checkEscape(" x");
+        checkEscape("x ");
+        checkEscape("  ");
+        checkEscape("   ");
+        checkEscape(" x ");
+        // Handling of dots within the first two characters
+        checkEscape(".");
+        checkEscape("..");
+        checkEscape(".x");
+        checkEscape("x.");
+        checkEscape(". ");
+        checkEscape(" .");
+        // Handling of the special characters
+        checkEscape("%/:[]*'\"|\t\r\n");
+    }
+    
+}



Mime
View raw message