Package org.mokai

Examples of org.mokai.ConnectorService


  @Test
  public void shouldListApplications() throws Exception {
    Connector connector = mock(Connector.class);

    ConnectorService cs = mock(ConnectorService.class);
    when( cs.getId() ).thenReturn("test-application");
    when( cs.getConnector() ).thenReturn( connector );
    when( cs.getState() ).thenReturn( State.STARTED );
    when( cs.getStatus() ).thenReturn( Status.UNKNOWN );
    when( cs.getNumQueuedMessages() ).thenReturn(0);
    when( cs.getPriority() ).thenReturn(1000);

    RoutingEngine routingEngine = getSpringContext().getBean(RoutingEngine.class);
    Mockito.when(routingEngine.getApplications()).thenReturn( Collections.singletonList(cs) );

    MockResponse response = get("/applications").addCookie(new Cookie("access_token", "true")).run();
View Full Code Here


  @Test
  public void shouldListConnections() throws Exception {
    Connector connector = mock(Connector.class);

    ConnectorService cs = mock(ConnectorService.class);
    when( cs.getId() ).thenReturn("test-connection");
    when( cs.getConnector() ).thenReturn( connector );
    when( cs.getState() ).thenReturn( State.STARTED );
    when( cs.getStatus() ).thenReturn( Status.UNKNOWN );
    when( cs.getNumQueuedMessages() ).thenReturn(0);
    when( cs.getPriority() ).thenReturn(1000);

    RoutingEngine routingEngine = getSpringContext().getBean(RoutingEngine.class);
    when(routingEngine.getConnections()).thenReturn( Collections.singletonList(cs) );

    MockResponse response = get("/connections").addCookie(new Cookie("access_token", "true")).run();
View Full Code Here

  @Test
  public void shouldStopConnection() throws Exception {
    Connector connector = mock(Connector.class);

    ConnectorService cs = mock(ConnectorService.class);
    when( cs.getId() ).thenReturn("test-connection");
    when( cs.getConnector() ).thenReturn( connector );
    when( cs.getState() ).thenReturn( State.STARTED );
    when( cs.getStatus() ).thenReturn( Status.UNKNOWN );
    when( cs.getNumQueuedMessages() ).thenReturn(0);
    when( cs.getPriority() ).thenReturn(1000);

    RoutingEngine routingEngine = getSpringContext().getBean(RoutingEngine.class);
    when(routingEngine.getConnection("test-connection")).thenReturn(cs);

    MockResponse response = post("/connections/test-connection/stop")
View Full Code Here

    when(p1.supports(any(Message.class))).thenReturn(true);

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

    ConnectorService connectorService = buildConnectorService("test1", p1, a1, a2);

    TestRouter router = new TestRouter(Collections.singletonList(connectorService));

    String endpointUri = router.route(new Message());
    Assert.assertEquals(endpointUri, "endpoint-test1");
View Full Code Here

  @Test
  public void shouldReturnUnroutableUriIfNoProcessors() throws Exception {
    Connector c1 = mock(Connector.class);
    Acceptor a1 = buildAcceptor(true);
    ConnectorService connectorService = buildConnectorService("test1", c1, a1);

    TestRouter router = new TestRouter(Collections.singletonList(connectorService));

    String endpointUri = router.route(new Message());
    Assert.assertEquals(endpointUri, "unroutable");
View Full Code Here

    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);

    List<ConnectorService> connectorServices = new ArrayList<ConnectorService>();
    connectorServices.add(cs1);
    connectorServices.add(cs2);
View Full Code Here

    when(p1.supports(any(Message.class))).thenReturn(true);

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

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

    List<ConnectorService> connectorServices = new ArrayList<ConnectorService>();
    connectorServices.add(cs1);
    connectorServices.add(cs2);
View Full Code Here

  @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>();
    connectorServices.add(cs1);
    connectorServices.add(cs2);
View Full Code Here

  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);

    TestRouter router = new TestRouter(connectorServices);

    String endpointUri = router.route(new Message().withDestination("test1"));
View Full Code Here

    List<Acceptor> lstAcceptors = new ArrayList<Acceptor>();
    for (Acceptor acceptor : acceptors) {
      lstAcceptors.add(acceptor);
    }

    ConnectorService connectorService = mock(ConnectorService.class);
    when(connectorService.getId()).thenReturn(id);
    when(connectorService.getConnector()).thenReturn(connector);
    when(connectorService.getAcceptors()).thenReturn(lstAcceptors);

    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.