Package org.mokai

Examples of org.mokai.ConnectorService


    processorService.addPreProcessingAction(null);
  }

  @Test(expectedExceptions=IllegalArgumentException.class)
  public void shouldFailWithNullPostProcessingAction() throws Exception {
    ConnectorService processorService = new MockConnectorService("test", new MockProcessor(), resourceRegistry);
    processorService.addPostProcessingAction(null);
  }
View Full Code Here


    processorService.addPostProcessingAction(null);
  }

  @Test(expectedExceptions=IllegalArgumentException.class)
  public void shouldFailWithNullPostReceivingAction() throws Exception {
    ConnectorService processorService = new MockConnectorService("test", new MockProcessor(), resourceRegistry);
    processorService.addPostReceivingAction(null);
  }
View Full Code Here

  @Test
  public void testProcessorExceptionAndRecovery() throws Exception {
    MockEndpoint outboundEndpoint = getProcessedMessagesEndpoint(1);
    MockEndpoint failedEndpoint = getFailedMessagesEndpoint(0);

    ConnectorService processorService = new MockConnectorService("test", new Processor() {

      private int times = 0;

      @Override
      public void process(Message message) {
        if (times == 0) {
          times++;
          throw new NullPointerException();
        }
      }

      @Override
      public boolean supports(Message message) {
        return true;
      }

    }, resourceRegistry);
    processorService.start();

    simulateMessage(new Message(), "activemq:mokai-test");

    failedEndpoint.assertIsSatisfied(DEFAULT_TIMEOUT);
    outboundEndpoint.assertIsSatisfied(DEFAULT_TIMEOUT);
View Full Code Here

    outboundEndpoint.assertIsSatisfied(DEFAULT_TIMEOUT);
  }

  @Test
  public void testAddRemoveAcceptors() throws Exception {
    ConnectorService processorService = new MockConnectorService("test", new MockProcessor(), resourceRegistry);

    Acceptor acceptor1 = Mockito.mock(Acceptor.class);
    Acceptor acceptor2 = Mockito.mock(Acceptor.class);

    // add first acceptor
    processorService.addAcceptor(acceptor1);
    Assert.assertEquals(1, processorService.getAcceptors().size());

    // add second acceptor
    processorService.addAcceptor(acceptor2);
    Assert.assertEquals(2, processorService.getAcceptors().size());

    List<Acceptor> acceptors = processorService.getAcceptors();
    Assert.assertEquals(acceptors.get(0), acceptor1);
    Assert.assertEquals(acceptors.get(1), acceptor2);

    // remove acceptor 1
    processorService.removeAcceptor(acceptor1);

    Assert.assertEquals(1, processorService.getAcceptors().size());
    acceptors = processorService.getAcceptors();
    Assert.assertEquals(acceptors.get(0), acceptor2);
  }
View Full Code Here

    Assert.assertEquals(acceptors.get(0), acceptor2);
  }

  @Test
  public void testAddRemovePreProcessingActions() throws Exception {
    ConnectorService processorService = new MockConnectorService("test", new MockProcessor(), resourceRegistry);

    Action action1 = new MockAction();
    Action action2 = new MockAction();

    // add first action
    processorService.addPreProcessingAction(action1);
    Assert.assertEquals(1, processorService.getPreProcessingActions().size());

    // add second action
    processorService.addPreProcessingAction(action2);
    Assert.assertEquals(2, processorService.getPreProcessingActions().size());

    List<Action> preProcessingActions  = processorService.getPreProcessingActions();
    Assert.assertEquals(preProcessingActions.get(0), action1);
    Assert.assertEquals(preProcessingActions.get(1), action2);

    // remove action 1
    processorService.removePreProcessingAction(action1);

    Assert.assertEquals(1, processorService.getPreProcessingActions().size());
    preProcessingActions  = processorService.getPreProcessingActions();
    Assert.assertEquals(preProcessingActions.get(0), action2);
  }
View Full Code Here

    Assert.assertEquals(preProcessingActions.get(0), action2);
  }

  @Test
  public void testAddRemovePostProcessingActions() throws Exception {
    ConnectorService processorService = new MockConnectorService("test", new MockProcessor(), resourceRegistry);

    Action action1 = new MockAction();
    Action action2 = new MockAction();

    // add first action
    processorService.addPostProcessingAction(action1);
    Assert.assertEquals(1, processorService.getPostProcessingActions().size());

    // add second action
    processorService.addPostProcessingAction(action2);
    Assert.assertEquals(2, processorService.getPostProcessingActions().size());

    List<Action> postProcessingActions  = processorService.getPostProcessingActions();
    Assert.assertEquals(postProcessingActions.get(0), action1);
    Assert.assertEquals(postProcessingActions.get(1), action2);

    // remove action 1
    processorService.removePostProcessingAction(action1);

    Assert.assertEquals(1, processorService.getPostProcessingActions().size());
    postProcessingActions  = processorService.getPostProcessingActions();
    Assert.assertEquals(postProcessingActions.get(0), action2);
  }
View Full Code Here

    Assert.assertEquals(postProcessingActions.get(0), action2);
  }

  @Test
  public void testAddRemovePostReceivingActions() throws Exception {
    ConnectorService processorService = new MockConnectorService("test", new MockProcessor(), resourceRegistry);

    Action action1 = new MockAction();
    Action action2 = new MockAction();

    // add first action
    processorService.addPostReceivingAction(action1);
    Assert.assertEquals(1, processorService.getPostReceivingActions().size());

    // add second action
    processorService.addPostReceivingAction(action2);
    Assert.assertEquals(2, processorService.getPostReceivingActions().size());

    List<Action> postReceivingActions  = processorService.getPostReceivingActions();
    Assert.assertEquals(postReceivingActions.get(0), action1);
    Assert.assertEquals(postReceivingActions.get(1), action2);

    // remove action 1
    processorService.removePostReceivingAction(action1);

    Assert.assertEquals(1, processorService.getPostReceivingActions().size());
    postReceivingActions  = processorService.getPostReceivingActions();
    Assert.assertEquals(postReceivingActions.get(0), action2);
  }
View Full Code Here

    response.contentType("application/json").print(jsonConnections.toString());
  }

  public void show(Request request, Response response) throws JSONException {
    String id = request.getPathVariable("id").asString();
    ConnectorService connectorService = routingEngine.getConnection(id);

    if (connectorService == null) {
      response.notFound();
      return;
    }
View Full Code Here

    response.contentType("application/json").print(jsonConnector.toString());
  }

  public void start(Request request, Response response) throws JSONException {
    String id = request.getPathVariable("id").asString();
    ConnectorService connectorService = routingEngine.getConnection(id);

    if (connectorService == null) {
      response.notFound();
      return;
    }

    connectorService.start();
  }
View Full Code Here

    connectorService.start();
  }

  public void stop(Request request, Response response) throws JSONException {
    String id = request.getPathVariable("id").asString();
    ConnectorService connectorService = routingEngine.getConnection(id);

    if (connectorService == null) {
      response.notFound();
      return;
    }

    connectorService.stop();
  }
View Full Code Here

TOP

Related Classes of org.mokai.ConnectorService

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.