@SuppressWarnings("EqualsBetweenInconvertibleTypes")
 @Test
 public void compareContainers() {
   Container container = account.getContainer("alpha");
   StoredObject object1 = container.getObject("img1.png");
   StoredObject object2 = container.getObject("img2.png");
   assertFalse(object1.equals("alpha"));
   assertFalse(object1.equals(object2));
   Map<StoredObject, String> containers = new TreeMap<StoredObject, String>();
   containers.put(object1, object1.getName());
   containers.put(object2, object2.getName());
   assertEquals(object1.getName(), containers.get(object1));
   assertEquals(object2.getName(), containers.get(object2));
   assertEquals(object1.getName().hashCode(), object1.hashCode());
 }
  public void DownloadUsingSWIFT() throws Exception {

    while (true) {
      Collection<StoredObject> list =
          swiftapi.ReadBucket(SWIFT_ACCESS_KEY_ID, SWIFT_SECRET_KEY, SWIFT_ENDPOINT, SWIFT_BUCKET);

      int scount = list.size();
      int localCount = new File(LOCAL_DIR).listFiles().length;
      if (scount != localCount) {

        for (StoredObject obj : list) {

          if (!(new File(LOCAL_DIR, obj.getName()).exists())) {
            System.out.println("Downloading - " + obj.getName());
            vLogger.LogInfo("emcWorldDownloader: Downloading - " + obj.getName());
            InputStream in =
                swiftapi.ReadObject(
                    SWIFT_ACCESS_KEY_ID,
                    SWIFT_SECRET_KEY,
                    SWIFT_ENDPOINT,
                    SWIFT_BUCKET,
                    obj.getName());

            File file = new File(LOCAL_DIR + obj.getName());

            int count = 0;
            byte[] buf = new byte[1024];
            OutputStream out = new FileOutputStream(file);
            while ((count = in.read(buf)) != -1) {
              if (Thread.interrupted()) {
                throw new InterruptedException();
              }
              out.write(buf, 0, count);
            }
            out.close();
            in.close();
          } else {
            System.out.println("Skipping - " + obj.getName());
            vLogger.LogInfo("emcWorldDownloader: Skipping - " + obj.getName());
          }
        }
      } else System.out.println("No New Files Yet");

      vLogger.LogInfo("emcWorldDownloader: Skipping - Sleep 60 seconds");
      System.out.println("Sleep for 1 minute");
      Thread.sleep(60000);
    }
  }
示例#3
0
 @Test
 public void getObjectSegment() {
   StoredObject object = container.getObjectSegment("alpha", 14);
   assertEquals("alpha/00000014", object.getName());
 }