Package org.mokai

Examples of org.mokai.ConnectorService


  @Test
  public void testSaveOneConnectorNoAdditionals() throws Exception {
    String path = "src/test/resources/temp-connectors/connectors.xml";

    ConnectorService processorService = mockConnectorService("test", 1000,
        new MockConnector(), new ArrayList<Acceptor>(), new ArrayList<Action>(),
        new ArrayList<Action>(), new ArrayList<Action>());

    ConfigDelegator delegator = mock(ConfigDelegator.class);
    when(delegator.getConnectors())
View Full Code Here


    List<Action> actions = new ArrayList<Action>();
    actions.add(new MockAction());
    actions.add(new MockAction());

    ConnectorService connectorService = mockConnectorService("test", 1000,
        new MockConnector(), acceptors, actions, actions, actions);

    ConfigDelegator delegator = mock(ConfigDelegator.class);
    when(delegator.getConnectors())
      .thenReturn(Collections.singletonList(connectorService));
View Full Code Here

    acceptors.add(new MockConfigurableAcceptor("test1", 1));

    List<Action> actions = new ArrayList<Action>();
    actions.add(new MockConfigurableAction("test1", 1));

    ConnectorService connectorService = mockConnectorService("test", 1000, new MockConfigurableConnector("test", 0),
        acceptors, actions, actions, actions);

    ConfigDelegator delegator = mock(ConfigDelegator.class);
    when(delegator.getConnectors())
      .thenReturn(Collections.singletonList(connectorService));
View Full Code Here

  private ConnectorService mockConnectorService(String id, int priority, Processor processor,
      List<Acceptor> acceptors, List<Action> preProcessingActions,
      List<Action> postProcessingActions, List<Action> postReceivingActions) {

    ConnectorService processorService = mock(ConnectorService.class);

    when(processorService.getId()).thenReturn(id);
    when(processorService.getPriority()).thenReturn(priority);

    when(processorService.getConnector()).thenReturn(processor);

    when(processorService.getAcceptors()).thenReturn(acceptors);

    when(processorService.getPreProcessingActions()).thenReturn(preProcessingActions);

    when(processorService.getPostProcessingActions()).thenReturn(postProcessingActions);

    when(processorService.getPostReceivingActions()).thenReturn(postReceivingActions);

    return processorService;
  }
View Full Code Here

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

  @Test
  public void testAddRemoveConfigurableAcceptor() throws Exception {
    ConnectorService processorService = new MockConnectorService("test", Mockito.mock(Processor.class), resourceRegistry);

    Acceptor configurableAcceptor = Mockito.mock(Acceptor.class,
        Mockito.withSettings().extraInterfaces(Configurable.class));

    processorService.addAcceptor(configurableAcceptor);
    processorService.removeAcceptor(configurableAcceptor);

    Mockito.verify((Configurable) configurableAcceptor).configure();
    Mockito.verify((Configurable) configurableAcceptor).destroy();
  }
View Full Code Here

    Mockito.verify((Configurable) configurableAcceptor).destroy();
  }

  @Test
  public void testAddRemoveConfigurablePreProcessingAction() throws Exception {
    ConnectorService processorService = new MockConnectorService("test", Mockito.mock(Processor.class), resourceRegistry);

    Action configurableAction = Mockito.mock(Action.class,
        Mockito.withSettings().extraInterfaces(Configurable.class));

    processorService.addPreProcessingAction(configurableAction);
    processorService.removePreProcessingAction(configurableAction);

    Mockito.verify((Configurable) configurableAction).configure();
    Mockito.verify((Configurable) configurableAction).destroy();
  }
View Full Code Here

    Mockito.verify((Configurable) configurableAction).destroy();
  }

  @Test
  public void testAddRemoveConfigurablePostProcessingAction() throws Exception {
    ConnectorService processorService = new MockConnectorService("test", Mockito.mock(Processor.class), resourceRegistry);

    Action configurableAction = Mockito.mock(Action.class,
        Mockito.withSettings().extraInterfaces(Configurable.class));

    processorService.addPostProcessingAction(configurableAction);
    processorService.removePostProcessingAction(configurableAction);

    Mockito.verify((Configurable) configurableAction).configure();
    Mockito.verify((Configurable) configurableAction).destroy();
  }
View Full Code Here

    Mockito.verify((Configurable) configurableAction).destroy();
  }

  @Test
  public void testAddRemoveConfigurablePostReceivingAction() throws Exception {
    ConnectorService processorService = new MockConnectorService("test", Mockito.mock(Processor.class), resourceRegistry);

    Action configurableAction = Mockito.mock(Action.class,
        Mockito.withSettings().extraInterfaces(Configurable.class));

    processorService.addPostReceivingAction(configurableAction);
    processorService.removePostReceivingAction(configurableAction);

    Mockito.verify((Configurable) configurableAction).configure();
    Mockito.verify((Configurable) configurableAction).destroy();
  }
View Full Code Here

    MockEndpoint outboundEndpoint = getProcessedMessagesEndpoint(0);
    MockEndpoint failedEndpoint = getFailedMessagesEndpoint(0);

    MockProcessor processor = new MockProcessor();
    ConnectorService processorService = new MockConnectorService("test", processor, resourceRegistry);

    Action action = new StopAction();
    processorService.addPreProcessingAction(action);

    processorService.start();

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

    Thread.sleep(3000);
View Full Code Here

  public void testRouteNewMessageAction() throws Exception {
    MockEndpoint outboundEndpoint = getProcessedMessagesEndpoint(15);
    MockEndpoint failedEndpoint = getFailedMessagesEndpoint(0);

    MockProcessor processor = new MockProcessor();
    ConnectorService processorService = new MockConnectorService("test", processor, resourceRegistry);

    Action action1 = Mockito.mock(Action.class);
    Action action2 = new SplitterAction(5, true);
    Action action3 = Mockito.mock(Action.class);
    // duplicates the messages that arrive and generates 5 more as it wont stop the ones that arrived
    Action action4 = new SplitterAction(2, false);
    Action action5 = Mockito.mock(Action.class);

    processorService
      .addPreProcessingAction(action1)
      .addPreProcessingAction(action2)
      .addPreProcessingAction(action3)
      .addPreProcessingAction(action4)
      .addPreProcessingAction(action5);

    processorService.start();

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

    outboundEndpoint.assertIsSatisfied(5000);
    failedEndpoint.assertIsSatisfied(DEFAULT_TIMEOUT);
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.