You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2014/09/27 14:16:35 UTC

[8/8] git commit: CAMEL-7871 configure ERROR_CORRECTION only if barcode format is QR code

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/29d87acb
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/29d87acb
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/29d87acb

Branch: refs/heads/master
Commit: 29d87acb693e2545bb9ec0791880b5a5a168880d
Parents: ecaafc4
Author: Seiji Sogabe <s....@gmail.com>
Authored: Sun Sep 28 05:36:48 2014 +0900
Committer: Seiji Sogabe <s....@gmail.com>
Committed: Sun Sep 28 05:38:38 2014 +0900

----------------------------------------------------------------------
 .../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/29d87acb/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/29d87acb/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/29d87acb/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>