From commits-return-66122-archive-asf-public=cust-asf.ponee.io@camel.apache.org Mon Oct 22 07:49:51 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id 3C6E818064A for ; Mon, 22 Oct 2018 07:49:51 +0200 (CEST) Received: (qmail 20212 invoked by uid 500); 22 Oct 2018 05:49:50 -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 20203 invoked by uid 99); 22 Oct 2018 05:49:50 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 22 Oct 2018 05:49:50 +0000 Received: by gitbox.apache.org (ASF Mail Server at gitbox.apache.org, from userid 33) id 7878682922; Mon, 22 Oct 2018 05:49:49 +0000 (UTC) Date: Mon, 22 Oct 2018 05:49:49 +0000 To: "commits@camel.apache.org" Subject: [camel] branch camel-2.21.x updated: Fixing issue CAMEL-12890 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Message-ID: <154018738922.31837.8812307057556937997@gitbox.apache.org> From: acosentino@apache.org X-Git-Host: gitbox.apache.org X-Git-Repo: camel X-Git-Refname: refs/heads/camel-2.21.x X-Git-Reftype: branch X-Git-Oldrev: 46155f33dc202a63f232664c35731c24f6af1c5e X-Git-Newrev: 3d417b5ed4270e732db9b3eb451684d72d40c52c X-Git-Rev: 3d417b5ed4270e732db9b3eb451684d72d40c52c X-Git-NotificationType: ref_changed_plus_diff X-Git-Multimail-Version: 1.5.dev Auto-Submitted: auto-generated This is an automated email from the ASF dual-hosted git repository. acosentino pushed a commit to branch camel-2.21.x in repository https://gitbox.apache.org/repos/asf/camel.git The following commit(s) were added to refs/heads/camel-2.21.x by this push: new 3d417b5 Fixing issue CAMEL-12890 3d417b5 is described below commit 3d417b5ed4270e732db9b3eb451684d72d40c52c Author: Kalyan Kumar Bandi 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()) {