Search in sources :

Example 1 with StringConsumer

use of com.robo4j.core.StringConsumer in project robo4j by Robo4J.

the class RoboHttpDynamicTests method getServerRoboSystem.

// Private Methods
private RoboSystem getServerRoboSystem() throws Exception {
    /* tested system configuration */
    RoboSystem result = new RoboSystem();
    Configuration config = ConfigurationFactory.createEmptyConfiguration();
    HttpServerUnit httpServer = new HttpServerUnit(result, "http");
    config.setString("target", TARGET_UNIT);
    config.setInteger("port", PORT);
    config.setString("packages", "com.robo4j.core.httpunit.test.codec");
    Configuration targetUnits = config.createChildConfiguration(RoboHttpUtils.HTTP_TARGET_UNITS);
    targetUnits.setString(TARGET_UNIT, "POST");
    httpServer.initialize(config);
    HttpCommandTestController ctrl = new HttpCommandTestController(result, TARGET_UNIT);
    config = ConfigurationFactory.createEmptyConfiguration();
    config.setString("target", "request_consumer");
    ctrl.initialize(config);
    StringConsumer consumer = new StringConsumer(result, "request_consumer");
    Assert.assertNotNull(result.getUnits());
    Assert.assertEquals(result.getUnits().size(), 0);
    Assert.assertEquals(httpServer.getState(), LifecycleState.INITIALIZED);
    Assert.assertEquals(result.getState(), LifecycleState.UNINITIALIZED);
    result.addUnits(httpServer, ctrl, consumer);
    System.out.println(SystemUtil.printSocketEndPoint(httpServer, ctrl));
    result.start();
    return result;
}
Also used : RoboSystem(com.robo4j.core.RoboSystem) Configuration(com.robo4j.core.configuration.Configuration) HttpCommandTestController(com.robo4j.core.httpunit.test.HttpCommandTestController) StringConsumer(com.robo4j.core.StringConsumer)

Example 2 with StringConsumer

use of com.robo4j.core.StringConsumer in project robo4j by Robo4J.

the class RoboHttpPingPongTest method configurePongSystem.

// Private Methods
private RoboSystem configurePongSystem() throws Exception {
    final RoboSystem result = new RoboSystem();
    Configuration config = ConfigurationFactory.createEmptyConfiguration();
    HttpServerUnit httpServer = new HttpServerUnit(result, "http_server");
    config.setString("target", CONTROLLER_PING_PONG);
    config.setInteger("port", PORT);
    config.setString("packages", "com.robo4j.core.httpunit.test.codec");
    /* specific configuration */
    Configuration targetUnits = config.createChildConfiguration(RoboHttpUtils.HTTP_TARGET_UNITS);
    targetUnits.setString(CONTROLLER_PING_PONG, "POST");
    httpServer.initialize(config);
    StringConsumer consumer = new StringConsumer(result, "request_consumer");
    config = ConfigurationFactory.createEmptyConfiguration();
    consumer.initialize(config);
    HttpCommandTestController ctrl = new HttpCommandTestController(result, CONTROLLER_PING_PONG);
    config = ConfigurationFactory.createEmptyConfiguration();
    config.setString("target", "request_consumer");
    ctrl.initialize(config);
    result.addUnits(httpServer, consumer, ctrl);
    return result;
}
Also used : RoboSystem(com.robo4j.core.RoboSystem) Configuration(com.robo4j.core.configuration.Configuration) HttpCommandTestController(com.robo4j.core.httpunit.test.HttpCommandTestController) StringConsumer(com.robo4j.core.StringConsumer)

Aggregations

RoboSystem (com.robo4j.core.RoboSystem)2 StringConsumer (com.robo4j.core.StringConsumer)2 Configuration (com.robo4j.core.configuration.Configuration)2 HttpCommandTestController (com.robo4j.core.httpunit.test.HttpCommandTestController)2