Skip to content

Commit 934f67f

Browse files
committed
[ISSUE #9439]:Add test
1 parent 341d4ef commit 934f67f

1 file changed

Lines changed: 39 additions & 0 deletions

File tree

common/src/test/java/org/apache/rocketmq/common/MixAllTest.java

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,4 +85,43 @@ public void testIsLmq() {
8585
testLmq = "%LMQ%GID_TEST";
8686
assertThat(MixAll.isLmq(testLmq)).isTrue();
8787
}
88+
89+
@Test
90+
public void testAdjustConfigForPlatform_OnWindows() {
91+
if(MixAll.isWindows()) {
92+
String configWithSingleBackslash = "data\\path\\config\\file.properties";
93+
String adjusted = MixAll.adjustConfigForPlatform(configWithSingleBackslash);
94+
assertThat(adjusted).isEqualTo("data\\\\path\\\\config\\\\file.properties");
95+
96+
String configWithMultipleBackslashes = "C:\\\\RocketMQ\\\\logs\\\\broker.log";
97+
adjusted = MixAll.adjustConfigForPlatform(configWithMultipleBackslashes);
98+
assertThat(adjusted).isEqualTo("C:\\\\\\\\RocketMQ\\\\\\\\logs\\\\\\\\broker.log");
99+
100+
String configWithoutBackslash = "listenPort=10911";
101+
adjusted = MixAll.adjustConfigForPlatform(configWithoutBackslash);
102+
assertThat(adjusted).isEqualTo("listenPort=10911");
103+
104+
String emptyConfig = "";
105+
adjusted = MixAll.adjustConfigForPlatform(emptyConfig);
106+
assertThat(adjusted).isEqualTo("");
107+
108+
adjusted = MixAll.adjustConfigForPlatform(null);
109+
assertThat(adjusted).isNull();
110+
} else {
111+
String configWithSingleBackslash = "/home/rocketmq/conf/broker.conf";
112+
String adjusted = MixAll.adjustConfigForPlatform(configWithSingleBackslash);
113+
assertThat(adjusted).isEqualTo("/home/rocketmq/conf/broker.conf");
114+
115+
String linuxPathWithBackslash = "some\\directory\\file.txt";
116+
adjusted = MixAll.adjustConfigForPlatform(linuxPathWithBackslash);
117+
assertThat(adjusted).isEqualTo("some\\directory\\file.txt");
118+
119+
String emptyConfig = "";
120+
adjusted = MixAll.adjustConfigForPlatform(emptyConfig);
121+
assertThat(adjusted).isEqualTo("");
122+
123+
adjusted = MixAll.adjustConfigForPlatform(null);
124+
assertThat(adjusted).isNull();
125+
}
126+
}
88127
}

0 commit comments

Comments
 (0)