camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject svn commit: r1388366 - in /camel/trunk/components/camel-printer/src: main/java/org/apache/camel/component/printer/PrinterProducer.java test/java/org/apache/camel/component/printer/PrinterPrintTest.java
Date Fri, 21 Sep 2012 08:23:10 GMT
Author: ningjiang
Date: Fri Sep 21 08:23:09 2012
New Revision: 1388366

URL: http://svn.apache.org/viewvc?rev=1388366&view=rev
Log:
CAMEL-5630 lookup the printer name by using endWith

Modified:
    camel/trunk/components/camel-printer/src/main/java/org/apache/camel/component/printer/PrinterProducer.java
    camel/trunk/components/camel-printer/src/test/java/org/apache/camel/component/printer/PrinterPrintTest.java

Modified: camel/trunk/components/camel-printer/src/main/java/org/apache/camel/component/printer/PrinterProducer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-printer/src/main/java/org/apache/camel/component/printer/PrinterProducer.java?rev=1388366&r1=1388365&r2=1388366&view=diff
==============================================================================
--- camel/trunk/components/camel-printer/src/main/java/org/apache/camel/component/printer/PrinterProducer.java
(original)
+++ camel/trunk/components/camel-printer/src/main/java/org/apache/camel/component/printer/PrinterProducer.java
Fri Sep 21 08:23:09 2012
@@ -139,7 +139,7 @@ public class PrinterProducer extends Def
     private int findPrinter(PrintService[] services, String printer) {
         int position = -1;
         for (int i = 0; i < services.length; i++) {
-            if (printer.equalsIgnoreCase(services[i].getName())) {
+            if (services[i].getName().toLowerCase().endsWith(printer.toLowerCase())) {
                 position = i;
                 break;
             }

Modified: 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=1388366&r1=1388365&r2=1388366&view=diff
==============================================================================
--- camel/trunk/components/camel-printer/src/test/java/org/apache/camel/component/printer/PrinterPrintTest.java
(original)
+++ camel/trunk/components/camel-printer/src/test/java/org/apache/camel/component/printer/PrinterPrintTest.java
Fri Sep 21 08:23:09 2012
@@ -260,6 +260,35 @@ public class PrinterPrintTest extends Ca
     }
     
     @Test
+    public void printerNameTest() throws Exception {
+        if (isAwtHeadless()) {
+            return;
+        }
+        // setup javax.print 
+        PrintService ps1 = mock(PrintService.class);
+        when(ps1.getName()).thenReturn("MyPrinter\\\\remote\\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()) {
             return;



Mime
View raw message