use of org.apache.gobblin.ack.BasicAckableForTesting in project incubator-gobblin by apache.
the class RecordEnvelopeTest method testMultipleClones.
@Test
public void testMultipleClones() {
BasicAckableForTesting ackable = new BasicAckableForTesting();
RecordEnvelope<CopyableRecord> record = new RecordEnvelope<>(new CopyableRecord(), new MyWatermark(110));
record.addCallBack(ackable);
StreamEntity.ForkCloner cloner = record.forkCloner();
RecordEnvelope<CopyableRecord> copy1 = (RecordEnvelope<CopyableRecord>) cloner.getClone();
RecordEnvelope<CopyableRecord> copy2 = (RecordEnvelope<CopyableRecord>) cloner.getClone();
cloner.close();
Assert.assertEquals(record.getRecord().id, copy1.getRecord().id);
Assert.assertEquals(((MyWatermark) copy1.getWatermark()).getId(), 110);
Assert.assertEquals(record.getRecord().id, copy2.getRecord().id);
Assert.assertEquals(((MyWatermark) copy2.getWatermark()).getId(), 110);
copy1.ack();
Assert.assertEquals(ackable.acked, 0);
copy2.ack();
Assert.assertEquals(ackable.acked, 1);
}
use of org.apache.gobblin.ack.BasicAckableForTesting in project incubator-gobblin by apache.
the class RecordEnvelopeTest method testClone.
@Test
public void testClone() {
BasicAckableForTesting ackable = new BasicAckableForTesting();
RecordEnvelope<CopyableRecord> record = new RecordEnvelope<>(new CopyableRecord(), new MyWatermark(110));
record.addCallBack(ackable);
RecordEnvelope<CopyableRecord> copy = (RecordEnvelope<CopyableRecord>) record.getSingleClone();
Assert.assertEquals(record.getRecord().id, copy.getRecord().id);
Assert.assertEquals(((MyWatermark) copy.getWatermark()).getId(), 110);
copy.ack();
Assert.assertEquals(ackable.acked, 1);
try {
record.getSingleClone();
Assert.fail();
} catch (IllegalStateException ise) {
// expected, cannot clone more than once using getSingleClone
}
}
use of org.apache.gobblin.ack.BasicAckableForTesting in project incubator-gobblin by apache.
the class StreamEntityTest method testNack.
@Test
public void testNack() {
MyStreamEntity streamEntity = new MyStreamEntity();
BasicAckableForTesting ackable = new BasicAckableForTesting();
streamEntity.addCallBack(ackable);
streamEntity.nack(new RuntimeException());
Assert.assertEquals(ackable.nacked, 1);
Assert.assertTrue(ackable.throwable instanceof RuntimeException);
}
use of org.apache.gobblin.ack.BasicAckableForTesting in project incubator-gobblin by apache.
the class StreamEntityTest method testAcking.
@Test
public void testAcking() {
MyStreamEntity streamEntity = new MyStreamEntity();
BasicAckableForTesting ackable1 = new BasicAckableForTesting();
streamEntity.addCallBack(ackable1);
BasicAckableForTesting ackable2 = new BasicAckableForTesting();
streamEntity.addCallBack(ackable2);
streamEntity.ack();
Assert.assertEquals(ackable1.acked, 1);
Assert.assertEquals(ackable2.acked, 1);
}
Aggregations