@Test
  public void showGRETunnelConfigurationTest() throws CapabilityException, ProtocolException {
    log.info("Test showGRETunnelConfiguration method");

    IGRETunnelCapability greCapability =
        (IGRETunnelCapability)
            routerResource.getCapability(
                InitializerTestHelper.getCapabilityInformation(TestsConstants.GRE_CAPABILITY_TYPE));

    ComputerSystem routerModel = (ComputerSystem) routerResource.getModel();
    routerModel.addHostedService(
        ParamCreationHelper.getGRETunnelService(TUNNEL_NAME, IPv4_ADDRESS, IP_SOURCE, IP_DESTINY));
    routerModel.addHostedService(
        ParamCreationHelper.getGRETunnelService(TUNNEL_NAME, IPv6_ADDRESS, IP_SOURCE, IP_DESTINY));

    List<GRETunnelService> greServices = greCapability.showGRETunnelConfiguration();
    Assert.assertEquals(greServices.size(), 2);

    GRETunnelService greService = greServices.get(0);
    Assert.assertEquals(TUNNEL_NAME, greService.getName());

    Assert.assertNotNull(greService.getGRETunnelConfiguration());
    GRETunnelConfiguration greConfig = greService.getGRETunnelConfiguration();
    Assert.assertEquals(IP_SOURCE, greConfig.getSourceAddress());
    Assert.assertEquals(IP_DESTINY, greConfig.getDestinationAddress());

    Assert.assertEquals(greService.getProtocolEndpoint().size(), 1);
    ProtocolEndpoint pE = greService.getProtocolEndpoint().get(0);
    Assert.assertTrue(pE instanceof GRETunnelEndpoint);
    GRETunnelEndpoint gE = (GRETunnelEndpoint) pE;
    Assert.assertEquals(IPUtilsHelper.getAddressFromIP(IPv4_ADDRESS), gE.getIPv4Address());
    Assert.assertEquals(
        IPUtilsHelper.getPrefixFromIp(IPv4_ADDRESS),
        IPUtilsHelper.parseLongToShortIpv4NetMask(gE.getSubnetMask()));
    Assert.assertEquals(ProtocolIFType.IPV4, gE.getProtocolIFType());

    greService = greServices.get(1);
    Assert.assertEquals(TUNNEL_NAME, greService.getName());

    Assert.assertNotNull(greService.getGRETunnelConfiguration());
    greConfig = greService.getGRETunnelConfiguration();
    Assert.assertEquals(IP_SOURCE, greConfig.getSourceAddress());
    Assert.assertEquals(IP_DESTINY, greConfig.getDestinationAddress());

    Assert.assertEquals(greService.getProtocolEndpoint().size(), 1);
    pE = greService.getProtocolEndpoint().get(0);
    Assert.assertTrue(pE instanceof GRETunnelEndpoint);
    gE = (GRETunnelEndpoint) pE;
    Assert.assertEquals(IPUtilsHelper.getAddressFromIP(IPv6_ADDRESS), gE.getIPv6Address());
    Assert.assertEquals(
        IPUtilsHelper.getPrefixFromIp(IPv6_ADDRESS), String.valueOf(gE.getPrefixLength()));
    Assert.assertEquals(ProtocolIFType.IPV6, gE.getProtocolIFType());
  }
  @Test
  public void testGREDeleteTunnelAction() throws CapabilityException, ProtocolException {
    log.info("TEST GRE TUNNEL ACTION");
    IGRETunnelCapability greCapability =
        (IGRETunnelCapability)
            routerResource.getCapability(
                InitializerTestHelper.getCapabilityInformation(TestsConstants.GRE_CAPABILITY_TYPE));

    // add gre tunnel service to the router model.
    GRETunnelService greTunnelService = new GRETunnelService();
    greTunnelService.setName(TUNNEL_NAME);

    ComputerSystem model = (ComputerSystem) routerResource.getModel();
    model.addHostedService(greTunnelService);
    routerResource.setModel(model);

    greCapability.deleteGRETunnel(
        ParamCreationHelper.getGRETunnelService(TUNNEL_NAME, null, null, null, null));

    IQueueManagerCapability queueCapability =
        (IQueueManagerCapability)
            routerResource.getCapability(
                InitializerTestHelper.getCapabilityInformation(
                    TestsConstants.QUEUE_CAPABILIY_TYPE));

    List<IAction> queue = (List<IAction>) queueCapability.getActions();
    Assert.assertEquals(queue.size(), 1);

    QueueResponse queueResponse = (QueueResponse) queueCapability.execute();
    Assert.assertEquals(queueResponse.getResponses().size(), 1);

    Assert.assertEquals(queueResponse.getPrepareResponse().getStatus(), ActionResponse.STATUS.OK);
    Assert.assertEquals(queueResponse.getConfirmResponse().getStatus(), ActionResponse.STATUS.OK);
    Assert.assertEquals(queueResponse.getRefreshResponse().getStatus(), ActionResponse.STATUS.OK);
    Assert.assertEquals(
        queueResponse.getRestoreResponse().getStatus(), ActionResponse.STATUS.PENDING);

    Assert.assertTrue(queueResponse.isOk());

    queue = (List<IAction>) queueCapability.getActions();
    Assert.assertEquals(queue.size(), 0);
  }
Пример #3
0
  private static IModel getComputerSystem() {

    ComputerSystem model = new ComputerSystem();
    model.addHostedService(getGRETunnelService());
    return model;
  }