Search in sources :

Example 11 with Configuration

use of com.robo4j.core.configuration.Configuration in project robo4j by Robo4J.

the class RoboHttpPingPongTest method configurePingSystem.

private RoboSystem configurePingSystem() throws Exception {
    final RoboSystem result = new RoboSystem();
    Configuration config = ConfigurationFactory.createEmptyConfiguration();
    HttpClientUnit httpClient = new HttpClientUnit(result, "http_client");
    config.setString("address", HOST_SYSTEM);
    config.setInteger("port", PORT);
    /* specific configuration */
    Configuration targetUnits = config.createChildConfiguration(RoboHttpUtils.HTTP_TARGET_UNITS);
    targetUnits.setString(CONTROLLER_PING_PONG, "POST");
    httpClient.initialize(config);
    StringProducer producer = new StringProducer(result, "http_producer");
    config = ConfigurationFactory.createEmptyConfiguration();
    config.setString("target", "http_client");
    config.setString("method", "POST");
    config.setString("uri", "/controller");
    config.setString("targetAddress", HOST_SYSTEM);
    producer.initialize(config);
    result.addUnits(producer, httpClient);
    return result;
}
Also used : RoboSystem(com.robo4j.core.RoboSystem) Configuration(com.robo4j.core.configuration.Configuration) StringProducer(com.robo4j.core.StringProducer)

Example 12 with Configuration

use of com.robo4j.core.configuration.Configuration in project robo4j by Robo4J.

the class SchedulePeriodUnitTest method basicScheudlePeriodUnitTest.

@Test
public void basicScheudlePeriodUnitTest() throws ConfigurationException {
    RoboSystem system = new RoboSystem();
    Configuration config = ConfigurationFactory.createEmptyConfiguration();
    SchedulePeriodUnit unit = new SchedulePeriodUnit(system, "schedulePeriodUnit");
    config.setString("unit", "test");
    config.setInteger("delay", 1);
    config.setInteger("period", 1);
    config.setString("timeUnit", "SECONDS");
    unit.initialize(config);
    Assert.assertTrue(unit.getState().equals(LifecycleState.INITIALIZED));
}
Also used : RoboSystem(com.robo4j.core.RoboSystem) Configuration(com.robo4j.core.configuration.Configuration) Test(org.junit.Test)

Aggregations

Configuration (com.robo4j.core.configuration.Configuration)12 RoboSystem (com.robo4j.core.RoboSystem)7 Test (org.junit.Test)4 ConfigurationException (com.robo4j.core.ConfigurationException)2 LifecycleState (com.robo4j.core.LifecycleState)2 RoboContext (com.robo4j.core.RoboContext)2 RoboUnit (com.robo4j.core.RoboUnit)2 StringConsumer (com.robo4j.core.StringConsumer)2 RoboHttpUtils (com.robo4j.core.client.util.RoboHttpUtils)2 Constants (com.robo4j.core.httpunit.Constants)2 CameraMessage (com.robo4j.core.httpunit.codec.CameraMessage)2 CameraMessageCodec (com.robo4j.core.httpunit.codec.CameraMessageCodec)2 HttpCommandTestController (com.robo4j.core.httpunit.test.HttpCommandTestController)2 SimpleLoggingUtil (com.robo4j.core.logging.SimpleLoggingUtil)2 Robo4JSystem (com.robo4j.db.sql.model.Robo4JSystem)2 RoboEntity (com.robo4j.db.sql.model.RoboEntity)2 InetAddress (java.net.InetAddress)2 UnknownHostException (java.net.UnknownHostException)2 Base64 (java.util.Base64)2 HashMap (java.util.HashMap)2