You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by GitBox <gi...@apache.org> on 2019/04/22 13:57:48 UTC

[GitHub] [nifi] markap14 commented on a change in pull request #3439: NIFI-6218 Support setting transactional.id in PublishKafka/PublishKaf…

markap14 commented on a change in pull request #3439: NIFI-6218 Support setting transactional.id in PublishKafka/PublishKaf…
URL: https://github.com/apache/nifi/pull/3439#discussion_r277296600
 
 

 ##########
 File path: nifi-nar-bundles/nifi-kafka-bundle/nifi-kafka-0-11-processors/src/test/java/org/apache/nifi/processors/kafka/pubsub/TestPublisherPool.java
 ##########
 @@ -65,5 +70,40 @@ public void testPoisonedLeaseNotReturnedToPool() {
         lease.close();
         assertEquals(0, pool.available());
     }
+    @Test
+    public void testUseTransactionWithUUID() {
+        final Map<String, Object> kafkaProperties = new HashMap<>();
+        kafkaProperties.put("bootstrap.servers", "localhost:1111");
+        kafkaProperties.put("key.serializer", ByteArraySerializer.class.getName());
+        kafkaProperties.put("value.serializer", ByteArraySerializer.class.getName());
 
+        final PublisherPool pool = new PublisherPool(kafkaProperties, Mockito.mock(ComponentLog.class), 1024 * 1024, 1000L, true, null, null, StandardCharsets.UTF_8);
+        PublisherLease publisherLease = pool.obtainPublisher();
+
+        Producer producer = (Producer) Whitebox.getInternalState(publisherLease, "producer");
+        TransactionManager transactionManager = (TransactionManager) Whitebox.getInternalState(producer, "transactionManager");
+        String transactionalId = (String) Whitebox.getInternalState(transactionManager, "transactionalId");
+        try {
+            UUID uuid = UUID.fromString(transactionalId);
+        } catch (Exception e) {
+            fail(e.getMessage());
+        }
+    }
+
+    @Test
+    public void testUseTransactionWithProvidedTransactionalId() {
+        final Map<String, Object> kafkaProperties = new HashMap<>();
+        kafkaProperties.put("bootstrap.servers", "localhost:1111");
+        kafkaProperties.put("key.serializer", ByteArraySerializer.class.getName());
+        kafkaProperties.put("value.serializer", ByteArraySerializer.class.getName());
+
+        final PublisherPool pool = new PublisherPool(kafkaProperties, Mockito.mock(ComponentLog.class), 1024 * 1024, 1000L, true, "myTransactionalId", null, StandardCharsets.UTF_8);
+        PublisherLease publisherLease = pool.obtainPublisher();
+
+        Producer producer = (Producer) Whitebox.getInternalState(publisherLease, "producer");
 
 Review comment:
   Again, should avoid using reflection and expose the actual value instead

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services