use of com.ociweb.pronghorn.pipe.stream.StreamingReadVisitorMatcher in project PronghornPipes by oci-pronghorn.
the class StreamingConsumerTest method matchingTestPositive.
@Test
public void matchingTestPositive() {
Pipe<MessageSchemaDynamic> ring1 = new Pipe<MessageSchemaDynamic>(new PipeConfig<MessageSchemaDynamic>(new MessageSchemaDynamic(FROM), 1 << primaryRingSizeInBits, 1 << byteRingSizeInBits));
Pipe<MessageSchemaDynamic> ring2 = new Pipe<MessageSchemaDynamic>(new PipeConfig<MessageSchemaDynamic>(new MessageSchemaDynamic(FROM), 1 << primaryRingSizeInBits, 1 << byteRingSizeInBits));
ring1.initBuffers();
ring2.initBuffers();
int commonSeed = 100;
StreamingWriteVisitorGenerator swvg1 = new StreamingWriteVisitorGenerator(FROM, new Random(commonSeed), 30, 30);
StreamingVisitorWriter svw1 = new StreamingVisitorWriter(ring1, swvg1);
StreamingWriteVisitorGenerator swvg2 = new StreamingWriteVisitorGenerator(FROM, new Random(commonSeed), 30, 30);
StreamingVisitorWriter svw2 = new StreamingVisitorWriter(ring2, swvg2);
svw1.startup();
svw2.startup();
svw1.run();
svw2.run();
svw1.run();
svw2.run();
// confirm that both rings contain the exact same thing
assertTrue(Arrays.equals(Pipe.primaryBuffer(ring1), Pipe.primaryBuffer(ring2)));
assertTrue(Arrays.equals(Pipe.byteBuffer(ring1), Pipe.byteBuffer(ring2)));
// now use matcher to confirm the same.
StreamingReadVisitorMatcher srvm = new StreamingReadVisitorMatcher(ring1);
// new StreamingReadVisitorDebugDelegate(srvm) );
StreamingVisitorReader svr = new StreamingVisitorReader(ring2, srvm);
svr.startup();
try {
svr.run();
} catch (Throwable t) {
t.printStackTrace();
fail(t.getMessage());
}
svr.shutdown();
svw1.shutdown();
svw2.shutdown();
}
use of com.ociweb.pronghorn.pipe.stream.StreamingReadVisitorMatcher in project PronghornPipes by oci-pronghorn.
the class StreamingConsumerTest method matchingTestNegative.
@Test
public void matchingTestNegative() {
Pipe<MessageSchemaDynamic> ring1 = new Pipe<MessageSchemaDynamic>(new PipeConfig<MessageSchemaDynamic>(new MessageSchemaDynamic(FROM), 1 << primaryRingSizeInBits, 1 << byteRingSizeInBits));
Pipe<MessageSchemaDynamic> ring2 = new Pipe<MessageSchemaDynamic>(new PipeConfig<MessageSchemaDynamic>(new MessageSchemaDynamic(FROM), primaryRingSizeInBits, byteRingSizeInBits));
ring1.initBuffers();
ring2.initBuffers();
int commonSeed = 300;
StreamingWriteVisitorGenerator swvg1 = new StreamingWriteVisitorGenerator(FROM, new Random(commonSeed), 30, 30);
StreamingVisitorWriter svw1 = new StreamingVisitorWriter(ring1, swvg1);
StreamingWriteVisitorGenerator swvg2 = new StreamingWriteVisitorGenerator(FROM, new Random(commonSeed + 1), 30, 30);
StreamingVisitorWriter svw2 = new StreamingVisitorWriter(ring2, swvg2);
svw1.startup();
svw2.startup();
svw1.run();
svw2.run();
svw1.run();
svw2.run();
StreamingReadVisitorMatcher srvm = new StreamingReadVisitorMatcher(ring1);
StreamingVisitorReader svr = new StreamingVisitorReader(ring2, srvm);
svr.startup();
try {
svr.run();
fail("expected exception");
} catch (Throwable t) {
// success
// t.printStackTrace();
}
svr.shutdown();
svw1.shutdown();
svw2.shutdown();
}
Aggregations