Package org.mokai

Examples of org.mokai.Processor


   *
   * @throws Exception
   */
  @Test
  public void shouldReturnUriIfAtLeastOneAcceptorAccepts() throws Exception {
    Processor p1 = mock(Processor.class);
    when(p1.supports(any(Message.class))).thenReturn(true);

    Acceptor a1 = buildAcceptor(true);
    Acceptor a2 = buildAcceptor(false);

    ConnectorService connectorService = buildConnectorService("test1", p1, a1, a2);
View Full Code Here


   *
   * @throws Exception
   */
  @Test
  public void shouldReturnFirstUriIfMoreThanOneAccepts() throws Exception {
    Processor p1 = mock(Processor.class);
    when(p1.supports(any(Message.class))).thenReturn(true);

    Acceptor a1 = buildAcceptor(true);

    ConnectorService cs1 = buildConnectorService("test1", p1, a1);
    ConnectorService cs2 = buildConnectorService("test2", p1, a1);
View Full Code Here

    Assert.assertEquals(endpointUri, "endpoint-test1");
  }

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

    Acceptor a1 = buildAcceptor(false);
    Acceptor a2 = buildAcceptor(true);

    ConnectorService cs1 = buildConnectorService("test1", p1, a1);
View Full Code Here

    Assert.assertEquals(endpointUri, "endpoint-test2");
  }

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

    ConnectorService cs1 = buildConnectorService("test1", p1);
    ConnectorService cs2 = buildConnectorService("test2", p1);

    List<ConnectorService> connectorServices = new ArrayList<ConnectorService>();
View Full Code Here

    Assert.assertEquals(endpointUri, "unroutable");
  }

  @Test
  public void shouldReturnUnroutableIfMsgDestinationFoundButNoSupport() throws Exception {
    Processor p1 = mock(Processor.class);
    when(p1.supports(any(Message.class))).thenReturn(false);

    List<ConnectorService> connectorServices = new ArrayList<ConnectorService>();
    ConnectorService cs1 = buildConnectorService("test1", p1);
    connectorServices.add(cs1);
View Full Code Here

    // return if not a Processor instance
    if (!Processor.class.isInstance(connectorService.getConnector())) {
      return false;
    }

    Processor processor = (Processor) connectorService.getConnector();

    // check if the processor supports the message
    boolean supported = false;
    if (processor.supports(message)) {
      supported = true;
    }

    // check the acceptors only if the message is supported
    if (supported && checkAcceptors) {
View Full Code Here

              ", it doesn't implements org.mokai.Processor");
        }

        // try to process the message
        long startTime = System.currentTimeMillis();
        Processor processor = (Processor) connector;
        processor.process(message);
        message.setStatus(Message.STATUS_PROCESSED);
        long endTime = System.currentTimeMillis();
        log.debug("[processor=" + id + "] processing message took " + (endTime - startTime) + " millis");

        status = Monitorable.class.isInstance(processor) ? MonitorStatusBuilder.ok() : MonitorStatusBuilder.unknown();
View Full Code Here

  public void testProcessorStatus() throws Exception {
    // add failed validation
    MockEndpoint outboundEndpoint = getProcessedMessagesEndpoint(0);
    MockEndpoint failedEndpoint = getFailedMessagesEndpoint(1);

    Processor processor = Mockito.mock(Processor.class);
    Mockito
      .doThrow(new NullPointerException())
      .when(processor).process(Mockito.any(Message.class));

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

  public void testMonitorableProcessorStatus() throws Exception {
    // add processed validation
    MockEndpoint outboundEndpoint = getProcessedMessagesEndpoint(1);
    MockEndpoint failedEndpoint = getFailedMessagesEndpoint(0);

    Processor processor =
      Mockito.mock(Processor.class, Mockito.withSettings().extraInterfaces(Monitorable.class));
    Mockito
      .when(((Monitorable) processor).getStatus())
      .thenReturn(Status.OK);
View Full Code Here

  public void testFailedMonitorableProcessorStatus() throws Exception {
    // add processed validation
    MockEndpoint outboundEndpoint = getProcessedMessagesEndpoint(1);
    MockEndpoint failedEndpoint = getFailedMessagesEndpoint(0);

    Processor processor =
      Mockito.mock(Processor.class, Mockito.withSettings().extraInterfaces(Monitorable.class));
    Mockito
      .when(((Monitorable) processor).getStatus())
      .thenReturn(Status.FAILED);
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.