You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by jo...@apache.org on 2008/05/01 17:46:22 UTC

svn commit: r652561 - in /poi/trunk/src/testcases/org/apache/poi/hssf: HSSFTestDataSamples.java usermodel/AllUserModelTests.java usermodel/TestHSSFPatriarch.java usermodel/TestHSSFPicture.java

Author: josh
Date: Thu May  1 08:46:21 2008
New Revision: 652561

URL: http://svn.apache.org/viewvc?rev=652561&view=rev
Log:
added disabled junit for bug 44916

Added:
    poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFPatriarch.java
Modified:
    poi/trunk/src/testcases/org/apache/poi/hssf/HSSFTestDataSamples.java
    poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/AllUserModelTests.java
    poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFPicture.java

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/HSSFTestDataSamples.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/HSSFTestDataSamples.java?rev=652561&r1=652560&r2=652561&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/HSSFTestDataSamples.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/HSSFTestDataSamples.java Thu May  1 08:46:21 2008
@@ -172,4 +172,28 @@
 			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();
+	}
 }

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/AllUserModelTests.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/AllUserModelTests.java?rev=652561&r1=652560&r2=652561&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/AllUserModelTests.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/AllUserModelTests.java Thu May  1 08:46:21 2008
@@ -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 @@
 		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);

Added: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFPatriarch.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFPatriarch.java?rev=652561&view=auto
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFPatriarch.java (added)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFPatriarch.java Thu May  1 08:46:21 2008
@@ -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);
+	}
+
+}

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFPicture.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFPicture.java?rev=652561&r1=652560&r2=652561&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFPicture.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFPicture.java Thu May  1 08:46:21 2008
@@ -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 @@
         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 @@
         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();
-     }
 }



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