phrocker commented on a change in pull request #4:
URL: https://github.com/apache/hbase-native-client/pull/4#discussion_r439368476



##########
File path: src/hbase/test-util/mini-cluster.cc
##########
@@ -20,163 +20,147 @@
 #include "hbase/test-util/mini-cluster.h"
 #include <fcntl.h>
 #include <glog/logging.h>
-#include <boost/filesystem/fstream.hpp>
-#include <boost/filesystem/operations.hpp>
 #include <fstream>
 
 using hbase::MiniCluster;
+using std::string;
+using std::ifstream;
 
 JNIEnv *MiniCluster::CreateVM(JavaVM **jvm) {
   JavaVMInitArgs args;
   JavaVMOption jvm_options;
   args.version = JNI_VERSION_1_6;
   args.nOptions = 1;
+  // Sets the Java classpath to load the test jars and dependencies.
+  // Either set the CLASSPATH environment variable before running the test or 
the test loads it from the default
+  // location, if it exists.
   char *classpath = getenv("CLASSPATH");
-  std::string clspath;
-  if (classpath == NULL || strstr(classpath, "-tests.jar") == NULL) {
-    std::string 
clsPathFilePath("../../../hbase-build-configuration/target/cached_classpath.txt");
-    std::ifstream fd(clsPathFilePath);
-    std::string prefix("");
-    if (fd.is_open()) {
-      if (classpath == NULL) {
-        LOG(INFO) << "got empty classpath";
-      } else {
-        // prefix bootstrapper.jar
-        prefix.assign(classpath);
-      }
-      std::string line;
-      if (getline(fd, line)) {
-        clspath = prefix + ":" + line;
-        int ret = setenv("CLASSPATH", clspath.c_str(), 1);
-        LOG(INFO) << "set clspath " << ret;
-      } else {
-        LOG(INFO) << "nothing read from " << clsPathFilePath;
-        exit(-1);
-      }
-    } else {
-      LOG(INFO) << "nothing read from " << clsPathFilePath;
-      exit(-1);
+  // Copy it to a string so that we don't inadverdently change the environment 
variable.
+  string final_classpath;
+  if (classpath == nullptr || strstr(classpath, "-tests.jar") == nullptr) {
+    if (classpath != nullptr) {
+      final_classpath.assign(classpath);
     }
-    fd.close();
-  } else {
-    clspath.assign(classpath, strlen(classpath));
+    // Default classpath loaded from downloaded HBase src (paths defined in 
CMakeLists.txt)
+    string 
clspath_file_path("./apachehbase-src/hbase-build-configuration/target/cached_classpath.txt");

Review comment:
       In the case where they provide HBASE_HOME this might get a little 
tricky. Could have cmake pass HBASE_HOME as an option for compilation here so 
the path needn't be hardcoded in the future ( as a follow up ). 




----------------------------------------------------------------
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:
[email protected]


Reply via email to