diff --git a/google-cloud-clients/google-cloud-contrib/google-cloud-nio/src/test/java/com/google/cloud/storage/contrib/nio/CloudStorageReadTest.java b/google-cloud-clients/google-cloud-contrib/google-cloud-nio/src/test/java/com/google/cloud/storage/contrib/nio/CloudStorageReadTest.java index 3de6e8221156..ec62f54c1998 100644 --- a/google-cloud-clients/google-cloud-contrib/google-cloud-nio/src/test/java/com/google/cloud/storage/contrib/nio/CloudStorageReadTest.java +++ b/google-cloud-clients/google-cloud-contrib/google-cloud-nio/src/test/java/com/google/cloud/storage/contrib/nio/CloudStorageReadTest.java @@ -91,6 +91,9 @@ public void testInputStreamReads() throws IOException, InterruptedException { // reading past the end int eof = is.read(buf, 0, 1); assertWithMessage("EOF should return -1").that(eof).isEqualTo(-1); + } finally { + // clean up + Files.delete(p); } } } @@ -121,6 +124,9 @@ public void testChannelReads() throws IOException, InterruptedException { buf.clear(); int eof = chan.read(buf); assertWithMessage("EOF should return -1").that(eof).isEqualTo(-1); + } finally { + // clean up + Files.delete(p); } } } diff --git a/google-cloud-clients/google-cloud-contrib/google-cloud-nio/src/test/java/com/google/cloud/storage/contrib/nio/it/ITGcsNio.java b/google-cloud-clients/google-cloud-contrib/google-cloud-nio/src/test/java/com/google/cloud/storage/contrib/nio/it/ITGcsNio.java index 3b35352154cc..dfad90e9e681 100644 --- a/google-cloud-clients/google-cloud-contrib/google-cloud-nio/src/test/java/com/google/cloud/storage/contrib/nio/it/ITGcsNio.java +++ b/google-cloud-clients/google-cloud-contrib/google-cloud-nio/src/test/java/com/google/cloud/storage/contrib/nio/it/ITGcsNio.java @@ -527,6 +527,10 @@ public void testListFiles() throws IOException { got.add(path); } assertThat(got).containsExactlyElementsIn(goodPaths); + // clean up + for (Path path : paths) { + Files.delete(path); + } } } @@ -552,10 +556,12 @@ public void testDeleteRecursive() throws IOException { @Test public void testListFilesInRootDirectory() throws IOException { + // We must explicitly set the storageOptions, because the unit tests + // set the fake storage as default but we want to access the real storage. CloudStorageFileSystem fs = CloudStorageFileSystem.forBucket( BUCKET, CloudStorageConfiguration.builder().permitEmptyPathComponents(true) - .build()); - + .build(), storageOptions); + // test absolute path Path rootPath = fs.getPath(""); List objectNames = new ArrayList();