Search in sources :

Example 76 with Message

use of com.twosigma.beakerx.message.Message in project beakerx by twosigma.

the class KernelExecutionTest method shouldImportDemoClassWithWildcardByMagicCommand.

@Test
public void shouldImportDemoClassWithWildcardByMagicCommand() throws Exception {
    // given
    addDemoJar();
    String path = pathToDemoClassFromAddedDemoJar();
    String allCode = IMPORT + " " + path.substring(0, path.lastIndexOf(".")) + ".*";
    // when
    Code code = CodeFactory.create(allCode, new Message(), getKernel());
    code.execute(kernel, 1);
    // then
    verifyImportedDemoClassByMagicCommand();
}
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 77 with Message

use of com.twosigma.beakerx.message.Message in project beakerx by twosigma.

the class KernelExecutionTest method verifyAddedDemoJar.

private void verifyAddedDemoJar() throws InterruptedException {
    String code = codeForVerifyingAddedDemoJar();
    Message message = getExecuteRequestMessage(code);
    // when
    getKernelSocketsService().handleMsg(message);
    // then
    Optional<Message> idleMessage = waitForIdleMessage(getKernelSocketsService().getKernelSockets());
    assertThat(idleMessage).isPresent();
    Optional<Message> result = waitForResult(getKernelSocketsService().getKernelSockets());
    checkResultForErrors(result, code);
    verifyResultOfAddedJar(result.get());
}
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)

Example 78 with Message

use of com.twosigma.beakerx.message.Message in project beakerx by twosigma.

the class KernelExecutionTest method verifyLoadedMagicCommand.

private void verifyLoadedMagicCommand() throws InterruptedException {
    String allCode = "%showEnvs";
    Code code = CodeFactory.create(allCode, new Message(), getKernel());
    code.execute(getKernel(), 3);
    List<Message> std = waitForStdouts(getKernelSocketsService().getKernelSockets());
    String text = (String) std.get(2).getContent().get("text");
    assertThat(text).contains("PATH");
}
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 79 with Message

use of com.twosigma.beakerx.message.Message 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 80 with Message

use of com.twosigma.beakerx.message.Message 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)

Aggregations

Message (com.twosigma.beakerx.message.Message)270 Test (org.junit.Test)170 KernelTest (com.twosigma.beakerx.KernelTest)121 EvaluatorResultTestWatcher.waitForIdleMessage (com.twosigma.beakerx.evaluator.EvaluatorResultTestWatcher.waitForIdleMessage)64 EvaluatorTest (com.twosigma.beakerx.evaluator.EvaluatorTest)57 Code (com.twosigma.beakerx.kernel.Code)55 Serializable (java.io.Serializable)36 MessageFactoryTest.getExecuteRequestMessage (com.twosigma.beakerx.MessageFactoryTest.getExecuteRequestMessage)35 EvaluatorResultTestWatcher.waitForErrorMessage (com.twosigma.beakerx.evaluator.EvaluatorResultTestWatcher.waitForErrorMessage)28 MessageTest (com.twosigma.beakerx.message.MessageTest)27 Map (java.util.Map)26 HashMap (java.util.HashMap)24 Header (com.twosigma.beakerx.message.Header)23 MessageAssertions.verifyExecuteReplyMessage (com.twosigma.MessageAssertions.verifyExecuteReplyMessage)19 EvaluatorResultTestWatcher.waitForSentMessage (com.twosigma.beakerx.evaluator.EvaluatorResultTestWatcher.waitForSentMessage)19 PlainCode (com.twosigma.beakerx.kernel.PlainCode)14 KernelExecutionTest (com.twosigma.beakerx.KernelExecutionTest)13 EvaluatorResultTestWatcher.waitForUpdateMessage (com.twosigma.beakerx.evaluator.EvaluatorResultTestWatcher.waitForUpdateMessage)13 LinkedHashMap (java.util.LinkedHashMap)12 SimpleEvaluationObject (com.twosigma.beakerx.jvm.object.SimpleEvaluationObject)11