added disabled junit for bug 44916
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@652561 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
63a52cf21d
commit
45095a5d06
@ -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();
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user