use of org.structr.messaging.engine.entities.MessageClient in project structr by structr.
the class SimpleMessagingTest method test01.
@Test
public void test01() {
try (final Tx tx = app.tx()) {
MessageClient client1 = app.create(MessageClient.class, "client1");
MessageSubscriber sub = app.create(MessageSubscriber.class, "sub");
List<MessageSubscriber> subList = new ArrayList<>();
subList.add(sub);
client1.setProperty(StructrApp.key(MessageClient.class, "subscribers"), subList);
sub.setProperty(StructrApp.key(MessageSubscriber.class, "topic"), "test");
sub.setProperty(StructrApp.key(MessageSubscriber.class, "callback"), "set(this, 'name', retrieve('message'))");
Scripting.replaceVariables(new ActionContext(securityContext, null), client1, "${{Structr.log('Sending message'); Structr.get('this').sendMessage('test','testmessage');}}");
assertEquals("testmessage", sub.getName());
tx.success();
} catch (FrameworkException ex) {
fail("Exception during test: " + ex.getMessage());
}
}
Aggregations