From: Josh Micich Date: Thu, 1 May 2008 15:46:21 +0000 (+0000) Subject: added disabled junit for bug 44916 X-Git-Tag: REL_3_2_FINAL~374 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=f966107d0edabab57bf8e8e4fb41fe2945b8d0db;p=poi.git added disabled junit for bug 44916 git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@652561 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/testcases/org/apache/poi/hssf/HSSFTestDataSamples.java b/src/testcases/org/apache/poi/hssf/HSSFTestDataSamples.java index 703551f88e..0e64637f97 100644 --- a/src/testcases/org/apache/poi/hssf/HSSFTestDataSamples.java +++ b/src/testcases/org/apache/poi/hssf/HSSFTestDataSamples.java @@ -172,4 +172,28 @@ public final class HSSFTestDataSamples { throw new RuntimeException(e); } } + + /** + * @return byte array of sample file content from file found in standard hssf test data dir + */ + public static byte[] getTestDataFileContent(String fileName) { + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + + try { + InputStream fis = HSSFTestDataSamples.openSampleFileStream(fileName); + + byte[] buf = new byte[512]; + while (true) { + int bytesRead = fis.read(buf); + if (bytesRead < 1) { + break; + } + bos.write(buf, 0, bytesRead); + } + fis.close(); + } catch (IOException e) { + throw new RuntimeException(e); + } + return bos.toByteArray(); + } } diff --git a/src/testcases/org/apache/poi/hssf/usermodel/AllUserModelTests.java b/src/testcases/org/apache/poi/hssf/usermodel/AllUserModelTests.java index 6d6b053a63..47c2c481ea 100755 --- a/src/testcases/org/apache/poi/hssf/usermodel/AllUserModelTests.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/AllUserModelTests.java @@ -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 index 0000000000..f0d00dc670 --- /dev/null +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFPatriarch.java @@ -0,0 +1,71 @@ +/* ==================================================================== + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +==================================================================== */ + +package org.apache.poi.hssf.usermodel; + +import org.apache.poi.hssf.HSSFTestDataSamples; + +import junit.framework.AssertionFailedError; +import junit.framework.TestCase; + +/** + * @author Josh Micich + */ +public final class TestHSSFPatriarch extends TestCase { + + public void testBasic() { + + HSSFWorkbook wb = new HSSFWorkbook(); + HSSFSheet sheet = wb.createSheet(); + + HSSFPatriarch patr = sheet.createDrawingPatriarch(); + + assertNotNull(patr); + + // assert something more interesting + } + + // TODO - fix bug 44916 (1-May-2008) + public void DISABLED_test44916() { + + HSSFWorkbook wb = new HSSFWorkbook(); + HSSFSheet sheet = wb.createSheet(); + + // 1. Create drawing patriarch + HSSFPatriarch patr = sheet.createDrawingPatriarch(); + + // 2. Try to re-get the patriarch + HSSFPatriarch existingPatr; + try { + existingPatr = sheet.getDrawingPatriarch(); + } catch (NullPointerException e) { + throw new AssertionFailedError("Identified bug 44916"); + } + + // 3. Use patriarch + HSSFClientAnchor anchor = new HSSFClientAnchor(0, 0, 600, 245, (short) 1, 1, (short) 1, 2); + anchor.setAnchorType(3); + byte[] pictureData = HSSFTestDataSamples.getTestDataFileContent("logoKarmokar4.png"); + int idx1 = wb.addPicture(pictureData, HSSFWorkbook.PICTURE_TYPE_PNG); + patr.createPicture(anchor, idx1); + + // 4. Try to re-use patriarch later + existingPatr = sheet.getDrawingPatriarch(); + assertNotNull(existingPatr); + } + +} diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFPicture.java b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFPicture.java index 539f64f36f..87578ae01b 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFPicture.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFPicture.java @@ -16,10 +16,6 @@ */ package org.apache.poi.hssf.usermodel; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; - import junit.framework.TestCase; import org.apache.poi.hssf.HSSFTestDataSamples; @@ -36,7 +32,7 @@ public final class TestHSSFPicture extends TestCase{ HSSFSheet sh1 = wb.createSheet(); HSSFPatriarch p1 = sh1.createDrawingPatriarch(); - byte[] pictureData = getTestDataFileContent("logoKarmokar4.png"); + byte[] pictureData = HSSFTestDataSamples.getTestDataFileContent("logoKarmokar4.png"); int idx1 = wb.addPicture( pictureData, HSSFWorkbook.PICTURE_TYPE_PNG ); HSSFPicture picture1 = p1.createPicture(new HSSFClientAnchor(), idx1); HSSFClientAnchor anchor1 = picture1.getPreferredSize(); @@ -51,28 +47,4 @@ public final class TestHSSFPicture extends TestCase{ assertEquals(848, anchor1.getDx2()); assertEquals(240, anchor1.getDy2()); } - - /** - * Copied from org.apache.poi.hssf.usermodel.examples.OfficeDrawing - */ - private static byte[] getTestDataFileContent(String fileName) { - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - - try { - InputStream fis = HSSFTestDataSamples.openSampleFileStream(fileName); - - byte[] buf = new byte[512]; - while(true) { - int bytesRead = fis.read(buf); - if(bytesRead < 1) { - break; - } - bos.write(buf, 0, bytesRead); - } - fis.close(); - } catch (IOException e) { - throw new RuntimeException(e); - } - return bos.toByteArray(); - } }