use of org.apache.zeppelin.interpreter.InterpreterResult in project zeppelin by apache.
the class AlluxioInterpreterTest method mkdirTest.
@Test
public void mkdirTest() throws IOException, AlluxioException {
String qualifiedPath = "tachyon://" + mLocalAlluxioCluster.getMasterHostname() + ":" + mLocalAlluxioCluster.getMasterPort() + "/root/testFile1";
InterpreterResult output = alluxioInterpreter.interpret("mkdir " + qualifiedPath, null);
boolean existsDir = fs.exists(new AlluxioURI("/root/testFile1"));
Assert.assertEquals("Successfully created directory " + qualifiedPath + "\n\n", output.message().get(0).getData());
Assert.assertTrue(existsDir);
}
use of org.apache.zeppelin.interpreter.InterpreterResult in project zeppelin by apache.
the class BeamInterpreterTest method testStaticReplWithoutMain.
@Test
public void testStaticReplWithoutMain() {
StringBuffer sourceCode = new StringBuffer();
sourceCode.append("package org.mdkt;\n");
sourceCode.append("public class HelloClass {\n");
sourceCode.append(" public String hello() { return \"hello\"; }");
sourceCode.append("}");
InterpreterResult res = beam.interpret(sourceCode.toString(), context);
assertEquals(InterpreterResult.Code.ERROR, res.code());
}
use of org.apache.zeppelin.interpreter.InterpreterResult in project zeppelin by apache.
the class BeamInterpreterTest method testStaticReplWithSyntaxError.
@Test
public void testStaticReplWithSyntaxError() {
StringWriter writer = new StringWriter();
PrintWriter out = new PrintWriter(writer);
out.println("public class HelloWorld {");
out.println(" public static void main(String args[]) {");
out.println(" System.out.prin(\"This is in another java file\");");
out.println(" }");
out.println("}");
out.close();
InterpreterResult res = beam.interpret(writer.toString(), context);
assertEquals(InterpreterResult.Code.ERROR, res.code());
}
use of org.apache.zeppelin.interpreter.InterpreterResult in project zeppelin by apache.
the class BigQueryInterpreter method executeSql.
//Function to call bigQuery to run SQL and return results to the Interpreter for output
private InterpreterResult executeSql(String sql) {
int counter = 0;
StringBuilder finalmessage = null;
finalmessage = new StringBuilder("%table ");
String projId = getProperty(PROJECT_ID);
long wTime = Long.parseLong(getProperty(WAIT_TIME));
long maxRows = Long.parseLong(getProperty(MAX_ROWS));
Iterator<GetQueryResultsResponse> pages;
try {
pages = run(sql, projId, wTime, maxRows);
} catch (IOException ex) {
logger.error(ex.getMessage());
return new InterpreterResult(Code.ERROR, ex.getMessage());
}
try {
while (pages.hasNext()) {
finalmessage.append(printRows(pages.next()));
}
return new InterpreterResult(Code.SUCCESS, finalmessage.toString());
} catch (NullPointerException ex) {
return new InterpreterResult(Code.ERROR, ex.getMessage());
}
}
use of org.apache.zeppelin.interpreter.InterpreterResult in project zeppelin by apache.
the class BigQueryInterpreterTest method badSqlSyntaxFails.
@Test
public void badSqlSyntaxFails() {
InterpreterResult ret = bqInterpreter.interpret(CONSTANTS.getWrong(), context);
assertEquals(InterpreterResult.Code.ERROR, ret.code());
}
Aggregations