Skip to content

Commit 6c42c68

Browse files
authored
Merge pull request #199 from mercyblitz/dev
Fix the issues from the code-review
2 parents 70770cf + 8b07ae3 commit 6c42c68

2 files changed

Lines changed: 10 additions & 9 deletions

File tree

microsphere-java-core/src/test/java/io/microsphere/io/FileUtilsTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import static java.util.concurrent.Executors.newFixedThreadPool;
3535
import static java.util.concurrent.Executors.newSingleThreadExecutor;
3636
import static java.util.concurrent.TimeUnit.MILLISECONDS;
37+
import static java.util.concurrent.TimeUnit.SECONDS;
3738
import static org.junit.jupiter.api.Assertions.assertEquals;
3839
import static org.junit.jupiter.api.Assertions.assertFalse;
3940
import static org.junit.jupiter.api.Assertions.assertNotNull;
@@ -116,11 +117,10 @@ void testDeleteDirectoryOnIOException() throws Exception {
116117
ExecutorService executor = newSingleThreadExecutor();
117118
executor.submit(this::testDeleteDirectoryOnIOException0);
118119
shutdown(executor);
119-
while (!executor.isTerminated()) {
120-
}
120+
executor.awaitTermination(5, SECONDS);
121121
}
122122

123-
Void testDeleteDirectoryOnIOException0() throws Exception {
123+
File testDeleteDirectoryOnIOException0() throws Exception {
124124
File testDir = createRandomTempDirectory();
125125

126126
ExecutorService fileCreationExecutor = newSingleThreadExecutor();
@@ -170,7 +170,7 @@ Void testDeleteDirectoryOnIOException0() throws Exception {
170170
assertFalse(creatingFile.get());
171171
assertFalse(deletingDirectory.get());
172172

173-
return null;
173+
return testDir;
174174
}
175175

176176
@Test

microsphere-java-core/src/test/java/io/microsphere/util/StringUtilsTest.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,13 @@ void testSplit() {
111111

112112
String[] assertSplit(String str, String delimiter) {
113113
String[] values = split(str, delimiter);
114-
if (length(delimiter) == 1) {
114+
int length = length(delimiter);
115+
if (length == 1) {
115116
assertArrayEquals(split(str, delimiter.charAt(0)), values);
117+
} else if (length > 1) {
118+
String[] valuesFromString = delimitedListToStringArray(str, delimiter);
119+
assertArrayEquals(valuesFromString, values);
116120
}
117-
String[] valuesFromString = delimitedListToStringArray(str, delimiter);
118-
assertArrayEquals(valuesFromString, values);
119121
return values;
120122
}
121123

@@ -177,11 +179,10 @@ void testEndsWith() {
177179
@Test
178180
void testReplace() {
179181
assertNull(replace(null, null, null));
182+
180183
assertEquals(TEST_EMPTY_STRING, replace(TEST_EMPTY_STRING, null, null));
181184
assertEquals(TEST_EMPTY_STRING, replace(TEST_EMPTY_STRING, "null", null));
182185
assertEquals(TEST_CSV_STRING, replace(TEST_CSV_STRING, "null", "null"));
183-
184-
assertEquals(TEST_EMPTY_STRING, replace(TEST_EMPTY_STRING, null, null));
185186
assertEquals(TEST_EMPTY_STRING, replace(TEST_EMPTY_STRING, TEST_EMPTY_STRING, null));
186187
assertEquals(TEST_EMPTY_STRING, replace(TEST_EMPTY_STRING, TEST_EMPTY_STRING, TEST_EMPTY_STRING, 0));
187188

0 commit comments

Comments
 (0)