Package org.mokai

Examples of org.mokai.Processor


    try {
      routingEngine.setMessageStore(messageStore);
      routingEngine.start();

      // create the processors
      Processor connectionProcessor = mock(Processor.class);
      Processor applicationProcessor = mock(Processor.class);

      when(connectionProcessor.supports(any(Message.class))).thenReturn(true);
      when(applicationProcessor.supports(any(Message.class))).thenReturn(true);

      ConnectorService connectionService = routingEngine.addConnection("1", connectionProcessor);
      ConnectorService applicationService = routingEngine.addApplication("1", applicationProcessor);

      Acceptor acceptor = new Acceptor() {
View Full Code Here


public class RoundRobinProcessorTest {

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

    RoundRobinProcessor processor = new RoundRobinProcessor()
      .addProcessor(p1)
      .addProcessor(p2);
View Full Code Here

    verify(p2).process(any(Message.class));
  }

  @Test
  public void shouldProcessThroughNextProcessorIfFirstFails() throws Exception {
    Processor p1 = mock(Processor.class);
    when(p1.supports(any(Message.class))).thenReturn(true);
    doThrow(new Exception()).when(p1).process(any(Message.class));

    Processor p2 = mock(Processor.class);
    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);
View Full Code Here

    verify(p3).process(any(Message.class));
  }

  @Test
  public void shouldSupportMessage() throws Exception {
    Processor p1 = mock(Processor.class);
    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);
View Full Code Here

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

  @Test
  public void shouldNotSupportMessage() throws Exception {
    Processor p1 = mock(Processor.class);
    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);
View Full Code Here

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

  @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);
View Full Code Here

    verify((Configurable) p1).destroy();
  }

  @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);
View Full Code Here

    verify((Serviceable) p1).doStop();
  }

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

    RoundRobinProcessor processor = new RoundRobinProcessor()
      .addProcessor(p1)
      .addProcessor(p2);
View Full Code Here

    Assert.assertEquals(processor.getStatus(), Status.UNKNOWN);
  }

  @Test
  public void statusShouldBeOK() throws Exception {
    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);
View Full Code Here

    Assert.assertEquals(processor.getStatus(), Status.OK);
  }

  @Test
  public void statusShouldBeFailed() throws Exception {
    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);
View Full Code Here

TOP

Related Classes of org.mokai.Processor

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.