You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2018/10/22 05:46:52 UTC
[camel] branch master updated: Fixing issue CAMEL-12890
This is an automated email from the ASF dual-hosted git repository.
acosentino pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/master by this push:
new 6092c9f Fixing issue CAMEL-12890
6092c9f is described below
commit 6092c9f8a2eb206a4674aa10719ef8c1eb53db92
Author: Kalyan Kumar Bandi <Ka...@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()) {