Exemplo n.º 1
0
  /** Create a new instance of a HostOrBogey "host". */
  public org.opensims.model.HostOrBogey createHost(
      String ip_addr_str, org.opensims.agent.Agent agent, org.jdom.Element node, boolean update) {
    org.opensims.model.HostOrBogey host =
        getCorrelator().getBogeyManager().createHostOrBogey(ip_addr_str, agent, node, update);

    if (log_.isDebugEnabled()) {
      String xml = null;
      if (node != null) xml = org.opensims.xml.XmlBuilder.formatXML(node, false, true);

      log_.debug(
          "create known "
              + ip_addr_str
              + " update "
              + update
              + " agent "
              + agent
              + " bogey "
              + host.isBogey()
              + " - "
              + host);
      log_.debug(xml);
    }

    if (update) {
      setKnownHost(ip_addr_str, agent, (org.opensims.db.om.Host) host);
    }

    return host;
  }
Exemplo n.º 2
0
  /**
   * Parse an incoming <TEST_MESSAGE/> node from an agent ... save the XML input as test data, e.g.
   * from an agent, into a local file ... to use for regression testing.
   */
  protected void handleTestMessage(org.jdom.Element node) {
    try {
      java.io.File temp_dir = new java.io.File(getCorrelator().getConfig("temp.dir"));
      java.io.File test_file =
          new java.io.File(temp_dir, getCorrelator().getConfig("symplugin-tester.test_file"));

      java.io.FileWriter file_writer = new java.io.FileWriter(test_file);
      java.io.PrintWriter print_writer =
          new java.io.PrintWriter(new java.io.BufferedWriter(file_writer));

      String xml = org.opensims.xml.XmlBuilder.formatXML(node, false, true);
      print_writer.print(xml);

      print_writer.flush();
      print_writer.close();
      file_writer.close();
    } catch (Exception e) {
      log_.error("error saving test vector", e);
    }
  }