/**
   * This test require the dirty model, since the checkParams method would check there's a
   * GreTunnelService in the model.
   *
   * @throws CapabilityException
   * @throws ProtocolException
   */
  @Test
  @Ignore
  public void testDeleteUnexistingTunnelAction() throws CapabilityException, ProtocolException {
    log.info("TEST GRE TUNNEL ACTION");
    IGRETunnelCapability greCapability =
        (IGRETunnelCapability)
            routerResource.getCapability(
                InitializerTestHelper.getCapabilityInformation(TestsConstants.GRE_CAPABILITY_TYPE));

    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.assertFalse(queueResponse.isOk());

    queue = (List<IAction>) queueCapability.getActions();
    Assert.assertEquals(queue.size(), 0);
  }
  @Test
  public void testGRECreateTunnelAction() throws CapabilityException, ProtocolException {
    log.info("TEST GRE TUNNEL ACTION");
    IGRETunnelCapability greCapability =
        (IGRETunnelCapability)
            routerResource.getCapability(
                InitializerTestHelper.getCapabilityInformation(TestsConstants.GRE_CAPABILITY_TYPE));

    greCapability.createGRETunnel(
        ParamCreationHelper.getGRETunnelService(TUNNEL_NAME, IPv4_ADDRESS, IP_SOURCE, IP_DESTINY));

    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);
  }
 @Test
 public void testSetInterfaceDescription() throws ProtocolException, ResourceException {
   IIPCapability ipCapability =
       (IIPCapability)
           routerResource.getCapability(
               InitializerTestHelper.getCapabilityInformation(TestsConstants.IP_CAPABILITY_TYPE));
   ipCapability.setInterfaceDescription(ParamCreationHelper.getLogicalPort());
   IQueueManagerCapability queueCapability =
       (IQueueManagerCapability)
           routerResource.getCapability(
               InitializerTestHelper.getCapabilityInformation(
                   TestsConstants.QUEUE_CAPABILIY_TYPE));
   QueueResponse queueResponse = (QueueResponse) queueCapability.execute();
   Assert.assertTrue(queueResponse.isOk());
 }
 @Test
 /** Test to check if capability is available from OSGi. */
 public void isCapabilityAccessibleFromResource() throws ResourceException, ProtocolException {
   startResource();
   Assert.assertFalse(routerResource.getCapabilities().isEmpty());
   Assert.assertNotNull(
       routerResource.getCapability(
           InitializerTestHelper.getCapabilityInformation(TestsConstants.QUEUE_CAPABILIY_TYPE)));
   Assert.assertNotNull(
       routerResource.getCapability(
           InitializerTestHelper.getCapabilityInformation(
               TestsConstants.STATIC_ROUTE_CAPABILITY_TYPE)));
   stopResource();
   Assert.assertTrue(resourceManager.listResources().isEmpty());
 }
  @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);
  }
  @Test
  public void createGRETunnelv6Test() throws CapabilityException, ProtocolException {
    log.info("Test createGRETunnel method");
    IGRETunnelCapability greCapability =
        (IGRETunnelCapability)
            routerResource.getCapability(
                InitializerTestHelper.getCapabilityInformation(TestsConstants.GRE_CAPABILITY_TYPE));

    greCapability.createGRETunnel(
        ParamCreationHelper.getGRETunnelService(TUNNEL_NAME, IPv6_ADDRESS, IP_SOURCE, IP_DESTINY));

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

    QueueResponse queueResponse = (QueueResponse) queueCapability.execute();
    Assert.assertTrue(queueResponse.isOk());
  }
  @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 to check create static route method */
  @Test
  public void createStaticRouteTest() throws ProtocolException, ResourceException {
    startResource();

    StaticRouteCapability staticRouteCapability =
        (StaticRouteCapability)
            routerResource.getCapability(
                InitializerTestHelper.getCapabilityInformation(
                    TestsConstants.STATIC_ROUTE_CAPABILITY_TYPE));
    staticRouteCapability.createStaticRoute("0.0.0.0", "0.0.0.0", "192.168.1.1");

    IQueueManagerCapability queueCapability =
        (IQueueManagerCapability)
            routerResource.getCapability(
                InitializerTestHelper.getCapabilityInformation(
                    TestsConstants.QUEUE_CAPABILIY_TYPE));
    QueueResponse queueResponse = (QueueResponse) queueCapability.execute();
    Assert.assertTrue(queueResponse.isOk());

    stopResource();
  }