> +      assertThat(api.describeJob(VAULT_NAME, 
> inventoryRetrievalJob).getStatusCode()).isEqualTo(JobStatus.SUCCEEDED);
> +   }
> +
> +   @Test(groups = {"live", "livelong", "longtest"}, dependsOnMethods = 
> {"testWaitForSucceed"})
> +   public void testGetJobOutput() throws IOException {
> +      InputStream inputStream = api.getJobOutput(VAULT_NAME, 
> archiveRetrievalJob).openStream();
> +      try {
> +         InputStream expectedInputStream = buildData(PART_SIZE * 2 * 
> MiB).openStream();
> +         try {
> +            assertThat(inputStream).hasContentEqualTo(expectedInputStream);
> +         } finally {
> +            expectedInputStream.close();
> +         }
> +      } finally {
> +         inputStream.close();
> +      }

`Closer` helps write this more succinctly in Java 6 (Java 7 introduces 
try-with-resources):

```
Closer closer = Closer.create();
try {
   InputStream inputStream = closer.register(api.getJobOutput(VAULT_NAME, 
archiveRetrievalJob).openStream());
   InputStream expectedInputStream = closer.register(buildData(PART_SIZE * 2 * 
MiB).openStream());
   assertThat(inputStream).hasContentEqualTo(expectedInputStream);
} finally {
   closer.close();
}
```

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-aws/pull/41/files#r15323510

Reply via email to