poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cen...@apache.org
Subject svn commit: r1705807 - in /poi/trunk: src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java test-data/spreadsheet/46515.xls
Date Tue, 29 Sep 2015 07:51:48 GMT
Author: centic
Date: Tue Sep 29 07:51:48 2015
New Revision: 1705807

URL: http://svn.apache.org/viewvc?rev=1705807&view=rev
Log:
Add test which shows that bug 46515 is fixed since some time already.

Added:
    poi/trunk/test-data/spreadsheet/46515.xls   (with props)
Modified:
    poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java?rev=1705807&r1=1705806&r2=1705807&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java Tue Sep 29 07:51:48
2015
@@ -24,6 +24,7 @@ import static org.junit.Assert.assertNul
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
+import java.awt.image.BufferedImage;
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.File;
@@ -31,6 +32,7 @@ import java.io.FileInputStream;
 import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.InputStream;
+import java.net.URL;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Calendar;
@@ -39,6 +41,8 @@ import java.util.List;
 import java.util.Locale;
 import java.util.TimeZone;
 
+import javax.imageio.ImageIO;
+
 import org.apache.poi.EncryptedDocumentException;
 import org.apache.poi.hssf.HSSFITestDataProvider;
 import org.apache.poi.hssf.HSSFTestDataSamples;
@@ -75,6 +79,7 @@ import org.apache.poi.ss.usermodel.Workb
 import org.apache.poi.ss.util.CellRangeAddress;
 import org.apache.poi.util.LocaleUtil;
 import org.junit.After;
+import org.junit.Assume;
 import org.junit.Ignore;
 import org.junit.Test;
 
@@ -2930,4 +2935,43 @@ public final class TestBugs extends Base
         
         wb.close();
     }
+    
+    @Test
+    public void test46515() throws IOException {
+        Workbook wb = HSSFTestDataSamples.openSampleWorkbook("46515.xls");
+
+        // Get structure from webservice
+        String urlString = "http://poi.apache.org/resources/images/project-logo.jpg";
+        URL structURL = new URL(urlString);
+        BufferedImage bimage;
+        try {
+            bimage = ImageIO.read(structURL);
+        } catch (IOException e) {
+            Assume.assumeNoException("Downloading a jpg from poi.apache.org should work",
e);
+            return;
+        }
+
+        // Convert BufferedImage to byte[]
+        ByteArrayOutputStream imageBAOS = new ByteArrayOutputStream();
+        ImageIO.write(bimage, "jpeg", imageBAOS);
+        imageBAOS.flush();
+        byte[]imageBytes = imageBAOS.toByteArray();
+        imageBAOS.close();
+
+        // Pop structure into Structure HSSFSheet
+        int pict = wb.addPicture(imageBytes, HSSFWorkbook.PICTURE_TYPE_JPEG);
+        Sheet sheet = wb.getSheet("Structure");
+        assertNotNull("Did not find sheet", sheet);
+        HSSFPatriarch patriarch = (HSSFPatriarch) sheet.createDrawingPatriarch();
+        HSSFClientAnchor anchor = new HSSFClientAnchor(0, 0, 0, 0, (short) 1, 1, (short)
10, 22);
+        anchor.setAnchorType(2);
+        patriarch.createPicture(anchor, pict);
+
+        // Write out destination file
+//        FileOutputStream fileOut = new FileOutputStream("/tmp/46515.xls");
+//        wb.write(fileOut);
+//        fileOut.close();
+
+        wb.close();
+    }
 }

Added: poi/trunk/test-data/spreadsheet/46515.xls
URL: http://svn.apache.org/viewvc/poi/trunk/test-data/spreadsheet/46515.xls?rev=1705807&view=auto
==============================================================================
Binary file - no diff available.

Propchange: poi/trunk/test-data/spreadsheet/46515.xls
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org


Mime
View raw message