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 2015/12/20 08:00:05 UTC
[1/8] camel git commit: axiom-api/axiom-impl do not have a
(transitive) dependency on javax.mail anymore,
but now use geronimo-javamail_1.4_spec so excluded that instead
Repository: camel
Updated Branches:
refs/heads/camel-2.16.x d84c66f5a -> 43775d084
refs/heads/master 083814876 -> 962216f9c
axiom-api/axiom-impl do not have a (transitive) dependency on javax.mail anymore, but now use geronimo-javamail_1.4_spec so excluded that instead
abdera-parser does not have a (transitive) dependency on javax.mail anymore, so remove the exclusion
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/6a4534d4
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/6a4534d4
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/6a4534d4
Branch: refs/heads/master
Commit: 6a4534d40af3745d21773d21492dc71bc252cbe1
Parents: 5406300
Author: Pascal Schumacher <pa...@gmx.net>
Authored: Sat Dec 19 18:03:28 2015 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Sun Dec 20 07:05:46 2015 +0100
----------------------------------------------------------------------
components/camel-atom/pom.xml | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/6a4534d4/components/camel-atom/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-atom/pom.xml b/components/camel-atom/pom.xml
index cabe979..64f1bcb 100644
--- a/components/camel-atom/pom.xml
+++ b/components/camel-atom/pom.xml
@@ -76,10 +76,6 @@
<version>${abdera-version}</version>
<exclusions>
<exclusion>
- <groupId>com.sun.mail</groupId>
- <artifactId>javax.mail</artifactId>
- </exclusion>
- <exclusion>
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
</exclusion>
@@ -118,8 +114,8 @@
<artifactId>axiom-api</artifactId>
<exclusions>
<exclusion>
- <groupId>com.sun.mail</groupId>
- <artifactId>javax.mail</artifactId>
+ <artifactId>geronimo-javamail_1.4_spec</artifactId>
+ <groupId>org.apache.geronimo.specs</groupId>
</exclusion>
<exclusion>
<groupId>xml-apis</groupId>
@@ -160,8 +156,8 @@
<artifactId>axiom-impl</artifactId>
<exclusions>
<exclusion>
- <groupId>com.sun.mail</groupId>
- <artifactId>javax.mail</artifactId>
+ <artifactId>geronimo-javamail_1.4_spec</artifactId>
+ <groupId>org.apache.geronimo.specs</groupId>
</exclusion>
<exclusion>
<groupId>xml-apis</groupId>
[8/8] camel git commit: CAMEL-9375: TarSplitter includes one extra
empty entry at the end.
Posted by da...@apache.org.
CAMEL-9375: TarSplitter includes one extra empty entry at the end.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/43775d08
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/43775d08
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/43775d08
Branch: refs/heads/camel-2.16.x
Commit: 43775d08452dce6dfca8f6db1f8a80504fd0f5f9
Parents: d84c66f
Author: Sami Nurminen <sn...@gmail.com>
Authored: Sat Dec 19 13:48:27 2015 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Sun Dec 20 07:58:11 2015 +0100
----------------------------------------------------------------------
.../dataformat/tarfile/TarFileDataFormat.java | 2 +-
.../camel/dataformat/tarfile/TarIterator.java | 93 +++++++++-----------
.../camel/dataformat/tarfile/TarSplitter.java | 2 +-
3 files changed, 45 insertions(+), 52 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/43775d08/components/camel-tarfile/src/main/java/org/apache/camel/dataformat/tarfile/TarFileDataFormat.java
----------------------------------------------------------------------
diff --git a/components/camel-tarfile/src/main/java/org/apache/camel/dataformat/tarfile/TarFileDataFormat.java b/components/camel-tarfile/src/main/java/org/apache/camel/dataformat/tarfile/TarFileDataFormat.java
index e195699..94f2faa 100644
--- a/components/camel-tarfile/src/main/java/org/apache/camel/dataformat/tarfile/TarFileDataFormat.java
+++ b/components/camel-tarfile/src/main/java/org/apache/camel/dataformat/tarfile/TarFileDataFormat.java
@@ -86,7 +86,7 @@ public class TarFileDataFormat extends ServiceSupport implements DataFormat, Dat
@Override
public Object unmarshal(Exchange exchange, InputStream stream) throws Exception {
if (usingIterator) {
- return new TarIterator(exchange.getIn(), stream);
+ return new TarIterator(exchange, stream);
} else {
InputStream is = exchange.getIn().getMandatoryBody(InputStream.class);
TarArchiveInputStream tis = (TarArchiveInputStream) new ArchiveStreamFactory().createArchiveInputStream(ArchiveStreamFactory.TAR, new BufferedInputStream(is));
http://git-wip-us.apache.org/repos/asf/camel/blob/43775d08/components/camel-tarfile/src/main/java/org/apache/camel/dataformat/tarfile/TarIterator.java
----------------------------------------------------------------------
diff --git a/components/camel-tarfile/src/main/java/org/apache/camel/dataformat/tarfile/TarIterator.java b/components/camel-tarfile/src/main/java/org/apache/camel/dataformat/tarfile/TarIterator.java
index 943ea44..c5c85ce 100644
--- a/components/camel-tarfile/src/main/java/org/apache/camel/dataformat/tarfile/TarIterator.java
+++ b/components/camel-tarfile/src/main/java/org/apache/camel/dataformat/tarfile/TarIterator.java
@@ -26,6 +26,7 @@ import java.util.Iterator;
import org.apache.camel.Exchange;
import org.apache.camel.Message;
import org.apache.camel.RuntimeCamelException;
+import org.apache.camel.StreamCache;
import org.apache.camel.impl.DefaultMessage;
import org.apache.camel.util.IOHelper;
import org.apache.commons.compress.archivers.ArchiveException;
@@ -51,11 +52,13 @@ public class TarIterator implements Iterator<Message>, Closeable {
private final Message inputMessage;
private TarArchiveInputStream tarInputStream;
- private Message parent;
+ private Message nextMessage;
- public TarIterator(Message inputMessage, InputStream inputStream) {
- this.inputMessage = inputMessage;
- //InputStream inputStream = inputMessage.getBody(InputStream.class);
+ private Exchange exchange;
+
+ public TarIterator(Exchange exchange, InputStream inputStream) {
+ this.exchange = exchange;
+ this.inputMessage = exchange.getIn();
if (inputStream instanceof TarArchiveInputStream) {
tarInputStream = (TarArchiveInputStream) inputStream;
@@ -67,51 +70,40 @@ public class TarIterator implements Iterator<Message>, Closeable {
throw new RuntimeException(e.getMessage(), e);
}
}
- parent = null;
+ nextMessage = null;
}
@Override
public boolean hasNext() {
- try {
- if (tarInputStream == null) {
- return false;
- }
- boolean availableDataInCurrentEntry = tarInputStream.available() > 0;
- if (!availableDataInCurrentEntry) {
- // advance to the next entry.
- parent = getNextElement();
- if (parent == null) {
- tarInputStream.close();
- availableDataInCurrentEntry = false;
- } else {
- availableDataInCurrentEntry = true;
- }
- }
- return availableDataInCurrentEntry;
- } catch (IOException exception) {
- //Just wrap the IOException as CamelRuntimeException
- throw new RuntimeCamelException(exception);
- }
+ tryAdvanceToNext();
+
+ return this.nextMessage != null;
}
@Override
public Message next() {
- if (parent == null) {
- parent = getNextElement();
- }
-
- Message answer = parent;
- parent = null;
- checkNullAnswer(answer);
+ tryAdvanceToNext();
- return answer;
+ //consume element
+ Message next = this.nextMessage;
+ this.nextMessage = null;
+ return next;
}
- private Message getNextElement() {
- Message answer = null;
+ private void tryAdvanceToNext() {
+ //return current next
+ if (this.nextMessage != null) {
+ return;
+ }
+
+ this.nextMessage = createNextMessage();
+ checkNullAnswer(this.nextMessage);
+ }
+
+ private Message createNextMessage() {
if (tarInputStream == null) {
- return answer;
+ return null;
}
try {
@@ -119,12 +111,15 @@ public class TarIterator implements Iterator<Message>, Closeable {
if (current != null) {
LOGGER.debug("Reading tarEntry {}", current.getName());
- answer = new DefaultMessage();
+ Message answer = new DefaultMessage();
answer.getHeaders().putAll(inputMessage.getHeaders());
answer.setHeader(TARFILE_ENTRY_NAME_HEADER, current.getName());
answer.setHeader(Exchange.FILE_NAME, current.getName());
if (current.getSize() > 0) {
- answer.setBody(new TarElementInputStreamWrapper(tarInputStream));
+ //Have to cache current entry's portion of tarInputStream here, because getNextTarEntry
+ //advances tarInputStream beyond current entry
+ answer.setBody(exchange.getContext().getTypeConverter().mandatoryConvertTo(StreamCache.class, exchange,
+ new TarElementInputStreamWrapper(tarInputStream)));
} else {
// Workaround for the case when the entry is zero bytes big
answer.setBody(new ByteArrayInputStream(new byte[0]));
@@ -132,19 +127,18 @@ public class TarIterator implements Iterator<Message>, Closeable {
return answer;
} else {
LOGGER.trace("Closed tarInputStream");
+ return null;
}
- } catch (IOException exception) {
- //Just wrap the IOException as CamelRuntimeException
+ } catch (Exception exception) {
+ this.close();
+ //Just wrap the Exception as CamelRuntimeException
throw new RuntimeCamelException(exception);
}
-
- return answer;
}
public void checkNullAnswer(Message answer) {
- if (answer == null && tarInputStream != null) {
- IOHelper.close(tarInputStream);
- tarInputStream = null;
+ if (answer == null) {
+ this.close();
}
}
@@ -166,10 +160,9 @@ public class TarIterator implements Iterator<Message>, Closeable {
}
@Override
- public void close() throws IOException {
- if (tarInputStream != null) {
- tarInputStream.close();
- tarInputStream = null;
- }
+ public void close() {
+ //suppress any exceptions from closing
+ IOHelper.close(tarInputStream);
+ tarInputStream = null;
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/43775d08/components/camel-tarfile/src/main/java/org/apache/camel/dataformat/tarfile/TarSplitter.java
----------------------------------------------------------------------
diff --git a/components/camel-tarfile/src/main/java/org/apache/camel/dataformat/tarfile/TarSplitter.java b/components/camel-tarfile/src/main/java/org/apache/camel/dataformat/tarfile/TarSplitter.java
index 132dd55..3ee5371 100644
--- a/components/camel-tarfile/src/main/java/org/apache/camel/dataformat/tarfile/TarSplitter.java
+++ b/components/camel-tarfile/src/main/java/org/apache/camel/dataformat/tarfile/TarSplitter.java
@@ -33,7 +33,7 @@ public class TarSplitter implements Expression {
public Object evaluate(Exchange exchange) {
Message inputMessage = exchange.getIn();
- return new TarIterator(inputMessage, inputMessage.getBody(InputStream.class));
+ return new TarIterator(exchange, inputMessage.getBody(InputStream.class));
}
@Override
[6/8] camel git commit: Camel catalog - Add api to validate endpoint
uri
Posted by da...@apache.org.
Camel catalog - Add api to validate endpoint uri
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/4116ab27
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/4116ab27
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/4116ab27
Branch: refs/heads/master
Commit: 4116ab2756893c99071eff6a336384fff6524d86
Parents: 3e10975
Author: Claus Ibsen <da...@apache.org>
Authored: Sat Dec 19 17:03:35 2015 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Sun Dec 20 07:05:47 2015 +0100
----------------------------------------------------------------------
.../org/apache/camel/catalog/CamelCatalog.java | 7 +-
.../camel/catalog/DefaultCamelCatalog.java | 22 ++--
.../apache/camel/catalog/ValidationResult.java | 102 +++++++++++++++++++
.../apache/camel/catalog/CamelCatalogTest.java | 49 ++++-----
4 files changed, 137 insertions(+), 43 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/4116ab27/platforms/catalog/src/main/java/org/apache/camel/catalog/CamelCatalog.java
----------------------------------------------------------------------
diff --git a/platforms/catalog/src/main/java/org/apache/camel/catalog/CamelCatalog.java b/platforms/catalog/src/main/java/org/apache/camel/catalog/CamelCatalog.java
index dc1a3ca..ac01b51 100644
--- a/platforms/catalog/src/main/java/org/apache/camel/catalog/CamelCatalog.java
+++ b/platforms/catalog/src/main/java/org/apache/camel/catalog/CamelCatalog.java
@@ -173,12 +173,9 @@ public interface CamelCatalog {
* Parses and validates the endpoint uri and constructs a key/value properties of each option
*
* @param uri the endpoint uri
- * @return invalid properties as key/value properties of each invalid option, returns an empty map if no validation errors
+ * @return validation result
*/
- Map<String, String> validateProperties(String uri) throws URISyntaxException;
-
- // TODO: json with error instead of map
- // with description of the error, index, etc
+ ValidationResult validateProperties(String uri) throws URISyntaxException;
/**
* Returns the component name from the given endpoint uri
http://git-wip-us.apache.org/repos/asf/camel/blob/4116ab27/platforms/catalog/src/main/java/org/apache/camel/catalog/DefaultCamelCatalog.java
----------------------------------------------------------------------
diff --git a/platforms/catalog/src/main/java/org/apache/camel/catalog/DefaultCamelCatalog.java b/platforms/catalog/src/main/java/org/apache/camel/catalog/DefaultCamelCatalog.java
index 13b3052..f0e4c3c 100644
--- a/platforms/catalog/src/main/java/org/apache/camel/catalog/DefaultCamelCatalog.java
+++ b/platforms/catalog/src/main/java/org/apache/camel/catalog/DefaultCamelCatalog.java
@@ -646,8 +646,8 @@ public class DefaultCamelCatalog implements CamelCatalog {
}
@Override
- public Map<String, String> validateProperties(String uri) throws URISyntaxException {
- Map<String, String> answer = new LinkedHashMap<String, String>();
+ public ValidationResult validateProperties(String uri) throws URISyntaxException {
+ ValidationResult result = new ValidationResult();
// parse the uri
URI u = normalizeUri(uri);
@@ -665,14 +665,14 @@ public class DefaultCamelCatalog implements CamelCatalog {
Map<String, String> row = getRow(rows, name);
// unknown option
if (row == null) {
- answer.put(name, property.getValue());
+ result.addUnknown(name);
} else {
// invalid value/type
// is required but the value is empty
boolean required = isPropertyRequired(rows, name);
if (required && isEmpty(value)) {
- answer.put(name, value);
+ result.addRequired(name);
}
// is enum but the value is not within the enum range
@@ -687,7 +687,7 @@ public class DefaultCamelCatalog implements CamelCatalog {
}
}
if (!found) {
- answer.put(name, value);
+ result.addInvalidEnum(name);
}
}
@@ -696,7 +696,7 @@ public class DefaultCamelCatalog implements CamelCatalog {
// value must be a boolean
boolean bool = "true".equalsIgnoreCase(value) || "false".equalsIgnoreCase(value);
if (!bool) {
- answer.put(name, value);
+ result.addInvalidBoolean(name);
}
}
@@ -710,7 +710,7 @@ public class DefaultCamelCatalog implements CamelCatalog {
// ignore
}
if (!valid) {
- answer.put(name, value);
+ result.addInvalidInteger(name);
}
}
@@ -719,12 +719,12 @@ public class DefaultCamelCatalog implements CamelCatalog {
// value must be an number
boolean valid = false;
try {
- valid = Double.valueOf(value).isNaN() == false || Float.valueOf(value).isNaN() == false;
+ valid = !Double.valueOf(value).isNaN() || !Float.valueOf(value).isNaN();
} catch (Exception e) {
// ignore
}
if (!valid) {
- answer.put(name, value);
+ result.addInvalidNumber(name);
}
}
}
@@ -740,12 +740,12 @@ public class DefaultCamelCatalog implements CamelCatalog {
value = getPropertyDefaultValue(rows, name);
}
if (isEmpty(value)) {
- answer.put(name, value);
+ result.addRequired(name);
}
}
}
- return answer;
+ return result;
}
@Override
http://git-wip-us.apache.org/repos/asf/camel/blob/4116ab27/platforms/catalog/src/main/java/org/apache/camel/catalog/ValidationResult.java
----------------------------------------------------------------------
diff --git a/platforms/catalog/src/main/java/org/apache/camel/catalog/ValidationResult.java b/platforms/catalog/src/main/java/org/apache/camel/catalog/ValidationResult.java
new file mode 100644
index 0000000..2ea9528
--- /dev/null
+++ b/platforms/catalog/src/main/java/org/apache/camel/catalog/ValidationResult.java
@@ -0,0 +1,102 @@
+/**
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.catalog;
+
+import java.io.Serializable;
+import java.util.LinkedHashSet;
+import java.util.Set;
+
+public class ValidationResult implements Serializable {
+
+ private Set<String> unknown;
+ private Set<String> required;
+ private Set<String> invalidEnum;
+ private Set<String> invalidBoolean;
+ private Set<String> invalidInteger;
+ private Set<String> invalidNumber;
+
+ public boolean isSuccess() {
+ return unknown == null && required == null && invalidEnum == null
+ && invalidBoolean == null && invalidInteger == null && invalidNumber == null;
+ }
+
+ public void addUnknown(String name) {
+ if (unknown == null) {
+ unknown = new LinkedHashSet<String>();
+ }
+ unknown.add(name);
+ }
+
+ public void addRequired(String name) {
+ if (required == null) {
+ required = new LinkedHashSet<String>();
+ }
+ required.add(name);
+ }
+
+ public void addInvalidEnum(String name) {
+ if (invalidEnum == null) {
+ invalidEnum = new LinkedHashSet<String>();
+ }
+ invalidEnum.add(name);
+ }
+
+ public void addInvalidBoolean(String name) {
+ if (invalidBoolean == null) {
+ invalidBoolean = new LinkedHashSet<String>();
+ }
+ invalidBoolean.add(name);
+ }
+
+ public void addInvalidInteger(String name) {
+ if (invalidInteger == null) {
+ invalidInteger = new LinkedHashSet<String>();
+ }
+ invalidInteger.add(name);
+ }
+
+ public void addInvalidNumber(String name) {
+ if (invalidNumber == null) {
+ invalidNumber = new LinkedHashSet<String>();
+ }
+ invalidNumber.add(name);
+ }
+
+ public Set<String> getUnknown() {
+ return unknown;
+ }
+
+ public Set<String> getRequired() {
+ return required;
+ }
+
+ public Set<String> getInvalidEnum() {
+ return invalidEnum;
+ }
+
+ public Set<String> getInvalidBoolean() {
+ return invalidBoolean;
+ }
+
+ public Set<String> getInvalidInteger() {
+ return invalidInteger;
+ }
+
+ public Set<String> getInvalidNumber() {
+ return invalidNumber;
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/4116ab27/platforms/catalog/src/test/java/org/apache/camel/catalog/CamelCatalogTest.java
----------------------------------------------------------------------
diff --git a/platforms/catalog/src/test/java/org/apache/camel/catalog/CamelCatalogTest.java b/platforms/catalog/src/test/java/org/apache/camel/catalog/CamelCatalogTest.java
index 4c020da..59ec112 100644
--- a/platforms/catalog/src/test/java/org/apache/camel/catalog/CamelCatalogTest.java
+++ b/platforms/catalog/src/test/java/org/apache/camel/catalog/CamelCatalogTest.java
@@ -27,6 +27,7 @@ import org.junit.Test;
import static org.apache.camel.catalog.CatalogHelper.loadText;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
@@ -389,45 +390,39 @@ public class CamelCatalogTest {
@Test
public void validateProperties() throws Exception {
// valid
- Map<String, String> map = catalog.validateProperties("log:mylog");
- assertNotNull(map);
- assertEquals(0, map.size());
+ ValidationResult result = catalog.validateProperties("log:mylog");
+ assertTrue(result.isSuccess());
// unknown
- map = catalog.validateProperties("log:mylog?level=WARN&foo=bar");
- assertNotNull(map);
- assertEquals(1, map.size());
- assertEquals("bar", map.get("foo"));
+ result = catalog.validateProperties("log:mylog?level=WARN&foo=bar");
+ assertFalse(result.isSuccess());
+ assertTrue(result.getUnknown().contains("foo"));
// enum
- map = catalog.validateProperties("jms:unknown:myqueue");
- assertNotNull(map);
- assertEquals(1, map.size());
+ result = catalog.validateProperties("jms:unknown:myqueue");
+ assertFalse(result.isSuccess());
+ assertTrue(result.getInvalidEnum().contains("destinationType"));
// okay
- map = catalog.validateProperties("yammer:MESSAGES?accessToken=aaa&consumerKey=bbb&consumerSecret=ccc&useJson=true&initialDelay=500");
- assertNotNull(map);
- assertEquals(0, map.size());
+ result = catalog.validateProperties("yammer:MESSAGES?accessToken=aaa&consumerKey=bbb&consumerSecret=ccc&useJson=true&initialDelay=500");
+ assertTrue(result.isSuccess());
// required / boolean / integer
- map = catalog.validateProperties("yammer:MESSAGES?accessToken=aaa&consumerKey=&useJson=no&initialDelay=five");
- assertNotNull(map);
- assertEquals(4, map.size());
- assertEquals(null, map.get("consumerKey"));
- assertEquals(null, map.get("consumerSecret"));
- assertEquals("no", map.get("useJson"));
- assertEquals("five", map.get("initialDelay"));
+ result = catalog.validateProperties("yammer:MESSAGES?accessToken=aaa&consumerKey=&useJson=no&initialDelay=five");
+ assertFalse(result.isSuccess());
+ assertTrue(result.getRequired().contains("consumerKey"));
+ assertTrue(result.getRequired().contains("consumerSecret"));
+ assertTrue(result.getInvalidBoolean().contains("useJson"));
+ assertTrue(result.getInvalidInteger().contains("initialDelay"));
// okay
- map = catalog.validateProperties("mqtt:myqtt?reconnectBackOffMultiplier=2.5");
- assertNotNull(map);
- assertEquals(0, map.size());
+ result = catalog.validateProperties("mqtt:myqtt?reconnectBackOffMultiplier=2.5");
+ assertTrue(result.isSuccess());
// number
- map = catalog.validateProperties("mqtt:myqtt?reconnectBackOffMultiplier=five");
- assertNotNull(map);
- assertEquals(1, map.size());
- assertEquals("five", map.get("reconnectBackOffMultiplier"));
+ result = catalog.validateProperties("mqtt:myqtt?reconnectBackOffMultiplier=five");
+ assertFalse(result.isSuccess());
+ assertTrue(result.getInvalidNumber().contains("reconnectBackOffMultiplier"));
}
@Test
[2/8] camel git commit: aws-java-sdk does not have a (transitive)
dependency on javax.mail anymore, so remove the exclusion
Posted by da...@apache.org.
aws-java-sdk does not have a (transitive) dependency on javax.mail anymore, so remove the exclusion
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/54063002
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/54063002
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/54063002
Branch: refs/heads/master
Commit: 540630028bb280fea7fb84dac26b27c1adb20e13
Parents: bfa79ad
Author: Pascal Schumacher <pa...@gmx.net>
Authored: Sat Dec 19 18:01:12 2015 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Sun Dec 20 07:05:46 2015 +0100
----------------------------------------------------------------------
components/camel-aws/pom.xml | 4 ----
1 file changed, 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/54063002/components/camel-aws/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-aws/pom.xml b/components/camel-aws/pom.xml
index fc40fed..28516d2 100644
--- a/components/camel-aws/pom.xml
+++ b/components/camel-aws/pom.xml
@@ -89,10 +89,6 @@
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
</exclusion>
- <exclusion>
- <groupId>com.sun.mail</groupId>
- <artifactId>javax.mail</artifactId>
- </exclusion>
</exclusions>
</dependency>
<dependency>
[3/8] camel git commit: CAMEL-9433: Upgrade java mail with new maven
coord.
Posted by da...@apache.org.
CAMEL-9433: Upgrade java mail with new maven coord.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/bfa79add
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/bfa79add
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/bfa79add
Branch: refs/heads/master
Commit: bfa79add0edd5f6d00353b3d7ca370383a27f349
Parents: 929d437
Author: Pascal Schumacher <pa...@gmx.net>
Authored: Sat Dec 19 11:19:12 2015 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Sun Dec 20 07:05:46 2015 +0100
----------------------------------------------------------------------
components/camel-atom/pom.xml | 12 ++++++------
components/camel-aws/pom.xml | 8 ++++----
components/camel-google-mail/pom.xml | 4 ++--
tests/test-bundles/mock-javamail_1.7/pom.xml | 6 +++---
4 files changed, 15 insertions(+), 15 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/bfa79add/components/camel-atom/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-atom/pom.xml b/components/camel-atom/pom.xml
index 3bf1b4b..cabe979 100644
--- a/components/camel-atom/pom.xml
+++ b/components/camel-atom/pom.xml
@@ -76,8 +76,8 @@
<version>${abdera-version}</version>
<exclusions>
<exclusion>
- <groupId>javax.mail</groupId>
- <artifactId>mail</artifactId>
+ <groupId>com.sun.mail</groupId>
+ <artifactId>javax.mail</artifactId>
</exclusion>
<exclusion>
<groupId>xml-apis</groupId>
@@ -118,8 +118,8 @@
<artifactId>axiom-api</artifactId>
<exclusions>
<exclusion>
- <groupId>javax.mail</groupId>
- <artifactId>mail</artifactId>
+ <groupId>com.sun.mail</groupId>
+ <artifactId>javax.mail</artifactId>
</exclusion>
<exclusion>
<groupId>xml-apis</groupId>
@@ -160,8 +160,8 @@
<artifactId>axiom-impl</artifactId>
<exclusions>
<exclusion>
- <groupId>javax.mail</groupId>
- <artifactId>mail</artifactId>
+ <groupId>com.sun.mail</groupId>
+ <artifactId>javax.mail</artifactId>
</exclusion>
<exclusion>
<groupId>xml-apis</groupId>
http://git-wip-us.apache.org/repos/asf/camel/blob/bfa79add/components/camel-aws/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-aws/pom.xml b/components/camel-aws/pom.xml
index 426d135..fc40fed 100644
--- a/components/camel-aws/pom.xml
+++ b/components/camel-aws/pom.xml
@@ -90,8 +90,8 @@
<artifactId>commons-codec</artifactId>
</exclusion>
<exclusion>
- <groupId>javax.mail</groupId>
- <artifactId>mail</artifactId>
+ <groupId>com.sun.mail</groupId>
+ <artifactId>javax.mail</artifactId>
</exclusion>
</exclusions>
</dependency>
@@ -119,8 +119,8 @@
<artifactId>commons-codec</artifactId>
</dependency>
<dependency>
- <groupId>javax.mail</groupId>
- <artifactId>mail</artifactId>
+ <groupId>com.sun.mail</groupId>
+ <artifactId>javax.mail</artifactId>
<version>${javax-mail-version}</version>
</dependency>
http://git-wip-us.apache.org/repos/asf/camel/blob/bfa79add/components/camel-google-mail/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-google-mail/pom.xml b/components/camel-google-mail/pom.xml
index ff1af15..3ebb677 100644
--- a/components/camel-google-mail/pom.xml
+++ b/components/camel-google-mail/pom.xml
@@ -69,8 +69,8 @@
</dependency>
<dependency>
- <groupId>javax.mail</groupId>
- <artifactId>mail</artifactId>
+ <groupId>com.sun.mail</groupId>
+ <artifactId>javax.mail</artifactId>
<version>${javax-mail-version}</version>
<exclusions>
<!-- javax activation is part of the JDK now -->
http://git-wip-us.apache.org/repos/asf/camel/blob/bfa79add/tests/test-bundles/mock-javamail_1.7/pom.xml
----------------------------------------------------------------------
diff --git a/tests/test-bundles/mock-javamail_1.7/pom.xml b/tests/test-bundles/mock-javamail_1.7/pom.xml
index 36fec1d..7734684 100644
--- a/tests/test-bundles/mock-javamail_1.7/pom.xml
+++ b/tests/test-bundles/mock-javamail_1.7/pom.xml
@@ -60,13 +60,13 @@
<version>${pkgVersion}</version>
<exclusions>
<exclusion>
- <groupId>com.sun.mail</groupId>
- <artifactId>javax.mail</artifactId>
+ <groupId>javax.mail</groupId>
+ <artifactId>mail</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
- <groupId>com.sun.mail</groupId>
+ <groupId>com.sun.mail</groupId>
<artifactId>javax.mail</artifactId>
<version>${javax-mail-version}</version>
</dependency>
[4/8] camel git commit: CAMEL-9375: TarSplitter includes one extra
empty entry at the end.
Posted by da...@apache.org.
CAMEL-9375: TarSplitter includes one extra empty entry at the end.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/929d437c
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/929d437c
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/929d437c
Branch: refs/heads/master
Commit: 929d437cc2dd73b284d38485adf1931c4700b9c1
Parents: 0838148
Author: Sami Nurminen <sn...@gmail.com>
Authored: Sat Dec 19 13:48:27 2015 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Sun Dec 20 07:05:46 2015 +0100
----------------------------------------------------------------------
.../dataformat/tarfile/TarFileDataFormat.java | 2 +-
.../camel/dataformat/tarfile/TarIterator.java | 84 ++++++++++----------
.../camel/dataformat/tarfile/TarSplitter.java | 2 +-
3 files changed, 42 insertions(+), 46 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/929d437c/components/camel-tarfile/src/main/java/org/apache/camel/dataformat/tarfile/TarFileDataFormat.java
----------------------------------------------------------------------
diff --git a/components/camel-tarfile/src/main/java/org/apache/camel/dataformat/tarfile/TarFileDataFormat.java b/components/camel-tarfile/src/main/java/org/apache/camel/dataformat/tarfile/TarFileDataFormat.java
index 5465edc..49b1a82 100644
--- a/components/camel-tarfile/src/main/java/org/apache/camel/dataformat/tarfile/TarFileDataFormat.java
+++ b/components/camel-tarfile/src/main/java/org/apache/camel/dataformat/tarfile/TarFileDataFormat.java
@@ -86,7 +86,7 @@ public class TarFileDataFormat extends ServiceSupport implements DataFormat, Dat
@Override
public Object unmarshal(final Exchange exchange, final InputStream stream) throws Exception {
if (usingIterator) {
- return new TarIterator(exchange.getIn(), stream);
+ return new TarIterator(exchange, stream);
} else {
BufferedInputStream bis = new BufferedInputStream(stream);
TarArchiveInputStream tis = (TarArchiveInputStream) new ArchiveStreamFactory().createArchiveInputStream(ArchiveStreamFactory.TAR, bis);
http://git-wip-us.apache.org/repos/asf/camel/blob/929d437c/components/camel-tarfile/src/main/java/org/apache/camel/dataformat/tarfile/TarIterator.java
----------------------------------------------------------------------
diff --git a/components/camel-tarfile/src/main/java/org/apache/camel/dataformat/tarfile/TarIterator.java b/components/camel-tarfile/src/main/java/org/apache/camel/dataformat/tarfile/TarIterator.java
index 91933c0..c5c85ce 100644
--- a/components/camel-tarfile/src/main/java/org/apache/camel/dataformat/tarfile/TarIterator.java
+++ b/components/camel-tarfile/src/main/java/org/apache/camel/dataformat/tarfile/TarIterator.java
@@ -26,6 +26,7 @@ import java.util.Iterator;
import org.apache.camel.Exchange;
import org.apache.camel.Message;
import org.apache.camel.RuntimeCamelException;
+import org.apache.camel.StreamCache;
import org.apache.camel.impl.DefaultMessage;
import org.apache.camel.util.IOHelper;
import org.apache.commons.compress.archivers.ArchiveException;
@@ -51,11 +52,13 @@ public class TarIterator implements Iterator<Message>, Closeable {
private final Message inputMessage;
private TarArchiveInputStream tarInputStream;
- private Message parent;
+ private Message nextMessage;
- public TarIterator(Message inputMessage, InputStream inputStream) {
- this.inputMessage = inputMessage;
- //InputStream inputStream = inputMessage.getBody(InputStream.class);
+ private Exchange exchange;
+
+ public TarIterator(Exchange exchange, InputStream inputStream) {
+ this.exchange = exchange;
+ this.inputMessage = exchange.getIn();
if (inputStream instanceof TarArchiveInputStream) {
tarInputStream = (TarArchiveInputStream) inputStream;
@@ -67,47 +70,38 @@ public class TarIterator implements Iterator<Message>, Closeable {
throw new RuntimeException(e.getMessage(), e);
}
}
- parent = null;
+ nextMessage = null;
}
@Override
public boolean hasNext() {
- try {
- if (tarInputStream == null) {
- return false;
- }
- boolean availableDataInCurrentEntry = tarInputStream.available() > 0;
- if (!availableDataInCurrentEntry) {
- // advance to the next entry.
- parent = getNextElement();
- if (parent == null) {
- tarInputStream.close();
- availableDataInCurrentEntry = false;
- } else {
- availableDataInCurrentEntry = true;
- }
- }
- return availableDataInCurrentEntry;
- } catch (IOException exception) {
- //Just wrap the IOException as CamelRuntimeException
- throw new RuntimeCamelException(exception);
- }
+ tryAdvanceToNext();
+
+ return this.nextMessage != null;
}
@Override
public Message next() {
- if (parent == null) {
- parent = getNextElement();
- }
+ tryAdvanceToNext();
+
+ //consume element
+ Message next = this.nextMessage;
+ this.nextMessage = null;
+ return next;
+ }
- Message answer = parent;
- parent = null;
- checkNullAnswer(answer);
- return answer;
+ private void tryAdvanceToNext() {
+ //return current next
+ if (this.nextMessage != null) {
+ return;
+ }
+
+ this.nextMessage = createNextMessage();
+ checkNullAnswer(this.nextMessage);
}
- private Message getNextElement() {
+ private Message createNextMessage() {
if (tarInputStream == null) {
return null;
}
@@ -122,7 +116,10 @@ public class TarIterator implements Iterator<Message>, Closeable {
answer.setHeader(TARFILE_ENTRY_NAME_HEADER, current.getName());
answer.setHeader(Exchange.FILE_NAME, current.getName());
if (current.getSize() > 0) {
- answer.setBody(new TarElementInputStreamWrapper(tarInputStream));
+ //Have to cache current entry's portion of tarInputStream here, because getNextTarEntry
+ //advances tarInputStream beyond current entry
+ answer.setBody(exchange.getContext().getTypeConverter().mandatoryConvertTo(StreamCache.class, exchange,
+ new TarElementInputStreamWrapper(tarInputStream)));
} else {
// Workaround for the case when the entry is zero bytes big
answer.setBody(new ByteArrayInputStream(new byte[0]));
@@ -132,16 +129,16 @@ public class TarIterator implements Iterator<Message>, Closeable {
LOGGER.trace("Closed tarInputStream");
return null;
}
- } catch (IOException exception) {
- //Just wrap the IOException as CamelRuntimeException
+ } catch (Exception exception) {
+ this.close();
+ //Just wrap the Exception as CamelRuntimeException
throw new RuntimeCamelException(exception);
}
}
public void checkNullAnswer(Message answer) {
- if (answer == null && tarInputStream != null) {
- IOHelper.close(tarInputStream);
- tarInputStream = null;
+ if (answer == null) {
+ this.close();
}
}
@@ -163,10 +160,9 @@ public class TarIterator implements Iterator<Message>, Closeable {
}
@Override
- public void close() throws IOException {
- if (tarInputStream != null) {
- tarInputStream.close();
- tarInputStream = null;
- }
+ public void close() {
+ //suppress any exceptions from closing
+ IOHelper.close(tarInputStream);
+ tarInputStream = null;
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/929d437c/components/camel-tarfile/src/main/java/org/apache/camel/dataformat/tarfile/TarSplitter.java
----------------------------------------------------------------------
diff --git a/components/camel-tarfile/src/main/java/org/apache/camel/dataformat/tarfile/TarSplitter.java b/components/camel-tarfile/src/main/java/org/apache/camel/dataformat/tarfile/TarSplitter.java
index 132dd55..3ee5371 100644
--- a/components/camel-tarfile/src/main/java/org/apache/camel/dataformat/tarfile/TarSplitter.java
+++ b/components/camel-tarfile/src/main/java/org/apache/camel/dataformat/tarfile/TarSplitter.java
@@ -33,7 +33,7 @@ public class TarSplitter implements Expression {
public Object evaluate(Exchange exchange) {
Message inputMessage = exchange.getIn();
- return new TarIterator(inputMessage, inputMessage.getBody(InputStream.class));
+ return new TarIterator(exchange, inputMessage.getBody(InputStream.class));
}
@Override
[5/8] camel git commit: Camel catalog - Add api to validate endpoint
uri
Posted by da...@apache.org.
Camel catalog - Add api to validate endpoint uri
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/3e109750
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/3e109750
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/3e109750
Branch: refs/heads/master
Commit: 3e1097502bb06043b480969641a14f50a35f0259
Parents: 6a4534d
Author: Claus Ibsen <da...@apache.org>
Authored: Sat Dec 19 14:49:43 2015 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Sun Dec 20 07:05:47 2015 +0100
----------------------------------------------------------------------
.../org/apache/camel/catalog/CamelCatalog.java | 11 ++
.../camel/catalog/DefaultCamelCatalog.java | 117 +++++++++++++++++++
.../apache/camel/catalog/JSonSchemaHelper.java | 78 +++++++++++++
.../apache/camel/catalog/CamelCatalogTest.java | 45 ++++++-
4 files changed, 250 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/3e109750/platforms/catalog/src/main/java/org/apache/camel/catalog/CamelCatalog.java
----------------------------------------------------------------------
diff --git a/platforms/catalog/src/main/java/org/apache/camel/catalog/CamelCatalog.java b/platforms/catalog/src/main/java/org/apache/camel/catalog/CamelCatalog.java
index 7dc67a0..dc1a3ca 100644
--- a/platforms/catalog/src/main/java/org/apache/camel/catalog/CamelCatalog.java
+++ b/platforms/catalog/src/main/java/org/apache/camel/catalog/CamelCatalog.java
@@ -170,6 +170,17 @@ public interface CamelCatalog {
Map<String, String> endpointProperties(String uri) throws URISyntaxException;
/**
+ * Parses and validates the endpoint uri and constructs a key/value properties of each option
+ *
+ * @param uri the endpoint uri
+ * @return invalid properties as key/value properties of each invalid option, returns an empty map if no validation errors
+ */
+ Map<String, String> validateProperties(String uri) throws URISyntaxException;
+
+ // TODO: json with error instead of map
+ // with description of the error, index, etc
+
+ /**
* Returns the component name from the given endpoint uri
*
* @param uri the endpoint uri
http://git-wip-us.apache.org/repos/asf/camel/blob/3e109750/platforms/catalog/src/main/java/org/apache/camel/catalog/DefaultCamelCatalog.java
----------------------------------------------------------------------
diff --git a/platforms/catalog/src/main/java/org/apache/camel/catalog/DefaultCamelCatalog.java b/platforms/catalog/src/main/java/org/apache/camel/catalog/DefaultCamelCatalog.java
index 870bc0f..13b3052 100644
--- a/platforms/catalog/src/main/java/org/apache/camel/catalog/DefaultCamelCatalog.java
+++ b/platforms/catalog/src/main/java/org/apache/camel/catalog/DefaultCamelCatalog.java
@@ -42,8 +42,14 @@ import org.w3c.dom.Document;
import static org.apache.camel.catalog.CatalogHelper.after;
import static org.apache.camel.catalog.JSonSchemaHelper.getPropertyDefaultValue;
+import static org.apache.camel.catalog.JSonSchemaHelper.getPropertyEnum;
+import static org.apache.camel.catalog.JSonSchemaHelper.getRow;
+import static org.apache.camel.catalog.JSonSchemaHelper.isPropertyBoolean;
+import static org.apache.camel.catalog.JSonSchemaHelper.isPropertyInteger;
+import static org.apache.camel.catalog.JSonSchemaHelper.isPropertyNumber;
import static org.apache.camel.catalog.JSonSchemaHelper.isPropertyRequired;
import static org.apache.camel.catalog.URISupport.createQueryString;
+import static org.apache.camel.catalog.URISupport.isEmpty;
import static org.apache.camel.catalog.URISupport.normalizeUri;
import static org.apache.camel.catalog.URISupport.stripQuery;
@@ -72,9 +78,17 @@ public class DefaultCamelCatalog implements CamelCatalog {
private boolean caching;
+ /**
+ * Creates the {@link CamelCatalog} without caching enabled.
+ */
public DefaultCamelCatalog() {
}
+ /**
+ * Creates the {@link CamelCatalog}
+ *
+ * @param caching whether to use cache
+ */
public DefaultCamelCatalog(boolean caching) {
this.caching = caching;
}
@@ -632,6 +646,109 @@ public class DefaultCamelCatalog implements CamelCatalog {
}
@Override
+ public Map<String, String> validateProperties(String uri) throws URISyntaxException {
+ Map<String, String> answer = new LinkedHashMap<String, String>();
+
+ // parse the uri
+ URI u = normalizeUri(uri);
+ String scheme = u.getScheme();
+ String json = componentJSonSchema(scheme);
+ List<Map<String, String>> rows = JSonSchemaHelper.parseJsonSchema("properties", json, true);
+
+ // parse into a map of properties of the uri, and look for options that are invalid
+ Map<String, String> properties = endpointProperties(uri);
+ for (Map.Entry<String, String> property : properties.entrySet()) {
+ String name = property.getKey();
+ String value = property.getValue();
+ boolean placeholder = value.startsWith("{{") || value.startsWith("${") || value.startsWith("$simple{");
+
+ Map<String, String> row = getRow(rows, name);
+ // unknown option
+ if (row == null) {
+ answer.put(name, property.getValue());
+ } else {
+ // invalid value/type
+
+ // is required but the value is empty
+ boolean required = isPropertyRequired(rows, name);
+ if (required && isEmpty(value)) {
+ answer.put(name, value);
+ }
+
+ // is enum but the value is not within the enum range
+ // but we can only check if the value is not a placeholder
+ String enums = getPropertyEnum(rows, name);
+ if (!placeholder && enums != null) {
+ boolean found = false;
+ for (String s : enums.split(",")) {
+ if (value.equalsIgnoreCase(s)) {
+ found = true;
+ break;
+ }
+ }
+ if (!found) {
+ answer.put(name, value);
+ }
+ }
+
+ // is boolean
+ if (!placeholder && isPropertyBoolean(rows, name)) {
+ // value must be a boolean
+ boolean bool = "true".equalsIgnoreCase(value) || "false".equalsIgnoreCase(value);
+ if (!bool) {
+ answer.put(name, value);
+ }
+ }
+
+ // is integer
+ if (!placeholder && isPropertyInteger(rows, name)) {
+ // value must be an integer
+ boolean valid = false;
+ try {
+ valid = Integer.valueOf(value) != null;
+ } catch (Exception e) {
+ // ignore
+ }
+ if (!valid) {
+ answer.put(name, value);
+ }
+ }
+
+ // is number
+ if (!placeholder && isPropertyNumber(rows, name)) {
+ // value must be an number
+ boolean valid = false;
+ try {
+ valid = Double.valueOf(value).isNaN() == false || Float.valueOf(value).isNaN() == false;
+ } catch (Exception e) {
+ // ignore
+ }
+ if (!valid) {
+ answer.put(name, value);
+ }
+ }
+ }
+ }
+
+ // now check if all required values are there, and that a default value does not exists
+ for (Map<String, String> row : rows) {
+ String name = row.get("name");
+ boolean required = isPropertyRequired(rows, name);
+ if (required) {
+ String value = properties.get(name);
+ if (isEmpty(value)) {
+ value = getPropertyDefaultValue(rows, name);
+ }
+ if (isEmpty(value)) {
+ answer.put(name, value);
+ }
+ }
+ }
+
+ return answer;
+ }
+
+ @Override
public Map<String, String> endpointProperties(String uri) throws URISyntaxException {
// NOTICE: This logic is similar to org.apache.camel.util.EndpointHelper#endpointProperties
// as the catalog also offers similar functionality (without having camel-core on classpath)
http://git-wip-us.apache.org/repos/asf/camel/blob/3e109750/platforms/catalog/src/main/java/org/apache/camel/catalog/JSonSchemaHelper.java
----------------------------------------------------------------------
diff --git a/platforms/catalog/src/main/java/org/apache/camel/catalog/JSonSchemaHelper.java b/platforms/catalog/src/main/java/org/apache/camel/catalog/JSonSchemaHelper.java
index 17e0f85..e3e4beb 100644
--- a/platforms/catalog/src/main/java/org/apache/camel/catalog/JSonSchemaHelper.java
+++ b/platforms/catalog/src/main/java/org/apache/camel/catalog/JSonSchemaHelper.java
@@ -129,6 +129,57 @@ public final class JSonSchemaHelper {
return false;
}
+ public static boolean isPropertyBoolean(List<Map<String, String>> rows, String name) {
+ for (Map<String, String> row : rows) {
+ String type = null;
+ boolean found = false;
+ if (row.containsKey("name")) {
+ found = name.equals(row.get("name"));
+ }
+ if (row.containsKey("type")) {
+ type = row.get("type");
+ }
+ if (found) {
+ return "boolean".equals(type);
+ }
+ }
+ return false;
+ }
+
+ public static boolean isPropertyInteger(List<Map<String, String>> rows, String name) {
+ for (Map<String, String> row : rows) {
+ String type = null;
+ boolean found = false;
+ if (row.containsKey("name")) {
+ found = name.equals(row.get("name"));
+ }
+ if (row.containsKey("type")) {
+ type = row.get("type");
+ }
+ if (found) {
+ return "integer".equals(type);
+ }
+ }
+ return false;
+ }
+
+ public static boolean isPropertyNumber(List<Map<String, String>> rows, String name) {
+ for (Map<String, String> row : rows) {
+ String type = null;
+ boolean found = false;
+ if (row.containsKey("name")) {
+ found = name.equals(row.get("name"));
+ }
+ if (row.containsKey("type")) {
+ type = row.get("type");
+ }
+ if (found) {
+ return "number".equals(type);
+ }
+ }
+ return false;
+ }
+
public static String getPropertyDefaultValue(List<Map<String, String>> rows, String name) {
for (Map<String, String> row : rows) {
String defaultValue = null;
@@ -146,4 +197,31 @@ public final class JSonSchemaHelper {
return null;
}
+ public static String getPropertyEnum(List<Map<String, String>> rows, String name) {
+ for (Map<String, String> row : rows) {
+ String enums = null;
+ String defaultValue = null;
+ boolean found = false;
+ if (row.containsKey("name")) {
+ found = name.equals(row.get("name"));
+ }
+ if (row.containsKey("enum")) {
+ enums = row.get("enum");
+ }
+ if (found) {
+ return enums;
+ }
+ }
+ return null;
+ }
+
+ public static Map<String, String> getRow(List<Map<String, String>> rows, String key) {
+ for (Map<String, String> row : rows) {
+ if (key.equals(row.get("name"))) {
+ return row;
+ }
+ }
+ return null;
+ }
+
}
http://git-wip-us.apache.org/repos/asf/camel/blob/3e109750/platforms/catalog/src/test/java/org/apache/camel/catalog/CamelCatalogTest.java
----------------------------------------------------------------------
diff --git a/platforms/catalog/src/test/java/org/apache/camel/catalog/CamelCatalogTest.java b/platforms/catalog/src/test/java/org/apache/camel/catalog/CamelCatalogTest.java
index 324362f..4c020da 100644
--- a/platforms/catalog/src/test/java/org/apache/camel/catalog/CamelCatalogTest.java
+++ b/platforms/catalog/src/test/java/org/apache/camel/catalog/CamelCatalogTest.java
@@ -22,7 +22,6 @@ import java.util.Map;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
-import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -388,6 +387,50 @@ public class CamelCatalogTest {
}
@Test
+ public void validateProperties() throws Exception {
+ // valid
+ Map<String, String> map = catalog.validateProperties("log:mylog");
+ assertNotNull(map);
+ assertEquals(0, map.size());
+
+ // unknown
+ map = catalog.validateProperties("log:mylog?level=WARN&foo=bar");
+ assertNotNull(map);
+ assertEquals(1, map.size());
+ assertEquals("bar", map.get("foo"));
+
+ // enum
+ map = catalog.validateProperties("jms:unknown:myqueue");
+ assertNotNull(map);
+ assertEquals(1, map.size());
+
+ // okay
+ map = catalog.validateProperties("yammer:MESSAGES?accessToken=aaa&consumerKey=bbb&consumerSecret=ccc&useJson=true&initialDelay=500");
+ assertNotNull(map);
+ assertEquals(0, map.size());
+
+ // required / boolean / integer
+ map = catalog.validateProperties("yammer:MESSAGES?accessToken=aaa&consumerKey=&useJson=no&initialDelay=five");
+ assertNotNull(map);
+ assertEquals(4, map.size());
+ assertEquals(null, map.get("consumerKey"));
+ assertEquals(null, map.get("consumerSecret"));
+ assertEquals("no", map.get("useJson"));
+ assertEquals("five", map.get("initialDelay"));
+
+ // okay
+ map = catalog.validateProperties("mqtt:myqtt?reconnectBackOffMultiplier=2.5");
+ assertNotNull(map);
+ assertEquals(0, map.size());
+
+ // number
+ map = catalog.validateProperties("mqtt:myqtt?reconnectBackOffMultiplier=five");
+ assertNotNull(map);
+ assertEquals(1, map.size());
+ assertEquals("five", map.get("reconnectBackOffMultiplier"));
+ }
+
+ @Test
public void testEndpointComponentName() throws Exception {
String name = catalog.endpointComponentName("jms:queue:foo");
assertEquals("jms", name);
[7/8] camel git commit: CAMEL-9375: Fixed todo. Closes #739
Posted by da...@apache.org.
CAMEL-9375: Fixed todo. Closes #739
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/962216f9
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/962216f9
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/962216f9
Branch: refs/heads/master
Commit: 962216f9c8cca3004ce8fbd229e192473781ff37
Parents: 4116ab2
Author: Claus Ibsen <da...@apache.org>
Authored: Sun Dec 20 07:55:44 2015 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Sun Dec 20 07:55:44 2015 +0100
----------------------------------------------------------------------
.../camel/dataformat/tarfile/TarSplitterRouteIssueTest.java | 4 ----
1 file changed, 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/962216f9/components/camel-tarfile/src/test/java/org/apache/camel/dataformat/tarfile/TarSplitterRouteIssueTest.java
----------------------------------------------------------------------
diff --git a/components/camel-tarfile/src/test/java/org/apache/camel/dataformat/tarfile/TarSplitterRouteIssueTest.java b/components/camel-tarfile/src/test/java/org/apache/camel/dataformat/tarfile/TarSplitterRouteIssueTest.java
index 7bbf813..37a8cef 100644
--- a/components/camel-tarfile/src/test/java/org/apache/camel/dataformat/tarfile/TarSplitterRouteIssueTest.java
+++ b/components/camel-tarfile/src/test/java/org/apache/camel/dataformat/tarfile/TarSplitterRouteIssueTest.java
@@ -36,10 +36,6 @@ public class TarSplitterRouteIssueTest extends CamelTestSupport {
template.sendBody("seda:decompressFiles", new File("src/test/resources/data/tarfile3.tar"));
- // TODO: a bug which causes the TarSplitter to include an extra empty entry
- // the bug is in the TarIterator hasNext / next
- Thread.sleep(2000);
-
assertMockEndpointsSatisfied();
}