You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2023/08/03 12:52:55 UTC

[camel] branch export created (now 4750a40e2ae)

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

davsclaus pushed a change to branch export
in repository https://gitbox.apache.org/repos/asf/camel.git


      at 4750a40e2ae camel class resolver should be able to scan from root package if you use dot as the package name.

This branch includes the following new commits:

     new 3dc2228178f CAMEL-19694: camel-jbang - Export can now configure java package name to use for source code
     new a76bcab3c54 camel class resolver should be able to scan from root package if you use dot as the package name.
     new 68fb1e0299e Regen
     new 4750a40e2ae camel class resolver should be able to scan from root package if you use dot as the package name.

The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[camel] 03/04: Regen

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 68fb1e0299ee0559f692bb701bef4c01b71383a1
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Thu Aug 3 14:43:31 2023 +0200

    Regen
---
 .../org/apache/camel/component/saga/SagaComponentTest.java |  3 ++-
 .../component/seda/SameSedaQueueSizeAndNoSizeTest.java     | 11 +++++++----
 .../apache/camel/component/seda/SedaBlockWhenFullTest.java |  3 ++-
 .../seda/SedaConcurrentConsumersNPEIssueTest.java          | 14 ++++++++------
 .../camel/component/seda/SedaDefaultBlockWhenFullTest.java | 12 ++++++------
 .../component/seda/SedaDefaultUnboundedQueueSizeTest.java  |  5 +++--
 .../camel/component/seda/SedaInOutChainedTimeoutTest.java  |  3 ++-
 .../camel/component/seda/SedaInOutWithErrorTest.java       |  3 ++-
 .../apache/camel/component/seda/SedaNoConsumerTest.java    | 13 ++++++++-----
 .../org/apache/camel/component/seda/SedaTimeoutTest.java   |  6 +++---
 .../seda/SedaWaitForTaskCompleteOnCompletionTest.java      |  5 +++--
 .../apache/camel/component/timer/TimerEndpointTest.java    |  4 ++--
 .../camel/component/timer/TimerWithTimeOptionTest.java     |  6 +++---
 .../validator/ValidatorLazyStartProducerTest.java          |  6 +++---
 14 files changed, 54 insertions(+), 40 deletions(-)

