Search in sources :

Example 21 with Code

use of com.twosigma.beakerx.kernel.Code in project beakerx by twosigma.

the class KernelExecutionTest method addJarWithCustomMagicCommand.

private void addJarWithCustomMagicCommand() throws InterruptedException {
    String allCode = CLASSPATH_ADD_JAR + " " + LOAD_MAGIC_DEMO_JAR;
    Code code = CodeFactory.create(allCode, new Message(), getKernel());
    code.execute(getKernel(), 1);
    List<Message> std = waitForStdouts(getKernelSocketsService().getKernelSockets());
    String text = (String) std.get(0).getContent().get("text");
    assertThat(text).contains("Added jar: [loadMagicJarDemo.jar]");
}
Also used : MessageAssertions.verifyExecuteReplyMessage(com.twosigma.MessageAssertions.verifyExecuteReplyMessage) EvaluatorResultTestWatcher.waitForIdleMessage(com.twosigma.beakerx.evaluator.EvaluatorResultTestWatcher.waitForIdleMessage) Message(com.twosigma.beakerx.message.Message) MessageFactoryTest.getExecuteRequestMessage(com.twosigma.beakerx.MessageFactoryTest.getExecuteRequestMessage) EvaluatorResultTestWatcher.waitForErrorMessage(com.twosigma.beakerx.evaluator.EvaluatorResultTestWatcher.waitForErrorMessage) EvaluatorResultTestWatcher.waitForSentMessage(com.twosigma.beakerx.evaluator.EvaluatorResultTestWatcher.waitForSentMessage) Code(com.twosigma.beakerx.kernel.Code)

Example 22 with Code

use of com.twosigma.beakerx.kernel.Code in project beakerx by twosigma.

the class KernelExecutionTest method loadMagicCommandByClass.

private void loadMagicCommandByClass() throws InterruptedException {
    String allCode = LOAD_MAGIC + "   com.twosigma.beakerx.custom.magic.command.ShowEnvsCustomMagicCommand";
    Code code = CodeFactory.create(allCode, new Message(), getKernel());
    code.execute(getKernel(), 2);
    List<Message> std = waitForStdouts(getKernelSocketsService().getKernelSockets());
    String text = (String) std.get(1).getContent().get("text");
    assertThat(text).contains("Magic command %showEnvs was successfully added.");
}
Also used : MessageAssertions.verifyExecuteReplyMessage(com.twosigma.MessageAssertions.verifyExecuteReplyMessage) EvaluatorResultTestWatcher.waitForIdleMessage(com.twosigma.beakerx.evaluator.EvaluatorResultTestWatcher.waitForIdleMessage) Message(com.twosigma.beakerx.message.Message) MessageFactoryTest.getExecuteRequestMessage(com.twosigma.beakerx.MessageFactoryTest.getExecuteRequestMessage) EvaluatorResultTestWatcher.waitForErrorMessage(com.twosigma.beakerx.evaluator.EvaluatorResultTestWatcher.waitForErrorMessage) EvaluatorResultTestWatcher.waitForSentMessage(com.twosigma.beakerx.evaluator.EvaluatorResultTestWatcher.waitForSentMessage) Code(com.twosigma.beakerx.kernel.Code)

Example 23 with Code

use of com.twosigma.beakerx.kernel.Code in project beakerx by twosigma.

the class KernelExecutionTest method shouldUnimportDemoClassByMagicCommand.

@Test
public void shouldUnimportDemoClassByMagicCommand() throws Exception {
    // given
    addDemoJar();
    String path = pathToDemoClassFromAddedDemoJar();
    Code code = CodeFactory.create(IMPORT + " " + path, new Message(), getKernel());
    code.execute(kernel, 1);
    // when
    Code code2 = CodeFactory.create(UNIMPORT + " " + path, new Message(), getKernel());
    code2.execute(kernel, 2);
    // then
    // assertThat(status).isEqualTo(MagicCommandOutcomeItem.Status.OK);
    verifyUnImportedDemoClassByMagicCommand();
}
Also used : MessageAssertions.verifyExecuteReplyMessage(com.twosigma.MessageAssertions.verifyExecuteReplyMessage) EvaluatorResultTestWatcher.waitForIdleMessage(com.twosigma.beakerx.evaluator.EvaluatorResultTestWatcher.waitForIdleMessage) Message(com.twosigma.beakerx.message.Message) MessageFactoryTest.getExecuteRequestMessage(com.twosigma.beakerx.MessageFactoryTest.getExecuteRequestMessage) EvaluatorResultTestWatcher.waitForErrorMessage(com.twosigma.beakerx.evaluator.EvaluatorResultTestWatcher.waitForErrorMessage) EvaluatorResultTestWatcher.waitForSentMessage(com.twosigma.beakerx.evaluator.EvaluatorResultTestWatcher.waitForSentMessage) Code(com.twosigma.beakerx.kernel.Code) Test(org.junit.Test)

Example 24 with Code

