Main { public static void main(String[] args) { NodeConfig config = NodeConfig.builder() .shortName(true) .build(); Node node = Nodes.singleNode("java@localhost", config); Mailbox mailbox = node.mailbox() .name("my_process") .build(); ErlangTerm payload = mailbox.receive().getBody(); ErlangPid from = payload.get(0) .filter(ErlangTerm::isPid) .map(ErlangTerm::asPid) .orElseThrow(() -> new RuntimeException("Expected first element is PID")); String text = payload.get(1) .filter(ErlangTerm::isTextual) .map(ErlangTerm::asText) .orElseThrow(() -> new RuntimeException("Expected second element is string")); System.out.format("from %s message: %s\n", from, text); mailbox.send(from, string("hello world")); node.close(); }  static void main(String[] args);  }
@Test public void test () throws Exception { ExecutorService executorService = Executors.newSingleThreadExecutor(); executorService.execute(() -> Main.main(null)); SECONDS.sleep(2); try (Node node = Nodes.singleNode("test@localhost", true)) { Mailbox mailbox = node.mailbox() .build(); mailbox.send("java@localhost", "my_process", tuple(mailbox.getPid(), atom("popa"))); ErlangTerm payload = mailbox.receive(20, SECONDS).getBody(); assertThat(payload.asText()).isEqualTo("hello world"); } }