Repository: zeppelin
Updated Branches:
  refs/heads/branch-0.6 c503f450c -> ee7ebca06
Updated Tags:  refs/tags/v0.5.6-rc1 [created] e34579e81


ZEPPELIN-992 Move some tests from InterpreterFactoryTest to 
LazyOpenInterpreterTest

### What is this PR for?
Moving Interpreter.interpret into LazyOpenInterpreterTest in oder to divide 
test scope between InterpreterFactoryTest and LazyOpenInterpreter. This is 
related to #987 a little bit.

### What type of PR is it?
[Refactoring]

### Todos
* [x] - Divide tests

### What is the Jira issue?
* https://issues.apache.org/jira/browse/ZEPPELIN-992

### How should this be tested?
Changed only test case

### Screenshots (if appropriate)

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

Author: Jongyoul Lee <[email protected]>

Closes #1002 from jongyoul/ZEPPELIN-992 and squashes the following commits:

da851da [Jongyoul Lee] Removed author tag
8ef2be3 [Jongyoul Lee] Moved Interpreter.interpret into LazyOpenInterpreterTest


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

Branch: refs/heads/branch-0.6
Commit: ee7ebca065bbe3a2e81ca10118baf047dd3fa561
Parents: c503f45
Author: Jongyoul Lee <[email protected]>
Authored: Wed Jun 15 00:58:21 2016 +0900
Committer: Jongyoul Lee <[email protected]>
Committed: Wed Jun 15 19:05:11 2016 +0900

----------------------------------------------------------------------
 .../interpreter/LazyOpenInterpreterTest.java    | 43 ++++++++++++++++++++
 .../interpreter/InterpreterFactoryTest.java     | 12 ++----
 2 files changed, 46 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/zeppelin/blob/ee7ebca0/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/LazyOpenInterpreterTest.java
----------------------------------------------------------------------
diff --git 
a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/LazyOpenInterpreterTest.java
 
b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/LazyOpenInterpreterTest.java
new file mode 100644
index 0000000..bc34539
--- /dev/null
+++ 
b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/LazyOpenInterpreterTest.java
@@ -0,0 +1,43 @@
+/*
+ * 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.interpreter;
+
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+public class LazyOpenInterpreterTest {
+  Interpreter interpreter = mock(Interpreter.class);
+
+  @Test
+  public void isOpenTest() {
+    InterpreterResult interpreterResult = new 
InterpreterResult(InterpreterResult.Code.SUCCESS, "");
+    when(interpreter.interpret(any(String.class), 
any(InterpreterContext.class))).thenReturn(interpreterResult);
+
+    LazyOpenInterpreter lazyOpenInterpreter = new 
LazyOpenInterpreter(interpreter);
+
+    assertFalse("Interpreter is not open", lazyOpenInterpreter.isOpen());
+    InterpreterContext interpreterContext =
+        new InterpreterContext("note", "id", "title", "text", null, null, 
null, null, null, null, null);
+    lazyOpenInterpreter.interpret("intp 1", interpreterContext);
+    assertTrue("Interpeter is open", lazyOpenInterpreter.isOpen());
+  }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/ee7ebca0/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/InterpreterFactoryTest.java
----------------------------------------------------------------------
diff --git 
a/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/InterpreterFactoryTest.java
 
b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/InterpreterFactoryTest.java
index 742877a..3d9ee6f 100644
--- 
a/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/InterpreterFactoryTest.java
+++ 
b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/InterpreterFactoryTest.java
@@ -17,11 +17,6 @@
 
 package org.apache.zeppelin.interpreter;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
 import java.io.*;
 import java.util.LinkedList;
 import java.util.List;
@@ -39,6 +34,8 @@ import org.junit.Before;
 import org.junit.Test;
 import org.sonatype.aether.RepositoryException;
 
+import static org.junit.Assert.*;
+
 public class InterpreterFactoryTest {
 
   private InterpreterFactory factory;
@@ -91,10 +88,7 @@ public class InterpreterFactoryTest {
     factory.createInterpretersForNote(setting, "sharedProcess", "session");
 
     // get interpreter
-    Interpreter repl1 = interpreterGroup.get("session").get(0);
-    assertFalse(((LazyOpenInterpreter) repl1).isOpen());
-    repl1.interpret("repl1", context);
-    assertTrue(((LazyOpenInterpreter) repl1).isOpen());
+    assertNotNull("get Interpreter", interpreterGroup.get("session").get(0));
 
     // try to get unavailable interpreter
     assertNull(factory.get("unknown"));

Reply via email to