]> source.dussan.org Git - poi.git/commitdiff
added disabled junit for bug 44916
authorJosh Micich <josh@apache.org>
Thu, 1 May 2008 15:46:21 +0000 (15:46 +0000)
committerJosh Micich <josh@apache.org>
Thu, 1 May 2008 15:46:21 +0000 (15:46 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@652561 13f79535-47bb-0310-9956-ffa450edef68

src/testcases/org/apache/poi/hssf/HSSFTestDataSamples.java
src/testcases/org/apache/poi/hssf/usermodel/AllUserModelTests.java
src/testcases/org/apache/poi/hssf/usermodel/TestHSSFPatriarch.java [new file with mode: 0644]
src/testcases/org/apache/poi/hssf/usermodel/TestHSSFPicture.java

index 703551f88e7e0e3ab2ab07d7960eabab640e5cbe..0e64637f97280aa3897ebfd894e5eff63fdd8cb0 100644 (file)
@@ -172,4 +172,28 @@ public final class HSSFTestDataSamples {
                        throw new RuntimeException(e);\r
                }\r
        }\r
+\r
+       /**\r
+        * @return byte array of sample file content from file found in standard hssf test data dir \r
+        */\r
+       public static byte[] getTestDataFileContent(String fileName) {\r
+               ByteArrayOutputStream bos = new ByteArrayOutputStream();\r
+\r
+               try {\r
+                       InputStream fis = HSSFTestDataSamples.openSampleFileStream(fileName);\r
+\r
+                       byte[] buf = new byte[512];\r
+                       while (true) {\r
+                               int bytesRead = fis.read(buf);\r
+                               if (bytesRead < 1) {\r
+                                       break;\r
+                               }\r
+                               bos.write(buf, 0, bytesRead);\r
+                       }\r
+                       fis.close();\r
+               } catch (IOException e) {\r
+                       throw new RuntimeException(e);\r
+               }\r
+               return bos.toByteArray();\r
+       }\r
 }\r
index 6d6b053a63d8f1e23f9c5d1d9abe4392344fd543..47c2c481ea9dd0d40a0ebad7128cd15a0008170a 100755 (executable)
@@ -14,7 +14,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-       
+
 package org.apache.poi.hssf.usermodel;
 
 import junit.framework.Test;
