use of org.apache.kafka.test.MockProcessorContext in project kafka by apache.
the class SegmentIteratorTest method before.
@Before
public void before() {
final MockProcessorContext context = new MockProcessorContext(TestUtils.tempDirectory(), Serdes.String(), Serdes.String(), new NoOpRecordCollector(), new ThreadCache("testCache", 0, new MockStreamsMetrics(new Metrics())));
segmentOne.openDB(context);
segmentTwo.openDB(context);
segmentOne.put(Bytes.wrap("a".getBytes()), "1".getBytes());
segmentOne.put(Bytes.wrap("b".getBytes()), "2".getBytes());
segmentTwo.put(Bytes.wrap("c".getBytes()), "3".getBytes());
segmentTwo.put(Bytes.wrap("d".getBytes()), "4".getBytes());
}
use of org.apache.kafka.test.MockProcessorContext in project kafka by apache.
the class SegmentsTest method createContext.
@Before
public void createContext() {
context = new MockProcessorContext(TestUtils.tempDirectory(), Serdes.String(), Serdes.Long(), new NoOpRecordCollector(), new ThreadCache("testCache", 0, new MockStreamsMetrics(new Metrics())));
segments = new Segments("test", 4 * 60 * 1000, NUM_SEGMENTS);
}
use of org.apache.kafka.test.MockProcessorContext in project kafka by apache.
the class RocksDBKeyValueStoreSupplierTest method shouldCreateLoggingEnabledStoreWhenStoreLogged.
@Test
public void shouldCreateLoggingEnabledStoreWhenStoreLogged() throws Exception {
store = createStore(true, false);
final List<ProducerRecord> logged = new ArrayList<>();
final NoOpRecordCollector collector = new NoOpRecordCollector() {
@Override
public <K, V> void send(final String topic, K key, V value, Integer partition, Long timestamp, Serializer<K> keySerializer, Serializer<V> valueSerializer) {
logged.add(new ProducerRecord<K, V>(topic, partition, timestamp, key, value));
}
};
final MockProcessorContext context = new MockProcessorContext(TestUtils.tempDirectory(), Serdes.String(), Serdes.String(), collector, cache);
context.setTime(1);
store.init(context, store);
store.put("a", "b");
assertFalse(logged.isEmpty());
}
use of org.apache.kafka.test.MockProcessorContext in project kafka by apache.
the class RocksDBKeyValueStoreTest method shouldPerformRangeQueriesWithCachingDisabled.
@Test
public void shouldPerformRangeQueriesWithCachingDisabled() throws Exception {
final KeyValueStoreTestDriver<Integer, String> driver = KeyValueStoreTestDriver.create(Integer.class, String.class);
final MockProcessorContext context = (MockProcessorContext) driver.context();
final KeyValueStore<Integer, String> store = createStore(context, Integer.class, String.class, false, false);
context.setTime(1L);
store.put(1, "hi");
store.put(2, "goodbye");
final KeyValueIterator<Integer, String> range = store.range(1, 2);
assertEquals("hi", range.next().value);
assertEquals("goodbye", range.next().value);
assertFalse(range.hasNext());
}
use of org.apache.kafka.test.MockProcessorContext in project kafka by apache.
the class RocksDBSegmentedBytesStoreTest method before.
@Before
public void before() {
bytesStore = new RocksDBSegmentedBytesStore(storeName, retention, numSegments, new SessionKeySchema());
stateDir = TestUtils.tempDirectory();
final MockProcessorContext context = new MockProcessorContext(stateDir, Serdes.String(), Serdes.Long(), new NoOpRecordCollector(), new ThreadCache("testCache", 0, new MockStreamsMetrics(new Metrics())));
bytesStore.init(context, bytesStore);
}
Aggregations