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 2009/06/12 23:53:20 UTC
svn commit: r784284 [1/3] - in /poi/trunk/src:
ooxml/testcases/org/apache/poi/openxml4j/opc/compliance/
ooxml/testcases/org/apache/poi/xssf/eventusermodel/
ooxml/testcases/org/apache/poi/xssf/usermodel/
scratchpad/testcases/org/apache/poi/hdf/model/ sc...
Author: josh
Date: Fri Jun 12 21:53:17 2009
New Revision: 784284
URL: http://svn.apache.org/viewvc?rev=784284&view=rev
Log:
Removed static void main(String[]) methods from junit classes. Other minor clean-up.
Modified:
poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/compliance/TestOPCCompliancePackageModel.java
poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/compliance/TestOPCCompliancePartName.java
poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/eventusermodel/TestXSSFReader.java
poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFormulaEvaluation.java
poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFHyperlink.java
poi/trunk/src/scratchpad/testcases/org/apache/poi/hdf/model/TestHDFDocument.java
poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestCHPBinTable.java
poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestDocumentProperties.java
poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestFileInformationBlock.java
poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestFontTable.java
poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestPAPBinTable.java
poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestPlexOfCps.java
poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestSectionTable.java
poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestStyleSheet.java
poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestTextPieceTable.java
poi/trunk/src/testcases/org/apache/poi/hpsf/basic/TestBasic.java
poi/trunk/src/testcases/org/apache/poi/hpsf/basic/TestClassID.java
poi/trunk/src/testcases/org/apache/poi/hpsf/basic/TestEmptyProperties.java
poi/trunk/src/testcases/org/apache/poi/hssf/eventmodel/TestModelFactory.java
poi/trunk/src/testcases/org/apache/poi/hssf/record/TestCFRuleRecord.java
poi/trunk/src/testcases/org/apache/poi/hssf/record/TestPaletteRecord.java
poi/trunk/src/testcases/org/apache/poi/hssf/record/chart/TestAxisOptionsRecord.java
poi/trunk/src/testcases/org/apache/poi/hssf/record/chart/TestTickRecord.java
poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestReadWriteChart.java
poi/trunk/src/testcases/org/apache/poi/poifs/eventfilesystem/TestPOIFSReaderRegistry.java
poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestDirectoryNode.java
poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestDocument.java
poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestDocumentDescriptor.java
poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestDocumentNode.java
poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestDocumentOutputStream.java
poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestEmptyDocument.java
poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestPOIFSDocumentPath.java
poi/trunk/src/testcases/org/apache/poi/poifs/property/TestDirectoryProperty.java
poi/trunk/src/testcases/org/apache/poi/poifs/property/TestDocumentProperty.java
poi/trunk/src/testcases/org/apache/poi/poifs/property/TestPropertyFactory.java
poi/trunk/src/testcases/org/apache/poi/poifs/property/TestPropertyTable.java
poi/trunk/src/testcases/org/apache/poi/poifs/property/TestRootProperty.java
poi/trunk/src/testcases/org/apache/poi/poifs/storage/TestBATBlock.java
poi/trunk/src/testcases/org/apache/poi/poifs/storage/TestBlockAllocationTableReader.java
poi/trunk/src/testcases/org/apache/poi/poifs/storage/TestBlockAllocationTableWriter.java
poi/trunk/src/testcases/org/apache/poi/poifs/storage/TestBlockListImpl.java
poi/trunk/src/testcases/org/apache/poi/poifs/storage/TestHeaderBlockReader.java
poi/trunk/src/testcases/org/apache/poi/poifs/storage/TestHeaderBlockWriter.java
poi/trunk/src/testcases/org/apache/poi/poifs/storage/TestPropertyBlock.java
poi/trunk/src/testcases/org/apache/poi/poifs/storage/TestRawDataBlock.java
poi/trunk/src/testcases/org/apache/poi/poifs/storage/TestRawDataBlockList.java
poi/trunk/src/testcases/org/apache/poi/poifs/storage/TestSmallBlockTableReader.java
poi/trunk/src/testcases/org/apache/poi/poifs/storage/TestSmallBlockTableWriter.java
poi/trunk/src/testcases/org/apache/poi/poifs/storage/TestSmallDocumentBlockList.java
poi/trunk/src/testcases/org/apache/poi/util/TestBinaryTree.java
poi/trunk/src/testcases/org/apache/poi/util/TestBitField.java
poi/trunk/src/testcases/org/apache/poi/util/TestByteField.java
poi/trunk/src/testcases/org/apache/poi/util/TestIntList.java
poi/trunk/src/testcases/org/apache/poi/util/TestIntegerField.java
poi/trunk/src/testcases/org/apache/poi/util/TestPOILogFactory.java
poi/trunk/src/testcases/org/apache/poi/util/TestPOILogger.java
poi/trunk/src/testcases/org/apache/poi/util/TestShortField.java
poi/trunk/src/testcases/org/apache/poi/util/TestShortList.java
poi/trunk/src/testcases/org/apache/poi/util/TestStringUtil.java
Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/compliance/TestOPCCompliancePackageModel.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/compliance/TestOPCCompliancePackageModel.java?rev=784284&r1=784283&r2=784284&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/compliance/TestOPCCompliancePackageModel.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/compliance/TestOPCCompliancePackageModel.java Fri Jun 12 21:53:17 2009
@@ -32,18 +32,14 @@
/**
* Test Open Packaging Convention package model compliance.
- *
+ *
* M1.11 : A package implementer shall neither create nor recognize a part with
* a part name derived from another part name by appending segments to it.
- *
+ *
* @author Julien Chable
*/
public class TestOPCCompliancePackageModel extends TestCase {
- public TestOPCCompliancePackageModel(String name) {
- super(name);
- }
-
/**
* A package implementer shall neither create nor recognize a part with a
* part name derived from another part name by appending segments to it.
@@ -135,7 +131,7 @@
/**
* Try to add a relationship to a relationship part.
- *
+ *
* Check rule M1.25: The Relationships part shall not have relationships to
* any other part. Package implementers shall enforce this requirement upon
* the attempt to create such a relationship and shall treat any such
Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/compliance/TestOPCCompliancePartName.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/compliance/TestOPCCompliancePartName.java?rev=784284&r1=784283&r2=784284&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/compliance/TestOPCCompliancePartName.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/compliance/TestOPCCompliancePartName.java Fri Jun 12 21:53:17 2009
@@ -79,10 +79,6 @@
*/
public final class TestOPCCompliancePartName extends TestCase {
- public TestOPCCompliancePartName(String name) {
- super(name);
- }
-
/**
* Test some common invalid names.
*
Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/eventusermodel/TestXSSFReader.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/eventusermodel/TestXSSFReader.java?rev=784284&r1=784283&r2=784284&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/eventusermodel/TestXSSFReader.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/eventusermodel/TestXSSFReader.java Fri Jun 12 21:53:17 2009
@@ -28,111 +28,110 @@
import org.apache.poi.openxml4j.opc.OPCPackage;
/**
- * Tests for XSSFReader
+ * Tests for {@link XSSFReader}
*/
-public class TestXSSFReader extends TestCase {
+public final class TestXSSFReader extends TestCase {
private String dirName;
-
- public TestXSSFReader(String name) {
- super(name);
-
+
+ @Override
+ protected void setUp() {
+
dirName = System.getProperty("HSSF.testdata.path");
assertNotNull(dirName);
assertTrue( (new File(dirName)).exists() );
-
+
// Use system out logger
- System.setProperty(
- "org.apache.poi.util.POILogger",
- "org.apache.poi.util.SystemOutLogger"
- );
- }
-
- public void testGetBits() throws Exception {
- File f = new File(dirName, "SampleSS.xlsx");
- OPCPackage pkg = OPCPackage.open(f.toString());
-
- XSSFReader r = new XSSFReader(pkg);
-
- assertNotNull(r.getWorkbookData());
- assertNotNull(r.getSharedStringsData());
- assertNotNull(r.getStylesData());
-
- assertNotNull(r.getSharedStringsTable());
- assertNotNull(r.getStylesTable());
- }
-
- public void testStyles() throws Exception {
- File f = new File(dirName, "SampleSS.xlsx");
- OPCPackage pkg = OPCPackage.open(f.toString());
-
- XSSFReader r = new XSSFReader(pkg);
-
- assertEquals(3, r.getStylesTable().getFonts().size());
- assertEquals(0, r.getStylesTable()._getNumberFormatSize());
- }
-
- public void testStrings() throws Exception {
- File f = new File(dirName, "SampleSS.xlsx");
- OPCPackage pkg = OPCPackage.open(f.toString());
-
- XSSFReader r = new XSSFReader(pkg);
-
- assertEquals(11, r.getSharedStringsTable().getItems().size());
- assertEquals("Test spreadsheet", new XSSFRichTextString(r.getSharedStringsTable().getEntryAt(0)).toString());
- }
-
- public void testSheets() throws Exception {
- File f = new File(dirName, "SampleSS.xlsx");
- OPCPackage pkg = OPCPackage.open(f.toString());
-
- XSSFReader r = new XSSFReader(pkg);
- byte[] data = new byte[4096];
-
- // By r:id
- assertNotNull(r.getSheet("rId2"));
- int read = IOUtils.readFully(r.getSheet("rId2"), data);
- assertEquals(974, read);
-
- // All
- Iterator<InputStream> it = r.getSheetsData();
-
- int count = 0;
- while(it.hasNext()) {
- count++;
- InputStream inp = it.next();
- assertNotNull(inp);
- read = IOUtils.readFully(inp, data);
- inp.close();
-
- assertTrue(read > 400);
- assertTrue(read < 1500);
- }
- assertEquals(3, count);
- }
-
- /**
- * Check that the sheet iterator returns sheets in the logical order
- * (as they are defined in the workbook.xml)
- */
- public void testOrderOfSheets() throws Exception {
- File f = new File(dirName, "reordered_sheets.xlsx");
- OPCPackage pkg = OPCPackage.open(f.toString());
-
- XSSFReader r = new XSSFReader(pkg);
-
- String[] sheetNames = {"Sheet4", "Sheet2", "Sheet3", "Sheet1"};
- XSSFReader.SheetIterator it = (XSSFReader.SheetIterator)r.getSheetsData();
-
- int count = 0;
- while(it.hasNext()) {
- InputStream inp = it.next();
- assertNotNull(inp);
- inp.close();
-
- assertEquals(sheetNames[count], it.getSheetName());
- count++;
- }
- assertEquals(4, count);
+ System.setProperty(
+ "org.apache.poi.util.POILogger",
+ "org.apache.poi.util.SystemOutLogger"
+ );
+ }
+
+ public void testGetBits() throws Exception {
+ File f = new File(dirName, "SampleSS.xlsx");
+ OPCPackage pkg = OPCPackage.open(f.toString());
+
+ XSSFReader r = new XSSFReader(pkg);
+
+ assertNotNull(r.getWorkbookData());
+ assertNotNull(r.getSharedStringsData());
+ assertNotNull(r.getStylesData());
+
+ assertNotNull(r.getSharedStringsTable());
+ assertNotNull(r.getStylesTable());
+ }
+
+ public void testStyles() throws Exception {
+ File f = new File(dirName, "SampleSS.xlsx");
+ OPCPackage pkg = OPCPackage.open(f.toString());
+
+ XSSFReader r = new XSSFReader(pkg);
- }
+ assertEquals(3, r.getStylesTable().getFonts().size());
+ assertEquals(0, r.getStylesTable()._getNumberFormatSize());
+ }
+
+ public void testStrings() throws Exception {
+ File f = new File(dirName, "SampleSS.xlsx");
+ OPCPackage pkg = OPCPackage.open(f.toString());
+
+ XSSFReader r = new XSSFReader(pkg);
+
+ assertEquals(11, r.getSharedStringsTable().getItems().size());
+ assertEquals("Test spreadsheet", new XSSFRichTextString(r.getSharedStringsTable().getEntryAt(0)).toString());
+ }
+
+ public void testSheets() throws Exception {
+ File f = new File(dirName, "SampleSS.xlsx");
+ OPCPackage pkg = OPCPackage.open(f.toString());
+
+ XSSFReader r = new XSSFReader(pkg);
+ byte[] data = new byte[4096];
+
+ // By r:id
+ assertNotNull(r.getSheet("rId2"));
+ int read = IOUtils.readFully(r.getSheet("rId2"), data);
+ assertEquals(974, read);
+
+ // All
+ Iterator<InputStream> it = r.getSheetsData();
+
+ int count = 0;
+ while(it.hasNext()) {
+ count++;
+ InputStream inp = it.next();
+ assertNotNull(inp);
+ read = IOUtils.readFully(inp, data);
+ inp.close();
+
+ assertTrue(read > 400);
+ assertTrue(read < 1500);
+ }
+ assertEquals(3, count);
+ }
+
+ /**
+ * Check that the sheet iterator returns sheets in the logical order
+ * (as they are defined in the workbook.xml)
+ */
+ public void testOrderOfSheets() throws Exception {
+ File f = new File(dirName, "reordered_sheets.xlsx");
+ OPCPackage pkg = OPCPackage.open(f.toString());
+
+ XSSFReader r = new XSSFReader(pkg);
+
+ String[] sheetNames = {"Sheet4", "Sheet2", "Sheet3", "Sheet1"};
+ XSSFReader.SheetIterator it = (XSSFReader.SheetIterator)r.getSheetsData();
+
+ int count = 0;
+ while(it.hasNext()) {
+ InputStream inp = it.next();
+ assertNotNull(inp);
+ inp.close();
+
+ assertEquals(sheetNames[count], it.getSheetName());
+ count++;
+ }
+ assertEquals(4, count);
+ }
}
Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFormulaEvaluation.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFormulaEvaluation.java?rev=784284&r1=784283&r2=784284&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFormulaEvaluation.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFormulaEvaluation.java Fri Jun 12 21:53:17 2009
@@ -23,9 +23,8 @@
import org.apache.poi.xssf.XSSFTestDataSamples;
public final class TestXSSFFormulaEvaluation extends TestCase {
- public TestXSSFFormulaEvaluation(String name) {
- super(name);
-
+ @Override
+ protected void setUp() {
// Use system out logger
System.setProperty(
"org.apache.poi.util.POILogger",
Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFHyperlink.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFHyperlink.java?rev=784284&r1=784283&r2=784284&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFHyperlink.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFHyperlink.java Fri Jun 12 21:53:17 2009
@@ -27,31 +27,26 @@
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.xssf.XSSFTestDataSamples;
-public class TestXSSFHyperlink extends TestCase {
- public TestXSSFHyperlink(String name) {
- super(name);
-
+public final class TestXSSFHyperlink extends TestCase {
+ @Override
+ protected void setUp() {
// Use system out logger
- System.setProperty(
- "org.apache.poi.util.POILogger",
- "org.apache.poi.util.SystemOutLogger"
- );
+ System.setProperty(
+ "org.apache.poi.util.POILogger",
+ "org.apache.poi.util.SystemOutLogger"
+ );
}
-
- public void testAddNew() throws Exception {
-
- }
- public void testLoadExisting() throws Exception {
+ public void testLoadExisting() throws Exception {
File xml = new File(
System.getProperty("HSSF.testdata.path") +
File.separator + "WithMoreVariousData.xlsx"
);
assertTrue(xml.exists());
-
+
XSSFWorkbook workbook = new XSSFWorkbook(xml.toString());
assertEquals(3, workbook.getNumberOfSheets());
-
+
XSSFSheet sheet = (XSSFSheet)workbook.getSheetAt(0);
// Check the hyperlinks
@@ -59,13 +54,13 @@
doTestHyperlinkContents(sheet);
}
- public void testLoadSave() throws Exception {
+ public void testLoadSave() throws Exception {
File xml = new File(
System.getProperty("HSSF.testdata.path") +
File.separator + "WithMoreVariousData.xlsx"
);
assertTrue(xml.exists());
-
+
XSSFWorkbook workbook = new XSSFWorkbook(xml.toString());
CreationHelper createHelper = workbook.getCreationHelper();
assertEquals(3, workbook.getNumberOfSheets());
@@ -74,8 +69,8 @@
// Check hyperlinks
assertEquals(4, sheet.getNumHyperlinks());
doTestHyperlinkContents(sheet);
-
-
+
+
// Write out, and check
// Load up again, check all links still there
@@ -84,95 +79,95 @@
assertNotNull(wb2.getSheetAt(0));
assertNotNull(wb2.getSheetAt(1));
assertNotNull(wb2.getSheetAt(2));
-
+
sheet = (XSSFSheet)wb2.getSheetAt(0);
-
+
// Check hyperlinks again
assertEquals(4, sheet.getNumHyperlinks());
doTestHyperlinkContents(sheet);
-
-
+
+
// Add one more, and re-check
Row r17 = sheet.createRow(17);
Cell r17c = r17.createCell(2);
-
+
Hyperlink hyperlink = createHelper.createHyperlink(Hyperlink.LINK_URL);
hyperlink.setAddress("http://poi.apache.org/spreadsheet/");
hyperlink.setLabel("POI SS Link");
r17c.setHyperlink(hyperlink);
-
+
assertEquals(5, sheet.getNumHyperlinks());
doTestHyperlinkContents(sheet);
-
- assertEquals(Hyperlink.LINK_URL,
+
+ assertEquals(Hyperlink.LINK_URL,
sheet.getRow(17).getCell(2).getHyperlink().getType());
- assertEquals("POI SS Link",
+ assertEquals("POI SS Link",
sheet.getRow(17).getCell(2).getHyperlink().getLabel());
- assertEquals("http://poi.apache.org/spreadsheet/",
+ assertEquals("http://poi.apache.org/spreadsheet/",
sheet.getRow(17).getCell(2).getHyperlink().getAddress());
-
-
+
+
// Save and re-load once more
- XSSFWorkbook wb3 = XSSFTestDataSamples.writeOutAndReadBack(wb2);
+ XSSFWorkbook wb3 = XSSFTestDataSamples.writeOutAndReadBack(wb2);
assertEquals(3, wb3.getNumberOfSheets());
assertNotNull(wb3.getSheetAt(0));
assertNotNull(wb3.getSheetAt(1));
assertNotNull(wb3.getSheetAt(2));
-
+
sheet = wb3.getSheetAt(0);
-
+
assertEquals(5, sheet.getNumHyperlinks());
doTestHyperlinkContents(sheet);
-
- assertEquals(Hyperlink.LINK_URL,
+
+ assertEquals(Hyperlink.LINK_URL,
sheet.getRow(17).getCell(2).getHyperlink().getType());
- assertEquals("POI SS Link",
+ assertEquals("POI SS Link",
sheet.getRow(17).getCell(2).getHyperlink().getLabel());
- assertEquals("http://poi.apache.org/spreadsheet/",
+ assertEquals("http://poi.apache.org/spreadsheet/",
sheet.getRow(17).getCell(2).getHyperlink().getAddress());
- }
+ }
- /**
- * Only for WithMoreVariousData.xlsx !
- */
- private void doTestHyperlinkContents(XSSFSheet sheet) {
+ /**
+ * Only for WithMoreVariousData.xlsx !
+ */
+ private void doTestHyperlinkContents(XSSFSheet sheet) {
assertNotNull(sheet.getRow(3).getCell(2).getHyperlink());
assertNotNull(sheet.getRow(14).getCell(2).getHyperlink());
assertNotNull(sheet.getRow(15).getCell(2).getHyperlink());
assertNotNull(sheet.getRow(16).getCell(2).getHyperlink());
-
+
// First is a link to poi
- assertEquals(Hyperlink.LINK_URL,
+ assertEquals(Hyperlink.LINK_URL,
sheet.getRow(3).getCell(2).getHyperlink().getType());
- assertEquals(null,
+ assertEquals(null,
sheet.getRow(3).getCell(2).getHyperlink().getLabel());
- assertEquals("http://poi.apache.org/",
+ assertEquals("http://poi.apache.org/",
sheet.getRow(3).getCell(2).getHyperlink().getAddress());
-
+
// Next is an internal doc link
- assertEquals(Hyperlink.LINK_DOCUMENT,
+ assertEquals(Hyperlink.LINK_DOCUMENT,
sheet.getRow(14).getCell(2).getHyperlink().getType());
- assertEquals("Internal hyperlink to A2",
+ assertEquals("Internal hyperlink to A2",
sheet.getRow(14).getCell(2).getHyperlink().getLabel());
- assertEquals("Sheet1!A2",
+ assertEquals("Sheet1!A2",
sheet.getRow(14).getCell(2).getHyperlink().getAddress());
-
+
// Next is a file
- assertEquals(Hyperlink.LINK_FILE,
+ assertEquals(Hyperlink.LINK_FILE,
sheet.getRow(15).getCell(2).getHyperlink().getType());
- assertEquals(null,
+ assertEquals(null,
sheet.getRow(15).getCell(2).getHyperlink().getLabel());
- assertEquals("WithVariousData.xlsx",
+ assertEquals("WithVariousData.xlsx",
sheet.getRow(15).getCell(2).getHyperlink().getAddress());
-
+
// Last is a mailto
- assertEquals(Hyperlink.LINK_EMAIL,
+ assertEquals(Hyperlink.LINK_EMAIL,
sheet.getRow(16).getCell(2).getHyperlink().getType());
- assertEquals(null,
+ assertEquals(null,
sheet.getRow(16).getCell(2).getHyperlink().getLabel());
- assertEquals("mailto:dev@poi.apache.org?subject=XSSF%20Hyperlinks",
+ assertEquals("mailto:dev@poi.apache.org?subject=XSSF%20Hyperlinks",
sheet.getRow(16).getCell(2).getHyperlink().getAddress());
- }
+ }
}
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hdf/model/TestHDFDocument.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hdf/model/TestHDFDocument.java?rev=784284&r1=784283&r2=784284&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hdf/model/TestHDFDocument.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hdf/model/TestHDFDocument.java Fri Jun 12 21:53:17 2009
@@ -17,130 +17,74 @@
package org.apache.poi.hdf.model;
-
-import junit.framework.TestCase;
-
import java.io.FileInputStream;
+import java.io.FileNotFoundException;
import java.io.IOException;
+import java.io.InputStream;
+import junit.framework.TestCase;
/**
- * Class to test HDFDocument functionality
+ * Class to test {@link HDFDocument} functionality
*
* @author Bob Otterberg
*/
-public final class TestHDFDocument
- extends TestCase
-{
-
- public TestHDFDocument( String name )
- {
- super( name );
+public final class TestHDFDocument extends TestCase {
+ public void testStopJUnitComplainintAboutNoTests() {
+ // TODO - fix these junits
}
- public void testStopJUnitComplainintAboutNoTests()
- throws Exception
- {
-
+ private static InputStream openSample(String sampleFileName) {
+ String fullPathName = System.getProperty("HDF.testdata.path") + "/" + sampleFileName;
+ try {
+ return new FileInputStream(System.getProperty("HDF.testdata.path"));
+ } catch (FileNotFoundException e) {
+ throw new RuntimeException("Sample HDF file '" + fullPathName + "' was not found.");
+ }
}
/**
- * TEST NAME: Test Read Empty <P>
* OBJECTIVE: Test that HDF can read an empty document (empty.doc).<P>
* SUCCESS: HDF reads the document. Matches values in their particular positions.<P>
* FAILURE: HDF does not read the document or excepts. HDF cannot identify values
* in the document in their known positions.<P>
- *
*/
- public void fixme_testEmpty()
- throws IOException
- {
-
- String filename = System.getProperty( "HDF.testdata.path" );
-
-
- filename = filename + "/empty.doc";
-
- FileInputStream stream = new FileInputStream( filename );
-
- HDFDocument empty = new HDFDocument( stream );
-
- stream.close();
-
+ public void fixme_testEmpty() throws IOException {
+ InputStream stream = openSample("empty.doc");
+ new HDFDocument(stream);
}
-
/**
- * TEST NAME: Test Simple <P>
* OBJECTIVE: Test that HDF can read an _very_ simple document (simple.doc).<P>
* SUCCESS: HDF reads the document. Matches values in their particular positions.<P>
* FAILURE: HDF does not read the document or excepts. HDF cannot identify values
* in the document in their known positions.<P>
- *
*/
- public void fixme_testSimple()
- throws IOException
- {
- String filename = System.getProperty( "HDF.testdata.path" );
- filename = filename + "/simple.doc";
- FileInputStream stream = new FileInputStream( filename );
- HDFDocument empty = new HDFDocument( stream );
- stream.close();
+ public void fixme_testSimple() throws IOException {
+ InputStream stream = openSample("simple.doc");
+ new HDFDocument(stream);
}
/**
- * TEST NAME: Test Read Simple List <P>
* OBJECTIVE: Test that HDF can read a document containing a simple list (simple-list.doc).<P>
* SUCCESS: HDF reads the document. Matches values in their particular positions.<P>
* FAILURE: HDF does not read the document or excepts. HDF cannot identify values
* in the document in their known positions.<P>
*
*/
- public void fixme_testSimpleList()
- throws IOException
- {
- String filename = System.getProperty( "HDF.testdata.path" );
-
- filename = filename + "/simple-list.doc";
- FileInputStream stream = new FileInputStream( filename );
- HDFDocument empty = new HDFDocument( stream );
- stream.close();
+ public void fixme_testSimpleList() throws IOException {
+ InputStream stream = openSample("simple-list.doc");
+ new HDFDocument(stream);
}
/**
- * TEST NAME: Test Read Simple Table <P>
* OBJECTIVE: Test that HDF can read a document containing a simple table (simple-table.doc).<P>
* SUCCESS: HDF reads the document. Matches values in their particular positions.<P>
* FAILURE: HDF does not read the document or excepts. HDF cannot identify values
* in the document in their known positions.<P>
- *
*/
- public void fixme_testSimpleTable()
- throws IOException
- {
- String filename = System.getProperty( "HDF.testdata.path" );
-
- filename = filename + "/simple-table.doc";
- FileInputStream stream = new FileInputStream( filename );
- HDFDocument empty = new HDFDocument( stream );
- stream.close();
- }
-
- public static void main( String[] ignored_args )
- {
- String path = System.getProperty( "HDF.testdata.path" );
-
- // assume this is relative to basedir
- if ( path == null )
- {
- System.setProperty(
- "HDF.testdata.path",
- "src/scratchpad/testcases/org/apache/poi/hdf/data" );
- }
- System.out.println( "Testing org.apache.poi.hdf.model.HDFDocument" );
-
- junit.textui.TestRunner.run( TestHDFDocument.class );
+ public void fixme_testSimpleTable() throws IOException {
+ InputStream stream = openSample("simple-table.doc");
+ new HDFDocument(stream);
}
}
-
-
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestCHPBinTable.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestCHPBinTable.java?rev=784284&r1=784283&r2=784284&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestCHPBinTable.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestCHPBinTable.java Fri Jun 12 21:53:17 2009
@@ -33,11 +33,6 @@
private TextPieceTable fakeTPT = new TextPieceTable();
- public TestCHPBinTable(String name)
- {
- super(name);
- }
-
public void testReadWrite()
throws Exception
{
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestDocumentProperties.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestDocumentProperties.java?rev=784284&r1=784283&r2=784284&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestDocumentProperties.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestDocumentProperties.java Fri Jun 12 21:53:17 2009
@@ -29,12 +29,6 @@
private DocumentProperties _documentProperties = null;
private HWPFDocFixture _hWPFDocFixture;
- public TestDocumentProperties(String name)
- {
- super(name);
- }
-
-
public void testReadWrite()
throws Exception
{
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=784284&r1=784283&r2=784284&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 Fri Jun 12 21:53:17 2009
@@ -28,11 +28,6 @@
private FileInformationBlock _fileInformationBlock = null;
private HWPFDocFixture _hWPFDocFixture;
- public TestFileInformationBlock(String name)
- {
- super(name);
- }
-
public void testReadWrite()
throws Exception
{
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestFontTable.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestFontTable.java?rev=784284&r1=784283&r2=784284&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestFontTable.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestFontTable.java Fri Jun 12 21:53:17 2009
@@ -27,11 +27,6 @@
private FontTable _fontTable = null;
private HWPFDocFixture _hWPFDocFixture;
- public TestFontTable(String name)
- {
- super(name);
- }
-
public void testReadWrite()
throws Exception
{
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestPAPBinTable.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestPAPBinTable.java?rev=784284&r1=784283&r2=784284&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestPAPBinTable.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestPAPBinTable.java Fri Jun 12 21:53:17 2009
@@ -32,11 +32,6 @@
private TextPieceTable fakeTPT = new TextPieceTable();
- public TestPAPBinTable(String name)
- {
- super(name);
- }
-
public void testReadWrite()
throws Exception
{
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestPlexOfCps.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestPlexOfCps.java?rev=784284&r1=784283&r2=784284&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestPlexOfCps.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestPlexOfCps.java Fri Jun 12 21:53:17 2009
@@ -28,13 +28,7 @@
private PlexOfCps _plexOfCps = null;
private HWPFDocFixture _hWPFDocFixture;
- public TestPlexOfCps(String name)
- {
- super(name);
- }
- public void testWriteRead()
- throws Exception
- {
+ public void testWriteRead() {
_plexOfCps = new PlexOfCps(4);
int last = 0;
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestSectionTable.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestSectionTable.java?rev=784284&r1=784283&r2=784284&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestSectionTable.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestSectionTable.java Fri Jun 12 21:53:17 2009
@@ -30,11 +30,6 @@
{
private HWPFDocFixture _hWPFDocFixture;
- public TestSectionTable(String name)
- {
- super(name);
- }
-
public void testReadWrite()
throws Exception
{
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestStyleSheet.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestStyleSheet.java?rev=784284&r1=784283&r2=784284&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestStyleSheet.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestStyleSheet.java Fri Jun 12 21:53:17 2009
@@ -28,12 +28,6 @@
private StyleSheet _styleSheet = null;
private HWPFDocFixture _hWPFDocFixture;
-
- public TestStyleSheet(String name)
- {
- super(name);
- }
-
public void testReadWrite()
throws Exception
{
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=784284&r1=784283&r2=784284&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 Fri Jun 12 21:53:17 2009
@@ -33,11 +33,6 @@
private HWPFDocFixture _hWPFDocFixture;
private String dirname;
- public TestTextPieceTable(String name)
- {
- super(name);
- }
-
public void testReadWrite()
throws Exception
{
Modified: poi/trunk/src/testcases/org/apache/poi/hpsf/basic/TestBasic.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hpsf/basic/TestBasic.java?rev=784284&r1=784283&r2=784284&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hpsf/basic/TestBasic.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hpsf/basic/TestBasic.java Fri Jun 12 21:53:17 2009
@@ -43,11 +43,10 @@
*
* @author Rainer Klute (klute@rainer-klute.de)
*/
-public class TestBasic extends TestCase
-{
+public final class TestBasic extends TestCase {
- static final String POI_FS = "TestGermanWord90.doc";
- static final String[] POI_FILES = new String[]
+ private static final String POI_FS = "TestGermanWord90.doc";
+ private static final String[] POI_FILES = new String[]
{
"\005SummaryInformation",
"\005DocumentSummaryInformation",
@@ -55,42 +54,29 @@
"\001CompObj",
"1Table"
};
- static final int BYTE_ORDER = 0xfffe;
- static final int FORMAT = 0x0000;
- static final int OS_VERSION = 0x00020A04;
- static final byte[] CLASS_ID =
+ private static final int BYTE_ORDER = 0xfffe;
+ private static final int FORMAT = 0x0000;
+ private static final int OS_VERSION = 0x00020A04;
+ private static final byte[] CLASS_ID =
{
(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00
};
- static final int[] SECTION_COUNT =
+ private static final int[] SECTION_COUNT =
{1, 2};
- static final boolean[] IS_SUMMARY_INFORMATION =
+ private static final boolean[] IS_SUMMARY_INFORMATION =
{true, false};
- static final boolean[] IS_DOCUMENT_SUMMARY_INFORMATION =
- {false, true};
-
- POIFile[] poiFiles;
-
-
-
- /**
- * <p>Test case constructor.</p>
- *
- * @param name The test case's name.
- */
- public TestBasic(final String name)
- {
- super(name);
- }
+ private static final boolean[] IS_DOCUMENT_SUMMARY_INFORMATION =
+ {false, true};
+ private POIFile[] poiFiles;
/**
* <p>Read a the test file from the "data" directory.</p>
- *
+ *
* @exception FileNotFoundException if the file to be read does not exist.
* @exception IOException if any other I/O exception occurs.
*/
@@ -102,8 +88,6 @@
poiFiles = Util.readPOIFiles(data);
}
-
-
/**
* <p>Checks the names of the files in the POI filesystem. They
* are expected to be in a certain order.</p>
@@ -115,8 +99,6 @@
Assert.assertEquals(poiFiles[i].getName(), expected[i]);
}
-
-
/**
* <p>Tests whether property sets can be created from the POI
* files in the POI file system. This test case expects the first
@@ -125,9 +107,9 @@
* property sets. In the latter cases a {@link
* NoPropertySetStreamException} will be thrown when trying to
* create a {@link PropertySet}.</p>
- *
+ *
* @exception IOException if an I/O exception occurs.
- *
+ *
* @exception UnsupportedEncodingException if a character encoding is not
* supported.
*/
@@ -163,13 +145,11 @@
}
}
-
-
/**
* <p>Tests the {@link PropertySet} methods. The test file has two
* property sets: the first one is a {@link SummaryInformation},
* the second one is a {@link DocumentSummaryInformation}.</p>
- *
+ *
* @exception IOException if an I/O exception occurs
* @exception HPSFException if any HPSF exception occurs
*/
@@ -194,13 +174,11 @@
}
}
-
-
/**
* <p>Tests the {@link Section} methods. The test file has two
* property sets: the first one is a {@link SummaryInformation},
* the second one is a {@link DocumentSummaryInformation}.</p>
- *
+ *
* @exception IOException if an I/O exception occurs
* @exception HPSFException if any HPSF exception occurs
*/
@@ -218,21 +196,4 @@
Assert.assertEquals("Titel", s.getProperty(2));
Assert.assertEquals(1748, s.getSize());
}
-
-
-
- /**
- * <p>Runs the test cases stand-alone.</p>
- *
- * @param args Command-line arguments (ignored)
- *
- * @exception Throwable if any sort of exception or error occurs
- */
- public static void main(final String[] args) throws Throwable
- {
- System.setProperty("HPSF.testdata.path",
- "./src/testcases/org/apache/poi/hpsf/data");
- junit.textui.TestRunner.run(TestBasic.class);
- }
-
}
Modified: poi/trunk/src/testcases/org/apache/poi/hpsf/basic/TestClassID.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hpsf/basic/TestClassID.java?rev=784284&r1=784283&r2=784284&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hpsf/basic/TestClassID.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hpsf/basic/TestClassID.java Fri Jun 12 21:53:17 2009
@@ -14,7 +14,6 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
package org.apache.poi.hpsf.basic;
@@ -31,17 +30,7 @@
*
* @author Michael Zalewski (zalewski@optonline.net)
*/
-public class TestClassID extends TestCase
-{
- /**
- * <p>Constructor</p>
- *
- * @param name the test case's name
- */
- public TestClassID(final String name)
- {
- super(name);
- }
+public final class TestClassID extends TestCase {
/**
* Various tests of overridden .equals()
@@ -130,19 +119,4 @@
"{04030201-0605-0807-090A-0B0C0D0E0F10}"
);
}
-
-
-
- /**
- * <p>Runs the test cases stand-alone.</p>
- *
- * @param args Command-line parameters (ignored)
- */
- public static void main(final String[] args)
- {
- System.setProperty("HPSF.testdata.path",
- "./src/testcases/org/apache/poi/hpsf/data");
- junit.textui.TestRunner.run(TestClassID.class);
- }
-
}
Modified: poi/trunk/src/testcases/org/apache/poi/hpsf/basic/TestEmptyProperties.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hpsf/basic/TestEmptyProperties.java?rev=784284&r1=784283&r2=784284&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hpsf/basic/TestEmptyProperties.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hpsf/basic/TestEmptyProperties.java Fri Jun 12 21:53:17 2009
@@ -43,37 +43,22 @@
* @author Rainer Klute <a
* href="mailto:klute@rainer-klute.de"><klute@rainer-klute.de></a>
*/
-public class TestEmptyProperties extends TestCase
-{
+public final class TestEmptyProperties extends TestCase {
/**
* <p>This test file's summary information stream contains some empty
* properties.</p>
*/
- static final String POI_FS = "TestCorel.shw";
+ private static final String POI_FS = "TestCorel.shw";
- static final String[] POI_FILES = new String[]
+ private static final String[] POI_FILES = new String[]
{
"PerfectOffice_MAIN",
"\005SummaryInformation",
"Main"
};
- POIFile[] poiFiles;
-
-
-
- /**
- * <p>Constructor</p>
- *
- * @param name The name of the test case
- */
- public TestEmptyProperties(final String name)
- {
- super(name);
- }
-
-
+ private POIFile[] poiFiles;
/**
* <p>Read a the test file from the "data" directory.</p>
@@ -91,8 +76,6 @@
poiFiles = Util.readPOIFiles(data);
}
-
-
/**
* <p>Checks the names of the files in the POI filesystem. They
* are expected to be in a certain order.</p>
@@ -104,8 +87,6 @@
Assert.assertEquals(poiFiles[i].getName(), expected[i]);
}
-
-
/**
* <p>Tests whether property sets can be created from the POI
* files in the POI file system. This test case expects the first
@@ -114,15 +95,15 @@
* property sets. In the latter cases a {@link
* NoPropertySetStreamException} will be thrown when trying to
* create a {@link PropertySet}.</p>
- *
+ *
* @exception IOException if an I/O exception occurs.
- *
+ *
* @exception UnsupportedEncodingException if a character encoding is not
* supported.
*/
public void testCreatePropertySets()
throws UnsupportedEncodingException, IOException
- {
+ {
Class[] expected = new Class[]
{
NoPropertySetStreamException.class,
@@ -150,13 +131,11 @@
}
}
-
-
/**
* <p>Tests the {@link PropertySet} methods. The test file has two
* property sets: the first one is a {@link SummaryInformation},
* the second one is a {@link DocumentSummaryInformation}.</p>
- *
+ *
* @exception IOException if an I/O exception occurs
* @exception HPSFException if an HPSF operation fails
*/
@@ -184,21 +163,4 @@
assertNull(s.getThumbnail());
assertNull(s.getApplicationName());
}
-
-
-
- /**
- * <p>Runs the test cases stand-alone.</p>
- *
- * @param args the command-line arguments (unused)
- *
- * @exception Throwable if any exception or error occurs
- */
- public static void main(final String[] args) throws Throwable
- {
- System.setProperty("HPSF.testdata.path",
- "./src/testcases/org/apache/poi/hpsf/data");
- junit.textui.TestRunner.run(TestBasic.class);
- }
-
}
Modified: poi/trunk/src/testcases/org/apache/poi/hssf/eventmodel/TestModelFactory.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/eventmodel/TestModelFactory.java?rev=784284&r1=784283&r2=784284&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/eventmodel/TestModelFactory.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/eventmodel/TestModelFactory.java Fri Jun 12 21:53:17 2009
@@ -36,41 +36,25 @@
import junit.framework.TestCase;
/**
- * Tests the ModelFactory.
- *
+ * Tests the ModelFactory.
+ *
* @author Andrew C. Oliver acoliver@apache.org
*/
-public class TestModelFactory extends TestCase
-{
+public class TestModelFactory extends TestCase {
private ModelFactory factory;
private HSSFWorkbook book;
private InputStream in;
private List models;
- /**
- * Tests that the listeners collection is created
- * @param arg0
- */
- public TestModelFactory(String arg0)
+ protected void setUp() throws Exception
{
- super(arg0);
ModelFactory mf = new ModelFactory();
assertTrue("listeners member cannot be null", mf.listeners != null);
- assertTrue("listeners member must be a List", mf.listeners instanceof List);
- }
-
- public static void main(String[] args)
- {
- junit.textui.TestRunner.run(TestModelFactory.class);
- }
-
- protected void setUp() throws Exception
- {
- super.setUp();
+ assertTrue("listeners member must be a List", mf.listeners instanceof List);
models = new ArrayList(3);
factory = new ModelFactory();
book = new HSSFWorkbook();
- ByteArrayOutputStream stream = (ByteArrayOutputStream)setupRunFile(book);
+ ByteArrayOutputStream stream = (ByteArrayOutputStream)setupRunFile(book);
POIFSFileSystem fs = new POIFSFileSystem(
new ByteArrayInputStream(stream.toByteArray())
);
@@ -91,9 +75,9 @@
public void testRegisterListener()
{
if (factory.listeners.size() != 0) {
- factory = new ModelFactory();
+ factory = new ModelFactory();
}
-
+
factory.registerListener(new MFListener(null));
factory.registerListener(new MFListener(null));
assertTrue("Factory listeners should be two, was="+
@@ -109,29 +93,29 @@
{
Model temp = null;
Iterator mi = null;
-
+
if (factory.listeners.size() != 0) {
- factory = new ModelFactory();
+ factory = new ModelFactory();
}
-
+
factory.registerListener(new MFListener(models));
factory.run(in);
-
+
assertTrue("Models size must be 2 was = "+models.size(),
models.size() == 2);
- mi = models.iterator();
+ mi = models.iterator();
temp = (Model)mi.next();
-
+
assertTrue("First model is Workbook was " + temp.getClass().getName(),
temp instanceof Workbook);
-
+
temp = (Model)mi.next();
-
+
assertTrue("Second model is Sheet was " + temp.getClass().getName(),
temp instanceof Sheet);
-
+
}
-
+
/**
* Sets up a test file
*/
@@ -153,17 +137,16 @@
class MFListener implements ModelFactoryListener {
private List mlist;
public MFListener(List mlist) {
- this.mlist = mlist;
+ this.mlist = mlist;
}
-
+
public boolean process(Model model)
{
- mlist.add(model);
+ mlist.add(model);
return true;
}
-
+
public Iterator models() {
- return mlist.iterator();
+ return mlist.iterator();
}
-
-}
\ No newline at end of file
+}
Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestCFRuleRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestCFRuleRecord.java?rev=784284&r1=784283&r2=784284&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestCFRuleRecord.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestCFRuleRecord.java Fri Jun 12 21:53:17 2009
@@ -27,22 +27,19 @@
import org.apache.poi.hssf.record.formula.Ptg;
import org.apache.poi.hssf.record.formula.RefNPtg;
import org.apache.poi.hssf.record.formula.RefPtg;
-import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.hssf.usermodel.HSSFSheet;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.hssf.util.HSSFColor;
import org.apache.poi.util.LittleEndian;
-import org.apache.poi.ss.formula.Formula;
/**
* Tests the serialization and deserialization of the TestCFRuleRecord
* class works correctly.
*
- * @author Dmitriy Kumshayev
+ * @author Dmitriy Kumshayev
*/
-public final class TestCFRuleRecord extends TestCase
-{
- public void testConstructors ()
- {
+public final class TestCFRuleRecord extends TestCase {
+ public void testConstructors () {
HSSFWorkbook workbook = new HSSFWorkbook();
HSSFSheet sheet = workbook.createSheet();
@@ -65,8 +62,7 @@
assertSame(Ptg.EMPTY_PTG_ARRAY, rule3.getParsedExpression2());
}
- public void testCreateCFRuleRecord ()
- {
+ public void testCreateCFRuleRecord() {
HSSFWorkbook workbook = new HSSFWorkbook();
HSSFSheet sheet = workbook.createSheet();
CFRuleRecord record = CFRuleRecord.create(sheet, "7");
@@ -94,8 +90,7 @@
}
}
- private void testCFRuleRecord(CFRuleRecord record)
- {
+ private void testCFRuleRecord(CFRuleRecord record) {
FontFormatting fontFormatting = new FontFormatting();
testFontFormattingAccessors(fontFormatting);
assertFalse(record.containsFontFormattingBlock());
@@ -152,8 +147,7 @@
assertTrue(record.isPatternStyleModified());
}
- private void testPatternFormattingAccessors(PatternFormatting patternFormatting)
- {
+ private void testPatternFormattingAccessors(PatternFormatting patternFormatting) {
patternFormatting.setFillBackgroundColor(HSSFColor.GREEN.index);
assertEquals(HSSFColor.GREEN.index,patternFormatting.getFillBackgroundColor());
@@ -164,8 +158,7 @@
assertEquals(PatternFormatting.DIAMONDS,patternFormatting.getFillPattern());
}
- private void testBorderFormattingAccessors(BorderFormatting borderFormatting)
- {
+ private void testBorderFormattingAccessors(BorderFormatting borderFormatting) {
borderFormatting.setBackwardDiagonalOn(false);
assertFalse(borderFormatting.isBackwardDiagonalOn());
borderFormatting.setBackwardDiagonalOn(true);
@@ -207,8 +200,7 @@
}
- private void testFontFormattingAccessors(FontFormatting fontFormatting)
- {
+ private void testFontFormattingAccessors(FontFormatting fontFormatting) {
// Check for defaults
assertFalse(fontFormatting.isEscapementTypeModified());
assertFalse(fontFormatting.isFontCancellationModified());
@@ -357,31 +349,6 @@
assertTrue(refNPtg.isRowRelative());
byte[] data = rr.serialize();
-
- if (!compareArrays(DATA_REFN, 0, data, 4, DATA_REFN.length)) {
- fail("Did not re-serialize correctly");
- }
- }
-
- private static boolean compareArrays(byte[] arrayA, int offsetA, byte[] arrayB, int offsetB, int length) {
-
- if (offsetA + length > arrayA.length) {
- return false;
- }
- if (offsetB + length > arrayB.length) {
- return false;
- }
- for (int i = 0; i < length; i++) {
- if (arrayA[i+offsetA] != arrayB[i+offsetB]) {
- return false;
- }
- }
- return true;
- }
-
- public static void main(String[] ignored_args)
- {
- System.out.println("Testing org.apache.poi.hssf.record.CFRuleRecord");
- junit.textui.TestRunner.run(TestCFRuleRecord.class);
+ TestcaseRecordInputStream.confirmRecordEncoding(CFRuleRecord.sid, DATA_REFN, data);
}
}
Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestPaletteRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestPaletteRecord.java?rev=784284&r1=784283&r2=784284&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestPaletteRecord.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestPaletteRecord.java Fri Jun 12 21:53:17 2009
@@ -1,4 +1,3 @@
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
@@ -15,7 +14,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
package org.apache.poi.hssf.record;
import java.util.Iterator;
@@ -28,20 +27,14 @@
*
* @author Brian Sanders (bsanders at risklabs dot com)
*/
-public class TestPaletteRecord extends TestCase
-{
- public TestPaletteRecord(String name)
- {
- super(name);
- }
-
+public final class TestPaletteRecord extends TestCase {
+
/**
* Tests that the default palette matches the constants of HSSFColor
*/
- public void testDefaultPalette()
- {
+ public void testDefaultPalette() {
PaletteRecord palette = new PaletteRecord();
-
+
//make sure all the HSSFColor constants match
Map colors = HSSFColor.getIndexHash();
Iterator indexes = colors.keySet().iterator();
Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/chart/TestAxisOptionsRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/chart/TestAxisOptionsRecord.java?rev=784284&r1=784283&r2=784284&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/chart/TestAxisOptionsRecord.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/chart/TestAxisOptionsRecord.java Fri Jun 12 21:53:17 2009
@@ -31,7 +31,7 @@
* @author Andrew C. Oliver(acoliver at apache.org)
*/
public final class TestAxisOptionsRecord extends TestCase {
- byte[] data = new byte[] {
+ private static final byte[] data = {
(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x01,
(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x01,(byte)0x00,
(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,
@@ -88,14 +88,4 @@
for (int i = 0; i < data.length; i++)
assertEquals("At offset " + i, data[i], recordBytes[i+4]);
}
-
- /**
- * The main program for the TestAxisOptionsRecord class
- *
- *@param args The command line arguments
- */
- public static void main(String[] args) {
- System.out.println("Testing org.apache.poi.hssf.record.AxisOptionsRecord");
- junit.textui.TestRunner.run(TestAxisOptionsRecord.class);
- }
}
Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/chart/TestTickRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/chart/TestTickRecord.java?rev=784284&r1=784283&r2=784284&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/chart/TestTickRecord.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/chart/TestTickRecord.java Fri Jun 12 21:53:17 2009
@@ -27,18 +27,17 @@
* class works correctly. Test data taken directly from a real
* Excel file.
*
-
* @author Andrew C. Oliver(acoliver at apache.org)
*/
public final class TestTickRecord extends TestCase {
- byte[] data = new byte[] {
- (byte)0x02, (byte)0x00, (byte)0x03, (byte)0x01,
+ private static final byte[] data = {
+ (byte)0x02, (byte)0x00, (byte)0x03, (byte)0x01,
(byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
- (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
- (byte)0x00, (byte)0x00, (byte)0x00,
- (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
- (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x23, (byte)0x00,
- (byte)0x4D, (byte)0x00, (byte)0x00, (byte)0x00
+ (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
+ (byte)0x00, (byte)0x00, (byte)0x00,
+ (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
+ (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x23, (byte)0x00,
+ (byte)0x4D, (byte)0x00, (byte)0x00, (byte)0x00
};
public void testLoad() {
@@ -62,8 +61,7 @@
assertEquals( 34, record.getRecordSize() );
}
- public void testStore()
- {
+ public void testStore() {
TickRecord record = new TickRecord();
record.setMajorTickType( (byte)2 );
record.setMinorTickType( (byte)0 );
@@ -86,16 +84,4 @@
for (int i = 0; i < data.length; i++)
assertEquals("At offset " + i, data[i], recordBytes[i+4]);
}
-
-
- /**
- * The main program for the TestTickRecord class
- *
- *@param args The command line arguments
- */
- public static void main(String[] args) {
- System.out.println("Testing org.apache.poi.hssf.record.TickRecord");
- junit.textui.TestRunner.run(TestTickRecord.class);
- }
-
}
Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestReadWriteChart.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestReadWriteChart.java?rev=784284&r1=784283&r2=784284&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestReadWriteChart.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestReadWriteChart.java Fri Jun 12 21:53:17 2009
@@ -52,13 +52,7 @@
Sheet newSheet = workbook.getSheetAt(0).getSheet();
List records = newSheet.getRecords();
- //System.out.println("BOF Assertion");
assertTrue(records.get(0) instanceof BOFRecord);
- //System.out.println("EOF Assertion");
assertTrue(records.get(records.size() - 1) instanceof EOFRecord);
}
-
- public static void main(String [] args) {
- junit.textui.TestRunner.run(TestReadWriteChart.class);
- }
}
Modified: poi/trunk/src/testcases/org/apache/poi/poifs/eventfilesystem/TestPOIFSReaderRegistry.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/poifs/eventfilesystem/TestPOIFSReaderRegistry.java?rev=784284&r1=784283&r2=784284&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/poifs/eventfilesystem/TestPOIFSReaderRegistry.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/poifs/eventfilesystem/TestPOIFSReaderRegistry.java Fri Jun 12 21:53:17 2009
@@ -1,4 +1,3 @@
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
@@ -15,13 +14,14 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
package org.apache.poi.poifs.eventfilesystem;
-import junit.framework.*;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
-import java.util.*;
+import junit.framework.TestCase;
import org.apache.poi.poifs.filesystem.POIFSDocumentPath;
@@ -30,10 +30,7 @@
*
* @author Marc Johnson
*/
-
-public class TestPOIFSReaderRegistry
- extends TestCase
-{
+public final class TestPOIFSReaderRegistry extends TestCase {
private POIFSReaderListener[] listeners =
{
new Listener(), new Listener(), new Listener(), new Listener()
@@ -57,22 +54,9 @@
};
/**
- * Constructor TestPOIFSReaderRegistry
- *
- * @param name
- */
-
- public TestPOIFSReaderRegistry(String name)
- {
- super(name);
- }
-
- /**
* Test empty registry
*/
-
- public void testEmptyRegistry()
- {
+ public void testEmptyRegistry() {
POIFSReaderRegistry registry = new POIFSReaderRegistry();
for (int j = 0; j < paths.length; j++)
@@ -90,9 +74,7 @@
/**
* Test mixed registration operations
*/
-
- public void testMixedRegistrationOperations()
- {
+ public void testMixedRegistrationOperations() {
POIFSReaderRegistry registry = new POIFSReaderRegistry();
for (int j = 0; j < listeners.length; j++)
@@ -172,17 +154,4 @@
}
}
}
-
- /**
- * main method to run the unit tests
- *
- * @param ignored_args
- */
-
- public static void main(String [] ignored_args)
- {
- System.out.println(
- "Testing org.apache.poi.poifs.eventfilesystem.POIFSReaderRegistry");
- junit.textui.TestRunner.run(TestPOIFSReaderRegistry.class);
- }
}
Modified: poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestDirectoryNode.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestDirectoryNode.java?rev=784284&r1=784283&r2=784284&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestDirectoryNode.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestDirectoryNode.java Fri Jun 12 21:53:17 2009
@@ -15,7 +15,6 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
package org.apache.poi.poifs.filesystem;
@@ -33,31 +32,12 @@
*
* @author Marc Johnson
*/
-
-public class TestDirectoryNode
- extends TestCase
-{
-
- /**
- * Constructor TestDirectoryNode
- *
- * @param name
- */
-
- public TestDirectoryNode(String name)
- {
- super(name);
- }
+public final class TestDirectoryNode extends TestCase {
/**
* test trivial constructor (a DirectoryNode with no children)
- *
- * @exception IOException
*/
-
- public void testEmptyConstructor()
- throws IOException
- {
+ public void testEmptyConstructor() {
POIFSFileSystem fs = new POIFSFileSystem();
DirectoryProperty property1 = new DirectoryProperty("parent");
DirectoryProperty property2 = new DirectoryProperty("child");
@@ -113,13 +93,8 @@
/**
* test non-trivial constructor (a DirectoryNode with children)
- *
- * @exception IOException
*/
-
- public void testNonEmptyConstructor()
- throws IOException
- {
+ public void testNonEmptyConstructor() throws IOException {
DirectoryProperty property1 = new DirectoryProperty("parent");
DirectoryProperty property2 = new DirectoryProperty("child1");
@@ -177,13 +152,8 @@
/**
* test deletion methods
- *
- * @exception IOException
*/
-
- public void testDeletion()
- throws IOException
- {
+ public void testDeletion() throws IOException {
POIFSFileSystem fs = new POIFSFileSystem();
DirectoryEntry root = fs.getRoot();
@@ -213,13 +183,8 @@
/**
* test change name methods
- *
- * @exception IOException
*/
-
- public void testRename()
- throws IOException
- {
+ public void testRename() throws IOException {
POIFSFileSystem fs = new POIFSFileSystem();
DirectoryEntry root = fs.getRoot();
@@ -237,17 +202,4 @@
assertTrue(dir2.renameTo("foo"));
assertEquals("foo", dir2.getName());
}
-
- /**
- * main method to run the unit tests
- *
- * @param ignored_args
- */
-
- public static void main(String [] ignored_args)
- {
- System.out
- .println("Testing org.apache.poi.poifs.filesystem.DirectoryNode");
- junit.textui.TestRunner.run(TestDirectoryNode.class);
- }
}
Modified: poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestDocument.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestDocument.java?rev=784284&r1=784283&r2=784284&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestDocument.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestDocument.java Fri Jun 12 21:53:17 2009
@@ -1,4 +1,3 @@
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
@@ -15,18 +14,15 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
package org.apache.poi.poifs.filesystem;
-import java.io.*;
-
-import java.util.*;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
-import junit.framework.*;
+import junit.framework.TestCase;
-import org.apache.poi.util.LittleEndian;
-import org.apache.poi.util.LittleEndianConsts;
import org.apache.poi.poifs.property.DocumentProperty;
import org.apache.poi.poifs.storage.RawDataBlock;
import org.apache.poi.poifs.storage.SmallDocumentBlock;
@@ -36,31 +32,12 @@
*
* @author Marc Johnson
*/
-
-public class TestDocument
- extends TestCase
-{
-
- /**
- * Constructor TestDocument
- *
- * @param name
- */
-
- public TestDocument(String name)
- {
- super(name);
- }
+public final class TestDocument extends TestCase {
/**
* Integration test -- really about all we can do
- *
- * @exception IOException
*/
-
- public void testPOIFSDocument()
- throws IOException
- {
+ public void testPOIFSDocument() throws IOException {
// verify correct number of blocks get created for document
// that is exact multituple of block size
@@ -158,10 +135,8 @@
}
}
- private POIFSDocument makeCopy(POIFSDocument document, byte [] input,
- byte [] data)
- throws IOException
- {
+ private static POIFSDocument makeCopy(POIFSDocument document, byte[] input, byte[] data)
+ throws IOException {
POIFSDocument copy = null;
if (input.length >= 4096)
@@ -194,10 +169,8 @@
return copy;
}
- private void checkDocument(final POIFSDocument document,
- final byte [] input)
- throws IOException
- {
+ private static void checkDocument(final POIFSDocument document, final byte[] input)
+ throws IOException {
int big_blocks = 0;
int small_blocks = 0;
int total_output = 0;
@@ -221,11 +194,8 @@
input)), input);
}
- private byte [] checkValues(int big_blocks, int small_blocks,
- int total_output, POIFSDocument document,
- byte [] input)
- throws IOException
- {
+ private static byte[] checkValues(int big_blocks, int small_blocks, int total_output,
+ POIFSDocument document, byte[] input) throws IOException {
assertEquals(document, document.getDocumentProperty().getDocument());
int increment = ( int ) Math.sqrt(input.length);
@@ -267,17 +237,4 @@
}
return output;
}
-
- /**
- * main method to run the unit tests
- *
- * @param ignored_args
- */
-
- public static void main(String [] ignored_args)
- {
- System.out
- .println("Testing org.apache.poi.poifs.filesystem.POIFSDocument");
- junit.textui.TestRunner.run(TestDocument.class);
- }
}
Modified: poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestDocumentDescriptor.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestDocumentDescriptor.java?rev=784284&r1=784283&r2=784284&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestDocumentDescriptor.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestDocumentDescriptor.java Fri Jun 12 21:53:17 2009
@@ -1,4 +1,3 @@
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
@@ -15,53 +14,30 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
package org.apache.poi.poifs.filesystem;
-import junit.framework.*;
+import junit.framework.TestCase;
/**
* Class to test DocumentDescriptor functionality
*
* @author Marc Johnson
*/
-
-public class TestDocumentDescriptor
- extends TestCase
-{
-
- /**
- * Constructor TestDocumentDescriptor
- *
- * @param name
- */
-
- public TestDocumentDescriptor(String name)
- {
- super(name);
- }
+public final class TestDocumentDescriptor extends TestCase {
/**
* test equality
*/
-
- public void testEquality()
- {
- String[] names =
- {
- "c1", "c2", "c3", "c4", "c5"
- };
+ public void testEquality() {
+ String[] names = { "c1", "c2", "c3", "c4", "c5" };
POIFSDocumentPath a1 = new POIFSDocumentPath();
POIFSDocumentPath a2 = new POIFSDocumentPath(null);
POIFSDocumentPath a3 = new POIFSDocumentPath(new String[ 0 ]);
POIFSDocumentPath a4 = new POIFSDocumentPath(a1, null);
POIFSDocumentPath a5 = new POIFSDocumentPath(a1,
new String[ 0 ]);
- POIFSDocumentPath[] paths =
- {
- a1, a2, a3, a4, a5
- };
+ POIFSDocumentPath[] paths = { a1, a2, a3, a4, a5 };
for (int j = 0; j < paths.length; j++)
{
@@ -196,17 +172,4 @@
}
}
}
-
- /**
- * main method to run the unit tests
- *
- * @param ignored_args
- */
-
- public static void main(String [] ignored_args)
- {
- System.out.println(
- "Testing org.apache.poi.poifs.eventfilesystem.DocumentDescriptor");
- junit.textui.TestRunner.run(TestDocumentDescriptor.class);
- }
}
Modified: poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestDocumentNode.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestDocumentNode.java?rev=784284&r1=784283&r2=784284&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestDocumentNode.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestDocumentNode.java Fri Jun 12 21:53:17 2009
@@ -15,7 +15,6 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
package org.apache.poi.poifs.filesystem;
@@ -32,31 +31,12 @@
*
* @author Marc Johnson
*/
-
-public class TestDocumentNode
- extends TestCase
-{
-
- /**
- * Constructor TestDocumentNode
- *
- * @param name
- */
-
- public TestDocumentNode(String name)
- {
- super(name);
- }
+public final class TestDocumentNode extends TestCase {
/**
* test constructor
- *
- * @exception IOException
*/
-
- public void testConstructor()
- throws IOException
- {
+ public void testConstructor() throws IOException {
DirectoryProperty property1 = new DirectoryProperty("directory");
RawDataBlock[] rawBlocks = new RawDataBlock[ 4 ];
ByteArrayInputStream stream =
@@ -90,17 +70,4 @@
// verify getParent behaves correctly
assertEquals(parent, node.getParent());
}
-
- /**
- * main method to run the unit tests
- *
- * @param ignored_args
- */
-
- public static void main(String [] ignored_args)
- {
- System.out
- .println("Testing org.apache.poi.poifs.filesystem.DocumentNode");
- junit.textui.TestRunner.run(TestDocumentNode.class);
- }
}
Modified: poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestDocumentOutputStream.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestDocumentOutputStream.java?rev=784284&r1=784283&r2=784284&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestDocumentOutputStream.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestDocumentOutputStream.java Fri Jun 12 21:53:17 2009
@@ -15,53 +15,26 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
package org.apache.poi.poifs.filesystem;
-import java.io.*;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Arrays;
-import java.util.*;
-
-import junit.framework.*;
-
-import org.apache.poi.poifs.property.DirectoryProperty;
-import org.apache.poi.poifs.property.DocumentProperty;
-import org.apache.poi.poifs.storage.RawDataBlock;
+import junit.framework.TestCase;
/**
* Class to test DocumentOutputStream functionality
*
* @author Marc Johnson
*/
-
-public class TestDocumentOutputStream
- extends TestCase
-{
-
- /**
- * Constructor TestDocumentOutputStream
- *
- * @param name
- *
- * @exception IOException
- */
-
- public TestDocumentOutputStream(String name)
- throws IOException
- {
- super(name);
- }
+public final class TestDocumentOutputStream extends TestCase {
/**
* test write(int) behavior
- *
- * @exception IOException
*/
-
- public void testWrite1()
- throws IOException
- {
+ public void testWrite1() throws IOException {
ByteArrayOutputStream stream = new ByteArrayOutputStream();
DocumentOutputStream dstream = new DocumentOutputStream(stream, 25);
@@ -89,13 +62,8 @@
/**
* test write(byte[]) behavior
- *
- * @exception IOException
*/
-
- public void testWrite2()
- throws IOException
- {
+ public void testWrite2() throws IOException {
ByteArrayOutputStream stream = new ByteArrayOutputStream();
DocumentOutputStream dstream = new DocumentOutputStream(stream, 25);
@@ -133,13 +101,8 @@
/**
* test write(byte[], int, int) behavior
- *
- * @exception IOException
*/
-
- public void testWrite3()
- throws IOException
- {
+ public void testWrite3() throws IOException {
ByteArrayOutputStream stream = new ByteArrayOutputStream();
DocumentOutputStream dstream = new DocumentOutputStream(stream, 25);
byte[] array = new byte[ 50 ];
@@ -169,13 +132,8 @@
/**
* test writeFiller()
- *
- * @exception IOException
*/
-
- public void testWriteFiller()
- throws IOException
- {
+ public void testWriteFiller() throws IOException {
ByteArrayOutputStream stream = new ByteArrayOutputStream();
DocumentOutputStream dstream = new DocumentOutputStream(stream, 25);
@@ -205,17 +163,4 @@
}
stream.close();
}
-
- /**
- * main method to run the unit tests
- *
- * @param ignored_args
- */
-
- public static void main(String [] ignored_args)
- {
- System.out.println(
- "Testing org.apache.poi.poifs.filesystem.DocumentOutputStream");
- junit.textui.TestRunner.run(TestDocumentOutputStream.class);
- }
}
Modified: poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestEmptyDocument.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestEmptyDocument.java?rev=784284&r1=784283&r2=784284&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestEmptyDocument.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestEmptyDocument.java Fri Jun 12 21:53:17 2009
@@ -30,143 +30,88 @@
import org.apache.poi.poifs.filesystem.POIFSWriterListener;
import org.apache.poi.poifs.filesystem.DirectoryEntry;
-public class TestEmptyDocument extends TestCase {
+public final class TestEmptyDocument extends TestCase {
- public static void main(String[] args) {
- TestEmptyDocument driver = new TestEmptyDocument();
-
- System.out.println();
- System.out.println("As only file...");
- System.out.println();
-
- System.out.print("Trying using createDocument(String,InputStream): ");
- try {
- driver.testSingleEmptyDocument();
- System.out.println("Worked!");
- } catch (IOException exception) {
- System.out.println("failed! ");
- System.out.println(exception.toString());
- }
- System.out.println();
-
- System.out.print
- ("Trying using createDocument(String,int,POIFSWriterListener): ");
- try {
- driver.testSingleEmptyDocumentEvent();
- System.out.println("Worked!");
- } catch (IOException exception) {
- System.out.println("failed!");
- System.out.println(exception.toString());
- }
- System.out.println();
-
- System.out.println();
- System.out.println("After another file...");
- System.out.println();
-
- System.out.print("Trying using createDocument(String,InputStream): ");
- try {
- driver.testEmptyDocumentWithFriend();
- System.out.println("Worked!");
- } catch (IOException exception) {
- System.out.println("failed! ");
- System.out.println(exception.toString());
- }
- System.out.println();
-
- System.out.print
- ("Trying using createDocument(String,int,POIFSWriterListener): ");
- try {
- driver.testEmptyDocumentWithFriend();
- System.out.println("Worked!");
- } catch (IOException exception) {
- System.out.println("failed!");
- System.out.println(exception.toString());
- }
- System.out.println();
- }
-
- public void testSingleEmptyDocument() throws IOException {
- POIFSFileSystem fs = new POIFSFileSystem();
- DirectoryEntry dir = fs.getRoot();
- dir.createDocument("Foo", new ByteArrayInputStream(new byte[] { }));
-
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- fs.writeFilesystem(out);
- new POIFSFileSystem(new ByteArrayInputStream(out.toByteArray()));
- }
-
- public void testSingleEmptyDocumentEvent() throws IOException {
- POIFSFileSystem fs = new POIFSFileSystem();
- DirectoryEntry dir = fs.getRoot();
- dir.createDocument("Foo", 0, new POIFSWriterListener() {
- public void processPOIFSWriterEvent(POIFSWriterEvent event) {
- System.out.println("written");
- }
- });
-
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- fs.writeFilesystem(out);
- new POIFSFileSystem(new ByteArrayInputStream(out.toByteArray()));
- }
-
- public void testEmptyDocumentWithFriend() throws IOException {
- POIFSFileSystem fs = new POIFSFileSystem();
- DirectoryEntry dir = fs.getRoot();
- dir.createDocument("Bar", new ByteArrayInputStream(new byte[] { 0 }));
- dir.createDocument("Foo", new ByteArrayInputStream(new byte[] { }));
-
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- fs.writeFilesystem(out);
- new POIFSFileSystem(new ByteArrayInputStream(out.toByteArray()));
- }
-
- public void testEmptyDocumentEventWithFriend() throws IOException {
- POIFSFileSystem fs = new POIFSFileSystem();
- DirectoryEntry dir = fs.getRoot();
- dir.createDocument("Bar", 1, new POIFSWriterListener() {
- public void processPOIFSWriterEvent(POIFSWriterEvent event) {
- try {
- event.getStream().write(0);
- } catch (IOException exception) {
- throw new RuntimeException("exception on write: " + exception);
- }
- }
- });
- dir.createDocument("Foo", 0, new POIFSWriterListener() {
- public void processPOIFSWriterEvent(POIFSWriterEvent event) {
- }
- });
-
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- fs.writeFilesystem(out);
- new POIFSFileSystem(new ByteArrayInputStream(out.toByteArray()));
- }
-
- public void testEmptyDocumentBug11744() throws Exception {
- byte[] testData = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
-
- POIFSFileSystem fs = new POIFSFileSystem();
- fs.createDocument(new ByteArrayInputStream(new byte[0]), "Empty");
- fs.createDocument(new ByteArrayInputStream(testData), "NotEmpty");
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- fs.writeFilesystem(out);
- out.toByteArray();
-
- // This line caused the error.
- fs = new POIFSFileSystem(new ByteArrayInputStream(out.toByteArray()));
-
- DocumentEntry entry = (DocumentEntry) fs.getRoot().getEntry("Empty");
- assertEquals("Expected zero size", 0, entry.getSize());
- byte[] actualReadbackData;
- actualReadbackData = IOUtils.toByteArray(new DocumentInputStream(entry));
- assertEquals("Expected zero read from stream", 0,
- actualReadbackData.length);
-
- entry = (DocumentEntry) fs.getRoot().getEntry("NotEmpty");
- actualReadbackData = IOUtils.toByteArray(new DocumentInputStream(entry));
- assertEquals("Expected size was wrong", testData.length, entry.getSize());
- assertTrue("Expected different data read from stream",
- Arrays.equals(testData, actualReadbackData));
- }
+ public void testSingleEmptyDocument() throws IOException {
+ POIFSFileSystem fs = new POIFSFileSystem();
+ DirectoryEntry dir = fs.getRoot();
+ dir.createDocument("Foo", new ByteArrayInputStream(new byte[] {}));
+
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ fs.writeFilesystem(out);
+ new POIFSFileSystem(new ByteArrayInputStream(out.toByteArray()));
+ }
+
+ public void testSingleEmptyDocumentEvent() throws IOException {
+ POIFSFileSystem fs = new POIFSFileSystem();
+ DirectoryEntry dir = fs.getRoot();
+ dir.createDocument("Foo", 0, new POIFSWriterListener() {
+ public void processPOIFSWriterEvent(POIFSWriterEvent event) {
+ System.out.println("written");
+ }
+ });
+
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ fs.writeFilesystem(out);
+ new POIFSFileSystem(new ByteArrayInputStream(out.toByteArray()));
+ }
+
+ public void testEmptyDocumentWithFriend() throws IOException {
+ POIFSFileSystem fs = new POIFSFileSystem();
+ DirectoryEntry dir = fs.getRoot();
+ dir.createDocument("Bar", new ByteArrayInputStream(new byte[] { 0 }));
+ dir.createDocument("Foo", new ByteArrayInputStream(new byte[] {}));
+
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ fs.writeFilesystem(out);
+ new POIFSFileSystem(new ByteArrayInputStream(out.toByteArray()));
+ }
+
+ public void testEmptyDocumentEventWithFriend() throws IOException {
+ POIFSFileSystem fs = new POIFSFileSystem();
+ DirectoryEntry dir = fs.getRoot();
+ dir.createDocument("Bar", 1, new POIFSWriterListener() {
+ public void processPOIFSWriterEvent(POIFSWriterEvent event) {
+ try {
+ event.getStream().write(0);
+ } catch (IOException exception) {
+ throw new RuntimeException("exception on write: " + exception);
+ }
+ }
+ });
+ dir.createDocument("Foo", 0, new POIFSWriterListener() {
+ public void processPOIFSWriterEvent(POIFSWriterEvent event) {
+ }
+ });
+
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ fs.writeFilesystem(out);
+ new POIFSFileSystem(new ByteArrayInputStream(out.toByteArray()));
+ }
+
+ public void testEmptyDocumentBug11744() throws Exception {
+ byte[] testData = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
+
+ POIFSFileSystem fs = new POIFSFileSystem();
+ fs.createDocument(new ByteArrayInputStream(new byte[0]), "Empty");
+ fs.createDocument(new ByteArrayInputStream(testData), "NotEmpty");
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ fs.writeFilesystem(out);
+ out.toByteArray();
+
+ // This line caused the error.
+ fs = new POIFSFileSystem(new ByteArrayInputStream(out.toByteArray()));
+
+ DocumentEntry entry = (DocumentEntry) fs.getRoot().getEntry("Empty");
+ assertEquals("Expected zero size", 0, entry.getSize());
+ byte[] actualReadbackData;
+ actualReadbackData = IOUtils.toByteArray(new DocumentInputStream(entry));
+ assertEquals("Expected zero read from stream", 0, actualReadbackData.length);
+
+ entry = (DocumentEntry) fs.getRoot().getEntry("NotEmpty");
+ actualReadbackData = IOUtils.toByteArray(new DocumentInputStream(entry));
+ assertEquals("Expected size was wrong", testData.length, entry.getSize());
+ assertTrue("Expected different data read from stream", Arrays.equals(testData,
+ actualReadbackData));
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org