use of org.junit.experimental.theories.Theory in project spring-boot by spring-projects.
the class CounterServiceSpeedTests method raw.
@Theory
public void raw(String input) throws Exception {
iterate("writeRaw");
double rate = number / watch.getLastTaskTimeMillis() * 1000;
System.err.println("Rate(" + count + ")=" + rate + ", " + watch);
watch.start("readRaw" + count);
for (String name : names) {
this.counters.forEach(Pattern.compile(name).asPredicate(), new BiConsumer<String, CounterBuffer>() {
@Override
public void accept(String name, CounterBuffer value) {
err.println(name + "=" + value);
}
});
}
final LongAdder total = new LongAdder();
this.counters.forEach(Pattern.compile(".*").asPredicate(), new BiConsumer<String, CounterBuffer>() {
@Override
public void accept(String name, CounterBuffer value) {
total.add(value.getValue());
}
});
watch.stop();
System.err.println("Read(" + count + ")=" + watch.getLastTaskTimeMillis() + "ms");
assertThat(total.longValue()).isEqualTo(number * threadCount);
}
use of org.junit.experimental.theories.Theory in project spring-boot by spring-projects.
the class DefaultCounterServiceSpeedTests method counters.
@Theory
public void counters(String input) throws Exception {
watch.start("counters" + count++);
ExecutorService pool = Executors.newFixedThreadPool(threadCount);
Runnable task = new Runnable() {
@Override
public void run() {
for (int i = 0; i < number; i++) {
String name = sample[i % sample.length];
DefaultCounterServiceSpeedTests.this.counterService.increment(name);
}
}
};
Collection<Future<?>> futures = new HashSet<>();
for (int i = 0; i < threadCount; i++) {
futures.add(pool.submit(task));
}
for (Future<?> future : futures) {
future.get();
}
watch.stop();
double rate = number / watch.getLastTaskTimeMillis() * 1000;
System.err.println("Counters rate(" + count + ")=" + rate + ", " + watch);
watch.start("read" + count);
this.reader.findAll().forEach(new Consumer<Metric<?>>() {
@Override
public void accept(Metric<?> metric) {
err.println(metric);
}
});
final LongAdder total = new LongAdder();
this.reader.findAll().forEach(new Consumer<Metric<?>>() {
@Override
public void accept(Metric<?> value) {
total.add(value.getValue().intValue());
}
});
watch.stop();
System.err.println("Read(" + count + ")=" + watch.getLastTaskTimeMillis() + "ms");
assertThat(total.longValue()).isEqualTo(number * threadCount);
}
use of org.junit.experimental.theories.Theory in project RoboBinding by RoboBinding.
the class ValueModelAttributeTest method whenCreateWithLegalAttributeValue_thenReturnAttributeWithCorrectContents.
@Theory
public void whenCreateWithLegalAttributeValue_thenReturnAttributeWithCorrectContents(LegalValueModelAttributeValue legalAttributeValue) {
ValueModelAttribute attribute = aValueModelAttribute(legalAttributeValue.value);
assertThat(attribute.getPropertyName(), equalTo(legalAttributeValue.expectedPropertyName));
assertThat(attribute.isTwoWayBinding(), equalTo(legalAttributeValue.expectedIsTwoWayBinding()));
}
use of org.junit.experimental.theories.Theory in project RoboBinding by RoboBinding.
the class RowLayoutAttributeFactoryTest method shouldCreateExpectedLayoutAttribute.
@Theory
public void shouldCreateExpectedLayoutAttribute(RowLayoutAttributeExpectation expectation) {
ChildViewAttribute viewAttribute = rowLayoutAttributeFactory.createRowLayoutAttribute(expectation.propertyAttribute);
expectation.assertLayoutAttributeType(viewAttribute);
}
use of org.junit.experimental.theories.Theory in project neo4j by neo4j.
the class PrimitiveCollectionEqualityTest method addingDifferentValuesMustProduceUnequalCollections.
@Theory
public void addingDifferentValuesMustProduceUnequalCollections(ValueProducer values, Factory<PrimitiveCollection> factoryA, Factory<PrimitiveCollection> factoryB) {
assumeTrue(values.isApplicable(factoryA));
assumeTrue(values.isApplicable(factoryB));
try (PrimitiveCollection a = factoryA.newInstance();
PrimitiveCollection b = factoryB.newInstance()) {
values.randomValue().add(a);
values.randomValue().add(b);
assertNotEquals(a, b);
}
}
Aggregations