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/26 04:43:47 UTC
[04/49] zeppelin git commit: [ZEPPELIN-3740] Adopt
`google-java-format` and `fmt-maven-plugin`
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/55f6c91c/zeppelin-zengine/src/test/java/org/apache/zeppelin/helium/HeliumTest.java
----------------------------------------------------------------------
diff --git a/zeppelin-zengine/src/test/java/org/apache/zeppelin/helium/HeliumTest.java b/zeppelin-zengine/src/test/java/org/apache/zeppelin/helium/HeliumTest.java
index bdd639e..3357151 100644
--- a/zeppelin-zengine/src/test/java/org/apache/zeppelin/helium/HeliumTest.java
+++ b/zeppelin-zengine/src/test/java/org/apache/zeppelin/helium/HeliumTest.java
@@ -16,27 +16,28 @@
*/
package org.apache.zeppelin.helium;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
import com.github.eirslett.maven.plugins.frontend.lib.TaskRunnerException;
+import java.io.File;
+import java.io.IOException;
+import java.net.URISyntaxException;
import org.apache.commons.io.FileUtils;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
-import java.io.File;
-import java.io.IOException;
-import java.net.URISyntaxException;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
public class HeliumTest {
private File tmpDir;
private File localRegistryPath;
@Before
public void setUp() throws Exception {
- tmpDir = new File(System.getProperty("java.io.tmpdir") + "/ZeppelinLTest_" + System.currentTimeMillis());
+ tmpDir =
+ new File(
+ System.getProperty("java.io.tmpdir") + "/ZeppelinLTest_" + System.currentTimeMillis());
tmpDir.mkdirs();
localRegistryPath = new File(tmpDir, "helium");
localRegistryPath.mkdirs();
@@ -51,8 +52,14 @@ public class HeliumTest {
public void testSaveLoadConf() throws IOException, URISyntaxException, TaskRunnerException {
// given
File heliumConf = new File(tmpDir, "helium.conf");
- Helium helium = new Helium(heliumConf.getAbsolutePath(), localRegistryPath.getAbsolutePath(),
- null, null, null, null);
+ Helium helium =
+ new Helium(
+ heliumConf.getAbsolutePath(),
+ localRegistryPath.getAbsolutePath(),
+ null,
+ null,
+ null,
+ null);
assertFalse(heliumConf.exists());
// when
@@ -62,40 +69,55 @@ public class HeliumTest {
assertTrue(heliumConf.exists());
// then load without exception
- Helium heliumRestored = new Helium(
- heliumConf.getAbsolutePath(), localRegistryPath.getAbsolutePath(), null, null, null, null);
+ Helium heliumRestored =
+ new Helium(
+ heliumConf.getAbsolutePath(),
+ localRegistryPath.getAbsolutePath(),
+ null,
+ null,
+ null,
+ null);
}
@Test
- public void testRestoreRegistryInstances() throws IOException, URISyntaxException, TaskRunnerException {
+ public void testRestoreRegistryInstances()
+ throws IOException, URISyntaxException, TaskRunnerException {
File heliumConf = new File(tmpDir, "helium.conf");
- Helium helium = new Helium(
- heliumConf.getAbsolutePath(), localRegistryPath.getAbsolutePath(), null, null, null, null);
+ Helium helium =
+ new Helium(
+ heliumConf.getAbsolutePath(),
+ localRegistryPath.getAbsolutePath(),
+ null,
+ null,
+ null,
+ null);
HeliumTestRegistry registry1 = new HeliumTestRegistry("r1", "r1");
HeliumTestRegistry registry2 = new HeliumTestRegistry("r2", "r2");
helium.addRegistry(registry1);
helium.addRegistry(registry2);
// when
- registry1.add(new HeliumPackage(
- HeliumType.APPLICATION,
- "name1",
- "desc1",
- "artifact1",
- "className1",
- new String[][]{},
- "",
- ""));
-
- registry2.add(new HeliumPackage(
- HeliumType.APPLICATION,
- "name2",
- "desc2",
- "artifact2",
- "className2",
- new String[][]{},
- "",
- ""));
+ registry1.add(
+ new HeliumPackage(
+ HeliumType.APPLICATION,
+ "name1",
+ "desc1",
+ "artifact1",
+ "className1",
+ new String[][] {},
+ "",
+ ""));
+
+ registry2.add(
+ new HeliumPackage(
+ HeliumType.APPLICATION,
+ "name2",
+ "desc2",
+ "artifact2",
+ "className2",
+ new String[][] {},
+ "",
+ ""));
// then
assertEquals(2, helium.getAllPackageInfo().size());
@@ -104,35 +126,43 @@ public class HeliumTest {
@Test
public void testRefresh() throws IOException, URISyntaxException, TaskRunnerException {
File heliumConf = new File(tmpDir, "helium.conf");
- Helium helium = new Helium(
- heliumConf.getAbsolutePath(), localRegistryPath.getAbsolutePath(), null, null, null, null);
+ Helium helium =
+ new Helium(
+ heliumConf.getAbsolutePath(),
+ localRegistryPath.getAbsolutePath(),
+ null,
+ null,
+ null,
+ null);
HeliumTestRegistry registry1 = new HeliumTestRegistry("r1", "r1");
helium.addRegistry(registry1);
// when
- registry1.add(new HeliumPackage(
- HeliumType.APPLICATION,
- "name1",
- "desc1",
- "artifact1",
- "className1",
- new String[][]{},
- "",
- ""));
+ registry1.add(
+ new HeliumPackage(
+ HeliumType.APPLICATION,
+ "name1",
+ "desc1",
+ "artifact1",
+ "className1",
+ new String[][] {},
+ "",
+ ""));
// then
assertEquals(1, helium.getAllPackageInfo().size());
// when
- registry1.add(new HeliumPackage(
- HeliumType.APPLICATION,
- "name2",
- "desc2",
- "artifact2",
- "className2",
- new String[][]{},
- "",
- ""));
+ registry1.add(
+ new HeliumPackage(
+ HeliumType.APPLICATION,
+ "name2",
+ "desc2",
+ "artifact2",
+ "className2",
+ new String[][] {},
+ "",
+ ""));
// then
assertEquals(2, helium.getAllPackageInfo(true, null).size());
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/55f6c91c/zeppelin-zengine/src/test/java/org/apache/zeppelin/helium/HeliumTestApplication.java
----------------------------------------------------------------------
diff --git a/zeppelin-zengine/src/test/java/org/apache/zeppelin/helium/HeliumTestApplication.java b/zeppelin-zengine/src/test/java/org/apache/zeppelin/helium/HeliumTestApplication.java
index 2e66a3f..f13eec3 100644
--- a/zeppelin-zengine/src/test/java/org/apache/zeppelin/helium/HeliumTestApplication.java
+++ b/zeppelin-zengine/src/test/java/org/apache/zeppelin/helium/HeliumTestApplication.java
@@ -16,13 +16,13 @@
*/
package org.apache.zeppelin.helium;
-import org.apache.zeppelin.resource.ResourceSet;
-
import java.io.IOException;
import java.util.concurrent.atomic.AtomicInteger;
+import org.apache.zeppelin.resource.ResourceSet;
public class HeliumTestApplication extends Application {
private AtomicInteger numRun = new AtomicInteger(0);
+
public HeliumTestApplication(ApplicationContext context) {
super(context);
}
@@ -39,7 +39,5 @@ public class HeliumTestApplication extends Application {
}
@Override
- public void unload() throws ApplicationException {
-
- }
+ public void unload() throws ApplicationException {}
}
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/55f6c91c/zeppelin-zengine/src/test/java/org/apache/zeppelin/helium/HeliumTestRegistry.java
----------------------------------------------------------------------
diff --git a/zeppelin-zengine/src/test/java/org/apache/zeppelin/helium/HeliumTestRegistry.java b/zeppelin-zengine/src/test/java/org/apache/zeppelin/helium/HeliumTestRegistry.java
index a7b1538..e8ab9c1 100644
--- a/zeppelin-zengine/src/test/java/org/apache/zeppelin/helium/HeliumTestRegistry.java
+++ b/zeppelin-zengine/src/test/java/org/apache/zeppelin/helium/HeliumTestRegistry.java
@@ -17,7 +17,6 @@
package org.apache.zeppelin.helium;
import java.io.IOException;
-import java.net.URI;
import java.util.LinkedList;
import java.util.List;
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/55f6c91c/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/AbstractInterpreterTest.java
----------------------------------------------------------------------
diff --git a/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/AbstractInterpreterTest.java b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/AbstractInterpreterTest.java
index cd556a6..3476d74 100644
--- a/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/AbstractInterpreterTest.java
+++ b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/AbstractInterpreterTest.java
@@ -1,5 +1,8 @@
package org.apache.zeppelin.interpreter;
+import static org.mockito.Mockito.mock;
+
+import java.io.File;
import org.apache.commons.io.FileUtils;
import org.apache.zeppelin.conf.ZeppelinConfiguration;
import org.apache.zeppelin.display.AngularObjectRegistryListener;
@@ -11,17 +14,11 @@ import org.junit.Before;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.io.File;
-
-import static org.mockito.Mockito.mock;
-
/**
- * This class will load configuration files under
- * src/test/resources/interpreter
- * src/test/resources/conf
- *
- * to construct InterpreterSettingManager and InterpreterFactory properly
+ * This class will load configuration files under src/test/resources/interpreter
+ * src/test/resources/conf
*
+ * <p>to construct InterpreterSettingManager and InterpreterFactory properly
*/
public abstract class AbstractInterpreterTest {
protected static final Logger LOGGER = LoggerFactory.getLogger(AbstractInterpreterTest.class);
@@ -50,15 +47,26 @@ public abstract class AbstractInterpreterTest {
FileUtils.copyDirectory(new File("src/test/resources/interpreter"), interpreterDir);
FileUtils.copyDirectory(new File("src/test/resources/conf"), confDir);
- System.setProperty(ZeppelinConfiguration.ConfVars.ZEPPELIN_HOME.getVarName(), zeppelinHome.getAbsolutePath());
- System.setProperty(ZeppelinConfiguration.ConfVars.ZEPPELIN_CONF_DIR.getVarName(), confDir.getAbsolutePath());
- System.setProperty(ZeppelinConfiguration.ConfVars.ZEPPELIN_INTERPRETER_DIR.getVarName(), interpreterDir.getAbsolutePath());
- System.setProperty(ZeppelinConfiguration.ConfVars.ZEPPELIN_NOTEBOOK_DIR.getVarName(), notebookDir.getAbsolutePath());
- System.setProperty(ZeppelinConfiguration.ConfVars.ZEPPELIN_INTERPRETER_GROUP_DEFAULT.getVarName(), "test");
+ System.setProperty(
+ ZeppelinConfiguration.ConfVars.ZEPPELIN_HOME.getVarName(), zeppelinHome.getAbsolutePath());
+ System.setProperty(
+ ZeppelinConfiguration.ConfVars.ZEPPELIN_CONF_DIR.getVarName(), confDir.getAbsolutePath());
+ System.setProperty(
+ ZeppelinConfiguration.ConfVars.ZEPPELIN_INTERPRETER_DIR.getVarName(),
+ interpreterDir.getAbsolutePath());
+ System.setProperty(
+ ZeppelinConfiguration.ConfVars.ZEPPELIN_NOTEBOOK_DIR.getVarName(),
+ notebookDir.getAbsolutePath());
+ System.setProperty(
+ ZeppelinConfiguration.ConfVars.ZEPPELIN_INTERPRETER_GROUP_DEFAULT.getVarName(), "test");
conf = new ZeppelinConfiguration();
- interpreterSettingManager = new InterpreterSettingManager(conf,
- mock(AngularObjectRegistryListener.class), mock(RemoteInterpreterProcessListener.class), mock(ApplicationEventListener.class));
+ interpreterSettingManager =
+ new InterpreterSettingManager(
+ conf,
+ mock(AngularObjectRegistryListener.class),
+ mock(RemoteInterpreterProcessListener.class),
+ mock(ApplicationEventListener.class));
interpreterFactory = new InterpreterFactory(interpreterSettingManager);
}
@@ -71,13 +79,19 @@ public abstract class AbstractInterpreterTest {
}
protected Note createNote() {
- return new Note("test", "test", null, interpreterFactory, interpreterSettingManager, null, null, null, null);
+ return new Note(
+ "test",
+ "test",
+ null,
+ interpreterFactory,
+ interpreterSettingManager,
+ null,
+ null,
+ null,
+ null);
}
protected InterpreterContext createDummyInterpreterContext() {
- return InterpreterContext.builder()
- .setNoteId("noteId")
- .setParagraphId("paragraphId")
- .build();
+ return InterpreterContext.builder().setNoteId("noteId").setParagraphId("paragraphId").build();
}
}
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/55f6c91c/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/ConfInterpreterTest.java
----------------------------------------------------------------------
diff --git a/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/ConfInterpreterTest.java b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/ConfInterpreterTest.java
index d39b0ec..9e73590 100644
--- a/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/ConfInterpreterTest.java
+++ b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/ConfInterpreterTest.java
@@ -17,31 +17,35 @@
package org.apache.zeppelin.interpreter;
-import org.apache.zeppelin.interpreter.remote.RemoteInterpreter;
-import org.junit.Test;
-
-import java.io.IOException;
-
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
+import java.io.IOException;
+import org.apache.zeppelin.interpreter.remote.RemoteInterpreter;
+import org.junit.Test;
+
public class ConfInterpreterTest extends AbstractInterpreterTest {
@Test
public void testCorrectConf() throws IOException, InterpreterException {
- assertTrue(interpreterFactory.getInterpreter("user1", "note1", "test.conf", "test") instanceof ConfInterpreter);
- ConfInterpreter confInterpreter = (ConfInterpreter) interpreterFactory.getInterpreter("user1", "note1", "test.conf", "test");
+ assertTrue(
+ interpreterFactory.getInterpreter("user1", "note1", "test.conf", "test")
+ instanceof ConfInterpreter);
+ ConfInterpreter confInterpreter =
+ (ConfInterpreter) interpreterFactory.getInterpreter("user1", "note1", "test.conf", "test");
- InterpreterContext context = InterpreterContext.builder()
- .setNoteId("noteId")
- .setParagraphId("paragraphId")
- .build();
+ InterpreterContext context =
+ InterpreterContext.builder().setNoteId("noteId").setParagraphId("paragraphId").build();
- InterpreterResult result = confInterpreter.interpret("property_1\tnew_value\nnew_property\tdummy_value", context);
+ InterpreterResult result =
+ confInterpreter.interpret("property_1\tnew_value\nnew_property\tdummy_value", context);
assertEquals(InterpreterResult.Code.SUCCESS, result.code);
- assertTrue(interpreterFactory.getInterpreter("user1", "note1", "test", "test") instanceof RemoteInterpreter);
- RemoteInterpreter remoteInterpreter = (RemoteInterpreter) interpreterFactory.getInterpreter("user1", "note1", "test", "test");
+ assertTrue(
+ interpreterFactory.getInterpreter("user1", "note1", "test", "test")
+ instanceof RemoteInterpreter);
+ RemoteInterpreter remoteInterpreter =
+ (RemoteInterpreter) interpreterFactory.getInterpreter("user1", "note1", "test", "test");
remoteInterpreter.interpret("hello world", context);
assertEquals(7, remoteInterpreter.getProperties().size());
assertEquals("new_value", remoteInterpreter.getProperty("property_1"));
@@ -53,46 +57,51 @@ public class ConfInterpreterTest extends AbstractInterpreterTest {
assertEquals(InterpreterResult.Code.SUCCESS, result.code);
// run the paragraph with the same properties would result in ERROR
- result = confInterpreter.interpret("property_1\tnew_value_2\nnew_property\tdummy_value", context);
+ result =
+ confInterpreter.interpret("property_1\tnew_value_2\nnew_property\tdummy_value", context);
assertEquals(InterpreterResult.Code.ERROR, result.code);
}
@Test
public void testEmptyConf() throws IOException, InterpreterException {
- assertTrue(interpreterFactory.getInterpreter("user1", "note1", "test.conf", "test") instanceof ConfInterpreter);
- ConfInterpreter confInterpreter = (ConfInterpreter) interpreterFactory.getInterpreter("user1", "note1", "test.conf", "test");
-
- InterpreterContext context = InterpreterContext.builder()
- .setNoteId("noteId")
- .setParagraphId("paragraphId")
- .build();
+ assertTrue(
+ interpreterFactory.getInterpreter("user1", "note1", "test.conf", "test")
+ instanceof ConfInterpreter);
+ ConfInterpreter confInterpreter =
+ (ConfInterpreter) interpreterFactory.getInterpreter("user1", "note1", "test.conf", "test");
+
+ InterpreterContext context =
+ InterpreterContext.builder().setNoteId("noteId").setParagraphId("paragraphId").build();
InterpreterResult result = confInterpreter.interpret("", context);
assertEquals(InterpreterResult.Code.SUCCESS, result.code);
- assertTrue(interpreterFactory.getInterpreter("user1", "note1", "test", "test") instanceof RemoteInterpreter);
- RemoteInterpreter remoteInterpreter = (RemoteInterpreter) interpreterFactory.getInterpreter("user1", "note1", "test", "test");
+ assertTrue(
+ interpreterFactory.getInterpreter("user1", "note1", "test", "test")
+ instanceof RemoteInterpreter);
+ RemoteInterpreter remoteInterpreter =
+ (RemoteInterpreter) interpreterFactory.getInterpreter("user1", "note1", "test", "test");
assertEquals(6, remoteInterpreter.getProperties().size());
assertEquals("value_1", remoteInterpreter.getProperty("property_1"));
assertEquals("value_3", remoteInterpreter.getProperty("property_3"));
}
-
@Test
public void testRunningAfterOtherInterpreter() throws IOException, InterpreterException {
- assertTrue(interpreterFactory.getInterpreter("user1", "note1", "test.conf", "test") instanceof ConfInterpreter);
- ConfInterpreter confInterpreter = (ConfInterpreter) interpreterFactory.getInterpreter("user1", "note1", "test.conf", "test");
+ assertTrue(
+ interpreterFactory.getInterpreter("user1", "note1", "test.conf", "test")
+ instanceof ConfInterpreter);
+ ConfInterpreter confInterpreter =
+ (ConfInterpreter) interpreterFactory.getInterpreter("user1", "note1", "test.conf", "test");
- InterpreterContext context = InterpreterContext.builder()
- .setNoteId("noteId")
- .setParagraphId("paragraphId")
- .build();
+ InterpreterContext context =
+ InterpreterContext.builder().setNoteId("noteId").setParagraphId("paragraphId").build();
- RemoteInterpreter remoteInterpreter = (RemoteInterpreter) interpreterFactory.getInterpreter("user1", "note1", "test", "test");
+ RemoteInterpreter remoteInterpreter =
+ (RemoteInterpreter) interpreterFactory.getInterpreter("user1", "note1", "test", "test");
InterpreterResult result = remoteInterpreter.interpret("hello world", context);
assertEquals(InterpreterResult.Code.SUCCESS, result.code);
result = confInterpreter.interpret("property_1\tnew_value\nnew_property\tdummy_value", context);
assertEquals(InterpreterResult.Code.ERROR, result.code);
}
-
}
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/55f6c91c/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/DoubleEchoInterpreter.java
----------------------------------------------------------------------
diff --git a/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/DoubleEchoInterpreter.java b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/DoubleEchoInterpreter.java
index be3d5be..13d72c2 100644
--- a/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/DoubleEchoInterpreter.java
+++ b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/DoubleEchoInterpreter.java
@@ -15,12 +15,10 @@
* limitations under the License.
*/
-
package org.apache.zeppelin.interpreter;
import java.util.Properties;
-
public class DoubleEchoInterpreter extends Interpreter {
public DoubleEchoInterpreter(Properties property) {
@@ -28,14 +26,10 @@ public class DoubleEchoInterpreter extends Interpreter {
}
@Override
- public void open() {
-
- }
+ public void open() {}
@Override
- public void close() {
-
- }
+ public void close() {}
@Override
public InterpreterResult interpret(String st, InterpreterContext context) {
@@ -43,9 +37,7 @@ public class DoubleEchoInterpreter extends Interpreter {
}
@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/55f6c91c/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/EchoInterpreter.java
----------------------------------------------------------------------
diff --git a/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/EchoInterpreter.java b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/EchoInterpreter.java
index cf1713f..e7ac62d 100644
--- a/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/EchoInterpreter.java
+++ b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/EchoInterpreter.java
@@ -15,14 +15,11 @@
* limitations under the License.
*/
-
package org.apache.zeppelin.interpreter;
import java.util.Properties;
-/**
- * Just return the received statement back
- */
+/** Just return the received statement back */
public class EchoInterpreter extends Interpreter {
public EchoInterpreter(Properties property) {
@@ -30,14 +27,10 @@ public class EchoInterpreter extends Interpreter {
}
@Override
- public void open() {
-
- }
+ public void open() {}
@Override
- public void close() {
-
- }
+ public void close() {}
@Override
public InterpreterResult interpret(String st, InterpreterContext context) {
@@ -49,9 +42,7 @@ public class EchoInterpreter extends Interpreter {
}
@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/55f6c91c/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/FlinkIntegrationTest.java
----------------------------------------------------------------------
diff --git a/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/FlinkIntegrationTest.java b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/FlinkIntegrationTest.java
index 57aacdb..0148c4d 100644
--- a/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/FlinkIntegrationTest.java
+++ b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/FlinkIntegrationTest.java
@@ -1,5 +1,12 @@
package org.apache.zeppelin.interpreter;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.EnumSet;
+import java.util.List;
import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationsRequest;
import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationsResponse;
import org.apache.hadoop.yarn.api.records.YarnApplicationState;
@@ -12,14 +19,6 @@ import org.junit.runners.Parameterized;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.EnumSet;
-import java.util.List;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
@RunWith(value = Parameterized.class)
public class FlinkIntegrationTest {
private static Logger LOGGER = LoggerFactory.getLogger(SparkIntegrationTest.class);
@@ -40,11 +39,7 @@ public class FlinkIntegrationTest {
@Parameterized.Parameters
public static List<Object[]> data() {
- return Arrays.asList(new Object[][]{
- {"1.5.1"},
- {"1.5.2"}
- });
-
+ return Arrays.asList(new Object[][] {{"1.5.1"}, {"1.5.2"}});
}
@BeforeClass
@@ -70,26 +65,35 @@ public class FlinkIntegrationTest {
private void testInterpreterBasics() throws IOException, InterpreterException {
// test FlinkInterpreter
- Interpreter flinkInterpreter = interpreterFactory.getInterpreter("user1", "note1", "flink", "flink");
+ Interpreter flinkInterpreter =
+ interpreterFactory.getInterpreter("user1", "note1", "flink", "flink");
- InterpreterContext context = new InterpreterContext.Builder().setNoteId("note1").setParagraphId("paragraph_1").build();
+ InterpreterContext context =
+ new InterpreterContext.Builder().setNoteId("note1").setParagraphId("paragraph_1").build();
InterpreterResult interpreterResult = flinkInterpreter.interpret("1+1", context);
assertEquals(InterpreterResult.Code.SUCCESS, interpreterResult.code);
assertTrue(interpreterResult.msg.get(0).getData().contains("2"));
-
}
@Test
public void testLocalMode() throws IOException, YarnException, InterpreterException {
- InterpreterSetting flinkInterpreterSetting = interpreterSettingManager.getInterpreterSettingByName("flink");
+ InterpreterSetting flinkInterpreterSetting =
+ interpreterSettingManager.getInterpreterSettingByName("flink");
flinkInterpreterSetting.setProperty("FLINK_HOME", flinkHome);
- flinkInterpreterSetting.setProperty("ZEPPELIN_CONF_DIR", zeppelin.getZeppelinConfDir().getAbsolutePath());
+ flinkInterpreterSetting.setProperty(
+ "ZEPPELIN_CONF_DIR", zeppelin.getZeppelinConfDir().getAbsolutePath());
testInterpreterBasics();
// no yarn application launched
- GetApplicationsRequest request = GetApplicationsRequest.newInstance(EnumSet.of(YarnApplicationState.RUNNING));
- GetApplicationsResponse response = hadoopCluster.getYarnCluster().getResourceManager().getClientRMService().getApplications(request);
+ GetApplicationsRequest request =
+ GetApplicationsRequest.newInstance(EnumSet.of(YarnApplicationState.RUNNING));
+ GetApplicationsResponse response =
+ hadoopCluster
+ .getYarnCluster()
+ .getResourceManager()
+ .getClientRMService()
+ .getApplications(request);
assertEquals(0, response.getApplicationList().size());
interpreterSettingManager.close();
@@ -98,16 +102,24 @@ public class FlinkIntegrationTest {
// TODO(zjffdu) enable it when make yarn integration test work
// @Test
public void testYarnMode() throws IOException, InterpreterException, YarnException {
- InterpreterSetting flinkInterpreterSetting = interpreterSettingManager.getInterpreterSettingByName("flink");
+ InterpreterSetting flinkInterpreterSetting =
+ interpreterSettingManager.getInterpreterSettingByName("flink");
flinkInterpreterSetting.setProperty("HADOOP_CONF_DIR", hadoopCluster.getConfigPath());
flinkInterpreterSetting.setProperty("FLINK_HOME", flinkHome);
- flinkInterpreterSetting.setProperty("ZEPPELIN_CONF_DIR", zeppelin.getZeppelinConfDir().getAbsolutePath());
+ flinkInterpreterSetting.setProperty(
+ "ZEPPELIN_CONF_DIR", zeppelin.getZeppelinConfDir().getAbsolutePath());
flinkInterpreterSetting.setProperty("flink.execution.mode", "YARN");
testInterpreterBasics();
// 1 yarn application launched
- GetApplicationsRequest request = GetApplicationsRequest.newInstance(EnumSet.of(YarnApplicationState.RUNNING));
- GetApplicationsResponse response = hadoopCluster.getYarnCluster().getResourceManager().getClientRMService().getApplications(request);
+ GetApplicationsRequest request =
+ GetApplicationsRequest.newInstance(EnumSet.of(YarnApplicationState.RUNNING));
+ GetApplicationsResponse response =
+ hadoopCluster
+ .getYarnCluster()
+ .getResourceManager()
+ .getClientRMService()
+ .getApplications(request);
assertEquals(1, response.getApplicationList().size());
interpreterSettingManager.close();
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/55f6c91c/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 6d4666a..3be77e7 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,37 +17,54 @@
package org.apache.zeppelin.interpreter;
-import org.apache.zeppelin.interpreter.remote.RemoteInterpreter;
-import org.junit.Test;
-
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
+import org.apache.zeppelin.interpreter.remote.RemoteInterpreter;
+import org.junit.Test;
+
public class InterpreterFactoryTest extends AbstractInterpreterTest {
@Test
public void testGetFactory() throws InterpreterException {
- assertTrue(interpreterFactory.getInterpreter("user1", "note1", "", "test") instanceof RemoteInterpreter);
- RemoteInterpreter remoteInterpreter = (RemoteInterpreter) interpreterFactory.getInterpreter("user1", "note1", "", "test");
+ assertTrue(
+ interpreterFactory.getInterpreter("user1", "note1", "", "test")
+ instanceof RemoteInterpreter);
+ RemoteInterpreter remoteInterpreter =
+ (RemoteInterpreter) interpreterFactory.getInterpreter("user1", "note1", "", "test");
// EchoInterpreter is the default interpreter because test is the default interpreter group
assertEquals(EchoInterpreter.class.getName(), remoteInterpreter.getClassName());
- assertTrue(interpreterFactory.getInterpreter("user1", "note1", "double_echo", "test") instanceof RemoteInterpreter);
- remoteInterpreter = (RemoteInterpreter) interpreterFactory.getInterpreter("user1", "note1", "double_echo", "test");
+ assertTrue(
+ interpreterFactory.getInterpreter("user1", "note1", "double_echo", "test")
+ instanceof RemoteInterpreter);
+ remoteInterpreter =
+ (RemoteInterpreter)
+ interpreterFactory.getInterpreter("user1", "note1", "double_echo", "test");
assertEquals(DoubleEchoInterpreter.class.getName(), remoteInterpreter.getClassName());
- assertTrue(interpreterFactory.getInterpreter("user1", "note1", "test", "test") instanceof RemoteInterpreter);
- remoteInterpreter = (RemoteInterpreter) interpreterFactory.getInterpreter("user1", "note1", "test", "test");
+ assertTrue(
+ interpreterFactory.getInterpreter("user1", "note1", "test", "test")
+ instanceof RemoteInterpreter);
+ remoteInterpreter =
+ (RemoteInterpreter) interpreterFactory.getInterpreter("user1", "note1", "test", "test");
assertEquals(EchoInterpreter.class.getName(), remoteInterpreter.getClassName());
- assertTrue(interpreterFactory.getInterpreter("user1", "note1", "test2", "test") instanceof RemoteInterpreter);
- remoteInterpreter = (RemoteInterpreter) interpreterFactory.getInterpreter("user1", "note1", "test2", "test");
+ assertTrue(
+ interpreterFactory.getInterpreter("user1", "note1", "test2", "test")
+ instanceof RemoteInterpreter);
+ remoteInterpreter =
+ (RemoteInterpreter) interpreterFactory.getInterpreter("user1", "note1", "test2", "test");
assertEquals(EchoInterpreter.class.getName(), remoteInterpreter.getClassName());
- assertTrue(interpreterFactory.getInterpreter("user1", "note1", "test2.double_echo", "test") instanceof RemoteInterpreter);
- remoteInterpreter = (RemoteInterpreter) interpreterFactory.getInterpreter("user1", "note1", "test2.double_echo", "test");
+ assertTrue(
+ interpreterFactory.getInterpreter("user1", "note1", "test2.double_echo", "test")
+ instanceof RemoteInterpreter);
+ remoteInterpreter =
+ (RemoteInterpreter)
+ interpreterFactory.getInterpreter("user1", "note1", "test2.double_echo", "test");
assertEquals(DoubleEchoInterpreter.class.getName(), remoteInterpreter.getClassName());
}
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/55f6c91c/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/InterpreterSettingManagerTest.java
----------------------------------------------------------------------
diff --git a/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/InterpreterSettingManagerTest.java b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/InterpreterSettingManagerTest.java
index 1780960..6418fac 100644
--- a/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/InterpreterSettingManagerTest.java
+++ b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/InterpreterSettingManagerTest.java
@@ -15,9 +15,19 @@
* limitations under the License.
*/
-
package org.apache.zeppelin.interpreter;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+import static org.mockito.Mockito.mock;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
import org.apache.zeppelin.conf.ZeppelinConfiguration;
import org.apache.zeppelin.dep.Dependency;
import org.apache.zeppelin.display.AngularObjectRegistryListener;
@@ -28,20 +38,6 @@ import org.junit.Test;
import org.sonatype.aether.RepositoryException;
import org.sonatype.aether.repository.RemoteRepository;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-import static org.mockito.Mockito.mock;
-
-
public class InterpreterSettingManagerTest extends AbstractInterpreterTest {
@Test
@@ -74,8 +70,12 @@ public class InterpreterSettingManagerTest extends AbstractInterpreterTest {
assertEquals("central", repositories.get(0).getId());
// Load it again
- InterpreterSettingManager interpreterSettingManager2 = new InterpreterSettingManager(conf,
- mock(AngularObjectRegistryListener.class), mock(RemoteInterpreterProcessListener.class), mock(ApplicationEventListener.class));
+ InterpreterSettingManager interpreterSettingManager2 =
+ new InterpreterSettingManager(
+ conf,
+ mock(AngularObjectRegistryListener.class),
+ mock(RemoteInterpreterProcessListener.class),
+ mock(ApplicationEventListener.class));
assertEquals(5, interpreterSettingManager2.get().size());
interpreterSetting = interpreterSettingManager2.getByName("test");
assertEquals("test", interpreterSetting.getName());
@@ -92,7 +92,6 @@ public class InterpreterSettingManagerTest extends AbstractInterpreterTest {
repositories = interpreterSettingManager2.getRepositories();
assertEquals(2, repositories.size());
assertEquals("central", repositories.get(0).getId());
-
}
@Test
@@ -102,16 +101,18 @@ public class InterpreterSettingManagerTest extends AbstractInterpreterTest {
option.setPerNote("scoped");
option.setPerUser("scoped");
Map<String, InterpreterProperty> properties = new HashMap<>();
- properties.put("property_4", new InterpreterProperty("property_4","value_4"));
+ properties.put("property_4", new InterpreterProperty("property_4", "value_4"));
try {
- interpreterSettingManager.createNewSetting("test2", "test", new ArrayList<Dependency>(), option, properties);
+ interpreterSettingManager.createNewSetting(
+ "test2", "test", new ArrayList<Dependency>(), option, properties);
fail("Should fail due to interpreter already existed");
} catch (IOException e) {
assertTrue(e.getMessage().contains("already existed"));
}
- interpreterSettingManager.createNewSetting("test3", "test", new ArrayList<Dependency>(), option, properties);
+ interpreterSettingManager.createNewSetting(
+ "test3", "test", new ArrayList<Dependency>(), option, properties);
assertEquals(6, interpreterSettingManager.get().size());
InterpreterSetting interpreterSetting = interpreterSettingManager.getByName("test3");
assertEquals("test3", interpreterSetting.getName());
@@ -132,8 +133,12 @@ public class InterpreterSettingManagerTest extends AbstractInterpreterTest {
assertNotNull(interpreterSetting.getInterpreterSettingManager());
// load it again, it should be saved in interpreter-setting.json. So we can restore it properly
- InterpreterSettingManager interpreterSettingManager2 = new InterpreterSettingManager(conf,
- mock(AngularObjectRegistryListener.class), mock(RemoteInterpreterProcessListener.class), mock(ApplicationEventListener.class));
+ InterpreterSettingManager interpreterSettingManager2 =
+ new InterpreterSettingManager(
+ conf,
+ mock(AngularObjectRegistryListener.class),
+ mock(RemoteInterpreterProcessListener.class),
+ mock(ApplicationEventListener.class));
assertEquals(6, interpreterSettingManager2.get().size());
interpreterSetting = interpreterSettingManager2.getByName("test3");
assertEquals("test3", interpreterSetting.getName());
@@ -152,7 +157,8 @@ public class InterpreterSettingManagerTest extends AbstractInterpreterTest {
newProperties.put("property_4", new InterpreterProperty("property_4", "new_value_4"));
List<Dependency> newDependencies = new ArrayList<>();
newDependencies.add(new Dependency("com.databricks:spark-avro_2.11:3.1.0"));
- interpreterSettingManager.setPropertyAndRestart(interpreterSetting.getId(), newOption, newProperties, newDependencies);
+ interpreterSettingManager.setPropertyAndRestart(
+ interpreterSetting.getId(), newOption, newProperties, newDependencies);
interpreterSetting = interpreterSettingManager.get(interpreterSetting.getId());
assertEquals("test3", interpreterSetting.getName());
assertEquals("test", interpreterSetting.getGroup());
@@ -184,22 +190,29 @@ public class InterpreterSettingManagerTest extends AbstractInterpreterTest {
assertEquals(5, interpreterSettingManager.get().size());
// load it again
- InterpreterSettingManager interpreterSettingManager3 = new InterpreterSettingManager(new ZeppelinConfiguration(),
- mock(AngularObjectRegistryListener.class), mock(RemoteInterpreterProcessListener.class), mock(ApplicationEventListener.class));
+ InterpreterSettingManager interpreterSettingManager3 =
+ new InterpreterSettingManager(
+ new ZeppelinConfiguration(),
+ mock(AngularObjectRegistryListener.class),
+ mock(RemoteInterpreterProcessListener.class),
+ mock(ApplicationEventListener.class));
assertEquals(5, interpreterSettingManager3.get().size());
-
}
@Test
public void testGetEditor() throws IOException, InterpreterNotFoundException {
- Interpreter echoInterpreter = interpreterFactory.getInterpreter("user1", "note1", "test.echo", "test");
+ Interpreter echoInterpreter =
+ interpreterFactory.getInterpreter("user1", "note1", "test.echo", "test");
// get editor setting from interpreter-setting.json
- Map<String, Object> editor = interpreterSettingManager.getEditorSetting(echoInterpreter, "user1", "note1", "test.echo");
+ Map<String, Object> editor =
+ interpreterSettingManager.getEditorSetting(echoInterpreter, "user1", "note1", "test.echo");
assertEquals("java", editor.get("language"));
// when editor setting doesn't exit, return the default editor
- Interpreter mock1Interpreter = interpreterFactory.getInterpreter("user1", "note1", "mock1", "test");
- editor = interpreterSettingManager.getEditorSetting(mock1Interpreter,"user1", "note1", "mock1");
+ Interpreter mock1Interpreter =
+ interpreterFactory.getInterpreter("user1", "note1", "mock1", "test");
+ editor =
+ interpreterSettingManager.getEditorSetting(mock1Interpreter, "user1", "note1", "mock1");
assertEquals("text", editor.get("language"));
}
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/55f6c91c/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/InterpreterSettingTest.java
----------------------------------------------------------------------
diff --git a/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/InterpreterSettingTest.java b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/InterpreterSettingTest.java
index e3e47d3..974c155 100644
--- a/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/InterpreterSettingTest.java
+++ b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/InterpreterSettingTest.java
@@ -17,14 +17,13 @@
package org.apache.zeppelin.interpreter;
-import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
+import org.junit.Test;
public class InterpreterSettingTest {
@@ -32,28 +31,44 @@ public class InterpreterSettingTest {
public void testCreateInterpreters() {
InterpreterOption interpreterOption = new InterpreterOption();
interpreterOption.setPerUser(InterpreterOption.SHARED);
- InterpreterInfo interpreterInfo1 = new InterpreterInfo(EchoInterpreter.class.getName(), "echo", true, new HashMap<String, Object>());
- InterpreterInfo interpreterInfo2 = new InterpreterInfo(DoubleEchoInterpreter.class.getName(), "double_echo", false, new HashMap<String, Object>());
+ InterpreterInfo interpreterInfo1 =
+ new InterpreterInfo(
+ EchoInterpreter.class.getName(), "echo", true, new HashMap<String, Object>());
+ InterpreterInfo interpreterInfo2 =
+ new InterpreterInfo(
+ DoubleEchoInterpreter.class.getName(),
+ "double_echo",
+ false,
+ new HashMap<String, Object>());
List<InterpreterInfo> interpreterInfos = new ArrayList<>();
interpreterInfos.add(interpreterInfo1);
interpreterInfos.add(interpreterInfo2);
- InterpreterSetting interpreterSetting = new InterpreterSetting.Builder()
- .setId("id")
- .setName("test")
- .setGroup("test")
- .setInterpreterInfos(interpreterInfos)
- .setOption(interpreterOption)
- .create();
+ InterpreterSetting interpreterSetting =
+ new InterpreterSetting.Builder()
+ .setId("id")
+ .setName("test")
+ .setGroup("test")
+ .setInterpreterInfos(interpreterInfos)
+ .setOption(interpreterOption)
+ .create();
// create default interpreter for user1 and note1
- assertEquals(EchoInterpreter.class.getName(), interpreterSetting.getDefaultInterpreter("user1", "note1").getClassName());
+ assertEquals(
+ EchoInterpreter.class.getName(),
+ interpreterSetting.getDefaultInterpreter("user1", "note1").getClassName());
// create interpreter echo for user1 and note1
- assertEquals(EchoInterpreter.class.getName(), interpreterSetting.getInterpreter("user1", "note1", "echo").getClassName());
- assertEquals(interpreterSetting.getDefaultInterpreter("user1", "note1"), interpreterSetting.getInterpreter("user1", "note1", "echo"));
+ assertEquals(
+ EchoInterpreter.class.getName(),
+ interpreterSetting.getInterpreter("user1", "note1", "echo").getClassName());
+ assertEquals(
+ interpreterSetting.getDefaultInterpreter("user1", "note1"),
+ interpreterSetting.getInterpreter("user1", "note1", "echo"));
// create interpreter double_echo for user1 and note1
- assertEquals(DoubleEchoInterpreter.class.getName(), interpreterSetting.getInterpreter("user1", "note1", "double_echo").getClassName());
+ assertEquals(
+ DoubleEchoInterpreter.class.getName(),
+ interpreterSetting.getInterpreter("user1", "note1", "double_echo").getClassName());
// create non-existed interpreter
assertNull(interpreterSetting.getInterpreter("user1", "note1", "invalid_echo"));
@@ -63,18 +78,26 @@ public class InterpreterSettingTest {
public void testSharedMode() {
InterpreterOption interpreterOption = new InterpreterOption();
interpreterOption.setPerUser(InterpreterOption.SHARED);
- InterpreterInfo interpreterInfo1 = new InterpreterInfo(EchoInterpreter.class.getName(), "echo", true, new HashMap<String, Object>());
- InterpreterInfo interpreterInfo2 = new InterpreterInfo(DoubleEchoInterpreter.class.getName(), "double_echo", false, new HashMap<String, Object>());
+ InterpreterInfo interpreterInfo1 =
+ new InterpreterInfo(
+ EchoInterpreter.class.getName(), "echo", true, new HashMap<String, Object>());
+ InterpreterInfo interpreterInfo2 =
+ new InterpreterInfo(
+ DoubleEchoInterpreter.class.getName(),
+ "double_echo",
+ false,
+ new HashMap<String, Object>());
List<InterpreterInfo> interpreterInfos = new ArrayList<>();
interpreterInfos.add(interpreterInfo1);
interpreterInfos.add(interpreterInfo2);
- InterpreterSetting interpreterSetting = new InterpreterSetting.Builder()
- .setId("id")
- .setName("test")
- .setGroup("test")
- .setInterpreterInfos(interpreterInfos)
- .setOption(interpreterOption)
- .create();
+ InterpreterSetting interpreterSetting =
+ new InterpreterSetting.Builder()
+ .setId("id")
+ .setName("test")
+ .setGroup("test")
+ .setInterpreterInfos(interpreterInfos)
+ .setOption(interpreterOption)
+ .create();
// create default interpreter for user1 and note1
interpreterSetting.getDefaultInterpreter("user1", "note1");
@@ -99,18 +122,26 @@ public class InterpreterSettingTest {
public void testPerUserScopedMode() {
InterpreterOption interpreterOption = new InterpreterOption();
interpreterOption.setPerUser(InterpreterOption.SCOPED);
- InterpreterInfo interpreterInfo1 = new InterpreterInfo(EchoInterpreter.class.getName(), "echo", true, new HashMap<String, Object>());
- InterpreterInfo interpreterInfo2 = new InterpreterInfo(DoubleEchoInterpreter.class.getName(), "double_echo", false, new HashMap<String, Object>());
+ InterpreterInfo interpreterInfo1 =
+ new InterpreterInfo(
+ EchoInterpreter.class.getName(), "echo", true, new HashMap<String, Object>());
+ InterpreterInfo interpreterInfo2 =
+ new InterpreterInfo(
+ DoubleEchoInterpreter.class.getName(),
+ "double_echo",
+ false,
+ new HashMap<String, Object>());
List<InterpreterInfo> interpreterInfos = new ArrayList<>();
interpreterInfos.add(interpreterInfo1);
interpreterInfos.add(interpreterInfo2);
- InterpreterSetting interpreterSetting = new InterpreterSetting.Builder()
- .setId("id")
- .setName("test")
- .setGroup("test")
- .setInterpreterInfos(interpreterInfos)
- .setOption(interpreterOption)
- .create();
+ InterpreterSetting interpreterSetting =
+ new InterpreterSetting.Builder()
+ .setId("id")
+ .setName("test")
+ .setGroup("test")
+ .setInterpreterInfos(interpreterInfos)
+ .setOption(interpreterOption)
+ .create();
// create interpreter for user1 and note1
interpreterSetting.getDefaultInterpreter("user1", "note1");
@@ -135,18 +166,26 @@ public class InterpreterSettingTest {
public void testPerNoteScopedMode() {
InterpreterOption interpreterOption = new InterpreterOption();
interpreterOption.setPerNote(InterpreterOption.SCOPED);
- InterpreterInfo interpreterInfo1 = new InterpreterInfo(EchoInterpreter.class.getName(), "echo", true, new HashMap<String, Object>());
- InterpreterInfo interpreterInfo2 = new InterpreterInfo(DoubleEchoInterpreter.class.getName(), "double_echo", false, new HashMap<String, Object>());
+ InterpreterInfo interpreterInfo1 =
+ new InterpreterInfo(
+ EchoInterpreter.class.getName(), "echo", true, new HashMap<String, Object>());
+ InterpreterInfo interpreterInfo2 =
+ new InterpreterInfo(
+ DoubleEchoInterpreter.class.getName(),
+ "double_echo",
+ false,
+ new HashMap<String, Object>());
List<InterpreterInfo> interpreterInfos = new ArrayList<>();
interpreterInfos.add(interpreterInfo1);
interpreterInfos.add(interpreterInfo2);
- InterpreterSetting interpreterSetting = new InterpreterSetting.Builder()
- .setId("id")
- .setName("test")
- .setGroup("test")
- .setInterpreterInfos(interpreterInfos)
- .setOption(interpreterOption)
- .create();
+ InterpreterSetting interpreterSetting =
+ new InterpreterSetting.Builder()
+ .setId("id")
+ .setName("test")
+ .setGroup("test")
+ .setInterpreterInfos(interpreterInfos)
+ .setOption(interpreterOption)
+ .create();
// create interpreter for user1 and note1
interpreterSetting.getDefaultInterpreter("user1", "note1");
@@ -171,18 +210,26 @@ public class InterpreterSettingTest {
public void testPerUserIsolatedMode() {
InterpreterOption interpreterOption = new InterpreterOption();
interpreterOption.setPerUser(InterpreterOption.ISOLATED);
- InterpreterInfo interpreterInfo1 = new InterpreterInfo(EchoInterpreter.class.getName(), "echo", true, new HashMap<String, Object>());
- InterpreterInfo interpreterInfo2 = new InterpreterInfo(DoubleEchoInterpreter.class.getName(), "double_echo", false, new HashMap<String, Object>());
+ InterpreterInfo interpreterInfo1 =
+ new InterpreterInfo(
+ EchoInterpreter.class.getName(), "echo", true, new HashMap<String, Object>());
+ InterpreterInfo interpreterInfo2 =
+ new InterpreterInfo(
+ DoubleEchoInterpreter.class.getName(),
+ "double_echo",
+ false,
+ new HashMap<String, Object>());
List<InterpreterInfo> interpreterInfos = new ArrayList<>();
interpreterInfos.add(interpreterInfo1);
interpreterInfos.add(interpreterInfo2);
- InterpreterSetting interpreterSetting = new InterpreterSetting.Builder()
- .setId("id")
- .setName("test")
- .setGroup("test")
- .setInterpreterInfos(interpreterInfos)
- .setOption(interpreterOption)
- .create();
+ InterpreterSetting interpreterSetting =
+ new InterpreterSetting.Builder()
+ .setId("id")
+ .setName("test")
+ .setGroup("test")
+ .setInterpreterInfos(interpreterInfos)
+ .setOption(interpreterOption)
+ .create();
// create interpreter for user1 and note1
interpreterSetting.getDefaultInterpreter("user1", "note1");
@@ -207,18 +254,26 @@ public class InterpreterSettingTest {
public void testPerNoteIsolatedMode() {
InterpreterOption interpreterOption = new InterpreterOption();
interpreterOption.setPerNote(InterpreterOption.ISOLATED);
- InterpreterInfo interpreterInfo1 = new InterpreterInfo(EchoInterpreter.class.getName(), "echo", true, new HashMap<String, Object>());
- InterpreterInfo interpreterInfo2 = new InterpreterInfo(DoubleEchoInterpreter.class.getName(), "double_echo", false, new HashMap<String, Object>());
+ InterpreterInfo interpreterInfo1 =
+ new InterpreterInfo(
+ EchoInterpreter.class.getName(), "echo", true, new HashMap<String, Object>());
+ InterpreterInfo interpreterInfo2 =
+ new InterpreterInfo(
+ DoubleEchoInterpreter.class.getName(),
+ "double_echo",
+ false,
+ new HashMap<String, Object>());
List<InterpreterInfo> interpreterInfos = new ArrayList<>();
interpreterInfos.add(interpreterInfo1);
interpreterInfos.add(interpreterInfo2);
- InterpreterSetting interpreterSetting = new InterpreterSetting.Builder()
- .setId("id")
- .setName("test")
- .setGroup("test")
- .setInterpreterInfos(interpreterInfos)
- .setOption(interpreterOption)
- .create();
+ InterpreterSetting interpreterSetting =
+ new InterpreterSetting.Builder()
+ .setId("id")
+ .setName("test")
+ .setGroup("test")
+ .setInterpreterInfos(interpreterInfos)
+ .setOption(interpreterOption)
+ .create();
// create interpreter for user1 and note1
interpreterSetting.getDefaultInterpreter("user1", "note1");
@@ -243,18 +298,26 @@ public class InterpreterSettingTest {
InterpreterOption interpreterOption = new InterpreterOption();
interpreterOption.setPerUser(InterpreterOption.ISOLATED);
interpreterOption.setPerNote(InterpreterOption.SCOPED);
- InterpreterInfo interpreterInfo1 = new InterpreterInfo(EchoInterpreter.class.getName(), "echo", true, new HashMap<String, Object>());
- InterpreterInfo interpreterInfo2 = new InterpreterInfo(DoubleEchoInterpreter.class.getName(), "double_echo", false, new HashMap<String, Object>());
+ InterpreterInfo interpreterInfo1 =
+ new InterpreterInfo(
+ EchoInterpreter.class.getName(), "echo", true, new HashMap<String, Object>());
+ InterpreterInfo interpreterInfo2 =
+ new InterpreterInfo(
+ DoubleEchoInterpreter.class.getName(),
+ "double_echo",
+ false,
+ new HashMap<String, Object>());
List<InterpreterInfo> interpreterInfos = new ArrayList<>();
interpreterInfos.add(interpreterInfo1);
interpreterInfos.add(interpreterInfo2);
- InterpreterSetting interpreterSetting = new InterpreterSetting.Builder()
- .setId("id")
- .setName("test")
- .setGroup("test")
- .setInterpreterInfos(interpreterInfos)
- .setOption(interpreterOption)
- .create();
+ InterpreterSetting interpreterSetting =
+ new InterpreterSetting.Builder()
+ .setId("id")
+ .setName("test")
+ .setGroup("test")
+ .setInterpreterInfos(interpreterInfos)
+ .setOption(interpreterOption)
+ .create();
// create interpreter for user1 and note1
interpreterSetting.getDefaultInterpreter("user1", "note1");
@@ -270,7 +333,9 @@ public class InterpreterSettingTest {
assertEquals(2, interpreterSetting.getAllInterpreterGroups().size());
// group1 for user1 has 2 sessions, and group2 for user2 has 1 session
- assertEquals(interpreterSetting.getInterpreterGroup("user1", "note1"), interpreterSetting.getInterpreterGroup("user1", "note2"));
+ assertEquals(
+ interpreterSetting.getInterpreterGroup("user1", "note1"),
+ interpreterSetting.getInterpreterGroup("user1", "note2"));
assertEquals(2, interpreterSetting.getInterpreterGroup("user1", "note1").getSessionNum());
assertEquals(2, interpreterSetting.getInterpreterGroup("user1", "note2").getSessionNum());
assertEquals(1, interpreterSetting.getInterpreterGroup("user2", "note1").getSessionNum());
@@ -294,18 +359,26 @@ public class InterpreterSettingTest {
InterpreterOption interpreterOption = new InterpreterOption();
interpreterOption.setPerUser(InterpreterOption.ISOLATED);
interpreterOption.setPerNote(InterpreterOption.ISOLATED);
- InterpreterInfo interpreterInfo1 = new InterpreterInfo(EchoInterpreter.class.getName(), "echo", true, new HashMap<String, Object>());
- InterpreterInfo interpreterInfo2 = new InterpreterInfo(DoubleEchoInterpreter.class.getName(), "double_echo", false, new HashMap<String, Object>());
+ InterpreterInfo interpreterInfo1 =
+ new InterpreterInfo(
+ EchoInterpreter.class.getName(), "echo", true, new HashMap<String, Object>());
+ InterpreterInfo interpreterInfo2 =
+ new InterpreterInfo(
+ DoubleEchoInterpreter.class.getName(),
+ "double_echo",
+ false,
+ new HashMap<String, Object>());
List<InterpreterInfo> interpreterInfos = new ArrayList<>();
interpreterInfos.add(interpreterInfo1);
interpreterInfos.add(interpreterInfo2);
- InterpreterSetting interpreterSetting = new InterpreterSetting.Builder()
- .setId("id")
- .setName("test")
- .setGroup("test")
- .setInterpreterInfos(interpreterInfos)
- .setOption(interpreterOption)
- .create();
+ InterpreterSetting interpreterSetting =
+ new InterpreterSetting.Builder()
+ .setId("id")
+ .setName("test")
+ .setGroup("test")
+ .setInterpreterInfos(interpreterInfos)
+ .setOption(interpreterOption)
+ .create();
// create interpreter for user1 and note1
interpreterSetting.getDefaultInterpreter("user1", "note1");
@@ -350,18 +423,26 @@ public class InterpreterSettingTest {
InterpreterOption interpreterOption = new InterpreterOption();
interpreterOption.setPerUser(InterpreterOption.SCOPED);
interpreterOption.setPerNote(InterpreterOption.SCOPED);
- InterpreterInfo interpreterInfo1 = new InterpreterInfo(EchoInterpreter.class.getName(), "echo", true, new HashMap<String, Object>());
- InterpreterInfo interpreterInfo2 = new InterpreterInfo(DoubleEchoInterpreter.class.getName(), "double_echo", false, new HashMap<String, Object>());
+ InterpreterInfo interpreterInfo1 =
+ new InterpreterInfo(
+ EchoInterpreter.class.getName(), "echo", true, new HashMap<String, Object>());
+ InterpreterInfo interpreterInfo2 =
+ new InterpreterInfo(
+ DoubleEchoInterpreter.class.getName(),
+ "double_echo",
+ false,
+ new HashMap<String, Object>());
List<InterpreterInfo> interpreterInfos = new ArrayList<>();
interpreterInfos.add(interpreterInfo1);
interpreterInfos.add(interpreterInfo2);
- InterpreterSetting interpreterSetting = new InterpreterSetting.Builder()
- .setId("id")
- .setName("test")
- .setGroup("test")
- .setInterpreterInfos(interpreterInfos)
- .setOption(interpreterOption)
- .create();
+ InterpreterSetting interpreterSetting =
+ new InterpreterSetting.Builder()
+ .setId("id")
+ .setName("test")
+ .setGroup("test")
+ .setInterpreterInfos(interpreterInfos)
+ .setOption(interpreterOption)
+ .create();
// create interpreter for user1 and note1
interpreterSetting.getDefaultInterpreter("user1", "note1");
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/55f6c91c/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/ManagedInterpreterGroupTest.java
----------------------------------------------------------------------
diff --git a/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/ManagedInterpreterGroupTest.java b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/ManagedInterpreterGroupTest.java
index aa73749..010a2f8 100644
--- a/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/ManagedInterpreterGroupTest.java
+++ b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/ManagedInterpreterGroupTest.java
@@ -17,19 +17,17 @@
package org.apache.zeppelin.interpreter;
-import org.junit.Before;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.sonatype.aether.RepositoryException;
+import static org.junit.Assert.assertEquals;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
-
-import static org.junit.Assert.assertEquals;
-
+import org.junit.Before;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.sonatype.aether.RepositoryException;
public class ManagedInterpreterGroupTest {
@@ -41,23 +39,32 @@ public class ManagedInterpreterGroupTest {
public void setUp() throws IOException, RepositoryException {
InterpreterOption interpreterOption = new InterpreterOption();
interpreterOption.setPerUser(InterpreterOption.SCOPED);
- InterpreterInfo interpreterInfo1 = new InterpreterInfo(EchoInterpreter.class.getName(), "echo", true, new HashMap<String, Object>());
- InterpreterInfo interpreterInfo2 = new InterpreterInfo(DoubleEchoInterpreter.class.getName(), "double_echo", false, new HashMap<String, Object>());
+ InterpreterInfo interpreterInfo1 =
+ new InterpreterInfo(
+ EchoInterpreter.class.getName(), "echo", true, new HashMap<String, Object>());
+ InterpreterInfo interpreterInfo2 =
+ new InterpreterInfo(
+ DoubleEchoInterpreter.class.getName(),
+ "double_echo",
+ false,
+ new HashMap<String, Object>());
List<InterpreterInfo> interpreterInfos = new ArrayList<>();
interpreterInfos.add(interpreterInfo1);
interpreterInfos.add(interpreterInfo2);
- interpreterSetting = new InterpreterSetting.Builder()
- .setId("id")
- .setName("test")
- .setGroup("test")
- .setInterpreterInfos(interpreterInfos)
- .setOption(interpreterOption)
- .create();
+ interpreterSetting =
+ new InterpreterSetting.Builder()
+ .setId("id")
+ .setName("test")
+ .setGroup("test")
+ .setInterpreterInfos(interpreterInfos)
+ .setOption(interpreterOption)
+ .create();
}
@Test
public void testInterpreterGroup() {
- ManagedInterpreterGroup interpreterGroup = new ManagedInterpreterGroup("group_1", interpreterSetting);
+ ManagedInterpreterGroup interpreterGroup =
+ new ManagedInterpreterGroup("group_1", interpreterSetting);
assertEquals(0, interpreterGroup.getSessionNum());
// create session_1
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/55f6c91c/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/MiniHadoopCluster.java
----------------------------------------------------------------------
diff --git a/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/MiniHadoopCluster.java b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/MiniHadoopCluster.java
index b0799ae..4f29feb 100644
--- a/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/MiniHadoopCluster.java
+++ b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/MiniHadoopCluster.java
@@ -1,5 +1,8 @@
package org.apache.zeppelin.interpreter;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hdfs.MiniDFSCluster;
import org.apache.hadoop.yarn.conf.YarnConfiguration;
@@ -9,13 +12,7 @@ import org.junit.BeforeClass;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-
-
/**
- *
* Util class for creating a Mini Hadoop cluster in local machine to test scenarios that needs
* hadoop cluster.
*/
@@ -34,28 +31,31 @@ public class MiniHadoopCluster {
this.hadoopConf = new Configuration();
new File(configPath).mkdirs();
// start MiniDFSCluster
- this.dfsCluster = new MiniDFSCluster.Builder(hadoopConf)
- .numDataNodes(2)
- .format(true)
- .waitSafeMode(true)
- .build();
+ this.dfsCluster =
+ new MiniDFSCluster.Builder(hadoopConf)
+ .numDataNodes(2)
+ .format(true)
+ .waitSafeMode(true)
+ .build();
this.dfsCluster.waitActive();
saveConfig(hadoopConf, configPath + "/core-site.xml");
// start MiniYarnCluster
YarnConfiguration baseConfig = new YarnConfiguration(hadoopConf);
- baseConfig.set("yarn.nodemanager.disk-health-checker.max-disk-utilization-per-disk-percentage", "95");
- this.yarnCluster = new MiniYARNCluster(getClass().getName(), 2,
- 1, 1);
+ baseConfig.set(
+ "yarn.nodemanager.disk-health-checker.max-disk-utilization-per-disk-percentage", "95");
+ this.yarnCluster = new MiniYARNCluster(getClass().getName(), 2, 1, 1);
yarnCluster.init(baseConfig);
// Install a shutdown hook for stop the service and kill all running applications.
- Runtime.getRuntime().addShutdownHook(new Thread() {
- @Override
- public void run() {
- yarnCluster.stop();
- }
- });
+ Runtime.getRuntime()
+ .addShutdownHook(
+ new Thread() {
+ @Override
+ public void run() {
+ yarnCluster.stop();
+ }
+ });
yarnCluster.start();
@@ -77,7 +77,7 @@ public class MiniHadoopCluster {
}
LOGGER.info("RM address in configuration is " + yarnConfig.get(YarnConfiguration.RM_ADDRESS));
- saveConfig(yarnConfig,configPath + "/yarn-site.xml");
+ saveConfig(yarnConfig, configPath + "/yarn-site.xml");
}
protected void saveConfig(Configuration conf, String dest) throws IOException {
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/55f6c91c/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/MiniZeppelin.java
----------------------------------------------------------------------
diff --git a/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/MiniZeppelin.java b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/MiniZeppelin.java
index 1a1a2f3..9bb2976 100644
--- a/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/MiniZeppelin.java
+++ b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/MiniZeppelin.java
@@ -1,7 +1,10 @@
package org.apache.zeppelin.interpreter;
+import static org.mockito.Mockito.mock;
+
+import java.io.File;
+import java.io.IOException;
import org.apache.commons.io.FileUtils;
-import org.apache.commons.io.IOUtils;
import org.apache.zeppelin.conf.ZeppelinConfiguration;
import org.apache.zeppelin.display.AngularObjectRegistryListener;
import org.apache.zeppelin.helium.ApplicationEventListener;
@@ -9,11 +12,6 @@ import org.apache.zeppelin.interpreter.remote.RemoteInterpreterProcessListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.io.File;
-import java.io.IOException;
-
-import static org.mockito.Mockito.mock;
-
public class MiniZeppelin {
protected static final Logger LOGGER = LoggerFactory.getLogger(MiniZeppelin.class);
@@ -27,21 +25,32 @@ public class MiniZeppelin {
public void start() throws IOException {
zeppelinHome = new File("..");
- System.setProperty(ZeppelinConfiguration.ConfVars.ZEPPELIN_HOME.getVarName(),
- zeppelinHome.getAbsolutePath());
+ System.setProperty(
+ ZeppelinConfiguration.ConfVars.ZEPPELIN_HOME.getVarName(), zeppelinHome.getAbsolutePath());
confDir = new File(zeppelinHome, "conf_" + getClass().getSimpleName());
notebookDir = new File(zeppelinHome, "notebook_" + getClass().getSimpleName());
confDir.mkdirs();
notebookDir.mkdirs();
LOGGER.info("ZEPPELIN_HOME: " + zeppelinHome.getAbsolutePath());
- FileUtils.copyFile(new File(zeppelinHome, "conf/log4j.properties"), new File(confDir, "log4j.properties"));
- FileUtils.copyFile(new File(zeppelinHome, "conf/log4j_yarn_cluster.properties"), new File(confDir, "log4j_yarn_cluster.properties"));
- System.setProperty(ZeppelinConfiguration.ConfVars.ZEPPELIN_CONF_DIR.getVarName(), confDir.getAbsolutePath());
- System.setProperty(ZeppelinConfiguration.ConfVars.ZEPPELIN_NOTEBOOK_DIR.getVarName(), notebookDir.getAbsolutePath());
- System.setProperty(ZeppelinConfiguration.ConfVars.ZEPPELIN_INTERPRETER_CONNECT_TIMEOUT.getVarName(), "120000");
+ FileUtils.copyFile(
+ new File(zeppelinHome, "conf/log4j.properties"), new File(confDir, "log4j.properties"));
+ FileUtils.copyFile(
+ new File(zeppelinHome, "conf/log4j_yarn_cluster.properties"),
+ new File(confDir, "log4j_yarn_cluster.properties"));
+ System.setProperty(
+ ZeppelinConfiguration.ConfVars.ZEPPELIN_CONF_DIR.getVarName(), confDir.getAbsolutePath());
+ System.setProperty(
+ ZeppelinConfiguration.ConfVars.ZEPPELIN_NOTEBOOK_DIR.getVarName(),
+ notebookDir.getAbsolutePath());
+ System.setProperty(
+ ZeppelinConfiguration.ConfVars.ZEPPELIN_INTERPRETER_CONNECT_TIMEOUT.getVarName(), "120000");
conf = new ZeppelinConfiguration();
- interpreterSettingManager = new InterpreterSettingManager(conf,
- mock(AngularObjectRegistryListener.class), mock(RemoteInterpreterProcessListener.class), mock(ApplicationEventListener.class));
+ interpreterSettingManager =
+ new InterpreterSettingManager(
+ conf,
+ mock(AngularObjectRegistryListener.class),
+ mock(RemoteInterpreterProcessListener.class),
+ mock(ApplicationEventListener.class));
interpreterFactory = new InterpreterFactory(interpreterSettingManager);
}
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/55f6c91c/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/SessionConfInterpreterTest.java
----------------------------------------------------------------------
diff --git a/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/SessionConfInterpreterTest.java b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/SessionConfInterpreterTest.java
index 7baa2e2..f28d1ce 100644
--- a/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/SessionConfInterpreterTest.java
+++ b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/SessionConfInterpreterTest.java
@@ -15,19 +15,17 @@
* limitations under the License.
*/
-
package org.apache.zeppelin.interpreter;
-import org.apache.zeppelin.interpreter.remote.RemoteInterpreter;
-import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
-
-import static org.junit.Assert.assertEquals;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
+import org.apache.zeppelin.interpreter.remote.RemoteInterpreter;
+import org.junit.Test;
public class SessionConfInterpreterTest {
@@ -41,8 +39,8 @@ public class SessionConfInterpreterTest {
Properties properties = new Properties();
properties.setProperty("property_1", "value_1");
properties.setProperty("property_2", "value_2");
- SessionConfInterpreter confInterpreter = new SessionConfInterpreter(
- properties, "session_1", "group_1", mockInterpreterSetting);
+ SessionConfInterpreter confInterpreter =
+ new SessionConfInterpreter(properties, "session_1", "group_1", mockInterpreterSetting);
RemoteInterpreter remoteInterpreter =
new RemoteInterpreter(properties, "session_1", "clasName", "user1", null);
@@ -52,8 +50,8 @@ public class SessionConfInterpreterTest {
when(mockInterpreterGroup.get("session_1")).thenReturn(interpreters);
InterpreterResult result =
- confInterpreter.interpret("property_1\tupdated_value_1\nproperty_3\tvalue_3",
- mock(InterpreterContext.class));
+ confInterpreter.interpret(
+ "property_1\tupdated_value_1\nproperty_3\tvalue_3", mock(InterpreterContext.class));
assertEquals(InterpreterResult.Code.SUCCESS, result.code);
assertEquals(3, remoteInterpreter.getProperties().size());
assertEquals("updated_value_1", remoteInterpreter.getProperty("property_1"));
@@ -62,8 +60,8 @@ public class SessionConfInterpreterTest {
remoteInterpreter.setOpened(true);
result =
- confInterpreter.interpret("property_1\tupdated_value_1\nproperty_3\tvalue_3",
- mock(InterpreterContext.class));
+ confInterpreter.interpret(
+ "property_1\tupdated_value_1\nproperty_3\tvalue_3", mock(InterpreterContext.class));
assertEquals(InterpreterResult.Code.ERROR, result.code);
}
}
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/55f6c91c/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/SleepInterpreter.java
----------------------------------------------------------------------
diff --git a/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/SleepInterpreter.java b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/SleepInterpreter.java
index 7a904c6..eb2437f 100644
--- a/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/SleepInterpreter.java
+++ b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/SleepInterpreter.java
@@ -1,13 +1,10 @@
package org.apache.zeppelin.interpreter;
+import java.util.Properties;
import org.apache.zeppelin.scheduler.Scheduler;
import org.apache.zeppelin.scheduler.SchedulerFactory;
-import java.util.Properties;
-
-/**
- * Interpreter that only accept long value and sleep for such period
- */
+/** Interpreter that only accept long value and sleep for such period */
public class SleepInterpreter extends Interpreter {
public SleepInterpreter(Properties property) {
@@ -15,14 +12,10 @@ public class SleepInterpreter extends Interpreter {
}
@Override
- public void open() {
-
- }
+ public void open() {}
@Override
- public void close() {
-
- }
+ public void close() {}
@Override
public InterpreterResult interpret(String st, InterpreterContext context) {
@@ -35,9 +28,7 @@ public class SleepInterpreter extends Interpreter {
}
@Override
- public void cancel(InterpreterContext context) {
-
- }
+ public void cancel(InterpreterContext context) {}
@Override
public FormType getFormType() {
@@ -47,8 +38,8 @@ public class SleepInterpreter extends Interpreter {
@Override
public Scheduler getScheduler() {
if (Boolean.parseBoolean(getProperty("zeppelin.SleepInterpreter.parallel", "false"))) {
- return SchedulerFactory.singleton().createOrGetParallelScheduler(
- "Parallel-" + SleepInterpreter.class.getName(), 10);
+ return SchedulerFactory.singleton()
+ .createOrGetParallelScheduler("Parallel-" + SleepInterpreter.class.getName(), 10);
}
return super.getScheduler();
}
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/55f6c91c/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/SparkIntegrationTest.java
----------------------------------------------------------------------
diff --git a/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/SparkIntegrationTest.java b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/SparkIntegrationTest.java
index fed9ad2..a97751e 100644
--- a/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/SparkIntegrationTest.java
+++ b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/SparkIntegrationTest.java
@@ -1,5 +1,12 @@
package org.apache.zeppelin.interpreter;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.EnumSet;
+import java.util.List;
import org.apache.commons.io.IOUtils;
import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationsRequest;
import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationsResponse;
@@ -13,14 +20,6 @@ import org.junit.runners.Parameterized;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.EnumSet;
-import java.util.List;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
@RunWith(value = Parameterized.class)
public class SparkIntegrationTest {
private static Logger LOGGER = LoggerFactory.getLogger(SparkIntegrationTest.class);
@@ -41,12 +40,7 @@ public class SparkIntegrationTest {
@Parameterized.Parameters
public static List<Object[]> data() {
- return Arrays.asList(new Object[][]{
- {"2.2.1"},
- {"2.1.2"},
- {"2.0.2"},
- {"1.6.3"}
- });
+ return Arrays.asList(new Object[][] {{"2.2.1"}, {"2.1.2"}, {"2.0.2"}, {"1.6.3"}});
}
@BeforeClass
@@ -72,40 +66,54 @@ public class SparkIntegrationTest {
private void testInterpreterBasics() throws IOException, InterpreterException {
// test SparkInterpreter
- Interpreter sparkInterpreter = interpreterFactory.getInterpreter("user1", "note1", "spark.spark", "test");
+ Interpreter sparkInterpreter =
+ interpreterFactory.getInterpreter("user1", "note1", "spark.spark", "test");
- InterpreterContext context = new InterpreterContext.Builder().setNoteId("note1").setParagraphId("paragraph_1").build();
+ InterpreterContext context =
+ new InterpreterContext.Builder().setNoteId("note1").setParagraphId("paragraph_1").build();
InterpreterResult interpreterResult = sparkInterpreter.interpret("sc.version", context);
assertEquals(InterpreterResult.Code.SUCCESS, interpreterResult.code);
String detectedSparkVersion = interpreterResult.message().get(0).getData();
- assertTrue(detectedSparkVersion +" doesn't contain " + this.sparkVersion, detectedSparkVersion.contains(this.sparkVersion));
+ assertTrue(
+ detectedSparkVersion + " doesn't contain " + this.sparkVersion,
+ detectedSparkVersion.contains(this.sparkVersion));
interpreterResult = sparkInterpreter.interpret("sc.range(1,10).sum()", context);
assertEquals(InterpreterResult.Code.SUCCESS, interpreterResult.code);
assertTrue(interpreterResult.msg.get(0).getData().contains("45"));
// test PySparkInterpreter
- Interpreter pySparkInterpreter = interpreterFactory.getInterpreter("user1", "note1", "spark.pyspark", "test");
- interpreterResult = pySparkInterpreter.interpret("sqlContext.createDataFrame([(1,'a'),(2,'b')], ['id','name']).registerTempTable('test')", context);
+ Interpreter pySparkInterpreter =
+ interpreterFactory.getInterpreter("user1", "note1", "spark.pyspark", "test");
+ interpreterResult =
+ pySparkInterpreter.interpret(
+ "sqlContext.createDataFrame([(1,'a'),(2,'b')], ['id','name']).registerTempTable('test')",
+ context);
assertEquals(InterpreterResult.Code.SUCCESS, interpreterResult.code);
// test IPySparkInterpreter
- Interpreter ipySparkInterpreter = interpreterFactory.getInterpreter("user1", "note1", "spark.ipyspark", "test");
+ Interpreter ipySparkInterpreter =
+ interpreterFactory.getInterpreter("user1", "note1", "spark.ipyspark", "test");
interpreterResult = ipySparkInterpreter.interpret("sqlContext.table('test').show()", context);
assertEquals(InterpreterResult.Code.SUCCESS, interpreterResult.code);
// test SparkSQLInterpreter
- Interpreter sqlInterpreter = interpreterFactory.getInterpreter("user1", "note1", "spark.sql", "test");
+ Interpreter sqlInterpreter =
+ interpreterFactory.getInterpreter("user1", "note1", "spark.sql", "test");
interpreterResult = sqlInterpreter.interpret("select count(1) as c from test", context);
assertEquals(InterpreterResult.Code.SUCCESS, interpreterResult.code);
assertEquals(InterpreterResult.Type.TABLE, interpreterResult.message().get(0).getType());
assertEquals("c\n2\n", interpreterResult.message().get(0).getData());
// test SparkRInterpreter
- Interpreter sparkrInterpreter = interpreterFactory.getInterpreter("user1", "note1", "spark.r", "test");
+ Interpreter sparkrInterpreter =
+ interpreterFactory.getInterpreter("user1", "note1", "spark.r", "test");
if (isSpark2()) {
- interpreterResult = sparkrInterpreter.interpret("df <- as.DataFrame(faithful)\nhead(df)", context);
+ interpreterResult =
+ sparkrInterpreter.interpret("df <- as.DataFrame(faithful)\nhead(df)", context);
} else {
- interpreterResult = sparkrInterpreter.interpret("df <- createDataFrame(sqlContext, faithful)\nhead(df)", context);
+ interpreterResult =
+ sparkrInterpreter.interpret(
+ "df <- createDataFrame(sqlContext, faithful)\nhead(df)", context);
}
assertEquals(InterpreterResult.Code.SUCCESS, interpreterResult.code);
assertEquals(InterpreterResult.Type.TEXT, interpreterResult.message().get(0).getType());
@@ -114,30 +122,41 @@ public class SparkIntegrationTest {
@Test
public void testLocalMode() throws IOException, YarnException, InterpreterException {
- InterpreterSetting sparkInterpreterSetting = interpreterSettingManager.getInterpreterSettingByName("spark");
+ InterpreterSetting sparkInterpreterSetting =
+ interpreterSettingManager.getInterpreterSettingByName("spark");
sparkInterpreterSetting.setProperty("master", "local[*]");
sparkInterpreterSetting.setProperty("SPARK_HOME", sparkHome);
- sparkInterpreterSetting.setProperty("ZEPPELIN_CONF_DIR", zeppelin.getZeppelinConfDir().getAbsolutePath());
+ sparkInterpreterSetting.setProperty(
+ "ZEPPELIN_CONF_DIR", zeppelin.getZeppelinConfDir().getAbsolutePath());
sparkInterpreterSetting.setProperty("zeppelin.spark.useHiveContext", "false");
sparkInterpreterSetting.setProperty("zeppelin.pyspark.useIPython", "false");
testInterpreterBasics();
// no yarn application launched
- GetApplicationsRequest request = GetApplicationsRequest.newInstance(EnumSet.of(YarnApplicationState.RUNNING));
- GetApplicationsResponse response = hadoopCluster.getYarnCluster().getResourceManager().getClientRMService().getApplications(request);
+ GetApplicationsRequest request =
+ GetApplicationsRequest.newInstance(EnumSet.of(YarnApplicationState.RUNNING));
+ GetApplicationsResponse response =
+ hadoopCluster
+ .getYarnCluster()
+ .getResourceManager()
+ .getClientRMService()
+ .getApplications(request);
assertEquals(0, response.getApplicationList().size());
interpreterSettingManager.close();
}
@Test
- public void testYarnClientMode() throws IOException, YarnException, InterruptedException, InterpreterException {
- InterpreterSetting sparkInterpreterSetting = interpreterSettingManager.getInterpreterSettingByName("spark");
+ public void testYarnClientMode()
+ throws IOException, YarnException, InterruptedException, InterpreterException {
+ InterpreterSetting sparkInterpreterSetting =
+ interpreterSettingManager.getInterpreterSettingByName("spark");
sparkInterpreterSetting.setProperty("master", "yarn-client");
sparkInterpreterSetting.setProperty("HADOOP_CONF_DIR", hadoopCluster.getConfigPath());
sparkInterpreterSetting.setProperty("SPARK_HOME", sparkHome);
- sparkInterpreterSetting.setProperty("ZEPPELIN_CONF_DIR", zeppelin.getZeppelinConfDir().getAbsolutePath());
+ sparkInterpreterSetting.setProperty(
+ "ZEPPELIN_CONF_DIR", zeppelin.getZeppelinConfDir().getAbsolutePath());
sparkInterpreterSetting.setProperty("zeppelin.spark.useHiveContext", "false");
sparkInterpreterSetting.setProperty("zeppelin.pyspark.useIPython", "false");
sparkInterpreterSetting.setProperty("PYSPARK_PYTHON", getPythonExec());
@@ -146,20 +165,29 @@ public class SparkIntegrationTest {
testInterpreterBasics();
// 1 yarn application launched
- GetApplicationsRequest request = GetApplicationsRequest.newInstance(EnumSet.of(YarnApplicationState.RUNNING));
- GetApplicationsResponse response = hadoopCluster.getYarnCluster().getResourceManager().getClientRMService().getApplications(request);
+ GetApplicationsRequest request =
+ GetApplicationsRequest.newInstance(EnumSet.of(YarnApplicationState.RUNNING));
+ GetApplicationsResponse response =
+ hadoopCluster
+ .getYarnCluster()
+ .getResourceManager()
+ .getClientRMService()
+ .getApplications(request);
assertEquals(1, response.getApplicationList().size());
interpreterSettingManager.close();
}
@Test
- public void testYarnClusterMode() throws IOException, YarnException, InterruptedException, InterpreterException {
- InterpreterSetting sparkInterpreterSetting = interpreterSettingManager.getInterpreterSettingByName("spark");
+ public void testYarnClusterMode()
+ throws IOException, YarnException, InterruptedException, InterpreterException {
+ InterpreterSetting sparkInterpreterSetting =
+ interpreterSettingManager.getInterpreterSettingByName("spark");
sparkInterpreterSetting.setProperty("master", "yarn-cluster");
sparkInterpreterSetting.setProperty("HADOOP_CONF_DIR", hadoopCluster.getConfigPath());
sparkInterpreterSetting.setProperty("SPARK_HOME", sparkHome);
- sparkInterpreterSetting.setProperty("ZEPPELIN_CONF_DIR", zeppelin.getZeppelinConfDir().getAbsolutePath());
+ sparkInterpreterSetting.setProperty(
+ "ZEPPELIN_CONF_DIR", zeppelin.getZeppelinConfDir().getAbsolutePath());
sparkInterpreterSetting.setProperty("zeppelin.spark.useHiveContext", "false");
sparkInterpreterSetting.setProperty("zeppelin.pyspark.useIPython", "false");
sparkInterpreterSetting.setProperty("PYSPARK_PYTHON", getPythonExec());
@@ -168,8 +196,14 @@ public class SparkIntegrationTest {
testInterpreterBasics();
// 1 yarn application launched
- GetApplicationsRequest request = GetApplicationsRequest.newInstance(EnumSet.of(YarnApplicationState.RUNNING));
- GetApplicationsResponse response = hadoopCluster.getYarnCluster().getResourceManager().getClientRMService().getApplications(request);
+ GetApplicationsRequest request =
+ GetApplicationsRequest.newInstance(EnumSet.of(YarnApplicationState.RUNNING));
+ GetApplicationsResponse response =
+ hadoopCluster
+ .getYarnCluster()
+ .getResourceManager()
+ .getClientRMService()
+ .getApplications(request);
assertEquals(1, response.getApplicationList().size());
interpreterSettingManager.close();
@@ -180,7 +214,7 @@ public class SparkIntegrationTest {
}
private String getPythonExec() throws IOException, InterruptedException {
- Process process = Runtime.getRuntime().exec(new String[]{"which", "python"});
+ Process process = Runtime.getRuntime().exec(new String[] {"which", "python"});
if (process.waitFor() != 0) {
throw new RuntimeException("Fail to run command: which python.");
}