Search in sources :

Example 26 with Message

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

the class OutputWidgetTest method shouldSendCommMsgWhenAppendStderr.

@Test
public void shouldSendCommMsgWhenAppendStderr() throws Exception {
    // given
    Output output = new Output();
    groovyKernel.clearPublishedMessages();
    // when
    output.appendStderr("Error 1");
    // then
    Message streamMessage = EvaluatorResultTestWatcher.getStreamMessage(groovyKernel).get();
    assertThat(streamMessage.getContent().get(OUTPUT_TYPE)).isEqualTo(Output.STREAM.toString());
    assertThat(streamMessage.getContent().get(Output.NAME)).isEqualTo(Output.STDERR);
    assertThat(streamMessage.getContent().get(Output.TEXT)).isEqualTo("Error 1\n");
}
Also used : Message(com.twosigma.beakerx.message.Message) Test(org.junit.Test) KernelTest(com.twosigma.beakerx.KernelTest)

Example 27 with Message

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

the class OutputWidgetTest method shouldSendCommMsgWhenAppendStdout.

@Test
public void shouldSendCommMsgWhenAppendStdout() throws Exception {
    // given
    Output output = new Output();
    groovyKernel.clearPublishedMessages();
    // when
    output.appendStdout("Hello 1");
    // then
    Message streamMessage = EvaluatorResultTestWatcher.getStreamMessage(groovyKernel).get();
    assertThat(streamMessage.getContent().get(OUTPUT_TYPE)).isEqualTo(Output.STREAM.toString());
    assertThat(streamMessage.getContent().get(Output.NAME)).isEqualTo(Output.STDOUT);
    assertThat(streamMessage.getContent().get(Output.TEXT)).isEqualTo("Hello 1\n");
}
Also used : Message(com.twosigma.beakerx.message.Message) Test(org.junit.Test) KernelTest(com.twosigma.beakerx.KernelTest)

Example 28 with Message

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

the class TabTest method verifyChildren.

private void verifyChildren(List<Widget> children) {
    Message message = kernel.getPublishedMessages().get(1);
    Map data = getState(message);
    Object[] objects = (Object[]) data.get(Tab.CHILDREN);
    assertThat(objects[0]).isEqualTo(Tab.IPY_MODEL + children.get(0).getComm().getCommId());
    assertThat(objects[1]).isEqualTo(Tab.IPY_MODEL + children.get(1).getComm().getCommId());
}
Also used : Message(com.twosigma.beakerx.message.Message) Map(java.util.Map)

Example 29 with Message

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

the class TextTest method verifyTextField.

public static void verifyTextField(List<Message> messages, String modelNameValue, String modelModuleValue, String viewNameValue, String viewModuleValue) {
    Message widget = SearchMessages.getListWidgetsByViewName(messages, viewNameValue).get(0);
    Message layout = SearchMessages.getLayoutForWidget(messages, widget);
    verifyTypeMsg(widget, COMM_OPEN);
    Map data = getState(widget);
    assertThat(data.get(LAYOUT)).isEqualTo(IPY_MODEL + layout.getContent().get(Comm.COMM_ID));
    assertThat(data.get(MODEL_NAME)).isEqualTo(modelNameValue);
    assertThat(data.get(MODEL_MODULE)).isEqualTo(modelModuleValue);
    assertThat(data.get(VIEW_NAME)).isEqualTo(viewNameValue);
    assertThat(data.get(VIEW_MODULE)).isEqualTo(viewModuleValue);
}
Also used : Message(com.twosigma.beakerx.message.Message) Map(java.util.Map)

Example 30 with Message

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

the class ClojureCommOpenHandlerTest method handleMessage_shouldSendShellSocketMessage.

@Test
public void handleMessage_shouldSendShellSocketMessage() throws Exception {
    // given
    Message message = JupyterHandlerTest.initOpenMessage();
    // when
    commOpenHandler.handle(message);
    // then
    Assertions.assertThat(kernel.getSentMessages()).isNotEmpty();
}
Also used : Message(com.twosigma.beakerx.message.Message) JupyterHandlerTest(com.twosigma.beakerx.jupyter.handler.JupyterHandlerTest) Test(org.junit.Test)

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