Repository: camel Updated Branches: refs/heads/master 43db4d071 -> 9be077802
Fixed test on windows Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/9be07780 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/9be07780 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/9be07780 Branch: refs/heads/master Commit: 9be077802c3f06a0c2521026f6171b2a88d99538 Parents: 43db4d0 Author: Claus Ibsen <[email protected]> Authored: Thu Mar 5 09:15:54 2015 +0100 Committer: Claus Ibsen <[email protected]> Committed: Thu Mar 5 09:15:54 2015 +0100 ---------------------------------------------------------------------- .../barcode/BarcodeDataFormatCamelTest.java | 5 +++++ .../camel/dataformat/barcode/BarcodeTestBase.java | 16 +++++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/9be07780/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 308cf2d..56589f7 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 @@ -63,6 +63,7 @@ public class BarcodeDataFormatCamelTest extends BarcodeTestBase { */ @Test public void testDefaultQRCode() throws Exception { + out.reset(); out.expectedBodiesReceived(MSG); image.expectedMessageCount(1); @@ -79,6 +80,7 @@ public class BarcodeDataFormatCamelTest extends BarcodeTestBase { */ @Test public void testQRCodeWithModifiedSize() throws Exception { + out.reset(); out.expectedBodiesReceived(MSG); image.expectedMessageCount(1); @@ -95,6 +97,7 @@ public class BarcodeDataFormatCamelTest extends BarcodeTestBase { */ @Test public void testQRCodeWithJPEGType() throws Exception { + out.reset(); out.expectedBodiesReceived(MSG); image.expectedMessageCount(1); @@ -111,6 +114,7 @@ public class BarcodeDataFormatCamelTest extends BarcodeTestBase { */ @Test public void testPDF417CodeWidthModifiedSizeAndImageType() throws Exception { + out.reset(); out.expectedBodiesReceived(MSG); image.expectedMessageCount(1); @@ -128,6 +132,7 @@ public class BarcodeDataFormatCamelTest extends BarcodeTestBase { */ @Test public void testAZTECWidthModifiedSizeAndImageType() throws Exception { + out.reset(); out.expectedBodiesReceived(MSG); image.expectedMessageCount(1); http://git-wip-us.apache.org/repos/asf/camel/blob/9be07780/components/camel-barcode/src/test/java/org/apache/camel/dataformat/barcode/BarcodeTestBase.java ---------------------------------------------------------------------- diff --git a/components/camel-barcode/src/test/java/org/apache/camel/dataformat/barcode/BarcodeTestBase.java b/components/camel-barcode/src/test/java/org/apache/camel/dataformat/barcode/BarcodeTestBase.java index f875e8a..0db58ba 100644 --- a/components/camel-barcode/src/test/java/org/apache/camel/dataformat/barcode/BarcodeTestBase.java +++ b/components/camel-barcode/src/test/java/org/apache/camel/dataformat/barcode/BarcodeTestBase.java @@ -18,6 +18,7 @@ package org.apache.camel.dataformat.barcode; import java.awt.image.BufferedImage; import java.io.File; +import java.io.FileInputStream; import java.io.IOException; import javax.imageio.ImageIO; @@ -37,6 +38,8 @@ import org.apache.camel.EndpointInject; import org.apache.camel.Exchange; import org.apache.camel.component.mock.MockEndpoint; import org.apache.camel.test.junit4.CamelTestSupport; +import org.apache.camel.util.FileUtil; +import org.apache.camel.util.IOHelper; public class BarcodeTestBase extends CamelTestSupport { @@ -55,14 +58,18 @@ public class BarcodeTestBase extends CamelTestSupport { protected void checkImage(MockEndpoint mock, int height, int width, String type, BarcodeFormat format) throws IOException { Exchange ex = mock.getReceivedExchanges().get(0); File in = ex.getIn().getBody(File.class); + FileInputStream fis = new FileInputStream(in); // check image - BufferedImage i = ImageIO.read(in); + BufferedImage i = ImageIO.read(fis); + IOHelper.close(fis); + assertTrue(height >= i.getHeight()); assertTrue(width >= i.getWidth()); this.checkType(in, type); this.checkFormat(in, format); - in.delete(); + + FileUtil.deleteFile(in); } protected void checkImage(MockEndpoint mock, String type, BarcodeFormat format) throws IOException { @@ -70,7 +77,8 @@ public class BarcodeTestBase extends CamelTestSupport { File in = ex.getIn().getBody(File.class); this.checkType(in, type); this.checkFormat(in, format); - in.delete(); + + FileUtil.deleteFile(in); } private void checkFormat(File file, BarcodeFormat format) throws IOException { @@ -89,6 +97,8 @@ public class BarcodeTestBase extends CamelTestSupport { private void checkType(File file, String type) throws IOException { ImageInputStream iis = ImageIO.createImageInputStream(file); ImageReader reader = ImageIO.getImageReaders(iis).next(); + IOHelper.close(iis); + String format = reader.getFormatName(); assertEquals(type, format.toUpperCase()); }
