@Test public void objectPersistedRegistration() throws IOException, SignatureException, URISyntaxException, XmlProcessingException { final String bucketName = "test_bucket"; try { client.putBucket(new PutBucketRequest(bucketName)); final Ds3ClientHelpers.Job job = Util.getLoadJob(client, bucketName, Util.RESOURCE_BASE_NAME); final NotificationResponse response = client.createObjectPersistedNotification( new CreateObjectPersistedNotificationRequest("192.168.56.101/other", job.getJobId())); assertThat(response, is(notNullValue())); assertThat(response.getRegistration(), is(notNullValue())); job.transfer(new ResourceObjectPutter(Util.RESOURCE_BASE_NAME)); final UUID registrationId = response.getRegistration().getId(); final NotificationResponse getResponse = client.getObjectPersistedNotification( new GetObjectPersistedNotificationRequest(registrationId)); assertThat(getResponse, is(notNullValue())); assertThat(getResponse.getRegistration(), is(notNullValue())); assertThat(getResponse.getRegistration().getId(), is(notNullValue())); assertThat( client.deleteObjectPersistedNotification( new DeleteObjectPersistedNotificationRequest(registrationId)), is(notNullValue())); } finally { Util.deleteAllContents(client, bucketName); } }
@Test public void objectOutputStreamBuilder_Test() throws IOException, URISyntaxException { // Retrieve the object on the BP using ObjectOutputStreamBuilder and verify contents final Ds3Object obj = new Ds3Object(OBJ_NAME, OBJ_BYTES.length); final Ds3ClientHelpers.Job job = HELPERS.startReadJob(BUCKET_NAME, Lists.newArrayList(obj)); final ByteArrayOutputStream stream = new ByteArrayOutputStream(); job.transfer( new ObjectOutputStreamBuilder() { @Override public OutputStream buildOutputStream(final String key) throws IOException { return stream; } }); assertThat(stream.toByteArray(), is(OBJ_BYTES)); }
@Before public void beforeRunningTestMethod() throws IOException { // Create a bucket and transfer object to BP using ObjectInputStreamBuilder HELPERS.ensureBucketExists(BUCKET_NAME, envDataPolicyId); final Ds3Object obj = new Ds3Object(OBJ_NAME, OBJ_BYTES.length); final Ds3ClientHelpers.Job job = HELPERS.startWriteJob(BUCKET_NAME, Lists.newArrayList(obj)); job.transfer( new ObjectInputStreamBuilder() { @Override public InputStream buildInputStream(final String key) { return new ByteArrayInputStream(OBJ_BYTES); } }); }