@Test
  @JUnitSnmpAgents(
      value = {
        @JUnitSnmpAgent(
            host = ROUTER1_IP,
            port = 161,
            resource = "classpath:linkd/nms17216/router1-walk.txt")
      })
  @Transactional
  public final void testRouter1() throws MarshalException, ValidationException, IOException {
    m_capsd.init();
    m_capsd.start();
    m_capsd.scanSuspectInterface(ROUTER1_IP);

    List<OnmsIpInterface> ips = m_interfaceDao.findByIpAddress(ROUTER1_IP);
    assertTrue("Has only one ip interface", ips.size() == 1);

    OnmsIpInterface ip = ips.get(0);

    for (OnmsIpInterface ipinterface : ip.getNode().getIpInterfaces()) {
      if (ipinterface.getIfIndex() != null)
        System.out.println(
            "ROUTER1_IP_IF_MAP.put(InetAddress.getByName(\""
                + ipinterface.getIpHostName()
                + "\"), "
                + ipinterface.getIfIndex()
                + ");");
    }

    for (OnmsSnmpInterface snmpinterface : ip.getNode().getSnmpInterfaces()) {
      if (snmpinterface.getIfName() != null)
        System.out.println(
            "ROUTER1_IF_IFNAME_MAP.put("
                + snmpinterface.getIfIndex()
                + ", \""
                + snmpinterface.getIfName()
                + "\");");
      if (snmpinterface.getIfDescr() != null)
        System.out.println(
            "ROUTER1_IF_IFDESCR_MAP.put("
                + snmpinterface.getIfIndex()
                + ", \""
                + snmpinterface.getIfDescr()
                + "\");");
      if (snmpinterface.getPhysAddr() != null)
        System.out.println(
            "ROUTER1_IF_MAC_MAP.put("
                + snmpinterface.getIfIndex()
                + ", \""
                + snmpinterface.getPhysAddr()
                + "\");");
      if (snmpinterface.getIfAlias() != null)
        System.out.println(
            "ROUTER1_IF_IFALIAS_MAP.put("
                + snmpinterface.getIfIndex()
                + ", \""
                + snmpinterface.getIfAlias()
                + "\");");
    }

    m_capsd.stop();
  }
  private ArrayList<OnmsResource> populateResourceList(
      File parent, File relPath, OnmsNode node, Boolean isForeign) {

    ArrayList<OnmsResource> resources = new ArrayList<OnmsResource>();

    File[] intfDirs = parent.listFiles(RrdFileConstants.INTERFACE_DIRECTORY_FILTER);

    Set<OnmsSnmpInterface> snmpInterfaces = node.getSnmpInterfaces();
    Map<String, OnmsSnmpInterface> intfMap = new HashMap<String, OnmsSnmpInterface>();

    for (OnmsSnmpInterface snmpInterface : snmpInterfaces) {
      /*
       * When Cisco Express Forwarding (CEF) or some ATM encapsulations
       * (AAL5) are used on Cisco routers, an additional entry might be
       * in the ifTable for these sub-interfaces, but there is no
       * performance data available for collection.  This check excludes
       * ifTable entries where ifDescr contains "-cef".  See bug #803.
       */
      if (snmpInterface.getIfDescr() != null) {
        if (Pattern.matches(".*-cef.*", snmpInterface.getIfDescr())) {
          continue;
        }
      }

      String replacedIfName = AlphaNumeric.parseAndReplace(snmpInterface.getIfName(), '_');
      String replacedIfDescr = AlphaNumeric.parseAndReplace(snmpInterface.getIfDescr(), '_');

      String[] keys =
          new String[] {
            replacedIfName + "-",
            replacedIfDescr + "-",
            replacedIfName + "-" + snmpInterface.getPhysAddr(),
            replacedIfDescr + "-" + snmpInterface.getPhysAddr()
          };

      for (String key : keys) {
        if (!intfMap.containsKey(key)) {
          intfMap.put(key, snmpInterface);
        }
      }
    }

    for (File intfDir : intfDirs) {
      String name = intfDir.getName();

      String desc = name;
      String mac = "";

      // Strip off the MAC address from the end, if there is one
      int dashIndex = name.lastIndexOf('-');

      if (dashIndex >= 0) {
        desc = name.substring(0, dashIndex);
        mac = name.substring(dashIndex + 1, name.length());
      }

      String key = desc + "-" + mac;
      OnmsSnmpInterface snmpInterface = intfMap.get(key);

      String label;
      Long ifSpeed = null;
      String ifSpeedFriendly = null;
      if (snmpInterface == null) {
        label = name + " (*)";
      } else {
        StringBuffer descr = new StringBuffer();
        StringBuffer parenString = new StringBuffer();

        if (snmpInterface.getIfAlias() != null) {
          parenString.append(snmpInterface.getIfAlias());
        }
        // Append all of the IP addresses on this ifindex
        for (OnmsIpInterface ipif : snmpInterface.getIpInterfaces()) {
          String ipaddr = InetAddressUtils.str(ipif.getIpAddress());
          if (!"0.0.0.0".equals(ipaddr)) {
            if (parenString.length() > 0) {
              parenString.append(", ");
            }
            parenString.append(ipaddr);
          }
        }
        if ((snmpInterface.getIfSpeed() != null) && (snmpInterface.getIfSpeed() != 0)) {
          ifSpeed = snmpInterface.getIfSpeed();
          ifSpeedFriendly = SIUtils.getHumanReadableIfSpeed(ifSpeed);
          if (parenString.length() > 0) {
            parenString.append(", ");
          }
          parenString.append(ifSpeedFriendly);
        }

        if (snmpInterface.getIfName() != null) {
          descr.append(snmpInterface.getIfName());
        } else if (snmpInterface.getIfDescr() != null) {
          descr.append(snmpInterface.getIfDescr());
        } else {
          /*
           * Should never reach this point, since ifLabel is based on
           * the values of ifName and ifDescr but better safe than sorry.
           */
          descr.append(name);
        }

        /* Add the extended information in parenthesis after the ifLabel,
         * if such information was found.
         */
        if (parenString.length() > 0) {
          descr.append(" (");
          descr.append(parenString);
          descr.append(")");
        }

        label = descr.toString();
      }

      OnmsResource resource = null;
      if (isForeign) {
        resource =
            getResourceByNodeSourceAndInterface(
                relPath.toString(), intfDir.getName(), label, ifSpeed, ifSpeedFriendly);
      } else {
        resource =
            getResourceByNodeAndInterface(
                node.getId(), intfDir.getName(), label, ifSpeed, ifSpeedFriendly);
      }
      if (snmpInterface != null) {
        Set<OnmsIpInterface> ipInterfaces = snmpInterface.getIpInterfaces();
        if (ipInterfaces.size() > 0) {
          int id = ipInterfaces.iterator().next().getId();
          resource.setLink("element/interface.jsp?ipinterfaceid=" + id);
        } else {
          int ifIndex = snmpInterface.getIfIndex();
          if (ifIndex > -1) {
            resource.setLink(
                "element/snmpinterface.jsp?node=" + node.getNodeId() + "&ifindex=" + ifIndex);
          }
        }

        resource.setEntity(snmpInterface);
      } else {
        LOG.debug("populateResourceList: snmpInterface is null");
      }
      LOG.debug("populateResourceList: adding resource toString {}", resource.toString());
      resources.add(resource);
    }

    return resources;
  }