subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hwri...@apache.org
Subject svn commit: r951031 - in /subversion/trunk/subversion/bindings/javahl: native/org_apache_subversion_javahl_Path.cpp src/org/apache/subversion/javahl/Path.java src/org/tigris/subversion/javahl/Path.java tests/org/apache/subversion/javahl/BasicTests.java
Date Thu, 03 Jun 2010 15:25:54 GMT
Author: hwright
Date: Thu Jun  3 15:25:54 2010
New Revision: 951031

URL: http://svn.apache.org/viewvc?rev=951031&view=rev
Log:
JavaHL: Remove the Path object from the apache package: it isn't being used
anywhere (we universally use Strings instead).

[ in subversion/bindings/javahl/ ]
* tests/org/apache/subversion/javahl/BasicTests.java
  (testPathValidation, testPathIsURL): Remove.

* native/org_apache_subversion_javahl_Path.cpp:
  Remove.

* src/org/apache/subversion/javahl/Path.java:
  Remove.

* src/org/tigris/subversion/javahl/Path.java:
  Bring back the old implementation from r906611.
  (isValid): Implement in Java, rather than natively.

Removed:
    subversion/trunk/subversion/bindings/javahl/native/org_apache_subversion_javahl_Path.cpp
    subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/Path.java
Modified:
    subversion/trunk/subversion/bindings/javahl/src/org/tigris/subversion/javahl/Path.java
    subversion/trunk/subversion/bindings/javahl/tests/org/apache/subversion/javahl/BasicTests.java

Modified: subversion/trunk/subversion/bindings/javahl/src/org/tigris/subversion/javahl/Path.java
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/src/org/tigris/subversion/javahl/Path.java?rev=951031&r1=951030&r2=951031&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/src/org/tigris/subversion/javahl/Path.java
(original)
+++ subversion/trunk/subversion/bindings/javahl/src/org/tigris/subversion/javahl/Path.java
Thu Jun  3 15:25:54 2010
@@ -28,6 +28,56 @@ package org.tigris.subversion.javahl;
  *
  * @since 1.4.0
  */
-public class Path extends org.apache.subversion.javahl.Path
+public class Path
 {
+    /**
+     * Load the required native library.
+     */
+    static
+    {
+        org.apache.subversion.javahl.NativeResources.loadNativeLibrary();
+    }
+
+    /**
+     * A valid path is a UTF-8 string without any control characters.
+     *
+     * @return Whether Subversion can store the path in a repository.
+     */
+    public static boolean isValid(String path)
+    {
+        try {
+            byte[] bytes = path.getBytes("UTF-8");
+
+            for (byte b : bytes)
+            {
+                if (b < 0x20)
+                    return false;
+            }
+
+            return true;
+        }
+        catch (Exception ex)
+        {
+            return false;
+        }
+    }
+
+    /**
+     * Whether a URL is valid. Implementation may behave differently
+     * than <code>svn_path_is_url()</code>.
+     *
+     * @param path The Subversion "path" to inspect.
+     * @return Whether <code>path</code> is a URL.
+     * @throws IllegalArgumentException If <code>path</code> is
+     * <code>null</code>.
+     */
+    public static boolean isURL(String path)
+    {
+        if (path == null)
+        {
+            throw new IllegalArgumentException();
+        }
+        // Require at least "s://".
+        return (path.indexOf("://") > 0);
+    }
 }

Modified: subversion/trunk/subversion/bindings/javahl/tests/org/apache/subversion/javahl/BasicTests.java
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/tests/org/apache/subversion/javahl/BasicTests.java?rev=951031&r1=951030&r2=951031&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/tests/org/apache/subversion/javahl/BasicTests.java
(original)
+++ subversion/trunk/subversion/bindings/javahl/tests/org/apache/subversion/javahl/BasicTests.java
Thu Jun  3 15:25:54 2010
@@ -129,58 +129,6 @@ public class BasicTests extends SVNTests
     }
 
     /**
-     * Tests Subversion path validation.
-     */
-    public void testPathValidation() throws Throwable
-    {
-        // Rather than segfaulting, JavaHL considers null an invalid path.
-        assertFalse("Path validation produced false-positive for null path",
-                    Path.isValid(null));
-
-        String path = "valid-path";
-        assertTrue("Validation check of valid path '" + path +
-                   "' should succeed", Path.isValid(path));
-
-        // File names cannot contain control characters.
-        path = "invalid-\u0001-path";
-        assertFalse("Validation check of invalid path '" + path +
-                    "' (which contains control characters) should fail",
-                    Path.isValid(path));
-    }
-
-    /**
-     * Tests Subversion path as URL predicate.
-     */
-    public void testPathIsURL() throws Throwable
-    {
-        try
-        {
-            Path.isURL(null);
-            fail("A null path should raise an exception");
-        }
-        catch (IllegalArgumentException expected)
-        {
-        }
-
-        // Subversion "paths" which aren't URLs.
-        String[] paths = { "/path", "c:\\path" };
-        for (String path : paths)
-        {
-            assertFalse("'" + path + "' should not be considered a URL",
-                        Path.isURL(path));
-        }
-
-        // Subversion "paths" which are URLs.
-        paths = new String[] { "http://example.com", "svn://example.com",
-                               "svn+ssh://example.com", "file:///src/svn/" };
-        for (String path : paths)
-        {
-            assertTrue("'" + path + "' should be considered a URL",
-                       Path.isURL(path));
-        }
-    }
-
-    /**
      * Tests Mergeinfo and RevisionRange classes.
      * @since 1.5
      */



Mime
View raw message