This is an automated email from the ASF dual-hosted git repository.
lizhanhui pushed a commit to branch bazel
in repository https://gitbox.apache.org/repos/asf/rocketmq.git
The following commit(s) were added to refs/heads/bazel by this push:
new ece4fff3f Bazel (#4877)
ece4fff3f is described below
commit ece4fff3f656b3d529b6ca4563524af2cd22706e
Author: Zhanhui Li <[email protected]>
AuthorDate: Wed Aug 24 11:15:01 2022 +0800
Bazel (#4877)
* Make test portable to Windows
* Fix label issues
* Fix trailing separator issue
* Fix java-io-tmpdir inconsistency
---
.../java/org/apache/rocketmq/acl/common/AclUtilsTest.java | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/acl/src/test/java/org/apache/rocketmq/acl/common/AclUtilsTest.java
b/acl/src/test/java/org/apache/rocketmq/acl/common/AclUtilsTest.java
index fd7f12cac..2956df9c1 100644
--- a/acl/src/test/java/org/apache/rocketmq/acl/common/AclUtilsTest.java
+++ b/acl/src/test/java/org/apache/rocketmq/acl/common/AclUtilsTest.java
@@ -210,9 +210,19 @@ public class AclUtilsTest {
}
}
+ private static String randomTmpFile() {
+ String tmpFileName = System.getProperty("java.io.tmpdir");
+ //
https://rationalpi.wordpress.com/2007/01/26/javaiotmpdir-inconsitency/
+ if (!tmpFileName.endsWith(File.separator)) {
+ tmpFileName += File.separator;
+ }
+ tmpFileName += UUID.randomUUID() + ".yml";
+ return tmpFileName;
+ }
+
@Test
public void writeDataObject2YamlFileTest() throws IOException {
- String targetFileName = System.getProperty("java.io.tmpdir") +
UUID.randomUUID() + ".yml";
+ String targetFileName = randomTmpFile();
File transport = new File(targetFileName);
Assert.assertTrue(transport.createNewFile());
transport.deleteOnExit();
@@ -242,7 +252,7 @@ public class AclUtilsTest {
@Test
public void updateExistedYamlFileTest() throws IOException {
- String targetFileName = System.getProperty("java.io.tmpdir") +
UUID.randomUUID() + ".yml";
+ String targetFileName = randomTmpFile();
File transport = new File(targetFileName);
Assert.assertTrue(transport.createNewFile());
transport.deleteOnExit();