use of org.jetbrains.plugins.ipnb.protocol.IpnbConnection in project intellij-community by JetBrains.
the class WebSocketConnectionTest method testBasicWebSocket.
public void testBasicWebSocket() throws IOException, URISyntaxException, InterruptedException {
final Ref<Boolean> evaluated = Ref.create(false);
final IpnbConnection connection = new IpnbConnection(getTestServerURI(), new IpnbConnectionListenerBase() {
private String myMessageId;
@Override
public void onOpen(@NotNull IpnbConnection connection) {
myMessageId = connection.execute("2 + 2");
}
@Override
public void onOutput(@NotNull IpnbConnection connection, @NotNull String parentMessageId) {
if (myMessageId.equals(parentMessageId)) {
final IpnbOutputCell output = connection.getOutput();
assertEquals(output.getClass(), IpnbOutOutputCell.class);
final List<String> text = output.getText();
assertNotNull(text);
assertEquals("4", text.get(0));
evaluated.set(true);
connection.shutdown();
}
}
}, null, DefaultProjectFactory.getInstance().getDefaultProject(), "");
connection.close();
assertTrue(evaluated.get());
}
Aggregations