You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by or...@apache.org on 2021/11/29 13:54:00 UTC

[camel] branch main updated: CAMEL-17241: fixed incorrect exception test

This is an automated email from the ASF dual-hosted git repository.

orpiske pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/main by this push:
     new e012412  CAMEL-17241: fixed incorrect exception test
e012412 is described below

commit e0124120e119c516b97f6235a16b8b07d91412b5
Author: Otavio Rodolfo Piske <op...@redhat.com>
AuthorDate: Fri Nov 26 13:28:56 2021 +0100

    CAMEL-17241: fixed incorrect exception test
---
 .../java/org/apache/camel/component/kafka/KafkaProducerTest.java   | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/components/camel-kafka/src/test/java/org/apache/camel/component/kafka/KafkaProducerTest.java b/components/camel-kafka/src/test/java/org/apache/camel/component/kafka/KafkaProducerTest.java
index aac2425..3e287ee 100644
--- a/components/camel-kafka/src/test/java/org/apache/camel/component/kafka/KafkaProducerTest.java
+++ b/components/camel-kafka/src/test/java/org/apache/camel/component/kafka/KafkaProducerTest.java
@@ -128,15 +128,16 @@ public class KafkaProducerTest {
 
     @Test
     @SuppressWarnings({ "unchecked" })
-    public void processSendsMessageWithException() throws Exception {
+    public void processSendsMessageWithException() {
         endpoint.getConfiguration().setTopic("sometopic");
         // setup the exception here
         org.apache.kafka.clients.producer.KafkaProducer kp = producer.getKafkaProducer();
         Mockito.when(kp.send(any(ProducerRecord.class))).thenThrow(new ApiException());
         Mockito.when(exchange.getIn()).thenReturn(in);
+        Mockito.when(exchange.getMessage()).thenReturn(in);
         in.setHeader(KafkaConstants.PARTITION_KEY, 4);
 
-        assertThrows(Exception.class,
+        assertThrows(ApiException.class,
                 () -> producer.process(exchange));
     }
 
@@ -158,7 +159,7 @@ public class KafkaProducerTest {
     }
 
     @Test
-    public void processAsyncSendsMessageWithException() throws Exception {
+    public void processAsyncSendsMessageWithException() {
         endpoint.getConfiguration().setTopic("sometopic");
         Mockito.when(exchange.getIn()).thenReturn(in);
         Mockito.when(exchange.getMessage()).thenReturn(in);