camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From acosent...@apache.org
Subject [10/28] camel git commit: Fixed style and documentation issues. The documentation is not yet complete.
Date Fri, 25 Nov 2016 10:00:49 GMT
Fixed style and documentation issues. The documentation is not yet complete.


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/cec7b30f
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/cec7b30f
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/cec7b30f

Branch: refs/heads/master
Commit: cec7b30f3395529dae6dc5b5d46ff0e64cb1d209
Parents: 8a4a3cd
Author: gilfernandes <gil.fernandes@gmail.com>
Authored: Fri Nov 18 17:59:58 2016 +0000
Committer: Andrea Cosentino <ancosen@gmail.com>
Committed: Fri Nov 25 10:05:36 2016 +0100

----------------------------------------------------------------------
 .../src/main/docs/firebase-component.adoc       | 204 +++++++++++++++++++
 .../component/firebase/FirebaseComponent.java   |  20 +-
 .../component/firebase/FirebaseConfig.java      |  26 ++-
 .../component/firebase/FirebaseConsumer.java    |  16 ++
 .../component/firebase/FirebaseEndpoint.java    |  43 +++-
 .../component/firebase/FirebaseProducer.java    |  16 ++
 .../firebase/data/FirebaseMessage.java          |  28 ++-
 .../component/firebase/data/Operation.java      |  16 ++
 .../exception/DatabaseErrorException.java       |  16 ++
 .../firebase/exception/FirebaseException.java   |  47 ++---
 .../firebase/FirebaseConsumerDeleteTest.java    |  51 +++--
 .../firebase/FirebaseConsumerTest.java          |  45 ++--
 .../firebase/FirebaseProducerTest.java          |  42 ++--
 .../provider/ConfigurationProvider.java         |  25 ++-
 .../firebase/provider/SampleInputProvider.java  |  18 +-
 15 files changed, 517 insertions(+), 96 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/cec7b30f/components/camel-firebase/src/main/docs/firebase-component.adoc
