Return-Path: X-Original-To: apmail-camel-commits-archive@www.apache.org Delivered-To: apmail-camel-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id E892B11E97 for ; Mon, 22 Sep 2014 07:09:22 +0000 (UTC) Received: (qmail 97324 invoked by uid 500); 22 Sep 2014 07:09:22 -0000 Delivered-To: apmail-camel-commits-archive@camel.apache.org Received: (qmail 97276 invoked by uid 500); 22 Sep 2014 07:09:22 -0000 Mailing-List: contact commits-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@camel.apache.org Delivered-To: mailing list commits@camel.apache.org Received: (qmail 97261 invoked by uid 99); 22 Sep 2014 07:09:22 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 22 Sep 2014 07:09:22 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 3A67794834F; Mon, 22 Sep 2014 07:09:22 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: ningjiang@apache.org To: commits@camel.apache.org Date: Mon, 22 Sep 2014 07:09:23 -0000 Message-Id: In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [2/3] git commit: CAMEL-7839 Fixed the issue that Xpath is not namespace aware in choice CAMEL-7839 Fixed the issue that Xpath is not namespace aware in choice Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/61867a06 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/61867a06 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/61867a06 Branch: refs/heads/camel-2.13.x Commit: 61867a06054b57d8e6b218d78cec0c9e4ed8c8ea Parents: 9780114 Author: Willem Jiang Authored: Mon Sep 22 15:05:59 2014 +0800 Committer: Willem Jiang Committed: Mon Sep 22 15:08:24 2014 +0800 ---------------------------------------------------------------------- .../camel/model/ProcessorDefinitionHelper.java | 3 ++ .../model/ProcessorDefinitionHelperTest.java | 6 ++- ...erWithNamespaceOnImportRouteContextTest.java | 38 +++++++++++++++++++ .../xpathChoiceWithNamespaceOnRouteContext.xml | 32 ++++++++++++++++ ...eWithNamespaceOnRouteContextRouteContext.xml | 39 ++++++++++++++++++++ 5 files changed, 116 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/61867a06/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinitionHelper.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinitionHelper.java b/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinitionHelper.java index 2ae283b..a46502f 100644 --- a/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinitionHelper.java +++ b/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinitionHelper.java @@ -210,6 +210,9 @@ public final class ProcessorDefinitionHelper { if (out instanceof ChoiceDefinition) { ChoiceDefinition choice = (ChoiceDefinition) out; for (WhenDefinition when : choice.getWhenClauses()) { + if (type.isInstance(when)) { + found.add((T)when); + } List> children = when.getOutputs(); doFindType(children, type, found); } http://git-wip-us.apache.org/repos/asf/camel/blob/61867a06/camel-core/src/test/java/org/apache/camel/model/ProcessorDefinitionHelperTest.java ---------------------------------------------------------------------- diff --git a/camel-core/src/test/java/org/apache/camel/model/ProcessorDefinitionHelperTest.java b/camel-core/src/test/java/org/apache/camel/model/ProcessorDefinitionHelperTest.java index 4aa1d7e..8aa7b0c 100644 --- a/camel-core/src/test/java/org/apache/camel/model/ProcessorDefinitionHelperTest.java +++ b/camel-core/src/test/java/org/apache/camel/model/ProcessorDefinitionHelperTest.java @@ -29,7 +29,9 @@ public class ProcessorDefinitionHelperTest extends ContextTestSupport { Iterator it = ProcessorDefinitionHelper.filterTypeInOutputs(route.getOutputs(), ProcessorDefinition.class); assertNotNull(it); + assertEquals("whenfoo", it.next().getId()); assertEquals("foo", it.next().getId()); + assertEquals("whenbar", it.next().getId()); assertEquals("bar", it.next().getId()); assertEquals("baz", it.next().getId()); assertFalse(it.hasNext()); @@ -42,8 +44,8 @@ public class ProcessorDefinitionHelperTest extends ContextTestSupport { public void configure() throws Exception { from("direct:start") .choice() - .when(header("foo")).to("mock:foo").id("foo") - .when(header("bar")).to("mock:bar").id("bar") + .when(header("foo")).id("whenfoo").to("mock:foo").id("foo") + .when(header("bar")).id("whenbar").to("mock:bar").id("bar") .otherwise() .to("mock:baz").id("baz"); } http://git-wip-us.apache.org/repos/asf/camel/blob/61867a06/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringXPathFilterWithNamespaceOnImportRouteContextTest.java ---------------------------------------------------------------------- diff --git a/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringXPathFilterWithNamespaceOnImportRouteContextTest.java b/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringXPathFilterWithNamespaceOnImportRouteContextTest.java new file mode 100644 index 0000000..0a1a42e --- /dev/null +++ b/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringXPathFilterWithNamespaceOnImportRouteContextTest.java @@ -0,0 +1,38 @@ +/** + * 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.spring.processor; + +import org.apache.camel.CamelContext; +import org.apache.camel.processor.XPathFilterTest; + +import static org.apache.camel.spring.processor.SpringTestHelper.createSpringCamelContext; + +/** + * + */ +public class SpringXPathFilterWithNamespaceOnImportRouteContextTest extends XPathFilterTest { + + @Override + protected void setUp() throws Exception { + matchingBody = ""; + super.setUp(); + } + + protected CamelContext createCamelContext() throws Exception { + return createSpringCamelContext(this, "org/apache/camel/spring/processor/xpathChoiceWithNamespaceOnRouteContext.xml"); + } +} http://git-wip-us.apache.org/repos/asf/camel/blob/61867a06/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/xpathChoiceWithNamespaceOnRouteContext.xml ---------------------------------------------------------------------- diff --git a/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/xpathChoiceWithNamespaceOnRouteContext.xml b/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/xpathChoiceWithNamespaceOnRouteContext.xml new file mode 100644 index 0000000..d39bd34 --- /dev/null +++ b/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/xpathChoiceWithNamespaceOnRouteContext.xml @@ -0,0 +1,32 @@ + + + + + + + + + + + + \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/61867a06/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/xpathChoiceWithNamespaceOnRouteContextRouteContext.xml ---------------------------------------------------------------------- diff --git a/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/xpathChoiceWithNamespaceOnRouteContextRouteContext.xml b/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/xpathChoiceWithNamespaceOnRouteContextRouteContext.xml new file mode 100644 index 0000000..885a837 --- /dev/null +++ b/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/xpathChoiceWithNamespaceOnRouteContextRouteContext.xml @@ -0,0 +1,39 @@ + + + + + + + + + + + /foo:person[@name='James'] + + + + + + + + \ No newline at end of file