Package org.mokai

Examples of org.mokai.ConnectorService


      routingEngine.start();

      Connector connector = mock(Connector.class);

      // create a connector service
      ConnectorService cs1 = routingEngine.addConnection("test1", connector).withPriority(2000);
      cs1.start();

      // check that the connector service was created successfully
      Assert.assertNotNull(cs1);
      Assert.assertEquals(Service.State.STARTED, cs1.getState());

      // check that there is only one connector
      List<ConnectorService> connectorServices = routingEngine.getConnections();
      Assert.assertEquals(1, connectorServices.size());

      // create a second and third connector
      ConnectorService cs2 = routingEngine.addConnection("test2", connector).withPriority(0);
      cs2.start();

      ConnectorService cs3 = routingEngine.addConnection("test3", connector).withPriority(1000);
      cs3.start();

      connectorServices = routingEngine.getConnections();
      Assert.assertEquals(3, connectorServices.size());

      // check that the connector are in order
      ConnectorService psTest = connectorServices.get(0);
      Assert.assertEquals(cs2, psTest); // the one with 0 priority

      psTest = connectorServices.get(1);
      Assert.assertEquals(cs3, psTest); // the one with 1000 priority
View Full Code Here


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

  public void show(Request request, Response response) throws JSONException {
    String id = request.getPathVariable("id").asString();
    ConnectorService connectorService = routingEngine.getApplication(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.getApplication(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.getApplication(id);

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

    connectorService.stop();
  }
View Full Code Here

    try {
      routingEngine.start();
      routingEngine.setConnectorServiceChangeListener( listener );

      ConnectorService cs1 = routingEngine.addConnection("test1", mock(Connector.class));

      cs1.start();
      cs1.stop();

      verify(listener, times(2)).changed(cs1, Direction.TO_CONNECTIONS);
    } finally {
      routingEngine.shutdown();
    }
View Full Code Here

    try {
      routingEngine.start();
      routingEngine.setConnectorServiceChangeListener( listener );

      ConnectorService cs1 = routingEngine.addApplication("test1", mock(Connector.class));

      cs1.start();
      cs1.stop();

      verify(listener, times(2)).changed(cs1, Direction.TO_APPLICATIONS);
    } finally {
      routingEngine.shutdown();
    }
View Full Code Here

      routingEngine.start();

      Connector connector = mock(Connector.class);

      // create and start a connector service
      ConnectorService connectorService = routingEngine.addConnection("test", connector)
        .withPriority(2000);
      connectorService.start();

      // retrieve an existing connector
      ConnectorService csTest = routingEngine.getConnection("test");
      Assert.assertEquals(connectorService, csTest);

      // try to retrieve an unexisting connector
      csTest = routingEngine.getConnection("nonexisting");
      Assert.assertNull(csTest);
View Full Code Here

    CamelRoutingEngine routingEngine = new CamelRoutingEngine();

    try {
      Connector connector = mock(Connector.class);

      ConnectorService cs1 = routingEngine.addConnection("test1", connector).withPriority(2000);
      ConnectorService cs2 = routingEngine.addConnection("test2", connector).withPriority(1000);
      ConnectorService cs3 = routingEngine.addConnection("test3", connector).withPriority(1500);

      List<ConnectorService> connectorServices = routingEngine.getConnections();

      Assert.assertNotNull(connectorServices);
      Assert.assertEquals(3, connectorServices.size());
View Full Code Here

  public void shouldFailToModifyReturnedConnections() throws Exception {
    CamelRoutingEngine routingEngine = new CamelRoutingEngine();

    try {
      Connector connector = mock(Connector.class);
      ConnectorService cs1 = routingEngine.addConnection("test1", connector);

      List<ConnectorService> connectorServices = routingEngine.getConnections();
      Assert.assertEquals(connectorServices.size(), 1);

      connectorServices.add(cs1);
View Full Code Here

    try {
      routingEngine.start();

      Connector connector = mock(Connector.class);

      ConnectorService cs1 = routingEngine.addApplication("test1", connector);
      cs1.start();

      // check that the application was created successfully
      Assert.assertNotNull(cs1);
      Assert.assertEquals(Service.State.STARTED, cs1.getState());

      // check that there is only one application
      Collection<ConnectorService> applications = routingEngine.getApplications();
      Assert.assertEquals(1, applications.size());

      // create a second and third receiver
      ConnectorService cs2 = routingEngine.addApplication("test2", connector);
      cs2.start();
      ConnectorService cs3 = routingEngine.addApplication("test3", connector);
      cs3.start();

      applications = routingEngine.getApplications();
      Assert.assertEquals(3, applications.size());

      // check that all applications are contained
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.