SystemProperties { protected Config mergeConfigs(String input, Function<String, Config> parserFunc) { Config config = ConfigFactory.empty(); if (input != null && !input.isEmpty()) { String[] list = input.split(","); for (int i = list.length - 1; i >= 0; --i) { config = config.withFallback(parserFunc.apply(list[i])); } } return config; } SystemProperties();  SystemProperties(File configFile);  SystemProperties(String configResource);  SystemProperties(Config apiConfig);  SystemProperties(Config apiConfig, ClassLoader classLoader); static SystemProperties getDefault(); static void resetToDefault(); static void setUseOnlySpringConfig(boolean useOnlySpringConfig); static List<InputStream> loadResources(
            final String name, final ClassLoader classLoader); Config getConfig(); void overrideParams(Config overrideOptions); void overrideParams(String ... keyValuePairs); void overrideParams(Map<String, ?> cliOptions); T getProperty(String propName, T defaultValue); BlockchainNetConfig getBlockchainConfig(); void setBlockchainConfig(BlockchainNetConfig config); @ValidateMe boolean peerDiscovery(); void setDiscoveryEnabled(Boolean discoveryEnabled); @ValidateMe boolean peerDiscoveryPersist(); @ValidateMe int peerDiscoveryWorkers(); @ValidateMe int peerDiscoveryTouchPeriod(); @ValidateMe int peerDiscoveryTouchMaxNodes(); @ValidateMe int peerConnectionTimeout(); @ValidateMe int defaultP2PVersion(); @ValidateMe int rlpxMaxFrameSize(); @ValidateMe int transactionApproveTimeout(); @ValidateMe List<String> peerDiscoveryIPList(); @ValidateMe boolean databaseReset(); void setDatabaseReset(Boolean reset); @ValidateMe long databaseResetBlock(); @ValidateMe boolean databaseFromBackup(); @ValidateMe int databasePruneDepth(); @ValidateMe List<Node> peerActive(); @ValidateMe NodeFilter peerTrusted(); @ValidateMe Integer blockQueueSize(); @ValidateMe Integer headerQueueSize(); @ValidateMe Integer peerChannelReadTimeout(); @ValidateMe Integer traceStartBlock(); @ValidateMe boolean recordBlocks(); @ValidateMe boolean dumpFull(); @ValidateMe String dumpDir(); @ValidateMe String dumpStyle(); @ValidateMe int dumpBlock(); @ValidateMe String databaseDir(); String ethashDir(); void setDataBaseDir(String dataBaseDir); @ValidateMe boolean dumpCleanOnRestart(); @ValidateMe boolean playVM(); @ValidateMe boolean blockChainOnly(); @ValidateMe int syncPeerCount(); Integer syncVersion(); @ValidateMe boolean exitOnBlockConflict(); @ValidateMe String projectVersion(); @ValidateMe Integer databaseVersion(); @ValidateMe String projectVersionModifier(); @ValidateMe String helloPhrase(); @ValidateMe String rootHashStart(); @ValidateMe List<String> peerCapabilities(); @ValidateMe boolean vmTrace(); @ValidateMe boolean vmTraceCompressed(); @ValidateMe int vmTraceInitStorageLimit(); @ValidateMe int cacheFlushBlocks(); @ValidateMe String vmTraceDir(); String customSolcPath(); String privateKey(); ECKey getMyKey(); byte[] nodeId(); @ValidateMe int networkId(); @ValidateMe int maxActivePeers(); @ValidateMe boolean eip8(); @ValidateMe int listenPort(); String bindIp(); String externalIp(); @ValidateMe String getKeyValueDataSource(); @ValidateMe boolean isSyncEnabled(); void setSyncEnabled(Boolean syncEnabled); @ValidateMe boolean isFastSyncEnabled(); @ValidateMe byte[] getFastSyncPivotBlockHash(); @ValidateMe boolean fastSyncBackupState(); @ValidateMe boolean fastSyncSkipHistory(); @ValidateMe int makeDoneByTimeout(); @ValidateMe boolean isPublicHomeNode(); @ValidateMe String genesisInfo(); @ValidateMe int txOutdatedThreshold(); void setGenesisInfo(String genesisInfo); @ValidateMe boolean minerStart(); @ValidateMe byte[] getMinerCoinbase(); @ValidateMe byte[] getMineExtraData(); @ValidateMe BigInteger getMineMinGasPrice(); @ValidateMe long getMineMinBlockTimeoutMsec(); @ValidateMe int getMineCpuThreads(); @ValidateMe boolean isMineFullDataset(); @ValidateMe String getCryptoProviderName(); @ValidateMe boolean recordInternalTransactionsData(); void setRecordInternalTransactionsData(Boolean recordInternalTransactionsData); @ValidateMe String getHash256AlgName(); @ValidateMe String getHash512AlgName(); @ValidateMe String getEthashMode(); Genesis getGenesis(); Genesis useGenesis(InputStream inputStream); String dump(); boolean vmTestLoadLocal(); String blocksLoader(); String githubTestsPath(); boolean githubTestsLoadLocal(); final static String PROPERTY_DB_DIR; final static String PROPERTY_LISTEN_PORT; final static String PROPERTY_PEER_ACTIVE; final static String PROPERTY_DB_RESET; final static String PROPERTY_PEER_DISCOVERY_ENABLED; }
@Test public void testMergeConfigs1() { String firstConfig = ""; SystemProperties props = new SystemProperties(); Config config = props.mergeConfigs(firstConfig, ConfigFactory::parseString); assertFalse(config.hasPath("peer.listen.port")); }
@Test public void testMergeConfigs2() { String firstConfig = "peer.listen.port=30123"; SystemProperties props = new SystemProperties(); Config config = props.mergeConfigs(firstConfig, ConfigFactory::parseString); assertEquals(30123, config.getInt("peer.listen.port")); }
@Test public void testMergeConfigs3() { String firstConfig = "peer.listen.port=30123,peer.listen.port=30145"; SystemProperties props = new SystemProperties(); Config config = props.mergeConfigs(firstConfig, ConfigFactory::parseString); assertEquals(30145, config.getInt("peer.listen.port")); }
@Test public void testMergeConfigs4() { String firstConfig = "peer.listen.port=30123,sync.enabled=true"; SystemProperties props = new SystemProperties(); Config config = props.mergeConfigs(firstConfig, ConfigFactory::parseString); assertEquals(30123, config.getInt("peer.listen.port")); assertEquals(Boolean.TRUE, config.getBoolean("sync.enabled")); }