[
https://issues.apache.org/jira/browse/CAMEL-12888?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16654058#comment-16654058
]
ASF GitHub Bot commented on CAMEL-12888:
----------------------------------------
aldettinger closed pull request #2567: CAMEL-12888: Fixed the short java type
generation in camel-package-ma…
URL: https://github.com/apache/camel/pull/2567
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/camel-core/src/main/docs/seda-component.adoc
b/camel-core/src/main/docs/seda-component.adoc
index d12159c8f1d..cdc99f3ef8d 100644
--- a/camel-core/src/main/docs/seda-component.adoc
+++ b/camel-core/src/main/docs/seda-component.adoc
@@ -48,7 +48,7 @@ The SEDA component supports 6 options, which are listed below.
| Name | Description | Default | Type
| *queueSize* (advanced) | Sets the default maximum capacity of the SEDA queue
(i.e., the number of messages it can hold). | 1000 | int
| *concurrentConsumers* (consumer) | Sets the default number of concurrent
threads processing exchanges. | 1 | int
-| *defaultQueueFactory* (advanced) | Sets the default queue factory. | |
Exchange>
+| *defaultQueueFactory* (advanced) | Sets the default queue factory. | |
BlockingQueueFactory
| *defaultBlockWhenFull* (producer) | Whether a thread that sends messages to
a full SEDA queue will block until the queue's capacity is no longer exhausted.
By default, an exception will be thrown stating that the queue is full. By
enabling this option, the calling thread will instead block and wait until the
message can be accepted. | false | boolean
| *defaultOfferTimeout* (producer) | Whether a thread that sends messages to a
full SEDA queue will block until the queue's capacity is no longer exhausted.
By default, an exception will be thrown stating that the queue is full. By
enabling this option, where a configured timeout can be added to the block
case. Utilizing the .offer(timeout) method of the underlining java queue | |
long
| *resolveProperty Placeholders* (advanced) | Whether the component should
resolve property placeholders on itself when starting. Only properties which
are of String type can use property placeholders. | true | boolean
diff --git a/camel-core/src/main/docs/stub-component.adoc
b/camel-core/src/main/docs/stub-component.adoc
index eb112d36cd9..8f7840c9ba9 100644
--- a/camel-core/src/main/docs/stub-component.adoc
+++ b/camel-core/src/main/docs/stub-component.adoc
@@ -38,7 +38,7 @@ The Stub component supports 6 options, which are listed below.
| Name | Description | Default | Type
| *queueSize* (advanced) | Sets the default maximum capacity of the SEDA queue
(i.e., the number of messages it can hold). | 1000 | int
| *concurrentConsumers* (consumer) | Sets the default number of concurrent
threads processing exchanges. | 1 | int
-| *defaultQueueFactory* (advanced) | Sets the default queue factory. | |
Exchange>
+| *defaultQueueFactory* (advanced) | Sets the default queue factory. | |
BlockingQueueFactory
| *defaultBlockWhenFull* (producer) | Whether a thread that sends messages to
a full SEDA queue will block until the queue's capacity is no longer exhausted.
By default, an exception will be thrown stating that the queue is full. By
enabling this option, the calling thread will instead block and wait until the
message can be accepted. | false | boolean
| *defaultOfferTimeout* (producer) | Whether a thread that sends messages to a
full SEDA queue will block until the queue's capacity is no longer exhausted.
By default, an exception will be thrown stating that the queue is full. By
enabling this option, where a configured timeout can be added to the block
case. Utilizing the .offer(timeout) method of the underlining java queue | |
long
| *resolveProperty Placeholders* (advanced) | Whether the component should
resolve property placeholders on itself when starting. Only properties which
are of String type can use property placeholders. | true | boolean
diff --git a/camel-core/src/main/docs/vm-component.adoc
b/camel-core/src/main/docs/vm-component.adoc
index 8e1c3a9128f..9b9279a8b0e 100644
--- a/camel-core/src/main/docs/vm-component.adoc
+++ b/camel-core/src/main/docs/vm-component.adoc
@@ -68,7 +68,7 @@ The VM component supports 6 options, which are listed below.
| Name | Description | Default | Type
| *queueSize* (advanced) | Sets the default maximum capacity of the SEDA queue
(i.e., the number of messages it can hold). | 1000 | int
| *concurrentConsumers* (consumer) | Sets the default number of concurrent
threads processing exchanges. | 1 | int
-| *defaultQueueFactory* (advanced) | Sets the default queue factory. | |
Exchange>
+| *defaultQueueFactory* (advanced) | Sets the default queue factory. | |
BlockingQueueFactory
| *defaultBlockWhenFull* (producer) | Whether a thread that sends messages to
a full SEDA queue will block until the queue's capacity is no longer exhausted.
By default, an exception will be thrown stating that the queue is full. By
enabling this option, the calling thread will instead block and wait until the
message can be accepted. | false | boolean
| *defaultOfferTimeout* (producer) | Whether a thread that sends messages to a
full SEDA queue will block until the queue's capacity is no longer exhausted.
By default, an exception will be thrown stating that the queue is full. By
enabling this option, where a configured timeout can be added to the block
case. Utilizing the .offer(timeout) method of the underlining java queue | |
long
| *resolveProperty Placeholders* (advanced) | Whether the component should
resolve property placeholders on itself when starting. Only properties which
are of String type can use property placeholders. | true | boolean
diff --git a/components/camel-ehcache/src/main/docs/ehcache-component.adoc
b/components/camel-ehcache/src/main/docs/ehcache-component.adoc
index 05a787aa64c..f4cc6c81587 100644
--- a/components/camel-ehcache/src/main/docs/ehcache-component.adoc
+++ b/components/camel-ehcache/src/main/docs/ehcache-component.adoc
@@ -48,7 +48,7 @@ The Ehcache component supports 7 options, which are listed
below.
| *configuration* (advanced) | Sets the global component configuration | |
EhcacheConfiguration
| *cacheManager* (common) | The cache manager | | CacheManager
| *cacheManager Configuration* (common) | The cache manager configuration | |
Configuration
-| *cacheConfiguration* (common) | The default cache configuration to be used
to create caches. | | CacheConfiguration<?,?>
+| *cacheConfiguration* (common) | The default cache configuration to be used
to create caches. | | CacheConfiguration
| *cachesConfigurations* (common) | A map of caches configurations to be used
to create caches. | | Map
| *cacheConfigurationUri* (common) | URI pointing to the Ehcache XML
configuration file's location | | String
| *resolveProperty Placeholders* (advanced) | Whether the component should
resolve property placeholders on itself when starting. Only properties which
are of String type can use property placeholders. | true | boolean
diff --git
a/components/camel-guava-eventbus/src/main/docs/guava-eventbus-component.adoc
b/components/camel-guava-eventbus/src/main/docs/guava-eventbus-component.adoc
index 9f3eeebd403..cdf00cd26be 100644
---
a/components/camel-guava-eventbus/src/main/docs/guava-eventbus-component.adoc
+++
b/components/camel-guava-eventbus/src/main/docs/guava-eventbus-component.adoc
@@ -54,7 +54,7 @@ The Guava EventBus component supports 3 options, which are
listed below.
|===
| Name | Description | Default | Type
| *eventBus* (common) | To use the given Guava EventBus instance | | EventBus
-| *listenerInterface* (common) | The interface with method(s) marked with the
Subscribe annotation. Dynamic proxy will be created over the interface so it
could be registered as the EventBus listener. Particularly useful when creating
multi-event listeners and for handling DeadEvent properly. This option cannot
be used together with eventClass option. | | Class<?>
+| *listenerInterface* (common) | The interface with method(s) marked with the
Subscribe annotation. Dynamic proxy will be created over the interface so it
could be registered as the EventBus listener. Particularly useful when creating
multi-event listeners and for handling DeadEvent properly. This option cannot
be used together with eventClass option. | | Class
| *resolveProperty Placeholders* (advanced) | Whether the component should
resolve property placeholders on itself when starting. Only properties which
are of String type can use property placeholders. | true | boolean
|===
// component options: END
diff --git a/components/camel-milo/src/main/docs/milo-server-component.adoc
b/components/camel-milo/src/main/docs/milo-server-component.adoc
index 696f00ccd99..da228426844 100644
--- a/components/camel-milo/src/main/docs/milo-server-component.adoc
+++ b/components/camel-milo/src/main/docs/milo-server-component.adoc
@@ -42,7 +42,7 @@ The OPC UA Server component supports 20 options, which are
listed below.
| *serverName* (common) | Server name | | String
| *hostname* (common) | Server hostname | | String
| *securityPolicies* (common) | Security policies | | Set
-| *securityPoliciesById* (common) | Security policies by URI or name | |
String>
+| *securityPoliciesById* (common) | Security policies by URI or name | |
Collection
| *userAuthentication Credentials* (common) | Set user password combinations
in the form of user1:pwd1,user2:pwd2 Usernames and passwords will be URL
decoded | | String
| *enableAnonymous Authentication* (common) | Enable anonymous authentication,
disabled by default | false | boolean
| *usernameSecurityPolicy Uri* (common) | Set the UserTokenPolicy used when |
| SecurityPolicy
@@ -50,7 +50,7 @@ The OPC UA Server component supports 20 options, which are
listed below.
| *buildInfo* (common) | Server build info | | BuildInfo
| *serverCertificate* (common) | Server certificate | | Result
| *certificateManager* (common) | Server certificate manager | |
CertificateManager
-| *certificateValidator* (common) | Validator for client certificates | |
CertificateValidator>
+| *certificateValidator* (common) | Validator for client certificates | |
Supplier
| *defaultCertificate Validator* (common) | Validator for client certificates
using default file based approach | | File
| *resolveProperty Placeholders* (advanced) | Whether the component should
resolve property placeholders on itself when starting. Only properties which
are of String type can use property placeholders. | true | boolean
|===
diff --git a/tooling/maven/camel-package-maven-plugin/pom.xml
b/tooling/maven/camel-package-maven-plugin/pom.xml
index 50afd0f6fc4..ed4a0b73fbc 100644
--- a/tooling/maven/camel-package-maven-plugin/pom.xml
+++ b/tooling/maven/camel-package-maven-plugin/pom.xml
@@ -172,6 +172,26 @@
<groupId>org.apache.camel</groupId>
<artifactId>spi-annotations</artifactId>
</dependency>
+
+ <!-- testing -->
+ <dependency>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-api</artifactId>
+ <version>${junit-jupiter-version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-engine</artifactId>
+ <version>${junit-jupiter-version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-params</artifactId>
+ <version>${junit-jupiter-version}</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<profiles>
diff --git
a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/model/ComponentOptionModel.java
b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/model/ComponentOptionModel.java
index d74f314510c..ba758a546ec 100644
---
a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/model/ComponentOptionModel.java
+++
b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/model/ComponentOptionModel.java
@@ -155,20 +155,8 @@ public String getShortJavaType() {
}
public String getShortJavaType(int watermark) {
- if (javaType.startsWith("java.util.Map")) {
- return "Map";
- } else if (javaType.startsWith("java.util.Set")) {
- return "Set";
- } else if (javaType.startsWith("java.util.List")) {
- return "List";
- }
-
- String text = javaType;
- int pos = text.lastIndexOf(".");
- if (pos != -1) {
- text = text.substring(pos + 1);
- }
+ String text = javaType.replaceAll("<.*>",
"").replaceAll(".*[.]([^.]+)", "$1");
// if its some kind of java object then lets wrap it as its long
if ("object".equals(type)) {
diff --git
a/tooling/maven/camel-package-maven-plugin/src/test/java/org/apache/camel/maven/packaging/model/ComponentOptionModelTest.java
b/tooling/maven/camel-package-maven-plugin/src/test/java/org/apache/camel/maven/packaging/model/ComponentOptionModelTest.java
new file mode 100644
index 00000000000..dc43fd7e3ef
--- /dev/null
+++
b/tooling/maven/camel-package-maven-plugin/src/test/java/org/apache/camel/maven/packaging/model/ComponentOptionModelTest.java
@@ -0,0 +1,58 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.maven.packaging.model;
+
+import java.util.stream.Stream;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.Arguments;
+import org.junit.jupiter.params.provider.MethodSource;
+
+import static org.junit.jupiter.params.provider.Arguments.arguments;
+
+public class ComponentOptionModelTest {
+
+ ComponentOptionModel componentOptionModelUnderTest;
+
+ @BeforeEach
+ public void setup() {
+ componentOptionModelUnderTest = new ComponentOptionModel();
+ }
+
+ static Stream<Arguments> getShortJavaTypeVarations() {
+ return Stream.of(
+ arguments("String", "String"),
+ arguments("String", "java.lang.String"),
+ arguments("List", "List<String>"),
+ arguments("List", "java.util.List<String>"),
+ arguments("List", "List<java.lang.String>"),
+ arguments("BlockingQueue",
"java.util.concurrent.BlockingQueue<org.apache.camel.Exchange>"),
+ arguments("List",
"java.util.List<Map<String,Integer>>"),
+ arguments("List",
"java.util.List<Map<java.lang.String,Integer>>"),
+ arguments("List",
"java.util.List<Map<String,java.lang.Integer>>"),
+ arguments("List",
"java.util.List<Map<java.lang.String,java.lang.Integer>>"));
+ };
+
+ @ParameterizedTest
+ @MethodSource("getShortJavaTypeVarations")
+ public void getShortTypeShouldSucceed(String expectedShortJavaType, String
javaType) {
+ componentOptionModelUnderTest.setJavaType(javaType);
+ Assertions.assertEquals(expectedShortJavaType,
componentOptionModelUnderTest.getShortJavaType());
+ }
+}
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> The camel-maven-package-plugin issue wrong short java type
> ----------------------------------------------------------
>
> Key: CAMEL-12888
> URL: https://issues.apache.org/jira/browse/CAMEL-12888
> Project: Camel
> Issue Type: Bug
> Components: tooling
> Affects Versions: 2.23.0
> Reporter: Alex Dettinger
> Assignee: Alex Dettinger
> Priority: Minor
>
> For instance, [the seda component documentation
> |https://github.com/apache/camel/blob/master/camel-core/src/main/docs/seda-component.adoc]
> exhibits *Exchange>* as the type for the option *defaultQueueFactory*
> whereas we should issue *BlockingQueueFactory*.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)