@Before
  public void before(TestContext context) {
    String uid = "tem";
    String host = "localhost";
    int port = 1234;
    JsonObject emuconfig =
        new JsonObject()
            .put(
                "devices",
                new JsonArray()
                    .add(
                        new JsonObject()
                            .put("type", "BrickletTemperature")
                            .put("uid", uid)
                            .put("enabled", true)));
    System.out.println(emuconfig.encodePrettily());
    DeploymentOptions deploymentOptions = new DeploymentOptions().setConfig(emuconfig);

    vertx = Vertx.vertx();
    Async async = context.async();
    vertx.deployVerticle(
        "org.m1theo.tfemulator.Brickd",
        deploymentOptions,
        res -> {
          async.complete();
        });
    ipcon = new IPConnection(); // Create IP connection
    try {
      try {
        Thread.sleep(100);
      } catch (InterruptedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
      ipcon.connect(host, port);
    } catch (AlreadyConnectedException | IOException e) {
      context.fail(e);
    }
    device = new BrickletTemperature(uid, ipcon);
  }
Exemplo n.º 2
0
 @CodeTranslate
 public void encodePrettily() throws Exception {
   JsonObject obj = new JsonObject().put("foo", "foo_value");
   JsonTest.o = obj.encodePrettily();
 }