snuyanzin commented on code in PR #20991:
URL: https://github.com/apache/flink/pull/20991#discussion_r1047271926


##########
flink-connectors/flink-connector-kafka/src/test/java/org/apache/flink/streaming/connectors/kafka/FlinkKafkaInternalProducerITCase.java:
##########
@@ -148,62 +153,78 @@ public void testResumeTransaction() throws Exception {
         deleteTestTopic(topicName);
     }
 
-    @Test(timeout = 30000L, expected = IllegalStateException.class)
-    public void testPartitionsForAfterClosed() {
+    @Test
+    @Timeout(30L)
+    void testPartitionsForAfterClosed() {
         FlinkKafkaInternalProducer<String, String> kafkaProducer =
                 new FlinkKafkaInternalProducer<>(extraProperties);
         kafkaProducer.close(Duration.ofSeconds(5));
-        kafkaProducer.partitionsFor("Topic");
+        assertThatThrownBy(() -> kafkaProducer.partitionsFor("Topic"))
+                .isInstanceOf(IllegalStateException.class);
     }
 
-    @Test(timeout = 30000L, expected = IllegalStateException.class)
-    public void testInitTransactionsAfterClosed() {
+    @Test
+    @Timeout(30L)
+    void testInitTransactionsAfterClosed() {
         FlinkKafkaInternalProducer<String, String> kafkaProducer =
                 new FlinkKafkaInternalProducer<>(extraProperties);
         kafkaProducer.close(Duration.ofSeconds(5));
-        kafkaProducer.initTransactions();
+        assertThatThrownBy(kafkaProducer::initTransactions)
+                .isInstanceOf(IllegalStateException.class);
     }
 
-    @Test(timeout = 30000L, expected = IllegalStateException.class)
-    public void testBeginTransactionAfterClosed() {
+    @Test
+    @Timeout(30L)
+    void testBeginTransactionAfterClosed() {
         FlinkKafkaInternalProducer<String, String> kafkaProducer =
                 new FlinkKafkaInternalProducer<>(extraProperties);
         kafkaProducer.initTransactions();
         kafkaProducer.close(Duration.ofSeconds(5));
-        kafkaProducer.beginTransaction();
+        assertThatThrownBy(kafkaProducer::beginTransaction)
+                .isInstanceOf(IllegalStateException.class);
     }
 
-    @Test(timeout = 30000L, expected = IllegalStateException.class)
-    public void testCommitTransactionAfterClosed() {
+    @Test
+    @Timeout(30L)
+    void testCommitTransactionAfterClosed() {
         String topicName = "testCommitTransactionAfterClosed";
         FlinkKafkaInternalProducer<String, String> kafkaProducer = 
getClosedProducer(topicName);
-        kafkaProducer.commitTransaction();
+        assertThatThrownBy(kafkaProducer::commitTransaction)
+                .isInstanceOf(IllegalStateException.class);
     }
 
-    @Test(timeout = 30000L, expected = IllegalStateException.class)
-    public void testResumeTransactionAfterClosed() {
+    @Test
+    @Timeout(30L)
+    void testResumeTransactionAfterClosed() {
         String topicName = "testAbortTransactionAfterClosed";
         FlinkKafkaInternalProducer<String, String> kafkaProducer = 
getClosedProducer(topicName);
-        kafkaProducer.resumeTransaction(0L, (short) 1);
+        assertThatThrownBy(() -> kafkaProducer.resumeTransaction(0L, (short) 
1))
+                .isInstanceOf(IllegalStateException.class);
     }
 
-    @Test(timeout = 30000L, expected = IllegalStateException.class)
-    public void testAbortTransactionAfterClosed() {
+    @Test
+    @Timeout(30L)
+    // TODO verify why 'The producer 951754235 has already been closed' is 
coming
+    @Disabled
+    void testAbortTransactionAfterClosed() {
         String topicName = "testAbortTransactionAfterClosed";
         FlinkKafkaInternalProducer<String, String> kafkaProducer = 
getClosedProducer(topicName);
         kafkaProducer.abortTransaction();
-        kafkaProducer.resumeTransaction(0L, (short) 1);
+        assertThatThrownBy(() -> kafkaProducer.resumeTransaction(0L, (short) 
1))
+                .isInstanceOf(IllegalStateException.class);
     }
 
-    @Test(timeout = 30000L, expected = IllegalStateException.class)
-    public void testFlushAfterClosed() {
+    @Test
+    @Timeout(30L)
+    void testFlushAfterClosed() {
         String topicName = "testCommitTransactionAfterClosed";
         FlinkKafkaInternalProducer<String, String> kafkaProducer = 
getClosedProducer(topicName);
-        kafkaProducer.flush();
+        
assertThatThrownBy(kafkaProducer::flush).isInstanceOf(IllegalStateException.class);
     }
 
-    @Test(timeout = 30000L)
-    public void 
testProducerWhenCommitEmptyPartitionsToOutdatedTxnCoordinator() throws 
Exception {
+    @Test
+    @Timeout(30L)

Review Comment:
   time unit should be specified



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to