camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [5/8] git commit: CAMEL-7871 configure ERROR_CORRECTION only if barcode format is QR code
Date Sat, 27 Sep 2014 12:16:32 GMT
CAMEL-7871 configure ERROR_CORRECTION only if barcode format is QR code


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/47725f76
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/47725f76
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/47725f76

Branch: refs/heads/camel-2.14.x
Commit: 47725f76e5e6d6ba6eb25dd52b1a45b59615bd70
Parents: fa62b65
Author: Seiji Sogabe <s.sogabe@gmail.com>
Authored: Sun Sep 28 05:36:48 2014 +0900
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Sat Sep 27 14:15:38 2014 +0200

----------------------------------------------------------------------
 .../dataformat/barcode/BarcodeDataFormat.java   | 14 +++++++-----
 .../barcode/BarcodeDataFormatCamelTest.java     | 23 ++++++++++++++++++++
 .../barcode/barcodeDataformatSpring.xml         |  9 +++++++-
 3 files changed, 40 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/47725f76/components/camel-barcode/src/main/java/org/apache/camel/dataformat/barcode/BarcodeDataFormat.java
----------------------------------------------------------------------
diff --git a/components/camel-barcode/src/main/java/org/apache/camel/dataformat/barcode/BarcodeDataFormat.java
b/components/camel-barcode/src/main/java/org/apache/camel/dataformat/barcode/BarcodeDataFormat.java
index 7639eaf..1dd5f9b 100644
--- a/components/camel-barcode/src/main/java/org/apache/camel/dataformat/barcode/BarcodeDataFormat.java
+++ b/components/camel-barcode/src/main/java/org/apache/camel/dataformat/barcode/BarcodeDataFormat.java
@@ -191,11 +191,15 @@ public class BarcodeDataFormat implements DataFormat {
         this.readerHintMap.clear();
 
         // writer hints
-        this.writerHintMap
-                .put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.H);
-        
-        if (this.params.getFormat().toString()
-                .equals(BarcodeFormat.DATA_MATRIX.toString())) {
+        String format = this.params.getFormat().toString();
+
+        // only for QR code. AZTEC uses zxing's default error correction 33%.
+        if (format.equals(BarcodeFormat.QR_CODE.toString())) {
+            this.writerHintMap
+                  .put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.H);
+        }
+
+        if (format.equals(BarcodeFormat.DATA_MATRIX.toString())) {
             this.writerHintMap
                     .put(EncodeHintType.DATA_MATRIX_SHAPE
                             , SymbolShapeHint.FORCE_SQUARE);

http://git-wip-us.apache.org/repos/asf/camel/blob/47725f76/components/camel-barcode/src/test/java/org/apache/camel/dataformat/barcode/BarcodeDataFormatCamelTest.java
----------------------------------------------------------------------
diff --git a/components/camel-barcode/src/test/java/org/apache/camel/dataformat/barcode/BarcodeDataFormatCamelTest.java
b/components/camel-barcode/src/test/java/org/apache/camel/dataformat/barcode/BarcodeDataFormatCamelTest.java
index b5a5d6b..308cf2d 100644
--- a/components/camel-barcode/src/test/java/org/apache/camel/dataformat/barcode/BarcodeDataFormatCamelTest.java
+++ b/components/camel-barcode/src/test/java/org/apache/camel/dataformat/barcode/BarcodeDataFormatCamelTest.java
@@ -120,6 +120,23 @@ public class BarcodeDataFormatCamelTest extends BarcodeTestBase {
         this.checkImage(image, "JPEG", BarcodeFormat.PDF_417);
     }
 
+    /**
+     * tests barcode (AZTEC).
+     *
+     * @throws Exception 
+     * @see CAMEL-7681
+     */
+    @Test
+    public void testAZTECWidthModifiedSizeAndImageType() throws Exception {
+        out.expectedBodiesReceived(MSG);
+        image.expectedMessageCount(1);
+
+        template.sendBody("direct:code5", MSG);
+
+        assertMockEndpointsSatisfied(60, TimeUnit.SECONDS);
+        this.checkImage(image, 200, 200, "PNG", BarcodeFormat.AZTEC);
+    }
+
     @Override
     protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {
@@ -154,6 +171,12 @@ public class BarcodeDataFormatCamelTest extends BarcodeTestBase {
                         .marshal(code4)
                         .to(FILE_ENDPOINT);
 
+                // AZTEC with modified size and PNG type
+                DataFormat code5 = new BarcodeDataFormat(200, 200, BarcodeImageType.PNG,
BarcodeFormat.AZTEC);
+
+                from("direct:code5")
+                        .marshal(code5)
+                        .to(FILE_ENDPOINT);
 
                 // generic file read --->
                 // 

http://git-wip-us.apache.org/repos/asf/camel/blob/47725f76/components/camel-barcode/src/test/resources/org/apache/camel/dataformat/barcode/barcodeDataformatSpring.xml
----------------------------------------------------------------------
diff --git a/components/camel-barcode/src/test/resources/org/apache/camel/dataformat/barcode/barcodeDataformatSpring.xml
b/components/camel-barcode/src/test/resources/org/apache/camel/dataformat/barcode/barcodeDataformatSpring.xml
index 1c12d9b..2e80909 100644
--- a/components/camel-barcode/src/test/resources/org/apache/camel/dataformat/barcode/barcodeDataformatSpring.xml
+++ b/components/camel-barcode/src/test/resources/org/apache/camel/dataformat/barcode/barcodeDataformatSpring.xml
@@ -31,6 +31,7 @@
       <barcode id="code2" width="200" height="200" />
       <barcode id="code3" imageType="JPG" />
       <barcode id="code4" width="200" height="200" imageType="JPG" barcodeFormat="PDF_417"/>
+      <barcode id="code5" width="200" height="200" imageType="PNG" barcodeFormat="AZTEC"/>
       
     </dataFormats>
 
@@ -57,7 +58,13 @@
       <marshal ref="code4"/>
       <to uri="file:target/out"/>
     </route>
-    
+
+     <route>
+      <from uri="direct:code5"/>
+      <marshal ref="code5"/>
+      <to uri="file:target/out"/>
+    </route>
+
     <route>
       <from uri="file:target/out?noop=true"/>
       <multicast>


Mime
View raw message