use of com.robo4j.RoboBuilder in project robo4j by Robo4J.
the class RoboDatagramPingPongTest method configurePingSystem.
private RoboContext configurePingSystem() throws Exception {
RoboBuilder builder = new RoboBuilder();
Configuration config = new ConfigurationBuilder().addString(PROPERTY_CODEC_PACKAGES, PACKAGE_CODECS).addString(PROPERTY_HOST, "localhost").addInteger(PROPERTY_SOCKET_PORT, RoboHttpUtils.DEFAULT_UDP_PORT).addString(PROPERTY_UNIT_PATHS_CONFIG, "[{\"roboUnit\":\"stringConsumer\",\"callbacks\": [\"stringConsumer\"]}]").build();
builder.add(DatagramClientUnit.class, config, UDP_CLIENT);
config = ConfigurationFactory.createEmptyConfiguration();
builder.add(StringConsumer.class, config, StringConsumer.NAME);
return builder.build();
}
use of com.robo4j.RoboBuilder in project robo4j by Robo4J.
the class RoboDatagramPingPongTest method configurePongSystem.
/**
* create simple UDP server with consumer unit
*
* @return roboContext
* @throws Exception
* exception
*/
private RoboContext configurePongSystem(int totalNumberOfMessage) throws Exception {
RoboBuilder builder = new RoboBuilder();
Configuration config = new ConfigurationBuilder().addString(PROPERTY_CODEC_PACKAGES, PACKAGE_CODECS).addString(PROPERTY_UNIT_PATHS_CONFIG, "[{\"roboUnit\":\"stringConsumer\",\"filters\":[]}]").build();
builder.add(DatagramServerUnit.class, config, UDP_SERVER);
config = new ConfigurationBuilder().addInteger(StringConsumer.PROP_TOTAL_NUMBER_MESSAGES, totalNumberOfMessage).build();
builder.add(StringConsumer.class, config, StringConsumer.NAME);
return builder.build();
}
use of com.robo4j.RoboBuilder in project robo4j by Robo4J.
the class RoboHttpDynamicTests method getClientRoboSystem.
private RoboContext getClientRoboSystem() throws Exception {
/* system which is testing main system */
RoboBuilder builder = getHttpClientRobotBuilder(HOST_SYSTEM, PORT);
Configuration config = new ConfigurationBuilder().addString(PROPERTY_TARGET, ID_CLIENT_UNIT).addString(PROPERTY_UNIT_PATHS_CONFIG, "[{\"roboUnit\":\"" + ID_TARGET_UNIT + "\",\"method\":\"POST\"}]").addString("message", JSON_STRING).build();
builder.add(SocketMessageDecoratedProducerUnit.class, config, DECORATED_PRODUCER);
RoboContext result = builder.build();
result.start();
return result;
}
use of com.robo4j.RoboBuilder in project robo4j by Robo4J.
the class RoboHttpUnitGetTestApp method oneKnownAttributeTest.
/**
* Run the system with known attributes
*
* @throws Exception
* exception
*/
public void oneKnownAttributeTest() throws Exception {
final HttpPathConfigJsonBuilder pathBuilder = HttpPathConfigJsonBuilder.Builder().addPath("controller", HttpMethod.GET);
// @formatter:off
Configuration systemConfiguration = new ConfigurationBuilder().addInteger("poolSizeScheduler", 4).addInteger("poolSizeWorker", 2).addInteger("poolSizeBlocking", 3).build();
RoboBuilder builder = new RoboBuilder("roboSystem1", systemConfiguration);
// @formatter:on
// @formatter:off
Configuration config = new ConfigurationBuilder().addInteger(PROPERTY_SOCKET_PORT, SERVER_PORT).addString("packages", PACKAGE_CODECS).addString(PROPERTY_UNIT_PATHS_CONFIG, pathBuilder.build()).build();
// @formatter:on
builder.add(HttpServerUnit.class, config, "http_server");
config = new ConfigurationBuilder().addInteger(StringConsumer.PROP_TOTAL_NUMBER_MESSAGES, 1).build();
builder.add(StringConsumer.class, config, "request_consumer");
config = new ConfigurationBuilder().addString("target", "request_consumer").build();
builder.add(HttpOneAttributeGetController.class, config, "controller");
RoboContext system = builder.build();
system.start();
System.out.println("systemPong: State after start:");
System.out.println(SystemUtil.printStateReport(system));
System.out.println("Press <Enter>...");
System.in.read();
system.shutdown();
}
use of com.robo4j.RoboBuilder in project robo4j by Robo4J.
the class HttpServerUnitTests method httpServerUnitNoCodecsPackageTest.
@Test
void httpServerUnitNoCodecsPackageTest() throws Exception {
Throwable exception = assertThrows(RoboBuilderException.class, () -> {
RoboBuilder builder = new RoboBuilder();
Configuration config = new ConfigurationBuilder().addInteger(PROPERTY_SOCKET_PORT, PORT).build();
builder.add(HttpServerUnit.class, config, ID_HTTP_SERVER);
RoboContext system = builder.build();
system.start();
System.out.println("system: State after start:");
System.out.println(SystemUtil.printStateReport(system));
RoboReference<HttpServerUnit> systemReference = system.getReference(ID_HTTP_SERVER);
system.shutdown();
System.out.println("system: State after shutdown:");
System.out.println(SystemUtil.printStateReport(system));
assertEquals(LifecycleState.SHUTDOWN, systemReference.getState());
});
assertEquals("Error initializing RoboUnit", exception.getMessage());
}
Aggregations