Package org.mokai.connector

Examples of org.mokai.connector.RoundRobinProcessor


  @Test
  public void shouldProcessInRoundRobinFashion() throws Exception {
    Processor p1 = mock(Processor.class);
    Processor p2 = mock(Processor.class);

    RoundRobinProcessor processor = new RoundRobinProcessor()
      .addProcessor(p1)
      .addProcessor(p2);

    processor.process(new Message());
    verify(p1).process(any(Message.class));
    verify(p2, never()).process(any(Message.class));

    processor.process(new Message());
    verify(p1).process(any(Message.class));
    verify(p2).process(any(Message.class));
  }
View Full Code Here


    when(p2.supports(any(Message.class))).thenReturn(true);

    Processor p3 = mock(Processor.class);
    when(p3.supports(any(Message.class))).thenReturn(true);

    RoundRobinProcessor processor = new RoundRobinProcessor()
      .addProcessor(p1)
      .addProcessor(p2)
      .addProcessor(p3);

    processor.process(new Message());
    verify(p2).process(any(Message.class));
    verify(p3, never()).process(any(Message.class));

    processor.process(new Message());
    verify(p2).process(any(Message.class));
    verify(p3).process(any(Message.class));
  }
View Full Code Here

    when(p1.supports(any(Message.class))).thenReturn(true);

    Processor p2 = mock(Processor.class);
    when(p2.supports(any(Message.class))).thenReturn(true);

    RoundRobinProcessor processor = new RoundRobinProcessor()
      .addProcessor(p1)
      .addProcessor(p2);

    Assert.assertTrue(processor.supports(new Message()));
  }
View Full Code Here

    when(p1.supports(any(Message.class))).thenReturn(true);

    Processor p2 = mock(Processor.class);
    when(p2.supports(any(Message.class))).thenReturn(false);

    RoundRobinProcessor processor = new RoundRobinProcessor()
      .addProcessor(p1)
      .addProcessor(p2);

    Assert.assertFalse(processor.supports(new Message()));
  }
View Full Code Here

    Assert.assertFalse(processor.supports(new Message()));
  }

  @Test
  public void shouldNotSupportMessageIfNoProcessors() throws Exception {
    RoundRobinProcessor processor = new RoundRobinProcessor();
    Assert.assertFalse(processor.supports(new Message()));
  }
View Full Code Here

  @Test
  public void shouldConfigureAndDestroyProcessors() throws Exception {
    Processor p1 = mock(Processor.class, withSettings().extraInterfaces(Configurable.class));
    Processor p2 = mock(Processor.class);

    RoundRobinProcessor processor = new RoundRobinProcessor()
      .addProcessor(p1)
      .addProcessor(p2);

    processor.configure();

    verify((Configurable) p1).configure();

    processor.destroy();

    verify((Configurable) p1).destroy();
  }
View Full Code Here

  @Test
  public void shouldStartAndStopProcessors() throws Exception {
    Processor p1 = mock(Processor.class, withSettings().extraInterfaces(Serviceable.class));
    Processor p2 = mock(Processor.class);

    RoundRobinProcessor processor = new RoundRobinProcessor()
      .addProcessor(p1)
      .addProcessor(p2);

    processor.doStart();

    verify((Serviceable) p1).doStart();

    processor.doStop();

    verify((Serviceable) p1).doStop();
  }
View Full Code Here

  @Test
  public void statusShouldBeUnknown() throws Exception {
    Processor p1 = mock(Processor.class);
    Processor p2 = mock(Processor.class);

    RoundRobinProcessor processor = new RoundRobinProcessor()
      .addProcessor(p1)
      .addProcessor(p2);

    Assert.assertEquals(processor.getStatus(), Status.UNKNOWN);
  }
View Full Code Here

    Processor p1 = mock(Processor.class, withSettings().extraInterfaces(Monitorable.class));
    when(((Monitorable) p1).getStatus()).thenReturn(Status.OK);

    Processor p2 = mock(Processor.class);

    RoundRobinProcessor processor = new RoundRobinProcessor()
      .addProcessor(p1)
      .addProcessor(p2);

    Assert.assertEquals(processor.getStatus(), Status.OK);
  }
View Full Code Here

    Processor p1 = mock(Processor.class, withSettings().extraInterfaces(Monitorable.class));
    when(((Monitorable) p1).getStatus()).thenReturn(Status.FAILED);

    Processor p2 = mock(Processor.class);

    RoundRobinProcessor processor = new RoundRobinProcessor()
      .addProcessor(p1)
      .addProcessor(p2);

    Assert.assertEquals(processor.getStatus(), Status.FAILED);
  }
View Full Code Here

TOP

Related Classes of org.mokai.connector.RoundRobinProcessor

Copyright © 2018 www.massapicom. 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.