Skip to content

Commit

Permalink
fix: windows test failure in ConfigDefTest
Browse files Browse the repository at this point in the history
Signed-off-by: ZhangJian He <[email protected]>
  • Loading branch information
shoothzj committed Apr 9, 2024
1 parent 8fd32b5 commit 53ce6cc
Showing 1 changed file with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@
import static org.junit.Assert.assertTrue;

import com.google.common.collect.Lists;
import com.google.common.io.ByteStreams;
import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Iterator;
import java.util.Set;
import lombok.extern.slf4j.Slf4j;
Expand Down Expand Up @@ -280,11 +281,15 @@ public void testBuildConfigDef() {

@Test
public void testSaveConfigDef() throws IOException {
byte[] confData;
try (InputStream is = this.getClass().getClassLoader().getResourceAsStream("test_conf_2.conf")) {
confData = new byte[is.available()];
ByteStreams.readFully(is, confData);
StringBuilder sb = new StringBuilder();
try (InputStream is = this.getClass().getClassLoader().getResourceAsStream("test_conf_2.conf");
BufferedReader reader = new BufferedReader(new InputStreamReader(is, UTF_8))) {
String line;
while ((line = reader.readLine()) != null) {
sb.append(line).append(System.lineSeparator());
}
}
String confData = sb.toString();

ConfigDef configDef = ConfigDef.of(TestConfig2.class);
String readConf;
Expand All @@ -294,7 +299,7 @@ public void testSaveConfigDef() throws IOException {
log.info("\n{}", readConf);
}

assertEquals(new String(confData, UTF_8), readConf);
assertEquals(confData, readConf);
}

}

0 comments on commit 53ce6cc

Please sign in to comment.