use of org.apache.kafka.test.NoOpRecordCollector in project kafka by apache.
the class RocksDBSessionStoreSupplierTest 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(new Windowed<>("a", new SessionWindow(0, 10)), "b");
assertFalse(logged.isEmpty());
}
use of org.apache.kafka.test.NoOpRecordCollector in project kafka by apache.
the class RocksDBSessionStoreSupplierTest method shouldNotBeLoggingEnabledStoreWhenLoggingNotEnabled.
@Test
public void shouldNotBeLoggingEnabledStoreWhenLoggingNotEnabled() throws Exception {
store = createStore(false, 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(new Windowed<>("a", new SessionWindow(0, 10)), "b");
assertTrue(logged.isEmpty());
}
use of org.apache.kafka.test.NoOpRecordCollector in project kafka by apache.
the class KStreamSessionWindowAggregateProcessorTest method initializeStore.
@SuppressWarnings("unchecked")
@Before
public void initializeStore() {
final File stateDir = TestUtils.tempDirectory();
context = new MockProcessorContext(stateDir, Serdes.String(), Serdes.String(), new NoOpRecordCollector(), new ThreadCache("testCache", 100000, new MockStreamsMetrics(new Metrics()))) {
@Override
public <K, V> void forward(final K key, final V value) {
results.add(KeyValue.pair(key, value));
}
};
initStore(true);
processor.init(context);
}
use of org.apache.kafka.test.NoOpRecordCollector in project kafka by apache.
the class RocksDBWindowStoreSupplierTest method shouldCreateLoggingEnabledStoreWhenWindowStoreLogged.
@Test
public void shouldCreateLoggingEnabledStoreWhenWindowStoreLogged() 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.NoOpRecordCollector in project kafka by apache.
the class StateStoreTestUtils method newKeyValueStore.
public static <K, V> KeyValueStore<K, V> newKeyValueStore(String name, Class<K> keyType, Class<V> valueType) {
final InMemoryKeyValueStoreSupplier<K, V> supplier = new InMemoryKeyValueStoreSupplier<>(name, null, null, new MockTime(), false, Collections.<String, String>emptyMap());
final StateStore stateStore = supplier.get();
stateStore.init(new MockProcessorContext(StateSerdes.withBuiltinTypes(name, keyType, valueType), new NoOpRecordCollector()), stateStore);
return (KeyValueStore<K, V>) stateStore;
}
Aggregations