Package org.asmatron.messengine.engines

Examples of org.asmatron.messengine.engines.DefaultMessagingDelegate.start()


  public void shouldListenFooMessage() throws Exception {
    final Semaphore lock = new Semaphore(0);
    final StringBuilder actualBody = new StringBuilder();
    final String expectedBody = "Hello World!";
    DefaultMessagingDelegate engine = new DefaultMessagingDelegate();
    engine.start();
    MessageListener<Message<String>> listener = new MessageListener<Message<String>>() {

      @Override
      public void onMessage(Message<String> message) {
        actualBody.append((String) message.getBody());
View Full Code Here


  @Test(timeout = 1000)
  public void shouldListen1000FooMessages() throws Exception {
    final Semaphore lock = new Semaphore(0);
    final String expectedBody = "HELLO WORLD!";
    DefaultMessagingDelegate engine = new DefaultMessagingDelegate();
    engine.start();
    final AtomicInteger counter = new AtomicInteger();
    final MessageListener<Message<String>> listener = new MessageListener<Message<String>>() {
      @Override
      public void onMessage(Message<String> message) {
        counter.incrementAndGet();
View Full Code Here

  @Test(timeout = 1000)
  public void shouldHaveManyListenersForTheSameMessageType() throws Exception {
    final Semaphore lock = new Semaphore(0);
    DefaultMessagingDelegate engine = new DefaultMessagingDelegate();
    engine.start();
    final AtomicInteger counter = new AtomicInteger();
    final MessageListener<Message<String>> listenerA = new MessageListener<Message<String>>() {
      @Override
      public void onMessage(Message<String> message) {
        counter.incrementAndGet();
View Full Code Here

  }

  @Test
  public void shouldStopListeningToMessage() throws Exception {
    DefaultMessagingDelegate engine = new DefaultMessagingDelegate();
    engine.start();
    final AtomicInteger counter = new AtomicInteger();
    final MessageListener<Message<String>> listener = new MessageListener<Message<String>>() {
      @Override
      public void onMessage(Message<String> message) {
        counter.incrementAndGet();
View Full Code Here

  }

  @Test
  public void shouldRequestAndBlockUntilResponse() throws Exception {
    final DefaultMessagingDelegate engine = new DefaultMessagingDelegate();
    engine.start();

    final int timeout = 5000;
    final int responseDelay = 1000;
    String responseType = "responseType";
    final Message<?> expectedResponse = new TestMessage<String>(responseType, "responseBody");
View Full Code Here

  }

  @Test
  public void shouldRequestAndBlockUntilTimeout() throws Exception {
    final DefaultMessagingDelegate engine = new DefaultMessagingDelegate();
    engine.start();
    final int timeout = 300;
    long startTime = System.currentTimeMillis();

    Future<Message<?>> future = engine.request(new TestMessage<String>("requestType", "requestBody"), "responseType",
        timeout);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.