コード例 #1
0
ファイル: WebDAVer.java プロジェクト: elambert/honeycomb
  /** Create a random new file in a davtest view and return its URL */
  public String createFile(int viewIndex, DavTestSchema schema) throws HoneycombTestException {
    String url = null;

    try {
      Map md = new HashMap();
      schema.addDavMD(md);
      url = schema.getDavTestName(md, viewIndex);

      NVPair[] headers = new NVPair[1];
      headers[0] = new NVPair("Content-type", "text/plain");

      if (putFile(url, FILESIZE, false, headers).pass) return url;
    } catch (HoneycombTestException e) {

      if (e.exitStatus != null) {
        int rc = e.exitStatus.getReturnCode();
        String err = e.exitStatus.getOutputString(false);
        String msg = "Couldn't upload scratch file!";

        if (rc == 400) msg += " Is metadata_config_davtest.xml loaded?";

        msg += " Error " + rc + ":" + err;

        throw new HoneycombTestException(msg);
      } else throw new RuntimeException(e);
    }

    throw new HoneycombTestException("Couldn't create file [" + url + "]");
  }