@Test
 public void removeDeleteAt() throws IOException, DateParseException {
   expectStatusCode(202, false);
   prepareMetadata();
   object.setDeleteAt(null);
   verifyHeaderValue(null, X_DELETE_AT, "POST");
 }
 @Test
 public void setContentType() throws IOException {
   expectStatusCode(202, false);
   prepareMetadata();
   object.setContentType("image/bmp");
   verifyHeaderValue("image/bmp", CONTENT_TYPE, "POST");
 }
 @Test
 public void uploadFromByteArray() throws IOException {
   expectStatusCode(201);
   this.bytes = new byte[] {0x01, 0x02, 0x03, 0x04, 0x05};
   object.uploadObject(this.bytes);
   verifyUploadContent(this.bytes);
 }
 @Test
 public void copyObject() throws IOException {
   Container beta = account.getContainer("beta");
   StoredObject object2 = beta.getObject("other-image.png");
   expectStatusCode(201);
   object.copyObject(beta, object2);
   verifyHeaderValue("/alpha/image.png", CopyFrom.X_COPY_FROM);
 }
 @Test
 public void setDeleteAfter() throws IOException {
   expectStatusCode(202, false);
   prepareMetadata();
   object.setDeleteAfter(42);
   verifyHeaderValue("42", X_DELETE_AFTER, "POST");
   verifyHeaderValue(null, X_DELETE_AT, "POST");
 }
 @Test
 public void setDeleteAt() throws IOException, DateParseException {
   expectStatusCode(202, false);
   prepareMetadata();
   final Date date = DateUtils.parseDate("Mon, 03 Sep 2001 05:40:33 GMT");
   object.setDeleteAt(date);
   verifyHeaderValue(Long.toString(date.getTime() / 1000), X_DELETE_AT, "POST");
 }
 @Test
 public void emptyDeleteAt() {
   expectStatusCode(202);
   List<Header> headers = new ArrayList<Header>();
   prepareHeader(response, LAST_MODIFIED, "Mon, 03 Sep 2012 05:40:33 GMT", headers);
   prepareHeadersForRetrieval(response, headers);
   assertNull(object.getDeleteAt());
   assertNull(object.getDeleteAtAsDate());
 }
 @Test
 public void removeAndDoNotSaveMetadata() throws IOException {
   expectStatusCode(202);
   object.removeAndDoNotSaveMetadata("Year");
   object.removeAndDoNotSaveMetadata("Company");
   object.saveMetadata();
   verifyHeaderValue("", X_OBJECT_META_PREFIX + "Year");
   verifyHeaderValue("", X_OBJECT_META_PREFIX + "Company");
 }
 @Test
 public void setAndDoNotSaveMetadata() throws IOException {
   expectStatusCode(202);
   object.setAndDoNotSaveMetadata("Year", "1989");
   object.setAndDoNotSaveMetadata("Company", "42 BV");
   object.saveMetadata();
   verifyHeaderValue("1989", X_OBJECT_META_PREFIX + "Year");
   verifyHeaderValue("42 BV", X_OBJECT_META_PREFIX + "Company");
 }
 @Test
 public void uploadFromFile() throws IOException {
   OutputStream outputStream = new FileOutputStream(downloadedFile);
   IOUtils.write(this.bytes, outputStream);
   outputStream.close();
   expectStatusCode(201);
   object.uploadObject(downloadedFile);
   verifyUploadContent(this.bytes);
 }
 @Test
 public void setMetadata() throws IOException {
   expectStatusCode(202);
   Map<String, Object> metadata = new TreeMap<String, Object>();
   metadata.put("Year", "1989");
   metadata.put("Company", "42 BV");
   object.setMetadata(metadata);
   verifyHeaderValue("1989", X_OBJECT_META_PREFIX + "Year");
   verifyHeaderValue("42 BV", X_OBJECT_META_PREFIX + "Company");
 }
 @Test
 public void getMetadata() throws IOException, DateParseException {
   expectStatusCode(202);
   prepareMetadata();
   assertEquals("1989", object.getMetadata().get("Year"));
   assertEquals("42 BV", object.getMetadata().get("Company"));
   assertEquals("Mon, 03 Sep 2012 05:40:33 GMT", object.getLastModified());
   assertEquals(
       DateUtils.parseDate("Mon, 03 Sep 2012 05:40:33 GMT"), object.getLastModifiedAsDate());
   assertEquals(654321, object.getContentLength());
   assertEquals("image/png", object.getContentType());
   assertEquals("cae4ebb15a282e98ba7b65402a72f57c", object.getEtag());
   assertEquals("1339429105", object.getDeleteAt());
   assertEquals(DateUtils.parseDate("Mon, 11 Jun 2012 15:38:25 GMT"), object.getDeleteAtAsDate());
 }
 protected void prepareBytes(byte[] bytes, String md5) {
   expectStatusCode(200, false);
   prepareHeader(
       response,
       AbstractDownloadObjectCommand.ETAG,
       md5 == null ? DigestUtils.md5Hex(bytes) : md5);
   prepareHeader(
       response, AbstractDownloadObjectCommand.CONTENT_LENGTH, Long.toString(bytes.length));
   httpEntity = new ByteArrayEntity(bytes);
   new NonStrictExpectations() {
     {
       response.getEntity();
       result = httpEntity;
     }
   };
 }
 @Test(expected = CommandException.class)
 public void checkWhetherANonExistingFileExistsButThrowAnotherError() {
   expectStatusCode(500);
   object.exists();
 }
 @Test
 public void checkWhetherANonExistingFileExists() {
   expectStatusCode(404);
   assertFalse(object.exists());
 }
 @Test
 public void deleteObject() {
   expectStatusCode(204);
   object.delete();
 }