CAMEL-9097: Move test to camel-saxon
Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/eeb09c82 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/eeb09c82 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/eeb09c82 Branch: refs/heads/master Commit: eeb09c8277e2e520dcc7322a1f334560acd185c1 Parents: 717a42d Author: Claus Ibsen <davscl...@apache.org> Authored: Wed Sep 16 14:48:15 2015 +0200 Committer: Claus Ibsen <davscl...@apache.org> Committed: Wed Sep 16 14:48:15 2015 +0200 ---------------------------------------------------------------------- camel-core/pom.xml | 7 -- .../toolbox/XsltAggregationStrategyTest.java | 74 -------------------- .../util/toolbox/aggregate-user-property.xsl | 32 --------- .../org/apache/camel/util/toolbox/aggregate.xsl | 32 --------- .../org/apache/camel/util/toolbox/data1.xml | 18 ----- .../org/apache/camel/util/toolbox/data2.xml | 18 ----- .../org/apache/camel/util/toolbox/data3.xml | 18 ----- .../toolbox/XsltAggregationStrategyTest.java | 74 ++++++++++++++++++++ .../util/toolbox/aggregate-user-property.xsl | 32 +++++++++ .../org/apache/camel/util/toolbox/aggregate.xsl | 32 +++++++++ .../org/apache/camel/util/toolbox/data1.xml | 18 +++++ .../org/apache/camel/util/toolbox/data2.xml | 18 +++++ .../org/apache/camel/util/toolbox/data3.xml | 18 +++++ 13 files changed, 192 insertions(+), 199 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/eeb09c82/camel-core/pom.xml ---------------------------------------------------------------------- diff --git a/camel-core/pom.xml b/camel-core/pom.xml index 5817dee..0152138 100644 --- a/camel-core/pom.xml +++ b/camel-core/pom.xml @@ -169,13 +169,6 @@ <scope>test</scope> </dependency> - <!-- for xslt tests --> - <dependency> - <groupId>net.sf.saxon</groupId> - <artifactId>Saxon-HE</artifactId> - <scope>test</scope> - </dependency> - <!-- validator --> <dependency> <groupId>xml-resolver</groupId> http://git-wip-us.apache.org/repos/asf/camel/blob/eeb09c82/camel-core/src/test/java/org/apache/camel/util/toolbox/XsltAggregationStrategyTest.java ---------------------------------------------------------------------- diff --git a/camel-core/src/test/java/org/apache/camel/util/toolbox/XsltAggregationStrategyTest.java b/camel-core/src/test/java/org/apache/camel/util/toolbox/XsltAggregationStrategyTest.java deleted file mode 100644 index da5bf67..0000000 --- a/camel-core/src/test/java/org/apache/camel/util/toolbox/XsltAggregationStrategyTest.java +++ /dev/null @@ -1,74 +0,0 @@ -/** - * 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.util.toolbox; - -import org.apache.camel.ContextTestSupport; -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.component.mock.MockEndpoint; -import org.junit.Test; - -/** - * Unit test for the {@link XsltAggregationStrategy}. - * <p> - * Need to use Saxon to get a predictable result: we cannot rely on the JDK's XSLT processor as it can vary across - * platforms and JDK versions. Also, Xalan does not handle node-set properties well. - */ -public class XsltAggregationStrategyTest extends ContextTestSupport { - - @Test - public void testXsltAggregationDefaultProperty() throws Exception { - context.startRoute("route1"); - MockEndpoint mock = getMockEndpoint("mock:transformed"); - mock.expectedMessageCount(1); - mock.expectedBodiesReceived("<?xml version=\"1.0\" encoding=\"UTF-8\"?><item>ABC</item>"); - assertMockEndpointsSatisfied(); - } - - @Test - public void testXsltAggregationUserProperty() throws Exception { - context.startRoute("route2"); - MockEndpoint mock = getMockEndpoint("mock:transformed"); - mock.expectedMessageCount(1); - mock.expectedBodiesReceived("<?xml version=\"1.0\" encoding=\"UTF-8\"?><item>ABC</item>"); - assertMockEndpointsSatisfied(); - } - - protected RouteBuilder createRouteBuilder() throws Exception { - return new RouteBuilder() { - @Override - public void configure() throws Exception { - from("file:src/test/resources/org/apache/camel/util/toolbox?noop=true&antInclude=*.xml") - .routeId("route1").noAutoStartup() - .aggregate(new XsltAggregationStrategy("org/apache/camel/util/toolbox/aggregate.xsl") - .withSaxon()) - .constant(true) - .completionFromBatchConsumer() - .log("after aggregate body: ${body}") - .to("mock:transformed"); - - from("file:src/test/resources/org/apache/camel/util/toolbox?noop=true&antInclude=*.xml") - .routeId("route2").noAutoStartup() - .aggregate(new XsltAggregationStrategy("org/apache/camel/util/toolbox/aggregate-user-property.xsl") - .withSaxon().withPropertyName("user-property")) - .constant(true) - .completionFromBatchConsumer() - .log("after aggregate body: ${body}") - .to("mock:transformed"); - } - }; - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/eeb09c82/camel-core/src/test/resources/org/apache/camel/util/toolbox/aggregate-user-property.xsl ---------------------------------------------------------------------- diff --git a/camel-core/src/test/resources/org/apache/camel/util/toolbox/aggregate-user-property.xsl b/camel-core/src/test/resources/org/apache/camel/util/toolbox/aggregate-user-property.xsl deleted file mode 100644 index 74bdd85..0000000 --- a/camel-core/src/test/resources/org/apache/camel/util/toolbox/aggregate-user-property.xsl +++ /dev/null @@ -1,32 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- - 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. ---> -<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> - - <xsl:output method="xml" indent="no"/> - <xsl:strip-space elements="*"/> - - <xsl:param name="user-property" /> - - <xsl:template match="/"> - <item> - <xsl:value-of select="."/> - <xsl:value-of select="$user-property/item"/> - </item> - </xsl:template> - -</xsl:stylesheet> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/eeb09c82/camel-core/src/test/resources/org/apache/camel/util/toolbox/aggregate.xsl ---------------------------------------------------------------------- diff --git a/camel-core/src/test/resources/org/apache/camel/util/toolbox/aggregate.xsl b/camel-core/src/test/resources/org/apache/camel/util/toolbox/aggregate.xsl deleted file mode 100644 index 8d20385..0000000 --- a/camel-core/src/test/resources/org/apache/camel/util/toolbox/aggregate.xsl +++ /dev/null @@ -1,32 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- - 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. ---> -<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> - - <xsl:output method="xml" indent="no"/> - <xsl:strip-space elements="*"/> - - <xsl:param name="new-exchange" /> - - <xsl:template match="/"> - <item> - <xsl:value-of select="."/> - <xsl:value-of select="$new-exchange/item"/> - </item> - </xsl:template> - -</xsl:stylesheet> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/eeb09c82/camel-core/src/test/resources/org/apache/camel/util/toolbox/data1.xml ---------------------------------------------------------------------- diff --git a/camel-core/src/test/resources/org/apache/camel/util/toolbox/data1.xml b/camel-core/src/test/resources/org/apache/camel/util/toolbox/data1.xml deleted file mode 100644 index be8cd6d..0000000 --- a/camel-core/src/test/resources/org/apache/camel/util/toolbox/data1.xml +++ /dev/null @@ -1,18 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - 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. ---> -<item>A</item> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/eeb09c82/camel-core/src/test/resources/org/apache/camel/util/toolbox/data2.xml ---------------------------------------------------------------------- diff --git a/camel-core/src/test/resources/org/apache/camel/util/toolbox/data2.xml b/camel-core/src/test/resources/org/apache/camel/util/toolbox/data2.xml deleted file mode 100644 index 3d3d463..0000000 --- a/camel-core/src/test/resources/org/apache/camel/util/toolbox/data2.xml +++ /dev/null @@ -1,18 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - 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. ---> -<item>B</item> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/eeb09c82/camel-core/src/test/resources/org/apache/camel/util/toolbox/data3.xml ---------------------------------------------------------------------- diff --git a/camel-core/src/test/resources/org/apache/camel/util/toolbox/data3.xml b/camel-core/src/test/resources/org/apache/camel/util/toolbox/data3.xml deleted file mode 100644 index 9182bcb..0000000 --- a/camel-core/src/test/resources/org/apache/camel/util/toolbox/data3.xml +++ /dev/null @@ -1,18 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - 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. ---> -<item>C</item> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/eeb09c82/components/camel-saxon/src/test/java/org/apache/camel/util/toolbox/XsltAggregationStrategyTest.java ---------------------------------------------------------------------- diff --git a/components/camel-saxon/src/test/java/org/apache/camel/util/toolbox/XsltAggregationStrategyTest.java b/components/camel-saxon/src/test/java/org/apache/camel/util/toolbox/XsltAggregationStrategyTest.java new file mode 100644 index 0000000..7ad2ab6 --- /dev/null +++ b/components/camel-saxon/src/test/java/org/apache/camel/util/toolbox/XsltAggregationStrategyTest.java @@ -0,0 +1,74 @@ +/** + * 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.util.toolbox; + +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.component.mock.MockEndpoint; +import org.apache.camel.test.junit4.CamelTestSupport; +import org.junit.Test; + +/** + * Unit test for the {@link XsltAggregationStrategy}. + * <p> + * Need to use Saxon to get a predictable result: we cannot rely on the JDK's XSLT processor as it can vary across + * platforms and JDK versions. Also, Xalan does not handle node-set properties well. + */ +public class XsltAggregationStrategyTest extends CamelTestSupport { + + @Test + public void testXsltAggregationDefaultProperty() throws Exception { + context.startRoute("route1"); + MockEndpoint mock = getMockEndpoint("mock:transformed"); + mock.expectedMessageCount(1); + mock.expectedBodiesReceived("<?xml version=\"1.0\" encoding=\"UTF-8\"?><item>ABC</item>"); + assertMockEndpointsSatisfied(); + } + + @Test + public void testXsltAggregationUserProperty() throws Exception { + context.startRoute("route2"); + MockEndpoint mock = getMockEndpoint("mock:transformed"); + mock.expectedMessageCount(1); + mock.expectedBodiesReceived("<?xml version=\"1.0\" encoding=\"UTF-8\"?><item>ABC</item>"); + assertMockEndpointsSatisfied(); + } + + protected RouteBuilder createRouteBuilder() throws Exception { + return new RouteBuilder() { + @Override + public void configure() throws Exception { + from("file:src/test/resources/org/apache/camel/util/toolbox?noop=true&antInclude=*.xml") + .routeId("route1").noAutoStartup() + .aggregate(new XsltAggregationStrategy("org/apache/camel/util/toolbox/aggregate.xsl") + .withSaxon()) + .constant(true) + .completionFromBatchConsumer() + .log("after aggregate body: ${body}") + .to("mock:transformed"); + + from("file:src/test/resources/org/apache/camel/util/toolbox?noop=true&antInclude=*.xml") + .routeId("route2").noAutoStartup() + .aggregate(new XsltAggregationStrategy("org/apache/camel/util/toolbox/aggregate-user-property.xsl") + .withSaxon().withPropertyName("user-property")) + .constant(true) + .completionFromBatchConsumer() + .log("after aggregate body: ${body}") + .to("mock:transformed"); + } + }; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/eeb09c82/components/camel-saxon/src/test/resources/org/apache/camel/util/toolbox/aggregate-user-property.xsl ---------------------------------------------------------------------- diff --git a/components/camel-saxon/src/test/resources/org/apache/camel/util/toolbox/aggregate-user-property.xsl b/components/camel-saxon/src/test/resources/org/apache/camel/util/toolbox/aggregate-user-property.xsl new file mode 100644 index 0000000..74bdd85 --- /dev/null +++ b/components/camel-saxon/src/test/resources/org/apache/camel/util/toolbox/aggregate-user-property.xsl @@ -0,0 +1,32 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + 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. +--> +<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> + + <xsl:output method="xml" indent="no"/> + <xsl:strip-space elements="*"/> + + <xsl:param name="user-property" /> + + <xsl:template match="/"> + <item> + <xsl:value-of select="."/> + <xsl:value-of select="$user-property/item"/> + </item> + </xsl:template> + +</xsl:stylesheet> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/eeb09c82/components/camel-saxon/src/test/resources/org/apache/camel/util/toolbox/aggregate.xsl ---------------------------------------------------------------------- diff --git a/components/camel-saxon/src/test/resources/org/apache/camel/util/toolbox/aggregate.xsl b/components/camel-saxon/src/test/resources/org/apache/camel/util/toolbox/aggregate.xsl new file mode 100644 index 0000000..8d20385 --- /dev/null +++ b/components/camel-saxon/src/test/resources/org/apache/camel/util/toolbox/aggregate.xsl @@ -0,0 +1,32 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + 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. +--> +<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> + + <xsl:output method="xml" indent="no"/> + <xsl:strip-space elements="*"/> + + <xsl:param name="new-exchange" /> + + <xsl:template match="/"> + <item> + <xsl:value-of select="."/> + <xsl:value-of select="$new-exchange/item"/> + </item> + </xsl:template> + +</xsl:stylesheet> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/eeb09c82/components/camel-saxon/src/test/resources/org/apache/camel/util/toolbox/data1.xml ---------------------------------------------------------------------- diff --git a/components/camel-saxon/src/test/resources/org/apache/camel/util/toolbox/data1.xml b/components/camel-saxon/src/test/resources/org/apache/camel/util/toolbox/data1.xml new file mode 100644 index 0000000..be8cd6d --- /dev/null +++ b/components/camel-saxon/src/test/resources/org/apache/camel/util/toolbox/data1.xml @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + 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. +--> +<item>A</item> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/eeb09c82/components/camel-saxon/src/test/resources/org/apache/camel/util/toolbox/data2.xml ---------------------------------------------------------------------- diff --git a/components/camel-saxon/src/test/resources/org/apache/camel/util/toolbox/data2.xml b/components/camel-saxon/src/test/resources/org/apache/camel/util/toolbox/data2.xml new file mode 100644 index 0000000..3d3d463 --- /dev/null +++ b/components/camel-saxon/src/test/resources/org/apache/camel/util/toolbox/data2.xml @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + 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. +--> +<item>B</item> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/eeb09c82/components/camel-saxon/src/test/resources/org/apache/camel/util/toolbox/data3.xml ---------------------------------------------------------------------- diff --git a/components/camel-saxon/src/test/resources/org/apache/camel/util/toolbox/data3.xml b/components/camel-saxon/src/test/resources/org/apache/camel/util/toolbox/data3.xml new file mode 100644 index 0000000..9182bcb --- /dev/null +++ b/components/camel-saxon/src/test/resources/org/apache/camel/util/toolbox/data3.xml @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + 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. +--> +<item>C</item> \ No newline at end of file