Пример #1
0
  /** 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 + "]");
  }
Пример #2
0
  public void testDirScanf() {

    TestCase self = initTest("DirScanf");
    if (self == null) return;

    try {
      Map file = webdavCreateFileWithSpecialDirs();

      String oid = (String) file.get("system.object_id");
      String url = getURL(file);

      if (!dav.exists(url)) {
        self.testFailed("File can't be retrieved from stored URL \"" + url + "\"");
        return;
      }

      Log.INFO("WebDAVFilenames: PUT \"" + url + "\" with WebDAV, OID " + oid);

      Map retrieved = apiRetrieveMD(oid);

      DavTestSchema.compareMaps(file, retrieved);

      self.testPassed("OK");
    } catch (Exception e) {
      e.printStackTrace();
      self.testFailed(e.getMessage());
    }
  }
Пример #3
0
  public void testScanf() {
    // PUT a file into a view, then retrieve the file's metadata
    // with the API and check all string values. (It's like scanf
    // because the webdav server has to parse out four values from
    // the filename.)

    TestCase self = initTest("Scanf");
    if (self == null) return;

    try {
      Map file = webdavCreateFile();

      String oid = (String) file.get("system.object_id");
      String url = getURL(file);

      if (!dav.exists(url)) {
        self.testFailed("File can't be retrieved from stored URL \"" + url + "\"");
        return;
      }

      Log.INFO("WebDAVFilenames: PUT \"" + url + "\" with WebDAV, OID " + oid);

      Map retrieved = apiRetrieveMD(oid);

      DavTestSchema.compareMaps(file, retrieved);

      self.testPassed("OK");
    } catch (Exception e) {
      e.printStackTrace();
      self.testFailed(e.getMessage());
    }
  }
Пример #4
0
  private void addStrings(Map md, boolean useSpecials) {
    md.put("davtest.long1", new Long(System.currentTimeMillis()));
    for (int i = 1; i <= 4; i++) md.put("davtest.string" + i, DavTestSchema.newRandomString(10));

    if (useSpecials) {
      // Insert a few special chars into string4, which is the
      // second-level directory
      String value = (String) md.get("davtest.string4");
      value = "<&>" + value;
      md.put("davtest.string4", value);
    }
  }