----------------------------------------------------------------------
diff --git a/components/camel-firebase/src/main/docs/firebase-component.adoc b/components/camel-firebase/src/main/docs/firebase-component.adoc
new file mode 100644
index 0000000..e3ca1bb
--- /dev/null
+++ b/components/camel-firebase/src/main/docs/firebase-component.adoc
@@ -0,0 +1,204 @@
+[[Firebase-FirebaseComponent]]
+Firebase Component
+~~~~~~~~~~~~~~~~~
+
+*Available as of Camel 2.18.x*
+
+The *firebase* component enables you to save, modify data in Google Firebase database
+and consume to all child of a specific reference.
+
+This component supports producer and event based consumer endpoints.
+
+The Firebase consumer is an event based consumer and can be used to listen
+and respond to five types of Firebase events: add, change, remove, move and cancel 
+
+Maven users will need to add the following dependency to
+their `pom.xml` for this component:
+
+[source,xml]
+------------------------------------------------------------
+<dependency>
+    <groupId>org.apache.camel</groupId>
+    <artifactId>camel-firebase</artifactId>
+    <version>x.x.x</version>
+    <!-- use the same version as your Camel core version -->
+</dependency>
+------------------------------------------------------------
+
+[[Ehcache-URIformat]]
+URI format
+^^^^^^^^^^
+
+[source,java]
+-----------------------------
+firebase://databaseUrl[?options]
+-----------------------------
+
+You can append query options to the URI in the following
+format, `?option=value&option=#beanRef&...`
+
+Do not forget to URL encode the parameters
+
+[[Firebase-Options]]
+Options
+^^^^^^^
+
+
+// component options: START
+The Firebase component has no options.
+// component options: END
+
+
+
+// endpoint options: START
+The Firebase component supports 9 endpoint options which are listed below:
+
+{% raw %}
+[width="100%",cols="2,1,1m,1m,5",options="header"]
+|=======================================================================
+| Name | Group | Default | Java Type | Description
+| databaseUrl | common |  | String | *Required* The Firebase database URL. Always uses https
+| async | common | async | boolean | If true the save or update request (set value in Firebase
terms) is fired and the reply will be ignored else the routing thread will wait and the reply
will be saved in the exchange message
+| keyName | common | firebaseKey | String | The Camel exchange header name in which the Firebase
key is specified. Only needed in case you are saving or updating data
+| rootReference | common |  | String | *Required* The path in the database tree where the
key value pairs are to be stored
+| serviceAccountFile | common |  | String | *Required* The path to the JSON file which provided
the keys used to connect to Firebase. This file is typically generated when you create the
database
+| bridgeErrorHandler | consumer | false | boolean | Allows for bridging the consumer to the
Camel routing Error Handler which mean any exceptions occurred while the consumer is trying
to pickup incoming messages or the likes will now be processed as a message and handled by
the routing Error Handler. By default the consumer will use the org.apache.camel.spi.ExceptionHandler
to deal with exceptions that will be logged at WARN/ERROR level and ignored.
+| exceptionHandler | consumer (advanced) |  | ExceptionHandler | To let the consumer use
a custom ExceptionHandler. Notice if the option bridgeErrorHandler is enabled then this options
is not in use. By default the consumer will deal with exceptions that will be logged at WARN/ERROR
level and ignored.
+| exchangePattern | consumer (advanced) |  | ExchangePattern | Sets the exchange pattern
when the consumer creates an exchange.
+| synchronous | advanced | false | boolean | Sets whether synchronous processing should be
strictly used or Camel is allowed to use asynchronous processing (if supported).
+|=======================================================================
+{% endraw %}
+// endpoint options: END
+
+
+[[Ehcache-MessageHeadersCamel]]
+Message Headers Camel 
+++++++++++++++++++++++
+
+ 
+[width="100%",cols="10%,10%,80%",options="header",]
+|=======================================================================
+|Header |Type |Description
+
+|CamelEhcacheAction |`String` |The operation to be perfomed on the cache, valid options are:
+
+* CLEAR
+* PUT
+* PUT_ALL
+* PUT_IF_ABSENT
+* GET
+* GET_ALL
+* REMOVE
+* REMOVE_ALL
+* REPLACE
+
+|CamelEhcacheActionHasResult |Boolean |Set to true if the action has a result
+
+|CamelEhcacheActionSucceeded |`Boolean` |Set to true if the actionsuccedded
+
+|CamelEhcacheKey |Object |The cache key used for an action
+
+|CamelEhcacheKeys |Set<Object> |A list of keys, used in
+
+* PUT_ALL
+* GET_ALL
+* REMOVE_ALL
+
+|CamelEhcacheValue |Object |The value to put in the cache or the result of an operation
+
+|CamelEhcacheOldValue |Object |The old value associated to a key for actions like PUT_IF_ABSENT
or the
+Object used for comparison for actions like REPLACE
+
+|CamelEhcacheEventType |EventType |The type of event received
+|=======================================================================
+
+[[Ehcache-Ehcachebasedidempotentrepositoryexample:]]
+Ehcache based idempotent repository example:
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+[source,java]
+------------------------------------------------------------------------------------------------
+CacheManager manager = CacheManagerBuilder.newCacheManager(new XmlConfiguration("ehcache.xml"));
+EhcacheIdempotentRepository repo = new EhcacheIdempotentRepository(manager, "idempotent-cache");
+ 
+from("direct:in")
+    .idempotentConsumer(header("messageId"), idempotentRepo)
+    .to("mock:out");
+------------------------------------------------------------------------------------------------
+
+ 
+
+[[Ehcache-Ehcachebasedaggregationrepositoryexample:]]
+Ehcache based aggregation repository example:
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+[source,java]
+---------------------------------------------------------------------------------------------------------------------------------
+public class EhcacheAggregationRepositoryRoutesTest extends CamelTestSupport {
+    private static final String ENDPOINT_MOCK = "mock:result";
+    private static final String ENDPOINT_DIRECT = "direct:one";
+    private static final int[] VALUES = generateRandomArrayOfInt(10, 0, 30);
+    private static final int SUM = IntStream.of(VALUES).reduce(0, (a, b) -> a + b);
+    private static final String CORRELATOR = "CORRELATOR";
+
+    @EndpointInject(uri = ENDPOINT_MOCK)
+    private MockEndpoint mock;
+
+    @Produce(uri = ENDPOINT_DIRECT)
+    private ProducerTemplate producer;
+
+    @Test
+    public void checkAggregationFromOneRoute() throws Exception {
+        mock.expectedMessageCount(VALUES.length);
+        mock.expectedBodiesReceived(SUM);
+
+        IntStream.of(VALUES).forEach(
+            i -> producer.sendBodyAndHeader(i, CORRELATOR, CORRELATOR)
+        );
+
+        mock.assertIsSatisfied();
+    }
+
+    private Exchange aggregate(Exchange oldExchange, Exchange newExchange) {
+        if (oldExchange == null) {
+            return newExchange;
+        } else {
+            Integer n = newExchange.getIn().getBody(Integer.class);
+            Integer o = oldExchange.getIn().getBody(Integer.class);
+            Integer v = (o == null ? 0 : o) + (n == null ? 0 : n);
+
+            oldExchange.getIn().setBody(v, Integer.class);
+
+            return oldExchange;
+        }
+    }
+
+    @Override
+    protected RoutesBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from(ENDPOINT_DIRECT)
+                    .routeId("AggregatingRouteOne")
+                    .aggregate(header(CORRELATOR))
+                    .aggregationRepository(createAggregateRepository())
+                    .aggregationStrategy(EhcacheAggregationRepositoryRoutesTest.this::aggregate)
+                    .completionSize(VALUES.length)
+                        .to("log:org.apache.camel.component.ehcache.processor.aggregate.level=INFO&showAll=true&mulltiline=true")
+                        .to(ENDPOINT_MOCK);
+            }
+        };
+    }
+
+    protected EhcacheAggregationRepository createAggregateRepository() throws Exception {
+        CacheManager cacheManager = CacheManagerBuilder.newCacheManager(new XmlConfiguration("ehcache.xml"));
+        cacheManager.init();
+
+        EhcacheAggregationRepository repository = new EhcacheAggregationRepository();
+        repository.setCacheManager(cacheManager);
+        repository.setCacheName("aggregate");
+
+        return repository;
+    }
+}
+---------------------------------------------------------------------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/camel/blob/cec7b30f/components/camel-firebase/src/main/java/org/apache/camel/component/firebase/FirebaseComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-firebase/src/main/java/org/apache/camel/component/firebase/FirebaseComponent.java
b/components/camel-firebase/src/main/java/org/apache/camel/component/firebase/FirebaseComponent.java
index 18e6d64..8b80a2a 100644
--- a/components/camel-firebase/src/main/java/org/apache/camel/component/firebase/FirebaseComponent.java
+++ b/components/camel-firebase/src/main/java/org/apache/camel/component/firebase/FirebaseComponent.java
@@ -1,11 +1,27 @@
+/**
+ * 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.component.firebase;
 
+import java.util.Map;
+
 import org.apache.camel.CamelContext;
 import org.apache.camel.Endpoint;
 import org.apache.camel.impl.UriEndpointComponent;
 
-import java.util.Map;
-
 /**
  * Represents the component that manages {@link FirebaseEndpoint}.
  */

