You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ce...@apache.org on 2014/06/11 22:36:31 UTC
svn commit: r1602008 [2/2] - in /poi/trunk: ./ src/java/org/apache/poi/hpsf/
src/ooxml/java/org/apache/poi/xssf/usermodel/
src/ooxml/testcases/org/apache/poi/xwpf/
src/scratchpad/src/org/apache/poi/hmef/
src/scratchpad/testcases/org/apache/poi/hmef/ sr...
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hmef/attribute/TestMAPIAttributes.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hmef/attribute/TestMAPIAttributes.java?rev=1602008&r1=1602007&r2=1602008&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hmef/attribute/TestMAPIAttributes.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hmef/attribute/TestMAPIAttributes.java Wed Jun 11 20:36:30 2014
@@ -18,6 +18,7 @@
package org.apache.poi.hmef.attribute;
import java.io.ByteArrayInputStream;
+import java.io.InputStream;
import java.text.DateFormat;
import java.util.Locale;
import java.util.TimeZone;
@@ -32,17 +33,25 @@ import org.apache.poi.util.LittleEndian;
public final class TestMAPIAttributes extends TestCase {
private static final POIDataSamples _samples = POIDataSamples.getHMEFInstance();
private HMEFMessage quick;
+ private InputStream stream;
@Override
protected void setUp() throws Exception {
super.setUp();
- quick = new HMEFMessage(
- _samples.openResourceAsStream("quick-winmail.dat")
- );
+ stream = _samples.openResourceAsStream("quick-winmail.dat");
+ quick = new HMEFMessage(stream);
}
-
- /**
+
+
+ protected void tearDown() throws Exception {
+ stream.close();
+
+ super.tearDown();
+ }
+
+
+/**
* Test counts
*/
public void testCounts() throws Exception {
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hpbf/extractor/TestPublisherTextExtractor.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hpbf/extractor/TestPublisherTextExtractor.java?rev=1602008&r1=1602007&r2=1602008&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hpbf/extractor/TestPublisherTextExtractor.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hpbf/extractor/TestPublisherTextExtractor.java Wed Jun 11 20:36:30 2014
@@ -91,8 +91,9 @@ public final class TestPublisherTextExtr
assertEquals( SAMPLE_TEXT, ext.getText() );
// And with NPOIFS
- HPBFDocument docNPOIFS = new HPBFDocument(
- new NPOIFSFileSystem(sample)
+ NPOIFSFileSystem fs = new NPOIFSFileSystem(sample);
+ HPBFDocument docNPOIFS = new HPBFDocument(
+ fs
);
ext = new PublisherTextExtractor(docNPOIFS);
assertEquals( SAMPLE_TEXT, ext.getText() );
@@ -103,6 +104,7 @@ public final class TestPublisherTextExtr
new FileInputStream(simple)
);
assertEquals( SIMPLE_TEXT, ext.getText() );
+ fs.close();
}
/**
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/extractor/TestExtractor.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/extractor/TestExtractor.java?rev=1602008&r1=1602007&r2=1602008&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/extractor/TestExtractor.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/extractor/TestExtractor.java Wed Jun 11 20:36:30 2014
@@ -349,7 +349,8 @@ public final class TestExtractor extends
// Open the two filesystems
DirectoryNode[] files = new DirectoryNode[2];
files[0] = (new POIFSFileSystem(slTests.openResourceAsStream("basic_test_ppt_file.ppt"))).getRoot();
- files[1] = (new NPOIFSFileSystem(slTests.getFile("basic_test_ppt_file.ppt"))).getRoot();
+ NPOIFSFileSystem npoifsFileSystem = new NPOIFSFileSystem(slTests.getFile("basic_test_ppt_file.ppt"));
+ files[1] = npoifsFileSystem.getRoot();
// Open directly
for(DirectoryNode dir : files) {
@@ -363,6 +364,8 @@ public final class TestExtractor extends
PowerPointExtractor extractor = new PowerPointExtractor(slideshow);
assertEquals(expectText, extractor.getText());
}
+
+ npoifsFileSystem.close();
}
public void testTable() throws Exception{
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/extractor/TestWordExtractor.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/extractor/TestWordExtractor.java?rev=1602008&r1=1602007&r2=1602008&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/extractor/TestWordExtractor.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/extractor/TestWordExtractor.java Wed Jun 11 20:36:30 2014
@@ -342,7 +342,8 @@ public final class TestWordExtractor ext
// Open the two filesystems
DirectoryNode[] files = new DirectoryNode[2];
files[0] = (new POIFSFileSystem(docTests.openResourceAsStream("test2.doc"))).getRoot();
- files[1] = (new NPOIFSFileSystem(docTests.getFile("test2.doc"))).getRoot();
+ NPOIFSFileSystem npoifsFileSystem = new NPOIFSFileSystem(docTests.getFile("test2.doc"));
+ files[1] = npoifsFileSystem.getRoot();
// Open directly
for(DirectoryNode dir : files) {
@@ -356,6 +357,8 @@ public final class TestWordExtractor ext
WordExtractor extractor = new WordExtractor(doc);
assertEquals(p_text1_block, extractor.getText());
}
+
+ npoifsFileSystem.close();
}
/**
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestFileInformationBlock.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestFileInformationBlock.java?rev=1602008&r1=1602007&r2=1602008&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestFileInformationBlock.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestFileInformationBlock.java Wed Jun 11 20:36:30 2014
@@ -21,53 +21,51 @@ import java.lang.reflect.AccessibleObjec
import java.lang.reflect.Field;
import junit.framework.TestCase;
+
import org.apache.poi.hwpf.HWPFDocFixture;
-public final class TestFileInformationBlock
- extends TestCase
-{
- private FileInformationBlock _fileInformationBlock = null;
- private HWPFDocFixture _hWPFDocFixture;
-
- public void testReadWrite()
- throws Exception
- {
- int size = _fileInformationBlock.getSize();
- byte[] buf = new byte[size];
-
- _fileInformationBlock.getFibBase().serialize(buf, 0);
-
- FileInformationBlock newFileInformationBlock =
- new FileInformationBlock(buf);
-
- Field[] fields = FileInformationBlock.class.getSuperclass().getDeclaredFields();
- AccessibleObject.setAccessible(fields, true);
-
- for (int x = 0; x < fields.length; x++)
- {
- assertEquals(fields[x].get(_fileInformationBlock), fields[x].get(newFileInformationBlock));
+public final class TestFileInformationBlock extends TestCase {
+ private FileInformationBlock _fileInformationBlock = null;
+ private HWPFDocFixture _hWPFDocFixture;
+
+ public void testReadWrite() throws Exception {
+ int size = _fileInformationBlock.getSize();
+ byte[] buf = new byte[size];
+
+ _fileInformationBlock.getFibBase().serialize(buf, 0);
+
+ FileInformationBlock newFileInformationBlock = new FileInformationBlock(
+ buf);
+
+ Field[] fields = FileInformationBlock.class.getSuperclass()
+ .getDeclaredFields();
+ AccessibleObject.setAccessible(fields, true);
+
+ for (int x = 0; x < fields.length; x++) {
+ assertEquals(fields[x].get(_fileInformationBlock),
+ fields[x].get(newFileInformationBlock));
+ }
+
+ assertNotNull(_fileInformationBlock.toString());
}
- }
- protected void setUp()
- throws Exception
- {
- super.setUp();
- /**@todo verify the constructors*/
- _hWPFDocFixture = new HWPFDocFixture(this, HWPFDocFixture.DEFAULT_TEST_FILE);
-
- _hWPFDocFixture.setUp();
- _fileInformationBlock = _hWPFDocFixture._fib;
- }
-
- protected void tearDown()
- throws Exception
- {
- _fileInformationBlock = null;
- _hWPFDocFixture.tearDown();
-
- _hWPFDocFixture = null;
- super.tearDown();
- }
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ /** @todo verify the constructors */
+ _hWPFDocFixture = new HWPFDocFixture(this,
+ HWPFDocFixture.DEFAULT_TEST_FILE);
+
+ _hWPFDocFixture.setUp();
+ _fileInformationBlock = _hWPFDocFixture._fib;
+ }
+ @Override
+ protected void tearDown() throws Exception {
+ _fileInformationBlock = null;
+ _hWPFDocFixture.tearDown();
+
+ _hWPFDocFixture = null;
+ super.tearDown();
+ }
}
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestTextPieceTable.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestTextPieceTable.java?rev=1602008&r1=1602007&r2=1602008&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestTextPieceTable.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestTextPieceTable.java Wed Jun 11 20:36:30 2014
@@ -27,162 +27,162 @@ import org.apache.poi.hwpf.HWPFDocument;
import org.apache.poi.hwpf.HWPFTestDataSamples;
import org.apache.poi.hwpf.model.io.HWPFFileSystem;
-
+@SuppressWarnings("deprecation")
public final class TestTextPieceTable extends TestCase {
- private HWPFDocFixture _hWPFDocFixture;
- //private String dirname;
+ private HWPFDocFixture _hWPFDocFixture;
+
+ // private String dirname;
- public void testReadWrite()
- throws Exception
- {
- FileInformationBlock fib = _hWPFDocFixture._fib;
- byte[] mainStream = _hWPFDocFixture._mainStream;
- byte[] tableStream = _hWPFDocFixture._tableStream;
- int fcMin = fib.getFibBase().getFcMin();
-
- ComplexFileTable cft = new ComplexFileTable(mainStream, tableStream, fib.getFcClx(), fcMin);
-
-
- HWPFFileSystem fileSys = new HWPFFileSystem();
-
- cft.writeTo(fileSys);
- ByteArrayOutputStream tableOut = fileSys.getStream("1Table");
- ByteArrayOutputStream mainOut = fileSys.getStream("WordDocument");
-
- byte[] newTableStream = tableOut.toByteArray();
- byte[] newMainStream = mainOut.toByteArray();
-
- ComplexFileTable newCft = new ComplexFileTable(newMainStream, newTableStream, 0,0);
-
- TextPieceTable oldTextPieceTable = cft.getTextPieceTable();
- TextPieceTable newTextPieceTable = newCft.getTextPieceTable();
-
- assertEquals(oldTextPieceTable, newTextPieceTable);
- }
-
- /**
- * Check that we do the positions correctly when
- * working with pure-ascii
- */
- public void testAsciiParts() throws Exception {
- HWPFDocument doc = HWPFTestDataSamples.openSampleFile("ThreeColHeadFoot.doc");
- TextPieceTable tbl = doc.getTextTable();
-
- // All ascii, so stored in one big lump
- assertEquals(1, tbl.getTextPieces().size());
- TextPiece tp = tbl.getTextPieces().get(0);
-
- assertEquals(0, tp.getStart());
- assertEquals(339, tp.getEnd());
- assertEquals(339, tp.characterLength());
- assertEquals(339, tp.bytesLength());
- assertTrue(tp.getStringBuilder().toString().startsWith("This is a sample word document"));
-
-
- // Save and re-load
- HWPFDocument docB = saveAndReload(doc);
- tbl = docB.getTextTable();
-
- assertEquals(1, tbl.getTextPieces().size());
- tp = tbl.getTextPieces().get(0);
-
- assertEquals(0, tp.getStart());
- assertEquals(339, tp.getEnd());
- assertEquals(339, tp.characterLength());
- assertEquals(339, tp.bytesLength());
- assertTrue(tp.getStringBuilder().toString().startsWith("This is a sample word document"));
- }
-
- /**
- * Check that we do the positions correctly when
- * working with a mix ascii, unicode file
- */
- public void testUnicodeParts() throws Exception {
- HWPFDocument doc = HWPFTestDataSamples.openSampleFile("HeaderFooterUnicode.doc");
- TextPieceTable tbl = doc.getTextTable();
-
- // In three bits, split every 512 bytes
- assertEquals(3, tbl.getTextPieces().size());
- TextPiece tpA = (TextPiece)tbl.getTextPieces().get(0);
- TextPiece tpB = (TextPiece)tbl.getTextPieces().get(1);
- TextPiece tpC = (TextPiece)tbl.getTextPieces().get(2);
-
- assertTrue(tpA.isUnicode());
- assertTrue(tpB.isUnicode());
- assertTrue(tpC.isUnicode());
-
- assertEquals(256, tpA.characterLength());
- assertEquals(256, tpB.characterLength());
- assertEquals(19, tpC.characterLength());
-
- assertEquals(512, tpA.bytesLength());
- assertEquals(512, tpB.bytesLength());
- assertEquals(38, tpC.bytesLength());
-
- assertEquals(0, tpA.getStart());
- assertEquals(256, tpA.getEnd());
- assertEquals(256, tpB.getStart());
- assertEquals(512, tpB.getEnd());
- assertEquals(512, tpC.getStart());
- assertEquals(531, tpC.getEnd());
-
-
- // Save and re-load
- HWPFDocument docB = saveAndReload(doc);
- tbl = docB.getTextTable();
-
- assertEquals(3, tbl.getTextPieces().size());
- tpA = (TextPiece)tbl.getTextPieces().get(0);
- tpB = (TextPiece)tbl.getTextPieces().get(1);
- tpC = (TextPiece)tbl.getTextPieces().get(2);
-
- assertTrue(tpA.isUnicode());
- assertTrue(tpB.isUnicode());
- assertTrue(tpC.isUnicode());
-
- assertEquals(256, tpA.characterLength());
- assertEquals(256, tpB.characterLength());
- assertEquals(19, tpC.characterLength());
-
- assertEquals(512, tpA.bytesLength());
- assertEquals(512, tpB.bytesLength());
- assertEquals(38, tpC.bytesLength());
-
- assertEquals(0, tpA.getStart());
- assertEquals(256, tpA.getEnd());
- assertEquals(256, tpB.getStart());
- assertEquals(512, tpB.getEnd());
- assertEquals(512, tpC.getStart());
- assertEquals(531, tpC.getEnd());
- }
-
- protected HWPFDocument saveAndReload(HWPFDocument doc) throws Exception {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- doc.write(baos);
-
- return new HWPFDocument(
- new ByteArrayInputStream(baos.toByteArray())
- );
- }
-
- protected void setUp()
- throws Exception
- {
- super.setUp();
- System.setProperty( "org.apache.poi.hwpf.preserveTextTable", Boolean.TRUE.toString() );
-
- _hWPFDocFixture = new HWPFDocFixture(this, HWPFDocFixture.DEFAULT_TEST_FILE);
- _hWPFDocFixture.setUp();
- }
-
- protected void tearDown()
- throws Exception
- {
- _hWPFDocFixture.tearDown();
- _hWPFDocFixture = null;
-
- System.setProperty( "org.apache.poi.hwpf.preserveTextTable", Boolean.FALSE.toString() );
- super.tearDown();
- }
+ public void testReadWrite() throws Exception {
+ FileInformationBlock fib = _hWPFDocFixture._fib;
+ byte[] mainStream = _hWPFDocFixture._mainStream;
+ byte[] tableStream = _hWPFDocFixture._tableStream;
+ int fcMin = fib.getFibBase().getFcMin();
+
+ ComplexFileTable cft = new ComplexFileTable(mainStream, tableStream,
+ fib.getFcClx(), fcMin);
+
+ HWPFFileSystem fileSys = new HWPFFileSystem();
+
+ cft.writeTo(fileSys);
+ ByteArrayOutputStream tableOut = fileSys.getStream("1Table");
+ ByteArrayOutputStream mainOut = fileSys.getStream("WordDocument");
+
+ byte[] newTableStream = tableOut.toByteArray();
+ byte[] newMainStream = mainOut.toByteArray();
+
+ ComplexFileTable newCft = new ComplexFileTable(newMainStream,
+ newTableStream, 0, 0);
+
+ TextPieceTable oldTextPieceTable = cft.getTextPieceTable();
+ TextPieceTable newTextPieceTable = newCft.getTextPieceTable();
+
+ assertEquals(oldTextPieceTable, newTextPieceTable);
+ }
+
+ /**
+ * Check that we do the positions correctly when working with pure-ascii
+ */
+ public void testAsciiParts() throws Exception {
+ HWPFDocument doc = HWPFTestDataSamples
+ .openSampleFile("ThreeColHeadFoot.doc");
+ TextPieceTable tbl = doc.getTextTable();
+
+ // All ascii, so stored in one big lump
+ assertEquals(1, tbl.getTextPieces().size());
+ TextPiece tp = tbl.getTextPieces().get(0);
+
+ assertEquals(0, tp.getStart());
+ assertEquals(339, tp.getEnd());
+ assertEquals(339, tp.characterLength());
+ assertEquals(339, tp.bytesLength());
+ assertTrue(tp.getStringBuilder().toString()
+ .startsWith("This is a sample word document"));
+
+ // Save and re-load
+ HWPFDocument docB = saveAndReload(doc);
+ tbl = docB.getTextTable();
+
+ assertEquals(1, tbl.getTextPieces().size());
+ tp = tbl.getTextPieces().get(0);
+
+ assertEquals(0, tp.getStart());
+ assertEquals(339, tp.getEnd());
+ assertEquals(339, tp.characterLength());
+ assertEquals(339, tp.bytesLength());
+ assertTrue(tp.getStringBuilder().toString()
+ .startsWith("This is a sample word document"));
+ }
+
+ /**
+ * Check that we do the positions correctly when working with a mix ascii,
+ * unicode file
+ */
+ public void testUnicodeParts() throws Exception {
+ HWPFDocument doc = HWPFTestDataSamples
+ .openSampleFile("HeaderFooterUnicode.doc");
+ TextPieceTable tbl = doc.getTextTable();
+
+ // In three bits, split every 512 bytes
+ assertEquals(3, tbl.getTextPieces().size());
+ TextPiece tpA = tbl.getTextPieces().get(0);
+ TextPiece tpB = tbl.getTextPieces().get(1);
+ TextPiece tpC = tbl.getTextPieces().get(2);
+
+ assertTrue(tpA.isUnicode());
+ assertTrue(tpB.isUnicode());
+ assertTrue(tpC.isUnicode());
+
+ assertEquals(256, tpA.characterLength());
+ assertEquals(256, tpB.characterLength());
+ assertEquals(19, tpC.characterLength());
+
+ assertEquals(512, tpA.bytesLength());
+ assertEquals(512, tpB.bytesLength());
+ assertEquals(38, tpC.bytesLength());
+
+ assertEquals(0, tpA.getStart());
+ assertEquals(256, tpA.getEnd());
+ assertEquals(256, tpB.getStart());
+ assertEquals(512, tpB.getEnd());
+ assertEquals(512, tpC.getStart());
+ assertEquals(531, tpC.getEnd());
+
+ // Save and re-load
+ HWPFDocument docB = saveAndReload(doc);
+ tbl = docB.getTextTable();
+
+ assertEquals(3, tbl.getTextPieces().size());
+ tpA = tbl.getTextPieces().get(0);
+ tpB = tbl.getTextPieces().get(1);
+ tpC = tbl.getTextPieces().get(2);
+
+ assertTrue(tpA.isUnicode());
+ assertTrue(tpB.isUnicode());
+ assertTrue(tpC.isUnicode());
+
+ assertEquals(256, tpA.characterLength());
+ assertEquals(256, tpB.characterLength());
+ assertEquals(19, tpC.characterLength());
+
+ assertEquals(512, tpA.bytesLength());
+ assertEquals(512, tpB.bytesLength());
+ assertEquals(38, tpC.bytesLength());
+
+ assertEquals(0, tpA.getStart());
+ assertEquals(256, tpA.getEnd());
+ assertEquals(256, tpB.getStart());
+ assertEquals(512, tpB.getEnd());
+ assertEquals(512, tpC.getStart());
+ assertEquals(531, tpC.getEnd());
+ }
+
+ protected HWPFDocument saveAndReload(HWPFDocument doc) throws Exception {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ doc.write(baos);
+
+ return new HWPFDocument(new ByteArrayInputStream(baos.toByteArray()));
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ System.setProperty("org.apache.poi.hwpf.preserveTextTable",
+ Boolean.TRUE.toString());
+
+ _hWPFDocFixture = new HWPFDocFixture(this,
+ HWPFDocFixture.DEFAULT_TEST_FILE);
+ _hWPFDocFixture.setUp();
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ _hWPFDocFixture.tearDown();
+ _hWPFDocFixture = null;
+
+ System.setProperty("org.apache.poi.hwpf.preserveTextTable",
+ Boolean.FALSE.toString());
+ super.tearDown();
+ }
}
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestBugs.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestBugs.java?rev=1602008&r1=1602007&r2=1602008&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestBugs.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestBugs.java Wed Jun 11 20:36:30 2014
@@ -396,11 +396,15 @@ public class TestBugs extends TestCase
// document as text file using encoding UTF-8)
InputStream is = POIDataSamples.getDocumentInstance()
.openResourceAsStream( "Bug47742-text.txt" );
- byte[] expectedBytes = IOUtils.toByteArray( is );
- String expectedText = new String( expectedBytes, "utf-8" )
- .substring( 1 ); // strip-off the unicode marker
-
- assertEquals( expectedText, foundText );
+ try {
+ byte[] expectedBytes = IOUtils.toByteArray( is );
+ String expectedText = new String( expectedBytes, "utf-8" )
+ .substring( 1 ); // strip-off the unicode marker
+
+ assertEquals( expectedText, foundText );
+ } finally {
+ is.close();
+ }
}
/**
Modified: poi/trunk/src/testcases/org/apache/poi/hpsf/basic/TestWrite.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hpsf/basic/TestWrite.java?rev=1602008&r1=1602007&r2=1602008&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hpsf/basic/TestWrite.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hpsf/basic/TestWrite.java Wed Jun 11 20:36:30 2014
@@ -268,7 +268,7 @@ public class TestWrite
assertNotNull(psa[0]);
assertTrue(psa[0].isSummaryInformation());
- final Section s = (Section) (psa[0].getSections().get(0));
+ final Section s = (psa[0].getSections().get(0));
Object p1 = s.getProperty(PropertyIDMap.PID_AUTHOR);
Object p2 = s.getProperty(PropertyIDMap.PID_TITLE);
assertEquals(AUTHOR, p1);
@@ -349,11 +349,11 @@ public class TestWrite
stream.close();
}
assertNotNull(psa[0]);
- Section s = (Section) (psa[0].getSections().get(0));
+ Section s = (psa[0].getSections().get(0));
assertEquals(s.getFormatID(), formatID);
Object p = s.getProperty(2);
assertEquals(SECTION1, p);
- s = (Section) (psa[0].getSections().get(1));
+ s = (psa[0].getSections().get(1));
p = s.getProperty(2);
assertEquals(SECTION2, p);
}
@@ -584,7 +584,7 @@ public class TestWrite
PropertySet psr = new PropertySet(bytes);
assertTrue(psr.isSummaryInformation());
- Section sr = (Section) psr.getSections().get(0);
+ Section sr = psr.getSections().get(0);
String title = (String) sr.getProperty(PropertyIDMap.PID_TITLE);
assertEquals(TITLE, title);
}
Modified: poi/trunk/src/testcases/org/apache/poi/hpsf/basic/Util.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hpsf/basic/Util.java?rev=1602008&r1=1602007&r2=1602008&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hpsf/basic/Util.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hpsf/basic/Util.java Wed Jun 11 20:36:30 2014
@@ -131,7 +131,7 @@ final class Util {
final String[] poiFiles)
throws FileNotFoundException, IOException
{
- final List files = new ArrayList();
+ final List<POIFile> files = new ArrayList<POIFile>();
POIFSReader r = new POIFSReader();
POIFSReaderListener pfl = new POIFSReaderListener()
{
@@ -170,7 +170,7 @@ final class Util {
r.read(new FileInputStream(poiFs));
POIFile[] result = new POIFile[files.size()];
for (int i = 0; i < result.length; i++)
- result[i] = (POIFile) files.get(i);
+ result[i] = files.get(i);
return result;
}
@@ -195,7 +195,7 @@ final class Util {
public static POIFile[] readPropertySets(final File poiFs)
throws FileNotFoundException, IOException
{
- final List files = new ArrayList(7);
+ final List<POIFile> files = new ArrayList<POIFile>(7);
final POIFSReader r = new POIFSReader();
POIFSReaderListener pfl = new POIFSReaderListener()
{
Modified: poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestNPOIFSFileSystem.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestNPOIFSFileSystem.java?rev=1602008&r1=1602007&r2=1602008&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestNPOIFSFileSystem.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestNPOIFSFileSystem.java Wed Jun 11 20:36:30 2014
@@ -111,6 +111,8 @@ public final class TestNPOIFSFileSystem
for(NPOIFSFileSystem fs : new NPOIFSFileSystem[] {fsA,fsB}) {
assertEquals(512, fs.getBigBlockSize());
}
+ fsA.close();
+ fsB.close();
// Now with a simple 4096 block file
fsA = new NPOIFSFileSystem(_inst.getFile("BlockSize4096.zvi"));
@@ -118,6 +120,8 @@ public final class TestNPOIFSFileSystem
for(NPOIFSFileSystem fs : new NPOIFSFileSystem[] {fsA,fsB}) {
assertEquals(4096, fs.getBigBlockSize());
}
+ fsA.close();
+ fsB.close();
}
@Test
@@ -186,6 +190,8 @@ public final class TestNPOIFSFileSystem
assertEquals(i+1, ministore.getNextBlock(i));
}
assertEquals(POIFSConstants.END_OF_CHAIN, ministore.getNextBlock(50));
+
+ fs.close();
}
// Now with a simple 4096 block file
@@ -252,6 +258,8 @@ public final class TestNPOIFSFileSystem
assertEquals(i+1, ministore.getNextBlock(i));
}
assertEquals(POIFSConstants.END_OF_CHAIN, ministore.getNextBlock(50));
+
+ fs.close();
}
}
@@ -295,6 +303,8 @@ public final class TestNPOIFSFileSystem
for(int i=100; i<fs.getBigBlockSizeDetails().getBATEntriesPerBlock(); i++) {
assertEquals(POIFSConstants.UNUSED_BLOCK, fs.getNextBlock(i));
}
+
+ fs.close();
}
// Quick check on 4096 byte blocks too
@@ -311,6 +321,8 @@ public final class TestNPOIFSFileSystem
assertEquals(i+1, fs.getNextBlock(i));
}
assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(11));
+
+ fs.close();
}
}
@@ -348,6 +360,8 @@ public final class TestNPOIFSFileSystem
assertEquals((byte)0x00, b.get());
assertEquals((byte)0x00, b.get());
assertEquals((byte)0x00, b.get());
+
+ fs.close();
}
// Quick check on 4096 byte blocks too
@@ -380,6 +394,8 @@ public final class TestNPOIFSFileSystem
assertEquals((byte)0x00, b.get());
assertEquals((byte)0x00, b.get());
assertEquals((byte)0x00, b.get());
+
+ fs.close();
}
}
@@ -591,6 +607,8 @@ public final class TestNPOIFSFileSystem
// Look inside another
DirectoryEntry imageD = (DirectoryEntry)image;
assertEquals(7, imageD.getEntryCount());
+
+ fs.close();
}
}
@@ -635,6 +653,8 @@ public final class TestNPOIFSFileSystem
ps = PropertySetFactory.create(inp);
DocumentSummaryInformation dinf = (DocumentSummaryInformation)ps;
assertEquals(131333, dinf.getOSVersion());
+
+ fs.close();
}
}
Modified: poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestNPOIFSMiniStore.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestNPOIFSMiniStore.java?rev=1602008&r1=1602007&r2=1602008&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestNPOIFSMiniStore.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestNPOIFSMiniStore.java Wed Jun 11 20:36:30 2014
@@ -28,7 +28,6 @@ import org.apache.poi.poifs.common.POIFS
/**
* Tests for the Mini Store in the NIO POIFS
*/
-@SuppressWarnings("resource")
public final class TestNPOIFSMiniStore extends TestCase {
private static final POIDataSamples _inst = POIDataSamples.getPOIFSInstance();
@@ -103,6 +102,8 @@ public final class TestNPOIFSMiniStore e
for(int i=181; i<fs.getBigBlockSizeDetails().getBATEntriesPerBlock(); i++) {
assertEquals(POIFSConstants.UNUSED_BLOCK, ministore.getNextBlock(i));
}
+
+ fs.close();
}
}
@@ -168,6 +169,8 @@ public final class TestNPOIFSMiniStore e
assertEquals((byte)0, b.get());
assertEquals((byte)0, b.get());
}
+
+ fs.close();
}
}
@@ -198,6 +201,8 @@ public final class TestNPOIFSMiniStore e
// Allocate it, then ask again
ministore.setNextBlock(181, POIFSConstants.END_OF_CHAIN);
assertEquals(182, ministore.getFreeBlock());
+
+ fs.close();
}
/**
@@ -240,6 +245,8 @@ public final class TestNPOIFSMiniStore e
assertEquals(POIFSConstants.END_OF_CHAIN, ministore.getNextBlock(255)); // 2nd SBAT
assertEquals(POIFSConstants.UNUSED_BLOCK, ministore.getNextBlock(256)); // 3rd SBAT
assertEquals(POIFSConstants.UNUSED_BLOCK, ministore.getNextBlock(257)); // 3rd SBAT
+
+ fs.close();
}
/**
@@ -322,5 +329,7 @@ public final class TestNPOIFSMiniStore e
for(int i=193; i<256; i++) {
assertEquals(POIFSConstants.UNUSED_BLOCK, ministore.getNextBlock(i));
}
+
+ fs.close();
}
}
Modified: poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestNPOIFSStream.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestNPOIFSStream.java?rev=1602008&r1=1602007&r2=1602008&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestNPOIFSStream.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestNPOIFSStream.java Wed Jun 11 20:36:30 2014
@@ -62,6 +62,8 @@ public final class TestNPOIFSStream exte
assertEquals((byte)0x00, b.get());
assertEquals((byte)0x00, b.get());
assertEquals((byte)0x00, b.get());
+
+ fs.close();
}
/**
@@ -103,6 +105,8 @@ public final class TestNPOIFSStream exte
assertEquals((byte)0x00, b98.get());
assertEquals((byte)0x00, b98.get());
assertEquals((byte)0x00, b98.get());
+
+ fs.close();
}
/**
@@ -157,6 +161,8 @@ public final class TestNPOIFSStream exte
assertEquals((byte)0x01, b22.get());
assertEquals((byte)0x02, b22.get());
assertEquals((byte)0x00, b22.get());
+
+ fs.close();
}
/**
@@ -211,6 +217,8 @@ public final class TestNPOIFSStream exte
assertEquals((byte)0x00, b2.get());
assertEquals((byte)0x46, b2.get());
assertEquals((byte)0x00, b2.get());
+
+ fs.close();
}
/**
@@ -249,6 +257,8 @@ public final class TestNPOIFSStream exte
// Good, it was detected
}
assertEquals(true, i.hasNext());
+
+ fs.close();
}
/**
@@ -304,6 +314,8 @@ public final class TestNPOIFSStream exte
assertEquals((byte)0x00, b180.get());
assertEquals((byte)0x00, b180.get());
assertEquals((byte)0x80, b180.get());
+
+ fs.close();
}
/**
@@ -334,6 +346,8 @@ public final class TestNPOIFSStream exte
byte exp = (byte)(i%256);
assertEquals(exp, data[i]);
}
+
+ fs.close();
}
/**
@@ -373,6 +387,8 @@ public final class TestNPOIFSStream exte
byte exp = (byte)(i%256);
assertEquals(exp, data[i]);
}
+
+ fs.close();
}
/**
@@ -417,6 +433,8 @@ public final class TestNPOIFSStream exte
count++;
}
assertEquals(3, count);
+
+ fs.close();
}
/**
@@ -507,6 +525,8 @@ public final class TestNPOIFSStream exte
assertEquals(POIFSConstants.UNUSED_BLOCK, fs.getNextBlock(102));
assertEquals(POIFSConstants.UNUSED_BLOCK, fs.getNextBlock(103));
assertEquals(POIFSConstants.UNUSED_BLOCK, fs.getNextBlock(104));
+
+ fs.close();
}
/**
@@ -547,6 +567,8 @@ public final class TestNPOIFSStream exte
assertEquals(130, fs.getNextBlock(129));
assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(130));
assertEquals(POIFSConstants.UNUSED_BLOCK, fs.getNextBlock(131));
+
+ fs.close();
}
/**
@@ -600,6 +622,8 @@ public final class TestNPOIFSStream exte
count++;
}
assertEquals(5, count);
+
+ fs.close();
}
/**
@@ -790,6 +814,8 @@ public final class TestNPOIFSStream exte
assertEquals((byte)0x42, b183.get(1));
assertEquals((byte)0x81, b184.get(0));
assertEquals((byte)0x82, b184.get(1));
+
+ fs.close();
}
/**
@@ -823,6 +849,8 @@ public final class TestNPOIFSStream exte
stream.updateContents(data);
fail("Loop should have been detected but wasn't!");
} catch(IllegalStateException e) {}
+
+ fs.close();
}
/**
@@ -889,6 +917,8 @@ public final class TestNPOIFSStream exte
}
assertEquals(false, it.hasNext());
+
+ fs.close();
}
/**
@@ -1079,5 +1109,7 @@ public final class TestNPOIFSStream exte
normal = (DocumentEntry)fs.getRoot().getEntry("Normal");
assertEquals(4096, normal.getSize());
assertEquals(4096, ((DocumentNode)normal).getProperty().getSize());
+
+ fs.close();
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org