camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From acosent...@apache.org
Subject [camel] branch camel-2.22.x updated: Fixing issue CAMEL-12890
Date Mon, 22 Oct 2018 05:48:24 GMT
This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a commit to branch camel-2.22.x
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/camel-2.22.x by this push:
     new f0b9b72  Fixing issue CAMEL-12890
f0b9b72 is described below

commit f0b9b72f7d20182927ae1df9fc3eca2a3fbb5ae0
Author: Kalyan Kumar Bandi <Kalyankumarbandi@eurofins.com>
AuthorDate: Fri Oct 19 22:40:05 2018 +0530

    Fixing issue CAMEL-12890
---
 .../camel/component/printer/PrinterProducer.java   |  2 +-
 .../camel/component/printer/PrinterPrintTest.java  | 30 ++++++++++++++++++++++
 2 files changed, 31 insertions(+), 1 deletion(-)

diff --git a/components/camel-printer/src/main/java/org/apache/camel/component/printer/PrinterProducer.java
b/components/camel-printer/src/main/java/org/apache/camel/component/printer/PrinterProducer.java
index 7e69aa7..e19f9f0 100644
--- a/components/camel-printer/src/main/java/org/apache/camel/component/printer/PrinterProducer.java
+++ b/components/camel-printer/src/main/java/org/apache/camel/component/printer/PrinterProducer.java
@@ -148,7 +148,7 @@ public class PrinterProducer extends DefaultProducer {
             // align slashes so we match / or \
             printerName = printerName.toLowerCase(Locale.US);
             printerName = printerName.replace('\\', '/');
-            if (printerName.endsWith(printer)) {
+            if (printer.endsWith(printerName)) {
                 position = i;
                 break;
             }
diff --git a/components/camel-printer/src/test/java/org/apache/camel/component/printer/PrinterPrintTest.java
b/components/camel-printer/src/test/java/org/apache/camel/component/printer/PrinterPrintTest.java
index 8c099c4..5a02c8b 100644
--- a/components/camel-printer/src/test/java/org/apache/camel/component/printer/PrinterPrintTest.java
+++ b/components/camel-printer/src/test/java/org/apache/camel/component/printer/PrinterPrintTest.java
@@ -306,6 +306,36 @@ public class PrinterPrintTest extends CamelTestSupport {
         verify(job1, times(1)).print(any(Doc.class), any(PrintRequestAttributeSet.class));
     }
 
+    /*
+     * Test for CAMEL-12890
+     * Unable to send to remote printer
+     * */
+    @Test
+    public void testSendingFileToRemotePrinter() throws Exception {
+        // setup javax.print 
+        PrintService ps1 = mock(PrintService.class);
+        when(ps1.getName()).thenReturn("printer1");
+        when(ps1.isDocFlavorSupported(any(DocFlavor.class))).thenReturn(Boolean.TRUE);
+        boolean res1 = PrintServiceLookup.registerService(ps1);
+        assertTrue("The Remote PrintService #1 should be registered.", res1);
+        DocPrintJob job1 = mock(DocPrintJob.class);
+        when(ps1.createPrintJob()).thenReturn(job1);
+
+        context.addRoutes(new RouteBuilder() {
+
+            public void configure() {
+                from("direct:start1").to("lpr://remote/printer1?sendToPrinter=true");
+            }
+        });
+        context.start();
+
+        template.sendBody("direct:start1", "Hello Printer 1");
+
+        context.stop();
+
+        verify(job1, times(1)).print(any(Doc.class), any(PrintRequestAttributeSet.class));
+    }
+
     @Test
     public void setJobName() throws Exception {
         if (isAwtHeadless()) {


Mime
View raw message