You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ni...@apache.org on 2014/10/20 04:43:45 UTC
[3/4] git commit: fix for CAMEL-7883
fix for CAMEL-7883
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/ca61a385
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/ca61a385
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/ca61a385
Branch: refs/heads/camel-2.13.x
Commit: ca61a38570ee7fe1102e52ae7467bd2f79520ff8
Parents: 53aee2b
Author: Benjamin BONNET <be...@m4x.org>
Authored: Wed Oct 1 00:36:43 2014 +0200
Committer: Willem Jiang <wi...@gmail.com>
Committed: Mon Oct 20 10:43:04 2014 +0800
----------------------------------------------------------------------
.../validator/DefaultLSResourceResolver.java | 3 +-
.../ValidatorIncludeEncodingRouteTest.java | 85 ++++++++++++++++++++
.../camel/component/validator/sentence.xsd | 20 +++++
.../apache/camel/component/validator/text.xsd | 23 ++++++
4 files changed, 129 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/ca61a385/camel-core/src/main/java/org/apache/camel/component/validator/DefaultLSResourceResolver.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/component/validator/DefaultLSResourceResolver.java b/camel-core/src/main/java/org/apache/camel/component/validator/DefaultLSResourceResolver.java
index 622e257..38fa704 100644
--- a/camel-core/src/main/java/org/apache/camel/component/validator/DefaultLSResourceResolver.java
+++ b/camel-core/src/main/java/org/apache/camel/component/validator/DefaultLSResourceResolver.java
@@ -117,8 +117,7 @@ public class DefaultLSResourceResolver implements LSResourceResolver {
@Override
public Reader getCharacterStream() {
- InputStream is = getByteStream();
- return camelContext.getTypeConverter().convertTo(Reader.class, is);
+ return null;
}
@Override
http://git-wip-us.apache.org/repos/asf/camel/blob/ca61a385/camel-core/src/test/java/org/apache/camel/component/validator/ValidatorIncludeEncodingRouteTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/component/validator/ValidatorIncludeEncodingRouteTest.java b/camel-core/src/test/java/org/apache/camel/component/validator/ValidatorIncludeEncodingRouteTest.java
new file mode 100644
index 0000000..efb37f0
--- /dev/null
+++ b/camel-core/src/test/java/org/apache/camel/component/validator/ValidatorIncludeEncodingRouteTest.java
@@ -0,0 +1,85 @@
+/**
+ * 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.validator;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.Exchange;
+import org.apache.camel.LoggingLevel;
+import org.apache.camel.Processor;
+import org.apache.camel.ValidationException;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+
+/**
+ *
+ */
+public class ValidatorIncludeEncodingRouteTest extends ContextTestSupport {
+
+ protected MockEndpoint validEndpoint;
+ protected MockEndpoint finallyEndpoint;
+ protected MockEndpoint invalidEndpoint;
+
+ public void testValidMessage() throws Exception {
+ validEndpoint.expectedMessageCount(1);
+ finallyEndpoint.expectedMessageCount(1);
+
+ String body = "<t:text xmlns:t=\"org.text\">\n"
+ + " <t:sentence>J'aime les camélidés</t:sentence>\n"
+ + "</t:text>";
+
+ template.sendBody("direct:start", body);
+
+ MockEndpoint.assertIsSatisfied(validEndpoint, invalidEndpoint, finallyEndpoint);
+ }
+
+
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ validEndpoint = resolveMandatoryEndpoint("mock:valid", MockEndpoint.class);
+ invalidEndpoint = resolveMandatoryEndpoint("mock:invalid", MockEndpoint.class);
+ finallyEndpoint = resolveMandatoryEndpoint("mock:finally", MockEndpoint.class);
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ from("direct:start")
+ .doTry()
+ .to("validator:org/apache/camel/component/validator/text.xsd")
+ .to("mock:valid")
+ .doCatch(NumberFormatException.class)
+ .process(new Processor() {
+
+ @Override
+ public void process(Exchange exchange) throws Exception {
+System.err.println("helo " + exchange.getException());
+ }
+ })
+ .to("mock:invalid")
+ .doFinally()
+ .to("mock:finally")
+ .end();
+ }
+ };
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/ca61a385/camel-core/src/test/resources/org/apache/camel/component/validator/sentence.xsd
----------------------------------------------------------------------
diff --git a/camel-core/src/test/resources/org/apache/camel/component/validator/sentence.xsd b/camel-core/src/test/resources/org/apache/camel/component/validator/sentence.xsd
new file mode 100644
index 0000000..6fd3762
--- /dev/null
+++ b/camel-core/src/test/resources/org/apache/camel/component/validator/sentence.xsd
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!-- 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. -->
+<xs:schema attributeFormDefault="unqualified"
+ elementFormDefault="qualified" targetNamespace="org.text.sentence"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema">
+ <xs:simpleType name="sentence">
+ <xs:restriction base="xs:string">
+ <xs:pattern value="[a-zA-Z�' ]*" />
+ </xs:restriction>
+ </xs:simpleType>
+</xs:schema>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/ca61a385/camel-core/src/test/resources/org/apache/camel/component/validator/text.xsd
----------------------------------------------------------------------
diff --git a/camel-core/src/test/resources/org/apache/camel/component/validator/text.xsd b/camel-core/src/test/resources/org/apache/camel/component/validator/text.xsd
new file mode 100644
index 0000000..e49d58f
--- /dev/null
+++ b/camel-core/src/test/resources/org/apache/camel/component/validator/text.xsd
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!-- 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. -->
+<xs:schema attributeFormDefault="unqualified"
+ elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ xmlns:p="org.text" targetNamespace="org.text" xmlns:s="org.text.sentence">
+ <xs:import schemaLocation="sentence.xsd" namespace="org.text.sentence" />
+ <xs:element name="text" type="p:textType">
+ </xs:element>
+ <xs:complexType name="textType">
+ <xs:sequence>
+ <xs:element type="s:sentence" name="sentence" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+</xs:schema>
\ No newline at end of file