use of teetime.framework.Configuration in project TeeTime by teetime-framework.
the class MultipleExecutionsProducerIT method testRegularExecution.
void testRegularExecution(final List<String> expectedElements, final int numThreads) {
for (int numOfExecutions = 1; numOfExecutions < expectedElements.size() + 1; numOfExecutions++) {
List<String> actualElements = new ArrayList<>();
Configuration configuration = new Configuration().from(new ResponsiveProducer<String>(expectedElements)).end(new CollectorSink<String>(actualElements));
GlobalTaskPoolScheduling scheduler = new GlobalTaskPoolScheduling(numThreads, configuration, numOfExecutions);
Execution<Configuration> execution = new Execution<>(configuration, true, scheduler);
execution.executeBlocking();
assertThat("failed with numOfExecutions=" + numOfExecutions, actualElements, is(equalTo(expectedElements)));
}
}
use of teetime.framework.Configuration in project TeeTime by teetime-framework.
the class ProducerConsumerGlobalTaskPoolIT method shouldExecuteProducerConsumer.
private void shouldExecuteProducerConsumer(final int numThreads, final int numExecutions) {
int numElements = 10_000;
List<Integer> processedElements = new ArrayList<>();
IntStream inputElements = IntStream.iterate(0, i -> i + 1).limit(numElements);
Configuration config = new Configuration().from(new StreamProducer<>(inputElements)).end(new CollectorSink<>(processedElements));
TeeTimeScheduler scheduling = new GlobalTaskPoolScheduling(numThreads, config, numExecutions);
Execution<Configuration> execution = new Execution<>(config, true, scheduling);
execution.executeBlocking();
for (int i = 0; i < numElements; i++) {
assertThat(processedElements.get(i), is(i));
}
assertThat(processedElements, hasSize(numElements));
}
use of teetime.framework.Configuration in project TeeTime by teetime-framework.
the class ThreeStagesGlobalTaskPoolIT method shouldExecutePipelineCorrectlyManyElements.
private void shouldExecutePipelineCorrectlyManyElements(final int numElements, final int numThreads, final int numExecutions) {
List<Integer> processedElements = new ArrayList<>();
IntStream inputElements = IntStream.iterate(0, i -> i + 1).limit(numElements);
Configuration config = new Configuration().from(new StreamProducer<>(inputElements)).to(new Counter<>()).end(new CollectorSink<>(processedElements));
TeeTimeScheduler scheduling = new GlobalTaskPoolScheduling(numThreads, config, numExecutions);
Execution<Configuration> execution = new Execution<>(config, true, scheduling);
execution.executeBlocking();
for (int i = 0; i < numElements; i++) {
Integer actualElement = processedElements.get(i);
assertThat(actualElement, is(i));
}
assertThat(processedElements, hasSize(numElements));
}
use of teetime.framework.Configuration in project TeeTime by teetime-framework.
the class CipherTest method executeTestWithConfigurationCreatedByBuilder.
@Test
public void executeTestWithConfigurationCreatedByBuilder() throws IOException {
final Configuration configuration = ConfigurationBuilder.from(new InitialElementProducer<File>(new File(INPUT_FILE))).to(new File2ByteArray()).to(new CipherStage(PASSWORD, CipherMode.ENCRYPT)).to(new ZipByteArray(ZipMode.COMP)).to(new ZipByteArray(ZipMode.DECOMP)).to(new CipherStage(PASSWORD, CipherMode.DECRYPT)).end(new ByteArrayFileWriter(new File(OUTPUT_FILE)));
final Execution<Configuration> execution = new Execution<Configuration>(configuration);
execution.executeBlocking();
Assert.assertTrue(Files.equal(new File(INPUT_FILE), new File(OUTPUT_FILE)));
}
use of teetime.framework.Configuration in project TeeTime by teetime-framework.
the class OneExecutionProducerIT method testRegularExecution.
void testRegularExecution(final List<String> expectedElements, final int numThreads) {
for (int numOfExecutions = 1; numOfExecutions < expectedElements.size() + 1; numOfExecutions++) {
List<String> actualElements = new ArrayList<>();
Configuration configuration = new Configuration().from(new InitialElementProducer<String>(expectedElements)).end(new CollectorSink<String>(actualElements));
GlobalTaskPoolScheduling scheduler = new GlobalTaskPoolScheduling(numThreads, configuration, numOfExecutions);
Execution<Configuration> execution = new Execution<>(configuration, true, scheduler);
execution.executeBlocking();
assertThat("failed with numOfExecutions=" + numOfExecutions, actualElements, is(equalTo(expectedElements)));
}
}
Aggregations