chia7712 commented on a change in pull request #8826: URL: https://github.com/apache/kafka/pull/8826#discussion_r533093802
########## File path: clients/src/test/java/org/apache/kafka/clients/producer/KafkaProducerTest.java ########## @@ -1271,27 +1270,48 @@ public void testProducerJmxPrefix() throws Exception { producer.close(); } - private ProducerMetadata newMetadata(long refreshBackoffMs, long expirationMs) { - return new ProducerMetadata(refreshBackoffMs, expirationMs, defaultMetadataIdleMs, + private static ProducerMetadata newMetadata(long refreshBackoffMs, long expirationMs) { + return new ProducerMetadata(refreshBackoffMs, expirationMs, DEFAULT_METADATA_IDLE_MS, new LogContext(), new ClusterResourceListeners(), Time.SYSTEM); } @Test - public void serializerShouldSeeGeneratedClientId() { + public void configurableObjectsShouldSeeGeneratedClientId() { Properties props = new Properties(); props.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, "localhost:9999"); props.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, SerializerForClientId.class.getName()); props.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, SerializerForClientId.class.getName()); + props.put(ProducerConfig.PARTITIONER_CLASS_CONFIG, PartitionerForClientId.class.getName()); + props.put(ProducerConfig.INTERCEPTOR_CLASSES_CONFIG, ProducerInterceptorForClientId.class.getName()); KafkaProducer<byte[], byte[]> producer = new KafkaProducer<>(props); - assertEquals(2, SerializerForClientId.CLIENT_IDS.size()); - assertEquals(SerializerForClientId.CLIENT_IDS.get(0), producer.getClientId()); - assertEquals(SerializerForClientId.CLIENT_IDS.get(1), producer.getClientId()); + assertNotNull(producer.getClientId()); + assertNotEquals(0, producer.getClientId().length()); + assertEquals(4, CLIENT_IDS.size()); + CLIENT_IDS.forEach(id -> assertEquals(id, producer.getClientId())); producer.close(); } + @Test + public void testUnusedConfigs() { + Map<String, Object> props = new HashMap<>(); + props.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, "localhost:9999"); + props.put(SslConfigs.SSL_PROTOCOL_CONFIG, "TLS"); + ProducerConfig config = new ProducerConfig(ProducerConfig.appendSerializerToConfig(props, + new StringSerializer(), new StringSerializer())); + + assertTrue(new ProducerConfig(config.originals(), false).unused().contains(SslConfigs.SSL_PROTOCOL_CONFIG)); Review comment: I'm going to remove this test ```assertTrue(new ProducerConfig(config.originals(), false).unused().co...``` ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org