Search in sources :

Example 61 with Message

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

the class MagicCommandResultOrderTest method classpathShouldBeLast.

@Test
public void classpathShouldBeLast() {
    // given
    String allCode = "" + "%classpath add jar " + DOC_CONTENTS_DEMO_RESOURCES_BEAKERX_TEST_LIBRARY_JAR + "\n" + "%classpath";
    Code code = CodeFactory.create(allCode, new Message(), kernel);
    // when
    code.execute(kernel, 1);
    // then
    List<Message> std = EvaluatorResultTestWatcher.getStdouts(kernel.getPublishedMessages());
    String text = (String) std.get(0).getContent().get("text");
    assertThat(text).contains(DEMO_JAR);
}
Also used : Message(com.twosigma.beakerx.message.Message) PlainCode(com.twosigma.beakerx.kernel.PlainCode) Code(com.twosigma.beakerx.kernel.Code) EvaluatorTest(com.twosigma.beakerx.evaluator.EvaluatorTest) Test(org.junit.Test) KernelTest(com.twosigma.beakerx.KernelTest)

Example 62 with Message

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

the class MagicCommandResultOrderTest method codeResultShouldBeLast.

@Test
public void codeResultShouldBeLast() {
    // given
    String allCode = "" + "%classpath add jar " + DOC_CONTENTS_DEMO_RESOURCES_BEAKERX_TEST_LIBRARY_JAR + "\n" + "%classpath\n" + "code code code";
    // when
    Code code = CodeFactory.create(allCode, new Message(), kernel);
    code.execute(kernel, 1);
    // then
    PlainCode actual = (PlainCode) code.getCodeFrames().get(2);
    assertThat(actual.getPlainCode()).isEqualTo("code code code");
}
Also used : Message(com.twosigma.beakerx.message.Message) PlainCode(com.twosigma.beakerx.kernel.PlainCode) Code(com.twosigma.beakerx.kernel.Code) PlainCode(com.twosigma.beakerx.kernel.PlainCode) EvaluatorTest(com.twosigma.beakerx.evaluator.EvaluatorTest) Test(org.junit.Test) KernelTest(com.twosigma.beakerx.KernelTest)

Example 63 with Message

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

the class TimeItLineModeMagicCommandTest method timeitLineMode.

@Test
public void timeitLineMode() {
    // given
    String allCode = "%timeit -r3 -n1 sleep(1)";
    Code code = CodeFactory.create(allCode, new Message(), kernel);
    // when
    code.execute(kernel, 1);
    // then
    List<Message> std = EvaluatorResultTestWatcher.getStdouts(kernel.getPublishedMessages());
    String text = (String) std.get(0).getContent().get("text");
    assertThat(text).contains("loop");
}
Also used : Message(com.twosigma.beakerx.message.Message) Code(com.twosigma.beakerx.kernel.Code) EvaluatorTest(com.twosigma.beakerx.evaluator.EvaluatorTest) Test(org.junit.Test) KernelTest(com.twosigma.beakerx.KernelTest)

Example 64 with Message

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

the class ClasspathMagicCommandTest method handleClasspathAddJarWildcardMagicCommand.

@Test
public void handleClasspathAddJarWildcardMagicCommand() {
    // given
    String allCode = "" + CLASSPATH_ADD_JAR + " " + SRC_TEST_RESOURCES + "dirWithTwoJars/*";
    Code code = CodeFactory.create(allCode, new Message(), kernel);
    // when
    code.execute(kernel, 1);
    // then
    List<Message> std = EvaluatorResultTestWatcher.getStdouts(kernel.getPublishedMessages());
    String text = (String) std.get(0).getContent().get("text");
    assertThat(text).contains(FOO_JAR, "bar.jar");
    assertThat(evaluator.getResetEnvironmentCounter()).isEqualTo(0);
}
Also used : Message(com.twosigma.beakerx.message.Message) PlainCode(com.twosigma.beakerx.kernel.PlainCode) Code(com.twosigma.beakerx.kernel.Code) Test(org.junit.Test) KernelTest(com.twosigma.beakerx.KernelTest) EvaluatorTest(com.twosigma.beakerx.evaluator.EvaluatorTest)

Example 65 with Message

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

the class ClasspathMagicCommandTest method showClasspath.

@Test
public void showClasspath() {
    // given
    kernel.addJarsToClasspath(asList(new PathToJar(CLASSPATH_TO_JAR_PATH)));
    Code code = CodeFactory.create("%classpath", new Message(), kernel);
    // when
    code.execute(kernel, 1);
    // then
    List<Message> std = EvaluatorResultTestWatcher.getStdouts(kernel.getPublishedMessages());
    String text = (String) std.get(0).getContent().get("text");
    assertThat(text).contains(FOO_JAR);
}
Also used : Message(com.twosigma.beakerx.message.Message) PathToJar(com.twosigma.beakerx.kernel.PathToJar) PlainCode(com.twosigma.beakerx.kernel.PlainCode) Code(com.twosigma.beakerx.kernel.Code) Test(org.junit.Test) KernelTest(com.twosigma.beakerx.KernelTest) EvaluatorTest(com.twosigma.beakerx.evaluator.EvaluatorTest)

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