Package net.kuujo.vertigo.network

Examples of net.kuujo.vertigo.network.NetworkConfig


    assertEquals("in", connection.getTarget().getPort());
  }

  @Test
  public void testDestroyConnection() {
    NetworkConfig network = new DefaultNetworkConfig("test");
    ConnectionConfig connection = network.createConnection("foo", "bar");
    network.destroyConnection("foo", "bar");
    boolean exists = false;
    for (ConnectionConfig other : network.getConnections()) {
      if (other.equals(connection)) {
        exists = true;
      }
    }
    assertFalse(exists);
View Full Code Here


    assertFalse(exists);
  }

  @Test
  public void testMergeNetworks() {
    NetworkConfig network1 = new DefaultNetworkConfig("test");
    network1.addComponent("foo", "foo.py", 2);
    NetworkConfig network2 = new DefaultNetworkConfig("test");
    network2.addComponent("bar", "bar.js", 4);
    network2.createConnection("foo", "bar");
    NetworkConfig network3 = Configs.mergeNetworks(network1, network2);
    assertTrue(network3.hasComponent("foo"));
    assertTrue(network3.hasComponent("bar"));
    boolean exists = false;
    for (ConnectionConfig connection : network3.getConnections()) {
      if (connection.equals(new DefaultConnectionConfig("foo", "bar", null))) {
        exists = true;
        break;
      }
    }
View Full Code Here

    assertTrue(exists);
  }

  @Test
  public void testUnmergeNetworks() {
    NetworkConfig network1 = new DefaultNetworkConfig("test");
    network1.addComponent("foo", "foo.py", 2);
    network1.addComponent("bar", "bar.js", 4);
    network1.createConnection("foo", "bar");
    NetworkConfig network2 = new DefaultNetworkConfig("test");
    network2.addComponent("bar", "bar.js", 4);
    network2.createConnection("foo", "bar");
    NetworkConfig network3 = Configs.unmergeNetworks(network1, network2);
    assertTrue(network3.hasComponent("foo"));
    assertFalse(network3.hasComponent("bar"));
    boolean exists = false;
    for (ConnectionConfig connection : network3.getConnections()) {
      if (connection.equals(new DefaultConnectionConfig("foo", "bar", null))) {
        exists = true;
        break;
      }
    }
View Full Code Here

    assertFalse(exists);
  }

  @Test
  public void testMergeNetworksFail() {
    NetworkConfig network1 = new DefaultNetworkConfig("test");
    NetworkConfig network2 = new DefaultNetworkConfig("nottest");
    try {
      Configs.mergeNetworks(network1, network2);
      fail();
    } catch(Exception e) {
    }
View Full Code Here

  @Test
  public void testNetworkFromJson() {
    JsonObject json = new JsonObject()
        .putString(NetworkConfig.NETWORK_NAME, "test")
        .putObject(NetworkConfig.NETWORK_COMPONENTS, new JsonObject());
    NetworkConfig network = new Vertigo(null, null).createNetwork(json);
    assertEquals("test", network.getName());
  }
View Full Code Here

        .putString(ModuleConfig.COMPONENT_TYPE, ModuleConfig.COMPONENT_TYPE_MODULE)
        .putString(ModuleConfig.MODULE_NAME, "com.test~test-module~1.0")
        .putObject(ModuleConfig.COMPONENT_CONFIG, new JsonObject().putString("foo", "bar"))
        .putNumber(ModuleConfig.COMPONENT_NUM_INSTANCES, 2);
    json.putObject(NetworkConfig.NETWORK_COMPONENTS, new JsonObject().putObject("feeder", jsonFeeder));
    NetworkConfig network = new Vertigo(null, null).createNetwork(json);
    assertEquals("test", network.getName());
    ModuleConfig module = network.getComponent("feeder");
    assertEquals("feeder", module.getName());
    assertEquals("com.test~test-module~1.0", module.getModule());
    assertEquals("bar", module.getConfig().getString("foo"));
    assertEquals(2, module.getInstances());
    assertTrue(module.getType().equals(ComponentConfig.Type.MODULE));
View Full Code Here

        .putObject(VerticleConfig.COMPONENT_CONFIG, new JsonObject().putString("foo", "bar"))
        .putNumber(VerticleConfig.COMPONENT_NUM_INSTANCES, 2)
        .putBoolean(VerticleConfig.VERTICLE_IS_WORKER, true)
        .putBoolean(VerticleConfig.VERTICLE_IS_MULTI_THREADED, true);
    json.putObject(NetworkConfig.NETWORK_COMPONENTS, new JsonObject().putObject("feeder", jsonFeeder));
    NetworkConfig network = new Vertigo(null, null).createNetwork(json);
    assertEquals("test", network.getName());
    VerticleConfig verticle = network.getComponent("feeder");
    assertEquals("feeder", verticle.getName());
    assertEquals("test.py", verticle.getMain());
    assertEquals("bar", verticle.getConfig().getString("foo"));
    assertEquals(2, verticle.getInstances());
    assertTrue(verticle.getType().equals(ComponentConfig.Type.VERTICLE));
View Full Code Here

        .putString(ModuleConfig.COMPONENT_TYPE, ModuleConfig.COMPONENT_TYPE_MODULE)
        .putString(ModuleConfig.MODULE_NAME, "com.test~test-module~1.0")
        .putObject(ModuleConfig.COMPONENT_CONFIG, new JsonObject().putString("foo", "bar"))
        .putNumber(ModuleConfig.COMPONENT_NUM_INSTANCES, 2);
    json.putObject(NetworkConfig.NETWORK_COMPONENTS, new JsonObject().putObject("worker", jsonWorker));
    NetworkConfig network = new Vertigo(null, null).createNetwork(json);
    assertEquals("test", network.getName());
    ModuleConfig module = network.getComponent("worker");
    assertEquals("worker", module.getName());
    assertEquals("com.test~test-module~1.0", module.getModule());
    assertEquals("bar", module.getConfig().getString("foo"));
    assertEquals(2, module.getInstances());
    assertTrue(module.getType().equals(ComponentConfig.Type.MODULE));
View Full Code Here

        .putObject(VerticleConfig.COMPONENT_CONFIG, new JsonObject().putString("foo", "bar"))
        .putNumber(VerticleConfig.COMPONENT_NUM_INSTANCES, 2)
        .putBoolean(VerticleConfig.VERTICLE_IS_WORKER, true)
        .putBoolean(VerticleConfig.VERTICLE_IS_MULTI_THREADED, true);
    json.putObject(NetworkConfig.NETWORK_COMPONENTS, new JsonObject().putObject("worker", jsonWorker));
    NetworkConfig network = new Vertigo(null, null).createNetwork(json);
    assertEquals("test", network.getName());
    VerticleConfig verticle = network.getComponent("worker");
    assertEquals("worker", verticle.getName());
    assertEquals("test.py", verticle.getMain());
    assertEquals("bar", verticle.getConfig().getString("foo"));
    assertEquals(2, verticle.getInstances());
    assertTrue(verticle.getType().equals(ComponentConfig.Type.VERTICLE));
View Full Code Here

    JsonObject jsonConnection = new JsonObject()
        .putObject("source", new JsonObject().putString("component", "foo").putString("port", "notout"))
        .putObject("target", new JsonObject().putString("component", "bar").putString("port", "notin"))
        .putObject("grouping", new JsonObject().putString("type", "random"));
    json.putArray("connections", new JsonArray().add(jsonConnection));
    NetworkConfig network = new Vertigo(null, null).createNetwork(json);
    assertEquals("test", network.getName());
    ConnectionConfig connection = network.getConnections().iterator().next();
    assertEquals("foo", connection.getSource().getComponent());
    assertEquals("notout", connection.getSource().getPort());
    assertEquals("bar", connection.getTarget().getComponent());
    assertEquals("notin", connection.getTarget().getPort());
  }
View Full Code Here

TOP

Related Classes of net.kuujo.vertigo.network.NetworkConfig

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.