You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by kl...@apache.org on 2022/05/09 19:43:02 UTC

[camel-examples] branch main updated: CAMEL-17847: fix examples which have failing tests (#90)

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

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


The following commit(s) were added to refs/heads/main by this push:
     new b28a86fb CAMEL-17847: fix examples which have failing tests (#90)
b28a86fb is described below

commit b28a86fbc31340baa8e20e8d6d4e9fa87ee313a9
Author: klease <38...@users.noreply.github.com>
AuthorDate: Mon May 9 21:42:58 2022 +0200

    CAMEL-17847: fix examples which have failing tests (#90)
    
    JOOQ: fix path in DB URI
    Kamelet-chunknorris: change YAML to match syntax change
    OAIPMH: use longer timeout to handle large amount of messages
    Transformer-demo: change Spring contex XML to remove obsolete ref attribute
    Widget-gadget-java: modify the way activemq bean is bound to registry
---
 examples/jooq/src/main/resources/config.properties        |  2 +-
 .../resources/kamelets/chuck-norris-source.kamelet.yaml   |  4 ++--
 .../java/org/apache/camel/example/oaipmh/OAIPMHTest.java  |  2 +-
 .../src/main/resources/META-INF/spring/camel-context.xml  | 11 +++--------
 .../org/apache/camel/example/widget/WidgetGadgetTest.java | 15 +++++++++------
 5 files changed, 16 insertions(+), 18 deletions(-)

diff --git a/examples/jooq/src/main/resources/config.properties b/examples/jooq/src/main/resources/config.properties
index cdcb6813..c470cc56 100644
--- a/examples/jooq/src/main/resources/config.properties
+++ b/examples/jooq/src/main/resources/config.properties
@@ -16,7 +16,7 @@
 ## ---------------------------------------------------------------------------
 #Database Configuration
 db.driver=org.hsqldb.jdbcDriver
-db.url=jdbc:hsqldb:file:target/db;shutdown=true
+db.url=jdbc:hsqldb:file:${basedir}/target/db;shutdown=true
 db.pool.maxActive=50
 db.pool.maxIdle=20
 db.username=sa
diff --git a/examples/kamelet-chucknorris/src/main/resources/kamelets/chuck-norris-source.kamelet.yaml b/examples/kamelet-chucknorris/src/main/resources/kamelets/chuck-norris-source.kamelet.yaml
index 75be465d..44e57871 100644
--- a/examples/kamelet-chucknorris/src/main/resources/kamelets/chuck-norris-source.kamelet.yaml
+++ b/examples/kamelet-chucknorris/src/main/resources/kamelets/chuck-norris-source.kamelet.yaml
@@ -30,7 +30,7 @@ spec:
     - "camel:timer"
     - "camel:http"
     - "camel:jsonpath"
-  flow:
+  template:
     from:
       uri: "timer:chuck"
       parameters:
@@ -39,4 +39,4 @@ spec:
         - to: "http://api.icndb.com/jokes/random"
         - set-body:
             jsonpath: "$.value.joke"
-        - to: "kamelet:sink"
\ No newline at end of file
+        - to: "kamelet:sink"
diff --git a/examples/oaipmh/src/test/java/org/apache/camel/example/oaipmh/OAIPMHTest.java b/examples/oaipmh/src/test/java/org/apache/camel/example/oaipmh/OAIPMHTest.java
index 2b27e58f..22063314 100644
--- a/examples/oaipmh/src/test/java/org/apache/camel/example/oaipmh/OAIPMHTest.java
+++ b/examples/oaipmh/src/test/java/org/apache/camel/example/oaipmh/OAIPMHTest.java
@@ -34,7 +34,7 @@ class OAIPMHTest extends CamelTestSupport {
     void should_extract_title_publications() {
         NotifyBuilder notify = new NotifyBuilder(context).wereSentTo("log:titles").whenCompleted(1).create();
         assertTrue(
-            notify.matches(30, TimeUnit.SECONDS), "at least 1 message should be completed"
+            notify.matches(40, TimeUnit.SECONDS), "at least 1 message should be completed"
         );
     }
 
diff --git a/examples/transformer-demo/src/main/resources/META-INF/spring/camel-context.xml b/examples/transformer-demo/src/main/resources/META-INF/spring/camel-context.xml
index cc3ce8d5..b6eb8147 100644
--- a/examples/transformer-demo/src/main/resources/META-INF/spring/camel-context.xml
+++ b/examples/transformer-demo/src/main/resources/META-INF/spring/camel-context.xml
@@ -29,13 +29,6 @@
     <!-- END SNIPPET: e1 -->
 
     <camel:camelContext id="order">
-
-        <!-- START SNIPPET: e2 -->
-        <camel:dataFormats>
-            <camel:json id="jsondf" library="Jackson" unmarshalType="org.apache.camel.example.transformer.demo.Order"/>
-        </camel:dataFormats>
-        <!-- END SNIPPET: e2 -->
-
         <!-- START SNIPPET: e3 -->
         <camel:transformers>
             <!-- specifying from&to data type for the Java-CSV transformation -->
@@ -47,7 +40,9 @@
                 <camel:jaxb id="xmldf" contextPath="org.apache.camel.example.transformer.demo"/>
             </camel:dataFormatTransformer>
             <!--  for all the Java-JSON transformation, referring to already defined DataFormat -->
-            <camel:dataFormatTransformer ref="jsondf" scheme="json"/>
+            <camel:dataFormatTransformer scheme="json">
+                <camel:json library="Jackson" unmarshalType="org.apache.camel.example.transformer.demo.Order"/>
+            </camel:dataFormatTransformer>
         </camel:transformers>
         <!-- END SNIPPET: e3 -->
         <!-- START SNIPPET: e8 -->
diff --git a/examples/widget-gadget-java/src/test/java/org/apache/camel/example/widget/WidgetGadgetTest.java b/examples/widget-gadget-java/src/test/java/org/apache/camel/example/widget/WidgetGadgetTest.java
index 7e0b8ce5..038c11e7 100644
--- a/examples/widget-gadget-java/src/test/java/org/apache/camel/example/widget/WidgetGadgetTest.java
+++ b/examples/widget-gadget-java/src/test/java/org/apache/camel/example/widget/WidgetGadgetTest.java
@@ -21,6 +21,7 @@ import java.util.concurrent.TimeUnit;
 import javax.jms.ConnectionFactory;
 
 import org.apache.activemq.ActiveMQConnectionFactory;
+import org.apache.camel.CamelConfiguration;
 import org.apache.camel.builder.NotifyBuilder;
 import org.apache.camel.component.jms.JmsComponent;
 import org.apache.camel.main.MainConfigurationProperties;
@@ -35,13 +36,14 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
  * properly using Apache ActiveMQ.
  */
 class WidgetGadgetTest extends CamelMainTestSupport {
+    public static class BrokerConfiguration implements CamelConfiguration {
 
-    @Override
-    protected void bindToRegistry(Registry registry) throws Exception {
-        // connect to embedded ActiveMQ JMS broker
-        ConnectionFactory connectionFactory =
-                new ActiveMQConnectionFactory("vm://localhost?broker.persistent=false");
-        registry.bind("activemq", JmsComponent.jmsComponentAutoAcknowledge(connectionFactory));
+        @org.apache.camel.BindToRegistry("activemq")
+        public JmsComponent createActiveMQbroker() throws Exception {
+            ConnectionFactory connectionFactory =
+                    new ActiveMQConnectionFactory("vm://localhost?broker.persistent=false");
+            return JmsComponent.jmsComponentAutoAcknowledge(connectionFactory);
+        }
     }
 
     @Test
@@ -59,6 +61,7 @@ class WidgetGadgetTest extends CamelMainTestSupport {
 
     @Override
     protected void configure(MainConfigurationProperties configuration) {
+        configuration.addConfiguration(BrokerConfiguration.class);
         configuration.addRoutesBuilder(new WidgetGadgetRoute());
         configuration.addRoutesBuilder(new CreateOrderRoute());
     }