/**
   * Check Response, ignore case. Maybe the case was not the same as expected.
   *
   * @param reqField required filed
   * @param map values to compare against
   * @return return found value
   */
  protected String checkResponseCaseless(String reqField, Map map) {
    Set respKeySet = map.keySet();
    Iterator iter = null;
    String key = null;

    iter = respKeySet.iterator();

    while (iter.hasNext()) {
      key = (String) iter.next();

      if (reqField.equalsIgnoreCase(key)) {
        return key;
      }
    }

    return null;
  }
  /**
   * Optional logout response arguments to check
   *
   * @param transactionName Transaction name
   * @param map responseMap
   */
  protected TestResult checkResponseArgsOpt(String transactionName, Map map) {

    TestResult result = new TestResult("Logout", "Checking Optional Response Arguments");

    String notes = "Fields found : ";
    String info = "";
    String missingOptFields = "";

    int missingCount = 0;
    int foundCount = 0;
    int badCaseCount = 0;
    String key = null;

    for (int i = 0; i < optResponseArgs.length; i++) {
      if (map.get(optResponseArgs[i]) == null) {
        key = checkResponseCaseless(optResponseArgs[i], map);

        if (key == null) {
          if (missingCount++ == 0) {
            missingOptFields = optResponseArgs[i];
          } else {
            missingOptFields = missingOptFields + ", " + optResponseArgs[i];
          }
        } else {
          badCaseCount++;

          info = info + "\t Looking for \"" + optResponseArgs[i] + "\" found \"" + key + "\"\n";
        }
      } else {
        if (foundCount++ > 0) {
          notes = notes + ", " + optResponseArgs[i];
        } else {
          notes = notes + optResponseArgs[i];
        }
      }
    }

    String display = "";

    if (missingCount > 0) {
      result.setStatus("Info");
      display +=
          ("Logout transaction does not support the following optional response arguments:\n "
              + missingOptFields
              + "\n\n");
    }

    if (badCaseCount > 0) {
      result.setStatus("Failure");
      display +=
          ("Logout transaction supports the following optional response arguments, but with an incorrect case: \n"
              + info
              + "\n\n");
    }

    if (foundCount > 0) {
      result.setStatus("Success");
      display +=
          ("Logout transaction supports the following optional response arguments:\n  "
              + notes
              + " \n\n ");
    }

    result.setNotes(display);
    return result;
  }