MmiReceiver implements ITypedReceiver { @Override public void receiveObject(final Object object, final Message msg) { final ClassLoader loader = getClass().getClassLoader(); Thread.currentThread().setContextClassLoader(loader); if (LOGGER.isDebugEnabled()) { LOGGER.debug("received '" + object + "'"); } final LifeCycleEvent event; try { event = convertToLifeCycleEvent(object); } catch (SAXException | IOException | TransformerException | ParserConfigurationException e) { LOGGER.error(e.getMessage(), e); return; } final Mmi mmi = new Mmi(); mmi.setLifeCycleEvent(event); final DecoratedMMIEvent docatedEvent = new DecoratedMMIEvent(sourceUrl, mmi); final CallMetadata data = new CallMetadata(); data.setProtocolName("umundo"); synchronized (listeners) { for (MMIEventListener listener : listeners) { listener.receivedEvent(docatedEvent, data); } } } MmiReceiver(final String source); @Override void receiveObject(final Object object, final Message msg); void addMMIEventListener(final MMIEventListener listener); void removeMMIEventListener(final MMIEventListener listener);  }
@Test(timeout = 5000) public void testReceiveObject() throws Exception { final TypedPublisher publisher = new TypedPublisher("test"); publishingNode.addPublisher(publisher); publisher.waitForSubscribers(1); final String requestId = "requestId1"; final String source = "source1"; final String target = "target1"; final String context = "context1"; final String content = "content1"; final String contentUrl = "contentUrl1"; final LifeCycleEvents.PrepareRequest prepareRequest = LifeCycleEvents.PrepareRequest .newBuilder().setContent(content).setContentURL(contentUrl) .build(); final LifeCycleEvents.LifeCycleRequest lifeCycleRequest = LifeCycleEvents.LifeCycleRequest .newBuilder() .setContext(context) .setExtension(LifeCycleEvents.PrepareRequest.request, prepareRequest).build(); final LifeCycleEvents.LifeCycleEvent event1 = LifeCycleEvents.LifeCycleEvent .newBuilder() .setType(LifeCycleEventType.PREPARE_REQUEST) .setRequestID(requestId) .setSource(source) .setTarget(target) .setExtension(LifeCycleEvents.LifeCycleRequest.request, lifeCycleRequest).build(); publisher.sendObject("LifeCycleEvent", event1); synchronized (lock) { lock.wait(); } Assert.assertNotNull(receivedEvent); Assert.assertTrue(receivedEvent instanceof PrepareRequest); }