activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstrac...@apache.org
Subject svn commit: r534084 - in /activemq/camel/trunk: camel-core/src/main/java/org/apache/camel/builder/ camel-core/src/main/java/org/apache/camel/builder/xml/ camel-core/src/test/java/org/apache/camel/ camel-core/src/test/java/org/apache/camel/builder/xml/ ...
Date Tue, 01 May 2007 13:42:07 GMT
Author: jstrachan
Date: Tue May  1 06:42:05 2007
New Revision: 534084

URL: http://svn.apache.org/viewvc?view=rev&rev=534084
Log:
added XSLT test case

Added:
    activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/builder/xml/XsltTest.java
  (with props)
    activemq/camel/trunk/camel-core/src/test/resources/org/
    activemq/camel/trunk/camel-core/src/test/resources/org/apache/
    activemq/camel/trunk/camel-core/src/test/resources/org/apache/camel/
    activemq/camel/trunk/camel-core/src/test/resources/org/apache/camel/builder/
    activemq/camel/trunk/camel-core/src/test/resources/org/apache/camel/builder/xml/
    activemq/camel/trunk/camel-core/src/test/resources/org/apache/camel/builder/xml/example.xsl
  (with props)
    activemq/camel/trunk/camel-saxon/src/test/resources/log4j.properties   (with props)