diff --git a/core/camel-core/src/test/java/org/apache/camel/component/saga/SagaComponentTest.java b/core/camel-core/src/test/java/org/apache/camel/component/saga/SagaComponentTest.java
index 3861783b385..89eb26f9cab 100644
--- a/core/camel-core/src/test/java/org/apache/camel/component/saga/SagaComponentTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/saga/SagaComponentTest.java
@@ -85,7 +85,8 @@ public class SagaComponentTest extends ContextTestSupport {
         MockEndpoint compensated = getMockEndpoint("mock:compensated");
         compensated.expectedMessageCount(1);
 
-        assertThrows(Exception.class, () -> template.sendBody("direct:auto-workflow", "auto-compensate"), "Should throw an exception");
+        assertThrows(Exception.class, () -> template.sendBody("direct:auto-workflow", "auto-compensate"),
+                "Should throw an exception");
 
         completed.assertIsNotSatisfied();
         compensated.assertIsSatisfied();
diff --git a/core/camel-core/src/test/java/org/apache/camel/component/seda/SameSedaQueueSizeAndNoSizeTest.java b/core/camel-core/src/test/java/org/apache/camel/component/seda/SameSedaQueueSizeAndNoSizeTest.java
index cb4d372853a..50ef8e0ddeb 100644
--- a/core/camel-core/src/test/java/org/apache/camel/component/seda/SameSedaQueueSizeAndNoSizeTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/seda/SameSedaQueueSizeAndNoSizeTest.java
@@ -36,7 +36,8 @@ public class SameSedaQueueSizeAndNoSizeTest extends ContextTestSupport {
             template.sendBody("seda:foo", "" + i);
         }
 
-        CamelExecutionException e = assertThrows(CamelExecutionException.class, () -> template.sendBody("seda:foo", "Should be full now"), "Should fail");
+        CamelExecutionException e = assertThrows(CamelExecutionException.class,
+                () -> template.sendBody("seda:foo", "Should be full now"), "Should fail");
         IllegalStateException ise = assertIsInstanceOf(IllegalStateException.class, e.getCause());
         if (!isJavaVendor("ibm")) {
             assertEquals("Queue full", ise.getMessage());
@@ -45,7 +46,8 @@ public class SameSedaQueueSizeAndNoSizeTest extends ContextTestSupport {
 
     @Test
     public void testSameQueueDifferentSize() {
-        ResolveEndpointFailedException e = assertThrows(ResolveEndpointFailedException.class, () -> template.sendBody("seda:foo?size=200", "Should fail"), "Should fail");
+        ResolveEndpointFailedException e = assertThrows(ResolveEndpointFailedException.class,
+                () -> template.sendBody("seda:foo?size=200", "Should fail"), "Should fail");
         IllegalArgumentException ise = assertIsInstanceOf(IllegalArgumentException.class, e.getCause());
         assertEquals(
                 "Cannot use existing queue seda://foo as the existing queue size 100 does not match given queue size 200",
@@ -54,10 +56,11 @@ public class SameSedaQueueSizeAndNoSizeTest extends ContextTestSupport {
 
     @Test
     public void testSameQueueDifferentSizeBar() {
-        ResolveEndpointFailedException e = assertThrows(ResolveEndpointFailedException.class,() -> template.sendBody("seda:bar?size=200", "Should fail"), "Should fail");
+        ResolveEndpointFailedException e = assertThrows(ResolveEndpointFailedException.class,
+                () -> template.sendBody("seda:bar?size=200", "Should fail"), "Should fail");
         IllegalArgumentException ise = assertIsInstanceOf(IllegalArgumentException.class, e.getCause());
         assertEquals("Cannot use existing queue seda://bar as the existing queue size " + SedaConstants.QUEUE_SIZE
-                        + " does not match given queue size 200",
+                     + " does not match given queue size 200",
                 ise.getMessage());
     }
 
diff --git a/core/camel-core/src/test/java/org/apache/camel/component/seda/SedaBlockWhenFullTest.java b/core/camel-core/src/test/java/org/apache/camel/component/seda/SedaBlockWhenFullTest.java
index 99ac0a0a6d5..a50259eaa37 100644
--- a/core/camel-core/src/test/java/org/apache/camel/component/seda/SedaBlockWhenFullTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/seda/SedaBlockWhenFullTest.java
@@ -71,7 +71,8 @@ public class SedaBlockWhenFullTest extends ContextTestSupport {
         assertFalse(seda.isBlockWhenFull(),
                 "Seda Endpoint is not setting the correct default (should be false) for \"blockWhenFull\"");
 
-        Exception e = assertThrows(Exception.class, () -> sendTwoOverCapacity(DEFAULT_URI, QUEUE_SIZE), "The route didn't fill the queue beyond capacity: test class isn't working as intended");
+        Exception e = assertThrows(Exception.class, () -> sendTwoOverCapacity(DEFAULT_URI, QUEUE_SIZE),
+                "The route didn't fill the queue beyond capacity: test class isn't working as intended");
         assertIsInstanceOf(IllegalStateException.class, e.getCause());
     }
 
diff --git a/core/camel-core/src/test/java/org/apache/camel/component/seda/SedaConcurrentConsumersNPEIssueTest.java b/core/camel-core/src/test/java/org/apache/camel/component/seda/SedaConcurrentConsumersNPEIssueTest.java
index ad7f185ffea..d09c8a18c25 100644
--- a/core/camel-core/src/test/java/org/apache/camel/component/seda/SedaConcurrentConsumersNPEIssueTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/seda/SedaConcurrentConsumersNPEIssueTest.java
@@ -36,11 +36,12 @@ public class SedaConcurrentConsumersNPEIssueTest extends ContextTestSupport {
 
         assertMockEndpointsSatisfied();
 
-        FailedToStartRouteException e = assertThrows(FailedToStartRouteException.class, () -> context.getRouteController().startRoute("first"),
-                "Should have thrown exception");
+        FailedToStartRouteException e
+                = assertThrows(FailedToStartRouteException.class, () -> context.getRouteController().startRoute("first"),
+                        "Should have thrown exception");
 
         assertEquals("Failed to start route first because of Multiple consumers for the same endpoint is not allowed:"
-                        + " seda://foo?concurrentConsumers=5",
+                     + " seda://foo?concurrentConsumers=5",
                 e.getMessage());
     }
 
@@ -56,11 +57,12 @@ public class SedaConcurrentConsumersNPEIssueTest extends ContextTestSupport {
         // this should be okay
         context.getRouteController().startRoute("third");
 
-        FailedToStartRouteException e = assertThrows(FailedToStartRouteException.class, () -> context.getRouteController().startRoute("first"),
-                "Should have thrown exception");
+        FailedToStartRouteException e
+                = assertThrows(FailedToStartRouteException.class, () -> context.getRouteController().startRoute("first"),
+                        "Should have thrown exception");
 
         assertEquals("Failed to start route first because of Multiple consumers for the same endpoint is not allowed:"
-                        + " seda://foo?concurrentConsumers=5",
+                     + " seda://foo?concurrentConsumers=5",
                 e.getMessage());
     }
 
diff --git a/core/camel-core/src/test/java/org/apache/camel/component/seda/SedaDefaultBlockWhenFullTest.java b/core/camel-core/src/test/java/org/apache/camel/component/seda/SedaDefaultBlockWhenFullTest.java
index 090be18b1a1..48167cb9d42 100644
--- a/core/camel-core/src/test/java/org/apache/camel/component/seda/SedaDefaultBlockWhenFullTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/seda/SedaDefaultBlockWhenFullTest.java
@@ -24,8 +24,8 @@ import org.junit.jupiter.api.Timeout;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertTrue;
 import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 /**
  * Tests that a Seda component properly set blockWhenFull on endpoints.
@@ -74,12 +74,12 @@ public class SedaDefaultBlockWhenFullTest extends ContextTestSupport {
 
     @Test
     public void testSedaDefaultWhenFull() {
-            SedaEndpoint seda = context.getEndpoint(DEFAULT_URI, SedaEndpoint.class);
-            assertFalse(seda.isBlockWhenFull(),
-                    "Seda Endpoint is not setting the correct default (should be false) for \"blockWhenFull\"");
+        SedaEndpoint seda = context.getEndpoint(DEFAULT_URI, SedaEndpoint.class);
+        assertFalse(seda.isBlockWhenFull(),
+                "Seda Endpoint is not setting the correct default (should be false) for \"blockWhenFull\"");
 
-            Exception e = assertThrows(Exception.class, () -> sendTwoOverCapacity(DEFAULT_URI, QUEUE_SIZE),
-                    "The route didn't fill the queue beyond capacity: test class isn't working as intended");
+        Exception e = assertThrows(Exception.class, () -> sendTwoOverCapacity(DEFAULT_URI, QUEUE_SIZE),
+                "The route didn't fill the queue beyond capacity: test class isn't working as intended");
 
         assertIsInstanceOf(IllegalStateException.class, e.getCause());
     }
diff --git a/core/camel-core/src/test/java/org/apache/camel/component/seda/SedaDefaultUnboundedQueueSizeTest.java b/core/camel-core/src/test/java/org/apache/camel/component/seda/SedaDefaultUnboundedQueueSizeTest.java
index 1a19890607c..c55361ed030 100644
--- a/core/camel-core/src/test/java/org/apache/camel/component/seda/SedaDefaultUnboundedQueueSizeTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/seda/SedaDefaultUnboundedQueueSizeTest.java
@@ -19,8 +19,8 @@ package org.apache.camel.component.seda;
 import org.apache.camel.ContextTestSupport;
 import org.junit.jupiter.api.Test;
 
-import static org.junit.jupiter.api.Assertions.assertThrows;
 import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 
 public class SedaDefaultUnboundedQueueSizeTest extends ContextTestSupport {
 
@@ -48,7 +48,8 @@ public class SedaDefaultUnboundedQueueSizeTest extends ContextTestSupport {
         assertEquals(500, seda.getQueue().size());
 
         // sending one more hit the limit
-        Exception e = assertThrows(Exception.class, () -> template.sendBody("seda:foo", "Message overflow"), "Should thrown an exception");
+        Exception e = assertThrows(Exception.class, () -> template.sendBody("seda:foo", "Message overflow"),
+                "Should thrown an exception");
         assertIsInstanceOf(IllegalStateException.class, e.getCause());
     }
 
diff --git a/core/camel-core/src/test/java/org/apache/camel/component/seda/SedaInOutChainedTimeoutTest.java b/core/camel-core/src/test/java/org/apache/camel/component/seda/SedaInOutChainedTimeoutTest.java
index d12b79d63f5..ae8c2b33f7c 100644
--- a/core/camel-core/src/test/java/org/apache/camel/component/seda/SedaInOutChainedTimeoutTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/seda/SedaInOutChainedTimeoutTest.java
@@ -34,7 +34,8 @@ public class SedaInOutChainedTimeoutTest extends ContextTestSupport {
         // time timeout after 2 sec should trigger an immediate reply
         StopWatch watch = new StopWatch();
 
-        CamelExecutionException e = assertThrows(CamelExecutionException.class, () -> template.requestBody("seda:a?timeout=5000", "Hello World"), "Should have thrown an exception");
+        CamelExecutionException e = assertThrows(CamelExecutionException.class,
+                () -> template.requestBody("seda:a?timeout=5000", "Hello World"), "Should have thrown an exception");
         ExchangeTimedOutException cause = assertIsInstanceOf(ExchangeTimedOutException.class, e.getCause());
         assertEquals(2000, cause.getTimeout());
 
diff --git a/core/camel-core/src/test/java/org/apache/camel/component/seda/SedaInOutWithErrorTest.java b/core/camel-core/src/test/java/org/apache/camel/component/seda/SedaInOutWithErrorTest.java
index 9982f285275..460a07168bc 100644
--- a/core/camel-core/src/test/java/org/apache/camel/component/seda/SedaInOutWithErrorTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/seda/SedaInOutWithErrorTest.java
@@ -30,7 +30,8 @@ public class SedaInOutWithErrorTest extends ContextTestSupport {
     public void testInOutWithError() throws Exception {
         getMockEndpoint("mock:result").expectedMessageCount(0);
 
-        CamelExecutionException e = assertThrows(CamelExecutionException.class, () -> template.requestBody("direct:start", "Hello World", String.class),
+        CamelExecutionException e = assertThrows(CamelExecutionException.class,
+                () -> template.requestBody("direct:start", "Hello World", String.class),
                 "Should have thrown an exception");
 
         assertIsInstanceOf(IllegalArgumentException.class, e.getCause());
diff --git a/core/camel-core/src/test/java/org/apache/camel/component/seda/SedaNoConsumerTest.java b/core/camel-core/src/test/java/org/apache/camel/component/seda/SedaNoConsumerTest.java
index 66c67fc4e71..c13714b3df2 100644
--- a/core/camel-core/src/test/java/org/apache/camel/component/seda/SedaNoConsumerTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/seda/SedaNoConsumerTest.java
@@ -16,6 +16,8 @@
  */
 package org.apache.camel.component.seda;
 
+import java.util.concurrent.TimeUnit;
+
 import org.apache.camel.CamelExecutionException;
 import org.apache.camel.ContextTestSupport;
 import org.apache.camel.ExchangeTimedOutException;
@@ -23,8 +25,6 @@ import org.apache.camel.builder.NotifyBuilder;
 import org.apache.camel.builder.RouteBuilder;
 import org.junit.jupiter.api.Test;
 
-import java.util.concurrent.TimeUnit;
-
 import static org.junit.jupiter.api.Assertions.assertThrows;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 
@@ -64,7 +64,8 @@ public class SedaNoConsumerTest extends ContextTestSupport {
 
         context.start();
 
-        CamelExecutionException e = assertThrows(CamelExecutionException.class, () -> template.requestBody("direct:start", "Hello World"), "Should throw an exception");
+        CamelExecutionException e = assertThrows(CamelExecutionException.class,
+                () -> template.requestBody("direct:start", "Hello World"), "Should throw an exception");
         assertIsInstanceOf(ExchangeTimedOutException.class, e.getCause());
     }
 
@@ -79,7 +80,8 @@ public class SedaNoConsumerTest extends ContextTestSupport {
 
         context.start();
 
-        CamelExecutionException e = assertThrows(CamelExecutionException.class, () -> template.sendBody("direct:start", "Hello World"), "Should throw an exception");
+        CamelExecutionException e = assertThrows(CamelExecutionException.class,
+                () -> template.sendBody("direct:start", "Hello World"), "Should throw an exception");
         assertIsInstanceOf(SedaConsumerNotAvailableException.class, e.getCause());
     }
 
@@ -124,7 +126,8 @@ public class SedaNoConsumerTest extends ContextTestSupport {
         context.getRouteController().stopRoute("stopThisRoute");
         TimeUnit.MILLISECONDS.sleep(100);
 
-        CamelExecutionException e = assertThrows(CamelExecutionException.class, () -> template.sendBody("seda:foo?failIfNoConsumers=true", "Hello World"), "Should throw an exception");
+        CamelExecutionException e = assertThrows(CamelExecutionException.class,
+                () -> template.sendBody("seda:foo?failIfNoConsumers=true", "Hello World"), "Should throw an exception");
         assertIsInstanceOf(SedaConsumerNotAvailableException.class, e.getCause());
     }
 
diff --git a/core/camel-core/src/test/java/org/apache/camel/component/seda/SedaTimeoutTest.java b/core/camel-core/src/test/java/org/apache/camel/component/seda/SedaTimeoutTest.java
index 29f598ff19f..62bb1f81936 100644
--- a/core/camel-core/src/test/java/org/apache/camel/component/seda/SedaTimeoutTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/seda/SedaTimeoutTest.java
@@ -16,15 +16,15 @@
  */
 package org.apache.camel.component.seda;
 
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Future;
+
 import org.apache.camel.CamelExecutionException;
 import org.apache.camel.ContextTestSupport;
 import org.apache.camel.ExchangeTimedOutException;
 import org.apache.camel.builder.RouteBuilder;
 import org.junit.jupiter.api.Test;
 
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Future;
-
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertNotNull;
 import static org.junit.jupiter.api.Assertions.assertThrows;
diff --git a/core/camel-core/src/test/java/org/apache/camel/component/seda/SedaWaitForTaskCompleteOnCompletionTest.java b/core/camel-core/src/test/java/org/apache/camel/component/seda/SedaWaitForTaskCompleteOnCompletionTest.java
index ce1d421fb46..fd95595cec5 100644
--- a/core/camel-core/src/test/java/org/apache/camel/component/seda/SedaWaitForTaskCompleteOnCompletionTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/seda/SedaWaitForTaskCompleteOnCompletionTest.java
@@ -35,8 +35,9 @@ public class SedaWaitForTaskCompleteOnCompletionTest extends ContextTestSupport
     public void testAlways() throws Exception {
         getMockEndpoint("mock:result").expectedMessageCount(0);
 
-        CamelExecutionException e = assertThrows(CamelExecutionException.class, () -> template.sendBody("direct:start", "Hello World"),
-                "Should have thrown an exception");
+        CamelExecutionException e
+                = assertThrows(CamelExecutionException.class, () -> template.sendBody("direct:start", "Hello World"),
+                        "Should have thrown an exception");
 
         assertIsInstanceOf(IllegalArgumentException.class, e.getCause());
         assertEquals("Forced", e.getCause().getMessage());
diff --git a/core/camel-core/src/test/java/org/apache/camel/component/timer/TimerEndpointTest.java b/core/camel-core/src/test/java/org/apache/camel/component/timer/TimerEndpointTest.java
index 5b6ab042f2b..46dd377c08a 100644
--- a/core/camel-core/src/test/java/org/apache/camel/component/timer/TimerEndpointTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/timer/TimerEndpointTest.java
@@ -16,6 +16,8 @@
  */
 package org.apache.camel.component.timer;
 
+import java.util.Timer;
+
 import org.apache.camel.ContextTestSupport;
 import org.apache.camel.Endpoint;
 import org.apache.camel.RuntimeCamelException;
@@ -24,8 +26,6 @@ import org.apache.camel.component.mock.MockEndpoint;
 import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.Test;
 
-import java.util.Timer;
-
 public class TimerEndpointTest extends ContextTestSupport {
 
     @Override
diff --git a/core/camel-core/src/test/java/org/apache/camel/component/timer/TimerWithTimeOptionTest.java b/core/camel-core/src/test/java/org/apache/camel/component/timer/TimerWithTimeOptionTest.java
index 19c57198778..f79e11c709a 100644
--- a/core/camel-core/src/test/java/org/apache/camel/component/timer/TimerWithTimeOptionTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/timer/TimerWithTimeOptionTest.java
@@ -16,6 +16,9 @@
  */
 package org.apache.camel.component.timer;
 
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
 import org.apache.camel.ContextTestSupport;
 import org.apache.camel.FailedToCreateRouteException;
 import org.apache.camel.builder.RouteBuilder;
@@ -23,9 +26,6 @@ import org.apache.camel.component.mock.MockEndpoint;
 import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.Test;
 
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
 public class TimerWithTimeOptionTest extends ContextTestSupport {
 
     @Override
diff --git a/core/camel-core/src/test/java/org/apache/camel/component/validator/ValidatorLazyStartProducerTest.java b/core/camel-core/src/test/java/org/apache/camel/component/validator/ValidatorLazyStartProducerTest.java
index ba46f959b94..36648958eb7 100644
--- a/core/camel-core/src/test/java/org/apache/camel/component/validator/ValidatorLazyStartProducerTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/validator/ValidatorLazyStartProducerTest.java
@@ -16,12 +16,12 @@
  */
 package org.apache.camel.component.validator;
 
+import java.io.FileNotFoundException;
+
 import org.apache.camel.ContextTestSupport;
 import org.apache.camel.builder.RouteBuilder;
 import org.junit.jupiter.api.Test;
 
-import java.io.FileNotFoundException;
-
 import static org.junit.jupiter.api.Assertions.assertThrows;
 
 public class ValidatorLazyStartProducerTest extends ContextTestSupport {
@@ -30,7 +30,7 @@ public class ValidatorLazyStartProducerTest extends ContextTestSupport {
     public void testLazyStartProducerFail() throws Exception {
         getMockEndpoint("mock:result").expectedMessageCount(0);
 
-        Exception e = assertThrows(Exception.class, () ->             template.sendBody("direct:fail",
+        Exception e = assertThrows(Exception.class, () -> template.sendBody("direct:fail",
                 "<mail xmlns='http://foo.com/bar'><subject>Hey</subject><body>Hello world!</body></mail>"),
                 "Should throw exception");
 


[camel] 01/04: CAMEL-19694: camel-jbang - Export can now configure java package name to use for source code

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 3dc2228178f2c094e49d16e6b66bbae31f9fff73
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Thu Aug 3 14:30:39 2023 +0200

    CAMEL-19694: camel-jbang - Export can now configure java package name to use for source code
---
 .../camel/dsl/jbang/core/commands/Export.java      |  1 +
 .../dsl/jbang/core/commands/ExportBaseCommand.java | 22 +++++++++++--
 .../dsl/jbang/core/commands/ExportCamelMain.java   | 36 ++++++++++++++++------
 .../dsl/jbang/core/commands/ExportQuarkus.java     | 13 +++++---
 .../dsl/jbang/core/commands/ExportSpringBoot.java  | 15 ++++++---
 .../src/main/resources/templates/main.tmpl         |  2 +-
 6 files changed, 66 insertions(+), 23 deletions(-)

diff --git a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Export.java b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Export.java
index aaeaca73e42..830e36a0b07 100644
--- a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Export.java
+++ b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Export.java
@@ -120,6 +120,7 @@ public class Export extends ExportBaseCommand {
         cmd.secretsRefresh = this.secretsRefresh;
         cmd.secretsRefreshProviders = this.secretsRefreshProviders;
         cmd.openapi = this.openapi;
+        cmd.packageName = this.packageName;
         // run export
         return cmd.export();
     }
diff --git a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ExportBaseCommand.java b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ExportBaseCommand.java
index 543c47e7d35..bd7df4db115 100644
--- a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ExportBaseCommand.java
+++ b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ExportBaseCommand.java
@@ -158,6 +158,12 @@ abstract class ExportBaseCommand extends CamelCommand {
     @CommandLine.Option(names = { "--logging-level" }, defaultValue = "info", description = "Logging level")
     protected String loggingLevel;
 
+    @CommandLine.Option(names = { "--package-name" },
+                        description = "For Java source files should they have the given package name. By default the package name is computed from the Maven GAV. "
+                                      +
+                                      "Use false to turn off and not include package name in the Java source files.")
+    protected String packageName;
+
     @CommandLine.Option(names = { "--fresh" }, description = "Make sure we use fresh (i.e. non-cached) resources")
     protected boolean fresh;
 
@@ -443,8 +449,10 @@ abstract class ExportBaseCommand extends CamelCommand {
                             }
                         } else {
                             fos = new FileOutputStream(out);
-                            lines.add(0, "");
-                            lines.add(0, "package " + packageName + ";");
+                            if (packageName != null && !"false".equalsIgnoreCase(packageName)) {
+                                lines.add(0, "");
+                                lines.add(0, "package " + packageName + ";");
+                            }
                         }
                         for (String line : lines) {
                             adjustJavaSourceFileLine(line, fos);
@@ -462,7 +470,15 @@ abstract class ExportBaseCommand extends CamelCommand {
         // noop
     }
 
-    protected String exportPackageName(String groupId, String artifactId) {
+    protected String exportPackageName(String groupId, String artifactId, String packageName) {
+        if ("false".equalsIgnoreCase(packageName)) {
+            return null; // package names are turned off (we should use root package)
+        }
+        if (packageName != null) {
+            return packageName; // use specific package name
+        }
+
+        // compute package name based on Maven GAV
         // for package name it must be in lower-case and alpha/numeric
         String s = groupId + "." + artifactId;
         StringBuilder sb = new StringBuilder();
diff --git a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ExportCamelMain.java b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ExportCamelMain.java
index 54cc96a053e..9c5d9df7e6d 100644
--- a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ExportCamelMain.java
+++ b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ExportCamelMain.java
@@ -82,10 +82,15 @@ class ExportCamelMain extends Export {
         FileUtil.removeDir(buildDir);
         buildDir.mkdirs();
 
-        // copy source files
-        String packageName = exportPackageName(ids[0], ids[1]);
+        // compute source folders
         File srcJavaDirRoot = new File(BUILD_DIR, "src/main/java");
-        File srcJavaDir = new File(srcJavaDirRoot, packageName.replace('.', File.separatorChar));
+        String srcPackageName = exportPackageName(ids[0], ids[1], packageName);
+        File srcJavaDir;
+        if (srcPackageName == null) {
+            srcJavaDir = srcJavaDirRoot;
+        } else {
+            srcJavaDir = new File(srcJavaDirRoot, srcPackageName.replace('.', File.separatorChar));
+        }
         srcJavaDir.mkdirs();
         File srcResourcesDir = new File(BUILD_DIR, "src/main/resources");
         srcResourcesDir.mkdirs();
@@ -93,12 +98,15 @@ class ExportCamelMain extends Export {
         srcCamelResourcesDir.mkdirs();
         File srcKameletsResourcesDir = new File(BUILD_DIR, "src/main/resources/kamelets");
         srcKameletsResourcesDir.mkdirs();
+        // copy source files
         copySourceFiles(settings, profile, srcJavaDirRoot, srcJavaDir, srcResourcesDir, srcCamelResourcesDir,
-                srcKameletsResourcesDir, packageName);
+                srcKameletsResourcesDir, srcPackageName);
         // copy from settings to profile
         copySettingsAndProfile(settings, profile, srcResourcesDir, prop -> {
-            if (!prop.containsKey("camel.main.basePackageScan") && !prop.containsKey("camel.main.base-package-scan")) {
-                prop.put("camel.main.basePackageScan", packageName);
+            if (!prop.containsKey("camel.main.basePackageScan")
+                    && !prop.containsKey("camel.main.base-package-scan")) {
+                // use dot as root package if no package are in use
+                prop.put("camel.main.basePackageScan", srcPackageName == null ? "." : srcPackageName);
             }
             if (!hasModeline(settings)) {
                 prop.remove("camel.main.modeline");
@@ -117,13 +125,13 @@ class ExportCamelMain extends Export {
             return prop;
         });
         // create main class
-        createMainClassSource(srcJavaDir, packageName, mainClassname);
+        createMainClassSource(srcJavaDir, srcPackageName, mainClassname);
         // gather dependencies
         Set<String> deps = resolveDependencies(settings, profile);
         // copy local lib JARs
         copyLocalLibDependencies(deps);
         if ("maven".equals(buildTool)) {
-            createMavenPom(settings, profile, new File(BUILD_DIR, "pom.xml"), deps, packageName);
+            createMavenPom(settings, profile, new File(BUILD_DIR, "pom.xml"), deps, srcPackageName);
             if (mavenWrapper) {
                 copyMavenWrapper();
             }
@@ -156,7 +164,11 @@ class ExportCamelMain extends Export {
         context = context.replaceFirst("\\{\\{ \\.Version }}", ids[2]);
         context = context.replaceFirst("\\{\\{ \\.JavaVersion }}", javaVersion);
         context = context.replaceAll("\\{\\{ \\.CamelVersion }}", camelVersion);
-        context = context.replaceAll("\\{\\{ \\.MainClassname }}", packageName + "." + mainClassname);
+        if (packageName != null) {
+            context = context.replaceAll("\\{\\{ \\.MainClassname }}", packageName + "." + mainClassname);
+        } else {
+            context = context.replaceAll("\\{\\{ \\.MainClassname }}", mainClassname);
+        }
 
         Properties prop = new CamelCaseOrderedProperties();
         RuntimeUtil.loadProperties(prop, settings);
@@ -307,7 +319,11 @@ class ExportCamelMain extends Export {
         String context = IOHelper.loadText(is);
         IOHelper.close(is);
 
-        context = context.replaceFirst("\\{\\{ \\.PackageName }}", packageName);
+        if (packageName != null) {
+            context = context.replaceFirst("\\{\\{ \\.PackageName }}", "package " + packageName + ";");
+        } else {
+            context = context.replaceFirst("\\{\\{ \\.PackageName }}", "");
+        }
         context = context.replaceAll("\\{\\{ \\.MainClassname }}", mainClassname);
         IOHelper.writeText(context, new FileOutputStream(srcJavaDir + "/" + mainClassname + ".java", false));
     }
diff --git a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ExportQuarkus.java b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ExportQuarkus.java
index aa7cc6bce78..c525ff3a1a2 100644
--- a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ExportQuarkus.java
+++ b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ExportQuarkus.java
@@ -85,10 +85,14 @@ class ExportQuarkus extends Export {
         FileUtil.removeDir(buildDir);
         buildDir.mkdirs();
 
-        // copy source files
-        String packageName = exportPackageName(ids[0], ids[1]);
         File srcJavaDirRoot = new File(BUILD_DIR, "src/main/java");
-        File srcJavaDir = new File(srcJavaDirRoot, packageName.replace('.', File.separatorChar));
+        String srcPackageName = exportPackageName(ids[0], ids[1], packageName);
+        File srcJavaDir;
+        if (srcPackageName == null) {
+            srcJavaDir = srcJavaDirRoot;
+        } else {
+            srcJavaDir = new File(srcJavaDirRoot, srcPackageName.replace('.', File.separatorChar));
+        }
         srcJavaDir.mkdirs();
         File srcResourcesDir = new File(BUILD_DIR, "src/main/resources");
         srcResourcesDir.mkdirs();
@@ -96,8 +100,9 @@ class ExportQuarkus extends Export {
         srcCamelResourcesDir.mkdirs();
         File srcKameletsResourcesDir = new File(BUILD_DIR, "src/main/resources/kamelets");
         srcKameletsResourcesDir.mkdirs();
+        // copy source files
         copySourceFiles(settings, profile, srcJavaDirRoot, srcJavaDir, srcResourcesDir, srcCamelResourcesDir,
-                srcKameletsResourcesDir, packageName);
+                srcKameletsResourcesDir, srcPackageName);
         // copy from settings to profile
         copySettingsAndProfile(settings, profile, srcResourcesDir, prop -> {
             if (!hasModeline(settings)) {
diff --git a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ExportSpringBoot.java b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ExportSpringBoot.java
index e393f3ef0ea..5c9e5103e7a 100644
--- a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ExportSpringBoot.java
+++ b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ExportSpringBoot.java
@@ -86,10 +86,14 @@ class ExportSpringBoot extends Export {
         FileUtil.removeDir(buildDir);
         buildDir.mkdirs();
 
-        // copy source files
-        String packageName = exportPackageName(ids[0], ids[1]);
         File srcJavaDirRoot = new File(BUILD_DIR, "src/main/java");
-        File srcJavaDir = new File(srcJavaDirRoot, packageName.replace('.', File.separatorChar));
+        String srcPackageName = exportPackageName(ids[0], ids[1], packageName);
+        File srcJavaDir;
+        if (srcPackageName == null) {
+            srcJavaDir = srcJavaDirRoot;
+        } else {
+            srcJavaDir = new File(srcJavaDirRoot, srcPackageName.replace('.', File.separatorChar));
+        }
         srcJavaDir.mkdirs();
         File srcResourcesDir = new File(BUILD_DIR, "src/main/resources");
         srcResourcesDir.mkdirs();
@@ -97,8 +101,9 @@ class ExportSpringBoot extends Export {
         srcCamelResourcesDir.mkdirs();
         File srcKameletsResourcesDir = new File(BUILD_DIR, "src/main/resources/kamelets");
         srcKameletsResourcesDir.mkdirs();
+        // copy source files
         copySourceFiles(settings, profile, srcJavaDirRoot, srcJavaDir, srcResourcesDir, srcCamelResourcesDir,
-                srcKameletsResourcesDir, packageName);
+                srcKameletsResourcesDir, srcPackageName);
         // copy from settings to profile
         copySettingsAndProfile(settings, profile, srcResourcesDir, prop -> {
             if (!hasModeline(settings)) {
@@ -107,7 +112,7 @@ class ExportSpringBoot extends Export {
             return prop;
         });
         // create main class
-        createMainClassSource(srcJavaDir, packageName, mainClassname);
+        createMainClassSource(srcJavaDir, srcPackageName, mainClassname);
         // gather dependencies
         Set<String> deps = resolveDependencies(settings, profile);
         // copy local lib JARs
diff --git a/dsl/camel-jbang/camel-jbang-core/src/main/resources/templates/main.tmpl b/dsl/camel-jbang/camel-jbang-core/src/main/resources/templates/main.tmpl
index bf0bf30cd3c..52e141843ca 100644
--- a/dsl/camel-jbang/camel-jbang-core/src/main/resources/templates/main.tmpl
+++ b/dsl/camel-jbang/camel-jbang-core/src/main/resources/templates/main.tmpl
@@ -1,4 +1,4 @@
-package {{ .PackageName }};
+{{ .PackageName }}
 
 import org.apache.camel.main.Main;
 


[camel] 02/04: camel class resolver should be able to scan from root package if you use dot as the package name.

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit a76bcab3c546bb401f07cd416e0ded65055f641e
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Thu Aug 3 14:35:40 2023 +0200

    camel class resolver should be able to scan from root package if you use dot as the package name.
---
 .../java/org/apache/camel/impl/engine/BasePackageScanResolver.java | 2 +-
 .../apache/camel/impl/engine/DefaultPackageScanClassResolver.java  | 7 ++++++-
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/BasePackageScanResolver.java b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/BasePackageScanResolver.java
index 7d703de948c..30968f2e1f4 100644
--- a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/BasePackageScanResolver.java
+++ b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/BasePackageScanResolver.java
@@ -137,7 +137,7 @@ public abstract class BasePackageScanResolver extends ServiceSupport implements
 
         // If the URL is a jar, the URLClassloader.getResources() seems to require a trailing slash.  The
         // trailing slash is harmless for other URLs
-        if (!packageName.endsWith("/")) {
+        if (!packageName.isEmpty() && !packageName.endsWith("/")) {
             packageName = packageName + "/";
         }
         return loader.getResources(packageName);
diff --git a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/DefaultPackageScanClassResolver.java b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/DefaultPackageScanClassResolver.java
index e5027274903..f3f72b0910b 100644
--- a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/DefaultPackageScanClassResolver.java
+++ b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/DefaultPackageScanClassResolver.java
@@ -149,7 +149,12 @@ public class DefaultPackageScanClassResolver extends BasePackageScanResolver
     }
 
     protected void find(PackageScanFilter test, String packageName, Set<Class<?>> classes) {
-        packageName = packageName.replace('.', '/');
+        // special for root package
+        if (".".equals(packageName)) {
+            packageName = "";
+        } else {
+            packageName = packageName.replace('.', '/');
+        }
 
         Set<ClassLoader> set = getClassLoaders();
 


[camel] 04/04: camel class resolver should be able to scan from root package if you use dot as the package name.

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 4750a40e2ae9fe7dd6b68b6886120ddc42293aaa
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Thu Aug 3 14:52:41 2023 +0200

    camel class resolver should be able to scan from root package if you use dot as the package name.
---
 .../camel/impl/engine/DefaultPackageScanResourceResolver.java  | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/DefaultPackageScanResourceResolver.java b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/DefaultPackageScanResourceResolver.java
index 6fa8a18eaf9..358030969ad 100644
--- a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/DefaultPackageScanResourceResolver.java
+++ b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/DefaultPackageScanResourceResolver.java
@@ -105,10 +105,16 @@ public class DefaultPackageScanResourceResolver extends BasePackageScanResolver
             Set<Resource> resources,
             String subPattern) {
 
-        packageName = packageName.replace('.', '/');
+        // special for root package
+        if (".".equals(packageName)) {
+            packageName = "";
+        } else {
+            packageName = packageName.replace('.', '/');
+        }
+
         // If the URL is a jar, the URLClassloader.getResources() seems to require a trailing slash.
         // The trailing slash is harmless for other URLs
-        if (!packageName.endsWith("/")) {
+        if (!packageName.isEmpty() && !packageName.endsWith("/")) {
             packageName = packageName + "/";
         }