use of com.twosigma.beakerx.kernel.Code in project beakerx by twosigma.

the class GroovyKernelTest method shouldNotImportStaticNotStaticPathByMagicCommand.

@Test
public void shouldNotImportStaticNotStaticPathByMagicCommand() throws Exception {
    // given
    addDemoJar();
    String path = "garbage";
    // when
    Code code = CodeFactory.create(ADD_STATIC_IMPORT + " " + path, new Message(), getKernel());
    code.execute(kernel, 1);
    // then
    verifyNotImportedStaticMagicCommand();
}
Also used : MessageFactoryTest.getExecuteRequestMessage(com.twosigma.beakerx.MessageFactoryTest.getExecuteRequestMessage) EvaluatorResultTestWatcher.waitForIdleMessage(com.twosigma.beakerx.evaluator.EvaluatorResultTestWatcher.waitForIdleMessage) Message(com.twosigma.beakerx.message.Message) EvaluatorResultTestWatcher.waitForUpdateMessage(com.twosigma.beakerx.evaluator.EvaluatorResultTestWatcher.waitForUpdateMessage) Code(com.twosigma.beakerx.kernel.Code) KernelExecutionTest(com.twosigma.beakerx.KernelExecutionTest) Test(org.junit.Test)

Example 25 with Code

use of com.twosigma.beakerx.kernel.Code in project beakerx by twosigma.

the class GroovyKernelTest method shouldImportStaticMethodDemoClassByMagicCommand.

@Test
public void shouldImportStaticMethodDemoClassByMagicCommand() throws Exception {
    // given
    addDemoJar();
    String path = pathToDemoClassFromAddedDemoJar() + ".staticTest";
    // when
    Code code = CodeFactory.create(ADD_STATIC_IMPORT + " " + path, new Message(), getKernel());
    code.execute(kernel, 1);
    // then
    verifyStaticImportedDemoClassByMagicCommand(pathToDemoClassFromAddedDemoJar() + ".staticTest()");
}
Also used : MessageFactoryTest.getExecuteRequestMessage(com.twosigma.beakerx.MessageFactoryTest.getExecuteRequestMessage) EvaluatorResultTestWatcher.waitForIdleMessage(com.twosigma.beakerx.evaluator.EvaluatorResultTestWatcher.waitForIdleMessage) Message(com.twosigma.beakerx.message.Message) EvaluatorResultTestWatcher.waitForUpdateMessage(com.twosigma.beakerx.evaluator.EvaluatorResultTestWatcher.waitForUpdateMessage) Code(com.twosigma.beakerx.kernel.Code) KernelExecutionTest(com.twosigma.beakerx.KernelExecutionTest) Test(org.junit.Test)

Aggregations

Code (com.twosigma.beakerx.kernel.Code)55 Message (com.twosigma.beakerx.message.Message)54 Test (org.junit.Test)47 KernelTest (com.twosigma.beakerx.KernelTest)33 EvaluatorTest (com.twosigma.beakerx.evaluator.EvaluatorTest)29 MessageFactoryTest.getExecuteRequestMessage (com.twosigma.beakerx.MessageFactoryTest.getExecuteRequestMessage)16 EvaluatorResultTestWatcher.waitForIdleMessage (com.twosigma.beakerx.evaluator.EvaluatorResultTestWatcher.waitForIdleMessage)16 PlainCode (com.twosigma.beakerx.kernel.PlainCode)14 MessageAssertions.verifyExecuteReplyMessage (com.twosigma.MessageAssertions.verifyExecuteReplyMessage)9 EvaluatorResultTestWatcher.waitForErrorMessage (com.twosigma.beakerx.evaluator.EvaluatorResultTestWatcher.waitForErrorMessage)9 EvaluatorResultTestWatcher.waitForSentMessage (com.twosigma.beakerx.evaluator.EvaluatorResultTestWatcher.waitForSentMessage)9 KernelExecutionTest (com.twosigma.beakerx.KernelExecutionTest)7 EvaluatorResultTestWatcher.waitForUpdateMessage (com.twosigma.beakerx.evaluator.EvaluatorResultTestWatcher.waitForUpdateMessage)7 ClasspathAddMvnMagicCommand (com.twosigma.beakerx.kernel.magic.command.functionality.ClasspathAddMvnMagicCommand)4 ClasspathResetMagicCommand (com.twosigma.beakerx.kernel.magic.command.functionality.ClasspathResetMagicCommand)4 ImportPath (com.twosigma.beakerx.kernel.ImportPath)3 PathToJar (com.twosigma.beakerx.kernel.PathToJar)2 MagicCommand (com.twosigma.beakerx.kernel.magic.command.MagicCommand)2 ClassPathAddMvnCellMagicCommand (com.twosigma.beakerx.kernel.magic.command.functionality.ClassPathAddMvnCellMagicCommand)2 EvaluatorResultTestWatcher (com.twosigma.beakerx.evaluator.EvaluatorResultTestWatcher)1