http://git-wip-us.apache.org/repos/asf/camel/blob/cec7b30f/components/camel-firebase/src/main/java/org/apache/camel/component/firebase/FirebaseConfig.java
----------------------------------------------------------------------
diff --git a/components/camel-firebase/src/main/java/org/apache/camel/component/firebase/FirebaseConfig.java
b/components/camel-firebase/src/main/java/org/apache/camel/component/firebase/FirebaseConfig.java
index a46caf8..7f6641e 100644
--- a/components/camel-firebase/src/main/java/org/apache/camel/component/firebase/FirebaseConfig.java
+++ b/components/camel-firebase/src/main/java/org/apache/camel/component/firebase/FirebaseConfig.java
@@ -1,18 +1,34 @@
+/**
+ * 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.component.firebase;
 
-import com.google.firebase.FirebaseApp;
-import com.google.firebase.FirebaseOptions;
-
 import java.io.IOException;
 import java.io.InputStream;
 import java.nio.file.Files;
 import java.nio.file.Paths;
 import java.util.UUID;
 
+import com.google.firebase.FirebaseApp;
+import com.google.firebase.FirebaseOptions;
+
 /**
  * Contains the elements needed to connect to Firebase
  */
-public class FirebaseConfig {
+public final class FirebaseConfig {
 
     private final String databaseUrl;
 
@@ -35,7 +51,7 @@ public class FirebaseConfig {
     }
 
     public void init() throws IOException {
-        try(InputStream in = Files.newInputStream(Paths.get(serviceAccountFile))) {
+        try (InputStream in = Files.newInputStream(Paths.get(serviceAccountFile))) {
             FirebaseOptions options = new FirebaseOptions.Builder()
                     .setServiceAccount(in)
                     .setDatabaseUrl(this.databaseUrl)

http://git-wip-us.apache.org/repos/asf/camel/blob/cec7b30f/components/camel-firebase/src/main/java/org/apache/camel/component/firebase/FirebaseConsumer.java
----------------------------------------------------------------------
diff --git a/components/camel-firebase/src/main/java/org/apache/camel/component/firebase/FirebaseConsumer.java
b/components/camel-firebase/src/main/java/org/apache/camel/component/firebase/FirebaseConsumer.java
index 1dee1a4..bbcb2b6 100644
--- a/components/camel-firebase/src/main/java/org/apache/camel/component/firebase/FirebaseConsumer.java
+++ b/components/camel-firebase/src/main/java/org/apache/camel/component/firebase/FirebaseConsumer.java
@@ -1,3 +1,19 @@
+/**
+ * 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.component.firebase;
 
 import com.google.firebase.database.ChildEventListener;

http://git-wip-us.apache.org/repos/asf/camel/blob/cec7b30f/components/camel-firebase/src/main/java/org/apache/camel/component/firebase/FirebaseEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-firebase/src/main/java/org/apache/camel/component/firebase/FirebaseEndpoint.java
b/components/camel-firebase/src/main/java/org/apache/camel/component/firebase/FirebaseEndpoint.java
index 0be796a..a6b035b 100644
--- a/components/camel-firebase/src/main/java/org/apache/camel/component/firebase/FirebaseEndpoint.java
+++ b/components/camel-firebase/src/main/java/org/apache/camel/component/firebase/FirebaseEndpoint.java
@@ -1,3 +1,19 @@
+/**
+ * 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.component.firebase;
 
 import com.google.firebase.FirebaseApp;
@@ -8,27 +24,37 @@ import org.apache.camel.impl.DefaultEndpoint;
 import org.apache.camel.spi.Metadata;
 import org.apache.camel.spi.UriEndpoint;
 import org.apache.camel.spi.UriParam;
+import org.apache.camel.spi.UriPath;
 
 /**
  * Represents a Firebase endpoint.
  */
-@UriEndpoint(scheme = "firebase", title = "Firebase", syntax="firebase:name", consumerClass
= FirebaseConsumer.class, label = "Firebase")
+@UriEndpoint(scheme = "firebase", title = "Firebase", syntax = "firebase:name", consumerClass
= FirebaseConsumer.class, label = "Firebase")
 public class FirebaseEndpoint extends DefaultEndpoint {
 
     private final FirebaseConfig firebaseConfig;
 
-    @UriParam
+    @UriPath(description = "The Firebase database URL. Always uses https")
+    @Metadata(required = "true")
+    private String databaseUrl;
+
+    @UriParam(description = "The path in the database tree where the key value pairs are
to be stored")
     @Metadata(required = "true")
     private String rootReference;
 
-    @UriParam
+    @UriParam(description = "The path to the JSON file which provided the keys used to connect
to Firebase. #"
+            + "This file is typically generated when you create the database")
     @Metadata(required = "true")
     private String serviceAccountFile;
 
-    @UriParam(defaultValue = "firebaseKey") @Metadata(required = "false")
+    @UriParam(defaultValue = "firebaseKey", description = "The Camel exchange header name
in which "
+            + "the Firebase key is specified. Only needed in case you are saving or updating
data")
+    @Metadata(required = "false")
     private String keyName = "firebaseKey";
 
-    @UriParam(defaultValue = "async") @Metadata(required = "false")
+    @UriParam(defaultValue = "async", description = "If true, the save or update request
(set value in Firebase terms) "
+            + "is fired and the reply will be ignored, else the routing thread will wait
and the reply will be saved in the exchange message")
+    @Metadata(required = "false")
     private boolean async;
 
     public FirebaseEndpoint(String uri, FirebaseComponent firebaseComponent, FirebaseConfig
firebaseConfig) {
@@ -36,9 +62,10 @@ public class FirebaseEndpoint extends DefaultEndpoint {
         this.firebaseConfig = firebaseConfig;
         this.setRootReference(firebaseConfig.getRootReference());
         this.setServiceAccountFile(firebaseConfig.getServiceAccountFile());
+        this.databaseUrl = firebaseConfig.getDatabaseUrl();
         final String keyName = firebaseConfig.getKeyName();
         this.setAsync(firebaseConfig.isAsync());
-        if(keyName != null) {
+        if (keyName != null) {
             this.setKeyName(keyName);
         }
     }
@@ -94,4 +121,8 @@ public class FirebaseEndpoint extends DefaultEndpoint {
     public FirebaseApp getFirebaseApp() {
         return firebaseConfig.getFirebaseApp();
     }
+
+    public String getDatabaseUrl() {
+        return databaseUrl;
+    }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/cec7b30f/components/camel-firebase/src/main/java/org/apache/camel/component/firebase/FirebaseProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-firebase/src/main/java/org/apache/camel/component/firebase/FirebaseProducer.java
b/components/camel-firebase/src/main/java/org/apache/camel/component/firebase/FirebaseProducer.java
index bc09550..ef8f8a6 100644
--- a/components/camel-firebase/src/main/java/org/apache/camel/component/firebase/FirebaseProducer.java
+++ b/components/camel-firebase/src/main/java/org/apache/camel/component/firebase/FirebaseProducer.java
@@ -1,3 +1,19 @@
+/**
+ * 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.component.firebase;
 
 import com.google.firebase.database.DatabaseError;

http://git-wip-us.apache.org/repos/asf/camel/blob/cec7b30f/components/camel-firebase/src/main/java/org/apache/camel/component/firebase/data/FirebaseMessage.java
----------------------------------------------------------------------
diff --git a/components/camel-firebase/src/main/java/org/apache/camel/component/firebase/data/FirebaseMessage.java
b/components/camel-firebase/src/main/java/org/apache/camel/component/firebase/data/FirebaseMessage.java
index afd02ae..4999102 100644
--- a/components/camel-firebase/src/main/java/org/apache/camel/component/firebase/data/FirebaseMessage.java
+++ b/components/camel-firebase/src/main/java/org/apache/camel/component/firebase/data/FirebaseMessage.java
@@ -1,3 +1,19 @@
+/**
+ * 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.component.firebase.data;
 
 import com.google.firebase.database.DataSnapshot;
@@ -6,7 +22,7 @@ import com.google.firebase.database.DatabaseError;
 /**
  * Contains a message sent by Firebase.
  */
-public class FirebaseMessage {
+public final class FirebaseMessage {
 
     private final Operation operation;
 
@@ -41,11 +57,11 @@ public class FirebaseMessage {
 
     @Override
     public String toString() {
-        return "FirebaseMessage{" + "operation=" + operation +
-                ", dataSnapshot=" + dataSnapshot +
-                ", previousChildName='" + previousChildName + '\'' +
-                ", databaseError=" + databaseError +
-                '}';
+        return "FirebaseMessage{"
+                + "operation=" + operation
+                + ", dataSnapshot=" + dataSnapshot
+                + ", previousChildName='" + previousChildName + '\''
+                + ", databaseError=" + databaseError + '}';
     }
 
     public static class Builder {

http://git-wip-us.apache.org/repos/asf/camel/blob/cec7b30f/components/camel-firebase/src/main/java/org/apache/camel/component/firebase/data/Operation.java
----------------------------------------------------------------------
diff --git a/components/camel-firebase/src/main/java/org/apache/camel/component/firebase/data/Operation.java
b/components/camel-firebase/src/main/java/org/apache/camel/component/firebase/data/Operation.java
index 5410c61..609a209 100644
--- a/components/camel-firebase/src/main/java/org/apache/camel/component/firebase/data/Operation.java
+++ b/components/camel-firebase/src/main/java/org/apache/camel/component/firebase/data/Operation.java
@@ -1,3 +1,19 @@
+/**
+ * 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.component.firebase.data;
 
 /**

http://git-wip-us.apache.org/repos/asf/camel/blob/cec7b30f/components/camel-firebase/src/main/java/org/apache/camel/component/firebase/exception/DatabaseErrorException.java
----------------------------------------------------------------------
diff --git a/components/camel-firebase/src/main/java/org/apache/camel/component/firebase/exception/DatabaseErrorException.java
b/components/camel-firebase/src/main/java/org/apache/camel/component/firebase/exception/DatabaseErrorException.java
index 4c2d23e..a7939e2 100644
--- a/components/camel-firebase/src/main/java/org/apache/camel/component/firebase/exception/DatabaseErrorException.java
+++ b/components/camel-firebase/src/main/java/org/apache/camel/component/firebase/exception/DatabaseErrorException.java
@@ -1,3 +1,19 @@
+/**
+ * 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.component.firebase.exception;
 
 import com.google.firebase.database.DatabaseError;

http://git-wip-us.apache.org/repos/asf/camel/blob/cec7b30f/components/camel-firebase/src/main/java/org/apache/camel/component/firebase/exception/FirebaseException.java
----------------------------------------------------------------------
diff --git a/components/camel-firebase/src/main/java/org/apache/camel/component/firebase/exception/FirebaseException.java
b/components/camel-firebase/src/main/java/org/apache/camel/component/firebase/exception/FirebaseException.java
index 190f386..a39b871 100644
--- a/components/camel-firebase/src/main/java/org/apache/camel/component/firebase/exception/FirebaseException.java
+++ b/components/camel-firebase/src/main/java/org/apache/camel/component/firebase/exception/FirebaseException.java
@@ -1,34 +1,26 @@
+/**
+ * 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.component.firebase.exception;
 
-import com.google.firebase.database.DatabaseError;
-
 /**
  * Used to mark an exception occurred in the Firebase Camel processor.
  */
 public class FirebaseException extends RuntimeException {
 
-    private DatabaseError databaseError;
-
-    /**
-     * Constructs a new runtime exception with {@code null} as its
-     * detail message.  The cause is not initialized, and may subsequently be
-     * initialized by a call to {@link #initCause}.
-     */
-    public FirebaseException() {
-    }
-
-    /**
-     * Constructs a new runtime exception with the specified detail message.
-     * The cause is not initialized, and may subsequently be initialized by a
-     * call to {@link #initCause}.
-     *
-     * @param message the detail message. The detail message is saved for
-     *                later retrieval by the {@link #getMessage()} method.
-     */
-    public FirebaseException(String message) {
-        super(message);
-    }
-
     /**
      * Constructs a new runtime exception with the specified detail message and
      * cause.  <p>Note that the detail message associated with
@@ -47,11 +39,4 @@ public class FirebaseException extends RuntimeException {
         super(message, cause);
     }
 
-    public void setDatabaseError(DatabaseError databaseError) {
-        this.databaseError = databaseError;
-    }
-
-    public DatabaseError getDatabaseError() {
-        return databaseError;
-    }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/cec7b30f/components/camel-firebase/src/test/java/org/apache/camel/component/firebase/FirebaseConsumerDeleteTest.java
----------------------------------------------------------------------
diff --git a/components/camel-firebase/src/test/java/org/apache/camel/component/firebase/FirebaseConsumerDeleteTest.java
b/components/camel-firebase/src/test/java/org/apache/camel/component/firebase/FirebaseConsumerDeleteTest.java
index 460a7e7..f3600e9 100644
--- a/components/camel-firebase/src/test/java/org/apache/camel/component/firebase/FirebaseConsumerDeleteTest.java
+++ b/components/camel-firebase/src/test/java/org/apache/camel/component/firebase/FirebaseConsumerDeleteTest.java
@@ -1,5 +1,27 @@
+/**
+ * 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.component.firebase;
 
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.locks.Condition;
+import java.util.concurrent.locks.ReentrantLock;
+
+import static junit.framework.TestCase.fail;
+
 import com.google.firebase.database.DatabaseReference;
 import com.google.firebase.database.FirebaseDatabase;
 import org.apache.camel.CamelContext;
@@ -11,13 +33,9 @@ import org.apache.camel.component.firebase.provider.SampleInputProvider;
 import org.apache.camel.impl.DefaultCamelContext;
 import org.junit.Test;
 
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.locks.Condition;
-import java.util.concurrent.locks.ReentrantLock;
-
-import static junit.framework.TestCase.fail;
 import static org.assertj.core.api.Assertions.assertThat;
 
+
 /**
  * Starts a route which listens to the remove event in Firebase. It then writes and deletes
an entry in Firebase and
  * asserts, if the entry was deleted or not.
@@ -29,15 +47,13 @@ public class FirebaseConsumerDeleteTest {
     private final Condition wake = reentrantLock.newCondition();
 
     @Test
-    public void whenDelete_DeleteMessageShouldBeIntercepted() throws Exception {
+    public void whenDeleteDeleteMessageShouldBeIntercepted() throws Exception {
         CamelContext context = new DefaultCamelContext();
-        boolean[] deleteMessageReceived = { false };
+        boolean[] deleteMessageReceived = {false};
         FirebaseConfig firebaseConfig = ConfigurationProvider.createDemoConfig();
+        createAndDeleteContent(firebaseConfig, false);
         setupRoute(context, deleteMessageReceived);
-        context.addStartupListener((context1, alreadyStarted) -> {
-            TimeUnit.SECONDS.sleep(5);
-            createAndDeleteContent(firebaseConfig);
-        });
+
         context.start();
         try {
             reentrantLock.lock();
@@ -49,16 +65,19 @@ public class FirebaseConsumerDeleteTest {
         context.stop();
     }
 
-    private void createAndDeleteContent(FirebaseConfig firebaseConfig) {
+    private void createAndDeleteContent(FirebaseConfig firebaseConfig, boolean delete) {
         final DatabaseReference rootReference = FirebaseDatabase.getInstance(firebaseConfig.getFirebaseApp())
                 .getReference(ConfigurationProvider.createRootReference()).child(SampleInputProvider.createDeleteKey());
         rootReference
                 .setValue("AETHELWULF 839-856", (databaseError, databaseReference) ->
{
-                    databaseReference.removeValue();
+                    if (delete) {
+                        databaseReference.removeValue();
+                    }
                 });
     }
 
     private void setupRoute(CamelContext context, final boolean[] deleteMessageReceived)
throws Exception {
+        boolean deleteFired[] = {false};
         context.addRoutes(new RouteBuilder() {
             public void configure() {
                 try {
@@ -75,6 +94,12 @@ public class FirebaseConsumerDeleteTest {
                                     } finally {
                                         reentrantLock.unlock();
                                     }
+                                } else {
+                                    if (!deleteFired[0]) {
+                                        deleteFired[0] = true;
+                                        FirebaseConfig firebaseConfig = ConfigurationProvider.createDemoConfig();
+                                        createAndDeleteContent(firebaseConfig, true);
+                                    }
                                 }
                             });
 

http://git-wip-us.apache.org/repos/asf/camel/blob/cec7b30f/components/camel-firebase/src/test/java/org/apache/camel/component/firebase/FirebaseConsumerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-firebase/src/test/java/org/apache/camel/component/firebase/FirebaseConsumerTest.java
b/components/camel-firebase/src/test/java/org/apache/camel/component/firebase/FirebaseConsumerTest.java
index 2c6cbc4..8395a98 100644
--- a/components/camel-firebase/src/test/java/org/apache/camel/component/firebase/FirebaseConsumerTest.java
+++ b/components/camel-firebase/src/test/java/org/apache/camel/component/firebase/FirebaseConsumerTest.java
@@ -1,11 +1,21 @@
+/**
+ * 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.component.firebase;
 
-import com.google.firebase.database.FirebaseDatabase;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.firebase.provider.ConfigurationProvider;
-import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Test;
 
 import java.io.IOException;
 import java.net.URLDecoder;
@@ -13,13 +23,24 @@ import java.net.URLEncoder;
 import java.util.concurrent.locks.Condition;
 import java.util.concurrent.locks.ReentrantLock;
 
+import com.google.firebase.database.FirebaseDatabase;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.firebase.provider.ConfigurationProvider;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+
 /**
  * Writes a dummy message and then checks, if the consumer receives at least one message.
  */
 public class FirebaseConsumerTest extends CamelTestSupport {
 
+    private final ReentrantLock lock = new ReentrantLock();
+
+    private final Condition wake = lock.newCondition();
+
     @Test
-    public void whenFirebaseListener_ShouldReceiveMessages() throws Exception {
+    public void whenFirebaseListenerShouldReceiveMessages() throws Exception {
         MockEndpoint mock = getMockEndpoint("mock:result");
         mock.expectedMinimumMessageCount(1);
         assertMockEndpointsSatisfied();
@@ -47,10 +68,6 @@ public class FirebaseConsumerTest extends CamelTestSupport {
         };
     }
 
-    private final ReentrantLock lock = new ReentrantLock();
-
-    private final Condition wake = lock.newCondition();
-
     private void insertDummyData(String databaseUrl, String originalRootReference, String
serviceAccountFile) throws IOException, InterruptedException {
         FirebaseConfig config = new FirebaseConfig.Builder(databaseUrl, originalRootReference,
URLDecoder.decode(serviceAccountFile, "UTF-8"))
                 .build();
@@ -61,16 +78,14 @@ public class FirebaseConsumerTest extends CamelTestSupport {
                     try {
                         lock.lock();
                         wake.signal();
-                    }
-                    finally {
+                    } finally {
                         lock.unlock();
                     }
                 });
         try {
             lock.lock();
             wake.await();
-        }
-        finally {
+        } finally {
             lock.unlock();
         }
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/cec7b30f/components/camel-firebase/src/test/java/org/apache/camel/component/firebase/FirebaseProducerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-firebase/src/test/java/org/apache/camel/component/firebase/FirebaseProducerTest.java
b/components/camel-firebase/src/test/java/org/apache/camel/component/firebase/FirebaseProducerTest.java
index 549bfef..f0f2cc3 100644
--- a/components/camel-firebase/src/test/java/org/apache/camel/component/firebase/FirebaseProducerTest.java
+++ b/components/camel-firebase/src/test/java/org/apache/camel/component/firebase/FirebaseProducerTest.java
@@ -1,5 +1,27 @@
+/**
+ * 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.component.firebase;
 
+import java.net.URLEncoder;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.concurrent.locks.Condition;
+import java.util.concurrent.locks.ReentrantLock;
+
 import com.google.firebase.database.DatabaseReference;
 import org.apache.camel.CamelContext;
 import org.apache.camel.Message;
@@ -11,12 +33,6 @@ import org.apache.camel.impl.DefaultCamelContext;
 import org.junit.Before;
 import org.junit.Test;
 
-import java.net.URLEncoder;
-import java.nio.file.Files;
-import java.nio.file.Paths;
-import java.util.concurrent.locks.Condition;
-import java.util.concurrent.locks.ReentrantLock;
-
 import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
 
 /**
@@ -36,12 +52,12 @@ public class FirebaseProducerTest {
     }
 
     @Test
-    public void whenFirebaseSet_ShouldReceiveMessagesSync() throws Exception {
+    public void whenFirebaseSetShouldReceiveMessagesSync() throws Exception {
         startRoute(false, DatabaseReference.class);
     }
 
     @Test
-    public void whenFirebaseSet_ShouldReceiveMessagesAsync() throws Exception {
+    public void whenFirebaseSetShouldReceiveMessagesAsync() throws Exception {
         startRoute(true, String.class);
     }
 
@@ -67,22 +83,20 @@ public class FirebaseProducerTest {
                         .to("log:whenFirebaseSet?level=WARN")
                         .process(exchange1 -> {
                             assertThat(exchange1.getIn().getBody().getClass()).isEqualTo(expectedBodyClass);
-                            try{
+                            try {
                                 reentrantLock.lock();
                                 wake.signal();
-                            }
-                            finally {
+                            } finally {
                                 reentrantLock.unlock();
                             }
                         });
             }
         });
         context.start();
-        try{
+        try {
             reentrantLock.lock();
             wake.await();
-        }
-        finally {
+        } finally {
             reentrantLock.unlock();
         }
         context.stop();

http://git-wip-us.apache.org/repos/asf/camel/blob/cec7b30f/components/camel-firebase/src/test/java/org/apache/camel/component/firebase/provider/ConfigurationProvider.java
----------------------------------------------------------------------
diff --git a/components/camel-firebase/src/test/java/org/apache/camel/component/firebase/provider/ConfigurationProvider.java
b/components/camel-firebase/src/test/java/org/apache/camel/component/firebase/provider/ConfigurationProvider.java
index d33d881..6b6a51f 100644
--- a/components/camel-firebase/src/test/java/org/apache/camel/component/firebase/provider/ConfigurationProvider.java
+++ b/components/camel-firebase/src/test/java/org/apache/camel/component/firebase/provider/ConfigurationProvider.java
@@ -1,7 +1,21 @@
+/**
+ * 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.component.firebase.provider;
 
-import org.apache.camel.component.firebase.FirebaseConfig;
-
 import java.io.File;
 import java.io.IOException;
 import java.io.UnsupportedEncodingException;
@@ -10,12 +24,17 @@ import java.net.URL;
 import java.net.URLDecoder;
 import java.net.URLEncoder;
 
+import org.apache.camel.component.firebase.FirebaseConfig;
+
 import static org.junit.Assert.assertNotNull;
 
 /**
  * Provides the path of the configuration used to access Firebase.
  */
-public class ConfigurationProvider {
+public final class ConfigurationProvider {
+
+    private ConfigurationProvider() {
+    }
 
     public static String createFirebaseConfigLink() throws URISyntaxException, UnsupportedEncodingException
{
         URL url = Thread.currentThread().getContextClassLoader().getResource("firebase-admin-connection.json");

http://git-wip-us.apache.org/repos/asf/camel/blob/cec7b30f/components/camel-firebase/src/test/java/org/apache/camel/component/firebase/provider/SampleInputProvider.java
----------------------------------------------------------------------
diff --git a/components/camel-firebase/src/test/java/org/apache/camel/component/firebase/provider/SampleInputProvider.java
b/components/camel-firebase/src/test/java/org/apache/camel/component/firebase/provider/SampleInputProvider.java
index 4b0d4f7..38477ef 100644
--- a/components/camel-firebase/src/test/java/org/apache/camel/component/firebase/provider/SampleInputProvider.java
+++ b/components/camel-firebase/src/test/java/org/apache/camel/component/firebase/provider/SampleInputProvider.java
@@ -1,3 +1,19 @@
+/**
+ * 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.component.firebase.provider;
 
 import java.io.IOException;
@@ -20,7 +36,7 @@ public class SampleInputProvider {
 
     public SampleInputProvider() throws IOException {
         targetFolder = Paths.get("src/data");
-        if(!Files.exists(targetFolder)) {
+        if (!Files.exists(targetFolder)) {
             Files.createDirectories(targetFolder);
         }
     }


Mime
View raw message