You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@zeppelin.apache.org by jo...@apache.org on 2016/06/15 10:03:49 UTC

zeppelin git commit: ZEPPELIN-992 Move some tests from InterpreterFactoryTest to LazyOpenInterpreterTest

Repository: zeppelin
Updated Branches:
  refs/heads/master 1bc3e9c81 -> 020e0e7f8


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 <jo...@gmail.com>

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/020e0e7f
Tree: http://git-wip-us.apache.org/repos/asf/zeppelin/tree/020e0e7f
Diff: http://git-wip-us.apache.org/repos/asf/zeppelin/diff/020e0e7f

Branch: refs/heads/master
Commit: 020e0e7f815bcbb49a8539e9d7ca4d104916b343
Parents: 1bc3e9c
Author: Jongyoul Lee <jo...@gmail.com>
Authored: Wed Jun 15 00:58:21 2016 +0900
Committer: Jongyoul Lee <jo...@apache.org>
Committed: Wed Jun 15 19:03:43 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/020e0e7f/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/020e0e7f/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"));