Return-Path: X-Original-To: apmail-camel-commits-archive@www.apache.org Delivered-To: apmail-camel-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id BE31F1081C for ; Thu, 16 Jan 2014 09:36:26 +0000 (UTC) Received: (qmail 28223 invoked by uid 500); 16 Jan 2014 09:36:23 -0000 Delivered-To: apmail-camel-commits-archive@camel.apache.org Received: (qmail 28089 invoked by uid 500); 16 Jan 2014 09:36:21 -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 28058 invoked by uid 99); 16 Jan 2014 09:36:20 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 16 Jan 2014 09:36:20 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 4471B83525B; Thu, 16 Jan 2014 09:36:20 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: davsclaus@apache.org To: commits@camel.apache.org Date: Thu, 16 Jan 2014 09:36:21 -0000 Message-Id: <901d5aa14c234d4f95122c9b081a65b4@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [2/4] git commit: add printer tests with page orientation add printer tests with page orientation Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/7be880b7 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/7be880b7 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/7be880b7 Branch: refs/heads/master Commit: 7be880b753d9028c6d2be5c08cfe33073f9cc280 Parents: cdf0d0f Author: Carsten Erker Authored: Thu Jan 16 10:15:45 2014 +0100 Committer: Carsten Erker Committed: Thu Jan 16 10:15:45 2014 +0100 ---------------------------------------------------------------------- .../component/printer/PrinterPrintTest.java | 52 +++++++++++++------- 1 file changed, 35 insertions(+), 17 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/7be880b7/components/camel-printer/src/test/java/org/apache/camel/component/printer/PrinterPrintTest.java ---------------------------------------------------------------------- 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 2a13670..794e917 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 @@ -30,6 +30,7 @@ import javax.print.attribute.PrintRequestAttributeSet; import javax.print.attribute.standard.Media; import javax.print.attribute.standard.MediaSizeName; import javax.print.attribute.standard.MediaTray; +import javax.print.attribute.standard.OrientationRequested; import javax.print.attribute.standard.Sides; import org.apache.camel.Endpoint; @@ -181,6 +182,23 @@ public class PrinterPrintTest extends CamelTestSupport { sendJPEG(); } + @Test + @Ignore + public void testSendingJPEGToPrinterWithLandscapePageOrientation() throws Exception { + if (isAwtHeadless()) { + return; + } + context.addRoutes(new RouteBuilder() { + public void configure() { + from("direct:start").to("lpr://localhost/default?flavor=DocFlavor.INPUT_STREAM" + + "&mimeType=JPEG&sendToPrinter=false&orientation=landscape"); + } + }); + context.start(); + + sendJPEG(); + } + /** * Test for resolution of bug CAMEL-3446. * Not specifying mediaSize nor sides attributes make it use @@ -199,14 +217,14 @@ public class PrinterPrintTest extends CamelTestSupport { }); context.start(); } - + @Test public void moreThanOneLprEndpoint() throws Exception { if (isAwtHeadless()) { return; } - + int numberOfPrintservicesBefore = PrintServiceLookup.lookupPrintServices(null, null).length; // setup javax.print @@ -224,7 +242,7 @@ public class PrinterPrintTest extends CamelTestSupport { DocPrintJob job1 = mock(DocPrintJob.class); when(ps1.createPrintJob()).thenReturn(job1); - + context.addRoutes(new RouteBuilder() { public void configure() { @@ -258,7 +276,7 @@ public class PrinterPrintTest extends CamelTestSupport { verify(job1, times(1)).print(any(Doc.class), any(PrintRequestAttributeSet.class)); } - + @Test public void printerNameTest() throws Exception { if (isAwtHeadless()) { @@ -272,7 +290,7 @@ public class PrinterPrintTest extends CamelTestSupport { 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() { @@ -280,14 +298,14 @@ public class PrinterPrintTest extends CamelTestSupport { } }); 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()) { @@ -311,10 +329,11 @@ public class PrinterPrintTest extends CamelTestSupport { PrinterEndpoint endpoint = new PrinterEndpoint(); PrinterConfiguration configuration = new PrinterConfiguration(); configuration.setHostname("localhost"); - configuration.setPort(631); - configuration.setPrintername("DefaultPrinter"); - configuration.setMediaSizeName(MediaSizeName.ISO_A4); - configuration.setInternalSides(Sides.ONE_SIDED); + configuration.setPort( 631 ); + configuration.setPrintername( "DefaultPrinter" ); + configuration.setMediaSizeName( MediaSizeName.ISO_A4 ); + configuration.setInternalSides( Sides.ONE_SIDED ); + configuration.setInternalOrientation( OrientationRequested.PORTRAIT ); configuration.setMediaTray("middle"); PrinterProducer producer = new PrinterProducer(endpoint, configuration); @@ -328,7 +347,7 @@ public class PrinterPrintTest extends CamelTestSupport { MediaTray mediaTray = (MediaTray) attribute; assertEquals("middle", mediaTray.toString()); } - + @Test public void printsWithLandscapeOrientation() throws Exception { PrinterEndpoint endpoint = new PrinterEndpoint(); @@ -338,19 +357,18 @@ public class PrinterPrintTest extends CamelTestSupport { configuration.setPrintername("DefaultPrinter"); configuration.setMediaSizeName(MediaSizeName.ISO_A4); configuration.setInternalSides(Sides.ONE_SIDED); + configuration.setInternalOrientation( OrientationRequested.REVERSE_LANDSCAPE ); configuration.setMediaTray("middle"); - configuration.setOrientation("landscape"); + configuration.setSendToPrinter(false); PrinterProducer producer = new PrinterProducer(endpoint, configuration); producer.start(); PrinterOperations printerOperations = producer.getPrinterOperations(); PrintRequestAttributeSet attributeSet = printerOperations.getPrintRequestAttributeSet(); - Attribute attribute = attributeSet.get(javax.print.attribute.standard.Media.class); + Attribute attribute = attributeSet.get(OrientationRequested.class); assertNotNull(attribute); - assertTrue(attribute instanceof MediaTray); - MediaTray mediaTray = (MediaTray) attribute; - assertEquals("middle", mediaTray.toString()); + assertEquals("reverse-landscape", attribute.toString()); } protected void setupJavaPrint() {