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 2018/08/29 10:07:00 UTC
[04/50] [abbrv] zeppelin git commit: Revert "[ZEPPELIN-3740] Adopt
`google-java-format` and `fmt-maven-plugin`"
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/0d746fa2/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/install/InstallInterpreterTest.java
----------------------------------------------------------------------
diff --git a/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/install/InstallInterpreterTest.java b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/install/InstallInterpreterTest.java
index a03cee9..e934f1a 100644
--- a/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/install/InstallInterpreterTest.java
+++ b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/install/InstallInterpreterTest.java
@@ -1,16 +1,17 @@
package org.apache.zeppelin.interpreter.install;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-import java.io.File;
-import java.io.IOException;
import org.apache.commons.io.FileUtils;
import org.apache.zeppelin.conf.ZeppelinConfiguration;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
+import java.io.File;
+import java.io.IOException;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -34,9 +35,7 @@ public class InstallInterpreterTest {
@Before
public void setUp() throws IOException {
- tmpDir =
- new File(
- System.getProperty("java.io.tmpdir") + "/ZeppelinLTest_" + System.currentTimeMillis());
+ tmpDir = new File(System.getProperty("java.io.tmpdir")+"/ZeppelinLTest_"+System.currentTimeMillis());
new File(tmpDir, "conf").mkdirs();
interpreterBaseDir = new File(tmpDir, "interpreter");
File localRepoDir = new File(tmpDir, "local-repo");
@@ -45,9 +44,9 @@ public class InstallInterpreterTest {
File interpreterListFile = new File(tmpDir, "conf/interpreter-list");
+
// create interpreter list file
- System.setProperty(
- ZeppelinConfiguration.ConfVars.ZEPPELIN_HOME.getVarName(), tmpDir.getAbsolutePath());
+ System.setProperty(ZeppelinConfiguration.ConfVars.ZEPPELIN_HOME.getVarName(), tmpDir.getAbsolutePath());
String interpreterList = "";
interpreterList += "intp1 org.apache.commons:commons-csv:1.1 test interpreter 1\n";
@@ -55,9 +54,8 @@ public class InstallInterpreterTest {
FileUtils.writeStringToFile(new File(tmpDir, "conf/interpreter-list"), interpreterList);
- installer =
- new InstallInterpreter(
- interpreterListFile, interpreterBaseDir, localRepoDir.getAbsolutePath());
+ installer = new InstallInterpreter(interpreterListFile, interpreterBaseDir, localRepoDir
+ .getAbsolutePath());
}
@After
@@ -65,6 +63,7 @@ public class InstallInterpreterTest {
FileUtils.deleteDirectory(tmpDir);
}
+
@Test
public void testList() {
assertEquals(2, installer.list().size());
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/0d746fa2/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/lifecycle/TimeoutLifecycleManagerTest.java
----------------------------------------------------------------------
diff --git a/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/lifecycle/TimeoutLifecycleManagerTest.java b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/lifecycle/TimeoutLifecycleManagerTest.java
index 0576e9b..db08016 100644
--- a/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/lifecycle/TimeoutLifecycleManagerTest.java
+++ b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/lifecycle/TimeoutLifecycleManagerTest.java
@@ -17,12 +17,6 @@
package org.apache.zeppelin.interpreter.lifecycle;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import java.io.IOException;
-import java.util.Map;
import org.apache.zeppelin.conf.ZeppelinConfiguration;
import org.apache.zeppelin.interpreter.AbstractInterpreterTest;
import org.apache.zeppelin.interpreter.InterpreterContext;
@@ -32,43 +26,39 @@ import org.apache.zeppelin.interpreter.remote.RemoteInterpreter;
import org.apache.zeppelin.scheduler.Job;
import org.junit.Test;
+import java.io.IOException;
+import java.util.Map;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
public class TimeoutLifecycleManagerTest extends AbstractInterpreterTest {
@Override
public void setUp() throws Exception {
- System.setProperty(
- ZeppelinConfiguration.ConfVars.ZEPPELIN_INTERPRETER_LIFECYCLE_MANAGER_CLASS.getVarName(),
+ System.setProperty(ZeppelinConfiguration.ConfVars.ZEPPELIN_INTERPRETER_LIFECYCLE_MANAGER_CLASS.getVarName(),
TimeoutLifecycleManager.class.getName());
- System.setProperty(
- ZeppelinConfiguration.ConfVars.ZEPPELIN_INTERPRETER_LIFECYCLE_MANAGER_TIMEOUT_CHECK_INTERVAL
- .getVarName(),
- "1000");
- System.setProperty(
- ZeppelinConfiguration.ConfVars.ZEPPELIN_INTERPRETER_LIFECYCLE_MANAGER_TIMEOUT_THRESHOLD
- .getVarName(),
- "10000");
+ System.setProperty(ZeppelinConfiguration.ConfVars.ZEPPELIN_INTERPRETER_LIFECYCLE_MANAGER_TIMEOUT_CHECK_INTERVAL.getVarName(), "1000");
+ System.setProperty(ZeppelinConfiguration.ConfVars.ZEPPELIN_INTERPRETER_LIFECYCLE_MANAGER_TIMEOUT_THRESHOLD.getVarName(), "10000");
super.setUp();
}
@Test
public void testTimeout_1() throws InterpreterException, InterruptedException, IOException {
- assertTrue(
- interpreterFactory.getInterpreter("user1", "note1", "test.echo", "test")
- instanceof RemoteInterpreter);
- RemoteInterpreter remoteInterpreter =
- (RemoteInterpreter)
- interpreterFactory.getInterpreter("user1", "note1", "test.echo", "test");
+ assertTrue(interpreterFactory.getInterpreter("user1", "note1", "test.echo", "test") instanceof RemoteInterpreter);
+ RemoteInterpreter remoteInterpreter = (RemoteInterpreter) interpreterFactory.getInterpreter("user1", "note1", "test.echo", "test");
assertFalse(remoteInterpreter.isOpened());
- InterpreterSetting interpreterSetting =
- interpreterSettingManager.getInterpreterSettingByName("test");
+ InterpreterSetting interpreterSetting = interpreterSettingManager.getInterpreterSettingByName("test");
assertEquals(1, interpreterSetting.getAllInterpreterGroups().size());
- Thread.sleep(15 * 1000);
- // InterpreterGroup is not removed after 15 seconds, as TimeoutLifecycleManager only manage it
- // after it is started
+ Thread.sleep(15*1000);
+ // InterpreterGroup is not removed after 15 seconds, as TimeoutLifecycleManager only manage it after it is started
assertEquals(1, interpreterSetting.getAllInterpreterGroups().size());
- InterpreterContext context =
- InterpreterContext.builder().setNoteId("noteId").setParagraphId("paragraphId").build();
+ InterpreterContext context = InterpreterContext.builder()
+ .setNoteId("noteId")
+ .setParagraphId("paragraphId")
+ .build();
remoteInterpreter.interpret("hello world", context);
assertTrue(remoteInterpreter.isOpened());
@@ -80,59 +70,52 @@ public class TimeoutLifecycleManagerTest extends AbstractInterpreterTest {
@Test
public void testTimeout_2() throws InterpreterException, InterruptedException, IOException {
- assertTrue(
- interpreterFactory.getInterpreter("user1", "note1", "test.sleep", "test")
- instanceof RemoteInterpreter);
- final RemoteInterpreter remoteInterpreter =
- (RemoteInterpreter)
- interpreterFactory.getInterpreter("user1", "note1", "test.sleep", "test");
+ assertTrue(interpreterFactory.getInterpreter("user1", "note1", "test.sleep", "test") instanceof RemoteInterpreter);
+ final RemoteInterpreter remoteInterpreter = (RemoteInterpreter) interpreterFactory.getInterpreter("user1", "note1", "test.sleep", "test");
// simulate how zeppelin submit paragraph
- remoteInterpreter
- .getScheduler()
- .submit(
- new Job("test-job", null) {
- @Override
- public Object getReturn() {
- return null;
- }
-
- @Override
- public int progress() {
- return 0;
- }
-
- @Override
- public Map<String, Object> info() {
- return null;
- }
-
- @Override
- protected Object jobRun() throws Throwable {
- InterpreterContext context =
- InterpreterContext.builder()
- .setNoteId("noteId")
- .setParagraphId("paragraphId")
- .build();
- return remoteInterpreter.interpret("100000", context);
- }
-
- @Override
- protected boolean jobAbort() {
- return false;
- }
-
- @Override
- public void setResult(Object results) {}
- });
-
- while (!remoteInterpreter.isOpened()) {
+ remoteInterpreter.getScheduler().submit(new Job("test-job", null) {
+ @Override
+ public Object getReturn() {
+ return null;
+ }
+
+ @Override
+ public int progress() {
+ return 0;
+ }
+
+ @Override
+ public Map<String, Object> info() {
+ return null;
+ }
+
+ @Override
+ protected Object jobRun() throws Throwable {
+ InterpreterContext context = InterpreterContext.builder()
+ .setNoteId("noteId")
+ .setParagraphId("paragraphId")
+ .build();
+ return remoteInterpreter.interpret("100000", context);
+ }
+
+ @Override
+ protected boolean jobAbort() {
+ return false;
+ }
+
+ @Override
+ public void setResult(Object results) {
+
+ }
+ });
+
+ while(!remoteInterpreter.isOpened()) {
Thread.sleep(1000);
LOGGER.info("Wait for interpreter to be started");
}
- InterpreterSetting interpreterSetting =
- interpreterSettingManager.getInterpreterSettingByName("test");
+ InterpreterSetting interpreterSetting = interpreterSettingManager.getInterpreterSettingByName("test");
assertEquals(1, interpreterSetting.getAllInterpreterGroups().size());
Thread.sleep(15 * 1000);
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/0d746fa2/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/mock/MockInterpreter1.java
----------------------------------------------------------------------
diff --git a/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/mock/MockInterpreter1.java b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/mock/MockInterpreter1.java
index c466641..500c4f7 100644
--- a/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/mock/MockInterpreter1.java
+++ b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/mock/MockInterpreter1.java
@@ -1,28 +1,22 @@
/*
- * 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.
- */
+* 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.mock;
-import java.lang.management.ManagementFactory;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.concurrent.atomic.AtomicInteger;
import org.apache.zeppelin.interpreter.Interpreter;
import org.apache.zeppelin.interpreter.InterpreterContext;
import org.apache.zeppelin.interpreter.InterpreterResult;
@@ -30,86 +24,92 @@ import org.apache.zeppelin.interpreter.thrift.InterpreterCompletion;
import org.apache.zeppelin.scheduler.Scheduler;
import org.apache.zeppelin.scheduler.SchedulerFactory;
+import java.lang.management.ManagementFactory;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.concurrent.atomic.AtomicInteger;
+
public class MockInterpreter1 extends Interpreter {
- private static AtomicInteger IdGenerator = new AtomicInteger();
-
- private int object_id;
- private String pid;
- Map<String, Object> vars = new HashMap<>();
-
- public MockInterpreter1(Properties property) {
- super(property);
- this.object_id = IdGenerator.getAndIncrement();
- this.pid = ManagementFactory.getRuntimeMXBean().getName().split("@")[0];
- }
-
- boolean open;
-
- @Override
- public void open() {
- open = true;
- }
-
- @Override
- public void close() {
- open = false;
- }
-
- public boolean isOpen() {
- return open;
- }
-
- @Override
- public InterpreterResult interpret(String st, InterpreterContext context) {
- InterpreterResult result;
-
- if ("getId".equals(st)) {
- // get unique id of this interpreter instance
- result =
- new InterpreterResult(
- InterpreterResult.Code.SUCCESS, "" + this.object_id + "-" + this.pid);
- } else if (st.startsWith("sleep")) {
- try {
- Thread.sleep(Integer.parseInt(st.split(" ")[1]));
- } catch (InterruptedException e) {
- // nothing to do
- }
- result = new InterpreterResult(InterpreterResult.Code.SUCCESS, "repl1: " + st);
- } else {
- result = new InterpreterResult(InterpreterResult.Code.SUCCESS, "repl1: " + st);
- }
-
- if (context.getResourcePool() != null) {
- context
- .getResourcePool()
- .put(context.getNoteId(), context.getParagraphId(), "result", result);
- }
-
- return result;
- }
-
- @Override
- public void cancel(InterpreterContext context) {}
-
- @Override
- public FormType getFormType() {
- return FormType.SIMPLE;
- }
-
- @Override
- public int getProgress(InterpreterContext context) {
- return 0;
- }
-
- @Override
- public Scheduler getScheduler() {
- return SchedulerFactory.singleton().createOrGetFIFOScheduler("test_" + this.hashCode());
- }
-
- @Override
- public List<InterpreterCompletion> completion(
- String buf, int cursor, InterpreterContext interpreterContext) {
- return null;
- }
+ private static AtomicInteger IdGenerator = new AtomicInteger();
+
+ private int object_id;
+ private String pid;
+ Map<String, Object> vars = new HashMap<>();
+
+ public MockInterpreter1(Properties property) {
+ super(property);
+ this.object_id = IdGenerator.getAndIncrement();
+ this.pid = ManagementFactory.getRuntimeMXBean().getName().split("@")[0];
+ }
+
+ boolean open;
+
+
+ @Override
+ public void open() {
+ open = true;
+ }
+
+ @Override
+ public void close() {
+ open = false;
+ }
+
+
+ public boolean isOpen() {
+ return open;
+ }
+
+ @Override
+ public InterpreterResult interpret(String st, InterpreterContext context) {
+ InterpreterResult result;
+
+ if ("getId".equals(st)) {
+ // get unique id of this interpreter instance
+ result = new InterpreterResult(InterpreterResult.Code.SUCCESS, "" + this.object_id + "-" + this.pid);
+ } else if (st.startsWith("sleep")) {
+ try {
+ Thread.sleep(Integer.parseInt(st.split(" ")[1]));
+ } catch (InterruptedException e) {
+ // nothing to do
+ }
+ result = new InterpreterResult(InterpreterResult.Code.SUCCESS, "repl1: " + st);
+ } else {
+ result = new InterpreterResult(InterpreterResult.Code.SUCCESS, "repl1: " + st);
+ }
+
+ if (context.getResourcePool() != null) {
+ context.getResourcePool().put(context.getNoteId(), context.getParagraphId(), "result", result);
+ }
+
+ return result;
+ }
+
+ @Override
+ public void cancel(InterpreterContext context) {
+ }
+
+ @Override
+ public FormType getFormType() {
+ return FormType.SIMPLE;
+ }
+
+ @Override
+ public int getProgress(InterpreterContext context) {
+ return 0;
+ }
+
+ @Override
+ public Scheduler getScheduler() {
+ return SchedulerFactory.singleton().createOrGetFIFOScheduler("test_"+this.hashCode());
+ }
+
+ @Override
+ public List<InterpreterCompletion> completion(String buf, int cursor,
+ InterpreterContext interpreterContext) {
+ return null;
+ }
}
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/0d746fa2/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/mock/MockInterpreter2.java
----------------------------------------------------------------------
diff --git a/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/mock/MockInterpreter2.java b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/mock/MockInterpreter2.java
index 0d70635..f36df56 100644
--- a/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/mock/MockInterpreter2.java
+++ b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/mock/MockInterpreter2.java
@@ -17,10 +17,6 @@
package org.apache.zeppelin.interpreter.mock;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
import org.apache.zeppelin.interpreter.Interpreter;
import org.apache.zeppelin.interpreter.InterpreterContext;
import org.apache.zeppelin.interpreter.InterpreterResult;
@@ -28,76 +24,81 @@ import org.apache.zeppelin.interpreter.thrift.InterpreterCompletion;
import org.apache.zeppelin.scheduler.Scheduler;
import org.apache.zeppelin.scheduler.SchedulerFactory;
-public class MockInterpreter2 extends Interpreter {
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+public class MockInterpreter2 extends Interpreter{
Map<String, Object> vars = new HashMap<>();
- public MockInterpreter2(Properties property) {
- super(property);
- }
-
- boolean open;
-
- @Override
- public void open() {
- open = true;
- }
-
- @Override
- public void close() {
- open = false;
- }
-
- public boolean isOpen() {
- return open;
- }
-
- @Override
- public InterpreterResult interpret(String st, InterpreterContext context) {
- InterpreterResult result;
-
- if ("getId".equals(st)) {
- // get unique id of this interpreter instance
- result = new InterpreterResult(InterpreterResult.Code.SUCCESS, "" + this.hashCode());
- } else if (st.startsWith("sleep")) {
- try {
- Thread.sleep(Integer.parseInt(st.split(" ")[1]));
- } catch (InterruptedException e) {
- // nothing to do
- }
- result = new InterpreterResult(InterpreterResult.Code.SUCCESS, "repl2: " + st);
- } else {
- result = new InterpreterResult(InterpreterResult.Code.SUCCESS, "repl2: " + st);
- }
-
- if (context.getResourcePool() != null) {
- context
- .getResourcePool()
- .put(context.getNoteId(), context.getParagraphId(), "result", result);
- }
- return result;
- }
-
- @Override
- public void cancel(InterpreterContext context) {}
-
- @Override
- public FormType getFormType() {
- return FormType.SIMPLE;
- }
-
- @Override
- public int getProgress(InterpreterContext context) {
- return 0;
- }
-
- @Override
- public Scheduler getScheduler() {
- return SchedulerFactory.singleton().createOrGetFIFOScheduler("test_" + this.hashCode());
- }
-
- @Override
- public List<InterpreterCompletion> completion(
- String buf, int cursor, InterpreterContext interpreterContext) {
- return null;
- }
+ public MockInterpreter2(Properties property) {
+ super(property);
+ }
+
+ boolean open;
+
+ @Override
+ public void open() {
+ open = true;
+ }
+
+ @Override
+ public void close() {
+ open = false;
+ }
+
+ public boolean isOpen() {
+ return open;
+ }
+
+
+ @Override
+ public InterpreterResult interpret(String st, InterpreterContext context) {
+ InterpreterResult result;
+
+ if ("getId".equals(st)) {
+ // get unique id of this interpreter instance
+ result = new InterpreterResult(InterpreterResult.Code.SUCCESS, "" + this.hashCode());
+ } else if (st.startsWith("sleep")) {
+ try {
+ Thread.sleep(Integer.parseInt(st.split(" ")[1]));
+ } catch (InterruptedException e) {
+ // nothing to do
+ }
+ result = new InterpreterResult(InterpreterResult.Code.SUCCESS, "repl2: " + st);
+ } else {
+ result = new InterpreterResult(InterpreterResult.Code.SUCCESS, "repl2: " + st);
+ }
+
+ if (context.getResourcePool() != null) {
+ context.getResourcePool().put(context.getNoteId(), context.getParagraphId(), "result", result);
+ }
+ return result;
+ }
+
+ @Override
+ public void cancel(InterpreterContext context) {
+ }
+
+ @Override
+ public FormType getFormType() {
+ return FormType.SIMPLE;
+ }
+
+ @Override
+ public int getProgress(InterpreterContext context) {
+ return 0;
+ }
+
+ @Override
+ public Scheduler getScheduler() {
+ return SchedulerFactory.singleton().createOrGetFIFOScheduler("test_"+this.hashCode());
+ }
+
+ @Override
+ public List<InterpreterCompletion> completion(String buf, int cursor,
+ InterpreterContext interpreterContext) {
+ return null;
+ }
}
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/0d746fa2/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/recovery/FileSystemRecoveryStorageTest.java
----------------------------------------------------------------------
diff --git a/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/recovery/FileSystemRecoveryStorageTest.java b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/recovery/FileSystemRecoveryStorageTest.java
index c0b4f3a..2eaed74 100644
--- a/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/recovery/FileSystemRecoveryStorageTest.java
+++ b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/recovery/FileSystemRecoveryStorageTest.java
@@ -1,10 +1,6 @@
package org.apache.zeppelin.interpreter.recovery;
-import static org.junit.Assert.assertEquals;
-
import com.google.common.io.Files;
-import java.io.File;
-import java.io.IOException;
import org.apache.commons.io.FileUtils;
import org.apache.zeppelin.conf.ZeppelinConfiguration;
import org.apache.zeppelin.interpreter.AbstractInterpreterTest;
@@ -17,19 +13,21 @@ import org.apache.zeppelin.interpreter.remote.RemoteInterpreter;
import org.junit.Before;
import org.junit.Test;
+import java.io.File;
+import java.io.IOException;
+
+import static org.junit.Assert.assertEquals;
+
public class FileSystemRecoveryStorageTest extends AbstractInterpreterTest {
private File recoveryDir = null;
@Before
public void setUp() throws Exception {
- System.setProperty(
- ZeppelinConfiguration.ConfVars.ZEPPELIN_RECOVERY_STORAGE_CLASS.getVarName(),
+ System.setProperty(ZeppelinConfiguration.ConfVars.ZEPPELIN_RECOVERY_STORAGE_CLASS.getVarName(),
FileSystemRecoveryStorage.class.getName());
recoveryDir = Files.createTempDir();
- System.setProperty(
- ZeppelinConfiguration.ConfVars.ZEPPELIN_RECOVERY_DIR.getVarName(),
- recoveryDir.getAbsolutePath());
+ System.setProperty(ZeppelinConfiguration.ConfVars.ZEPPELIN_RECOVERY_DIR.getVarName(), recoveryDir.getAbsolutePath());
super.setUp();
}
@@ -46,8 +44,10 @@ public class FileSystemRecoveryStorageTest extends AbstractInterpreterTest {
Interpreter interpreter1 = interpreterSetting.getDefaultInterpreter("user1", "note1");
RemoteInterpreter remoteInterpreter1 = (RemoteInterpreter) interpreter1;
- InterpreterContext context1 =
- InterpreterContext.builder().setNoteId("noteId").setParagraphId("paragraphId").build();
+ InterpreterContext context1 = InterpreterContext.builder()
+ .setNoteId("noteId")
+ .setParagraphId("paragraphId")
+ .build();
remoteInterpreter1.interpret("hello", context1);
assertEquals(1, interpreterSettingManager.getRecoveryStorage().restore().size());
@@ -63,15 +63,19 @@ public class FileSystemRecoveryStorageTest extends AbstractInterpreterTest {
Interpreter interpreter1 = interpreterSetting.getDefaultInterpreter("user1", "note1");
RemoteInterpreter remoteInterpreter1 = (RemoteInterpreter) interpreter1;
- InterpreterContext context1 =
- InterpreterContext.builder().setNoteId("noteId").setParagraphId("paragraphId").build();
+ InterpreterContext context1 = InterpreterContext.builder()
+ .setNoteId("noteId")
+ .setParagraphId("paragraphId")
+ .build();
remoteInterpreter1.interpret("hello", context1);
assertEquals(1, interpreterSettingManager.getRecoveryStorage().restore().size());
Interpreter interpreter2 = interpreterSetting.getDefaultInterpreter("user2", "note2");
RemoteInterpreter remoteInterpreter2 = (RemoteInterpreter) interpreter2;
- InterpreterContext context2 =
- InterpreterContext.builder().setNoteId("noteId").setParagraphId("paragraphId").build();
+ InterpreterContext context2 = InterpreterContext.builder()
+ .setNoteId("noteId")
+ .setParagraphId("paragraphId")
+ .build();
remoteInterpreter2.interpret("hello", context2);
assertEquals(2, interpreterSettingManager.getRecoveryStorage().restore().size());
@@ -82,4 +86,5 @@ public class FileSystemRecoveryStorageTest extends AbstractInterpreterTest {
interpreterSetting.close();
assertEquals(0, interpreterSettingManager.getRecoveryStorage().restore().size());
}
+
}
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/0d746fa2/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/remote/AppendOutputRunnerTest.java
----------------------------------------------------------------------
diff --git a/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/remote/AppendOutputRunnerTest.java b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/remote/AppendOutputRunnerTest.java
index decc19d..7bbd2b8 100644
--- a/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/remote/AppendOutputRunnerTest.java
+++ b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/remote/AppendOutputRunnerTest.java
@@ -17,18 +17,6 @@
package org.apache.zeppelin.interpreter.remote;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyInt;
-import static org.mockito.Mockito.*;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.Executors;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.ScheduledFuture;
-import java.util.concurrent.TimeUnit;
import org.apache.log4j.AppenderSkeleton;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
@@ -38,18 +26,30 @@ import org.junit.Test;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.ScheduledFuture;
+import java.util.concurrent.TimeUnit;
+
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyInt;
+import static org.mockito.Mockito.*;
+
public class AppendOutputRunnerTest {
private static final int NUM_EVENTS = 10000;
private static final int NUM_CLUBBED_EVENTS = 100;
- private static final ScheduledExecutorService service =
- Executors.newSingleThreadScheduledExecutor();
+ private static final ScheduledExecutorService service = Executors.newSingleThreadScheduledExecutor();
private static ScheduledFuture<?> future = null;
/* It is being accessed by multiple threads.
* While loop for 'loopForBufferCompletion' could
* run for-ever.
*/
- private static volatile int numInvocations = 0;
+ private volatile static int numInvocations = 0;
@After
public void afterEach() {
@@ -64,8 +64,7 @@ public class AppendOutputRunnerTest {
String[][] buffer = {{"note", "para", "data\n"}};
loopForCompletingEvents(listener, 1, buffer);
- verify(listener, times(1))
- .onOutputAppend(any(String.class), any(String.class), anyInt(), any(String.class));
+ verify(listener, times(1)).onOutputAppend(any(String.class), any(String.class), anyInt(), any(String.class));
verify(listener, times(1)).onOutputAppend("note", "para", 0, "data\n");
}
@@ -75,14 +74,13 @@ public class AppendOutputRunnerTest {
String note1 = "note1";
String para1 = "para1";
String[][] buffer = {
- {note1, para1, "data1\n"},
- {note1, para1, "data2\n"},
- {note1, para1, "data3\n"}
+ {note1, para1, "data1\n"},
+ {note1, para1, "data2\n"},
+ {note1, para1, "data3\n"}
};
loopForCompletingEvents(listener, 1, buffer);
- verify(listener, times(1))
- .onOutputAppend(any(String.class), any(String.class), anyInt(), any(String.class));
+ verify(listener, times(1)).onOutputAppend(any(String.class), any(String.class), anyInt(), any(String.class));
verify(listener, times(1)).onOutputAppend(note1, para1, 0, "data1\ndata2\ndata3\n");
}
@@ -94,15 +92,14 @@ public class AppendOutputRunnerTest {
String para1 = "para1";
String para2 = "para2";
String[][] buffer = {
- {note1, para1, "data1\n"},
- {note1, para2, "data2\n"},
- {note2, para1, "data3\n"},
- {note2, para2, "data4\n"}
+ {note1, para1, "data1\n"},
+ {note1, para2, "data2\n"},
+ {note2, para1, "data3\n"},
+ {note2, para2, "data4\n"}
};
loopForCompletingEvents(listener, 4, buffer);
- verify(listener, times(4))
- .onOutputAppend(any(String.class), any(String.class), anyInt(), any(String.class));
+ verify(listener, times(4)).onOutputAppend(any(String.class), any(String.class), anyInt(), any(String.class));
verify(listener, times(1)).onOutputAppend(note1, para1, 0, "data1\n");
verify(listener, times(1)).onOutputAppend(note1, para2, 0, "data2\n");
verify(listener, times(1)).onOutputAppend(note2, para1, 0, "data3\n");
@@ -113,9 +110,8 @@ public class AppendOutputRunnerTest {
public void testClubbedData() throws InterruptedException {
RemoteInterpreterProcessListener listener = mock(RemoteInterpreterProcessListener.class);
AppendOutputRunner runner = new AppendOutputRunner(listener);
- future =
- service.scheduleWithFixedDelay(
- runner, 0, AppendOutputRunner.BUFFER_TIME_MS, TimeUnit.MILLISECONDS);
+ future = service.scheduleWithFixedDelay(runner, 0,
+ AppendOutputRunner.BUFFER_TIME_MS, TimeUnit.MILLISECONDS);
Thread thread = new Thread(new BombardEvents(runner));
thread.start();
thread.join();
@@ -126,8 +122,7 @@ public class AppendOutputRunnerTest {
* calls, 30-40 Web-socket calls are made. Keeping
* the unit-test to a pessimistic 100 web-socket calls.
*/
- verify(listener, atMost(NUM_CLUBBED_EVENTS))
- .onOutputAppend(any(String.class), any(String.class), anyInt(), any(String.class));
+ verify(listener, atMost(NUM_CLUBBED_EVENTS)).onOutputAppend(any(String.class), any(String.class), anyInt(), any(String.class));
}
@Test
@@ -137,7 +132,7 @@ public class AppendOutputRunnerTest {
String data = "data\n";
int numEvents = 100000;
- for (int i = 0; i < numEvents; i++) {
+ for (int i=0; i<numEvents; i++) {
runner.appendBuffer("noteId", "paraId", 0, data);
}
@@ -153,18 +148,16 @@ public class AppendOutputRunnerTest {
do {
warnLogCounter = 0;
log = appender.getLog();
- for (LoggingEvent logEntry : log) {
+ for (LoggingEvent logEntry: log) {
if (Level.WARN.equals(logEntry.getLevel())) {
sizeWarnLogEntry = logEntry;
warnLogCounter += 1;
}
}
- } while (warnLogCounter != 2);
+ } while(warnLogCounter != 2);
- String loggerString =
- "Processing size for buffered append-output is high: "
- + (data.length() * numEvents)
- + " characters.";
+ String loggerString = "Processing size for buffered append-output is high: " +
+ (data.length() * numEvents) + " characters.";
assertTrue(loggerString.equals(sizeWarnLogEntry.getMessage()));
}
@@ -180,7 +173,7 @@ public class AppendOutputRunnerTest {
public void run() {
String noteId = "noteId";
String paraId = "paraId";
- for (int i = 0; i < NUM_EVENTS; i++) {
+ for (int i=0; i<NUM_EVENTS; i++) {
runner.appendBuffer(noteId, paraId, 0, "data\n");
}
}
@@ -191,51 +184,48 @@ public class AppendOutputRunnerTest {
@Override
public boolean requiresLayout() {
- return false;
+ return false;
}
@Override
protected void append(final LoggingEvent loggingEvent) {
- log.add(loggingEvent);
+ log.add(loggingEvent);
}
@Override
- public void close() {}
+ public void close() {
+ }
public List<LoggingEvent> getLog() {
- return new ArrayList<>(log);
+ return new ArrayList<>(log);
}
}
private void prepareInvocationCounts(RemoteInterpreterProcessListener listener) {
- doAnswer(
- new Answer<Void>() {
- @Override
- public Void answer(InvocationOnMock invocation) throws Throwable {
- numInvocations += 1;
- return null;
- }
- })
- .when(listener)
- .onOutputAppend(any(String.class), any(String.class), anyInt(), any(String.class));
+ doAnswer(new Answer<Void>() {
+ @Override
+ public Void answer(InvocationOnMock invocation) throws Throwable {
+ numInvocations += 1;
+ return null;
+ }
+ }).when(listener).onOutputAppend(any(String.class), any(String.class), anyInt(), any(String.class));
}
- private void loopForCompletingEvents(
- RemoteInterpreterProcessListener listener, int numTimes, String[][] buffer) {
+ private void loopForCompletingEvents(RemoteInterpreterProcessListener listener,
+ int numTimes, String[][] buffer) {
numInvocations = 0;
prepareInvocationCounts(listener);
AppendOutputRunner runner = new AppendOutputRunner(listener);
- for (String[] bufferElement : buffer) {
+ for (String[] bufferElement: buffer) {
runner.appendBuffer(bufferElement[0], bufferElement[1], 0, bufferElement[2]);
}
- future =
- service.scheduleWithFixedDelay(
- runner, 0, AppendOutputRunner.BUFFER_TIME_MS, TimeUnit.MILLISECONDS);
+ future = service.scheduleWithFixedDelay(runner, 0,
+ AppendOutputRunner.BUFFER_TIME_MS, TimeUnit.MILLISECONDS);
long startTimeMs = System.currentTimeMillis();
- while (numInvocations != numTimes) {
+ while(numInvocations != numTimes) {
if (System.currentTimeMillis() - startTimeMs > 2000) {
fail("Buffered events were not sent for 2 seconds");
}
}
}
-}
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/0d746fa2/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/remote/RemoteAngularObjectTest.java
----------------------------------------------------------------------
diff --git a/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/remote/RemoteAngularObjectTest.java b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/remote/RemoteAngularObjectTest.java
index 757e402..1029696 100644
--- a/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/remote/RemoteAngularObjectTest.java
+++ b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/remote/RemoteAngularObjectTest.java
@@ -17,9 +17,6 @@
package org.apache.zeppelin.interpreter.remote;
-import static org.junit.Assert.assertEquals;
-
-import java.util.concurrent.atomic.AtomicInteger;
import org.apache.zeppelin.display.AngularObject;
import org.apache.zeppelin.display.AngularObjectRegistry;
import org.apache.zeppelin.display.AngularObjectRegistryListener;
@@ -32,6 +29,10 @@ import org.apache.zeppelin.resource.LocalResourcePool;
import org.junit.Before;
import org.junit.Test;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import static org.junit.Assert.assertEquals;
+
public class RemoteAngularObjectTest extends AbstractInterpreterTest
implements AngularObjectRegistryListener {
@@ -54,24 +55,21 @@ public class RemoteAngularObjectTest extends AbstractInterpreterTest
interpreterSetting = interpreterSettingManager.getInterpreterSettingByName("test");
intp = (RemoteInterpreter) interpreterSetting.getInterpreter("user1", "note1", "mock_ao");
- localRegistry =
- (RemoteAngularObjectRegistry) intp.getInterpreterGroup().getAngularObjectRegistry();
-
- context =
- InterpreterContext.builder()
- .setNoteId("note")
- .setParagraphId("id")
- .setAngularObjectRegistry(
- new AngularObjectRegistry(intp.getInterpreterGroup().getId(), null))
- .setResourcePool(new LocalResourcePool("pool1"))
- .build();
+ localRegistry = (RemoteAngularObjectRegistry) intp.getInterpreterGroup().getAngularObjectRegistry();
+
+ context = InterpreterContext.builder()
+ .setNoteId("note")
+ .setParagraphId("id")
+ .setAngularObjectRegistry(new AngularObjectRegistry(intp.getInterpreterGroup().getId(), null))
+ .setResourcePool(new LocalResourcePool("pool1"))
+ .build();
intp.open();
+
}
@Test
- public void testAngularObjectInterpreterSideCRUD()
- throws InterruptedException, InterpreterException {
+ public void testAngularObjectInterpreterSideCRUD() throws InterruptedException, InterpreterException {
InterpreterResult ret = intp.interpret("get", context);
Thread.sleep(500); // waitFor eventpoller pool event
String[] result = ret.message().get(0).getData().split(" ");
@@ -104,8 +102,7 @@ public class RemoteAngularObjectTest extends AbstractInterpreterTest
}
@Test
- public void testAngularObjectRemovalOnZeppelinServerSide()
- throws InterruptedException, InterpreterException {
+ public void testAngularObjectRemovalOnZeppelinServerSide() throws InterruptedException, InterpreterException {
// test if angularobject removal from server side propagate to interpreter process's registry.
// will happen when notebook is removed.
@@ -130,8 +127,7 @@ public class RemoteAngularObjectTest extends AbstractInterpreterTest
}
@Test
- public void testAngularObjectAddOnZeppelinServerSide()
- throws InterruptedException, InterpreterException {
+ public void testAngularObjectAddOnZeppelinServerSide() throws InterruptedException, InterpreterException {
// test if angularobject add from server side propagate to interpreter process's registry.
// will happen when zeppelin server loads notebook and restore the object into registry
@@ -164,4 +160,5 @@ public class RemoteAngularObjectTest extends AbstractInterpreterTest
public void onRemove(String interpreterGroupId, String name, String noteId, String paragraphId) {
onRemove.incrementAndGet();
}
+
}
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/0d746fa2/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreterOutputTestStream.java
----------------------------------------------------------------------
diff --git a/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreterOutputTestStream.java b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreterOutputTestStream.java
index 25e6f72..5e1cb7d 100644
--- a/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreterOutputTestStream.java
+++ b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreterOutputTestStream.java
@@ -17,11 +17,6 @@
package org.apache.zeppelin.interpreter.remote;
-import static org.junit.Assert.assertEquals;
-
-import java.io.IOException;
-import java.util.List;
-import java.util.Map;
import org.apache.zeppelin.interpreter.AbstractInterpreterTest;
import org.apache.zeppelin.interpreter.InterpreterContext;
import org.apache.zeppelin.interpreter.InterpreterException;
@@ -31,10 +26,20 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
-/** Test for remote interpreter output stream */
+import java.io.IOException;
+import java.util.List;
+import java.util.Map;
+
+import static org.junit.Assert.assertEquals;
+
+
+/**
+ * Test for remote interpreter output stream
+ */
public class RemoteInterpreterOutputTestStream extends AbstractInterpreterTest
implements RemoteInterpreterProcessListener {
+
private InterpreterSetting interpreterSetting;
@Before
@@ -49,13 +54,15 @@ public class RemoteInterpreterOutputTestStream extends AbstractInterpreterTest
}
private InterpreterContext createInterpreterContext() {
- return InterpreterContext.builder().setNoteId("noteId").setParagraphId("id").build();
+ return InterpreterContext.builder()
+ .setNoteId("noteId")
+ .setParagraphId("id")
+ .build();
}
@Test
public void testInterpreterResultOnly() throws InterpreterException {
- RemoteInterpreter intp =
- (RemoteInterpreter) interpreterSetting.getInterpreter("user1", "note1", "mock_stream");
+ RemoteInterpreter intp = (RemoteInterpreter) interpreterSetting.getInterpreter("user1", "note1", "mock_stream");
InterpreterResult ret = intp.interpret("SUCCESS::staticresult", createInterpreterContext());
assertEquals(InterpreterResult.Code.SUCCESS, ret.code());
assertEquals("staticresult", ret.message().get(0).getData());
@@ -71,8 +78,7 @@ public class RemoteInterpreterOutputTestStream extends AbstractInterpreterTest
@Test
public void testInterpreterOutputStreamOnly() throws InterpreterException {
- RemoteInterpreter intp =
- (RemoteInterpreter) interpreterSetting.getInterpreter("user1", "note1", "mock_stream");
+ RemoteInterpreter intp = (RemoteInterpreter) interpreterSetting.getInterpreter("user1", "note1", "mock_stream");
InterpreterResult ret = intp.interpret("SUCCESS:streamresult:", createInterpreterContext());
assertEquals(InterpreterResult.Code.SUCCESS, ret.code());
assertEquals("streamresult", ret.message().get(0).getData());
@@ -84,8 +90,7 @@ public class RemoteInterpreterOutputTestStream extends AbstractInterpreterTest
@Test
public void testInterpreterResultOutputStreamMixed() throws InterpreterException {
- RemoteInterpreter intp =
- (RemoteInterpreter) interpreterSetting.getInterpreter("user1", "note1", "mock_stream");
+ RemoteInterpreter intp = (RemoteInterpreter) interpreterSetting.getInterpreter("user1", "note1", "mock_stream");
InterpreterResult ret = intp.interpret("SUCCESS:stream:static", createInterpreterContext());
assertEquals(InterpreterResult.Code.SUCCESS, ret.code());
assertEquals("stream", ret.message().get(0).getData());
@@ -94,8 +99,7 @@ public class RemoteInterpreterOutputTestStream extends AbstractInterpreterTest
@Test
public void testOutputType() throws InterpreterException {
- RemoteInterpreter intp =
- (RemoteInterpreter) interpreterSetting.getInterpreter("user1", "note1", "mock_stream");
+ RemoteInterpreter intp = (RemoteInterpreter) interpreterSetting.getInterpreter("user1", "note1", "mock_stream");
InterpreterResult ret = intp.interpret("SUCCESS:%html hello:", createInterpreterContext());
assertEquals(InterpreterResult.Type.HTML, ret.message().get(0).getType());
@@ -113,27 +117,28 @@ public class RemoteInterpreterOutputTestStream extends AbstractInterpreterTest
}
@Override
- public void onOutputAppend(String noteId, String paragraphId, int index, String output) {}
+ public void onOutputAppend(String noteId, String paragraphId, int index, String output) {
+
+ }
@Override
- public void onOutputUpdated(
- String noteId, String paragraphId, int index, InterpreterResult.Type type, String output) {}
+ public void onOutputUpdated(String noteId, String paragraphId, int index, InterpreterResult.Type type, String output) {
+
+ }
@Override
- public void onOutputClear(String noteId, String paragraphId) {}
+ public void onOutputClear(String noteId, String paragraphId) {
+
+ }
@Override
- public void runParagraphs(
- String noteId,
- List<Integer> paragraphIndices,
- List<String> paragraphIds,
- String curParagraphId)
- throws IOException {}
+ public void runParagraphs(String noteId, List<Integer> paragraphIndices, List<String> paragraphIds, String curParagraphId) throws IOException {
+
+ }
@Override
- public void onParaInfosReceived(
- String noteId,
- String paragraphId,
- String interpreterSettingId,
- Map<String, String> metaInfos) {}
+ public void onParaInfosReceived(String noteId, String paragraphId,
+ String interpreterSettingId, Map<String, String> metaInfos) {
+ }
+
}
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/0d746fa2/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreterTest.java
----------------------------------------------------------------------
diff --git a/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreterTest.java b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreterTest.java
index 3086550..5b059ef 100644
--- a/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreterTest.java
+++ b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreterTest.java
@@ -17,13 +17,6 @@
package org.apache.zeppelin.interpreter.remote;
-import static org.junit.Assert.*;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
import org.apache.thrift.transport.TTransportException;
import org.apache.zeppelin.display.AngularObjectRegistry;
import org.apache.zeppelin.display.GUI;
@@ -31,9 +24,22 @@ import org.apache.zeppelin.display.Input;
import org.apache.zeppelin.display.ui.OptionInput;
import org.apache.zeppelin.interpreter.*;
import org.apache.zeppelin.interpreter.InterpreterResult.Code;
+import org.apache.zeppelin.interpreter.remote.mock.GetAngularObjectSizeInterpreter;
+import org.apache.zeppelin.interpreter.remote.mock.GetEnvPropertyInterpreter;
+import org.apache.zeppelin.user.AuthenticationInfo;
+import org.junit.After;
import org.junit.Before;
import org.junit.Test;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+import static org.junit.Assert.*;
+
public class RemoteInterpreterTest extends AbstractInterpreterTest {
private InterpreterSetting interpreterSetting;
@@ -58,17 +64,14 @@ public class RemoteInterpreterTest extends AbstractInterpreterTest {
assertEquals(remoteInterpreter1.getScheduler(), remoteInterpreter2.getScheduler());
InterpreterContext context1 = createDummyInterpreterContext();
- assertEquals(
- "hello", remoteInterpreter1.interpret("hello", context1).message().get(0).getData());
+ assertEquals("hello", remoteInterpreter1.interpret("hello", context1).message().get(0).getData());
assertEquals(Interpreter.FormType.NATIVE, interpreter1.getFormType());
assertEquals(0, remoteInterpreter1.getProgress(context1));
assertNotNull(remoteInterpreter1.getOrCreateInterpreterProcess());
assertTrue(remoteInterpreter1.getInterpreterGroup().getRemoteInterpreterProcess().isRunning());
- assertEquals(
- "hello", remoteInterpreter2.interpret("hello", context1).message().get(0).getData());
- assertEquals(
- remoteInterpreter1.getInterpreterGroup().getRemoteInterpreterProcess(),
+ assertEquals("hello", remoteInterpreter2.interpret("hello", context1).message().get(0).getData());
+ assertEquals(remoteInterpreter1.getInterpreterGroup().getRemoteInterpreterProcess(),
remoteInterpreter2.getInterpreterGroup().getRemoteInterpreterProcess());
// Call InterpreterGroup.close instead of Interpreter.close, otherwise we will have the
@@ -76,16 +79,14 @@ public class RemoteInterpreterTest extends AbstractInterpreterTest {
remoteInterpreter1.getInterpreterGroup().close(remoteInterpreter1.getSessionId());
assertNull(remoteInterpreter1.getInterpreterGroup().getRemoteInterpreterProcess());
try {
- assertEquals(
- "hello", remoteInterpreter1.interpret("hello", context1).message().get(0).getData());
+ assertEquals("hello", remoteInterpreter1.interpret("hello", context1).message().get(0).getData());
fail("Should not be able to call interpret after interpreter is closed");
} catch (Exception e) {
e.printStackTrace();
}
try {
- assertEquals(
- "hello", remoteInterpreter2.interpret("hello", context1).message().get(0).getData());
+ assertEquals("hello", remoteInterpreter2.interpret("hello", context1).message().get(0).getData());
fail("Should not be able to call getProgress after RemoterInterpreterProcess is stoped");
} catch (Exception e) {
e.printStackTrace();
@@ -106,33 +107,28 @@ public class RemoteInterpreterTest extends AbstractInterpreterTest {
assertNotEquals(interpreter1.getScheduler(), interpreter2.getScheduler());
InterpreterContext context1 = createDummyInterpreterContext();
- assertEquals(
- "hello", remoteInterpreter1.interpret("hello", context1).message().get(0).getData());
- assertEquals(
- "hello", remoteInterpreter2.interpret("hello", context1).message().get(0).getData());
+ assertEquals("hello", remoteInterpreter1.interpret("hello", context1).message().get(0).getData());
+ assertEquals("hello", remoteInterpreter2.interpret("hello", context1).message().get(0).getData());
assertEquals(Interpreter.FormType.NATIVE, interpreter1.getFormType());
assertEquals(0, remoteInterpreter1.getProgress(context1));
assertNotNull(remoteInterpreter1.getOrCreateInterpreterProcess());
assertTrue(remoteInterpreter1.getInterpreterGroup().getRemoteInterpreterProcess().isRunning());
- assertEquals(
- remoteInterpreter1.getInterpreterGroup().getRemoteInterpreterProcess(),
+ assertEquals(remoteInterpreter1.getInterpreterGroup().getRemoteInterpreterProcess(),
remoteInterpreter2.getInterpreterGroup().getRemoteInterpreterProcess());
// Call InterpreterGroup.close instead of Interpreter.close, otherwise we will have the
// RemoteInterpreterProcess leakage.
remoteInterpreter1.getInterpreterGroup().close(remoteInterpreter1.getSessionId());
try {
- assertEquals(
- "hello", remoteInterpreter1.interpret("hello", context1).message().get(0).getData());
+ assertEquals("hello", remoteInterpreter1.interpret("hello", context1).message().get(0).getData());
fail("Should not be able to call interpret after interpreter is closed");
} catch (Exception e) {
e.printStackTrace();
}
assertTrue(remoteInterpreter2.getInterpreterGroup().getRemoteInterpreterProcess().isRunning());
- assertEquals(
- "hello", remoteInterpreter2.interpret("hello", context1).message().get(0).getData());
+ assertEquals("hello", remoteInterpreter2.interpret("hello", context1).message().get(0).getData());
remoteInterpreter2.getInterpreterGroup().close(remoteInterpreter2.getSessionId());
try {
assertEquals("hello", remoteInterpreter2.interpret("hello", context1));
@@ -157,17 +153,14 @@ public class RemoteInterpreterTest extends AbstractInterpreterTest {
assertNotEquals(interpreter1.getScheduler(), interpreter2.getScheduler());
InterpreterContext context1 = createDummyInterpreterContext();
- assertEquals(
- "hello", remoteInterpreter1.interpret("hello", context1).message().get(0).getData());
- assertEquals(
- "hello", remoteInterpreter2.interpret("hello", context1).message().get(0).getData());
+ assertEquals("hello", remoteInterpreter1.interpret("hello", context1).message().get(0).getData());
+ assertEquals("hello", remoteInterpreter2.interpret("hello", context1).message().get(0).getData());
assertEquals(Interpreter.FormType.NATIVE, interpreter1.getFormType());
assertEquals(0, remoteInterpreter1.getProgress(context1));
assertNotNull(remoteInterpreter1.getOrCreateInterpreterProcess());
assertTrue(remoteInterpreter1.getInterpreterGroup().getRemoteInterpreterProcess().isRunning());
- assertNotEquals(
- remoteInterpreter1.getInterpreterGroup().getRemoteInterpreterProcess(),
+ assertNotEquals(remoteInterpreter1.getInterpreterGroup().getRemoteInterpreterProcess(),
remoteInterpreter2.getInterpreterGroup().getRemoteInterpreterProcess());
// Call InterpreterGroup.close instead of Interpreter.close, otherwise we will have the
// RemoteInterpreterProcess leakage.
@@ -181,33 +174,29 @@ public class RemoteInterpreterTest extends AbstractInterpreterTest {
e.printStackTrace();
}
- assertEquals(
- "hello", remoteInterpreter2.interpret("hello", context1).message().get(0).getData());
+ assertEquals("hello", remoteInterpreter2.interpret("hello", context1).message().get(0).getData());
remoteInterpreter2.getInterpreterGroup().close(remoteInterpreter2.getSessionId());
try {
- assertEquals(
- "hello", remoteInterpreter2.interpret("hello", context1).message().get(0).getData());
+ assertEquals("hello", remoteInterpreter2.interpret("hello", context1).message().get(0).getData());
fail("Should not be able to call interpret after interpreter is closed");
} catch (Exception e) {
e.printStackTrace();
}
assertNull(remoteInterpreter2.getInterpreterGroup().getRemoteInterpreterProcess());
+
}
@Test
- public void testExecuteIncorrectPrecode()
- throws TTransportException, IOException, InterpreterException {
+ public void testExecuteIncorrectPrecode() throws TTransportException, IOException, InterpreterException {
interpreterSetting.getOption().setPerUser(InterpreterOption.SHARED);
interpreterSetting.setProperty("zeppelin.SleepInterpreter.precode", "fail test");
Interpreter interpreter1 = interpreterSetting.getInterpreter("user1", "note1", "sleep");
- InterpreterContext context1 = createDummyInterpreterContext();
- ;
+ InterpreterContext context1 = createDummyInterpreterContext();;
assertEquals(Code.ERROR, interpreter1.interpret("10", context1).code());
}
@Test
- public void testExecuteCorrectPrecode()
- throws TTransportException, IOException, InterpreterException {
+ public void testExecuteCorrectPrecode() throws TTransportException, IOException, InterpreterException {
interpreterSetting.getOption().setPerUser(InterpreterOption.SHARED);
interpreterSetting.setProperty("zeppelin.SleepInterpreter.precode", "1");
Interpreter interpreter1 = interpreterSetting.getInterpreter("user1", "note1", "sleep");
@@ -216,8 +205,7 @@ public class RemoteInterpreterTest extends AbstractInterpreterTest {
}
@Test
- public void testRemoteInterperterErrorStatus()
- throws TTransportException, IOException, InterpreterException {
+ public void testRemoteInterperterErrorStatus() throws TTransportException, IOException, InterpreterException {
interpreterSetting.setProperty("zeppelin.interpreter.echo.fail", "true");
interpreterSetting.getOption().setPerUser(InterpreterOption.SHARED);
@@ -225,8 +213,7 @@ public class RemoteInterpreterTest extends AbstractInterpreterTest {
assertTrue(interpreter1 instanceof RemoteInterpreter);
RemoteInterpreter remoteInterpreter1 = (RemoteInterpreter) interpreter1;
- InterpreterContext context1 = createDummyInterpreterContext();
- ;
+ InterpreterContext context1 = createDummyInterpreterContext();;
assertEquals(Code.ERROR, remoteInterpreter1.interpret("hello", context1).code());
}
@@ -240,30 +227,28 @@ public class RemoteInterpreterTest extends AbstractInterpreterTest {
// run this dummy interpret method first to launch the RemoteInterpreterProcess to avoid the
// time overhead of launching the process.
interpreter1.interpret("1", context1);
- Thread thread1 =
- new Thread() {
- @Override
- public void run() {
- try {
- assertEquals(Code.SUCCESS, interpreter1.interpret("100", context1).code());
- } catch (InterpreterException e) {
- e.printStackTrace();
- fail();
- }
- }
- };
- Thread thread2 =
- new Thread() {
- @Override
- public void run() {
- try {
- assertEquals(Code.SUCCESS, interpreter1.interpret("100", context1).code());
- } catch (InterpreterException e) {
- e.printStackTrace();
- fail();
- }
- }
- };
+ Thread thread1 = new Thread() {
+ @Override
+ public void run() {
+ try {
+ assertEquals(Code.SUCCESS, interpreter1.interpret("100", context1).code());
+ } catch (InterpreterException e) {
+ e.printStackTrace();
+ fail();
+ }
+ }
+ };
+ Thread thread2 = new Thread() {
+ @Override
+ public void run() {
+ try {
+ assertEquals(Code.SUCCESS, interpreter1.interpret("100", context1).code());
+ } catch (InterpreterException e) {
+ e.printStackTrace();
+ fail();
+ }
+ }
+ };
long start = System.currentTimeMillis();
thread1.start();
thread2.start();
@@ -284,30 +269,28 @@ public class RemoteInterpreterTest extends AbstractInterpreterTest {
// run this dummy interpret method first to launch the RemoteInterpreterProcess to avoid the
// time overhead of launching the process.
interpreter1.interpret("1", context1);
- Thread thread1 =
- new Thread() {
- @Override
- public void run() {
- try {
- assertEquals(Code.SUCCESS, interpreter1.interpret("100", context1).code());
- } catch (InterpreterException e) {
- e.printStackTrace();
- fail();
- }
- }
- };
- Thread thread2 =
- new Thread() {
- @Override
- public void run() {
- try {
- assertEquals(Code.SUCCESS, interpreter1.interpret("100", context1).code());
- } catch (InterpreterException e) {
- e.printStackTrace();
- fail();
- }
- }
- };
+ Thread thread1 = new Thread() {
+ @Override
+ public void run() {
+ try {
+ assertEquals(Code.SUCCESS, interpreter1.interpret("100", context1).code());
+ } catch (InterpreterException e) {
+ e.printStackTrace();
+ fail();
+ }
+ }
+ };
+ Thread thread2 = new Thread() {
+ @Override
+ public void run() {
+ try {
+ assertEquals(Code.SUCCESS, interpreter1.interpret("100", context1).code());
+ } catch (InterpreterException e) {
+ e.printStackTrace();
+ fail();
+ }
+ }
+ };
long start = System.currentTimeMillis();
thread1.start();
thread2.start();
@@ -331,14 +314,12 @@ public class RemoteInterpreterTest extends AbstractInterpreterTest {
interpreterSetting.getOption().setPerUser(InterpreterOption.SCOPED);
Interpreter interpreter1_user1 = interpreterSetting.getInterpreter("user1", "note1", "sleep");
Interpreter interpreter2_user1 = interpreterSetting.getInterpreter("user1", "note1", "echo");
- assertEquals(
- interpreter1_user1.getInterpreterGroup(), interpreter2_user1.getInterpreterGroup());
+ assertEquals(interpreter1_user1.getInterpreterGroup(), interpreter2_user1.getInterpreterGroup());
assertEquals(interpreter1_user1.getScheduler(), interpreter2_user1.getScheduler());
Interpreter interpreter1_user2 = interpreterSetting.getInterpreter("user2", "note1", "sleep");
Interpreter interpreter2_user2 = interpreterSetting.getInterpreter("user2", "note1", "echo");
- assertEquals(
- interpreter1_user2.getInterpreterGroup(), interpreter2_user2.getInterpreterGroup());
+ assertEquals(interpreter1_user2.getInterpreterGroup(), interpreter2_user2.getInterpreterGroup());
assertEquals(interpreter1_user2.getScheduler(), interpreter2_user2.getScheduler());
// scheduler is shared in session but not across session
@@ -380,29 +361,19 @@ public class RemoteInterpreterTest extends AbstractInterpreterTest {
final Interpreter interpreter1 = interpreterSetting.getInterpreter("user1", "note1", "get");
final InterpreterContext context1 = createDummyInterpreterContext();
- assertEquals(
- "VALUE_1", interpreter1.interpret("getEnv ENV_1", context1).message().get(0).getData());
- assertEquals(
- "null", interpreter1.interpret("getEnv ENV_2", context1).message().get(0).getData());
-
- assertEquals(
- "value_1",
- interpreter1.interpret("getProperty property_1", context1).message().get(0).getData());
- assertEquals(
- "null",
- interpreter1
- .interpret("getProperty not_existed_property", context1)
- .message()
- .get(0)
- .getData());
+ assertEquals("VALUE_1", interpreter1.interpret("getEnv ENV_1", context1).message().get(0).getData());
+ assertEquals("null", interpreter1.interpret("getEnv ENV_2", context1).message().get(0).getData());
+
+ assertEquals("value_1", interpreter1.interpret("getProperty property_1", context1).message().get(0).getData());
+ assertEquals("null", interpreter1.interpret("getProperty not_existed_property", context1).message().get(0).getData());
}
@Test
public void testConvertDynamicForms() throws InterpreterException {
GUI gui = new GUI();
OptionInput.ParamOption[] paramOptions = {
- new OptionInput.ParamOption("value1", "param1"),
- new OptionInput.ParamOption("value2", "param2")
+ new OptionInput.ParamOption("value1", "param1"),
+ new OptionInput.ParamOption("value2", "param2")
};
List<Object> defaultValues = new ArrayList();
defaultValues.add("default1");
@@ -417,4 +388,5 @@ public class RemoteInterpreterTest extends AbstractInterpreterTest {
interpreter.interpret("text", context);
assertArrayEquals(expected.values().toArray(), gui.getForms().values().toArray());
}
+
}
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/0d746fa2/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/remote/mock/GetAngularObjectSizeInterpreter.java
----------------------------------------------------------------------
diff --git a/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/remote/mock/GetAngularObjectSizeInterpreter.java b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/remote/mock/GetAngularObjectSizeInterpreter.java
index 551e10e..6d6495f 100644
--- a/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/remote/mock/GetAngularObjectSizeInterpreter.java
+++ b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/remote/mock/GetAngularObjectSizeInterpreter.java
@@ -17,11 +17,13 @@
package org.apache.zeppelin.interpreter.remote.mock;
-import java.util.Properties;
+
import org.apache.zeppelin.interpreter.Interpreter;
import org.apache.zeppelin.interpreter.InterpreterContext;
import org.apache.zeppelin.interpreter.InterpreterResult;
+import java.util.Properties;
+
public class GetAngularObjectSizeInterpreter extends Interpreter {
public GetAngularObjectSizeInterpreter(Properties property) {
@@ -29,20 +31,25 @@ public class GetAngularObjectSizeInterpreter extends Interpreter {
}
@Override
- public void open() {}
+ public void open() {
+
+ }
@Override
- public void close() {}
+ public void close() {
+
+ }
@Override
public InterpreterResult interpret(String st, InterpreterContext context) {
- return new InterpreterResult(
- InterpreterResult.Code.SUCCESS,
+ return new InterpreterResult(InterpreterResult.Code.SUCCESS,
"" + context.getAngularObjectRegistry().getRegistry().size());
}
@Override
- public void cancel(InterpreterContext context) {}
+ public void cancel(InterpreterContext context) {
+
+ }
@Override
public FormType getFormType() {
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/0d746fa2/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/remote/mock/GetEnvPropertyInterpreter.java
----------------------------------------------------------------------
diff --git a/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/remote/mock/GetEnvPropertyInterpreter.java b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/remote/mock/GetEnvPropertyInterpreter.java
index 9d1b381..a039a59 100644
--- a/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/remote/mock/GetEnvPropertyInterpreter.java
+++ b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/remote/mock/GetEnvPropertyInterpreter.java
@@ -16,8 +16,6 @@
*/
package org.apache.zeppelin.interpreter.remote.mock;
-import java.util.List;
-import java.util.Properties;
import org.apache.zeppelin.interpreter.Interpreter;
import org.apache.zeppelin.interpreter.InterpreterContext;
import org.apache.zeppelin.interpreter.InterpreterResult;
@@ -25,6 +23,10 @@ import org.apache.zeppelin.interpreter.thrift.InterpreterCompletion;
import org.apache.zeppelin.scheduler.Scheduler;
import org.apache.zeppelin.scheduler.SchedulerFactory;
+import java.util.List;
+import java.util.Properties;
+
+
public class GetEnvPropertyInterpreter extends Interpreter {
public GetEnvPropertyInterpreter(Properties property) {
@@ -32,29 +34,29 @@ public class GetEnvPropertyInterpreter extends Interpreter {
}
@Override
- public void open() {}
+ public void open() {
+ }
@Override
- public void close() {}
+ public void close() {
+ }
@Override
public InterpreterResult interpret(String st, InterpreterContext context) {
String[] cmd = st.split(" ");
if (cmd[0].equals("getEnv")) {
- return new InterpreterResult(
- InterpreterResult.Code.SUCCESS,
- System.getenv(cmd[1]) == null ? "null" : System.getenv(cmd[1]));
- } else if (cmd[0].equals("getProperty")) {
- return new InterpreterResult(
- InterpreterResult.Code.SUCCESS,
- System.getProperty(cmd[1]) == null ? "null" : System.getProperty(cmd[1]));
+ return new InterpreterResult(InterpreterResult.Code.SUCCESS, System.getenv(cmd[1]) == null ? "null" : System.getenv(cmd[1]));
+ } else if (cmd[0].equals("getProperty")){
+ return new InterpreterResult(InterpreterResult.Code.SUCCESS, System.getProperty(cmd[1]) == null ? "null" : System.getProperty(cmd[1]));
} else {
return new InterpreterResult(InterpreterResult.Code.ERROR, cmd[0]);
}
}
@Override
- public void cancel(InterpreterContext context) {}
+ public void cancel(InterpreterContext context) {
+
+ }
@Override
public FormType getFormType() {
@@ -67,8 +69,8 @@ public class GetEnvPropertyInterpreter extends Interpreter {
}
@Override
- public List<InterpreterCompletion> completion(
- String buf, int cursor, InterpreterContext interpreterContext) {
+ public List<InterpreterCompletion> completion(String buf, int cursor,
+ InterpreterContext interpreterContext) {
return null;
}
@@ -77,3 +79,4 @@ public class GetEnvPropertyInterpreter extends Interpreter {
return SchedulerFactory.singleton().createOrGetFIFOScheduler("interpreter_" + this.hashCode());
}
}
+
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/0d746fa2/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/remote/mock/MockInterpreterA.java
----------------------------------------------------------------------
diff --git a/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/remote/mock/MockInterpreterA.java b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/remote/mock/MockInterpreterA.java
index a4ba9e6..dbd2df7 100644
--- a/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/remote/mock/MockInterpreterA.java
+++ b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/remote/mock/MockInterpreterA.java
@@ -17,8 +17,6 @@
package org.apache.zeppelin.interpreter.remote.mock;
-import java.util.List;
-import java.util.Properties;
import org.apache.zeppelin.interpreter.Interpreter;
import org.apache.zeppelin.interpreter.InterpreterContext;
import org.apache.zeppelin.interpreter.InterpreterException;
@@ -28,6 +26,9 @@ import org.apache.zeppelin.interpreter.thrift.InterpreterCompletion;
import org.apache.zeppelin.scheduler.Scheduler;
import org.apache.zeppelin.scheduler.SchedulerFactory;
+import java.util.List;
+import java.util.Properties;
+
public class MockInterpreterA extends Interpreter {
private String lastSt;
@@ -38,11 +39,12 @@ public class MockInterpreterA extends Interpreter {
@Override
public void open() {
- // new RuntimeException().printStackTrace();
+ //new RuntimeException().printStackTrace();
}
@Override
- public void close() {}
+ public void close() {
+ }
public String getLastStatement() {
return lastSt;
@@ -64,7 +66,9 @@ public class MockInterpreterA extends Interpreter {
}
@Override
- public void cancel(InterpreterContext context) {}
+ public void cancel(InterpreterContext context) {
+
+ }
@Override
public FormType getFormType() {
@@ -77,19 +81,17 @@ public class MockInterpreterA extends Interpreter {
}
@Override
- public List<InterpreterCompletion> completion(
- String buf, int cursor, InterpreterContext interpreterContext) {
+ public List<InterpreterCompletion> completion(String buf, int cursor,
+ InterpreterContext interpreterContext) {
return null;
}
@Override
public Scheduler getScheduler() {
if (getProperty("parallel") != null && getProperty("parallel").equals("true")) {
- return SchedulerFactory.singleton()
- .createOrGetParallelScheduler("interpreter_" + this.hashCode(), 10);
+ return SchedulerFactory.singleton().createOrGetParallelScheduler("interpreter_" + this.hashCode(), 10);
} else {
- return SchedulerFactory.singleton()
- .createOrGetFIFOScheduler("interpreter_" + this.hashCode());
+ return SchedulerFactory.singleton().createOrGetFIFOScheduler("interpreter_" + this.hashCode());
}
}
}
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/0d746fa2/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/remote/mock/MockInterpreterAngular.java
----------------------------------------------------------------------
diff --git a/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/remote/mock/MockInterpreterAngular.java b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/remote/mock/MockInterpreterAngular.java
index 2e253bd..ec89241 100644
--- a/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/remote/mock/MockInterpreterAngular.java
+++ b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/remote/mock/MockInterpreterAngular.java
@@ -17,9 +17,6 @@
package org.apache.zeppelin.interpreter.remote.mock;
-import java.util.List;
-import java.util.Properties;
-import java.util.concurrent.atomic.AtomicInteger;
import org.apache.zeppelin.display.AngularObjectRegistry;
import org.apache.zeppelin.display.AngularObjectWatcher;
import org.apache.zeppelin.interpreter.Interpreter;
@@ -28,6 +25,10 @@ import org.apache.zeppelin.interpreter.InterpreterResult;
import org.apache.zeppelin.interpreter.InterpreterResult.Code;
import org.apache.zeppelin.interpreter.thrift.InterpreterCompletion;
+import java.util.List;
+import java.util.Properties;
+import java.util.concurrent.atomic.AtomicInteger;
+
public class MockInterpreterAngular extends Interpreter {
AtomicInteger numWatch = new AtomicInteger(0);
@@ -37,10 +38,13 @@ public class MockInterpreterAngular extends Interpreter {
}
@Override
- public void open() {}
+ public void open() {
+ }
@Override
- public void close() {}
+ public void close() {
+
+ }
@Override
public InterpreterResult interpret(String st, InterpreterContext context) {
@@ -59,16 +63,16 @@ public class MockInterpreterAngular extends Interpreter {
if (cmd.equals("add")) {
registry.add(name, value, context.getNoteId(), null);
- registry
- .get(name, context.getNoteId(), null)
- .addWatcher(
- new AngularObjectWatcher(null) {
-
- @Override
- public void watch(Object oldObject, Object newObject, InterpreterContext context) {
- numWatch.incrementAndGet();
- }
- });
+ registry.get(name, context.getNoteId(), null).addWatcher(new AngularObjectWatcher
+ (null) {
+
+ @Override
+ public void watch(Object oldObject, Object newObject,
+ InterpreterContext context) {
+ numWatch.incrementAndGet();
+ }
+
+ });
} else if (cmd.equalsIgnoreCase("update")) {
registry.get(name, context.getNoteId(), null).set(value);
} else if (cmd.equals("remove")) {
@@ -81,13 +85,14 @@ public class MockInterpreterAngular extends Interpreter {
logger.error("Exception in MockInterpreterAngular while interpret Thread.sleep", e);
}
- String msg =
- registry.getAll(context.getNoteId(), null).size() + " " + Integer.toString(numWatch.get());
+ String msg = registry.getAll(context.getNoteId(), null).size() + " " + Integer.toString(numWatch
+ .get());
return new InterpreterResult(Code.SUCCESS, msg);
}
@Override
- public void cancel(InterpreterContext context) {}
+ public void cancel(InterpreterContext context) {
+ }
@Override
public FormType getFormType() {
@@ -100,8 +105,8 @@ public class MockInterpreterAngular extends Interpreter {
}
@Override
- public List<InterpreterCompletion> completion(
- String buf, int cursor, InterpreterContext interpreterContext) {
+ public List<InterpreterCompletion> completion(String buf, int cursor,
+ InterpreterContext interpreterContext) {
return null;
}
}
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/0d746fa2/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/remote/mock/MockInterpreterOutputStream.java
----------------------------------------------------------------------
diff --git a/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/remote/mock/MockInterpreterOutputStream.java b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/remote/mock/MockInterpreterOutputStream.java
index aefd9c5..7a5321a 100644
--- a/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/remote/mock/MockInterpreterOutputStream.java
+++ b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/remote/mock/MockInterpreterOutputStream.java
@@ -16,9 +16,6 @@
*/
package org.apache.zeppelin.interpreter.remote.mock;
-import java.io.IOException;
-import java.util.List;
-import java.util.Properties;
import org.apache.zeppelin.interpreter.Interpreter;
import org.apache.zeppelin.interpreter.InterpreterContext;
import org.apache.zeppelin.interpreter.InterpreterException;
@@ -27,7 +24,13 @@ import org.apache.zeppelin.interpreter.thrift.InterpreterCompletion;
import org.apache.zeppelin.scheduler.Scheduler;
import org.apache.zeppelin.scheduler.SchedulerFactory;
-/** MockInterpreter to test outputstream */
+import java.io.IOException;
+import java.util.List;
+import java.util.Properties;
+
+/**
+ * MockInterpreter to test outputstream
+ */
public class MockInterpreterOutputStream extends Interpreter {
private String lastSt;
@@ -37,11 +40,12 @@ public class MockInterpreterOutputStream extends Interpreter {
@Override
public void open() {
- // new RuntimeException().printStackTrace();
+ //new RuntimeException().printStackTrace();
}
@Override
- public void close() {}
+ public void close() {
+ }
public String getLastStatement() {
return lastSt;
@@ -58,12 +62,14 @@ public class MockInterpreterOutputStream extends Interpreter {
} catch (IOException e) {
throw new InterpreterException(e);
}
- return new InterpreterResult(
- InterpreterResult.Code.valueOf(ret[0]), (ret.length > 2) ? ret[2] : "");
+ return new InterpreterResult(InterpreterResult.Code.valueOf(ret[0]), (ret.length > 2) ?
+ ret[2] : "");
}
@Override
- public void cancel(InterpreterContext context) {}
+ public void cancel(InterpreterContext context) {
+
+ }
@Override
public FormType getFormType() {
@@ -76,8 +82,8 @@ public class MockInterpreterOutputStream extends Interpreter {
}
@Override
- public List<InterpreterCompletion> completion(
- String buf, int cursor, InterpreterContext interpreterContext) {
+ public List<InterpreterCompletion> completion(String buf, int cursor,
+ InterpreterContext interpreterContext) {
return null;
}
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/0d746fa2/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/remote/mock/MockInterpreterResourcePool.java
----------------------------------------------------------------------
diff --git a/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/remote/mock/MockInterpreterResourcePool.java b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/remote/mock/MockInterpreterResourcePool.java
index b5604eb..ee9f15c 100644
--- a/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/remote/mock/MockInterpreterResourcePool.java
+++ b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/remote/mock/MockInterpreterResourcePool.java
@@ -18,9 +18,6 @@
package org.apache.zeppelin.interpreter.remote.mock;
import com.google.gson.Gson;
-import java.util.List;
-import java.util.Properties;
-import java.util.concurrent.atomic.AtomicInteger;
import org.apache.zeppelin.interpreter.Interpreter;
import org.apache.zeppelin.interpreter.InterpreterContext;
import org.apache.zeppelin.interpreter.InterpreterResult;
@@ -29,6 +26,10 @@ import org.apache.zeppelin.interpreter.thrift.InterpreterCompletion;
import org.apache.zeppelin.resource.Resource;
import org.apache.zeppelin.resource.ResourcePool;
+import java.util.List;
+import java.util.Properties;
+import java.util.concurrent.atomic.AtomicInteger;
+
public class MockInterpreterResourcePool extends Interpreter {
AtomicInteger numWatch = new AtomicInteger(0);
@@ -38,10 +39,13 @@ public class MockInterpreterResourcePool extends Interpreter {
}
@Override
- public void open() {}
+ public void open() {
+ }
@Override
- public void close() {}
+ public void close() {
+
+ }
@Override
public InterpreterResult interpret(String st, InterpreterContext context) {
@@ -82,7 +86,7 @@ public class MockInterpreterResourcePool extends Interpreter {
ret = resourcePool.getAll();
} else if (cmd.equals("invoke")) {
Resource resource = resourcePool.get(noteId, paragraphId, name);
- if (stmt.length >= 4) {
+ if (stmt.length >=4) {
Resource res = resource.invokeMethod(value, null, null, stmt[3]);
ret = res.get();
} else {
@@ -100,7 +104,8 @@ public class MockInterpreterResourcePool extends Interpreter {
}
@Override
- public void cancel(InterpreterContext context) {}
+ public void cancel(InterpreterContext context) {
+ }
@Override
public FormType getFormType() {
@@ -113,8 +118,8 @@ public class MockInterpreterResourcePool extends Interpreter {
}
@Override
- public List<InterpreterCompletion> completion(
- String buf, int cursor, InterpreterContext interpreterContext) {
+ public List<InterpreterCompletion> completion(String buf, int cursor,
+ InterpreterContext interpreterContext) {
return null;
}
}
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/0d746fa2/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/FolderTest.java
----------------------------------------------------------------------
diff --git a/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/FolderTest.java b/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/FolderTest.java
index 29b46eb..d756e14 100644
--- a/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/FolderTest.java
+++ b/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/FolderTest.java
@@ -17,10 +17,6 @@
package org.apache.zeppelin.notebook;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
import org.apache.zeppelin.interpreter.Interpreter;
import org.apache.zeppelin.interpreter.InterpreterFactory;
import org.apache.zeppelin.interpreter.InterpreterSettingManager;
@@ -34,25 +30,38 @@ import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
@RunWith(MockitoJUnitRunner.class)
public class FolderTest {
- @Mock NotebookRepo repo;
+ @Mock
+ NotebookRepo repo;
- @Mock ParagraphJobListener paragraphJobListener;
+ @Mock
+ ParagraphJobListener paragraphJobListener;
- @Mock SearchService index;
+ @Mock
+ SearchService index;
- @Mock Credentials credentials;
+ @Mock
+ Credentials credentials;
- @Mock Interpreter interpreter;
+ @Mock
+ Interpreter interpreter;
- @Mock Scheduler scheduler;
+ @Mock
+ Scheduler scheduler;
- @Mock NoteEventListener noteEventListener;
+ @Mock
+ NoteEventListener noteEventListener;
- @Mock InterpreterFactory interpreterFactory;
+ @Mock
+ InterpreterFactory interpreterFactory;
- @Mock InterpreterSettingManager interpreterSettingManager;
+ @Mock
+ InterpreterSettingManager interpreterSettingManager;
Folder folder;
@@ -62,43 +71,13 @@ public class FolderTest {
@Before
public void createFolderAndNotes() {
- note1 =
- new Note(
- "test",
- "",
- repo,
- interpreterFactory,
- interpreterSettingManager,
- paragraphJobListener,
- index,
- credentials,
- noteEventListener);
+ note1 = new Note("test", "", repo, interpreterFactory, interpreterSettingManager, paragraphJobListener, index, credentials, noteEventListener);
note1.setName("this/is/a/folder/note1");
- note2 =
- new Note(
- "test",
- "",
- repo,
- interpreterFactory,
- interpreterSettingManager,
- paragraphJobListener,
- index,
- credentials,
- noteEventListener);
+ note2 = new Note("test", "", repo, interpreterFactory, interpreterSettingManager, paragraphJobListener, index, credentials, noteEventListener);
note2.setName("this/is/a/folder/note2");
- note3 =
- new Note(
- "test",
- "",
- repo,
- interpreterFactory,
- interpreterSettingManager,
- paragraphJobListener,
- index,
- credentials,
- noteEventListener);
+ note3 = new Note("test", "", repo, interpreterFactory, interpreterSettingManager, paragraphJobListener, index, credentials, noteEventListener);
note3.setName("this/is/a/folder/note3");
folder = new Folder("this/is/a/folder");
@@ -139,17 +118,7 @@ public class FolderTest {
@Test
public void addNoteTest() {
- Note note4 =
- new Note(
- "test",
- "",
- repo,
- interpreterFactory,
- interpreterSettingManager,
- paragraphJobListener,
- index,
- credentials,
- noteEventListener);
+ Note note4 = new Note("test", "", repo, interpreterFactory, interpreterSettingManager, paragraphJobListener, index, credentials, noteEventListener);
note4.setName("this/is/a/folder/note4");
folder.addNote(note4);