camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jans...@apache.org
Subject svn commit: r814646 [2/2] - in /camel/trunk/components/camel-printer: ./ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/camel/ src/main/java/org/apache/camel/component/ src/main/java/org/apache/camel...
Date Mon, 14 Sep 2009 13:59:52 GMT
Added: camel/trunk/components/camel-printer/src/test/java/org/apache/camel/component/printer/PrinterPrintTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-printer/src/test/java/org/apache/camel/component/printer/PrinterPrintTest.java?rev=814646&view=auto
==============================================================================
--- camel/trunk/components/camel-printer/src/test/java/org/apache/camel/component/printer/PrinterPrintTest.java
(added)
+++ camel/trunk/components/camel-printer/src/test/java/org/apache/camel/component/printer/PrinterPrintTest.java
Mon Sep 14 13:59:50 2009
@@ -0,0 +1,140 @@
+/**
+ * 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.printer;
+
+import java.io.BufferedInputStream;
+import java.io.FileInputStream;
+import java.io.InputStream;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.Exchange;
+import org.apache.camel.Message;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+
+public class PrinterPrintTest extends ContextTestSupport {
+
+    @Override
+    public boolean isUseRouteBuilder() {
+        return false;
+    }
+
+    private void sendFile() throws Exception {
+        template.send("direct:start", new Processor() {
+            public void process(Exchange exchange) throws Exception {
+             // Read from an input stream
+                InputStream is = new BufferedInputStream(
+                    new FileInputStream("./src/test/resources/test.txt"));
+
+                byte buffer[] = new byte[is.available()];
+                int n = is.available();
+                for (int i = 0; i < n; i++) {
+                    buffer[i] = (byte)is.read();
+                }
+
+                is.close();
+                // Set the property of the charset encoding
+                exchange.setProperty(Exchange.CHARSET_NAME, "UTF-8");
+                Message in = exchange.getIn();
+                in.setBody(buffer);
+            }            
+        });       
+    }
+    
+    private void sendGIF() throws Exception {
+        template.send("direct:start", new Processor() {
+            public void process(Exchange exchange) throws Exception {
+             // Read from an input stream
+                InputStream is = new BufferedInputStream(
+                    new FileInputStream("./src/test/resources/asf-logo.gif"));
+
+                byte buffer[] = new byte[is.available()];
+                int n = is.available();
+                for (int i = 0; i < n; i++) {
+                    buffer[i] = (byte)is.read();
+                }
+                  
+                is.close();
+                // Set the property of the charset encoding
+                exchange.setProperty(Exchange.CHARSET_NAME, "UTF-8");
+                Message in = exchange.getIn();
+                in.setBody(buffer);
+            }            
+        });       
+    }
+    
+    private void sendJPEG() throws Exception {
+        template.send("direct:start", new Processor() {
+            public void process(Exchange exchange) throws Exception {
+             // Read from an input stream
+                InputStream is = new BufferedInputStream(
+                    new FileInputStream("./src/test/resources/asf-logo.JPG"));
+
+                byte buffer[] = new byte[is.available()];
+                int n = is.available();
+                for (int i = 0; i < n; i++) {
+                    buffer[i] = (byte)is.read();
+                }
+                
+                is.close();
+                
+                // Set the property of the charset encoding
+                exchange.setProperty(Exchange.CHARSET_NAME, "UTF-8");
+                Message in = exchange.getIn();
+                in.setBody(buffer);
+            }            
+        });       
+    }
+
+    public void testSendingFileToPrinter() throws Exception {
+        context.addRoutes(new RouteBuilder() {
+            public void configure() {
+                from("direct:start").
+                    to("lpr://localhost/default?copies=1&flavor=DocFlavor.BYTE_ARRAY&mimeType=AUTOSENSE&mediaSize=na-letter&sides=one-sided&sendToPrinter=false");
+            }
+        });
+        context.start();
+
+        sendFile();
+    }
+    
+    public void testSendingGIFToPrinter() throws Exception {
+        context.addRoutes(new RouteBuilder() {
+            public void configure() {
+                from("direct:start").
+                    to("lpr://localhost/default?flavor=DocFlavor.INPUT_STREAM&mimeType=GIF&mediaSize=na-letter&sides=one-sided&sendToPrinter=false");
+            }
+        });
+        context.start();
+
+        sendGIF();
+    }
+    
+    public void testSendingJPEGToPrinter() throws Exception {
+        context.addRoutes(new RouteBuilder() {
+            public void configure() {
+                from("direct:start").
+                    to("lpr://localhost/default?copies=2&flavor=DocFlavor.INPUT_STREAM&mimeType=JPEG&mediaSize=na-letter&sides=one-sided&sendToPrinter=false");
+            }
+        });
+        context.start();
+
+        sendJPEG();
+    }
+
+}

Added: camel/trunk/components/camel-printer/src/test/resources/Thumbs.db
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-printer/src/test/resources/Thumbs.db?rev=814646&view=auto
==============================================================================
Binary file - no diff available.

Propchange: camel/trunk/components/camel-printer/src/test/resources/Thumbs.db
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: camel/trunk/components/camel-printer/src/test/resources/asf-logo.JPG
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-printer/src/test/resources/asf-logo.JPG?rev=814646&view=auto
==============================================================================
Binary file - no diff available.

Propchange: camel/trunk/components/camel-printer/src/test/resources/asf-logo.JPG
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: camel/trunk/components/camel-printer/src/test/resources/asf-logo.gif
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-printer/src/test/resources/asf-logo.gif?rev=814646&view=auto
==============================================================================
Binary file - no diff available.

Propchange: camel/trunk/components/camel-printer/src/test/resources/asf-logo.gif
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: camel/trunk/components/camel-printer/src/test/resources/log4j.properties
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-printer/src/test/resources/log4j.properties?rev=814646&view=auto
==============================================================================
--- camel/trunk/components/camel-printer/src/test/resources/log4j.properties (added)
+++ camel/trunk/components/camel-printer/src/test/resources/log4j.properties Mon Sep 14 13:59:50
2009
@@ -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.
+## ------------------------------------------------------------------------
+
+#
+# The logging properties used for eclipse testing, We want to see debug output on the console.
+#
+log4j.rootLogger=INFO, file
+
+# uncomment the following to enable camel debugging
+log4j.logger.org.apache.camel.component.printer=INFO
+#log4j.logger.org.apache.camel=DEBUG
+#log4j.logger.org.apache.commons.net=TRACE
+
+# 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
+
+# File appender
+log4j.appender.file=org.apache.log4j.FileAppender
+log4j.appender.file.layout=org.apache.log4j.PatternLayout
+log4j.appender.file.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n
+log4j.appender.file.file=target/camel-printer-test.log

Added: camel/trunk/components/camel-printer/src/test/resources/test.txt
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-printer/src/test/resources/test.txt?rev=814646&view=auto
==============================================================================
--- camel/trunk/components/camel-printer/src/test/resources/test.txt (added)
+++ camel/trunk/components/camel-printer/src/test/resources/test.txt Mon Sep 14 13:59:50 2009
@@ -0,0 +1,11 @@
+All that is gold does not glitter 
+by: JRR Tolkien 
+
+All that is gold does not glitter,
+Not all those who wander are lost
+The old that is strong does not wither,
+Deep roots are not reached by the frost.
+From the ashes a fire shall be woken,
+A light from the shadows shall spring;
+Renewed shall be blade that was broken,
+The crownless again shall be king.
\ No newline at end of file



Mime
View raw message