You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by he...@apache.org on 2022/06/27 12:52:31 UTC

[brooklyn-server] 02/02: fix windows portability using streams rather than toURI

This is an automated email from the ASF dual-hosted git repository.

heneveld pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/brooklyn-server.git

commit e027d155ec346c4f8bb62b14af892043aa01bfba
Author: Alex Heneveld <al...@cloudsoft.io>
AuthorDate: Mon Jun 27 13:52:07 2022 +0100

    fix windows portability using streams rather than toURI
---
 .../test/java/org/apache/brooklyn/util/io/FileUtilTest.java | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/utils/common/src/test/java/org/apache/brooklyn/util/io/FileUtilTest.java b/utils/common/src/test/java/org/apache/brooklyn/util/io/FileUtilTest.java
index e00e589c19..de84a6466f 100644
--- a/utils/common/src/test/java/org/apache/brooklyn/util/io/FileUtilTest.java
+++ b/utils/common/src/test/java/org/apache/brooklyn/util/io/FileUtilTest.java
@@ -33,6 +33,7 @@ import com.google.common.io.Files;
 
 import org.apache.brooklyn.util.os.Os;
 import org.apache.brooklyn.util.stream.InputStreamSource;
+import org.apache.brooklyn.util.stream.Streams;
 import org.testng.annotations.AfterMethod;
 import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
@@ -127,29 +128,25 @@ public class FileUtilTest {
 
     @Test
     public void testIsJavaFileText() throws IOException, URISyntaxException {
-        byte[] bytes = java.nio.file.Files.readAllBytes(
-               Paths.get(this.getClass().getClassLoader().getResource("brooklyn/osgi/brooklyn-osgi-test-a_0.1.0.txt").toURI()));
+        byte[] bytes = Streams.readFully(getClass().getResourceAsStream("/brooklyn/osgi/brooklyn-osgi-test-a_0.1.0.txt"));
         assertFalse(FileUtil.doesZipContainJavaBinaries(InputStreamSource.of("Test bom file", bytes)));
     }
 
     @Test
     public void testIsJavaNoClassesJar() throws IOException, URISyntaxException {
-        byte[] bytes = java.nio.file.Files.readAllBytes(
-                Paths.get(this.getClass().getClassLoader().getResource("brooklyn/files/testNoJava-0.1.0-SNAPSHOT.jar").toURI()));
+        byte[] bytes = Streams.readFully(getClass().getResourceAsStream("/brooklyn/files/testNoJava-0.1.0-SNAPSHOT.jar"));
         assertFalse(FileUtil.doesZipContainJavaBinaries(InputStreamSource.of("Test Jar without Java classes", bytes)));
     }
 
     @Test
     public void testIsFakeJavaWithClassesJar() throws IOException, URISyntaxException {
-        byte[] bytes = java.nio.file.Files.readAllBytes(
-                Paths.get(this.getClass().getClassLoader().getResource("brooklyn/files/testWithJava-0.1.0-SNAPSHOT.jar").toURI()));
+        byte[] bytes = Streams.readFully(getClass().getResourceAsStream("/brooklyn/files/testWithJava-0.1.0-SNAPSHOT.jar"));
         assertTrue(FileUtil.doesZipContainJavaBinaries(InputStreamSource.of("Test fail JAR with files renamed as .class", bytes)));
     }
 
     @Test
     public void testIsRealJavaFileText() throws IOException, URISyntaxException {
-        byte[] bytes = java.nio.file.Files.readAllBytes(
-                Paths.get(this.getClass().getClassLoader().getResource("brooklyn/osgi/brooklyn-osgi-test-a_0.1.0.jar").toURI()));
+        byte[] bytes = Streams.readFully(getClass().getResourceAsStream("/brooklyn/osgi/brooklyn-osgi-test-a_0.1.0.jar"));
         assertTrue(FileUtil.doesZipContainJavaBinaries(InputStreamSource.of("Test real JAR with Java classes", bytes)));
     }
 }