@Test
  public void checkTemplate() throws ActionException {
    try {
      // in lt interfaces
      LogicalPort ltIface = createLogicalTunnelPort("lt-1/2/0", 2);
      ltIface = addVlanToIface(ltIface, 101);

      setVlanAction.setParams(ltIface);
      setVlanAction.checkParams(ltIface);
      setVlanAction.prepareMessage();

      Assert.assertEquals(setVlanAction.getTemplate(), "/VM_files/setVlanId.vm");

      // in eth interfaces
      LogicalPort feIface = createEthernetPort("fe-1/2/0", 2);
      feIface = addVlanToIface(feIface, 101);

      setVlanAction.setParams(feIface);
      setVlanAction.checkParams(feIface);
      setVlanAction.prepareMessage();

      Assert.assertEquals(setVlanAction.getTemplate(), "/VM_files/setVlanId.vm");

    } finally {
      setVlanAction.setParams(null);
    }
  }
  @Test
  public void checkParamsTest() throws ActionException {

    LogicalPort phyFeIface = createPhysicalInterface("fe-0/3/1");
    LogicalPort phyLtIface = createPhysicalInterface("lt-1/2/0");
    LogicalPort feIface = createEthernetPort("fe-0/3/1", 2);
    LogicalPort ltIface = createLogicalTunnelPort("lt-1/2/0", 2);

    Assert.assertTrue(setEncapsulationAction.checkParams(phyFeIface));
    Assert.assertTrue(setEncapsulationAction.checkParams(ltIface));
    Assert.assertTrue(removeEncapsulationAction.checkParams(phyFeIface));
    Assert.assertTrue(removeEncapsulationAction.checkParams(ltIface));

    try {
      setEncapsulationAction.checkParams(phyLtIface);
      Assert.fail("SetTaggedEthEncapsulation on physical lt interface should fail");
    } catch (ActionException e) {
    }
    try {
      setEncapsulationAction.checkParams(feIface);
      Assert.fail("SetTaggedEthEncapsulation on logical fe interface should fail");
    } catch (ActionException e) {
    }
    try {
      removeEncapsulationAction.checkParams(phyLtIface);
      Assert.fail("RemoveTaggedEthEncapsulation on physical lt interface should fail");
    } catch (ActionException e) {
    }
    try {
      removeEncapsulationAction.checkParams(feIface);
      Assert.fail("RemoveTaggedEthEncapsulation on logical fe interface should fail");
    } catch (ActionException e) {
    }

    try {
      setVlanAction.checkParams(phyFeIface);
      Assert.fail("Set vlanid action on physical interface should fail");
    } catch (ActionException e) {
    }
    try {
      setVlanAction.checkParams(phyLtIface);
      Assert.fail("Set vlanid action on physical interface should fail");
    } catch (ActionException e) {
    }

    try {
      setVlanAction.checkParams(feIface);
      Assert.fail("Set vlanid action without vlan should fail");
    } catch (ActionException e) {
    }
    try {
      setVlanAction.checkParams(ltIface);
      Assert.fail("Set vlanid action without vlan should fail");
    } catch (ActionException e) {
    }

    // add vlans
    phyFeIface = addVlanToIface(phyFeIface, 12);
    phyLtIface = addVlanToIface(phyLtIface, 12);
    feIface = addVlanToIface(feIface, 12);
    ltIface = addVlanToIface(ltIface, 12);

    try {
      setVlanAction.checkParams(phyFeIface);
      Assert.fail("Set vlanid action on physical interface should fail");
    } catch (ActionException e) {
    }
    try {
      setVlanAction.checkParams(phyLtIface);
      Assert.fail("Set vlanid action on physical interface should fail");
    } catch (ActionException e) {
    }
    Assert.assertTrue(setVlanAction.checkParams(feIface));
    Assert.assertTrue(setVlanAction.checkParams(ltIface));

    // use invalid vlans
    LogicalPort feIface2 = createEthernetPort("fe-0/3/1", 2);
    LogicalPort ltIface2 = createLogicalTunnelPort("lt-1/2/0", 2);
    feIface2 = addVlanToIface(feIface2, 8888);
    ltIface2 = addVlanToIface(ltIface2, 8888);

    try {
      setVlanAction.checkParams(feIface2);
      Assert.fail("Set vlanid action with invalid vlan id should fail");
    } catch (ActionException e) {
    }
    try {
      setVlanAction.checkParams(ltIface2);
      Assert.fail("Set vlanid action with invalid vlan id should fail");
    } catch (ActionException e) {
    }
  }