You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by br...@apache.org on 2013/06/22 18:17:13 UTC

svn commit: r1495751 - in /subversion/trunk/subversion/bindings/javahl: native/ src/org/apache/subversion/javahl/ src/org/apache/subversion/javahl/remote/ tests/org/apache/subversion/javahl/

Author: brane
Date: Sat Jun 22 16:17:12 2013
New Revision: 1495751

URL: http://svn.apache.org/r1495751
Log:
Implement the JavaHL RA methods ISVNRemote.getFile and ISVNRemote.getDirectory.

[in subversion/bindings/javahl/src/org/apache/subversion/javahl]
* ISVNRemote.java (ISVNRemote.getFile): Improve docstring.
  (ISVNRemote.getDirectory): Change the type of the "dirents" argument to a
   Map instead of a collection so that the native implementation does not
   have to worry about sorting the entries. Also improve docstring.
* remote/RemoteSession.java
  (ISVNRemote.getDirectory, RemoteSession.nativeGetDirectory): Update signature.

[in subversion/bindings/javahl/native]
* CreateJ.h (CreateJ::DirEntry, CreateJ::FillPropertyMap): New methods.
* CreateJ.cpp (CreateJ::DirEntry): Grab implementation from ListCallback.cpp.
  (CreateJ::FillPropertyMap): Factor out of CreateJ::PropertyMap.
  (CreateJ::PropertyMap): Call CreateJ::FillPropertyMap.
* ListCallback.cpp (ListCallback::createJavaDirEntry): Replace the
   implementation with a call to CreateJ::DirEntry.

* RemoteSession.cpp (RemoteSession::getFile, RemoteSession::getDirectory):
   Implement, using the new CreateJ::FillPropertyMap to fill in the properties.
  (fill_dirents): Helper for getDirectory, uses CreateJ::DirEntry.

[in subversion/bindings/javahl/tests/org/apache/subversion/javahl]
* SVNRemoteTests.java
  (SVNRemoteTests.testGetFile, SVNRemoteTests.testGetDirectory): New tests.

Modified:
    subversion/trunk/subversion/bindings/javahl/native/CreateJ.cpp
    subversion/trunk/subversion/bindings/javahl/native/CreateJ.h
    subversion/trunk/subversion/bindings/javahl/native/ListCallback.cpp
    subversion/trunk/subversion/bindings/javahl/native/RemoteSession.cpp
    subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/ISVNRemote.java
    subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/remote/RemoteSession.java
    subversion/trunk/subversion/bindings/javahl/tests/org/apache/subversion/javahl/SVNRemoteTests.java

Modified: subversion/trunk/subversion/bindings/javahl/native/CreateJ.cpp
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/native/CreateJ.cpp?rev=1495751&r1=1495750&r2=1495751&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/native/CreateJ.cpp (original)
+++ subversion/trunk/subversion/bindings/javahl/native/CreateJ.cpp Sat Jun 22 16:17:12 2013
@@ -230,6 +230,61 @@ CreateJ::Checksum(const svn_checksum_t *
 }
 
 jobject
