Search in sources :

Example 1 with InterpreterResult

use of org.apache.zeppelin.interpreter.InterpreterResult in project zeppelin by apache.

the class BeamInterpreterTest method testStaticRepl.

@Test
public void testStaticRepl() {
    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.println(\"This is in another java file\");");
    out.println("  }");
    out.println("}");
    out.close();
    InterpreterResult res = beam.interpret(writer.toString(), context);
    assertEquals(InterpreterResult.Code.SUCCESS, res.code());
}
Also used : StringWriter(java.io.StringWriter) InterpreterResult(org.apache.zeppelin.interpreter.InterpreterResult) PrintWriter(java.io.PrintWriter) Test(org.junit.Test)

Example 2 with InterpreterResult

use of org.apache.zeppelin.interpreter.InterpreterResult in project zeppelin by apache.

the class BigQueryInterpreterTest method sqlSuccess.

@Test
public void sqlSuccess() {
    InterpreterResult ret = bqInterpreter.interpret(CONSTANTS.getOne(), context);
    assertEquals(InterpreterResult.Code.SUCCESS, ret.code());
    assertEquals(ret.message().get(0).getType(), InterpreterResult.Type.TABLE);
}
Also used : InterpreterResult(org.apache.zeppelin.interpreter.InterpreterResult) Test(org.junit.Test)

Example 3 with InterpreterResult

use of org.apache.zeppelin.interpreter.InterpreterResult in project zeppelin by apache.

the class AlluxioInterpreterTest method lsRecursiveTest.

@Test
public void lsRecursiveTest() throws IOException, AlluxioException {
    URIStatus[] files = new URIStatus[4];
    FileSystemTestUtils.createByteFile(fs, "/testRoot/testFileA", WriteType.MUST_CACHE, 10, 10);
    FileSystemTestUtils.createByteFile(fs, "/testRoot/testDir/testFileB", WriteType.MUST_CACHE, 20, 20);
    FileSystemTestUtils.createByteFile(fs, "/testRoot/testFileC", WriteType.THROUGH, 30, 30);
    files[0] = fs.getStatus(new AlluxioURI("/testRoot/testFileA"));
    files[1] = fs.getStatus(new AlluxioURI("/testRoot/testDir"));
    files[2] = fs.getStatus(new AlluxioURI("/testRoot/testDir/testFileB"));
    files[3] = fs.getStatus(new AlluxioURI("/testRoot/testFileC"));
    InterpreterResult output = alluxioInterpreter.interpret("ls -R /testRoot", null);
    String expected = "";
    String format = "%-10s%-25s%-15s%-5s\n";
    expected += String.format(format, FormatUtils.getSizeFromBytes(10), CommandUtils.convertMsToDate(files[0].getCreationTimeMs()), "In Memory", "/testRoot/testFileA");
    expected += String.format(format, FormatUtils.getSizeFromBytes(0), CommandUtils.convertMsToDate(files[1].getCreationTimeMs()), "", "/testRoot/testDir");
    expected += String.format(format, FormatUtils.getSizeFromBytes(20), CommandUtils.convertMsToDate(files[2].getCreationTimeMs()), "In Memory", "/testRoot/testDir/testFileB");
    expected += String.format(format, FormatUtils.getSizeFromBytes(30), CommandUtils.convertMsToDate(files[3].getCreationTimeMs()), "Not In Memory", "/testRoot/testFileC");
    expected += "\n";
    Assert.assertEquals(expected, output.message().get(0).getData());
}
Also used : InterpreterResult(org.apache.zeppelin.interpreter.InterpreterResult) URIStatus(alluxio.client.file.URIStatus) AlluxioURI(alluxio.AlluxioURI)

Example 4 with InterpreterResult

use of org.apache.zeppelin.interpreter.InterpreterResult in project zeppelin by apache.

the class AlluxioInterpreterTest method catNotExistTest.

@Test
public void catNotExistTest() throws IOException {
    InterpreterResult output = alluxioInterpreter.interpret("cat /testFile", null);
    Assert.assertEquals(Code.ERROR, output.code());
}
Also used : InterpreterResult(org.apache.zeppelin.interpreter.InterpreterResult)

Example 5 with InterpreterResult

use of org.apache.zeppelin.interpreter.InterpreterResult in project zeppelin by apache.

the class AlluxioInterpreterTest method catDirectoryTest.

@Test
public void catDirectoryTest() throws IOException {
    String expected = "Successfully created directory /testDir\n\n" + "Path /testDir must be a file\n";
    InterpreterResult output = alluxioInterpreter.interpret("mkdir /testDir" + "\ncat /testDir", null);
    Assert.assertEquals(Code.ERROR, output.code());
    Assert.assertEquals(expected, output.message().get(0).getData());
}
Also used : InterpreterResult(org.apache.zeppelin.interpreter.InterpreterResult)

Aggregations

InterpreterResult (org.apache.zeppelin.interpreter.InterpreterResult)153 Test (org.junit.Test)63 Properties (java.util.Properties)17 File (java.io.File)10 IOException (java.io.IOException)9 AlluxioURI (alluxio.AlluxioURI)8 InterpreterContext (org.apache.zeppelin.interpreter.InterpreterContext)7 Theory (org.junit.experimental.theories.Theory)7 FileWriter (java.io.FileWriter)6 PrintStream (java.io.PrintStream)5 InterpreterException (org.apache.zeppelin.interpreter.InterpreterException)5 Code (org.apache.zeppelin.interpreter.InterpreterResult.Code)5 ActionResponse (org.apache.zeppelin.elasticsearch.action.ActionResponse)4 FileInStream (alluxio.client.file.FileInStream)3 JsonObject (com.google.gson.JsonObject)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)3 SQLException (java.sql.SQLException)3 HashMap (java.util.HashMap)3 LinkedList (java.util.LinkedList)3