private static void verifyMetadata(String metadataValue, AtmosObject getBlob) { assertEquals(getBlob.getContentMetadata().getContentLength(), new Long(16)); assert getBlob.getContentMetadata().getContentType().startsWith("text/plain"); assertEquals(getBlob.getUserMetadata().getMetadata().get("Metadata"), metadataValue); SystemMetadata md = getBlob.getSystemMetadata(); assertEquals(md.getSize(), 16); assert md.getGroupID() != null; assertEquals(md.getHardLinkCount(), 1); assert md.getInceptionTime() != null; assert md.getLastAccessTime() != null; assert md.getLastMetadataModification() != null; assert md.getLastUserDataModification() != null; assert md.getObjectID() != null; assertEquals(md.getObjectName(), "object"); assert md.getPolicyName() != null; assertEquals(md.getType(), FileType.REGULAR); assert md.getUserID() != null; try { Utils.toStringAndClose( URI.create( "http://accesspoint.emccis.com/rest/objects/" + getBlob.getSystemMetadata().getObjectID()) .toURL() .openStream()); assert false : "shouldn't have worked, since it is private"; } catch (IOException e) { } }
private void createOrReplaceObject(String name, Object data, String metadataValue) throws Exception { // Test PUT with string data, ETag hash, and a piece of metadata AtmosObject object = connection.newObject(); object.getContentMetadata().setName(name); object.setData(data); object.getContentMetadata().setContentLength(16); object.generateMD5(); object.getContentMetadata().setContentType("text/plain"); object.getUserMetadata().getMetadata().put("Metadata", metadataValue); replaceObject(object); }
private void alwaysDeleteFirstReplaceStrategy(AtmosObject object) throws Exception { deleteConfirmed(privateDirectory + "/" + object.getContentMetadata().getName()); long time = System.currentTimeMillis(); try { connection.createFile(privateDirectory, object); System.err.printf( "%s %s; %dms%n", "created", object.getData() instanceof InputStream ? "stream" : "string", System.currentTimeMillis() - time); } catch (Exception e) { String message = (e.getCause().getCause() != null) ? e.getCause().getCause().getMessage() : e.getCause().getMessage(); System.err.printf( "failure %s %s; %dms: [%s]%n", "creating", object.getData() instanceof InputStream ? "stream" : "string", System.currentTimeMillis() - time, message); throw e; } }