Modified:
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/RouteBuilder.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/xml/XsltBuilder.java
    activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/ContextTestSupport.java

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/RouteBuilder.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/RouteBuilder.java?view=diff&rev=534084&r1=534083&r2=534084
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/RouteBuilder.java
(original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/RouteBuilder.java
Tue May  1 06:42:05 2007
@@ -49,7 +49,7 @@
     /**
      * Called on initialization to to build the required destinationBuilders
      */
-    public abstract void configure();
+    public abstract void configure() throws Exception;
 
     @Fluent
     public FromBuilder from( @FluentArg("uri") String uri) {

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/xml/XsltBuilder.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/xml/XsltBuilder.java?view=diff&rev=534084&r1=534083&r2=534084
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/xml/XsltBuilder.java
(original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/xml/XsltBuilder.java
Tue May  1 06:42:05 2007
@@ -17,11 +17,13 @@
  */
 package org.apache.camel.builder.xml;
 
+import static org.apache.camel.util.ObjectHelper.notNull;
 import org.apache.camel.Exchange;
 import org.apache.camel.ExpectedBodyTypeException;
 import org.apache.camel.Message;
 import org.apache.camel.Processor;
 import org.apache.camel.RuntimeTransformException;
+import org.apache.camel.util.ObjectHelper;
 import org.apache.camel.converter.jaxp.XmlConverter;
 
 import javax.xml.parsers.ParserConfigurationException;
@@ -35,6 +37,9 @@
 import java.util.Map;
 import java.util.Set;
 import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
 
 /**
  * Creates a <a href="http://activemq.apache.org/camel/processor.html">Processor</a>
@@ -46,7 +51,7 @@
     private Map<String, Object> parameters = new HashMap<String, Object>();
     private XmlConverter converter = new XmlConverter();
     private Transformer transformer;
-    private ResultHandler resultHandler = new DomResultHandler();
+    private ResultHandler resultHandler = new StringResultHandler();
     private boolean failOnNullBody = true;
 
     public XsltBuilder() {
@@ -87,6 +92,7 @@
      * Creates an XSLT processor using the given XSLT source
      */
     public static <E extends Exchange> XsltBuilder<E> xslt(Source xslt) throws
TransformerConfigurationException {
+        notNull(xslt, "xslt");
         XsltBuilder<E> answer = new XsltBuilder<E>();
         answer.setTransformerSource(xslt);
         return answer;
@@ -96,6 +102,23 @@
      * Creates an XSLT processor using the given XSLT source
      */
     public static <E extends Exchange> XsltBuilder<E> xslt(File xslt) throws
TransformerConfigurationException {
+        notNull(xslt, "xslt");
+        return xslt(new StreamSource(xslt));
+    }
+
+    /**
+     * Creates an XSLT processor using the given XSLT source
+     */
+    public static <E extends Exchange> XsltBuilder<E> xslt(URL xslt) throws TransformerConfigurationException,
IOException {
+        notNull(xslt, "xslt");
+        return xslt(xslt.openStream());
+    }
+
+    /**
+     * Creates an XSLT processor using the given XSLT source
+     */
+    public static <E extends Exchange> XsltBuilder<E> xslt(InputStream xslt)
throws TransformerConfigurationException, IOException {
+        notNull(xslt, "xslt");
         return xslt(new StreamSource(xslt));
     }
 

Modified: activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/ContextTestSupport.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/ContextTestSupport.java?view=diff&rev=534084&r1=534083&r2=534084
==============================================================================
--- activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/ContextTestSupport.java
(original)
+++ activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/ContextTestSupport.java
Tue May  1 06:42:05 2007
@@ -51,7 +51,7 @@
         return new DefaultCamelContext();
     }
 
-    protected RouteBuilder createRouteBuilder() {
+    protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {
             public void configure() {
                 // no routes added by default

Added: activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/builder/xml/XsltTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/builder/xml/XsltTest.java?view=auto&rev=534084
==============================================================================
--- activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/builder/xml/XsltTest.java
(added)
+++ activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/builder/xml/XsltTest.java
Tue May  1 06:42:05 2007
@@ -0,0 +1,51 @@
+/**
+ *
+ * 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.builder.xml;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.builder.RouteBuilder;
+import static org.apache.camel.builder.xml.XsltBuilder.xslt;
+import org.apache.camel.component.mock.MockEndpoint;
+
+import java.net.URL;
+
+/**
+ * @version $Revision: 1.1 $
+ */
+public class XsltTest extends ContextTestSupport {
+    
+    public void testXslt() throws Exception {
+        MockEndpoint resultEndpoint = (MockEndpoint) resolveMandatoryEndpoint("mock:result");
+        resultEndpoint.expectedBodiesReceived("<?xml version=\"1.0\" encoding=\"UTF-8\"?><goodbye>world!</goodbye>");
+
+        send("direct:start", "<hello>world!</hello>");
+
+        resultEndpoint.assertIsSatisfied();
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() {
+        return new RouteBuilder() {
+            public void configure() throws Exception {
+                URL styleSheet = getClass().getResource("example.xsl");
+
+                from("direct:start").process(xslt(styleSheet)).to("mock:result");
+            }
+        };
+    }
+}

Propchange: activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/builder/xml/XsltTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/camel/trunk/camel-core/src/test/resources/org/apache/camel/builder/xml/example.xsl
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/resources/org/apache/camel/builder/xml/example.xsl?view=auto&rev=534084
==============================================================================
--- activemq/camel/trunk/camel-core/src/test/resources/org/apache/camel/builder/xml/example.xsl
(added)
+++ activemq/camel/trunk/camel-core/src/test/resources/org/apache/camel/builder/xml/example.xsl
Tue May  1 06:42:05 2007
@@ -0,0 +1,10 @@
+<?xml version = "1.0"?>
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+
+  <xsl:template match="/">
+    <goodbye>
+      <xsl:value-of select="/hello"/>
+    </goodbye>
+  </xsl:template>
+
+</xsl:stylesheet>
\ No newline at end of file

Propchange: activemq/camel/trunk/camel-core/src/test/resources/org/apache/camel/builder/xml/example.xsl
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/camel/trunk/camel-saxon/src/test/resources/log4j.properties
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-saxon/src/test/resources/log4j.properties?view=auto&rev=534084
==============================================================================
--- activemq/camel/trunk/camel-saxon/src/test/resources/log4j.properties (added)
+++ activemq/camel/trunk/camel-saxon/src/test/resources/log4j.properties Tue May  1 06:42:05
2007
@@ -0,0 +1,29 @@
+## ------------------------------------------------------------------------
+## 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.
+## ------------------------------------------------------------------------
+
+#
+# The logging properties used for eclipse testing, We want to see debug output on the console.
+#
+log4j.rootLogger=INFO, out
+
+#log4j.logger.org.apache.camel=DEBUG
+
+# CONSOLE appender not used by default
+log4j.appender.out=org.apache.log4j.ConsoleAppender
+log4j.appender.out.layout=org.apache.log4j.PatternLayout
+log4j.appender.out.layout.ConversionPattern=[%30.30t] %-30.30c{1} %-5p %m%n
+#log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n

Propchange: activemq/camel/trunk/camel-saxon/src/test/resources/log4j.properties
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message