@@ -46,6 +46,7 @@ public class AllUserModelTests {
                result.addTestSuite(TestHSSFHeaderFooter.class);
                result.addTestSuite(TestHSSFHyperlink.class);
                result.addTestSuite(TestHSSFPalette.class);
+               result.addTestSuite(TestHSSFPatriarch.class);
                result.addTestSuite(TestHSSFPicture.class);
                result.addTestSuite(TestHSSFPictureData.class);
                result.addTestSuite(TestHSSFRichTextString.class);
diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFPatriarch.java b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFPatriarch.java
new file mode 100644 (file)
index 0000000..f0d00dc
--- /dev/null
@@ -0,0 +1,71 @@
+/* ====================================================================\r
+   Licensed to the Apache Software Foundation (ASF) under one or more\r
+   contributor license agreements.  See the NOTICE file distributed with\r
+   this work for additional information regarding copyright ownership.\r
+   The ASF licenses this file to You under the Apache License, Version 2.0\r
+   (the "License"); you may not use this file except in compliance with\r
+   the License.  You may obtain a copy of the License at\r
+\r
+       http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+   Unless required by applicable law or agreed to in writing, software\r
+   distributed under the License is distributed on an "AS IS" BASIS,\r
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+   See the License for the specific language governing permissions and\r
+   limitations under the License.\r
+==================================================================== */\r
+\r
+package org.apache.poi.hssf.usermodel;\r
+\r
+import org.apache.poi.hssf.HSSFTestDataSamples;\r
+\r
+import junit.framework.AssertionFailedError;\r
+import junit.framework.TestCase;\r
+\r
+/**\r
+ * @author Josh Micich\r
+ */\r
+public final class TestHSSFPatriarch extends TestCase {\r
+\r
+       public void testBasic() {\r
+\r
+               HSSFWorkbook wb = new HSSFWorkbook();\r
+               HSSFSheet sheet = wb.createSheet();\r
+\r
+               HSSFPatriarch patr = sheet.createDrawingPatriarch();\r
+\r
+               assertNotNull(patr);\r
+\r
+               // assert something more interesting\r
+       }\r
+\r
+       // TODO - fix bug 44916 (1-May-2008)\r
+       public void DISABLED_test44916() {\r
+\r
+               HSSFWorkbook wb = new HSSFWorkbook();\r
+               HSSFSheet sheet = wb.createSheet();\r
+\r
+               // 1. Create drawing patriarch\r
+               HSSFPatriarch patr = sheet.createDrawingPatriarch();\r
+\r
+               // 2. Try to re-get the patriarch\r
+               HSSFPatriarch existingPatr;\r
+               try {\r
+                       existingPatr = sheet.getDrawingPatriarch();\r
+               } catch (NullPointerException e) {\r
+                       throw new AssertionFailedError("Identified bug 44916");\r
+               }\r
+\r
+               // 3. Use patriarch\r
+               HSSFClientAnchor anchor = new HSSFClientAnchor(0, 0, 600, 245, (short) 1, 1, (short) 1, 2);\r
+               anchor.setAnchorType(3);\r
+               byte[] pictureData = HSSFTestDataSamples.getTestDataFileContent("logoKarmokar4.png");\r
+               int idx1 = wb.addPicture(pictureData, HSSFWorkbook.PICTURE_TYPE_PNG);\r
+               patr.createPicture(anchor, idx1);\r
+\r
+               // 4. Try to re-use patriarch later\r
+               existingPatr = sheet.getDrawingPatriarch();\r
+               assertNotNull(existingPatr);\r
+       }\r
+\r
+}\r
index 539f64f36f1af4c3a92113ae331be6124562ed01..87578ae01bb628be0e9ccc0c4ba33fc10bac9970 100644 (file)
 */\r
 package org.apache.poi.hssf.usermodel;\r
 \r
-import java.io.ByteArrayOutputStream;\r
-import java.io.IOException;\r
-import java.io.InputStream;\r
-\r
 import junit.framework.TestCase;\r
 \r
 import org.apache.poi.hssf.HSSFTestDataSamples;\r
@@ -36,7 +32,7 @@ public final class TestHSSFPicture extends TestCase{
         HSSFSheet sh1 = wb.createSheet();\r
         HSSFPatriarch p1 = sh1.createDrawingPatriarch();\r
 \r
-        byte[] pictureData = getTestDataFileContent("logoKarmokar4.png");\r
+        byte[] pictureData = HSSFTestDataSamples.getTestDataFileContent("logoKarmokar4.png");\r
         int idx1 = wb.addPicture( pictureData, HSSFWorkbook.PICTURE_TYPE_PNG );\r
         HSSFPicture picture1 = p1.createPicture(new HSSFClientAnchor(), idx1);\r
         HSSFClientAnchor anchor1 = picture1.getPreferredSize();\r
@@ -51,28 +47,4 @@ public final class TestHSSFPicture extends TestCase{
         assertEquals(848, anchor1.getDx2());\r
         assertEquals(240, anchor1.getDy2());\r
     }\r
-\r
-    /**\r
-     * Copied from org.apache.poi.hssf.usermodel.examples.OfficeDrawing\r
-     */\r
-     private static byte[] getTestDataFileContent(String fileName) {\r
-        ByteArrayOutputStream bos = new ByteArrayOutputStream();\r
-\r
-        try {\r
-            InputStream fis = HSSFTestDataSamples.openSampleFileStream(fileName);\r
-\r
-            byte[] buf = new byte[512];\r
-            while(true) {\r
-                int bytesRead = fis.read(buf);\r
-                if(bytesRead < 1) {\r
-                    break;\r
-                }\r
-                bos.write(buf, 0, bytesRead);\r
-            }\r
-            fis.close();\r
-        } catch (IOException e) {\r
-            throw new RuntimeException(e);\r
-        }\r
-        return bos.toByteArray();\r
-     }\r
 }\r