|
9 | 9 |
|
10 | 10 | import java.io.IOException; |
11 | 11 | import java.net.URISyntaxException; |
| 12 | +import java.nio.channels.SeekableByteChannel; |
| 13 | +import java.nio.file.Files; |
| 14 | +import java.nio.file.Path; |
| 15 | +import java.nio.file.StandardOpenOption; |
12 | 16 | import java.security.SignatureException; |
| 17 | +import java.util.UUID; |
13 | 18 |
|
| 19 | +import com.spectralogic.ds3client.commands.*; |
| 20 | +import com.spectralogic.ds3client.helpers.Ds3ClientHelpers; |
| 21 | +import com.spectralogic.ds3client.models.bulk.JobStatus; |
14 | 22 | import org.junit.BeforeClass; |
15 | 23 | import org.junit.Test; |
16 | 24 |
|
17 | 25 | import com.spectralogic.ds3client.Ds3Client; |
18 | | -import com.spectralogic.ds3client.commands.DeleteBucketRequest; |
19 | | -import com.spectralogic.ds3client.commands.GetBucketRequest; |
20 | | -import com.spectralogic.ds3client.commands.GetBucketResponse; |
21 | | -import com.spectralogic.ds3client.commands.HeadBucketRequest; |
22 | | -import com.spectralogic.ds3client.commands.HeadBucketResponse; |
23 | | -import com.spectralogic.ds3client.commands.PutBucketRequest; |
24 | 26 | import com.spectralogic.ds3client.models.ListBucketResult; |
25 | 27 | import com.spectralogic.ds3client.networking.FailedRequestException; |
26 | 28 | import com.spectralogic.ds3client.serializer.XmlProcessingException; |
@@ -105,6 +107,38 @@ public void listContents() throws IOException, SignatureException, |
105 | 107 | } |
106 | 108 | } |
107 | 109 |
|
| 110 | + @Test |
| 111 | + public void getContents() throws IOException, SignatureException, URISyntaxException, XmlProcessingException { |
| 112 | + final String bucketName = "test_get_contents"; |
| 113 | + |
| 114 | + try { |
| 115 | + client.putBucket(new PutBucketRequest(bucketName)); |
| 116 | + Util.loadBookTestData(client, bucketName); |
| 117 | + |
| 118 | + final Ds3ClientHelpers helpers = Ds3ClientHelpers.wrap(client); |
| 119 | + |
| 120 | + final Ds3ClientHelpers.Job job = helpers.startReadAllJob(bucketName); |
| 121 | + |
| 122 | + final UUID jobId = job.getJobId(); |
| 123 | + |
| 124 | + job.transfer(new Ds3ClientHelpers.ObjectChannelBuilder() { |
| 125 | + @Override |
| 126 | + public SeekableByteChannel buildChannel(final String key) throws IOException { |
| 127 | + |
| 128 | + final Path filePath = Files.createTempFile("ds3", key); |
| 129 | + |
| 130 | + return Files.newByteChannel(filePath, StandardOpenOption.DELETE_ON_CLOSE, StandardOpenOption.WRITE); |
| 131 | + } |
| 132 | + }); |
| 133 | + |
| 134 | + final GetJobResponse jobResponse = client.getJob(new GetJobRequest(jobId)); |
| 135 | + assertThat(jobResponse.getMasterObjectList().getStatus(), is(JobStatus.COMPLETED)); |
| 136 | + |
| 137 | + } finally { |
| 138 | + Util.deleteAllContents(client, bucketName); |
| 139 | + } |
| 140 | + } |
| 141 | + |
108 | 142 | @Test |
109 | 143 | public void negativeDeleteNonEmptyBucket() throws IOException, |
110 | 144 | SignatureException, XmlProcessingException, URISyntaxException { |
|
0 commit comments