+CreateJ::DirEntry(const char *path, const char *absPath,
+                  const svn_dirent_t *dirent)
+{
+  JNIEnv *env = JNIUtil::getEnv();
+
+  // Create a local frame for our references
+  env->PushLocalFrame(LOCAL_FRAME_SIZE);
+  if (JNIUtil::isJavaExceptionThrown())
+    return SVN_NO_ERROR;
+
+  jclass clazz = env->FindClass(JAVA_PACKAGE"/types/DirEntry");
+  if (JNIUtil::isJavaExceptionThrown())
+    POP_AND_RETURN_NULL;
+
+  static jmethodID mid = 0;
+  if (mid == 0)
+    {
+      mid = env->GetMethodID(clazz, "<init>",
+                             "(Ljava/lang/String;Ljava/lang/String;"
+                             "L"JAVA_PACKAGE"/types/NodeKind;"
+                             "JZJJLjava/lang/String;)V");
+      if (JNIUtil::isJavaExceptionThrown())
+        POP_AND_RETURN_NULL;
+    }
+
+  jstring jPath = JNIUtil::makeJString(path);
+  if (JNIUtil::isJavaExceptionThrown())
+    POP_AND_RETURN_NULL;
+
+  jstring jAbsPath = JNIUtil::makeJString(absPath);
+  if (JNIUtil::isJavaExceptionThrown())
+    POP_AND_RETURN_NULL;
+
+  jobject jNodeKind = EnumMapper::mapNodeKind(dirent->kind);
+  if (JNIUtil::isJavaExceptionThrown())
+    POP_AND_RETURN_NULL;
+
+  jlong jSize = dirent->size;
+  jboolean jHasProps = (dirent->has_props? JNI_TRUE : JNI_FALSE);
+  jlong jLastChangedRevision = dirent->created_rev;
+  jlong jLastChanged = dirent->time;
+  jstring jLastAuthor = JNIUtil::makeJString(dirent->last_author);
+  if (JNIUtil::isJavaExceptionThrown())
+    POP_AND_RETURN_NULL;
+
+  jobject ret = env->NewObject(clazz, mid, jPath, jAbsPath, jNodeKind,
+                               jSize, jHasProps, jLastChangedRevision,
+                               jLastChanged, jLastAuthor);
+  if (JNIUtil::isJavaExceptionThrown())
+    POP_AND_RETURN_NULL;
+
+  return env->PopLocalFrame(ret);
+}
+
+jobject
 CreateJ::Info(const char *path, const svn_client_info2_t *info)
 {
   JNIEnv *env = JNIUtil::getEnv();
@@ -1124,6 +1179,37 @@ jobject CreateJ::PropertyMap(apr_hash_t 
   if (JNIUtil::isJavaExceptionThrown())
     POP_AND_RETURN_NULL;
 
+  FillPropertyMap(map, prop_hash, put_mid);
+  if (JNIUtil::isJavaExceptionThrown())
+    POP_AND_RETURN_NULL;
+
+  return env->PopLocalFrame(map);
+}
+
+void CreateJ::FillPropertyMap(jobject map, apr_hash_t* prop_hash,
+                              jmethodID put_mid)
+{
+  JNIEnv *env = JNIUtil::getEnv();
+
+  if (!map || !prop_hash)
+    return;
+
+  // Create a local frame for our references
+  env->PushLocalFrame(LOCAL_FRAME_SIZE);
+  if (JNIUtil::isJavaExceptionThrown())
+    return;
+
+  // The caller may not know the concrete class of the map, so
+  // determine the "put" method identifier here.
+  if (put_mid == 0)
+    {
+      put_mid = env->GetMethodID(env->GetObjectClass(map), "put",
+                                 "(Ljava/lang/Object;Ljava/lang/Object;)"
+                                 "Ljava/lang/Object;");
+      if (JNIUtil::isJavaExceptionThrown())
+        POP_AND_RETURN_NOTHING();
+    }
+
   apr_hash_index_t *hi;
   for (hi = apr_hash_first(apr_hash_pool_get(prop_hash), prop_hash);
        hi; hi = apr_hash_next(hi))
@@ -1131,28 +1217,28 @@ jobject CreateJ::PropertyMap(apr_hash_t 
       const char *key;
       svn_string_t *val;
 
-      apr_hash_this(hi,
-                    reinterpret_cast<const void **>(&key),
-                    NULL,
-                    reinterpret_cast<void **>(&val));
+      const void *v_key;
+      void *v_val;
+
+      apr_hash_this(hi, &v_key, NULL, &v_val);
+      key = static_cast<const char*>(v_key);
+      val = static_cast<svn_string_t*>(v_val);
 
       jstring jpropName = JNIUtil::makeJString(key);
       if (JNIUtil::isJavaExceptionThrown())
-        POP_AND_RETURN_NULL;
+        POP_AND_RETURN_NOTHING();
 
       jbyteArray jpropVal = JNIUtil::makeJByteArray(val);
       if (JNIUtil::isJavaExceptionThrown())
-        POP_AND_RETURN_NULL;
+        POP_AND_RETURN_NOTHING();
 
       env->CallObjectMethod(map, put_mid, jpropName, jpropVal);
       if (JNIUtil::isJavaExceptionThrown())
-        POP_AND_RETURN_NULL;
+        POP_AND_RETURN_NOTHING();
 
       env->DeleteLocalRef(jpropName);
       env->DeleteLocalRef(jpropVal);
     }
-
-  return env->PopLocalFrame(map);
 }
 
 jobject CreateJ::InheritedProps(apr_array_header_t *iprops)

Modified: subversion/trunk/subversion/bindings/javahl/native/CreateJ.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/native/CreateJ.h?rev=1495751&r1=1495750&r2=1495751&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/native/CreateJ.h (original)
+++ subversion/trunk/subversion/bindings/javahl/native/CreateJ.h Sat Jun 22 16:17:12 2013
@@ -49,6 +49,10 @@ class CreateJ
   Checksum(const svn_checksum_t *checksum);
 
   static jobject
+  DirEntry(const char *path, const char *absPath,
+           const svn_dirent_t *dirent);
+
+  static jobject
   Info(const char *path, const svn_client_info2_t *info);
 
   static jobject
@@ -85,6 +89,10 @@ class CreateJ
   static jobject
   PropertyMap(apr_hash_t *prop_hash);
 
+  static void
+  FillPropertyMap(jobject map, apr_hash_t* prop_hash,
+                  jmethodID put_method_id = 0);
+
   static jobject
   InheritedProps(apr_array_header_t *inherited_props);
 

Modified: subversion/trunk/subversion/bindings/javahl/native/ListCallback.cpp
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/native/ListCallback.cpp?rev=1495751&r1=1495750&r2=1495751&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/native/ListCallback.cpp (original)
+++ subversion/trunk/subversion/bindings/javahl/native/ListCallback.cpp Sat Jun 22 16:17:12 2013
@@ -126,53 +126,5 @@ jobject
 ListCallback::createJavaDirEntry(const char *path, const char *absPath,
                                  const svn_dirent_t *dirent)
 {
-  JNIEnv *env = JNIUtil::getEnv();
-
-  // Create a local frame for our references
-  env->PushLocalFrame(LOCAL_FRAME_SIZE);
-  if (JNIUtil::isJavaExceptionThrown())
-    return SVN_NO_ERROR;
-
-  jclass clazz = env->FindClass(JAVA_PACKAGE"/types/DirEntry");
-  if (JNIUtil::isJavaExceptionThrown())
-    POP_AND_RETURN_NULL;
-
-  static jmethodID mid = 0;
-  if (mid == 0)
-    {
-      mid = env->GetMethodID(clazz, "<init>",
-                             "(Ljava/lang/String;Ljava/lang/String;"
-                             "L"JAVA_PACKAGE"/types/NodeKind;"
-                             "JZJJLjava/lang/String;)V");
-      if (JNIUtil::isJavaExceptionThrown())
-        POP_AND_RETURN_NULL;
-    }
-
-  jstring jPath = JNIUtil::makeJString(path);
-  if (JNIUtil::isJavaExceptionThrown())
-    POP_AND_RETURN_NULL;
-
-  jstring jAbsPath = JNIUtil::makeJString(absPath);
-  if (JNIUtil::isJavaExceptionThrown())
-    POP_AND_RETURN_NULL;
-
-  jobject jNodeKind = EnumMapper::mapNodeKind(dirent->kind);
-  if (JNIUtil::isJavaExceptionThrown())
-    POP_AND_RETURN_NULL;
-
-  jlong jSize = dirent->size;
-  jboolean jHasProps = (dirent->has_props? JNI_TRUE : JNI_FALSE);
-  jlong jLastChangedRevision = dirent->created_rev;
-  jlong jLastChanged = dirent->time;
-  jstring jLastAuthor = JNIUtil::makeJString(dirent->last_author);
-  if (JNIUtil::isJavaExceptionThrown())
-    POP_AND_RETURN_NULL;
-
-  jobject ret = env->NewObject(clazz, mid, jPath, jAbsPath, jNodeKind,
-                               jSize, jHasProps, jLastChangedRevision,
-                               jLastChanged, jLastAuthor);
-  if (JNIUtil::isJavaExceptionThrown())
-    POP_AND_RETURN_NULL;
-
-  return env->PopLocalFrame(ret);
+  return CreateJ::DirEntry(path, absPath, dirent);
 }

Modified: subversion/trunk/subversion/bindings/javahl/native/RemoteSession.cpp
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/native/RemoteSession.cpp?rev=1495751&r1=1495750&r2=1495751&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/native/RemoteSession.cpp (original)
+++ subversion/trunk/subversion/bindings/javahl/native/RemoteSession.cpp Sat Jun 22 16:17:12 2013
@@ -33,9 +33,11 @@
 
 #include "svn_ra.h"
 #include "svn_string.h"
+#include "svn_dirent_uri.h"
 
 #include "CreateJ.h"
 #include "EnumMapper.h"
+#include "OutputStream.h"
 #include "Prompter.h"
 #include "Revision.h"
 #include "RemoteSession.h"
@@ -468,15 +470,150 @@ jlong
 RemoteSession::getFile(jlong jrevision, jstring jpath,
                        jobject jcontents, jobject jproperties)
 {
-  return SVN_INVALID_REVNUM;
+  JNIStringHolder path(jpath);
+  if (JNIUtil::isExceptionThrown())
+    return SVN_INVALID_REVNUM;
+
+  OutputStream contents_proxy(jcontents);
+  if (JNIUtil::isExceptionThrown())
+    return SVN_INVALID_REVNUM;
+
+  SVN::Pool subPool(pool);
+  apr_hash_t* props = NULL;
+  svn_revnum_t fetched_rev = svn_revnum_t(jrevision);
+  svn_stream_t* contents = (!jcontents ? NULL
+                            : contents_proxy.getStream(subPool));
+
+  SVN_JNI_ERR(svn_ra_get_file(m_session, path, fetched_rev,
+                              contents, &fetched_rev,
+                              (jproperties ? &props : NULL),
+                              subPool.getPool()),
+              SVN_INVALID_REVNUM);
+
+  if (jproperties)
+    {
+      CreateJ::FillPropertyMap(jproperties, props);
+      if (JNIUtil::isExceptionThrown())
+        return SVN_INVALID_REVNUM;
+    }
+
+  return fetched_rev;
 }
 
+namespace {
+void fill_dirents(const char* base_url, const char* base_relpath,
+                  jobject jdirents, apr_hash_t* dirents,
+                  apr_pool_t* scratch_pool)
+{
+  base_url = apr_pstrcat(scratch_pool, base_url, "/", base_relpath, NULL);
+  base_url = svn_uri_canonicalize(base_url, scratch_pool);
+  svn_stringbuf_t* abs_path = svn_stringbuf_create(base_url, scratch_pool);
+  svn_stringbuf_appendbyte(abs_path, '/');
+  const apr_size_t base_len = abs_path->len;
+
+  JNIEnv *env = JNIUtil::getEnv();
+
+  // Create a local frame for our references
+  env->PushLocalFrame(LOCAL_FRAME_SIZE);
+  if (JNIUtil::isJavaExceptionThrown())
+    return;
+
+  // We have no way of knowing the exact type of `dirents' in advance
+  // so we cannot remember the "put" method ID across calls.
+  jmethodID put_mid =
+    env->GetMethodID(env->GetObjectClass(jdirents), "put",
+                     "(Ljava/lang/Object;Ljava/lang/Object;)"
+                     "Ljava/lang/Object;");
+  if (JNIUtil::isJavaExceptionThrown())
+    POP_AND_RETURN_NOTHING();
+
+  static jfieldID path_fid = 0;
+  if (path_fid == 0)
+    {
+      jclass clazz = env->FindClass(JAVA_PACKAGE "/types/DirEntry");
+      if (JNIUtil::isJavaExceptionThrown())
+        POP_AND_RETURN_NOTHING();
+
+      path_fid = env->GetFieldID(clazz, "path", "Ljava/lang/String;");
+      if (JNIUtil::isJavaExceptionThrown())
+        POP_AND_RETURN_NOTHING();
+    }
+
+  for (apr_hash_index_t* hi = apr_hash_first(scratch_pool, dirents);
+       hi; hi = apr_hash_next(hi))
+    {
+      const char* path;
+      svn_dirent_t* dirent;
+
+      const void *v_key;
+      void *v_val;
+
+      apr_hash_this(hi, &v_key, NULL, &v_val);
+      path = static_cast<const char*>(v_key);
+      dirent = static_cast<svn_dirent_t*>(v_val);
+      abs_path->len = base_len;
+      svn_stringbuf_appendcstr(abs_path, path);
+
+      jobject jdirent = CreateJ::DirEntry(path, abs_path->data, dirent);
+      if (JNIUtil::isJavaExceptionThrown())
+        POP_AND_RETURN_NOTHING();
+
+      // Use the existing DirEntry.path field as the key
+      jstring jpath = jstring(env->GetObjectField(jdirent, path_fid));
+      if (JNIUtil::isJavaExceptionThrown())
+        POP_AND_RETURN_NOTHING();
+
+      env->CallObjectMethod(jdirents, put_mid, jpath, jdirent);
+      if (JNIUtil::isJavaExceptionThrown())
+        POP_AND_RETURN_NOTHING();
+      env->DeleteLocalRef(jdirent);
+    }
+
+  POP_AND_RETURN_NOTHING();
+}
+} // anonymous namespace
+
 jlong
 RemoteSession::getDirectory(jlong jrevision, jstring jpath,
                             jint jdirent_fields, jobject jdirents,
                             jobject jproperties)
 {
-  return SVN_INVALID_REVNUM;
+  JNIStringHolder path(jpath);
+  if (JNIUtil::isExceptionThrown())
+    return SVN_INVALID_REVNUM;
+
+  SVN::Pool subPool(pool);
+  apr_hash_t* props = NULL;
+  apr_hash_t* dirents = NULL;
+  svn_revnum_t fetched_rev = svn_revnum_t(jrevision);
+
+  SVN_JNI_ERR(svn_ra_get_dir2(m_session, (jdirents ? &dirents : NULL),
+                              &fetched_rev, (jproperties ? &props : NULL),
+                              path, fetched_rev, apr_uint32_t(jdirent_fields),
+                              subPool.getPool()),
+              SVN_INVALID_REVNUM);
+
+  if (jdirents)
+    {
+      // We will construct the absolute path in the DirEntry objects
+      // from the session URL and directory relpath.
+      const char* base_url;
+      SVN_JNI_ERR(svn_ra_get_session_url(m_session, &base_url,
+                                         subPool.getPool()),
+                  SVN_INVALID_REVNUM);
+      fill_dirents(base_url, path, jdirents, dirents, subPool.getPool());
+      if (JNIUtil::isExceptionThrown())
+        return SVN_INVALID_REVNUM;
+    }
+
+  if (jproperties)
+    {
+      CreateJ::FillPropertyMap(jproperties, props);
+      if (JNIUtil::isExceptionThrown())
+        return SVN_INVALID_REVNUM;
+    }
+
+  return fetched_rev;
 }
 
 // TODO: getMergeinfo

Modified: subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/ISVNRemote.java
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/ISVNRemote.java?rev=1495751&r1=1495750&r2=1495751&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/ISVNRemote.java (original)
+++ subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/ISVNRemote.java Sat Jun 22 16:17:12 2013
@@ -26,7 +26,6 @@ package org.apache.subversion.javahl;
 import org.apache.subversion.javahl.types.*;
 import org.apache.subversion.javahl.callback.*;
 
-import java.util.Collection;
 import java.util.Date;
 import java.util.Map;
 import java.io.OutputStream;
@@ -188,8 +187,9 @@ public interface ISVNRemote
      * will be discarded by calling {@link java.util.Map#clear()}, if the
      * map implementation supports that operation.
      * <p>
-     * The implementation of <code>contents</code> may not perform any
-     * ISVNRemote operations using this session.
+     * The implementations of <code>contents</code> and
+     * <code>properties</code> may not perform any ISVNRemote
+     * operations using this session.
      * @return The revision of the file that was retreived.
      * @throws ClientException
      */
@@ -206,10 +206,11 @@ public interface ISVNRemote
      * used. <code>path</code> is interpreted relative to the
      * session's URL.
      * <p>
-     * If <code>dirents</code> is not <code>null</code>, it will contain
-     * all the entries of the directory. Any existing contente of the
+     * If <code>dirents</code> is not <code>null</code>, it will
+     * contain all the entries of the directory; the keys will be the
+     * entry basenames.  Any existing contente of the
      * <code>dirents</code> collection will be discarded by calling
-     * {@link java.util.Collection#clear()}, if the collection implementation
+     * {@link java.util.Map#clear()}, if the collection implementation
      * supports that operation.
      * <p>
      * <code>direntFields</code> controls which portions of the DirEntry
@@ -226,15 +227,17 @@ public interface ISVNRemote
      * will be discarded by calling {@link java.util.Map#clear()}, if the
      * map implementation supports that operation.
      * <p>
-     * The implementation of <code>dirents</code> may not perform any
-     * ISVNRemote operations using this session.
+     * The implementations of <code>dirents</code> and
+     * <code>properties</code> may not perform any ISVNRemote
+     * operations using this session.
      * @return The revision of the directory that was retreived.
      * @throws IllegalArgumentException if <code>direntFields</code>
      *         is less than or equal to 0.
      * @throws ClientException
      */
     long getDirectory(long revision, String path,
-                      int direntFields, Collection<DirEntry> dirents,
+                      int direntFields,
+                      Map<String, DirEntry> dirents,
                       Map<String, byte[]> properties)
             throws ClientException;
 

Modified: subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/remote/RemoteSession.java
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/remote/RemoteSession.java?rev=1495751&r1=1495750&r2=1495751&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/remote/RemoteSession.java (original)
+++ subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/remote/RemoteSession.java Sat Jun 22 16:17:12 2013
@@ -34,7 +34,6 @@ import org.apache.subversion.javahl.Oper
 import org.apache.subversion.javahl.ClientException;
 
 import java.lang.ref.WeakReference;
-import java.util.Collection;
 import java.util.HashSet;
 import java.util.Date;
 import java.util.Map;
@@ -129,12 +128,14 @@ public class RemoteSession extends JNIOb
     }
 
     public long getDirectory(long revision, String path,
-                             int direntFields, Collection<DirEntry> dirents,
+                             int direntFields,
+                             Map<String, DirEntry> dirents,
                              Map<String, byte[]> properties)
             throws ClientException
     {
-        if (direntFields <= 0)
-            throw new IllegalArgumentException("direntFields must be positive");
+        if (direntFields <= 0 && direntFields != DirEntry.Fields.all)
+            throw new IllegalArgumentException(
+                "direntFields must be positive or DirEntry.Fields.all");
         maybe_clear(dirents);
         maybe_clear(properties);
         return nativeGetDirectory(revision, path,
@@ -205,7 +206,7 @@ public class RemoteSession extends JNIOb
 
     private native long nativeGetDirectory(long revision, String path,
                                            int direntFields,
-                                           Collection<DirEntry> dirents,
+                                           Map<String, DirEntry> dirents,
                                            Map<String, byte[]> properties)
             throws ClientException;
     private native boolean nativeHasCapability(String capability)
@@ -235,14 +236,4 @@ public class RemoteSession extends JNIOb
                 // ignored
             }
     }
-
-    private final static void maybe_clear(Collection clearable)
-    {
-        if (clearable != null && !clearable.isEmpty())
-            try {
-                clearable.clear();
-            } catch (UnsupportedOperationException ex) {
-                // ignored
-            }
-    }
 }

Modified: subversion/trunk/subversion/bindings/javahl/tests/org/apache/subversion/javahl/SVNRemoteTests.java
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/tests/org/apache/subversion/javahl/SVNRemoteTests.java?rev=1495751&r1=1495750&r2=1495751&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/tests/org/apache/subversion/javahl/SVNRemoteTests.java (original)
+++ subversion/trunk/subversion/bindings/javahl/tests/org/apache/subversion/javahl/SVNRemoteTests.java Sat Jun 22 16:17:12 2013
@@ -30,7 +30,9 @@ import java.util.Arrays;
 import java.util.Date;
 import java.util.Set;
 import java.util.Map;
+import java.util.HashMap;
 import java.util.HashSet;
+import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.nio.charset.Charset;
 
@@ -327,4 +329,44 @@ public class SVNRemoteTests extends SVNT
         byte[] propval = session.getRevisionProperty(1, "svn:author");
         assertTrue(Arrays.equals(propval, USERNAME.getBytes(UTF8)));
     }
+
+    public void testGetFile() throws Exception
+    {
+        Charset UTF8 = Charset.forName("UTF-8");
+        ISVNRemote session = getSession();
+
+        ByteArrayOutputStream contents = new ByteArrayOutputStream();
+        HashMap<String, byte[]> properties = new HashMap<String, byte[]>();
+        properties.put("fakename", "fakecontents".getBytes(UTF8));
+        long fetched_rev =
+            session.getFile(Revision.SVN_INVALID_REVNUM, "A/B/lambda",
+                            contents, properties);
+        assertEquals(fetched_rev, 1);
+        assertEquals(contents.toString("UTF-8"),
+                     "This is the file 'lambda'.");
+        for (Map.Entry<String, byte[]> e : properties.entrySet())
+            assertTrue(e.getKey().startsWith("svn:entry:"));
+    }
+
+    public void testGetDirectory() throws Exception
+    {
+        Charset UTF8 = Charset.forName("UTF-8");
+        ISVNRemote session = getSession();
+
+        HashMap<String, DirEntry> dirents = new HashMap<String, DirEntry>();
+        dirents.put("E", null);
+        dirents.put("F", null);
+        dirents.put("lambda", null);
+        HashMap<String, byte[]> properties = new HashMap<String, byte[]>();
+        properties.put("fakename", "fakecontents".getBytes(UTF8));
+        long fetched_rev =
+            session.getDirectory(Revision.SVN_INVALID_REVNUM, "A/B",
+                                 DirEntry.Fields.all, dirents, properties);
+        assertEquals(fetched_rev, 1);
+        assertEquals(dirents.get("E").getPath(), "E");
+        assertEquals(dirents.get("F").getPath(), "F");
+        assertEquals(dirents.get("lambda").getPath(), "lambda");
+        for (Map.Entry<String, byte[]> e : properties.entrySet())
+            assertTrue(e.getKey().startsWith("svn:entry:"));
+    }
 }