zeppelin-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From m...@apache.org
Subject zeppelin git commit: [ZEPPELIN-1818] Absolute local repo path in dependency downloader
Date Mon, 19 Dec 2016 17:46:48 GMT
Repository: zeppelin
Updated Branches:
  refs/heads/master e230af9cf -> 9f32ecea9


[ZEPPELIN-1818] Absolute local repo path in dependency downloader

### What is this PR for?
Allow dependency resolver to use absolute path for local repo

### What type of PR is it?
Bug Fix

### What is the Jira issue?
[ZEPPELIN-1818](https://issues.apache.org/jira/browse/ZEPPELIN-1818)

### How should this be tested?
Outline the steps to test the PR here.

### Questions:
* Does the licenses files need update? No
* Is there breaking changes for older versions? No
* Does this needs documentation? No

Old implementation expected localRepoPath to be relative to ZEPPELIN_HOME.
It created broken path with absolute localRepoPath
(e.g. C:\Users\User\AppData\Local\Temp\..\C:\......)

Huge amount of tests passed absolute path to newRepositorySystemSession.

Path.resolve(...) works fine if parameter is absolute path

Author: Igor Drozdov <igor_drozdov@epam.com>

Closes #1769 from DrIgor/ZEPPELIN-1807 and squashes the following commits:

4c684af [Igor Drozdov] Set zeppelin.dep.localrepo property in test
eb2b9fc [Igor Drozdov] Make it possible to use absolute local repo path in dependency downloader


Project: http://git-wip-us.apache.org/repos/asf/zeppelin/repo
Commit: http://git-wip-us.apache.org/repos/asf/zeppelin/commit/9f32ecea
Tree: http://git-wip-us.apache.org/repos/asf/zeppelin/tree/9f32ecea
Diff: http://git-wip-us.apache.org/repos/asf/zeppelin/diff/9f32ecea

Branch: refs/heads/master
Commit: 9f32ecea9f77cbbe38ea35ff7c9a3cef8e3d19ec
Parents: e230af9
Author: Igor Drozdov <igor_drozdov@epam.com>
Authored: Fri Dec 16 09:28:41 2016 +0300
Committer: Lee moon soo <moon@apache.org>
Committed: Mon Dec 19 09:46:43 2016 -0800

----------------------------------------------------------------------
 .../spark/PySparkInterpreterMatplotlibTest.java | 38 ++++----------
 .../zeppelin/spark/PySparkInterpreterTest.java  | 36 ++++---------
 .../zeppelin/spark/SparkInterpreterTest.java    | 54 +++++++-------------
 .../zeppelin/spark/SparkSqlInterpreterTest.java | 21 ++++----
 .../java/org/apache/zeppelin/dep/Booter.java    | 37 ++++++++------
 .../org/apache/zeppelin/dep/BooterTest.java     | 49 ++++++++++++++++++
 6 files changed, 116 insertions(+), 119 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/zeppelin/blob/9f32ecea/spark/src/test/java/org/apache/zeppelin/spark/PySparkInterpreterMatplotlibTest.java
----------------------------------------------------------------------
diff --git a/spark/src/test/java/org/apache/zeppelin/spark/PySparkInterpreterMatplotlibTest.java
b/spark/src/test/java/org/apache/zeppelin/spark/PySparkInterpreterMatplotlibTest.java
index abad8e7..9a2a88a 100644
--- a/spark/src/test/java/org/apache/zeppelin/spark/PySparkInterpreterMatplotlibTest.java
+++ b/spark/src/test/java/org/apache/zeppelin/spark/PySparkInterpreterMatplotlibTest.java
@@ -16,20 +16,18 @@
  */
 
 package org.apache.zeppelin.spark;
+
 import org.apache.zeppelin.display.AngularObjectRegistry;
 import org.apache.zeppelin.display.GUI;
 import org.apache.zeppelin.interpreter.*;
 import org.apache.zeppelin.interpreter.InterpreterResult.Type;
 import org.apache.zeppelin.resource.LocalResourcePool;
 import org.apache.zeppelin.user.AuthenticationInfo;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.FixMethodOrder;
-import org.junit.Test;
+import org.junit.*;
+import org.junit.rules.TemporaryFolder;
 import org.junit.runners.MethodSorters;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import java.io.File;
 import java.io.IOException;
 import java.util.HashMap;
 import java.util.LinkedList;
@@ -40,10 +38,13 @@ import static org.junit.Assert.*;
 
 @FixMethodOrder(MethodSorters.NAME_ASCENDING)
 public class PySparkInterpreterMatplotlibTest {
+
+  @Rule
+  public TemporaryFolder tmpDir = new TemporaryFolder();
+
   public static SparkInterpreter sparkInterpreter;
   public static PySparkInterpreter pyspark;
   public static InterpreterGroup intpGroup;
-  private File tmpDir;
   public static Logger LOGGER = LoggerFactory.getLogger(PySparkInterpreterTest.class);
   private InterpreterContext context;
   
@@ -79,7 +80,7 @@ public class PySparkInterpreterMatplotlibTest {
     }
   }
 
-  public static Properties getPySparkTestProperties() {
+  private Properties getPySparkTestProperties() throws IOException {
     Properties p = new Properties();
     p.setProperty("master", "local[*]");
     p.setProperty("spark.app.name", "Zeppelin Test");
@@ -87,6 +88,7 @@ public class PySparkInterpreterMatplotlibTest {
     p.setProperty("zeppelin.spark.maxResult", "1000");
     p.setProperty("zeppelin.spark.importImplicit", "true");
     p.setProperty("zeppelin.pyspark.python", "python");
+    p.setProperty("zeppelin.dep.localrepo", tmpDir.newFolder().getAbsolutePath());
     return p;
   }
 
@@ -106,10 +108,6 @@ public class PySparkInterpreterMatplotlibTest {
 
   @Before
   public void setUp() throws Exception {
-    tmpDir = new File(System.getProperty("java.io.tmpdir") + "/ZeppelinLTest_" + System.currentTimeMillis());
-    System.setProperty("zeppelin.dep.localrepo", tmpDir.getAbsolutePath() + "/local-repo");
-    tmpDir.mkdirs();
-
     intpGroup = new InterpreterGroup();
     intpGroup.put("note", new LinkedList<Interpreter>());
 
@@ -137,24 +135,6 @@ public class PySparkInterpreterMatplotlibTest {
       new InterpreterOutput(null));
   }
 
-  @After
-  public void tearDown() throws Exception {
-    delete(tmpDir);
-  }
-
-  private void delete(File file) {
-    if (file.isFile()) file.delete();
-    else if (file.isDirectory()) {
-      File[] files = file.listFiles();
-      if (files != null && files.length > 0) {
-        for (File f : files) {
-          delete(f);
-        }
-      }
-      file.delete();
-    }
-  }
-
   @Test
   public void dependenciesAreInstalled() {
     // matplotlib

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/9f32ecea/spark/src/test/java/org/apache/zeppelin/spark/PySparkInterpreterTest.java
----------------------------------------------------------------------
diff --git a/spark/src/test/java/org/apache/zeppelin/spark/PySparkInterpreterTest.java b/spark/src/test/java/org/apache/zeppelin/spark/PySparkInterpreterTest.java
index 64e4abd..35b876d 100644
--- a/spark/src/test/java/org/apache/zeppelin/spark/PySparkInterpreterTest.java
+++ b/spark/src/test/java/org/apache/zeppelin/spark/PySparkInterpreterTest.java
@@ -16,20 +16,22 @@
  */
 
 package org.apache.zeppelin.spark;
+
 import org.apache.zeppelin.display.AngularObjectRegistry;
 import org.apache.zeppelin.display.GUI;
 import org.apache.zeppelin.interpreter.*;
 import org.apache.zeppelin.interpreter.thrift.InterpreterCompletion;
 import org.apache.zeppelin.resource.LocalResourcePool;
 import org.apache.zeppelin.user.AuthenticationInfo;
-import org.junit.After;
 import org.junit.Before;
 import org.junit.FixMethodOrder;
+import org.junit.Rule;
 import org.junit.Test;
+import org.junit.rules.TemporaryFolder;
 import org.junit.runners.MethodSorters;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import java.io.File;
+import java.io.IOException;
 import java.util.HashMap;
 import java.util.LinkedList;
 import java.util.List;
@@ -39,14 +41,17 @@ import static org.junit.Assert.*;
 
 @FixMethodOrder(MethodSorters.NAME_ASCENDING)
 public class PySparkInterpreterTest {
+
+  @Rule
+  public TemporaryFolder tmpDir = new TemporaryFolder();
+
   public static SparkInterpreter sparkInterpreter;
   public static PySparkInterpreter pySparkInterpreter;
   public static InterpreterGroup intpGroup;
-  private File tmpDir;
   public static Logger LOGGER = LoggerFactory.getLogger(PySparkInterpreterTest.class);
   private InterpreterContext context;
 
-  public static Properties getPySparkTestProperties() {
+  private Properties getPySparkTestProperties() throws IOException {
     Properties p = new Properties();
     p.setProperty("master", "local[*]");
     p.setProperty("spark.app.name", "Zeppelin Test");
@@ -54,6 +59,7 @@ public class PySparkInterpreterTest {
     p.setProperty("zeppelin.spark.maxResult", "1000");
     p.setProperty("zeppelin.spark.importImplicit", "true");
     p.setProperty("zeppelin.pyspark.python", "python");
+    p.setProperty("zeppelin.dep.localrepo", tmpDir.newFolder().getAbsolutePath());
     return p;
   }
 
@@ -73,10 +79,6 @@ public class PySparkInterpreterTest {
 
   @Before
   public void setUp() throws Exception {
-    tmpDir = new File(System.getProperty("java.io.tmpdir") + "/ZeppelinLTest_" + System.currentTimeMillis());
-    System.setProperty("zeppelin.dep.localrepo", tmpDir.getAbsolutePath() + "/local-repo");
-    tmpDir.mkdirs();
-
     intpGroup = new InterpreterGroup();
     intpGroup.put("note", new LinkedList<Interpreter>());
 
@@ -104,24 +106,6 @@ public class PySparkInterpreterTest {
       new InterpreterOutput(null));
   }
 
-  @After
-  public void tearDown() throws Exception {
-    delete(tmpDir);
-  }
-
-  private void delete(File file) {
-    if (file.isFile()) file.delete();
-    else if (file.isDirectory()) {
-      File[] files = file.listFiles();
-      if (files != null && files.length > 0) {
-        for (File f : files) {
-          delete(f);
-        }
-      }
-      file.delete();
-    }
-  }
-
   @Test
   public void testBasicIntp() {
     if (getSparkVersionNumber() > 11) {

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/9f32ecea/spark/src/test/java/org/apache/zeppelin/spark/SparkInterpreterTest.java
----------------------------------------------------------------------
diff --git a/spark/src/test/java/org/apache/zeppelin/spark/SparkInterpreterTest.java b/spark/src/test/java/org/apache/zeppelin/spark/SparkInterpreterTest.java
index 402962d..1410890 100644
--- a/spark/src/test/java/org/apache/zeppelin/spark/SparkInterpreterTest.java
+++ b/spark/src/test/java/org/apache/zeppelin/spark/SparkInterpreterTest.java
@@ -19,7 +19,7 @@ package org.apache.zeppelin.spark;
 
 import static org.junit.Assert.*;
 
-import java.io.File;
+import java.io.IOException;
 import java.util.HashMap;
 import java.util.LinkedList;
 import java.util.List;
@@ -35,20 +35,24 @@ import org.apache.zeppelin.user.AuthenticationInfo;
 import org.apache.zeppelin.display.GUI;
 import org.apache.zeppelin.interpreter.*;
 import org.apache.zeppelin.interpreter.InterpreterResult.Code;
-import org.junit.After;
 import org.junit.Before;
 import org.junit.FixMethodOrder;
+import org.junit.Rule;
 import org.junit.Test;
+import org.junit.rules.TemporaryFolder;
 import org.junit.runners.MethodSorters;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 @FixMethodOrder(MethodSorters.NAME_ASCENDING)
 public class SparkInterpreterTest {
+
+  @Rule
+  public TemporaryFolder tmpDir = new TemporaryFolder();
+
   public static SparkInterpreter repl;
   public static InterpreterGroup intpGroup;
   private InterpreterContext context;
-  private File tmpDir;
   public static Logger LOGGER = LoggerFactory.getLogger(SparkInterpreterTest.class);
 
   /**
@@ -65,28 +69,24 @@ public class SparkInterpreterTest {
     return version;
   }
 
-  public static Properties getSparkTestProperties() {
+  public static Properties getSparkTestProperties(TemporaryFolder tmpDir) throws IOException
{
     Properties p = new Properties();
     p.setProperty("master", "local[*]");
     p.setProperty("spark.app.name", "Zeppelin Test");
     p.setProperty("zeppelin.spark.useHiveContext", "true");
     p.setProperty("zeppelin.spark.maxResult", "1000");
     p.setProperty("zeppelin.spark.importImplicit", "true");
+    p.setProperty("zeppelin.dep.localrepo", tmpDir.newFolder().getAbsolutePath());
 
     return p;
   }
 
   @Before
   public void setUp() throws Exception {
-    tmpDir = new File(System.getProperty("java.io.tmpdir") + "/ZeppelinLTest_" + System.currentTimeMillis());
-    System.setProperty("zeppelin.dep.localrepo", tmpDir.getAbsolutePath() + "/local-repo");
-
-    tmpDir.mkdirs();
-
     if (repl == null) {
       intpGroup = new InterpreterGroup();
       intpGroup.put("note", new LinkedList<Interpreter>());
-      repl = new SparkInterpreter(getSparkTestProperties());
+      repl = new SparkInterpreter(getSparkTestProperties(tmpDir));
       repl.setInterpreterGroup(intpGroup);
       intpGroup.get("note").add(repl);
       repl.open();
@@ -102,24 +102,6 @@ public class SparkInterpreterTest {
         new InterpreterOutput(null));
   }
 
-  @After
-  public void tearDown() throws Exception {
-    delete(tmpDir);
-  }
-
-  private void delete(File file) {
-    if (file.isFile()) file.delete();
-    else if (file.isDirectory()) {
-      File[] files = file.listFiles();
-      if (files != null && files.length > 0) {
-        for (File f : files) {
-          delete(f);
-        }
-      }
-      file.delete();
-    }
-  }
-
   @Test
   public void testBasicIntp() {
     assertEquals(InterpreterResult.Code.SUCCESS,
@@ -194,7 +176,7 @@ public class SparkInterpreterTest {
   }
 
   @Test
-  public void testSparkSql(){
+  public void testSparkSql() throws IOException {
     repl.interpret("case class Person(name:String, age:Int)\n", context);
     repl.interpret("val people = sc.parallelize(Seq(Person(\"moon\", 33), Person(\"jobs\",
51), Person(\"gates\", 51), Person(\"park\", 34)))\n", context);
     assertEquals(Code.SUCCESS, repl.interpret("people.take(3)", context).code());
@@ -202,7 +184,7 @@ public class SparkInterpreterTest {
 
     if (getSparkVersionNumber() <= 11) { // spark 1.2 or later does not allow create multiple
SparkContext in the same jvm by default.
       // create new interpreter
-      SparkInterpreter repl2 = new SparkInterpreter(getSparkTestProperties());
+      SparkInterpreter repl2 = new SparkInterpreter(getSparkTestProperties(tmpDir));
       repl2.setInterpreterGroup(intpGroup);
       intpGroup.get("note").add(repl2);
       repl2.open();
@@ -236,9 +218,9 @@ public class SparkInterpreterTest {
   }
 
   @Test
-  public void shareSingleSparkContext() throws InterruptedException {
+  public void shareSingleSparkContext() throws InterruptedException, IOException {
     // create another SparkInterpreter
-    SparkInterpreter repl2 = new SparkInterpreter(getSparkTestProperties());
+    SparkInterpreter repl2 = new SparkInterpreter(getSparkTestProperties(tmpDir));
     repl2.setInterpreterGroup(intpGroup);
     intpGroup.get("note").add(repl2);
     repl2.open();
@@ -252,10 +234,10 @@ public class SparkInterpreterTest {
   }
 
   @Test
-  public void testEnableImplicitImport() {
+  public void testEnableImplicitImport() throws IOException {
     if (getSparkVersionNumber() >= 13) {
       // Set option of importing implicits to "true", and initialize new Spark repl
-      Properties p = getSparkTestProperties();
+      Properties p = getSparkTestProperties(tmpDir);
       p.setProperty("zeppelin.spark.importImplicit", "true");
       SparkInterpreter repl2 = new SparkInterpreter(p);
       repl2.setInterpreterGroup(intpGroup);
@@ -269,11 +251,11 @@ public class SparkInterpreterTest {
   }
 
   @Test
-  public void testDisableImplicitImport() {
+  public void testDisableImplicitImport() throws IOException {
     if (getSparkVersionNumber() >= 13) {
       // Set option of importing implicits to "false", and initialize new Spark repl
       // this test should return error status when creating DataFrame from sequence
-      Properties p = getSparkTestProperties();
+      Properties p = getSparkTestProperties(tmpDir);
       p.setProperty("zeppelin.spark.importImplicit", "false");
       SparkInterpreter repl2 = new SparkInterpreter(p);
       repl2.setInterpreterGroup(intpGroup);

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/9f32ecea/spark/src/test/java/org/apache/zeppelin/spark/SparkSqlInterpreterTest.java
----------------------------------------------------------------------
diff --git a/spark/src/test/java/org/apache/zeppelin/spark/SparkSqlInterpreterTest.java b/spark/src/test/java/org/apache/zeppelin/spark/SparkSqlInterpreterTest.java
index 5e5d32c..89cd712 100644
--- a/spark/src/test/java/org/apache/zeppelin/spark/SparkSqlInterpreterTest.java
+++ b/spark/src/test/java/org/apache/zeppelin/spark/SparkSqlInterpreterTest.java
@@ -17,8 +17,6 @@
 
 package org.apache.zeppelin.spark;
 
-import static org.junit.Assert.*;
-
 import java.util.HashMap;
 import java.util.LinkedList;
 import java.util.Properties;
@@ -29,25 +27,28 @@ import org.apache.zeppelin.user.AuthenticationInfo;
 import org.apache.zeppelin.display.GUI;
 import org.apache.zeppelin.interpreter.*;
 import org.apache.zeppelin.interpreter.InterpreterResult.Type;
-import org.junit.After;
 import org.junit.Before;
+import org.junit.Rule;
 import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.junit.rules.TemporaryFolder;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
 
 public class SparkSqlInterpreterTest {
 
+  @Rule
+  public TemporaryFolder tmpDir = new TemporaryFolder();
+
   private SparkSqlInterpreter sql;
   private SparkInterpreter repl;
   private InterpreterContext context;
   private InterpreterGroup intpGroup;
 
-  Logger LOGGER = LoggerFactory.getLogger(SparkSqlInterpreterTest.class);
-
   @Before
   public void setUp() throws Exception {
     Properties p = new Properties();
-    p.putAll(SparkInterpreterTest.getSparkTestProperties());
+    p.putAll(SparkInterpreterTest.getSparkTestProperties(tmpDir));
     p.setProperty("zeppelin.spark.maxResult", "1000");
     p.setProperty("zeppelin.spark.concurrentSQL", "false");
     p.setProperty("zeppelin.spark.sql.stacktrace", "false");
@@ -82,10 +83,6 @@ public class SparkSqlInterpreterTest {
         new LinkedList<InterpreterContextRunner>(), new InterpreterOutput(null));
   }
 
-  @After
-  public void tearDown() throws Exception {
-  }
-
   boolean isDataFrameSupported() {
     return SparkInterpreterTest.getSparkVersionNumber() >= 13;
   }

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/9f32ecea/zeppelin-interpreter/src/main/java/org/apache/zeppelin/dep/Booter.java
----------------------------------------------------------------------
diff --git a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/dep/Booter.java b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/dep/Booter.java
index 7a487fa..f96963b 100644
--- a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/dep/Booter.java
+++ b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/dep/Booter.java
@@ -17,14 +17,15 @@
 
 package org.apache.zeppelin.dep;
 
-import java.io.File;
-
+import org.apache.commons.lang3.Validate;
 import org.apache.maven.repository.internal.MavenRepositorySystemSession;
 import org.sonatype.aether.RepositorySystem;
 import org.sonatype.aether.RepositorySystemSession;
 import org.sonatype.aether.repository.LocalRepository;
 import org.sonatype.aether.repository.RemoteRepository;
 
+import java.nio.file.Paths;
+
 /**
  * Manage mvn repository.
  */
@@ -35,21 +36,11 @@ public class Booter {
 
   public static RepositorySystemSession newRepositorySystemSession(
       RepositorySystem system, String localRepoPath) {
-    MavenRepositorySystemSession session = new MavenRepositorySystemSession();
+    Validate.notNull(localRepoPath, "localRepoPath should have a value");
 
-    // find homedir
-    String home = System.getenv("ZEPPELIN_HOME");
-    if (home == null) {
-      home = System.getProperty("zeppelin.home");
-    }
-    if (home == null) {
-      home = "..";
-    }
-
-    String path = home + "/" + localRepoPath;
+    MavenRepositorySystemSession session = new MavenRepositorySystemSession();
 
-    LocalRepository localRepo =
-        new LocalRepository(new File(path).getAbsolutePath());
+    LocalRepository localRepo = new LocalRepository(resolveLocalRepoPath(localRepoPath));
     session.setLocalRepositoryManager(system.newLocalRepositoryManager(localRepo));
 
     // session.setTransferListener(new ConsoleTransferListener());
@@ -61,10 +52,24 @@ public class Booter {
     return session;
   }
 
+  static String resolveLocalRepoPath(String localRepoPath) {
+    // todo decouple home folder resolution
+    // find homedir
+    String home = System.getenv("ZEPPELIN_HOME");
+    if (home == null) {
+      home = System.getProperty("zeppelin.home");
+    }
+    if (home == null) {
+      home = "..";
+    }
+
+    return Paths.get(home).resolve(localRepoPath).toAbsolutePath().toString();
+  }
+
   public static RemoteRepository newCentralRepository() {
     return new RemoteRepository("central", "default", "http://repo1.maven.org/maven2/");
   }
-  
+
   public static RemoteRepository newLocalRepository() {
     return new RemoteRepository("local",
         "default", "file://" + System.getProperty("user.home") + "/.m2/repository");

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/9f32ecea/zeppelin-interpreter/src/test/java/org/apache/zeppelin/dep/BooterTest.java
----------------------------------------------------------------------
diff --git a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/dep/BooterTest.java b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/dep/BooterTest.java
new file mode 100644
index 0000000..ffc3c8f
--- /dev/null
+++ b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/dep/BooterTest.java
@@ -0,0 +1,49 @@
+/*
+ * 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.zeppelin.dep;
+
+import org.junit.Test;
+
+import java.nio.file.Paths;
+
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
+
+public class BooterTest {
+
+  @Test
+  public void should_return_absolute_path() {
+    String resolvedPath = Booter.resolveLocalRepoPath("path");
+    assertTrue(Paths.get(resolvedPath).isAbsolute());
+  }
+
+  @Test
+  public void should_not_change_absolute_path() {
+    String absolutePath
+        = Paths.get("first", "second").toAbsolutePath().toString();
+    String resolvedPath = Booter.resolveLocalRepoPath(absolutePath);
+
+    assertThat(resolvedPath, equalTo(absolutePath));
+  }
+
+  @Test(expected = NullPointerException.class)
+  public void should_throw_exception_for_null() {
+    Booter.resolveLocalRepoPath(null);
+  }
+}


Mime
View raw message