import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
+import java.io.File;
import java.io.IOException;
import java.util.List;
import junit.framework.TestCase;
import org.apache.poi.hssf.HSSFTestDataSamples;
+import org.junit.BeforeClass;
/**
* Test <code>HSSFPictureData</code>.
* @author Trejkaz (trejkaz at trypticon dot org)
*/
public final class TestHSSFPictureData extends TestCase{
-
+ @BeforeClass
+ public static void setUpClass() {
+ // ensure that temp-dir exists because ImageIO requires it
+ String tmpDirProperty = System.getProperty("java.io.tmpdir");
+ if(tmpDirProperty != null) {
+ final File tmpDir = new File(tmpDirProperty);
+ if(!tmpDir.exists()) {
+ if(!tmpDir.mkdirs()) {
+ throw new IllegalStateException("Could not create temporary directory " + tmpDirProperty + ", full path " + tmpDir.getAbsolutePath());
+ }
+ }
+ }
+ }
public void testPictures() throws IOException {
HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("SimpleWithImages.xls");
assertEquals(300, png.getHeight());
assertEquals(HSSFWorkbook.PICTURE_TYPE_PNG, pict.getFormat());
assertEquals("image/png", pict.getMimeType());
- } else {
- //TODO: test code for PICT, WMF and EMF
+ /*} else {
+ //TODO: test code for PICT, WMF and EMF*/
}
}
}
assertEquals("image/png", pict.getMimeType());
}
- public void testNotNullPictures() throws IOException {
+ public void testNotNullPictures() {
HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("SheetWithDrawing.xls");
assertNotNull(pict);
}
}
-
}