/** * @return Return a transaction with the current value. */ private Transaction current() { return new Transaction() .throwExceptions(throwExceptions) .threadPattern(threadPattern.toString()) .bootStrapDelay(bootstrapDelay); }
private void applyProperties(Properties prop) { Boolean debug = Boolean.parseBoolean(getValue(KEY_DEBUG, DEFAULT_DEBUG, prop)); tx.debug(debug); tx.bootStrapMode(ReactiveAudit.BootStrapMode.valueOf(getValue(KEY_BOOTSTRAP_MODE, DEFAULT_BOOTSTRAP_MODE, prop).toUpperCase())); tx.bootStrapCPUDelay(Long.parseLong(getValue(KEY_BOOTSTRAP_CPUDELAY, DEFAULT_BOOTSTRAP_CPUDELAY, prop))); tx.bootStrapDelay(Long.parseLong(getValue(KEY_BOOTSTRAP_DELAY, DEFAULT_BOOTSTRAP_DELAY, prop))); tx.throwExceptions(Boolean.parseBoolean(getValue(KEY_THROW_EXCEPTIONS, DEFAULT_THROW_EXCEPTIONS, prop))); tx.latencyFile(getValue(KEY_FILE_LATENCY, DEFAULT_FILE_LATENCY, prop)); tx.latencyNetwork(getValue(KEY_NETWORK_LATENCY, DEFAULT_NETWORK_LATENCY, prop)); tx.latencyCPU(getValue(KEY_CPU_LATENCY, DEFAULT_CPU_LATENCY, prop)); tx.logOutput(getValue(KEY_LOG_OUTPUT, DEFAULT_LOG_OUTPUT, prop), getValue(KEY_LOG_FORMAT, DEFAULT_LOG_FORMAT, prop), getValue(KEY_LOG_SIZE, DEFAULT_LOG_SIZE, prop)); String threadPattern = getValue(KEY_THREAD_PATTERN, DEFAULT_THREAD_PATTERN, prop); if (threadPattern.length() == 0) // Empty is not allowed threadPattern = "(^.*$)"; tx.threadPattern(threadPattern); tx.commit(); }
.threadPattern(".*") .latencyFile("LOW") .throwExceptions(false)
config.begin() .throwExceptions(true) .threadPattern("") .latencyFile("high") .latencyNetwork("medium") config.begin() .throwExceptions(false) .threadPattern("abc") .latencyFile("") .latencyNetwork("")
@Test public void logIfNewLoop() { config.reset(); config.begin() .threadPattern(".*") .logOutput(LoadParams.DEFAULT_LOG_OUTPUT,LoadParams.DEFAULT_LOG_FORMAT,LoadParams.DEFAULT_LOG_SIZE) .latencyFile("LOW") .throwExceptions(false) .commit(); try { addHandler(); for (int i = 0; i < 5; ++i) { log[0] = 0; latencyCall1(); if (i == 0) assertEquals(1, log[0]); else assertEquals(0, log[0]); } } finally { removeHandler(); } }
@Test(expected = IllegalArgumentException.class) public void lockTransaction() { config.reset(); config.begin() .seal() .threadPattern("abc"); }
@Test public void currentThread_nothing() { config.begin().threadPattern("(?!)").commit(); assertFalse(config.isThreadNameMatch(Thread.currentThread().getName())); }