}
}
- @SuppressWarnings("resource")
public InputStream getDataStream(DirectoryNode dir) throws IOException, GeneralSecurityException {
DocumentInputStream dis = dir.createDocumentInputStream(DEFAULT_POIFS_ENTRY);
_length = dis.readLong();
doc.write(baos);
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
+ ((HSSFWorkbook)doc).close();
+
doc = new HSSFWorkbook(bais);
assertNotNull(doc.getSummaryInformation());
assertNotNull(doc.getDocumentSummaryInformation());
+
+ ((HSSFWorkbook)doc).close();
}
@Test
// Write out and back in again, no change
ByteArrayOutputStream baos = new ByteArrayOutputStream();
doc.write(baos);
+
+ ((HSSFWorkbook)doc).close();
+
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
doc = new HSSFWorkbook(bais);
// Save and re-load
baos = new ByteArrayOutputStream();
doc.write(baos);
+
+ ((HSSFWorkbook)doc).close();
+
bais = new ByteArrayInputStream(baos.toByteArray());
doc = new HSSFWorkbook(bais);
assertNotNull(doc.getDocumentSummaryInformation());
assertEquals("POI Testing", doc.getSummaryInformation().getAuthor());
assertEquals("ASF", doc.getDocumentSummaryInformation().getCompany());
+
+ ((HSSFWorkbook)doc).close();
}
}
}
private static void writeLong(byte[] bb, int i, long val) {
- String oldVal = interpretLong(bb, i);
+ /*String oldVal =*/ interpretLong(bb, i);
bb[i+7] = (byte) (val >> 56);
bb[i+6] = (byte) (val >> 48);
bb[i+5] = (byte) (val >> 40);
package org.apache.poi.ss.util;
-import static org.junit.Assert.fail;
+import static org.junit.Assert.assertNotEquals;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
-//TODO: replace junit3 with junit4 code
-import junit.framework.TestCase; //junit3
-import static org.junit.Assert.assertNotEquals; //junit4
-
import org.apache.poi.hssf.record.TestcaseRecordInputStream;
import org.apache.poi.util.LittleEndianOutputStream;
+//TODO: replace junit3 with junit4 code
+import junit.framework.TestCase; //junit3
+
public final class TestCellRangeAddress extends TestCase {
byte[] data = new byte[] { (byte) 0x02, (byte) 0x00, (byte) 0x04,
(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x03, (byte) 0x00, };
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintStream;
-import java.lang.reflect.Constructor;
import org.junit.Test;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
+import java.io.IOException;
import junit.framework.AssertionFailedError;
import junit.framework.TestCase;
*/
public final class TestLittleEndianStreams extends TestCase {
- public void testRead() {
+ public void testRead() throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
LittleEndianOutput leo = new LittleEndianOutputStream(baos);
leo.writeInt(12345678);
leo.writeByte(200);
leo.writeLong(1234567890123456789L);
leo.writeDouble(123.456);
+ ((LittleEndianOutputStream)leo).close();
LittleEndianInput lei = new LittleEndianInputStream(new ByteArrayInputStream(baos.toByteArray()));
assertEquals(200, lei.readUByte());
assertEquals(1234567890123456789L, lei.readLong());
assertEquals(123.456, lei.readDouble(), 0.0);
+ ((LittleEndianInputStream)lei).close();
}
/**