use of junitparams.Parameters in project aion by aionnetwork.
the class ConcurrencyTest method testConcurrentPutBatch.
@Test
@Parameters(method = "databaseInstanceDefinitions")
public void testConcurrentPutBatch(Properties dbDef) throws InterruptedException {
dbDef.setProperty("db_name", DatabaseTestUtils.dbName + getNext());
IByteArrayKeyValueDatabase db = DatabaseFactory.connect(dbDef);
assertThat(db.open()).isTrue();
// create distinct threads with
List<Runnable> threads = new ArrayList<>();
for (int i = 0; i < CONCURRENT_THREADS; i++) {
addThread4PutBatch(threads, db, "key-" + i);
}
// run threads
assertConcurrent("Testing putBatch(...) ", threads, TIME_OUT);
// check that all values were added
assertThat(db.keys().size()).isEqualTo(3 * CONCURRENT_THREADS);
// ensuring close
db.close();
assertThat(db.isClosed()).isTrue();
}
use of junitparams.Parameters in project aion by aionnetwork.
the class ConcurrencyTest method testConcurrentUpdate.
@Test
@Parameters(method = "databaseInstanceDefinitions")
public void testConcurrentUpdate(Properties dbDef) throws InterruptedException {
dbDef.setProperty("db_name", DatabaseTestUtils.dbName + getNext());
// open database
IByteArrayKeyValueDatabase db = DatabaseFactory.connect(dbDef);
assertThat(db.open()).isTrue();
// create distinct threads with
List<Runnable> threads = new ArrayList<>();
int threadSetCount = CONCURRENT_THREADS / 4;
if (threadSetCount < 3) {
threadSetCount = 3;
}
for (int i = 0; i < threadSetCount; i++) {
String keyStr = "key-" + i + ".";
// 1. thread that puts entry
addThread4Put(threads, db, keyStr);
// 2. thread that deletes entry
addThread4Delete(threads, db, keyStr);
// 3. thread that puts entries
addThread4PutBatch(threads, db, keyStr);
// 4. thread that deletes entry
addThread4DeleteBatch(threads, db, keyStr);
}
// run threads and check for exceptions
assertConcurrent("Testing concurrent updates. ", threads, TIME_OUT);
// check that db is unlocked after updates
assertThat(db.isLocked()).isFalse();
// ensuring close
db.close();
assertThat(db.isClosed()).isTrue();
}
use of junitparams.Parameters in project aion by aionnetwork.
the class ConcurrencyTest method testConcurrentPut.
@Test
@Parameters(method = "databaseInstanceDefinitions")
public void testConcurrentPut(Properties dbDef) throws InterruptedException {
dbDef.setProperty("db_name", DatabaseTestUtils.dbName + getNext());
IByteArrayKeyValueDatabase db = DatabaseFactory.connect(dbDef);
assertThat(db.open()).isTrue();
// create distinct threads with
List<Runnable> threads = new ArrayList<>();
for (int i = 0; i < CONCURRENT_THREADS; i++) {
addThread4Put(threads, db, "key-" + i);
}
// run threads
assertConcurrent("Testing put(...) ", threads, TIME_OUT);
// check that all values were added
assertThat(db.keys().size()).isEqualTo(CONCURRENT_THREADS);
// ensuring close
db.close();
assertThat(db.isClosed()).isTrue();
}
use of junitparams.Parameters in project protoman by spotify.
the class EnumDefaultValueTest method testAllowedName.
@Parameters(method = "allowedNames")
@Test
public void testAllowedName(final String name) throws Exception {
final DescriptorSet candidate = DescriptorSetUtils.buildDescriptorSet("a.proto", String.format(TEMPLATE, name));
final ImmutableList<ValidationViolation> violations = schemaValidator.validate(DescriptorSet.empty(), candidate);
assertThat(violations, is(empty()));
}
use of junitparams.Parameters in project protoman by spotify.
the class EnumNamingRuleTest method testAllowedName_existing.
@Parameters(method = "allowedNames")
@Test
public void testAllowedName_existing(final String name) throws Exception {
final DescriptorSet candidate = DescriptorSetUtils.buildDescriptorSet("a.proto", String.format(TEMPLATE, name));
final ImmutableList<ValidationViolation> violations = schemaValidator.validate(candidate, candidate);
assertThat(violations, is(empty()));
}
Aggregations