use of com.icodici.universa.node2.Config in project jdk8u_jdk by JetBrains.
the class Duplicates method main.
public static void main(String[] args) throws Exception {
System.setProperty("java.security.krb5.conf", System.getProperty("test.src", ".") + "/k1.conf");
Config config = Config.getInstance();
config.listTable();
String s;
// Latter overwrites former for root section
s = config.get("libdefaults", "default_realm");
if (s != null) {
throw new Exception();
}
// Latter overwrites former for strings
s = config.get("libdefaults", "default_tkt_enctypes");
if (!s.equals("aes256-cts")) {
throw new Exception();
}
// Latter overwrites former for sub-section
s = config.get("realms", "R1", "kdc");
if (!s.equals("k2")) {
throw new Exception(s);
}
// Duplicate keys in [realms] are merged
s = config.getAll("realms", "R2", "kdc");
if (!s.equals("k1 k2 k3 k4")) {
throw new Exception(s);
}
// Duplicate keys in [capaths] are merged
s = config.getAll("capaths", "R1", "R2");
if (!s.equals("R3 R4 R5 R6")) {
throw new Exception(s);
}
// We can be very deep now
s = config.get("new", "x", "y", "z", "a", "b", "c");
if (!s.equals("d")) {
throw new Exception(s);
}
}
use of com.icodici.universa.node2.Config in project controller by opendaylight.
the class TracingBrokerTest method testPrintOpenTransactions.
@Test
// Finding resource leaks is the point of this test
@SuppressWarnings({ "resource", "unused" })
public void testPrintOpenTransactions() {
DOMDataBroker domDataBroker = mock(DOMDataBroker.class, RETURNS_DEEP_STUBS);
Config config = new ConfigBuilder().setTransactionDebugContextEnabled(true).build();
BindingNormalizedNodeSerializer codec = mock(BindingNormalizedNodeSerializer.class);
TracingBroker tracingBroker = new TracingBroker(domDataBroker, config, codec);
DOMDataReadWriteTransaction tx = tracingBroker.newReadWriteTransaction();
DOMTransactionChain txChain = tracingBroker.createTransactionChain(null);
DOMDataReadWriteTransaction txFromChain = txChain.newReadWriteTransaction();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PrintStream ps = new PrintStream(baos);
boolean printReturnValue = tracingBroker.printOpenTransactions(ps);
String output = new String(baos.toByteArray(), UTF_8);
assertThat(printReturnValue).isTrue();
// Assert expections about stack trace
assertThat(output).contains("testPrintOpenTransactions(TracingBrokerTest.java");
assertThat(output).doesNotContain(TracingBroker.class.getName());
String previousLine = "";
for (String line : output.split("\n")) {
if (line.contains("(...")) {
assertThat(previousLine.contains("(...)")).isFalse();
}
previousLine = line;
}
// We don't do any verify/times on the mocks,
// because the main point of the test is just to verify that
// printOpenTransactions runs through without any exceptions
// (e.g. it used to have a ClassCastException).
}
use of com.icodici.universa.node2.Config in project universa by UniversaBlockchain.
the class SlotContractTest method beforeClass.
@BeforeClass
public static void beforeClass() throws Exception {
nodeConfig = new Config();
nodeConfig.addTransactionUnitsIssuerKeyData(new KeyAddress("Zau3tT8YtDkj3UDBSznrWHAjbhhU4SXsfQLWDFsv5vw24TLn6s"));
}
use of com.icodici.universa.node2.Config in project universa by UniversaBlockchain.
the class FollowerContractTest method beforeClass.
@BeforeClass
public static void beforeClass() throws Exception {
nodeConfig = new Config();
nodeConfig.addTransactionUnitsIssuerKeyData(new KeyAddress("Zau3tT8YtDkj3UDBSznrWHAjbhhU4SXsfQLWDFsv5vw24TLn6s"));
}
use of com.icodici.universa.node2.Config in project universa by UniversaBlockchain.
the class Main method startNode.
private void startNode() throws SQLException, IOException {
// Minimum size of network is 10. Smaller configurations are treated as test networks.
// For such configurations we are using table data rather than formula
config.setConsensusConfigUpdater((config, n) -> {
int negative;
int positive;
if (n < 3) {
negative = 1;
positive = n;
} else if (n < 10) {
negative = 2;
positive = n - 1;
} else {
positive = (int) Math.ceil(n * 0.9);
negative = n + 1 - positive;
}
int resyncBreak = (int) Math.ceil(n * 0.2);
if (resyncBreak < 1)
resyncBreak = 1;
if (resyncBreak + positive == n)
resyncBreak += 1;
log(myInfo.getNumber() + ": Network consensus is set to (negative/positive/resyncBreak): " + negative + " / " + positive + " / " + resyncBreak);
config.setPositiveConsensus(positive);
config.setNegativeConsensus(negative);
config.setResyncBreakConsensus(resyncBreak);
});
network = new NetworkV2(netConfig, myInfo, nodeKey);
node = new Node(config, myInfo, ledger, network, nodeKey, new File(configRoot + "/config/contracts"));
cache = node.getCache();
parcelCache = node.getParcelCache();
paidOperationCache = node.getPaidOperationCache();
envCache = node.getEnvCache();
StateRecord r = ledger.getRecord(HashId.withDigest("bS/c4YMidaVuzTBhHLkGPFAvPbZQHybzQnXAoBwaZYM8eLYb7mAkVYEpuqKRXYc7anqX47BeNdvFN1n7KluH9A=="));
if (r != null)
r.destroy();
clientHTTPServer.setConfig(config);
clientHTTPServer.setNode(node);
clientHTTPServer.setCache(cache);
clientHTTPServer.setParcelCache(parcelCache);
clientHTTPServer.setPaidOperationCache(paidOperationCache);
clientHTTPServer.setEnvCache(envCache);
clientHTTPServer.setLocalCors(myInfo.getPublicHost().equals("localhost"));
}
Aggregations