davsclaus commented on code in PR #10804:
URL: https://github.com/apache/camel/pull/10804#discussion_r1272188032


##########
core/camel-core/src/test/java/org/apache/camel/builder/FluentProducerTemplateTest.java:
##########
@@ -39,19 +40,19 @@
 public class FluentProducerTemplateTest extends ContextTestSupport {
 
     @Test
-    public void testNoEndpoint() throws Exception {
+    public void testNoEndpoint() {
         FluentProducerTemplate fluent = context.createFluentProducerTemplate();
 
         try {
             fluent.withBody("Hello World").send();
-            fail("Should have thrown exception");
+            Assertions.assertDoesNotThrow(() -> fail("Should have thrown 
exception"));

Review Comment:
   This code is wrong as the code was expected to throw an exception, and hence 
it will execute the .. catch block.



##########
core/camel-core/src/test/java/org/apache/camel/builder/FluentProducerTemplateTest.java:
##########
@@ -239,12 +240,12 @@ public void testExceptionUsingExchange() throws Exception 
{
     }
 
     @Test
-    public void testExceptionUsingProcessorAndBody() throws Exception {
+    public void testExceptionUsingProcessorAndBody() {
         try {
             DefaultFluentProducerTemplate.on(context)
                     .withBody("World")
                     .withProcessor(exchange -> 
exchange.getIn().setHeader("foo", 123)).to("direct:async").send();
-            fail();
+            Assertions.assertDoesNotThrow(() -> fail());

Review Comment:
   Same as before



##########
core/camel-main/src/test/java/org/apache/camel/main/MainPropertyPlaceholderTest.java:
##########
@@ -33,7 +34,7 @@ public void testDefaultPropertyPlaceholderLocationDisabled() {
             main.setDefaultPropertyPlaceholderLocation("false");
             main.start();
             main.getCamelContext().resolvePropertyPlaceholders("{{hello}}");
-            fail("Expected IllegalArgumentException");
+            Assertions.assertDoesNotThrow( () -> fail("Expected 
IllegalArgumentException"));

Review Comment:
   Same as before



##########
core/camel-main/src/test/java/org/apache/camel/main/MainSupportCommandLineTest.java:
##########
@@ -44,20 +45,20 @@ public CamelContext getCamelContext() {
     }
 
     @Test
-    public void testMainSupport() throws Exception {
+    public void testMainSupport() {
         MyMainSupport my = new MyMainSupport();
-        my.run(new String[] { "-d", "1" });
+        Assertions.assertDoesNotThrow(() -> my.run(new String[] { "-d", "1" 
}));

Review Comment:
   Sorry this code is harder to understand and maintain.
   
   Its perfect OK for a test method to have throws exception.
   As. the old code is 100% how an end user will write the code.
   



##########
core/camel-main/src/test/java/org/apache/camel/main/MainVaultTest.java:
##########
@@ -48,7 +48,7 @@ public void testMainAws() throws Exception {
         Assertions.assertEquals("myKey", cfg.getAccessKey());
         Assertions.assertEquals("mySecret", cfg.getSecretKey());
         Assertions.assertEquals("myRegion", cfg.getRegion());
-        Assertions.assertEquals(false, cfg.isDefaultCredentialsProvider());
+        Assertions.assertFalse(cfg.isDefaultCredentialsProvider());

Review Comment:
   These changes are ok (and the following)



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