Package org.mokai

Examples of org.mokai.ConnectorService


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

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

    Action action = Mockito.mock(Action.class);
    Mockito.doThrow(new NullPointerException()).when(action).execute(Mockito.any(Message.class));

    processorService.addPreProcessingAction(action);

    processorService.start();

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

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


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

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

    Action action = Mockito.mock(Action.class);
    Mockito.doThrow(new NullPointerException()).when(action).execute(Mockito.any(Message.class));

    processorService.addPostProcessingAction(action);

    processorService.start();

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

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

  }

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

    processorService.start();
    Assert.assertEquals(Service.State.STARTED, processorService.getState());

    processorService.stop();
    Assert.assertEquals(Service.State.STOPPED, processorService.getState());
  }
View Full Code Here

  @Test
  public void testServiceableConnector() throws Exception {
    // mock Processor and Serviceable
    Processor processor = Mockito.mock(Processor.class, Mockito.withSettings().extraInterfaces(Serviceable.class));

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

    // verify
    Assert.assertEquals(Service.State.STARTED, processorService.getState());
    Mockito.verify((Serviceable) processor).doStart();


    processorService.stop();

    // verify
    Assert.assertEquals(Service.State.STOPPED, processorService.getState());
    Mockito.verify((Serviceable) processor).doStop();
  }
View Full Code Here

  public void shouldFailOnStartException() throws Exception {
    // mock Processor and Serviceable
    Processor processor = Mockito.mock(Processor.class, Mockito.withSettings().extraInterfaces(Serviceable.class));
    Mockito.doThrow(new NullPointerException()).when((Serviceable) processor).doStart();

    ConnectorService processorService = new MockConnectorService("test", processor, resourceRegistry);
    processorService.start();
  }
View Full Code Here

  public void shouldFailOnStopException() throws Exception {
    // mock Processor and Serviceable
    Processor processor = Mockito.mock(Processor.class, Mockito.withSettings().extraInterfaces(Serviceable.class));
    Mockito.doThrow(new NullPointerException()).when((Serviceable) processor).doStop();

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

    processorService.stop();
  }
View Full Code Here

  public void testMessageStoppedProcessor() throws Exception {
    MockEndpoint outboundEndpoint = getProcessedMessagesEndpoint(2);
    MockEndpoint failedEndpoint = getFailedMessagesEndpoint(0);

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

    simulateMessage(new Message(), "activemq:mokai-test");
    Thread.sleep(3000);

    Assert.assertEquals(0, processor.getCount());

    processorService.start();

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

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

  public void testInjectResourceToAcceptor() throws Exception {
    // add he resource to the resource registry
    resourceRegistry.putResource(MessageStore.class, Mockito.mock(MessageStore.class));

    Processor processor = Mockito.mock(Processor.class);
    ConnectorService processorService = new MockConnectorService("test", processor, resourceRegistry);

    MockAcceptor acceptor = new MockAcceptor();
    processorService.addAcceptor(acceptor);

    Assert.assertNotNull(acceptor.getMessageStore());
  }
View Full Code Here

  public void testInjectResourceToActions() throws Exception {
    // add he resource to the resource registry
    resourceRegistry.putResource(MessageStore.class, Mockito.mock(MessageStore.class));

    Processor processor = Mockito.mock(Processor.class);
    ConnectorService processorService = new MockConnectorService("test", processor, resourceRegistry);

    // test inject resource to pre-processing action
    MockAction action = new MockAction();
    processorService.addPreProcessingAction(action);
    Assert.assertNotNull(action.getMessageStore());

    // test inject resource to post-processing action
    action = new MockAction();
    processorService.addPostProcessingAction(action);
    Assert.assertNotNull(action.getMessageStore());

    // test inject resource to post-receiving action
    action = new MockAction();
    processorService.addPostReceivingAction(action);
    Assert.assertNotNull(action.getMessageStore());
  }
View Full Code Here

    private List<ConnectorService> connectorServices = new ArrayList<ConnectorService>();

    @Override
    public ConnectorService addConnector(String id, Connector connector) {
      ConnectorService connectorService = new MockConnectorService(id, connector);
      connectorServices.add(connectorService);
      return connectorService;
    }
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.