@Test public void testDefaultConsumerConfig() { Properties properties = new Properties(); properties.put("auto.offset.reset", "none"); properties.put("bootstrap.servers", "MyBroker:10251"); properties.put("enable.auto.commit", "false"); properties.put("group.id", "groupId"); properties.put("security.protocol", "SSL"); Properties actual = KafkaConsumerFactoryImpl.addConsumerDefaultProperties(properties); Properties expected = new Properties(); expected.putAll(properties); expected.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, DEFAULT_KEY_DESERIALIZER); expected.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, DEFAULT_VAL_DESERIALIZER); Assert.assertEquals(actual, expected); }
static Properties addConsumerDefaultProperties(Properties properties) { properties.putIfAbsent(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, DEFAULT_KEY_DESERIALIZER); properties.putIfAbsent(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, DEFAULT_VAL_DESERIALIZER); return properties; }
KafkaConsumerFactoryImpl implements KafkaConsumerFactory<byte[], byte[]> { static Properties addConsumerDefaultProperties(Properties properties) { properties.putIfAbsent(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, DEFAULT_KEY_DESERIALIZER); properties.putIfAbsent(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, DEFAULT_VAL_DESERIALIZER); return properties; } }
KafkaConsumerFactoryImpl implements KafkaConsumerFactory<byte[], byte[]> { static Properties addConsumerDefaultProperties(Properties properties) { properties.putIfAbsent(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, DEFAULT_KEY_DESERIALIZER); properties.putIfAbsent(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, DEFAULT_VAL_DESERIALIZER); return properties; }  }
KafkaConsumerFactoryImpl implements KafkaConsumerFactory<byte[], byte[]> { static Properties addConsumerDefaultProperties(Properties properties) { properties.putIfAbsent(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, DEFAULT_KEY_DESERIALIZER); properties.putIfAbsent(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, DEFAULT_VAL_DESERIALIZER); return properties; }  @Override Consumer<byte[], byte[]> createConsumer(Properties properties); }
KafkaConsumerFactoryImpl implements KafkaConsumerFactory<byte[], byte[]> { static Properties addConsumerDefaultProperties(Properties properties) { properties.putIfAbsent(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, DEFAULT_KEY_DESERIALIZER); properties.putIfAbsent(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, DEFAULT_VAL_DESERIALIZER); return properties; }  @Override Consumer<byte[], byte[]> createConsumer(Properties properties);  }