Remove ConnectionConfig console output

This commit is contained in:
Chris Beams 2019-12-20 15:52:02 +01:00
parent b5503a5aa4
commit 47794174a1
No known key found for this signature in database
GPG key ID: 3D214F8F5BC5ED73
2 changed files with 22 additions and 10 deletions

View file

@ -25,9 +25,6 @@ import java.io.UncheckedIOException;
import java.util.List;
import java.util.Optional;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ch.qos.logback.classic.Level;
import static java.lang.String.format;
@ -81,8 +78,6 @@ public class Config {
public static final String GENESIS_TOTAL_SUPPLY = "genesisTotalSupply";
public static final String DAO_ACTIVATED = "daoActivated";
private static final Logger log = LoggerFactory.getLogger(Config.class);
public static final int UNSPECIFIED_PORT = -1;
static final String DEFAULT_CONFIG_FILE_NAME = "bisq.properties";
public static final String DEFAULT_REGTEST_HOST = "localhost";
@ -596,11 +591,6 @@ public class Config {
this.msgThrottlePer10Sec = options.valueOf(msgThrottlePer10SecOpt);
this.sendMsgThrottleTrigger = options.valueOf(sendMsgThrottleTriggerOpt);
this.sendMsgThrottleSleep = options.valueOf(sendMsgThrottleSleepOpt);
// Preserve log output from now-removed ConnectionConfig class TODO: remove
log.info("ConnectionConfig{\n" +
" msgThrottlePerSec={},\n msgThrottlePer10Sec={},\n" +
" sendMsgThrottleTrigger={},\n sendMsgThrottleSleep={}\n}",
msgThrottlePerSec, msgThrottlePer10Sec, sendMsgThrottleTrigger, sendMsgThrottleSleep);
this.btcNodes = options.valueOf(btcNodesOpt);
this.useTorForBtc = options.valueOf(useTorForBtcOpt);
this.useTorForBtcOptionSetExplicitly = options.has(useTorForBtcOpt);

View file

@ -1,7 +1,9 @@
package bisq.common.config;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.PrintStream;
import java.io.PrintWriter;
import org.junit.Rule;
@ -13,6 +15,7 @@ import static java.lang.String.format;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.Matchers.contains;
import static org.hamcrest.Matchers.isEmptyString;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@ -165,4 +168,23 @@ public class ConfigTests {
new TestConfig("--help");
fail();
}
@Test
public void whenConfigIsConstructed_thenNoConsoleOutputSideEffectsShouldOccur() {
PrintStream outOrig = System.out;
PrintStream errOrig = System.err;
ByteArrayOutputStream outBytes = new ByteArrayOutputStream();
ByteArrayOutputStream errBytes = new ByteArrayOutputStream();
try (PrintStream outTest = new PrintStream(outBytes);
PrintStream errTest = new PrintStream(errBytes)) {
System.setOut(outTest);
System.setErr(errTest);
new Config();
assertThat(outBytes.toString(), isEmptyString());
assertThat(errBytes.toString(), isEmptyString());
} finally {
System.setOut(outOrig);
System.setErr(errOrig);
}
}
}