コード例 #1
0
  /*
   * Note: The following tests on the gateway pool/node related APIs in
   * VirutalRouterImpl class ensure only that the IGatewayPool API usage is
   * correct. It does not cover in detail the test cases for the IGatewayPool
   * APIs. Please refer GatewayPoolTest.java for detailed tests on the
   * IGatewayPool interface.
   */
  @Test
  public void testCreateGatewayPool() {
    String gatewayPoolName1 = "testGatewayPool1";
    vr.createGatewayPool(gatewayPoolName1);
    GatewayPoolImpl gatewayPool1 = vr.getGatewayPool(gatewayPoolName1);
    assertNotNull(gatewayPool1);
    assertEquals("testGatewayPool1", gatewayPool1.getName());

    String gatewayPoolName2 = "testGatewayPool2";
    vr.createGatewayPool(gatewayPoolName2);
    GatewayPoolImpl gatewayPool2 = vr.getGatewayPool(gatewayPoolName2);
    assertNotNull(gatewayPool2);
    assertEquals("testGatewayPool2", gatewayPool2.getName());
  }
コード例 #2
0
  @Test
  public void testAddGatewayNode() {
    String gatewayPoolName = "testGatewayPool";
    vr.createGatewayPool(gatewayPoolName);
    vr.addGatewayPoolNode(gatewayPoolName, "10.0.0.1");
    vr.addGatewayPoolNode(gatewayPoolName, "10.0.0.2");

    GatewayPoolImpl gatewayPool = vr.getGatewayPool(gatewayPoolName);
    assertNotNull(gatewayPool);
    assertEquals("testGatewayPool", gatewayPool.getName());

    Map<String, GatewayNode> nodes = gatewayPool.getGatewayNodes();
    assertNotNull(nodes);
    assertEquals(2, nodes.size());
    GatewayNode node1 = nodes.get("10.0.0.1");
    assertEquals("10.0.0.1", IPv4.fromIPv4Address(node1.getIp()));
    GatewayNode node2 = nodes.get("10.0.0.2");
    assertEquals("10.0.0.2", IPv4.fromIPv4Address(node2.getIp()));
  }