Removed static void main(String[]) methods from junit classes. Other minor clean-up.
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@784284 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
383e9e4a40
commit
3089c2e30f
src
ooxml/testcases/org/apache/poi
openxml4j/opc/compliance
xssf
scratchpad/testcases/org/apache/poi
hdf/model
hwpf/model
testcases/org/apache/poi
hpsf/basic
hssf
eventmodel
record
usermodel
poifs
eventfilesystem
filesystem
TestDirectoryNode.javaTestDocument.javaTestDocumentDescriptor.javaTestDocumentNode.javaTestDocumentOutputStream.javaTestEmptyDocument.javaTestPOIFSDocumentPath.java
property
TestDirectoryProperty.javaTestDocumentProperty.javaTestPropertyFactory.javaTestPropertyTable.javaTestRootProperty.java
storage
TestBATBlock.javaTestBlockAllocationTableReader.javaTestBlockAllocationTableWriter.javaTestBlockListImpl.javaTestHeaderBlockReader.javaTestHeaderBlockWriter.javaTestPropertyBlock.javaTestRawDataBlock.javaTestRawDataBlockList.javaTestSmallBlockTableReader.javaTestSmallBlockTableWriter.javaTestSmallDocumentBlockList.java
util
@ -32,18 +32,14 @@ import org.apache.poi.openxml4j.opc.TargetMode;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Test Open Packaging Convention package model compliance.
|
* Test Open Packaging Convention package model compliance.
|
||||||
*
|
*
|
||||||
* M1.11 : A package implementer shall neither create nor recognize a part with
|
* 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.
|
* a part name derived from another part name by appending segments to it.
|
||||||
*
|
*
|
||||||
* @author Julien Chable
|
* @author Julien Chable
|
||||||
*/
|
*/
|
||||||
public class TestOPCCompliancePackageModel extends TestCase {
|
public class TestOPCCompliancePackageModel extends TestCase {
|
||||||
|
|
||||||
public TestOPCCompliancePackageModel(String name) {
|
|
||||||
super(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A package implementer shall neither create nor recognize a part with a
|
* A package implementer shall neither create nor recognize a part with a
|
||||||
* part name derived from another part name by appending segments to it.
|
* part name derived from another part name by appending segments to it.
|
||||||
@ -135,7 +131,7 @@ public class TestOPCCompliancePackageModel extends TestCase {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Try to add a relationship to a relationship part.
|
* Try to add a relationship to a relationship part.
|
||||||
*
|
*
|
||||||
* Check rule M1.25: The Relationships part shall not have relationships to
|
* Check rule M1.25: The Relationships part shall not have relationships to
|
||||||
* any other part. Package implementers shall enforce this requirement upon
|
* any other part. Package implementers shall enforce this requirement upon
|
||||||
* the attempt to create such a relationship and shall treat any such
|
* the attempt to create such a relationship and shall treat any such
|
||||||
|
@ -79,10 +79,6 @@ import org.apache.poi.openxml4j.opc.PackagingURIHelper;
|
|||||||
*/
|
*/
|
||||||
public final class TestOPCCompliancePartName extends TestCase {
|
public final class TestOPCCompliancePartName extends TestCase {
|
||||||
|
|
||||||
public TestOPCCompliancePartName(String name) {
|
|
||||||
super(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test some common invalid names.
|
* Test some common invalid names.
|
||||||
*
|
*
|
||||||
|
@ -28,111 +28,110 @@ import org.apache.poi.xssf.usermodel.XSSFRichTextString;
|
|||||||
import org.apache.poi.openxml4j.opc.OPCPackage;
|
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;
|
private String dirName;
|
||||||
|
|
||||||
public TestXSSFReader(String name) {
|
@Override
|
||||||
super(name);
|
protected void setUp() {
|
||||||
|
|
||||||
dirName = System.getProperty("HSSF.testdata.path");
|
dirName = System.getProperty("HSSF.testdata.path");
|
||||||
assertNotNull(dirName);
|
assertNotNull(dirName);
|
||||||
assertTrue( (new File(dirName)).exists() );
|
assertTrue( (new File(dirName)).exists() );
|
||||||
|
|
||||||
// Use system out logger
|
// Use system out logger
|
||||||
System.setProperty(
|
System.setProperty(
|
||||||
"org.apache.poi.util.POILogger",
|
"org.apache.poi.util.POILogger",
|
||||||
"org.apache.poi.util.SystemOutLogger"
|
"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);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
public void testGetBits() throws Exception {
|
||||||
* Check that the sheet iterator returns sheets in the logical order
|
File f = new File(dirName, "SampleSS.xlsx");
|
||||||
* (as they are defined in the workbook.xml)
|
OPCPackage pkg = OPCPackage.open(f.toString());
|
||||||
*/
|
|
||||||
public void testOrderOfSheets() throws Exception {
|
|
||||||
File f = new File(dirName, "reordered_sheets.xlsx");
|
|
||||||
OPCPackage pkg = OPCPackage.open(f.toString());
|
|
||||||
|
|
||||||
XSSFReader r = new XSSFReader(pkg);
|
XSSFReader r = new XSSFReader(pkg);
|
||||||
|
|
||||||
String[] sheetNames = {"Sheet4", "Sheet2", "Sheet3", "Sheet1"};
|
assertNotNull(r.getWorkbookData());
|
||||||
XSSFReader.SheetIterator it = (XSSFReader.SheetIterator)r.getSheetsData();
|
assertNotNull(r.getSharedStringsData());
|
||||||
|
assertNotNull(r.getStylesData());
|
||||||
|
|
||||||
int count = 0;
|
assertNotNull(r.getSharedStringsTable());
|
||||||
while(it.hasNext()) {
|
assertNotNull(r.getStylesTable());
|
||||||
InputStream inp = it.next();
|
}
|
||||||
assertNotNull(inp);
|
|
||||||
inp.close();
|
|
||||||
|
|
||||||
assertEquals(sheetNames[count], it.getSheetName());
|
public void testStyles() throws Exception {
|
||||||
count++;
|
File f = new File(dirName, "SampleSS.xlsx");
|
||||||
}
|
OPCPackage pkg = OPCPackage.open(f.toString());
|
||||||
assertEquals(4, count);
|
|
||||||
|
|
||||||
}
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,9 +23,8 @@ import org.apache.poi.ss.usermodel.*;
|
|||||||
import org.apache.poi.xssf.XSSFTestDataSamples;
|
import org.apache.poi.xssf.XSSFTestDataSamples;
|
||||||
|
|
||||||
public final class TestXSSFFormulaEvaluation extends TestCase {
|
public final class TestXSSFFormulaEvaluation extends TestCase {
|
||||||
public TestXSSFFormulaEvaluation(String name) {
|
@Override
|
||||||
super(name);
|
protected void setUp() {
|
||||||
|
|
||||||
// Use system out logger
|
// Use system out logger
|
||||||
System.setProperty(
|
System.setProperty(
|
||||||
"org.apache.poi.util.POILogger",
|
"org.apache.poi.util.POILogger",
|
||||||
|
@ -27,31 +27,26 @@ import org.apache.poi.ss.usermodel.Hyperlink;
|
|||||||
import org.apache.poi.ss.usermodel.Row;
|
import org.apache.poi.ss.usermodel.Row;
|
||||||
import org.apache.poi.xssf.XSSFTestDataSamples;
|
import org.apache.poi.xssf.XSSFTestDataSamples;
|
||||||
|
|
||||||
public class TestXSSFHyperlink extends TestCase {
|
public final class TestXSSFHyperlink extends TestCase {
|
||||||
public TestXSSFHyperlink(String name) {
|
@Override
|
||||||
super(name);
|
protected void setUp() {
|
||||||
|
|
||||||
// Use system out logger
|
// Use system out logger
|
||||||
System.setProperty(
|
System.setProperty(
|
||||||
"org.apache.poi.util.POILogger",
|
"org.apache.poi.util.POILogger",
|
||||||
"org.apache.poi.util.SystemOutLogger"
|
"org.apache.poi.util.SystemOutLogger"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testAddNew() throws Exception {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testLoadExisting() throws Exception {
|
public void testLoadExisting() throws Exception {
|
||||||
File xml = new File(
|
File xml = new File(
|
||||||
System.getProperty("HSSF.testdata.path") +
|
System.getProperty("HSSF.testdata.path") +
|
||||||
File.separator + "WithMoreVariousData.xlsx"
|
File.separator + "WithMoreVariousData.xlsx"
|
||||||
);
|
);
|
||||||
assertTrue(xml.exists());
|
assertTrue(xml.exists());
|
||||||
|
|
||||||
XSSFWorkbook workbook = new XSSFWorkbook(xml.toString());
|
XSSFWorkbook workbook = new XSSFWorkbook(xml.toString());
|
||||||
assertEquals(3, workbook.getNumberOfSheets());
|
assertEquals(3, workbook.getNumberOfSheets());
|
||||||
|
|
||||||
XSSFSheet sheet = (XSSFSheet)workbook.getSheetAt(0);
|
XSSFSheet sheet = (XSSFSheet)workbook.getSheetAt(0);
|
||||||
|
|
||||||
// Check the hyperlinks
|
// Check the hyperlinks
|
||||||
@ -59,13 +54,13 @@ public class TestXSSFHyperlink extends TestCase {
|
|||||||
doTestHyperlinkContents(sheet);
|
doTestHyperlinkContents(sheet);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testLoadSave() throws Exception {
|
public void testLoadSave() throws Exception {
|
||||||
File xml = new File(
|
File xml = new File(
|
||||||
System.getProperty("HSSF.testdata.path") +
|
System.getProperty("HSSF.testdata.path") +
|
||||||
File.separator + "WithMoreVariousData.xlsx"
|
File.separator + "WithMoreVariousData.xlsx"
|
||||||
);
|
);
|
||||||
assertTrue(xml.exists());
|
assertTrue(xml.exists());
|
||||||
|
|
||||||
XSSFWorkbook workbook = new XSSFWorkbook(xml.toString());
|
XSSFWorkbook workbook = new XSSFWorkbook(xml.toString());
|
||||||
CreationHelper createHelper = workbook.getCreationHelper();
|
CreationHelper createHelper = workbook.getCreationHelper();
|
||||||
assertEquals(3, workbook.getNumberOfSheets());
|
assertEquals(3, workbook.getNumberOfSheets());
|
||||||
@ -74,8 +69,8 @@ public class TestXSSFHyperlink extends TestCase {
|
|||||||
// Check hyperlinks
|
// Check hyperlinks
|
||||||
assertEquals(4, sheet.getNumHyperlinks());
|
assertEquals(4, sheet.getNumHyperlinks());
|
||||||
doTestHyperlinkContents(sheet);
|
doTestHyperlinkContents(sheet);
|
||||||
|
|
||||||
|
|
||||||
// Write out, and check
|
// Write out, and check
|
||||||
|
|
||||||
// Load up again, check all links still there
|
// Load up again, check all links still there
|
||||||
@ -84,95 +79,95 @@ public class TestXSSFHyperlink extends TestCase {
|
|||||||
assertNotNull(wb2.getSheetAt(0));
|
assertNotNull(wb2.getSheetAt(0));
|
||||||
assertNotNull(wb2.getSheetAt(1));
|
assertNotNull(wb2.getSheetAt(1));
|
||||||
assertNotNull(wb2.getSheetAt(2));
|
assertNotNull(wb2.getSheetAt(2));
|
||||||
|
|
||||||
sheet = (XSSFSheet)wb2.getSheetAt(0);
|
sheet = (XSSFSheet)wb2.getSheetAt(0);
|
||||||
|
|
||||||
|
|
||||||
// Check hyperlinks again
|
// Check hyperlinks again
|
||||||
assertEquals(4, sheet.getNumHyperlinks());
|
assertEquals(4, sheet.getNumHyperlinks());
|
||||||
doTestHyperlinkContents(sheet);
|
doTestHyperlinkContents(sheet);
|
||||||
|
|
||||||
|
|
||||||
// Add one more, and re-check
|
// Add one more, and re-check
|
||||||
Row r17 = sheet.createRow(17);
|
Row r17 = sheet.createRow(17);
|
||||||
Cell r17c = r17.createCell(2);
|
Cell r17c = r17.createCell(2);
|
||||||
|
|
||||||
Hyperlink hyperlink = createHelper.createHyperlink(Hyperlink.LINK_URL);
|
Hyperlink hyperlink = createHelper.createHyperlink(Hyperlink.LINK_URL);
|
||||||
hyperlink.setAddress("http://poi.apache.org/spreadsheet/");
|
hyperlink.setAddress("http://poi.apache.org/spreadsheet/");
|
||||||
hyperlink.setLabel("POI SS Link");
|
hyperlink.setLabel("POI SS Link");
|
||||||
r17c.setHyperlink(hyperlink);
|
r17c.setHyperlink(hyperlink);
|
||||||
|
|
||||||
assertEquals(5, sheet.getNumHyperlinks());
|
assertEquals(5, sheet.getNumHyperlinks());
|
||||||
doTestHyperlinkContents(sheet);
|
doTestHyperlinkContents(sheet);
|
||||||
|
|
||||||
assertEquals(Hyperlink.LINK_URL,
|
assertEquals(Hyperlink.LINK_URL,
|
||||||
sheet.getRow(17).getCell(2).getHyperlink().getType());
|
sheet.getRow(17).getCell(2).getHyperlink().getType());
|
||||||
assertEquals("POI SS Link",
|
assertEquals("POI SS Link",
|
||||||
sheet.getRow(17).getCell(2).getHyperlink().getLabel());
|
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());
|
sheet.getRow(17).getCell(2).getHyperlink().getAddress());
|
||||||
|
|
||||||
|
|
||||||
// Save and re-load once more
|
// Save and re-load once more
|
||||||
|
|
||||||
XSSFWorkbook wb3 = XSSFTestDataSamples.writeOutAndReadBack(wb2);
|
XSSFWorkbook wb3 = XSSFTestDataSamples.writeOutAndReadBack(wb2);
|
||||||
assertEquals(3, wb3.getNumberOfSheets());
|
assertEquals(3, wb3.getNumberOfSheets());
|
||||||
assertNotNull(wb3.getSheetAt(0));
|
assertNotNull(wb3.getSheetAt(0));
|
||||||
assertNotNull(wb3.getSheetAt(1));
|
assertNotNull(wb3.getSheetAt(1));
|
||||||
assertNotNull(wb3.getSheetAt(2));
|
assertNotNull(wb3.getSheetAt(2));
|
||||||
|
|
||||||
sheet = wb3.getSheetAt(0);
|
sheet = wb3.getSheetAt(0);
|
||||||
|
|
||||||
assertEquals(5, sheet.getNumHyperlinks());
|
assertEquals(5, sheet.getNumHyperlinks());
|
||||||
doTestHyperlinkContents(sheet);
|
doTestHyperlinkContents(sheet);
|
||||||
|
|
||||||
assertEquals(Hyperlink.LINK_URL,
|
|
||||||
sheet.getRow(17).getCell(2).getHyperlink().getType());
|
|
||||||
assertEquals("POI SS Link",
|
|
||||||
sheet.getRow(17).getCell(2).getHyperlink().getLabel());
|
|
||||||
assertEquals("http://poi.apache.org/spreadsheet/",
|
|
||||||
sheet.getRow(17).getCell(2).getHyperlink().getAddress());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
assertEquals(Hyperlink.LINK_URL,
|
||||||
* Only for WithMoreVariousData.xlsx !
|
sheet.getRow(17).getCell(2).getHyperlink().getType());
|
||||||
*/
|
assertEquals("POI SS Link",
|
||||||
private void doTestHyperlinkContents(XSSFSheet sheet) {
|
sheet.getRow(17).getCell(2).getHyperlink().getLabel());
|
||||||
|
assertEquals("http://poi.apache.org/spreadsheet/",
|
||||||
|
sheet.getRow(17).getCell(2).getHyperlink().getAddress());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Only for WithMoreVariousData.xlsx !
|
||||||
|
*/
|
||||||
|
private void doTestHyperlinkContents(XSSFSheet sheet) {
|
||||||
assertNotNull(sheet.getRow(3).getCell(2).getHyperlink());
|
assertNotNull(sheet.getRow(3).getCell(2).getHyperlink());
|
||||||
assertNotNull(sheet.getRow(14).getCell(2).getHyperlink());
|
assertNotNull(sheet.getRow(14).getCell(2).getHyperlink());
|
||||||
assertNotNull(sheet.getRow(15).getCell(2).getHyperlink());
|
assertNotNull(sheet.getRow(15).getCell(2).getHyperlink());
|
||||||
assertNotNull(sheet.getRow(16).getCell(2).getHyperlink());
|
assertNotNull(sheet.getRow(16).getCell(2).getHyperlink());
|
||||||
|
|
||||||
// First is a link to poi
|
// First is a link to poi
|
||||||
assertEquals(Hyperlink.LINK_URL,
|
assertEquals(Hyperlink.LINK_URL,
|
||||||
sheet.getRow(3).getCell(2).getHyperlink().getType());
|
sheet.getRow(3).getCell(2).getHyperlink().getType());
|
||||||
assertEquals(null,
|
assertEquals(null,
|
||||||
sheet.getRow(3).getCell(2).getHyperlink().getLabel());
|
sheet.getRow(3).getCell(2).getHyperlink().getLabel());
|
||||||
assertEquals("http://poi.apache.org/",
|
assertEquals("http://poi.apache.org/",
|
||||||
sheet.getRow(3).getCell(2).getHyperlink().getAddress());
|
sheet.getRow(3).getCell(2).getHyperlink().getAddress());
|
||||||
|
|
||||||
// Next is an internal doc link
|
// Next is an internal doc link
|
||||||
assertEquals(Hyperlink.LINK_DOCUMENT,
|
assertEquals(Hyperlink.LINK_DOCUMENT,
|
||||||
sheet.getRow(14).getCell(2).getHyperlink().getType());
|
sheet.getRow(14).getCell(2).getHyperlink().getType());
|
||||||
assertEquals("Internal hyperlink to A2",
|
assertEquals("Internal hyperlink to A2",
|
||||||
sheet.getRow(14).getCell(2).getHyperlink().getLabel());
|
sheet.getRow(14).getCell(2).getHyperlink().getLabel());
|
||||||
assertEquals("Sheet1!A2",
|
assertEquals("Sheet1!A2",
|
||||||
sheet.getRow(14).getCell(2).getHyperlink().getAddress());
|
sheet.getRow(14).getCell(2).getHyperlink().getAddress());
|
||||||
|
|
||||||
// Next is a file
|
// Next is a file
|
||||||
assertEquals(Hyperlink.LINK_FILE,
|
assertEquals(Hyperlink.LINK_FILE,
|
||||||
sheet.getRow(15).getCell(2).getHyperlink().getType());
|
sheet.getRow(15).getCell(2).getHyperlink().getType());
|
||||||
assertEquals(null,
|
assertEquals(null,
|
||||||
sheet.getRow(15).getCell(2).getHyperlink().getLabel());
|
sheet.getRow(15).getCell(2).getHyperlink().getLabel());
|
||||||
assertEquals("WithVariousData.xlsx",
|
assertEquals("WithVariousData.xlsx",
|
||||||
sheet.getRow(15).getCell(2).getHyperlink().getAddress());
|
sheet.getRow(15).getCell(2).getHyperlink().getAddress());
|
||||||
|
|
||||||
// Last is a mailto
|
// Last is a mailto
|
||||||
assertEquals(Hyperlink.LINK_EMAIL,
|
assertEquals(Hyperlink.LINK_EMAIL,
|
||||||
sheet.getRow(16).getCell(2).getHyperlink().getType());
|
sheet.getRow(16).getCell(2).getHyperlink().getType());
|
||||||
assertEquals(null,
|
assertEquals(null,
|
||||||
sheet.getRow(16).getCell(2).getHyperlink().getLabel());
|
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());
|
sheet.getRow(16).getCell(2).getHyperlink().getAddress());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,130 +17,74 @@
|
|||||||
|
|
||||||
package org.apache.poi.hdf.model;
|
package org.apache.poi.hdf.model;
|
||||||
|
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class to test HDFDocument functionality
|
* Class to test {@link HDFDocument} functionality
|
||||||
*
|
*
|
||||||
* @author Bob Otterberg
|
* @author Bob Otterberg
|
||||||
*/
|
*/
|
||||||
public final class TestHDFDocument
|
public final class TestHDFDocument extends TestCase {
|
||||||
extends TestCase
|
public void testStopJUnitComplainintAboutNoTests() {
|
||||||
{
|
// TODO - fix these junits
|
||||||
|
|
||||||
public TestHDFDocument( String name )
|
|
||||||
{
|
|
||||||
super( name );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testStopJUnitComplainintAboutNoTests()
|
private static InputStream openSample(String sampleFileName) {
|
||||||
throws Exception
|
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>
|
* OBJECTIVE: Test that HDF can read an empty document (empty.doc).<P>
|
||||||
* SUCCESS: HDF reads the document. Matches values in their particular positions.<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
|
* FAILURE: HDF does not read the document or excepts. HDF cannot identify values
|
||||||
* in the document in their known positions.<P>
|
* in the document in their known positions.<P>
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public void fixme_testEmpty()
|
public void fixme_testEmpty() throws IOException {
|
||||||
throws IOException
|
InputStream stream = openSample("empty.doc");
|
||||||
{
|
new HDFDocument(stream);
|
||||||
|
|
||||||
String filename = System.getProperty( "HDF.testdata.path" );
|
|
||||||
|
|
||||||
|
|
||||||
filename = filename + "/empty.doc";
|
|
||||||
|
|
||||||
FileInputStream stream = new FileInputStream( filename );
|
|
||||||
|
|
||||||
HDFDocument empty = new HDFDocument( stream );
|
|
||||||
|
|
||||||
stream.close();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TEST NAME: Test Simple <P>
|
|
||||||
* OBJECTIVE: Test that HDF can read an _very_ simple document (simple.doc).<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>
|
* 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
|
* FAILURE: HDF does not read the document or excepts. HDF cannot identify values
|
||||||
* in the document in their known positions.<P>
|
* in the document in their known positions.<P>
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public void fixme_testSimple()
|
public void fixme_testSimple() throws IOException {
|
||||||
throws IOException
|
InputStream stream = openSample("simple.doc");
|
||||||
{
|
new HDFDocument(stream);
|
||||||
String filename = System.getProperty( "HDF.testdata.path" );
|
|
||||||
filename = filename + "/simple.doc";
|
|
||||||
FileInputStream stream = new FileInputStream( filename );
|
|
||||||
HDFDocument empty = new HDFDocument( stream );
|
|
||||||
stream.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TEST NAME: Test Read Simple List <P>
|
|
||||||
* OBJECTIVE: Test that HDF can read a document containing a simple list (simple-list.doc).<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>
|
* 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
|
* FAILURE: HDF does not read the document or excepts. HDF cannot identify values
|
||||||
* in the document in their known positions.<P>
|
* in the document in their known positions.<P>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void fixme_testSimpleList()
|
public void fixme_testSimpleList() throws IOException {
|
||||||
throws IOException
|
InputStream stream = openSample("simple-list.doc");
|
||||||
{
|
new HDFDocument(stream);
|
||||||
String filename = System.getProperty( "HDF.testdata.path" );
|
|
||||||
|
|
||||||
filename = filename + "/simple-list.doc";
|
|
||||||
FileInputStream stream = new FileInputStream( filename );
|
|
||||||
HDFDocument empty = new HDFDocument( stream );
|
|
||||||
stream.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TEST NAME: Test Read Simple Table <P>
|
|
||||||
* OBJECTIVE: Test that HDF can read a document containing a simple table (simple-table.doc).<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>
|
* 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
|
* FAILURE: HDF does not read the document or excepts. HDF cannot identify values
|
||||||
* in the document in their known positions.<P>
|
* in the document in their known positions.<P>
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public void fixme_testSimpleTable()
|
public void fixme_testSimpleTable() throws IOException {
|
||||||
throws IOException
|
InputStream stream = openSample("simple-table.doc");
|
||||||
{
|
new HDFDocument(stream);
|
||||||
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 );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -33,11 +33,6 @@ public final class TestCHPBinTable
|
|||||||
|
|
||||||
private TextPieceTable fakeTPT = new TextPieceTable();
|
private TextPieceTable fakeTPT = new TextPieceTable();
|
||||||
|
|
||||||
public TestCHPBinTable(String name)
|
|
||||||
{
|
|
||||||
super(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testReadWrite()
|
public void testReadWrite()
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
|
@ -29,12 +29,6 @@ public final class TestDocumentProperties
|
|||||||
private DocumentProperties _documentProperties = null;
|
private DocumentProperties _documentProperties = null;
|
||||||
private HWPFDocFixture _hWPFDocFixture;
|
private HWPFDocFixture _hWPFDocFixture;
|
||||||
|
|
||||||
public TestDocumentProperties(String name)
|
|
||||||
{
|
|
||||||
super(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void testReadWrite()
|
public void testReadWrite()
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
|
@ -28,11 +28,6 @@ public final class TestFileInformationBlock
|
|||||||
private FileInformationBlock _fileInformationBlock = null;
|
private FileInformationBlock _fileInformationBlock = null;
|
||||||
private HWPFDocFixture _hWPFDocFixture;
|
private HWPFDocFixture _hWPFDocFixture;
|
||||||
|
|
||||||
public TestFileInformationBlock(String name)
|
|
||||||
{
|
|
||||||
super(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testReadWrite()
|
public void testReadWrite()
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
|
@ -27,11 +27,6 @@ public final class TestFontTable
|
|||||||
private FontTable _fontTable = null;
|
private FontTable _fontTable = null;
|
||||||
private HWPFDocFixture _hWPFDocFixture;
|
private HWPFDocFixture _hWPFDocFixture;
|
||||||
|
|
||||||
public TestFontTable(String name)
|
|
||||||
{
|
|
||||||
super(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testReadWrite()
|
public void testReadWrite()
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
|
@ -32,11 +32,6 @@ public final class TestPAPBinTable
|
|||||||
|
|
||||||
private TextPieceTable fakeTPT = new TextPieceTable();
|
private TextPieceTable fakeTPT = new TextPieceTable();
|
||||||
|
|
||||||
public TestPAPBinTable(String name)
|
|
||||||
{
|
|
||||||
super(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testReadWrite()
|
public void testReadWrite()
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
|
@ -28,13 +28,7 @@ public final class TestPlexOfCps
|
|||||||
private PlexOfCps _plexOfCps = null;
|
private PlexOfCps _plexOfCps = null;
|
||||||
private HWPFDocFixture _hWPFDocFixture;
|
private HWPFDocFixture _hWPFDocFixture;
|
||||||
|
|
||||||
public TestPlexOfCps(String name)
|
public void testWriteRead() {
|
||||||
{
|
|
||||||
super(name);
|
|
||||||
}
|
|
||||||
public void testWriteRead()
|
|
||||||
throws Exception
|
|
||||||
{
|
|
||||||
_plexOfCps = new PlexOfCps(4);
|
_plexOfCps = new PlexOfCps(4);
|
||||||
|
|
||||||
int last = 0;
|
int last = 0;
|
||||||
|
@ -30,11 +30,6 @@ public final class TestSectionTable
|
|||||||
{
|
{
|
||||||
private HWPFDocFixture _hWPFDocFixture;
|
private HWPFDocFixture _hWPFDocFixture;
|
||||||
|
|
||||||
public TestSectionTable(String name)
|
|
||||||
{
|
|
||||||
super(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testReadWrite()
|
public void testReadWrite()
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
|
@ -28,12 +28,6 @@ public final class TestStyleSheet
|
|||||||
private StyleSheet _styleSheet = null;
|
private StyleSheet _styleSheet = null;
|
||||||
private HWPFDocFixture _hWPFDocFixture;
|
private HWPFDocFixture _hWPFDocFixture;
|
||||||
|
|
||||||
|
|
||||||
public TestStyleSheet(String name)
|
|
||||||
{
|
|
||||||
super(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testReadWrite()
|
public void testReadWrite()
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
|
@ -33,11 +33,6 @@ public final class TestTextPieceTable extends TestCase {
|
|||||||
private HWPFDocFixture _hWPFDocFixture;
|
private HWPFDocFixture _hWPFDocFixture;
|
||||||
private String dirname;
|
private String dirname;
|
||||||
|
|
||||||
public TestTextPieceTable(String name)
|
|
||||||
{
|
|
||||||
super(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testReadWrite()
|
public void testReadWrite()
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
|
@ -43,11 +43,10 @@ import org.apache.poi.hpsf.wellknown.SectionIDMap;
|
|||||||
*
|
*
|
||||||
* @author Rainer Klute (klute@rainer-klute.de)
|
* @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";
|
private static final String POI_FS = "TestGermanWord90.doc";
|
||||||
static final String[] POI_FILES = new String[]
|
private static final String[] POI_FILES = new String[]
|
||||||
{
|
{
|
||||||
"\005SummaryInformation",
|
"\005SummaryInformation",
|
||||||
"\005DocumentSummaryInformation",
|
"\005DocumentSummaryInformation",
|
||||||
@ -55,42 +54,29 @@ public class TestBasic extends TestCase
|
|||||||
"\001CompObj",
|
"\001CompObj",
|
||||||
"1Table"
|
"1Table"
|
||||||
};
|
};
|
||||||
static final int BYTE_ORDER = 0xfffe;
|
private static final int BYTE_ORDER = 0xfffe;
|
||||||
static final int FORMAT = 0x0000;
|
private static final int FORMAT = 0x0000;
|
||||||
static final int OS_VERSION = 0x00020A04;
|
private static final int OS_VERSION = 0x00020A04;
|
||||||
static final byte[] CLASS_ID =
|
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,
|
||||||
(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};
|
{1, 2};
|
||||||
static final boolean[] IS_SUMMARY_INFORMATION =
|
private static final boolean[] IS_SUMMARY_INFORMATION =
|
||||||
{true, false};
|
{true, false};
|
||||||
static final boolean[] IS_DOCUMENT_SUMMARY_INFORMATION =
|
private static final boolean[] IS_DOCUMENT_SUMMARY_INFORMATION =
|
||||||
{false, true};
|
{false, true};
|
||||||
|
|
||||||
POIFile[] poiFiles;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>Test case constructor.</p>
|
|
||||||
*
|
|
||||||
* @param name The test case's name.
|
|
||||||
*/
|
|
||||||
public TestBasic(final String name)
|
|
||||||
{
|
|
||||||
super(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
private POIFile[] poiFiles;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Read a the test file from the "data" directory.</p>
|
* <p>Read a the test file from the "data" directory.</p>
|
||||||
*
|
*
|
||||||
* @exception FileNotFoundException if the file to be read does not exist.
|
* @exception FileNotFoundException if the file to be read does not exist.
|
||||||
* @exception IOException if any other I/O exception occurs.
|
* @exception IOException if any other I/O exception occurs.
|
||||||
*/
|
*/
|
||||||
@ -102,8 +88,6 @@ public class TestBasic extends TestCase
|
|||||||
poiFiles = Util.readPOIFiles(data);
|
poiFiles = Util.readPOIFiles(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Checks the names of the files in the POI filesystem. They
|
* <p>Checks the names of the files in the POI filesystem. They
|
||||||
* are expected to be in a certain order.</p>
|
* are expected to be in a certain order.</p>
|
||||||
@ -115,8 +99,6 @@ public class TestBasic extends TestCase
|
|||||||
Assert.assertEquals(poiFiles[i].getName(), expected[i]);
|
Assert.assertEquals(poiFiles[i].getName(), expected[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Tests whether property sets can be created from the POI
|
* <p>Tests whether property sets can be created from the POI
|
||||||
* files in the POI file system. This test case expects the first
|
* files in the POI file system. This test case expects the first
|
||||||
@ -125,9 +107,9 @@ public class TestBasic extends TestCase
|
|||||||
* property sets. In the latter cases a {@link
|
* property sets. In the latter cases a {@link
|
||||||
* NoPropertySetStreamException} will be thrown when trying to
|
* NoPropertySetStreamException} will be thrown when trying to
|
||||||
* create a {@link PropertySet}.</p>
|
* create a {@link PropertySet}.</p>
|
||||||
*
|
*
|
||||||
* @exception IOException if an I/O exception occurs.
|
* @exception IOException if an I/O exception occurs.
|
||||||
*
|
*
|
||||||
* @exception UnsupportedEncodingException if a character encoding is not
|
* @exception UnsupportedEncodingException if a character encoding is not
|
||||||
* supported.
|
* supported.
|
||||||
*/
|
*/
|
||||||
@ -163,13 +145,11 @@ public class TestBasic extends TestCase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Tests the {@link PropertySet} methods. The test file has two
|
* <p>Tests the {@link PropertySet} methods. The test file has two
|
||||||
* property sets: the first one is a {@link SummaryInformation},
|
* property sets: the first one is a {@link SummaryInformation},
|
||||||
* the second one is a {@link DocumentSummaryInformation}.</p>
|
* the second one is a {@link DocumentSummaryInformation}.</p>
|
||||||
*
|
*
|
||||||
* @exception IOException if an I/O exception occurs
|
* @exception IOException if an I/O exception occurs
|
||||||
* @exception HPSFException if any HPSF exception occurs
|
* @exception HPSFException if any HPSF exception occurs
|
||||||
*/
|
*/
|
||||||
@ -194,13 +174,11 @@ public class TestBasic extends TestCase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Tests the {@link Section} methods. The test file has two
|
* <p>Tests the {@link Section} methods. The test file has two
|
||||||
* property sets: the first one is a {@link SummaryInformation},
|
* property sets: the first one is a {@link SummaryInformation},
|
||||||
* the second one is a {@link DocumentSummaryInformation}.</p>
|
* the second one is a {@link DocumentSummaryInformation}.</p>
|
||||||
*
|
*
|
||||||
* @exception IOException if an I/O exception occurs
|
* @exception IOException if an I/O exception occurs
|
||||||
* @exception HPSFException if any HPSF exception occurs
|
* @exception HPSFException if any HPSF exception occurs
|
||||||
*/
|
*/
|
||||||
@ -218,21 +196,4 @@ public class TestBasic extends TestCase
|
|||||||
Assert.assertEquals("Titel", s.getProperty(2));
|
Assert.assertEquals("Titel", s.getProperty(2));
|
||||||
Assert.assertEquals(1748, s.getSize());
|
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,6 @@
|
|||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
==================================================================== */
|
==================================================================== */
|
||||||
|
|
||||||
|
|
||||||
package org.apache.poi.hpsf.basic;
|
package org.apache.poi.hpsf.basic;
|
||||||
|
|
||||||
@ -31,17 +30,7 @@ import org.apache.poi.hpsf.SummaryInformation;
|
|||||||
*
|
*
|
||||||
* @author Michael Zalewski (zalewski@optonline.net)
|
* @author Michael Zalewski (zalewski@optonline.net)
|
||||||
*/
|
*/
|
||||||
public class TestClassID extends TestCase
|
public final class TestClassID extends TestCase {
|
||||||
{
|
|
||||||
/**
|
|
||||||
* <p>Constructor</p>
|
|
||||||
*
|
|
||||||
* @param name the test case's name
|
|
||||||
*/
|
|
||||||
public TestClassID(final String name)
|
|
||||||
{
|
|
||||||
super(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Various tests of overridden .equals()
|
* Various tests of overridden .equals()
|
||||||
@ -130,19 +119,4 @@ public class TestClassID extends TestCase
|
|||||||
"{04030201-0605-0807-090A-0B0C0D0E0F10}"
|
"{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);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -43,37 +43,22 @@ import org.apache.poi.hpsf.Variant;
|
|||||||
* @author Rainer Klute <a
|
* @author Rainer Klute <a
|
||||||
* href="mailto:klute@rainer-klute.de"><klute@rainer-klute.de></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
|
* <p>This test file's summary information stream contains some empty
|
||||||
* properties.</p>
|
* 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",
|
"PerfectOffice_MAIN",
|
||||||
"\005SummaryInformation",
|
"\005SummaryInformation",
|
||||||
"Main"
|
"Main"
|
||||||
};
|
};
|
||||||
|
|
||||||
POIFile[] poiFiles;
|
private POIFile[] poiFiles;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>Constructor</p>
|
|
||||||
*
|
|
||||||
* @param name The name of the test case
|
|
||||||
*/
|
|
||||||
public TestEmptyProperties(final String name)
|
|
||||||
{
|
|
||||||
super(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Read a the test file from the "data" directory.</p>
|
* <p>Read a the test file from the "data" directory.</p>
|
||||||
@ -91,8 +76,6 @@ public class TestEmptyProperties extends TestCase
|
|||||||
poiFiles = Util.readPOIFiles(data);
|
poiFiles = Util.readPOIFiles(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Checks the names of the files in the POI filesystem. They
|
* <p>Checks the names of the files in the POI filesystem. They
|
||||||
* are expected to be in a certain order.</p>
|
* are expected to be in a certain order.</p>
|
||||||
@ -104,8 +87,6 @@ public class TestEmptyProperties extends TestCase
|
|||||||
Assert.assertEquals(poiFiles[i].getName(), expected[i]);
|
Assert.assertEquals(poiFiles[i].getName(), expected[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Tests whether property sets can be created from the POI
|
* <p>Tests whether property sets can be created from the POI
|
||||||
* files in the POI file system. This test case expects the first
|
* files in the POI file system. This test case expects the first
|
||||||
@ -114,15 +95,15 @@ public class TestEmptyProperties extends TestCase
|
|||||||
* property sets. In the latter cases a {@link
|
* property sets. In the latter cases a {@link
|
||||||
* NoPropertySetStreamException} will be thrown when trying to
|
* NoPropertySetStreamException} will be thrown when trying to
|
||||||
* create a {@link PropertySet}.</p>
|
* create a {@link PropertySet}.</p>
|
||||||
*
|
*
|
||||||
* @exception IOException if an I/O exception occurs.
|
* @exception IOException if an I/O exception occurs.
|
||||||
*
|
*
|
||||||
* @exception UnsupportedEncodingException if a character encoding is not
|
* @exception UnsupportedEncodingException if a character encoding is not
|
||||||
* supported.
|
* supported.
|
||||||
*/
|
*/
|
||||||
public void testCreatePropertySets()
|
public void testCreatePropertySets()
|
||||||
throws UnsupportedEncodingException, IOException
|
throws UnsupportedEncodingException, IOException
|
||||||
{
|
{
|
||||||
Class[] expected = new Class[]
|
Class[] expected = new Class[]
|
||||||
{
|
{
|
||||||
NoPropertySetStreamException.class,
|
NoPropertySetStreamException.class,
|
||||||
@ -150,13 +131,11 @@ public class TestEmptyProperties extends TestCase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Tests the {@link PropertySet} methods. The test file has two
|
* <p>Tests the {@link PropertySet} methods. The test file has two
|
||||||
* property sets: the first one is a {@link SummaryInformation},
|
* property sets: the first one is a {@link SummaryInformation},
|
||||||
* the second one is a {@link DocumentSummaryInformation}.</p>
|
* the second one is a {@link DocumentSummaryInformation}.</p>
|
||||||
*
|
*
|
||||||
* @exception IOException if an I/O exception occurs
|
* @exception IOException if an I/O exception occurs
|
||||||
* @exception HPSFException if an HPSF operation fails
|
* @exception HPSFException if an HPSF operation fails
|
||||||
*/
|
*/
|
||||||
@ -184,21 +163,4 @@ public class TestEmptyProperties extends TestCase
|
|||||||
assertNull(s.getThumbnail());
|
assertNull(s.getThumbnail());
|
||||||
assertNull(s.getApplicationName());
|
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -36,41 +36,25 @@ import org.apache.poi.poifs.filesystem.POIFSFileSystem;
|
|||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests the ModelFactory.
|
* Tests the ModelFactory.
|
||||||
*
|
*
|
||||||
* @author Andrew C. Oliver acoliver@apache.org
|
* @author Andrew C. Oliver acoliver@apache.org
|
||||||
*/
|
*/
|
||||||
public class TestModelFactory extends TestCase
|
public class TestModelFactory extends TestCase {
|
||||||
{
|
|
||||||
private ModelFactory factory;
|
private ModelFactory factory;
|
||||||
private HSSFWorkbook book;
|
private HSSFWorkbook book;
|
||||||
private InputStream in;
|
private InputStream in;
|
||||||
private List models;
|
private List models;
|
||||||
|
|
||||||
/**
|
|
||||||
* Tests that the listeners collection is created
|
|
||||||
* @param arg0
|
|
||||||
*/
|
|
||||||
public TestModelFactory(String arg0)
|
|
||||||
{
|
|
||||||
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
|
protected void setUp() throws Exception
|
||||||
{
|
{
|
||||||
super.setUp();
|
ModelFactory mf = new ModelFactory();
|
||||||
|
assertTrue("listeners member cannot be null", mf.listeners != null);
|
||||||
|
assertTrue("listeners member must be a List", mf.listeners instanceof List);
|
||||||
models = new ArrayList(3);
|
models = new ArrayList(3);
|
||||||
factory = new ModelFactory();
|
factory = new ModelFactory();
|
||||||
book = new HSSFWorkbook();
|
book = new HSSFWorkbook();
|
||||||
ByteArrayOutputStream stream = (ByteArrayOutputStream)setupRunFile(book);
|
ByteArrayOutputStream stream = (ByteArrayOutputStream)setupRunFile(book);
|
||||||
POIFSFileSystem fs = new POIFSFileSystem(
|
POIFSFileSystem fs = new POIFSFileSystem(
|
||||||
new ByteArrayInputStream(stream.toByteArray())
|
new ByteArrayInputStream(stream.toByteArray())
|
||||||
);
|
);
|
||||||
@ -91,9 +75,9 @@ public class TestModelFactory extends TestCase
|
|||||||
public void testRegisterListener()
|
public void testRegisterListener()
|
||||||
{
|
{
|
||||||
if (factory.listeners.size() != 0) {
|
if (factory.listeners.size() != 0) {
|
||||||
factory = new ModelFactory();
|
factory = new ModelFactory();
|
||||||
}
|
}
|
||||||
|
|
||||||
factory.registerListener(new MFListener(null));
|
factory.registerListener(new MFListener(null));
|
||||||
factory.registerListener(new MFListener(null));
|
factory.registerListener(new MFListener(null));
|
||||||
assertTrue("Factory listeners should be two, was="+
|
assertTrue("Factory listeners should be two, was="+
|
||||||
@ -109,29 +93,29 @@ public class TestModelFactory extends TestCase
|
|||||||
{
|
{
|
||||||
Model temp = null;
|
Model temp = null;
|
||||||
Iterator mi = null;
|
Iterator mi = null;
|
||||||
|
|
||||||
if (factory.listeners.size() != 0) {
|
if (factory.listeners.size() != 0) {
|
||||||
factory = new ModelFactory();
|
factory = new ModelFactory();
|
||||||
}
|
}
|
||||||
|
|
||||||
factory.registerListener(new MFListener(models));
|
factory.registerListener(new MFListener(models));
|
||||||
factory.run(in);
|
factory.run(in);
|
||||||
|
|
||||||
assertTrue("Models size must be 2 was = "+models.size(),
|
assertTrue("Models size must be 2 was = "+models.size(),
|
||||||
models.size() == 2);
|
models.size() == 2);
|
||||||
mi = models.iterator();
|
mi = models.iterator();
|
||||||
temp = (Model)mi.next();
|
temp = (Model)mi.next();
|
||||||
|
|
||||||
assertTrue("First model is Workbook was " + temp.getClass().getName(),
|
assertTrue("First model is Workbook was " + temp.getClass().getName(),
|
||||||
temp instanceof Workbook);
|
temp instanceof Workbook);
|
||||||
|
|
||||||
temp = (Model)mi.next();
|
temp = (Model)mi.next();
|
||||||
|
|
||||||
assertTrue("Second model is Sheet was " + temp.getClass().getName(),
|
assertTrue("Second model is Sheet was " + temp.getClass().getName(),
|
||||||
temp instanceof Sheet);
|
temp instanceof Sheet);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets up a test file
|
* Sets up a test file
|
||||||
*/
|
*/
|
||||||
@ -153,17 +137,16 @@ public class TestModelFactory extends TestCase
|
|||||||
class MFListener implements ModelFactoryListener {
|
class MFListener implements ModelFactoryListener {
|
||||||
private List mlist;
|
private List mlist;
|
||||||
public MFListener(List mlist) {
|
public MFListener(List mlist) {
|
||||||
this.mlist = mlist;
|
this.mlist = mlist;
|
||||||
}
|
|
||||||
|
|
||||||
public boolean process(Model model)
|
|
||||||
{
|
|
||||||
mlist.add(model);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Iterator models() {
|
|
||||||
return mlist.iterator();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
public boolean process(Model model)
|
||||||
|
{
|
||||||
|
mlist.add(model);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Iterator models() {
|
||||||
|
return mlist.iterator();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -27,22 +27,19 @@ import org.apache.poi.hssf.record.cf.PatternFormatting;
|
|||||||
import org.apache.poi.hssf.record.formula.Ptg;
|
import org.apache.poi.hssf.record.formula.Ptg;
|
||||||
import org.apache.poi.hssf.record.formula.RefNPtg;
|
import org.apache.poi.hssf.record.formula.RefNPtg;
|
||||||
import org.apache.poi.hssf.record.formula.RefPtg;
|
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.HSSFSheet;
|
||||||
|
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||||
import org.apache.poi.hssf.util.HSSFColor;
|
import org.apache.poi.hssf.util.HSSFColor;
|
||||||
import org.apache.poi.util.LittleEndian;
|
import org.apache.poi.util.LittleEndian;
|
||||||
import org.apache.poi.ss.formula.Formula;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests the serialization and deserialization of the TestCFRuleRecord
|
* Tests the serialization and deserialization of the TestCFRuleRecord
|
||||||
* class works correctly.
|
* class works correctly.
|
||||||
*
|
*
|
||||||
* @author Dmitriy Kumshayev
|
* @author Dmitriy Kumshayev
|
||||||
*/
|
*/
|
||||||
public final class TestCFRuleRecord extends TestCase
|
public final class TestCFRuleRecord extends TestCase {
|
||||||
{
|
public void testConstructors () {
|
||||||
public void testConstructors ()
|
|
||||||
{
|
|
||||||
HSSFWorkbook workbook = new HSSFWorkbook();
|
HSSFWorkbook workbook = new HSSFWorkbook();
|
||||||
HSSFSheet sheet = workbook.createSheet();
|
HSSFSheet sheet = workbook.createSheet();
|
||||||
|
|
||||||
@ -65,8 +62,7 @@ public final class TestCFRuleRecord extends TestCase
|
|||||||
assertSame(Ptg.EMPTY_PTG_ARRAY, rule3.getParsedExpression2());
|
assertSame(Ptg.EMPTY_PTG_ARRAY, rule3.getParsedExpression2());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testCreateCFRuleRecord ()
|
public void testCreateCFRuleRecord() {
|
||||||
{
|
|
||||||
HSSFWorkbook workbook = new HSSFWorkbook();
|
HSSFWorkbook workbook = new HSSFWorkbook();
|
||||||
HSSFSheet sheet = workbook.createSheet();
|
HSSFSheet sheet = workbook.createSheet();
|
||||||
CFRuleRecord record = CFRuleRecord.create(sheet, "7");
|
CFRuleRecord record = CFRuleRecord.create(sheet, "7");
|
||||||
@ -94,8 +90,7 @@ public final class TestCFRuleRecord extends TestCase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void testCFRuleRecord(CFRuleRecord record)
|
private void testCFRuleRecord(CFRuleRecord record) {
|
||||||
{
|
|
||||||
FontFormatting fontFormatting = new FontFormatting();
|
FontFormatting fontFormatting = new FontFormatting();
|
||||||
testFontFormattingAccessors(fontFormatting);
|
testFontFormattingAccessors(fontFormatting);
|
||||||
assertFalse(record.containsFontFormattingBlock());
|
assertFalse(record.containsFontFormattingBlock());
|
||||||
@ -152,8 +147,7 @@ public final class TestCFRuleRecord extends TestCase
|
|||||||
assertTrue(record.isPatternStyleModified());
|
assertTrue(record.isPatternStyleModified());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void testPatternFormattingAccessors(PatternFormatting patternFormatting)
|
private void testPatternFormattingAccessors(PatternFormatting patternFormatting) {
|
||||||
{
|
|
||||||
patternFormatting.setFillBackgroundColor(HSSFColor.GREEN.index);
|
patternFormatting.setFillBackgroundColor(HSSFColor.GREEN.index);
|
||||||
assertEquals(HSSFColor.GREEN.index,patternFormatting.getFillBackgroundColor());
|
assertEquals(HSSFColor.GREEN.index,patternFormatting.getFillBackgroundColor());
|
||||||
|
|
||||||
@ -164,8 +158,7 @@ public final class TestCFRuleRecord extends TestCase
|
|||||||
assertEquals(PatternFormatting.DIAMONDS,patternFormatting.getFillPattern());
|
assertEquals(PatternFormatting.DIAMONDS,patternFormatting.getFillPattern());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void testBorderFormattingAccessors(BorderFormatting borderFormatting)
|
private void testBorderFormattingAccessors(BorderFormatting borderFormatting) {
|
||||||
{
|
|
||||||
borderFormatting.setBackwardDiagonalOn(false);
|
borderFormatting.setBackwardDiagonalOn(false);
|
||||||
assertFalse(borderFormatting.isBackwardDiagonalOn());
|
assertFalse(borderFormatting.isBackwardDiagonalOn());
|
||||||
borderFormatting.setBackwardDiagonalOn(true);
|
borderFormatting.setBackwardDiagonalOn(true);
|
||||||
@ -207,8 +200,7 @@ public final class TestCFRuleRecord extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void testFontFormattingAccessors(FontFormatting fontFormatting)
|
private void testFontFormattingAccessors(FontFormatting fontFormatting) {
|
||||||
{
|
|
||||||
// Check for defaults
|
// Check for defaults
|
||||||
assertFalse(fontFormatting.isEscapementTypeModified());
|
assertFalse(fontFormatting.isEscapementTypeModified());
|
||||||
assertFalse(fontFormatting.isFontCancellationModified());
|
assertFalse(fontFormatting.isFontCancellationModified());
|
||||||
@ -357,31 +349,6 @@ public final class TestCFRuleRecord extends TestCase
|
|||||||
assertTrue(refNPtg.isRowRelative());
|
assertTrue(refNPtg.isRowRelative());
|
||||||
|
|
||||||
byte[] data = rr.serialize();
|
byte[] data = rr.serialize();
|
||||||
|
TestcaseRecordInputStream.confirmRecordEncoding(CFRuleRecord.sid, DATA_REFN, data);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
/* ====================================================================
|
/* ====================================================================
|
||||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
contributor license agreements. See the NOTICE file distributed with
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
@ -15,7 +14,7 @@
|
|||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
==================================================================== */
|
==================================================================== */
|
||||||
|
|
||||||
package org.apache.poi.hssf.record;
|
package org.apache.poi.hssf.record;
|
||||||
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
@ -28,20 +27,14 @@ import org.apache.poi.hssf.util.HSSFColor;
|
|||||||
*
|
*
|
||||||
* @author Brian Sanders (bsanders at risklabs dot com)
|
* @author Brian Sanders (bsanders at risklabs dot com)
|
||||||
*/
|
*/
|
||||||
public class TestPaletteRecord extends TestCase
|
public final class TestPaletteRecord extends TestCase {
|
||||||
{
|
|
||||||
public TestPaletteRecord(String name)
|
|
||||||
{
|
|
||||||
super(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests that the default palette matches the constants of HSSFColor
|
* Tests that the default palette matches the constants of HSSFColor
|
||||||
*/
|
*/
|
||||||
public void testDefaultPalette()
|
public void testDefaultPalette() {
|
||||||
{
|
|
||||||
PaletteRecord palette = new PaletteRecord();
|
PaletteRecord palette = new PaletteRecord();
|
||||||
|
|
||||||
//make sure all the HSSFColor constants match
|
//make sure all the HSSFColor constants match
|
||||||
Map colors = HSSFColor.getIndexHash();
|
Map colors = HSSFColor.getIndexHash();
|
||||||
Iterator indexes = colors.keySet().iterator();
|
Iterator indexes = colors.keySet().iterator();
|
||||||
|
@ -31,7 +31,7 @@ import junit.framework.TestCase;
|
|||||||
* @author Andrew C. Oliver(acoliver at apache.org)
|
* @author Andrew C. Oliver(acoliver at apache.org)
|
||||||
*/
|
*/
|
||||||
public final class TestAxisOptionsRecord extends TestCase {
|
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)0x00,(byte)0x01,
|
||||||
(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x01,(byte)0x00,
|
(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x01,(byte)0x00,
|
||||||
(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,
|
(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,
|
||||||
@ -88,14 +88,4 @@ public final class TestAxisOptionsRecord extends TestCase {
|
|||||||
for (int i = 0; i < data.length; i++)
|
for (int i = 0; i < data.length; i++)
|
||||||
assertEquals("At offset " + i, data[i], recordBytes[i+4]);
|
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -27,18 +27,17 @@ import junit.framework.TestCase;
|
|||||||
* class works correctly. Test data taken directly from a real
|
* class works correctly. Test data taken directly from a real
|
||||||
* Excel file.
|
* Excel file.
|
||||||
*
|
*
|
||||||
|
|
||||||
* @author Andrew C. Oliver(acoliver at apache.org)
|
* @author Andrew C. Oliver(acoliver at apache.org)
|
||||||
*/
|
*/
|
||||||
public final class TestTickRecord extends TestCase {
|
public final class TestTickRecord extends TestCase {
|
||||||
byte[] data = new byte[] {
|
private static final byte[] data = {
|
||||||
(byte)0x02, (byte)0x00, (byte)0x03, (byte)0x01,
|
(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)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)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x23, (byte)0x00,
|
||||||
(byte)0x4D, (byte)0x00, (byte)0x00, (byte)0x00
|
(byte)0x4D, (byte)0x00, (byte)0x00, (byte)0x00
|
||||||
};
|
};
|
||||||
|
|
||||||
public void testLoad() {
|
public void testLoad() {
|
||||||
@ -62,8 +61,7 @@ public final class TestTickRecord extends TestCase {
|
|||||||
assertEquals( 34, record.getRecordSize() );
|
assertEquals( 34, record.getRecordSize() );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testStore()
|
public void testStore() {
|
||||||
{
|
|
||||||
TickRecord record = new TickRecord();
|
TickRecord record = new TickRecord();
|
||||||
record.setMajorTickType( (byte)2 );
|
record.setMajorTickType( (byte)2 );
|
||||||
record.setMinorTickType( (byte)0 );
|
record.setMinorTickType( (byte)0 );
|
||||||
@ -86,16 +84,4 @@ public final class TestTickRecord extends TestCase {
|
|||||||
for (int i = 0; i < data.length; i++)
|
for (int i = 0; i < data.length; i++)
|
||||||
assertEquals("At offset " + i, data[i], recordBytes[i+4]);
|
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -52,13 +52,7 @@ public final class TestReadWriteChart extends TestCase {
|
|||||||
Sheet newSheet = workbook.getSheetAt(0).getSheet();
|
Sheet newSheet = workbook.getSheetAt(0).getSheet();
|
||||||
List records = newSheet.getRecords();
|
List records = newSheet.getRecords();
|
||||||
|
|
||||||
//System.out.println("BOF Assertion");
|
|
||||||
assertTrue(records.get(0) instanceof BOFRecord);
|
assertTrue(records.get(0) instanceof BOFRecord);
|
||||||
//System.out.println("EOF Assertion");
|
|
||||||
assertTrue(records.get(records.size() - 1) instanceof EOFRecord);
|
assertTrue(records.get(records.size() - 1) instanceof EOFRecord);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String [] args) {
|
|
||||||
junit.textui.TestRunner.run(TestReadWriteChart.class);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
/* ====================================================================
|
/* ====================================================================
|
||||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
contributor license agreements. See the NOTICE file distributed with
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
@ -15,13 +14,14 @@
|
|||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
==================================================================== */
|
==================================================================== */
|
||||||
|
|
||||||
|
|
||||||
package org.apache.poi.poifs.eventfilesystem;
|
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;
|
import org.apache.poi.poifs.filesystem.POIFSDocumentPath;
|
||||||
|
|
||||||
@ -30,10 +30,7 @@ import org.apache.poi.poifs.filesystem.POIFSDocumentPath;
|
|||||||
*
|
*
|
||||||
* @author Marc Johnson
|
* @author Marc Johnson
|
||||||
*/
|
*/
|
||||||
|
public final class TestPOIFSReaderRegistry extends TestCase {
|
||||||
public class TestPOIFSReaderRegistry
|
|
||||||
extends TestCase
|
|
||||||
{
|
|
||||||
private POIFSReaderListener[] listeners =
|
private POIFSReaderListener[] listeners =
|
||||||
{
|
{
|
||||||
new Listener(), new Listener(), new Listener(), new Listener()
|
new Listener(), new Listener(), new Listener(), new Listener()
|
||||||
@ -56,23 +53,10 @@ public class TestPOIFSReaderRegistry
|
|||||||
"a0", "a1", "a2", "a3"
|
"a0", "a1", "a2", "a3"
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor TestPOIFSReaderRegistry
|
|
||||||
*
|
|
||||||
* @param name
|
|
||||||
*/
|
|
||||||
|
|
||||||
public TestPOIFSReaderRegistry(String name)
|
|
||||||
{
|
|
||||||
super(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test empty registry
|
* Test empty registry
|
||||||
*/
|
*/
|
||||||
|
public void testEmptyRegistry() {
|
||||||
public void testEmptyRegistry()
|
|
||||||
{
|
|
||||||
POIFSReaderRegistry registry = new POIFSReaderRegistry();
|
POIFSReaderRegistry registry = new POIFSReaderRegistry();
|
||||||
|
|
||||||
for (int j = 0; j < paths.length; j++)
|
for (int j = 0; j < paths.length; j++)
|
||||||
@ -90,9 +74,7 @@ public class TestPOIFSReaderRegistry
|
|||||||
/**
|
/**
|
||||||
* Test mixed registration operations
|
* Test mixed registration operations
|
||||||
*/
|
*/
|
||||||
|
public void testMixedRegistrationOperations() {
|
||||||
public void testMixedRegistrationOperations()
|
|
||||||
{
|
|
||||||
POIFSReaderRegistry registry = new POIFSReaderRegistry();
|
POIFSReaderRegistry registry = new POIFSReaderRegistry();
|
||||||
|
|
||||||
for (int j = 0; j < listeners.length; j++)
|
for (int j = 0; j < listeners.length; j++)
|
||||||
@ -172,17 +154,4 @@ public class TestPOIFSReaderRegistry
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
==================================================================== */
|
==================================================================== */
|
||||||
|
|
||||||
|
|
||||||
package org.apache.poi.poifs.filesystem;
|
package org.apache.poi.poifs.filesystem;
|
||||||
|
|
||||||
@ -33,31 +32,12 @@ import org.apache.poi.poifs.property.DocumentProperty;
|
|||||||
*
|
*
|
||||||
* @author Marc Johnson
|
* @author Marc Johnson
|
||||||
*/
|
*/
|
||||||
|
public final class TestDirectoryNode extends TestCase {
|
||||||
public class TestDirectoryNode
|
|
||||||
extends TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor TestDirectoryNode
|
|
||||||
*
|
|
||||||
* @param name
|
|
||||||
*/
|
|
||||||
|
|
||||||
public TestDirectoryNode(String name)
|
|
||||||
{
|
|
||||||
super(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* test trivial constructor (a DirectoryNode with no children)
|
* test trivial constructor (a DirectoryNode with no children)
|
||||||
*
|
|
||||||
* @exception IOException
|
|
||||||
*/
|
*/
|
||||||
|
public void testEmptyConstructor() {
|
||||||
public void testEmptyConstructor()
|
|
||||||
throws IOException
|
|
||||||
{
|
|
||||||
POIFSFileSystem fs = new POIFSFileSystem();
|
POIFSFileSystem fs = new POIFSFileSystem();
|
||||||
DirectoryProperty property1 = new DirectoryProperty("parent");
|
DirectoryProperty property1 = new DirectoryProperty("parent");
|
||||||
DirectoryProperty property2 = new DirectoryProperty("child");
|
DirectoryProperty property2 = new DirectoryProperty("child");
|
||||||
@ -113,13 +93,8 @@ public class TestDirectoryNode
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* test non-trivial constructor (a DirectoryNode with children)
|
* 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 property1 = new DirectoryProperty("parent");
|
||||||
DirectoryProperty property2 = new DirectoryProperty("child1");
|
DirectoryProperty property2 = new DirectoryProperty("child1");
|
||||||
|
|
||||||
@ -177,13 +152,8 @@ public class TestDirectoryNode
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* test deletion methods
|
* test deletion methods
|
||||||
*
|
|
||||||
* @exception IOException
|
|
||||||
*/
|
*/
|
||||||
|
public void testDeletion() throws IOException {
|
||||||
public void testDeletion()
|
|
||||||
throws IOException
|
|
||||||
{
|
|
||||||
POIFSFileSystem fs = new POIFSFileSystem();
|
POIFSFileSystem fs = new POIFSFileSystem();
|
||||||
DirectoryEntry root = fs.getRoot();
|
DirectoryEntry root = fs.getRoot();
|
||||||
|
|
||||||
@ -213,13 +183,8 @@ public class TestDirectoryNode
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* test change name methods
|
* test change name methods
|
||||||
*
|
|
||||||
* @exception IOException
|
|
||||||
*/
|
*/
|
||||||
|
public void testRename() throws IOException {
|
||||||
public void testRename()
|
|
||||||
throws IOException
|
|
||||||
{
|
|
||||||
POIFSFileSystem fs = new POIFSFileSystem();
|
POIFSFileSystem fs = new POIFSFileSystem();
|
||||||
DirectoryEntry root = fs.getRoot();
|
DirectoryEntry root = fs.getRoot();
|
||||||
|
|
||||||
@ -237,17 +202,4 @@ public class TestDirectoryNode
|
|||||||
assertTrue(dir2.renameTo("foo"));
|
assertTrue(dir2.renameTo("foo"));
|
||||||
assertEquals("foo", dir2.getName());
|
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
/* ====================================================================
|
/* ====================================================================
|
||||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
contributor license agreements. See the NOTICE file distributed with
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
@ -15,18 +14,15 @@
|
|||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
==================================================================== */
|
==================================================================== */
|
||||||
|
|
||||||
|
|
||||||
package org.apache.poi.poifs.filesystem;
|
package org.apache.poi.poifs.filesystem;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
import java.util.*;
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
import junit.framework.*;
|
|
||||||
|
|
||||||
import org.apache.poi.util.LittleEndian;
|
|
||||||
import org.apache.poi.util.LittleEndianConsts;
|
|
||||||
import org.apache.poi.poifs.property.DocumentProperty;
|
import org.apache.poi.poifs.property.DocumentProperty;
|
||||||
import org.apache.poi.poifs.storage.RawDataBlock;
|
import org.apache.poi.poifs.storage.RawDataBlock;
|
||||||
import org.apache.poi.poifs.storage.SmallDocumentBlock;
|
import org.apache.poi.poifs.storage.SmallDocumentBlock;
|
||||||
@ -36,31 +32,12 @@ import org.apache.poi.poifs.storage.SmallDocumentBlock;
|
|||||||
*
|
*
|
||||||
* @author Marc Johnson
|
* @author Marc Johnson
|
||||||
*/
|
*/
|
||||||
|
public final class TestDocument extends TestCase {
|
||||||
public class TestDocument
|
|
||||||
extends TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor TestDocument
|
|
||||||
*
|
|
||||||
* @param name
|
|
||||||
*/
|
|
||||||
|
|
||||||
public TestDocument(String name)
|
|
||||||
{
|
|
||||||
super(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Integration test -- really about all we can do
|
* 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
|
// verify correct number of blocks get created for document
|
||||||
// that is exact multituple of block size
|
// that is exact multituple of block size
|
||||||
@ -158,10 +135,8 @@ public class TestDocument
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private POIFSDocument makeCopy(POIFSDocument document, byte [] input,
|
private static POIFSDocument makeCopy(POIFSDocument document, byte[] input, byte[] data)
|
||||||
byte [] data)
|
throws IOException {
|
||||||
throws IOException
|
|
||||||
{
|
|
||||||
POIFSDocument copy = null;
|
POIFSDocument copy = null;
|
||||||
|
|
||||||
if (input.length >= 4096)
|
if (input.length >= 4096)
|
||||||
@ -194,10 +169,8 @@ public class TestDocument
|
|||||||
return copy;
|
return copy;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkDocument(final POIFSDocument document,
|
private static void checkDocument(final POIFSDocument document, final byte[] input)
|
||||||
final byte [] input)
|
throws IOException {
|
||||||
throws IOException
|
|
||||||
{
|
|
||||||
int big_blocks = 0;
|
int big_blocks = 0;
|
||||||
int small_blocks = 0;
|
int small_blocks = 0;
|
||||||
int total_output = 0;
|
int total_output = 0;
|
||||||
@ -221,11 +194,8 @@ public class TestDocument
|
|||||||
input)), input);
|
input)), input);
|
||||||
}
|
}
|
||||||
|
|
||||||
private byte [] checkValues(int big_blocks, int small_blocks,
|
private static byte[] checkValues(int big_blocks, int small_blocks, int total_output,
|
||||||
int total_output, POIFSDocument document,
|
POIFSDocument document, byte[] input) throws IOException {
|
||||||
byte [] input)
|
|
||||||
throws IOException
|
|
||||||
{
|
|
||||||
assertEquals(document, document.getDocumentProperty().getDocument());
|
assertEquals(document, document.getDocumentProperty().getDocument());
|
||||||
int increment = ( int ) Math.sqrt(input.length);
|
int increment = ( int ) Math.sqrt(input.length);
|
||||||
|
|
||||||
@ -267,17 +237,4 @@ public class TestDocument
|
|||||||
}
|
}
|
||||||
return output;
|
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
/* ====================================================================
|
/* ====================================================================
|
||||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
contributor license agreements. See the NOTICE file distributed with
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
@ -15,53 +14,30 @@
|
|||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
==================================================================== */
|
==================================================================== */
|
||||||
|
|
||||||
|
|
||||||
package org.apache.poi.poifs.filesystem;
|
package org.apache.poi.poifs.filesystem;
|
||||||
|
|
||||||
import junit.framework.*;
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class to test DocumentDescriptor functionality
|
* Class to test DocumentDescriptor functionality
|
||||||
*
|
*
|
||||||
* @author Marc Johnson
|
* @author Marc Johnson
|
||||||
*/
|
*/
|
||||||
|
public final class TestDocumentDescriptor extends TestCase {
|
||||||
public class TestDocumentDescriptor
|
|
||||||
extends TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor TestDocumentDescriptor
|
|
||||||
*
|
|
||||||
* @param name
|
|
||||||
*/
|
|
||||||
|
|
||||||
public TestDocumentDescriptor(String name)
|
|
||||||
{
|
|
||||||
super(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* test equality
|
* test equality
|
||||||
*/
|
*/
|
||||||
|
public void testEquality() {
|
||||||
public void testEquality()
|
String[] names = { "c1", "c2", "c3", "c4", "c5" };
|
||||||
{
|
|
||||||
String[] names =
|
|
||||||
{
|
|
||||||
"c1", "c2", "c3", "c4", "c5"
|
|
||||||
};
|
|
||||||
POIFSDocumentPath a1 = new POIFSDocumentPath();
|
POIFSDocumentPath a1 = new POIFSDocumentPath();
|
||||||
POIFSDocumentPath a2 = new POIFSDocumentPath(null);
|
POIFSDocumentPath a2 = new POIFSDocumentPath(null);
|
||||||
POIFSDocumentPath a3 = new POIFSDocumentPath(new String[ 0 ]);
|
POIFSDocumentPath a3 = new POIFSDocumentPath(new String[ 0 ]);
|
||||||
POIFSDocumentPath a4 = new POIFSDocumentPath(a1, null);
|
POIFSDocumentPath a4 = new POIFSDocumentPath(a1, null);
|
||||||
POIFSDocumentPath a5 = new POIFSDocumentPath(a1,
|
POIFSDocumentPath a5 = new POIFSDocumentPath(a1,
|
||||||
new String[ 0 ]);
|
new String[ 0 ]);
|
||||||
POIFSDocumentPath[] paths =
|
POIFSDocumentPath[] paths = { a1, a2, a3, a4, a5 };
|
||||||
{
|
|
||||||
a1, a2, a3, a4, a5
|
|
||||||
};
|
|
||||||
|
|
||||||
for (int j = 0; j < paths.length; j++)
|
for (int j = 0; j < paths.length; j++)
|
||||||
{
|
{
|
||||||
@ -196,17 +172,4 @@ public class TestDocumentDescriptor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
==================================================================== */
|
==================================================================== */
|
||||||
|
|
||||||
|
|
||||||
package org.apache.poi.poifs.filesystem;
|
package org.apache.poi.poifs.filesystem;
|
||||||
|
|
||||||
@ -32,31 +31,12 @@ import org.apache.poi.poifs.storage.RawDataBlock;
|
|||||||
*
|
*
|
||||||
* @author Marc Johnson
|
* @author Marc Johnson
|
||||||
*/
|
*/
|
||||||
|
public final class TestDocumentNode extends TestCase {
|
||||||
public class TestDocumentNode
|
|
||||||
extends TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor TestDocumentNode
|
|
||||||
*
|
|
||||||
* @param name
|
|
||||||
*/
|
|
||||||
|
|
||||||
public TestDocumentNode(String name)
|
|
||||||
{
|
|
||||||
super(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* test constructor
|
* test constructor
|
||||||
*
|
|
||||||
* @exception IOException
|
|
||||||
*/
|
*/
|
||||||
|
public void testConstructor() throws IOException {
|
||||||
public void testConstructor()
|
|
||||||
throws IOException
|
|
||||||
{
|
|
||||||
DirectoryProperty property1 = new DirectoryProperty("directory");
|
DirectoryProperty property1 = new DirectoryProperty("directory");
|
||||||
RawDataBlock[] rawBlocks = new RawDataBlock[ 4 ];
|
RawDataBlock[] rawBlocks = new RawDataBlock[ 4 ];
|
||||||
ByteArrayInputStream stream =
|
ByteArrayInputStream stream =
|
||||||
@ -90,17 +70,4 @@ public class TestDocumentNode
|
|||||||
// verify getParent behaves correctly
|
// verify getParent behaves correctly
|
||||||
assertEquals(parent, node.getParent());
|
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -15,53 +15,26 @@
|
|||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
==================================================================== */
|
==================================================================== */
|
||||||
|
|
||||||
|
|
||||||
package org.apache.poi.poifs.filesystem;
|
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.TestCase;
|
||||||
|
|
||||||
import junit.framework.*;
|
|
||||||
|
|
||||||
import org.apache.poi.poifs.property.DirectoryProperty;
|
|
||||||
import org.apache.poi.poifs.property.DocumentProperty;
|
|
||||||
import org.apache.poi.poifs.storage.RawDataBlock;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class to test DocumentOutputStream functionality
|
* Class to test DocumentOutputStream functionality
|
||||||
*
|
*
|
||||||
* @author Marc Johnson
|
* @author Marc Johnson
|
||||||
*/
|
*/
|
||||||
|
public final class TestDocumentOutputStream extends TestCase {
|
||||||
public class TestDocumentOutputStream
|
|
||||||
extends TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor TestDocumentOutputStream
|
|
||||||
*
|
|
||||||
* @param name
|
|
||||||
*
|
|
||||||
* @exception IOException
|
|
||||||
*/
|
|
||||||
|
|
||||||
public TestDocumentOutputStream(String name)
|
|
||||||
throws IOException
|
|
||||||
{
|
|
||||||
super(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* test write(int) behavior
|
* test write(int) behavior
|
||||||
*
|
|
||||||
* @exception IOException
|
|
||||||
*/
|
*/
|
||||||
|
public void testWrite1() throws IOException {
|
||||||
public void testWrite1()
|
|
||||||
throws IOException
|
|
||||||
{
|
|
||||||
ByteArrayOutputStream stream = new ByteArrayOutputStream();
|
ByteArrayOutputStream stream = new ByteArrayOutputStream();
|
||||||
DocumentOutputStream dstream = new DocumentOutputStream(stream, 25);
|
DocumentOutputStream dstream = new DocumentOutputStream(stream, 25);
|
||||||
|
|
||||||
@ -89,13 +62,8 @@ public class TestDocumentOutputStream
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* test write(byte[]) behavior
|
* test write(byte[]) behavior
|
||||||
*
|
|
||||||
* @exception IOException
|
|
||||||
*/
|
*/
|
||||||
|
public void testWrite2() throws IOException {
|
||||||
public void testWrite2()
|
|
||||||
throws IOException
|
|
||||||
{
|
|
||||||
ByteArrayOutputStream stream = new ByteArrayOutputStream();
|
ByteArrayOutputStream stream = new ByteArrayOutputStream();
|
||||||
DocumentOutputStream dstream = new DocumentOutputStream(stream, 25);
|
DocumentOutputStream dstream = new DocumentOutputStream(stream, 25);
|
||||||
|
|
||||||
@ -133,13 +101,8 @@ public class TestDocumentOutputStream
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* test write(byte[], int, int) behavior
|
* test write(byte[], int, int) behavior
|
||||||
*
|
|
||||||
* @exception IOException
|
|
||||||
*/
|
*/
|
||||||
|
public void testWrite3() throws IOException {
|
||||||
public void testWrite3()
|
|
||||||
throws IOException
|
|
||||||
{
|
|
||||||
ByteArrayOutputStream stream = new ByteArrayOutputStream();
|
ByteArrayOutputStream stream = new ByteArrayOutputStream();
|
||||||
DocumentOutputStream dstream = new DocumentOutputStream(stream, 25);
|
DocumentOutputStream dstream = new DocumentOutputStream(stream, 25);
|
||||||
byte[] array = new byte[ 50 ];
|
byte[] array = new byte[ 50 ];
|
||||||
@ -169,13 +132,8 @@ public class TestDocumentOutputStream
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* test writeFiller()
|
* test writeFiller()
|
||||||
*
|
|
||||||
* @exception IOException
|
|
||||||
*/
|
*/
|
||||||
|
public void testWriteFiller() throws IOException {
|
||||||
public void testWriteFiller()
|
|
||||||
throws IOException
|
|
||||||
{
|
|
||||||
ByteArrayOutputStream stream = new ByteArrayOutputStream();
|
ByteArrayOutputStream stream = new ByteArrayOutputStream();
|
||||||
DocumentOutputStream dstream = new DocumentOutputStream(stream, 25);
|
DocumentOutputStream dstream = new DocumentOutputStream(stream, 25);
|
||||||
|
|
||||||
@ -205,17 +163,4 @@ public class TestDocumentOutputStream
|
|||||||
}
|
}
|
||||||
stream.close();
|
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -30,143 +30,88 @@ import org.apache.poi.poifs.filesystem.POIFSWriterEvent;
|
|||||||
import org.apache.poi.poifs.filesystem.POIFSWriterListener;
|
import org.apache.poi.poifs.filesystem.POIFSWriterListener;
|
||||||
import org.apache.poi.poifs.filesystem.DirectoryEntry;
|
import org.apache.poi.poifs.filesystem.DirectoryEntry;
|
||||||
|
|
||||||
public class TestEmptyDocument extends TestCase {
|
public final class TestEmptyDocument extends TestCase {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public void testSingleEmptyDocument() throws IOException {
|
||||||
TestEmptyDocument driver = new TestEmptyDocument();
|
POIFSFileSystem fs = new POIFSFileSystem();
|
||||||
|
DirectoryEntry dir = fs.getRoot();
|
||||||
|
dir.createDocument("Foo", new ByteArrayInputStream(new byte[] {}));
|
||||||
|
|
||||||
System.out.println();
|
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||||
System.out.println("As only file...");
|
fs.writeFilesystem(out);
|
||||||
System.out.println();
|
new POIFSFileSystem(new ByteArrayInputStream(out.toByteArray()));
|
||||||
|
}
|
||||||
|
|
||||||
System.out.print("Trying using createDocument(String,InputStream): ");
|
public void testSingleEmptyDocumentEvent() throws IOException {
|
||||||
try {
|
POIFSFileSystem fs = new POIFSFileSystem();
|
||||||
driver.testSingleEmptyDocument();
|
DirectoryEntry dir = fs.getRoot();
|
||||||
System.out.println("Worked!");
|
dir.createDocument("Foo", 0, new POIFSWriterListener() {
|
||||||
} catch (IOException exception) {
|
public void processPOIFSWriterEvent(POIFSWriterEvent event) {
|
||||||
System.out.println("failed! ");
|
System.out.println("written");
|
||||||
System.out.println(exception.toString());
|
}
|
||||||
}
|
});
|
||||||
System.out.println();
|
|
||||||
|
|
||||||
System.out.print
|
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||||
("Trying using createDocument(String,int,POIFSWriterListener): ");
|
fs.writeFilesystem(out);
|
||||||
try {
|
new POIFSFileSystem(new ByteArrayInputStream(out.toByteArray()));
|
||||||
driver.testSingleEmptyDocumentEvent();
|
}
|
||||||
System.out.println("Worked!");
|
|
||||||
} catch (IOException exception) {
|
|
||||||
System.out.println("failed!");
|
|
||||||
System.out.println(exception.toString());
|
|
||||||
}
|
|
||||||
System.out.println();
|
|
||||||
|
|
||||||
System.out.println();
|
public void testEmptyDocumentWithFriend() throws IOException {
|
||||||
System.out.println("After another file...");
|
POIFSFileSystem fs = new POIFSFileSystem();
|
||||||
System.out.println();
|
DirectoryEntry dir = fs.getRoot();
|
||||||
|
dir.createDocument("Bar", new ByteArrayInputStream(new byte[] { 0 }));
|
||||||
|
dir.createDocument("Foo", new ByteArrayInputStream(new byte[] {}));
|
||||||
|
|
||||||
System.out.print("Trying using createDocument(String,InputStream): ");
|
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||||
try {
|
fs.writeFilesystem(out);
|
||||||
driver.testEmptyDocumentWithFriend();
|
new POIFSFileSystem(new ByteArrayInputStream(out.toByteArray()));
|
||||||
System.out.println("Worked!");
|
}
|
||||||
} catch (IOException exception) {
|
|
||||||
System.out.println("failed! ");
|
|
||||||
System.out.println(exception.toString());
|
|
||||||
}
|
|
||||||
System.out.println();
|
|
||||||
|
|
||||||
System.out.print
|
public void testEmptyDocumentEventWithFriend() throws IOException {
|
||||||
("Trying using createDocument(String,int,POIFSWriterListener): ");
|
POIFSFileSystem fs = new POIFSFileSystem();
|
||||||
try {
|
DirectoryEntry dir = fs.getRoot();
|
||||||
driver.testEmptyDocumentWithFriend();
|
dir.createDocument("Bar", 1, new POIFSWriterListener() {
|
||||||
System.out.println("Worked!");
|
public void processPOIFSWriterEvent(POIFSWriterEvent event) {
|
||||||
} catch (IOException exception) {
|
try {
|
||||||
System.out.println("failed!");
|
event.getStream().write(0);
|
||||||
System.out.println(exception.toString());
|
} catch (IOException exception) {
|
||||||
}
|
throw new RuntimeException("exception on write: " + exception);
|
||||||
System.out.println();
|
}
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
dir.createDocument("Foo", 0, new POIFSWriterListener() {
|
||||||
|
public void processPOIFSWriterEvent(POIFSWriterEvent event) {
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
public void testSingleEmptyDocument() throws IOException {
|
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||||
POIFSFileSystem fs = new POIFSFileSystem();
|
fs.writeFilesystem(out);
|
||||||
DirectoryEntry dir = fs.getRoot();
|
new POIFSFileSystem(new ByteArrayInputStream(out.toByteArray()));
|
||||||
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 {
|
public void testEmptyDocumentBug11744() throws Exception {
|
||||||
POIFSFileSystem fs = new POIFSFileSystem();
|
byte[] testData = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
|
||||||
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();
|
||||||
POIFSFileSystem fs = new POIFSFileSystem();
|
fs.createDocument(new ByteArrayInputStream(new byte[0]), "Empty");
|
||||||
DirectoryEntry dir = fs.getRoot();
|
fs.createDocument(new ByteArrayInputStream(testData), "NotEmpty");
|
||||||
dir.createDocument("Bar", new ByteArrayInputStream(new byte[] { 0 }));
|
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||||
dir.createDocument("Foo", new ByteArrayInputStream(new byte[] { }));
|
fs.writeFilesystem(out);
|
||||||
|
out.toByteArray();
|
||||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
|
||||||
fs.writeFilesystem(out);
|
|
||||||
new POIFSFileSystem(new ByteArrayInputStream(out.toByteArray()));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testEmptyDocumentEventWithFriend() throws IOException {
|
// This line caused the error.
|
||||||
POIFSFileSystem fs = new POIFSFileSystem();
|
fs = new POIFSFileSystem(new ByteArrayInputStream(out.toByteArray()));
|
||||||
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 {
|
DocumentEntry entry = (DocumentEntry) fs.getRoot().getEntry("Empty");
|
||||||
byte[] testData = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
|
assertEquals("Expected zero size", 0, entry.getSize());
|
||||||
|
byte[] actualReadbackData;
|
||||||
|
actualReadbackData = IOUtils.toByteArray(new DocumentInputStream(entry));
|
||||||
|
assertEquals("Expected zero read from stream", 0, actualReadbackData.length);
|
||||||
|
|
||||||
POIFSFileSystem fs = new POIFSFileSystem();
|
entry = (DocumentEntry) fs.getRoot().getEntry("NotEmpty");
|
||||||
fs.createDocument(new ByteArrayInputStream(new byte[0]), "Empty");
|
actualReadbackData = IOUtils.toByteArray(new DocumentInputStream(entry));
|
||||||
fs.createDocument(new ByteArrayInputStream(testData), "NotEmpty");
|
assertEquals("Expected size was wrong", testData.length, entry.getSize());
|
||||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
assertTrue("Expected different data read from stream", Arrays.equals(testData,
|
||||||
fs.writeFilesystem(out);
|
actualReadbackData));
|
||||||
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));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
/* ====================================================================
|
/* ====================================================================
|
||||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
contributor license agreements. See the NOTICE file distributed with
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
@ -15,39 +14,23 @@
|
|||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
==================================================================== */
|
==================================================================== */
|
||||||
|
|
||||||
|
|
||||||
package org.apache.poi.poifs.filesystem;
|
package org.apache.poi.poifs.filesystem;
|
||||||
|
|
||||||
import junit.framework.*;
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class to test POIFSDocumentPath functionality
|
* Class to test POIFSDocumentPath functionality
|
||||||
*
|
*
|
||||||
* @author Marc Johnson
|
* @author Marc Johnson
|
||||||
*/
|
*/
|
||||||
|
public final class TestPOIFSDocumentPath extends TestCase {
|
||||||
|
|
||||||
public class TestPOIFSDocumentPath
|
|
||||||
extends TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor TestPOIFSDocumentPath
|
|
||||||
*
|
|
||||||
* @param name
|
|
||||||
*/
|
|
||||||
|
|
||||||
public TestPOIFSDocumentPath(String name)
|
|
||||||
{
|
|
||||||
super(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test default constructor
|
* Test default constructor
|
||||||
*/
|
*/
|
||||||
|
public void testDefaultConstructor() {
|
||||||
public void testDefaultConstructor()
|
|
||||||
{
|
|
||||||
POIFSDocumentPath path = new POIFSDocumentPath();
|
POIFSDocumentPath path = new POIFSDocumentPath();
|
||||||
|
|
||||||
assertEquals(0, path.length());
|
assertEquals(0, path.length());
|
||||||
@ -56,9 +39,7 @@ public class TestPOIFSDocumentPath
|
|||||||
/**
|
/**
|
||||||
* Test full path constructor
|
* Test full path constructor
|
||||||
*/
|
*/
|
||||||
|
public void testFullPathConstructor() {
|
||||||
public void testFullPathConstructor()
|
|
||||||
{
|
|
||||||
String[] components =
|
String[] components =
|
||||||
{
|
{
|
||||||
"foo", "bar", "foobar", "fubar"
|
"foo", "bar", "foobar", "fubar"
|
||||||
@ -125,9 +106,7 @@ public class TestPOIFSDocumentPath
|
|||||||
/**
|
/**
|
||||||
* Test relative path constructor
|
* Test relative path constructor
|
||||||
*/
|
*/
|
||||||
|
public void testRelativePathConstructor() {
|
||||||
public void testRelativePathConstructor()
|
|
||||||
{
|
|
||||||
String[] initialComponents =
|
String[] initialComponents =
|
||||||
{
|
{
|
||||||
"a", "b", "c"
|
"a", "b", "c"
|
||||||
@ -216,9 +195,7 @@ public class TestPOIFSDocumentPath
|
|||||||
/**
|
/**
|
||||||
* test equality
|
* test equality
|
||||||
*/
|
*/
|
||||||
|
public void testEquality() {
|
||||||
public void testEquality()
|
|
||||||
{
|
|
||||||
POIFSDocumentPath a1 = new POIFSDocumentPath();
|
POIFSDocumentPath a1 = new POIFSDocumentPath();
|
||||||
POIFSDocumentPath a2 = new POIFSDocumentPath(null);
|
POIFSDocumentPath a2 = new POIFSDocumentPath(null);
|
||||||
POIFSDocumentPath a3 = new POIFSDocumentPath(new String[ 0 ]);
|
POIFSDocumentPath a3 = new POIFSDocumentPath(new String[ 0 ]);
|
||||||
@ -318,17 +295,4 @@ public class TestPOIFSDocumentPath
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 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.POIFSDocumentPath");
|
|
||||||
junit.textui.TestRunner.run(TestPOIFSDocumentPath.class);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
/* ====================================================================
|
/* ====================================================================
|
||||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
contributor license agreements. See the NOTICE file distributed with
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
@ -15,63 +14,39 @@
|
|||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
==================================================================== */
|
==================================================================== */
|
||||||
|
|
||||||
|
|
||||||
package org.apache.poi.poifs.property;
|
package org.apache.poi.poifs.property;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import java.util.*;
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
import junit.framework.*;
|
|
||||||
|
|
||||||
import org.apache.poi.poifs.common.POIFSConstants;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class to test DirectoryProperty functionality
|
* Class to test DirectoryProperty functionality
|
||||||
*
|
*
|
||||||
* @author Marc Johnson
|
* @author Marc Johnson
|
||||||
*/
|
*/
|
||||||
|
public final class TestDirectoryProperty extends TestCase {
|
||||||
public class TestDirectoryProperty
|
|
||||||
extends TestCase
|
|
||||||
{
|
|
||||||
private DirectoryProperty _property;
|
private DirectoryProperty _property;
|
||||||
private byte[] _testblock;
|
private byte[] _testblock;
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor TestDirectoryProperty
|
|
||||||
*
|
|
||||||
* @param name
|
|
||||||
*/
|
|
||||||
|
|
||||||
public TestDirectoryProperty(String name)
|
|
||||||
{
|
|
||||||
super(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test constructing DirectoryProperty
|
* Test constructing DirectoryProperty
|
||||||
*
|
|
||||||
* @exception IOException
|
|
||||||
*/
|
*/
|
||||||
|
public void testConstructor() throws IOException {
|
||||||
public void testConstructor()
|
|
||||||
throws IOException
|
|
||||||
{
|
|
||||||
createBasicDirectoryProperty();
|
createBasicDirectoryProperty();
|
||||||
verifyProperty();
|
verifyProperty();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test pre-write functionality
|
* Test pre-write functionality
|
||||||
*
|
|
||||||
* @exception IOException
|
|
||||||
*/
|
*/
|
||||||
|
public void testPreWrite() throws IOException {
|
||||||
public void testPreWrite()
|
|
||||||
throws IOException
|
|
||||||
{
|
|
||||||
createBasicDirectoryProperty();
|
createBasicDirectoryProperty();
|
||||||
_property.preWrite();
|
_property.preWrite();
|
||||||
|
|
||||||
@ -119,9 +94,7 @@ public class TestDirectoryProperty
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void verifyChildren(int count)
|
private void verifyChildren(int count) {
|
||||||
throws IOException
|
|
||||||
{
|
|
||||||
Iterator iter = _property.getChildren();
|
Iterator iter = _property.getChildren();
|
||||||
List children = new ArrayList();
|
List children = new ArrayList();
|
||||||
|
|
||||||
@ -175,8 +148,7 @@ public class TestDirectoryProperty
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createBasicDirectoryProperty()
|
private void createBasicDirectoryProperty() {
|
||||||
{
|
|
||||||
String name = "MyDirectory";
|
String name = "MyDirectory";
|
||||||
|
|
||||||
_property = new DirectoryProperty(name);
|
_property = new DirectoryProperty(name);
|
||||||
@ -209,9 +181,7 @@ public class TestDirectoryProperty
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void verifyProperty()
|
private void verifyProperty() throws IOException {
|
||||||
throws IOException
|
|
||||||
{
|
|
||||||
ByteArrayOutputStream stream = new ByteArrayOutputStream(512);
|
ByteArrayOutputStream stream = new ByteArrayOutputStream(512);
|
||||||
|
|
||||||
_property.writeData(stream);
|
_property.writeData(stream);
|
||||||
@ -225,15 +195,7 @@ public class TestDirectoryProperty
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void testAddChild() throws IOException {
|
||||||
* Test addChild
|
|
||||||
*
|
|
||||||
* @exception IOException
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testAddChild()
|
|
||||||
throws IOException
|
|
||||||
{
|
|
||||||
createBasicDirectoryProperty();
|
createBasicDirectoryProperty();
|
||||||
_property.addChild(new LocalProperty(1));
|
_property.addChild(new LocalProperty(1));
|
||||||
_property.addChild(new LocalProperty(2));
|
_property.addChild(new LocalProperty(2));
|
||||||
@ -260,15 +222,7 @@ public class TestDirectoryProperty
|
|||||||
_property.addChild(new LocalProperty(3));
|
_property.addChild(new LocalProperty(3));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void testDeleteChild() throws IOException {
|
||||||
* Test deleteChild
|
|
||||||
*
|
|
||||||
* @exception IOException
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testDeleteChild()
|
|
||||||
throws IOException
|
|
||||||
{
|
|
||||||
createBasicDirectoryProperty();
|
createBasicDirectoryProperty();
|
||||||
Property p1 = new LocalProperty(1);
|
Property p1 = new LocalProperty(1);
|
||||||
|
|
||||||
@ -288,15 +242,7 @@ public class TestDirectoryProperty
|
|||||||
_property.addChild(new LocalProperty(1));
|
_property.addChild(new LocalProperty(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void testChangeName() throws IOException {
|
||||||
* Test changeName
|
|
||||||
*
|
|
||||||
* @exception IOException
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testChangeName()
|
|
||||||
throws IOException
|
|
||||||
{
|
|
||||||
createBasicDirectoryProperty();
|
createBasicDirectoryProperty();
|
||||||
Property p1 = new LocalProperty(1);
|
Property p1 = new LocalProperty(1);
|
||||||
String originalName = p1.getName();
|
String originalName = p1.getName();
|
||||||
@ -314,15 +260,7 @@ public class TestDirectoryProperty
|
|||||||
assertTrue(_property.changeName(p1, originalName));
|
assertTrue(_property.changeName(p1, originalName));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void testReadingConstructor() throws IOException {
|
||||||
* Test reading constructor
|
|
||||||
*
|
|
||||||
* @exception IOException
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testReadingConstructor()
|
|
||||||
throws IOException
|
|
||||||
{
|
|
||||||
byte[] input =
|
byte[] input =
|
||||||
{
|
{
|
||||||
( byte ) 0x42, ( byte ) 0x00, ( byte ) 0x6F, ( byte ) 0x00,
|
( byte ) 0x42, ( byte ) 0x00, ( byte ) 0x6F, ( byte ) 0x00,
|
||||||
@ -362,7 +300,7 @@ public class TestDirectoryProperty
|
|||||||
verifyReadingProperty(0, input, 0, "Boot Entry");
|
verifyReadingProperty(0, input, 0, "Boot Entry");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void verifyReadingProperty(int index, byte [] input, int offset,
|
private static void verifyReadingProperty(int index, byte [] input, int offset,
|
||||||
String name)
|
String name)
|
||||||
throws IOException
|
throws IOException
|
||||||
{
|
{
|
||||||
@ -385,17 +323,4 @@ public class TestDirectoryProperty
|
|||||||
assertEquals(name, property.getName());
|
assertEquals(name, property.getName());
|
||||||
assertTrue(!property.getChildren().hasNext());
|
assertTrue(!property.getChildren().hasNext());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 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.property.DirectoryProperty");
|
|
||||||
junit.textui.TestRunner.run(TestDirectoryProperty.class);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
/* ====================================================================
|
/* ====================================================================
|
||||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
contributor license agreements. See the NOTICE file distributed with
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
@ -15,49 +14,22 @@
|
|||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
==================================================================== */
|
==================================================================== */
|
||||||
|
|
||||||
|
|
||||||
package org.apache.poi.poifs.property;
|
package org.apache.poi.poifs.property;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
import java.util.*;
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
import junit.framework.*;
|
|
||||||
|
|
||||||
import org.apache.poi.poifs.property.DocumentProperty;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class to test DocumentProperty functionality
|
* Class to test DocumentProperty functionality
|
||||||
*
|
*
|
||||||
* @author Marc Johnson
|
* @author Marc Johnson
|
||||||
*/
|
*/
|
||||||
|
public final class TestDocumentProperty extends TestCase {
|
||||||
|
|
||||||
public class TestDocumentProperty
|
public void testConstructor() throws IOException {
|
||||||
extends TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor TestDocumentProperty
|
|
||||||
*
|
|
||||||
* @param name
|
|
||||||
*/
|
|
||||||
|
|
||||||
public TestDocumentProperty(String name)
|
|
||||||
{
|
|
||||||
super(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test constructing DocumentPropertys
|
|
||||||
*
|
|
||||||
* @exception IOException
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testConstructor()
|
|
||||||
throws IOException
|
|
||||||
{
|
|
||||||
|
|
||||||
// test with short name, small file
|
// test with short name, small file
|
||||||
verifyProperty("foo", 1234);
|
verifyProperty("foo", 1234);
|
||||||
|
|
||||||
@ -71,15 +43,7 @@ public class TestDocumentProperty
|
|||||||
verifyProperty("A.really.long.long.long.name123", 4096);
|
verifyProperty("A.really.long.long.long.name123", 4096);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void testReadingConstructor() throws IOException {
|
||||||
* Test reading constructor
|
|
||||||
*
|
|
||||||
* @exception IOException
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testReadingConstructor()
|
|
||||||
throws IOException
|
|
||||||
{
|
|
||||||
byte[] input =
|
byte[] input =
|
||||||
{
|
{
|
||||||
( byte ) 0x52, ( byte ) 0x00, ( byte ) 0x6F, ( byte ) 0x00,
|
( byte ) 0x52, ( byte ) 0x00, ( byte ) 0x6F, ( byte ) 0x00,
|
||||||
@ -217,14 +181,11 @@ public class TestDocumentProperty
|
|||||||
|
|
||||||
verifyReadingProperty(1, input, 128, "Workbook");
|
verifyReadingProperty(1, input, 128, "Workbook");
|
||||||
verifyReadingProperty(2, input, 256, "\005SummaryInformation");
|
verifyReadingProperty(2, input, 256, "\005SummaryInformation");
|
||||||
verifyReadingProperty(3, input, 384,
|
verifyReadingProperty(3, input, 384, "\005DocumentSummaryInformation");
|
||||||
"\005DocumentSummaryInformation");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void verifyReadingProperty(int index, byte [] input, int offset,
|
private void verifyReadingProperty(int index, byte[] input, int offset, String name)
|
||||||
String name)
|
throws IOException {
|
||||||
throws IOException
|
|
||||||
{
|
|
||||||
DocumentProperty property = new DocumentProperty(index, input,
|
DocumentProperty property = new DocumentProperty(index, input,
|
||||||
offset);
|
offset);
|
||||||
ByteArrayOutputStream stream = new ByteArrayOutputStream(128);
|
ByteArrayOutputStream stream = new ByteArrayOutputStream(128);
|
||||||
@ -244,9 +205,7 @@ public class TestDocumentProperty
|
|||||||
assertEquals(name, property.getName());
|
assertEquals(name, property.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void verifyProperty(String name, int size)
|
private void verifyProperty(String name, int size) throws IOException {
|
||||||
throws IOException
|
|
||||||
{
|
|
||||||
DocumentProperty property = new DocumentProperty(name, size);
|
DocumentProperty property = new DocumentProperty(name, size);
|
||||||
|
|
||||||
if (size >= 4096)
|
if (size >= 4096)
|
||||||
@ -309,17 +268,4 @@ public class TestDocumentProperty
|
|||||||
output[ j ]);
|
output[ j ]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 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.property.DocumentProperty");
|
|
||||||
junit.textui.TestRunner.run(TestDocumentProperty.class);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
/* ====================================================================
|
/* ====================================================================
|
||||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
contributor license agreements. See the NOTICE file distributed with
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
@ -15,15 +14,14 @@
|
|||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
==================================================================== */
|
==================================================================== */
|
||||||
|
|
||||||
|
|
||||||
package org.apache.poi.poifs.property;
|
package org.apache.poi.poifs.property;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import java.util.*;
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
import junit.framework.*;
|
|
||||||
|
|
||||||
import org.apache.poi.poifs.storage.RawDataBlock;
|
import org.apache.poi.poifs.storage.RawDataBlock;
|
||||||
|
|
||||||
@ -32,31 +30,9 @@ import org.apache.poi.poifs.storage.RawDataBlock;
|
|||||||
*
|
*
|
||||||
* @author Marc Johnson
|
* @author Marc Johnson
|
||||||
*/
|
*/
|
||||||
|
public final class TestPropertyFactory extends TestCase {
|
||||||
|
|
||||||
public class TestPropertyFactory
|
public void testConvertToProperties() throws IOException {
|
||||||
extends TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor TestPropertyFactory
|
|
||||||
*
|
|
||||||
* @param name
|
|
||||||
*/
|
|
||||||
|
|
||||||
public TestPropertyFactory(String name)
|
|
||||||
{
|
|
||||||
super(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test executing convertToProperties
|
|
||||||
*
|
|
||||||
* @exception IOException
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testConvertToProperties()
|
|
||||||
throws IOException
|
|
||||||
{
|
|
||||||
|
|
||||||
// real data from a real file!
|
// real data from a real file!
|
||||||
byte[] testdata =
|
byte[] testdata =
|
||||||
@ -2223,17 +2199,4 @@ public class TestPropertyFactory
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 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.property.PropertyFactory");
|
|
||||||
junit.textui.TestRunner.run(TestPropertyFactory.class);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
/* ====================================================================
|
/* ====================================================================
|
||||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
contributor license agreements. See the NOTICE file distributed with
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
@ -15,15 +14,16 @@
|
|||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
==================================================================== */
|
==================================================================== */
|
||||||
|
|
||||||
|
|
||||||
package org.apache.poi.poifs.property;
|
package org.apache.poi.poifs.property;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Iterator;
|
||||||
|
|
||||||
import java.util.*;
|
import junit.framework.AssertionFailedError;
|
||||||
|
import junit.framework.TestCase;
|
||||||
import junit.framework.*;
|
|
||||||
|
|
||||||
import org.apache.poi.poifs.common.POIFSConstants;
|
import org.apache.poi.poifs.common.POIFSConstants;
|
||||||
import org.apache.poi.poifs.storage.BlockAllocationTableReader;
|
import org.apache.poi.poifs.storage.BlockAllocationTableReader;
|
||||||
@ -34,21 +34,7 @@ import org.apache.poi.poifs.storage.RawDataBlockList;
|
|||||||
*
|
*
|
||||||
* @author Marc Johnson
|
* @author Marc Johnson
|
||||||
*/
|
*/
|
||||||
|
public final class TestPropertyTable extends TestCase {
|
||||||
public class TestPropertyTable
|
|
||||||
extends TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor TestPropertyTable
|
|
||||||
*
|
|
||||||
* @param name
|
|
||||||
*/
|
|
||||||
|
|
||||||
public TestPropertyTable(String name)
|
|
||||||
{
|
|
||||||
super(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test PropertyTable
|
* Test PropertyTable
|
||||||
@ -65,13 +51,8 @@ public class TestPropertyTable
|
|||||||
* the output (including the preWrite phase first), and comparing
|
* the output (including the preWrite phase first), and comparing
|
||||||
* it against a real property table extracted from a file known to
|
* it against a real property table extracted from a file known to
|
||||||
* be acceptable to Excel.
|
* be acceptable to Excel.
|
||||||
*
|
|
||||||
* @exception IOException
|
|
||||||
*/
|
*/
|
||||||
|
public void testWriterPropertyTable() throws IOException {
|
||||||
public void testWriterPropertyTable()
|
|
||||||
throws IOException
|
|
||||||
{
|
|
||||||
|
|
||||||
// create the PropertyTable
|
// create the PropertyTable
|
||||||
PropertyTable table = new PropertyTable();
|
PropertyTable table = new PropertyTable();
|
||||||
@ -105,6 +86,7 @@ public class TestPropertyTable
|
|||||||
ByteArrayOutputStream stream = new ByteArrayOutputStream(512);
|
ByteArrayOutputStream stream = new ByteArrayOutputStream(512);
|
||||||
byte[] testblock =
|
byte[] testblock =
|
||||||
{
|
{
|
||||||
|
// TODO - put this raw data in a better format
|
||||||
( byte ) 0x52, ( byte ) 0x00, ( byte ) 0x6f, ( byte ) 0x00,
|
( byte ) 0x52, ( byte ) 0x00, ( byte ) 0x6f, ( byte ) 0x00,
|
||||||
( byte ) 0x6f, ( byte ) 0x00, ( byte ) 0x74, ( byte ) 0x00,
|
( byte ) 0x6f, ( byte ) 0x00, ( byte ) 0x74, ( byte ) 0x00,
|
||||||
( byte ) 0x20, ( byte ) 0x00, ( byte ) 0x45, ( byte ) 0x00,
|
( byte ) 0x20, ( byte ) 0x00, ( byte ) 0x45, ( byte ) 0x00,
|
||||||
@ -2622,6 +2604,9 @@ public class TestPropertyTable
|
|||||||
child = ( Property ) iter.next();
|
child = ( Property ) iter.next();
|
||||||
++count;
|
++count;
|
||||||
}
|
}
|
||||||
|
if (child == null) {
|
||||||
|
throw new AssertionFailedError("no children found");
|
||||||
|
}
|
||||||
assertEquals(1, count);
|
assertEquals(1, count);
|
||||||
assertTrue(child.isDirectory());
|
assertTrue(child.isDirectory());
|
||||||
iter = (( DirectoryProperty ) child).getChildren();
|
iter = (( DirectoryProperty ) child).getChildren();
|
||||||
@ -2633,17 +2618,4 @@ public class TestPropertyTable
|
|||||||
}
|
}
|
||||||
assertEquals(35, count);
|
assertEquals(35, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 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.property.PropertyTable");
|
|
||||||
junit.textui.TestRunner.run(TestPropertyTable.class);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
/* ====================================================================
|
/* ====================================================================
|
||||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
contributor license agreements. See the NOTICE file distributed with
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
@ -15,15 +14,13 @@
|
|||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
==================================================================== */
|
==================================================================== */
|
||||||
|
|
||||||
|
|
||||||
package org.apache.poi.poifs.property;
|
package org.apache.poi.poifs.property;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
import java.util.*;
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
import junit.framework.*;
|
|
||||||
|
|
||||||
import org.apache.poi.poifs.common.POIFSConstants;
|
import org.apache.poi.poifs.common.POIFSConstants;
|
||||||
|
|
||||||
@ -32,33 +29,12 @@ import org.apache.poi.poifs.common.POIFSConstants;
|
|||||||
*
|
*
|
||||||
* @author Marc Johnson
|
* @author Marc Johnson
|
||||||
*/
|
*/
|
||||||
|
public final class TestRootProperty extends TestCase {
|
||||||
public class TestRootProperty
|
|
||||||
extends TestCase
|
|
||||||
{
|
|
||||||
private RootProperty _property;
|
private RootProperty _property;
|
||||||
private byte[] _testblock;
|
private byte[] _testblock;
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor TestRootProperty
|
|
||||||
*
|
|
||||||
* @param name
|
|
||||||
*/
|
|
||||||
|
|
||||||
public TestRootProperty(String name)
|
public void testConstructor() throws IOException {
|
||||||
{
|
|
||||||
super(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test constructing RootProperty
|
|
||||||
*
|
|
||||||
* @exception IOException
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testConstructor()
|
|
||||||
throws IOException
|
|
||||||
{
|
|
||||||
createBasicRootProperty();
|
createBasicRootProperty();
|
||||||
verifyProperty();
|
verifyProperty();
|
||||||
}
|
}
|
||||||
@ -105,9 +81,7 @@ public class TestRootProperty
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void verifyProperty()
|
private void verifyProperty() throws IOException {
|
||||||
throws IOException
|
|
||||||
{
|
|
||||||
ByteArrayOutputStream stream = new ByteArrayOutputStream(512);
|
ByteArrayOutputStream stream = new ByteArrayOutputStream(512);
|
||||||
|
|
||||||
_property.writeData(stream);
|
_property.writeData(stream);
|
||||||
@ -121,12 +95,7 @@ public class TestRootProperty
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void testSetSize() {
|
||||||
* test setSize
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testSetSize()
|
|
||||||
{
|
|
||||||
for (int j = 0; j < 10; j++)
|
for (int j = 0; j < 10; j++)
|
||||||
{
|
{
|
||||||
createBasicRootProperty();
|
createBasicRootProperty();
|
||||||
@ -136,15 +105,7 @@ public class TestRootProperty
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void testReadingConstructor() throws IOException {
|
||||||
* Test reading constructor
|
|
||||||
*
|
|
||||||
* @exception IOException
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testReadingConstructor()
|
|
||||||
throws IOException
|
|
||||||
{
|
|
||||||
byte[] input =
|
byte[] input =
|
||||||
{
|
{
|
||||||
( byte ) 0x52, ( byte ) 0x00, ( byte ) 0x6F, ( byte ) 0x00,
|
( byte ) 0x52, ( byte ) 0x00, ( byte ) 0x6F, ( byte ) 0x00,
|
||||||
@ -184,10 +145,8 @@ public class TestRootProperty
|
|||||||
verifyReadingProperty(0, input, 0, "Root Entry", "{00020820-0000-0000-C000-000000000046}");
|
verifyReadingProperty(0, input, 0, "Root Entry", "{00020820-0000-0000-C000-000000000046}");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void verifyReadingProperty(int index, byte [] input, int offset,
|
private void verifyReadingProperty(int index, byte[] input, int offset, String name,
|
||||||
String name, String sClsId)
|
String sClsId) throws IOException {
|
||||||
throws IOException
|
|
||||||
{
|
|
||||||
RootProperty property = new RootProperty(index, input,
|
RootProperty property = new RootProperty(index, input,
|
||||||
offset);
|
offset);
|
||||||
ByteArrayOutputStream stream = new ByteArrayOutputStream(128);
|
ByteArrayOutputStream stream = new ByteArrayOutputStream(128);
|
||||||
@ -208,17 +167,4 @@ public class TestRootProperty
|
|||||||
assertTrue(!property.getChildren().hasNext());
|
assertTrue(!property.getChildren().hasNext());
|
||||||
assertEquals(property.getStorageClsid().toString(), sClsId);
|
assertEquals(property.getStorageClsid().toString(), sClsId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 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.property.RootProperty");
|
|
||||||
junit.textui.TestRunner.run(TestRootProperty.class);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
/* ====================================================================
|
/* ====================================================================
|
||||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
contributor license agreements. See the NOTICE file distributed with
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
@ -15,49 +14,29 @@
|
|||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
==================================================================== */
|
==================================================================== */
|
||||||
|
|
||||||
|
|
||||||
package org.apache.poi.poifs.storage;
|
package org.apache.poi.poifs.storage;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
import java.util.*;
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
import junit.framework.*;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class to test BATBlock functionality
|
* Class to test BATBlock functionality
|
||||||
*
|
*
|
||||||
* @author Marc Johnson
|
* @author Marc Johnson
|
||||||
*/
|
*/
|
||||||
|
public final class TestBATBlock extends TestCase {
|
||||||
public class TestBATBlock
|
|
||||||
extends TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor TestBATBlock
|
|
||||||
*
|
|
||||||
* @param name
|
|
||||||
*/
|
|
||||||
|
|
||||||
public TestBATBlock(String name)
|
|
||||||
{
|
|
||||||
super(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test the createBATBlocks method. The test involves setting up
|
* Test the createBATBlocks method. The test involves setting up
|
||||||
* various arrays of int's and ensuring that the correct number of
|
* various arrays of int's and ensuring that the correct number of
|
||||||
* BATBlocks is created for each array, and that the data from
|
* BATBlocks is created for each array, and that the data from
|
||||||
* each array is correctly written to the BATBlocks.
|
* each array is correctly written to the BATBlocks.
|
||||||
*
|
|
||||||
* @exception IOException
|
|
||||||
*/
|
*/
|
||||||
|
public void testCreateBATBlocks() throws IOException {
|
||||||
public void testCreateBATBlocks()
|
|
||||||
throws IOException
|
|
||||||
{
|
|
||||||
|
|
||||||
// test 0 length array (basic sanity)
|
// test 0 length array (basic sanity)
|
||||||
BATBlock[] rvalue = BATBlock.createBATBlocks(createTestArray(0));
|
BATBlock[] rvalue = BATBlock.createBATBlocks(createTestArray(0));
|
||||||
@ -85,8 +64,7 @@ public class TestBATBlock
|
|||||||
verifyContents(rvalue, 129);
|
verifyContents(rvalue, 129);
|
||||||
}
|
}
|
||||||
|
|
||||||
private int [] createTestArray(int count)
|
private static int[] createTestArray(int count) {
|
||||||
{
|
|
||||||
int[] rvalue = new int[ count ];
|
int[] rvalue = new int[ count ];
|
||||||
|
|
||||||
for (int j = 0; j < count; j++)
|
for (int j = 0; j < count; j++)
|
||||||
@ -96,9 +74,7 @@ public class TestBATBlock
|
|||||||
return rvalue;
|
return rvalue;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void verifyContents(BATBlock [] blocks, int entries)
|
private static void verifyContents(BATBlock[] blocks, int entries) throws IOException {
|
||||||
throws IOException
|
|
||||||
{
|
|
||||||
byte[] expected = new byte[ 512 * blocks.length ];
|
byte[] expected = new byte[ 512 * blocks.length ];
|
||||||
|
|
||||||
Arrays.fill(expected, ( byte ) 0xFF);
|
Arrays.fill(expected, ( byte ) 0xFF);
|
||||||
@ -127,16 +103,7 @@ public class TestBATBlock
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void testCreateXBATBlocks() throws IOException {
|
||||||
* test createXBATBlocks
|
|
||||||
*
|
|
||||||
* @exception IOException
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testCreateXBATBlocks()
|
|
||||||
throws IOException
|
|
||||||
{
|
|
||||||
|
|
||||||
// test 0 length array (basic sanity)
|
// test 0 length array (basic sanity)
|
||||||
BATBlock[] rvalue = BATBlock.createXBATBlocks(createTestArray(0), 1);
|
BATBlock[] rvalue = BATBlock.createXBATBlocks(createTestArray(0), 1);
|
||||||
|
|
||||||
@ -168,10 +135,8 @@ public class TestBATBlock
|
|||||||
verifyXBATContents(rvalue, 255, 1);
|
verifyXBATContents(rvalue, 255, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void verifyXBATContents(BATBlock [] blocks, int entries,
|
private static void verifyXBATContents(BATBlock[] blocks, int entries, int start_block)
|
||||||
int start_block)
|
throws IOException {
|
||||||
throws IOException
|
|
||||||
{
|
|
||||||
byte[] expected = new byte[ 512 * blocks.length ];
|
byte[] expected = new byte[ 512 * blocks.length ];
|
||||||
|
|
||||||
Arrays.fill(expected, ( byte ) 0xFF);
|
Arrays.fill(expected, ( byte ) 0xFF);
|
||||||
@ -220,20 +185,9 @@ public class TestBATBlock
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void testCalculateXBATStorageRequirements() {
|
||||||
* test calculateXBATStorageRequirements
|
int[] blockCounts = { 0, 1, 127, 128 };
|
||||||
*/
|
int[] requirements = { 0, 1, 1, 2 };
|
||||||
|
|
||||||
public void testCalculateXBATStorageRequirements()
|
|
||||||
{
|
|
||||||
int[] blockCounts =
|
|
||||||
{
|
|
||||||
0, 1, 127, 128
|
|
||||||
};
|
|
||||||
int[] requirements =
|
|
||||||
{
|
|
||||||
0, 1, 1, 2
|
|
||||||
};
|
|
||||||
|
|
||||||
for (int j = 0; j < blockCounts.length; j++)
|
for (int j = 0; j < blockCounts.length; j++)
|
||||||
{
|
{
|
||||||
@ -243,42 +197,13 @@ public class TestBATBlock
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void testEntriesPerBlock() {
|
||||||
* test entriesPerBlock
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testEntriesPerBlock()
|
|
||||||
{
|
|
||||||
assertEquals(128, BATBlock.entriesPerBlock());
|
assertEquals(128, BATBlock.entriesPerBlock());
|
||||||
}
|
}
|
||||||
|
public void testEntriesPerXBATBlock() {
|
||||||
/**
|
|
||||||
* test entriesPerXBATBlock
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testEntriesPerXBATBlock()
|
|
||||||
{
|
|
||||||
assertEquals(127, BATBlock.entriesPerXBATBlock());
|
assertEquals(127, BATBlock.entriesPerXBATBlock());
|
||||||
}
|
}
|
||||||
|
public void testGetXBATChainOffset() {
|
||||||
/**
|
|
||||||
* test getXBATChainOffset
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testGetXBATChainOffset()
|
|
||||||
{
|
|
||||||
assertEquals(508, BATBlock.getXBATChainOffset());
|
assertEquals(508, BATBlock.getXBATChainOffset());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 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.storage.BATBlock");
|
|
||||||
junit.textui.TestRunner.run(TestBATBlock.class);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
/* ====================================================================
|
/* ====================================================================
|
||||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
contributor license agreements. See the NOTICE file distributed with
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
@ -15,15 +14,13 @@
|
|||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
==================================================================== */
|
==================================================================== */
|
||||||
|
|
||||||
|
|
||||||
package org.apache.poi.poifs.storage;
|
package org.apache.poi.poifs.storage;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
import java.util.*;
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
import junit.framework.*;
|
|
||||||
|
|
||||||
import org.apache.poi.poifs.common.POIFSConstants;
|
import org.apache.poi.poifs.common.POIFSConstants;
|
||||||
import org.apache.poi.util.LittleEndian;
|
import org.apache.poi.util.LittleEndian;
|
||||||
@ -34,36 +31,18 @@ import org.apache.poi.util.LittleEndianConsts;
|
|||||||
*
|
*
|
||||||
* @author Marc Johnson
|
* @author Marc Johnson
|
||||||
*/
|
*/
|
||||||
|
public final class TestBlockAllocationTableReader extends TestCase {
|
||||||
public class TestBlockAllocationTableReader
|
|
||||||
extends TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor TestBlockAllocationTableReader
|
|
||||||
*
|
|
||||||
* @param name
|
|
||||||
*/
|
|
||||||
|
|
||||||
public TestBlockAllocationTableReader(String name)
|
|
||||||
{
|
|
||||||
super(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test small block allocation table constructor
|
* Test small block allocation table constructor
|
||||||
*
|
|
||||||
* @exception IOException
|
|
||||||
*/
|
*/
|
||||||
|
public void testSmallBATConstructor() throws IOException {
|
||||||
public void testSmallBATConstructor()
|
|
||||||
throws IOException
|
|
||||||
{
|
|
||||||
|
|
||||||
// need to create an array of raw blocks containing the SBAT,
|
// need to create an array of raw blocks containing the SBAT,
|
||||||
// and a small document block list
|
// and a small document block list
|
||||||
byte[] sbat_data =
|
byte[] sbat_data =
|
||||||
{
|
{
|
||||||
|
// TODO - put this raw data in a better format
|
||||||
( byte ) 0xFF, ( byte ) 0xFF, ( byte ) 0xFF, ( byte ) 0xFF,
|
( byte ) 0xFF, ( byte ) 0xFF, ( byte ) 0xFF, ( byte ) 0xFF,
|
||||||
( byte ) 0xFF, ( byte ) 0xFF, ( byte ) 0xFF, ( byte ) 0xFF,
|
( byte ) 0xFF, ( byte ) 0xFF, ( byte ) 0xFF, ( byte ) 0xFF,
|
||||||
( byte ) 0xFF, ( byte ) 0xFF, ( byte ) 0xFF, ( byte ) 0xFF,
|
( byte ) 0xFF, ( byte ) 0xFF, ( byte ) 0xFF, ( byte ) 0xFF,
|
||||||
@ -1160,28 +1139,20 @@ public class TestBlockAllocationTableReader
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void testReadingConstructor() throws IOException {
|
||||||
* Test reading constructor
|
|
||||||
*
|
|
||||||
* @exception IOException
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testReadingConstructor()
|
|
||||||
throws IOException
|
|
||||||
{
|
|
||||||
|
|
||||||
// create a document, minus the header block, and use that to
|
// create a document, minus the header block, and use that to
|
||||||
// create a RawDataBlockList. The document will exist entire
|
// create a RawDataBlockList. The document will exist entire
|
||||||
// of BATBlocks and XBATBlocks
|
// of BATBlocks and XBATBlocks
|
||||||
//
|
//
|
||||||
// we will create two XBAT blocks, which will encompass 128
|
// we will create two XBAT blocks, which will encompass 128
|
||||||
// BAT blocks between them, and two extra BAT blocks which
|
// BAT blocks between them, and two extra BAT blocks which
|
||||||
// will be in the block array passed to the constructor. This
|
// will be in the block array passed to the constructor. This
|
||||||
// makes a total of 130 BAT blocks, which will encompass
|
// makes a total of 130 BAT blocks, which will encompass
|
||||||
// 16,640 blocks, for a file size of some 8.5 megabytes.
|
// 16,640 blocks, for a file size of some 8.5 megabytes.
|
||||||
//
|
//
|
||||||
// Naturally, we'll fake that out ...
|
// Naturally, we'll fake that out ...
|
||||||
//
|
//
|
||||||
// map of blocks:
|
// map of blocks:
|
||||||
// block 0: xbat block 0
|
// block 0: xbat block 0
|
||||||
// block 1: xbat block 1
|
// block 1: xbat block 1
|
||||||
@ -1229,18 +1200,10 @@ public class TestBlockAllocationTableReader
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void testFetchBlocks() throws IOException {
|
||||||
* Test fetchBlocks
|
|
||||||
*
|
|
||||||
* @exception IOException
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testFetchBlocks()
|
|
||||||
throws IOException
|
|
||||||
{
|
|
||||||
|
|
||||||
// strategy:
|
// strategy:
|
||||||
//
|
//
|
||||||
// 1. set up a single BAT block from which to construct a
|
// 1. set up a single BAT block from which to construct a
|
||||||
// BAT. create nonsense blocks in the raw data block list
|
// BAT. create nonsense blocks in the raw data block list
|
||||||
// corresponding to the indices in the BAT block.
|
// corresponding to the indices in the BAT block.
|
||||||
@ -1350,17 +1313,4 @@ public class TestBlockAllocationTableReader
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 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.storage.BlockAllocationTableReader");
|
|
||||||
junit.textui.TestRunner.run(TestBlockAllocationTableReader.class);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
/* ====================================================================
|
/* ====================================================================
|
||||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
contributor license agreements. See the NOTICE file distributed with
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
@ -15,15 +14,14 @@
|
|||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
==================================================================== */
|
==================================================================== */
|
||||||
|
|
||||||
|
|
||||||
package org.apache.poi.poifs.storage;
|
package org.apache.poi.poifs.storage;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
import java.util.*;
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
import junit.framework.*;
|
|
||||||
|
|
||||||
import org.apache.poi.poifs.common.POIFSConstants;
|
import org.apache.poi.poifs.common.POIFSConstants;
|
||||||
import org.apache.poi.util.LittleEndian;
|
import org.apache.poi.util.LittleEndian;
|
||||||
@ -34,28 +32,9 @@ import org.apache.poi.util.LittleEndianConsts;
|
|||||||
*
|
*
|
||||||
* @author Marc Johnson
|
* @author Marc Johnson
|
||||||
*/
|
*/
|
||||||
|
public final class TestBlockAllocationTableWriter extends TestCase {
|
||||||
|
|
||||||
public class TestBlockAllocationTableWriter
|
public void testAllocateSpace() {
|
||||||
extends TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor TestBlockAllocationTableWriter
|
|
||||||
*
|
|
||||||
* @param name
|
|
||||||
*/
|
|
||||||
|
|
||||||
public TestBlockAllocationTableWriter(String name)
|
|
||||||
{
|
|
||||||
super(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test the allocateSpace method.
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testAllocateSpace()
|
|
||||||
{
|
|
||||||
BlockAllocationTableWriter table =
|
BlockAllocationTableWriter table =
|
||||||
new BlockAllocationTableWriter();
|
new BlockAllocationTableWriter();
|
||||||
int[] blockSizes =
|
int[] blockSizes =
|
||||||
@ -71,15 +50,7 @@ public class TestBlockAllocationTableWriter
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void testCreateBlocks() {
|
||||||
* Test the createBlocks method
|
|
||||||
*
|
|
||||||
* @exception IOException
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testCreateBlocks()
|
|
||||||
throws IOException
|
|
||||||
{
|
|
||||||
BlockAllocationTableWriter table = new BlockAllocationTableWriter();
|
BlockAllocationTableWriter table = new BlockAllocationTableWriter();
|
||||||
|
|
||||||
table.allocateSpace(127);
|
table.allocateSpace(127);
|
||||||
@ -117,13 +88,8 @@ public class TestBlockAllocationTableWriter
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Test content produced by BlockAllocationTableWriter
|
* Test content produced by BlockAllocationTableWriter
|
||||||
*
|
|
||||||
* @exception IOException
|
|
||||||
*/
|
*/
|
||||||
|
public void testProduct() throws IOException {
|
||||||
public void testProduct()
|
|
||||||
throws IOException
|
|
||||||
{
|
|
||||||
BlockAllocationTableWriter table = new BlockAllocationTableWriter();
|
BlockAllocationTableWriter table = new BlockAllocationTableWriter();
|
||||||
|
|
||||||
for (int k = 1; k <= 22; k++)
|
for (int k = 1; k <= 22; k++)
|
||||||
@ -168,28 +134,16 @@ public class TestBlockAllocationTableWriter
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void verifyBlocksCreated(BlockAllocationTableWriter table,
|
private static void verifyBlocksCreated(BlockAllocationTableWriter table, int count){
|
||||||
int count)
|
|
||||||
throws IOException
|
|
||||||
{
|
|
||||||
ByteArrayOutputStream stream = new ByteArrayOutputStream();
|
ByteArrayOutputStream stream = new ByteArrayOutputStream();
|
||||||
|
|
||||||
table.writeBlocks(stream);
|
try {
|
||||||
|
table.writeBlocks(stream);
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
byte[] output = stream.toByteArray();
|
byte[] output = stream.toByteArray();
|
||||||
|
|
||||||
assertEquals(count * 512, output.length);
|
assertEquals(count * 512, output.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 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.storage.BlockAllocationTableWriter");
|
|
||||||
junit.textui.TestRunner.run(TestBlockAllocationTableWriter.class);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
/* ====================================================================
|
/* ====================================================================
|
||||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
contributor license agreements. See the NOTICE file distributed with
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
@ -15,15 +14,16 @@
|
|||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
==================================================================== */
|
==================================================================== */
|
||||||
|
|
||||||
|
|
||||||
package org.apache.poi.poifs.storage;
|
package org.apache.poi.poifs.storage;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import java.util.*;
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
import junit.framework.*;
|
|
||||||
|
|
||||||
import org.apache.poi.util.LittleEndian;
|
import org.apache.poi.util.LittleEndian;
|
||||||
import org.apache.poi.util.LittleEndianConsts;
|
import org.apache.poi.util.LittleEndianConsts;
|
||||||
@ -33,31 +33,9 @@ import org.apache.poi.util.LittleEndianConsts;
|
|||||||
*
|
*
|
||||||
* @author Marc Johnson
|
* @author Marc Johnson
|
||||||
*/
|
*/
|
||||||
|
public final class TestBlockListImpl extends TestCase {
|
||||||
|
|
||||||
public class TestBlockListImpl
|
public void testZap() throws IOException {
|
||||||
extends TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor TestBlockListImpl
|
|
||||||
*
|
|
||||||
* @param name
|
|
||||||
*/
|
|
||||||
|
|
||||||
public TestBlockListImpl(String name)
|
|
||||||
{
|
|
||||||
super(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* test zap method
|
|
||||||
*
|
|
||||||
* @exception IOException
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testZap()
|
|
||||||
throws IOException
|
|
||||||
{
|
|
||||||
BlockListImpl list = new BlockListImpl();
|
BlockListImpl list = new BlockListImpl();
|
||||||
|
|
||||||
// verify that you can zap anything
|
// verify that you can zap anything
|
||||||
@ -92,15 +70,7 @@ public class TestBlockListImpl
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void testRemove() throws IOException {
|
||||||
* test remove method
|
|
||||||
*
|
|
||||||
* @exception IOException
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testRemove()
|
|
||||||
throws IOException
|
|
||||||
{
|
|
||||||
BlockListImpl list = new BlockListImpl();
|
BlockListImpl list = new BlockListImpl();
|
||||||
RawDataBlock[] blocks = new RawDataBlock[ 5 ];
|
RawDataBlock[] blocks = new RawDataBlock[ 5 ];
|
||||||
byte[] data = new byte[ 512 * 5 ];
|
byte[] data = new byte[ 512 * 5 ];
|
||||||
@ -159,15 +129,7 @@ public class TestBlockListImpl
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void testSetBAT() throws IOException {
|
||||||
* test setBAT
|
|
||||||
*
|
|
||||||
* @exception IOException
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testSetBAT()
|
|
||||||
throws IOException
|
|
||||||
{
|
|
||||||
BlockListImpl list = new BlockListImpl();
|
BlockListImpl list = new BlockListImpl();
|
||||||
|
|
||||||
list.setBAT(null);
|
list.setBAT(null);
|
||||||
@ -182,18 +144,10 @@ public class TestBlockListImpl
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void testFetchBlocks() throws IOException {
|
||||||
* Test fetchBlocks
|
|
||||||
*
|
|
||||||
* @exception IOException
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testFetchBlocks()
|
|
||||||
throws IOException
|
|
||||||
{
|
|
||||||
|
|
||||||
// strategy:
|
// strategy:
|
||||||
//
|
//
|
||||||
// 1. set up a single BAT block from which to construct a
|
// 1. set up a single BAT block from which to construct a
|
||||||
// BAT. create nonsense blocks in the raw data block list
|
// BAT. create nonsense blocks in the raw data block list
|
||||||
// corresponding to the indices in the BAT block.
|
// corresponding to the indices in the BAT block.
|
||||||
@ -310,17 +264,4 @@ public class TestBlockListImpl
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 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.storage.BlockListImpl");
|
|
||||||
junit.textui.TestRunner.run(TestBlockListImpl.class);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
/* ====================================================================
|
/* ====================================================================
|
||||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
contributor license agreements. See the NOTICE file distributed with
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
@ -15,49 +14,22 @@
|
|||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
==================================================================== */
|
==================================================================== */
|
||||||
|
|
||||||
|
|
||||||
package org.apache.poi.poifs.storage;
|
package org.apache.poi.poifs.storage;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
import java.util.*;
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
import junit.framework.*;
|
|
||||||
|
|
||||||
import org.apache.poi.util.LittleEndian;
|
|
||||||
import org.apache.poi.util.LittleEndianConsts;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class to test HeaderBlockReader functionality
|
* Class to test HeaderBlockReader functionality
|
||||||
*
|
*
|
||||||
* @author Marc Johnson
|
* @author Marc Johnson
|
||||||
*/
|
*/
|
||||||
|
public final class TestHeaderBlockReader extends TestCase {
|
||||||
|
|
||||||
public class TestHeaderBlockReader
|
public void testConstructors() throws IOException {
|
||||||
extends TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor TestHeaderBlockReader
|
|
||||||
*
|
|
||||||
* @param name
|
|
||||||
*/
|
|
||||||
|
|
||||||
public TestHeaderBlockReader(String name)
|
|
||||||
{
|
|
||||||
super(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test creating a HeaderBlockReader
|
|
||||||
*
|
|
||||||
* @exception IOException
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testConstructors()
|
|
||||||
throws IOException
|
|
||||||
{
|
|
||||||
byte[] content =
|
byte[] content =
|
||||||
{
|
{
|
||||||
( byte ) 0xD0, ( byte ) 0xCF, ( byte ) 0x11, ( byte ) 0xE0,
|
( byte ) 0xD0, ( byte ) 0xCF, ( byte ) 0x11, ( byte ) 0xE0,
|
||||||
@ -231,17 +203,4 @@ public class TestHeaderBlockReader
|
|||||||
content[ index ] = ( byte ) (content[ index ] + 1);
|
content[ index ] = ( byte ) (content[ index ] + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 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.storage.HeaderBlockReader");
|
|
||||||
junit.textui.TestRunner.run(TestHeaderBlockReader.class);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
/* ====================================================================
|
/* ====================================================================
|
||||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
contributor license agreements. See the NOTICE file distributed with
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
@ -15,15 +14,14 @@
|
|||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
==================================================================== */
|
==================================================================== */
|
||||||
|
|
||||||
|
|
||||||
package org.apache.poi.poifs.storage;
|
package org.apache.poi.poifs.storage;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
import java.util.*;
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
import junit.framework.*;
|
|
||||||
|
|
||||||
import org.apache.poi.util.LittleEndian;
|
import org.apache.poi.util.LittleEndian;
|
||||||
import org.apache.poi.util.LittleEndianConsts;
|
import org.apache.poi.util.LittleEndianConsts;
|
||||||
@ -33,38 +31,19 @@ import org.apache.poi.util.LittleEndianConsts;
|
|||||||
*
|
*
|
||||||
* @author Marc Johnson
|
* @author Marc Johnson
|
||||||
*/
|
*/
|
||||||
|
public final class TestHeaderBlockWriter extends TestCase {
|
||||||
public class TestHeaderBlockWriter
|
|
||||||
extends TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor TestHeaderBlockWriter
|
|
||||||
*
|
|
||||||
* @param name
|
|
||||||
*/
|
|
||||||
|
|
||||||
public TestHeaderBlockWriter(String name)
|
|
||||||
{
|
|
||||||
super(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test creating a HeaderBlockWriter
|
* Test creating a HeaderBlockWriter
|
||||||
*
|
|
||||||
* @exception IOException
|
|
||||||
*/
|
*/
|
||||||
|
public void testConstructors() throws IOException {
|
||||||
public void testConstructors()
|
|
||||||
throws IOException
|
|
||||||
{
|
|
||||||
HeaderBlockWriter block = new HeaderBlockWriter();
|
HeaderBlockWriter block = new HeaderBlockWriter();
|
||||||
ByteArrayOutputStream output = new ByteArrayOutputStream(512);
|
ByteArrayOutputStream output = new ByteArrayOutputStream(512);
|
||||||
|
|
||||||
block.writeBlocks(output);
|
block.writeBlocks(output);
|
||||||
byte[] copy = output.toByteArray();
|
byte[] copy = output.toByteArray();
|
||||||
byte[] expected =
|
byte[] expected =
|
||||||
{
|
{ // TODO - put this raw data in a better format
|
||||||
( byte ) 0xD0, ( byte ) 0xCF, ( byte ) 0x11, ( byte ) 0xE0,
|
( byte ) 0xD0, ( byte ) 0xCF, ( byte ) 0x11, ( byte ) 0xE0,
|
||||||
( byte ) 0xA1, ( byte ) 0xB1, ( byte ) 0x1A, ( byte ) 0xE1,
|
( byte ) 0xA1, ( byte ) 0xB1, ( byte ) 0x1A, ( byte ) 0xE1,
|
||||||
( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00,
|
( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00,
|
||||||
@ -213,13 +192,8 @@ public class TestHeaderBlockWriter
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Test setting the SBAT start block
|
* Test setting the SBAT start block
|
||||||
*
|
|
||||||
* @exception IOException
|
|
||||||
*/
|
*/
|
||||||
|
public void testSetSBATStart() throws IOException {
|
||||||
public void testSetSBATStart()
|
|
||||||
throws IOException
|
|
||||||
{
|
|
||||||
HeaderBlockWriter block = new HeaderBlockWriter();
|
HeaderBlockWriter block = new HeaderBlockWriter();
|
||||||
|
|
||||||
block.setSBATStart(0x01234567);
|
block.setSBATStart(0x01234567);
|
||||||
@ -368,13 +342,8 @@ public class TestHeaderBlockWriter
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* test setPropertyStart and getPropertyStart
|
* test setPropertyStart and getPropertyStart
|
||||||
*
|
|
||||||
* @exception IOException
|
|
||||||
*/
|
*/
|
||||||
|
public void testSetPropertyStart() throws IOException {
|
||||||
public void testSetPropertyStart()
|
|
||||||
throws IOException
|
|
||||||
{
|
|
||||||
HeaderBlockWriter block = new HeaderBlockWriter();
|
HeaderBlockWriter block = new HeaderBlockWriter();
|
||||||
|
|
||||||
block.setPropertyStart(0x01234567);
|
block.setPropertyStart(0x01234567);
|
||||||
@ -524,13 +493,8 @@ public class TestHeaderBlockWriter
|
|||||||
/**
|
/**
|
||||||
* test setting the BAT blocks; also tests getBATCount,
|
* test setting the BAT blocks; also tests getBATCount,
|
||||||
* getBATArray, getXBATCount
|
* getBATArray, getXBATCount
|
||||||
*
|
|
||||||
* @exception IOException
|
|
||||||
*/
|
*/
|
||||||
|
public void testSetBATBlocks() throws IOException {
|
||||||
public void testSetBATBlocks()
|
|
||||||
throws IOException
|
|
||||||
{
|
|
||||||
|
|
||||||
// first, a small set of blocks
|
// first, a small set of blocks
|
||||||
HeaderBlockWriter block = new HeaderBlockWriter();
|
HeaderBlockWriter block = new HeaderBlockWriter();
|
||||||
@ -1009,17 +973,4 @@ public class TestHeaderBlockWriter
|
|||||||
assertEquals("XBAT End of chain", -2,
|
assertEquals("XBAT End of chain", -2,
|
||||||
LittleEndian.getInt(copy, offset));
|
LittleEndian.getInt(copy, offset));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 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.storage.HeaderBlockWriter");
|
|
||||||
junit.textui.TestRunner.run(TestHeaderBlockWriter.class);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
/* ====================================================================
|
/* ====================================================================
|
||||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
contributor license agreements. See the NOTICE file distributed with
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
@ -15,48 +14,24 @@
|
|||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
==================================================================== */
|
==================================================================== */
|
||||||
|
|
||||||
|
|
||||||
package org.apache.poi.poifs.storage;
|
package org.apache.poi.poifs.storage;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import java.util.*;
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
import junit.framework.*;
|
|
||||||
|
|
||||||
import org.apache.poi.poifs.property.Property;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class to test PropertyBlock functionality
|
* Class to test PropertyBlock functionality
|
||||||
*
|
*
|
||||||
* @author Marc Johnson
|
* @author Marc Johnson
|
||||||
*/
|
*/
|
||||||
|
public final class TestPropertyBlock extends TestCase {
|
||||||
|
|
||||||
public class TestPropertyBlock
|
public void testCreatePropertyBlocks() {
|
||||||
extends TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor TestPropertyBlock
|
|
||||||
*
|
|
||||||
* @param name
|
|
||||||
*/
|
|
||||||
|
|
||||||
public TestPropertyBlock(String name)
|
|
||||||
{
|
|
||||||
super(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test constructing PropertyBlocks
|
|
||||||
*
|
|
||||||
* @exception IOException
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testCreatePropertyBlocks()
|
|
||||||
throws IOException
|
|
||||||
{
|
|
||||||
|
|
||||||
// test with 0 properties
|
// test with 0 properties
|
||||||
List properties = new ArrayList();
|
List properties = new ArrayList();
|
||||||
@ -178,7 +153,7 @@ public class TestPropertyBlock
|
|||||||
verifyCorrect(blocks, testblock);
|
verifyCorrect(blocks, testblock);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setDefaultBlock(byte [] testblock, int j)
|
private static void setDefaultBlock(byte [] testblock, int j)
|
||||||
{
|
{
|
||||||
int base = j * 128;
|
int base = j * 128;
|
||||||
int index = 0;
|
int index = 0;
|
||||||
@ -204,15 +179,16 @@ public class TestPropertyBlock
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void verifyCorrect(BlockWritable [] blocks, byte [] testblock)
|
private static void verifyCorrect(BlockWritable[] blocks, byte[] testblock) {
|
||||||
throws IOException
|
|
||||||
{
|
|
||||||
ByteArrayOutputStream stream = new ByteArrayOutputStream(512
|
ByteArrayOutputStream stream = new ByteArrayOutputStream(512
|
||||||
* blocks.length);
|
* blocks.length);
|
||||||
|
|
||||||
for (int j = 0; j < blocks.length; j++)
|
for (int j = 0; j < blocks.length; j++) {
|
||||||
{
|
try {
|
||||||
blocks[ j ].writeBlocks(stream);
|
blocks[ j ].writeBlocks(stream);
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
byte[] output = stream.toByteArray();
|
byte[] output = stream.toByteArray();
|
||||||
|
|
||||||
@ -223,17 +199,4 @@ public class TestPropertyBlock
|
|||||||
output[ j ]);
|
output[ j ]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 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.storage.PropertyBlock");
|
|
||||||
junit.textui.TestRunner.run(TestPropertyBlock.class);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
/* ====================================================================
|
/* ====================================================================
|
||||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
contributor license agreements. See the NOTICE file distributed with
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
@ -15,235 +14,212 @@
|
|||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
==================================================================== */
|
==================================================================== */
|
||||||
|
|
||||||
|
|
||||||
package org.apache.poi.poifs.storage;
|
package org.apache.poi.poifs.storage;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.util.Random;
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
import org.apache.poi.util.DummyPOILogger;
|
import org.apache.poi.util.DummyPOILogger;
|
||||||
|
|
||||||
import junit.framework.*;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class to test RawDataBlock functionality
|
* Class to test RawDataBlock functionality
|
||||||
*
|
*
|
||||||
* @author Marc Johnson
|
* @author Marc Johnson
|
||||||
*/
|
*/
|
||||||
|
public final class TestRawDataBlock extends TestCase {
|
||||||
public class TestRawDataBlock
|
|
||||||
extends TestCase
|
|
||||||
{
|
|
||||||
static {
|
static {
|
||||||
// We always want to use our own
|
// We always want to use our own
|
||||||
// logger
|
// logger
|
||||||
System.setProperty(
|
System.setProperty(
|
||||||
"org.apache.poi.util.POILogger",
|
"org.apache.poi.util.POILogger",
|
||||||
"org.apache.poi.util.DummyPOILogger"
|
"org.apache.poi.util.DummyPOILogger"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor TestRawDataBlock
|
* Test creating a normal RawDataBlock
|
||||||
*
|
*/
|
||||||
* @param name
|
public void testNormalConstructor() throws IOException {
|
||||||
*/
|
byte[] data = new byte[ 512 ];
|
||||||
public TestRawDataBlock(String name)
|
|
||||||
{
|
|
||||||
super(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
for (int j = 0; j < 512; j++)
|
||||||
* Test creating a normal RawDataBlock
|
{
|
||||||
*
|
data[ j ] = ( byte ) j;
|
||||||
* @exception IOException
|
}
|
||||||
*/
|
RawDataBlock block = new RawDataBlock(new ByteArrayInputStream(data));
|
||||||
|
|
||||||
public void testNormalConstructor()
|
assertTrue("Should not be at EOF", !block.eof());
|
||||||
throws IOException
|
byte[] out_data = block.getData();
|
||||||
{
|
|
||||||
byte[] data = new byte[ 512 ];
|
|
||||||
|
|
||||||
for (int j = 0; j < 512; j++)
|
assertEquals("Should be same length", data.length, out_data.length);
|
||||||
{
|
for (int j = 0; j < 512; j++)
|
||||||
data[ j ] = ( byte ) j;
|
{
|
||||||
}
|
assertEquals("Should be same value at offset " + j, data[ j ],
|
||||||
RawDataBlock block = new RawDataBlock(new ByteArrayInputStream(data));
|
out_data[ j ]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
assertTrue("Should not be at EOF", !block.eof());
|
/**
|
||||||
byte[] out_data = block.getData();
|
* Test creating an empty RawDataBlock
|
||||||
|
*/
|
||||||
|
public void testEmptyConstructor() throws IOException {
|
||||||
|
byte[] data = new byte[ 0 ];
|
||||||
|
RawDataBlock block = new RawDataBlock(new ByteArrayInputStream(data));
|
||||||
|
|
||||||
assertEquals("Should be same length", data.length, out_data.length);
|
assertTrue("Should be at EOF", block.eof());
|
||||||
for (int j = 0; j < 512; j++)
|
try
|
||||||
{
|
{
|
||||||
assertEquals("Should be same value at offset " + j, data[ j ],
|
block.getData();
|
||||||
out_data[ j ]);
|
}
|
||||||
}
|
catch (IOException ignored)
|
||||||
}
|
{
|
||||||
|
|
||||||
/**
|
// as expected
|
||||||
* Test creating an empty RawDataBlock
|
}
|
||||||
*
|
}
|
||||||
* @exception IOException
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testEmptyConstructor()
|
/**
|
||||||
throws IOException
|
* Test creating a short RawDataBlock
|
||||||
{
|
* Will trigger a warning, but no longer an IOException,
|
||||||
byte[] data = new byte[ 0 ];
|
* as people seem to have "valid" truncated files
|
||||||
RawDataBlock block = new RawDataBlock(new ByteArrayInputStream(data));
|
*/
|
||||||
|
public void testShortConstructor() throws Exception {
|
||||||
|
// Get the logger to be used
|
||||||
|
DummyPOILogger logger = new DummyPOILogger();
|
||||||
|
Field fld = RawDataBlock.class.getDeclaredField("log");
|
||||||
|
fld.setAccessible(true);
|
||||||
|
fld.set(null, logger);
|
||||||
|
assertEquals(0, logger.logged.size());
|
||||||
|
|
||||||
assertTrue("Should be at EOF", block.eof());
|
// Test for various data sizes
|
||||||
try
|
for (int k = 1; k <= 512; k++)
|
||||||
{
|
{
|
||||||
block.getData();
|
byte[] data = new byte[ k ];
|
||||||
}
|
|
||||||
catch (IOException ignored)
|
|
||||||
{
|
|
||||||
|
|
||||||
// as expected
|
for (int j = 0; j < k; j++)
|
||||||
}
|
{
|
||||||
}
|
data[ j ] = ( byte ) j;
|
||||||
|
}
|
||||||
|
RawDataBlock block = null;
|
||||||
|
|
||||||
/**
|
logger.reset();
|
||||||
* Test creating a short RawDataBlock
|
assertEquals(0, logger.logged.size());
|
||||||
* Will trigger a warning, but no longer an IOException,
|
|
||||||
* as people seem to have "valid" truncated files
|
|
||||||
*/
|
|
||||||
public void testShortConstructor() throws Exception
|
|
||||||
{
|
|
||||||
// Get the logger to be used
|
|
||||||
DummyPOILogger logger = new DummyPOILogger();
|
|
||||||
Field fld = RawDataBlock.class.getDeclaredField("log");
|
|
||||||
fld.setAccessible(true);
|
|
||||||
fld.set(null, logger);
|
|
||||||
assertEquals(0, logger.logged.size());
|
|
||||||
|
|
||||||
// Test for various data sizes
|
|
||||||
for (int k = 1; k <= 512; k++)
|
|
||||||
{
|
|
||||||
byte[] data = new byte[ k ];
|
|
||||||
|
|
||||||
for (int j = 0; j < k; j++)
|
// Have it created
|
||||||
{
|
block = new RawDataBlock(new ByteArrayInputStream(data));
|
||||||
data[ j ] = ( byte ) j;
|
assertNotNull(block);
|
||||||
}
|
|
||||||
RawDataBlock block = null;
|
// Check for the warning is there for <512
|
||||||
|
if(k < 512) {
|
||||||
logger.reset();
|
assertEquals(
|
||||||
assertEquals(0, logger.logged.size());
|
"Warning on " + k + " byte short block",
|
||||||
|
1, logger.logged.size()
|
||||||
// Have it created
|
);
|
||||||
block = new RawDataBlock(new ByteArrayInputStream(data));
|
|
||||||
assertNotNull(block);
|
// Build the expected warning message, and check
|
||||||
|
String bts = k + " byte";
|
||||||
// Check for the warning is there for <512
|
if(k > 1) {
|
||||||
if(k < 512) {
|
bts += "s";
|
||||||
assertEquals(
|
}
|
||||||
"Warning on " + k + " byte short block",
|
|
||||||
1, logger.logged.size()
|
assertEquals(
|
||||||
);
|
"7 - Unable to read entire block; "+bts+" read before EOF; expected 512 bytes. Your document was either written by software that ignores the spec, or has been truncated!",
|
||||||
|
(String)(logger.logged.get(0))
|
||||||
// Build the expected warning message, and check
|
);
|
||||||
String bts = k + " byte";
|
} else {
|
||||||
if(k > 1) {
|
assertEquals(0, logger.logged.size());
|
||||||
bts += "s";
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
assertEquals(
|
|
||||||
"7 - Unable to read entire block; "+bts+" read before EOF; expected 512 bytes. Your document was either written by software that ignores the spec, or has been truncated!",
|
/**
|
||||||
(String)(logger.logged.get(0))
|
* Tests that when using a slow input stream, which
|
||||||
);
|
* won't return a full block at a time, we don't
|
||||||
} else {
|
* incorrectly think that there's not enough data
|
||||||
assertEquals(0, logger.logged.size());
|
*/
|
||||||
}
|
public void testSlowInputStream() throws Exception {
|
||||||
}
|
// Get the logger to be used
|
||||||
}
|
DummyPOILogger logger = new DummyPOILogger();
|
||||||
|
Field fld = RawDataBlock.class.getDeclaredField("log");
|
||||||
/**
|
fld.setAccessible(true);
|
||||||
* Tests that when using a slow input stream, which
|
fld.set(null, logger);
|
||||||
* won't return a full block at a time, we don't
|
assertEquals(0, logger.logged.size());
|
||||||
* incorrectly think that there's not enough data
|
|
||||||
*/
|
// Test for various ok data sizes
|
||||||
public void testSlowInputStream() throws Exception {
|
for (int k = 1; k < 512; k++) {
|
||||||
// Get the logger to be used
|
byte[] data = new byte[ 512 ];
|
||||||
DummyPOILogger logger = new DummyPOILogger();
|
for (int j = 0; j < data.length; j++) {
|
||||||
Field fld = RawDataBlock.class.getDeclaredField("log");
|
data[j] = (byte) j;
|
||||||
fld.setAccessible(true);
|
}
|
||||||
fld.set(null, logger);
|
|
||||||
assertEquals(0, logger.logged.size());
|
// Shouldn't complain, as there is enough data,
|
||||||
|
// even if it dribbles through
|
||||||
// Test for various ok data sizes
|
RawDataBlock block =
|
||||||
for (int k = 1; k < 512; k++) {
|
new RawDataBlock(new SlowInputStream(data, k));
|
||||||
byte[] data = new byte[ 512 ];
|
assertFalse(block.eof());
|
||||||
for (int j = 0; j < data.length; j++) {
|
}
|
||||||
data[j] = (byte) j;
|
|
||||||
}
|
// But if there wasn't enough data available, will
|
||||||
|
// complain
|
||||||
// Shouldn't complain, as there is enough data,
|
for (int k = 1; k < 512; k++) {
|
||||||
// even if it dribbles through
|
byte[] data = new byte[ 511 ];
|
||||||
RawDataBlock block =
|
for (int j = 0; j < data.length; j++) {
|
||||||
new RawDataBlock(new SlowInputStream(data, k));
|
data[j] = (byte) j;
|
||||||
assertFalse(block.eof());
|
}
|
||||||
}
|
|
||||||
|
logger.reset();
|
||||||
// But if there wasn't enough data available, will
|
assertEquals(0, logger.logged.size());
|
||||||
// complain
|
|
||||||
for (int k = 1; k < 512; k++) {
|
// Should complain, as there isn't enough data
|
||||||
byte[] data = new byte[ 511 ];
|
RawDataBlock block =
|
||||||
for (int j = 0; j < data.length; j++) {
|
new RawDataBlock(new SlowInputStream(data, k));
|
||||||
data[j] = (byte) j;
|
assertNotNull(block);
|
||||||
}
|
assertEquals(
|
||||||
|
"Warning on " + k + " byte short block",
|
||||||
logger.reset();
|
1, logger.logged.size()
|
||||||
assertEquals(0, logger.logged.size());
|
);
|
||||||
|
}
|
||||||
// Should complain, as there isn't enough data
|
}
|
||||||
RawDataBlock block =
|
|
||||||
new RawDataBlock(new SlowInputStream(data, k));
|
/**
|
||||||
assertNotNull(block);
|
* An input stream which will return a maximum of
|
||||||
assertEquals(
|
* a given number of bytes to read, and often claims
|
||||||
"Warning on " + k + " byte short block",
|
* not to have any data
|
||||||
1, logger.logged.size()
|
*/
|
||||||
);
|
public static class SlowInputStream extends InputStream {
|
||||||
}
|
private Random rnd = new Random();
|
||||||
}
|
private byte[] data;
|
||||||
|
private int chunkSize;
|
||||||
/**
|
private int pos = 0;
|
||||||
* An input stream which will return a maximum of
|
|
||||||
* a given number of bytes to read, and often claims
|
public SlowInputStream(byte[] data, int chunkSize) {
|
||||||
* not to have any data
|
this.chunkSize = chunkSize;
|
||||||
*/
|
this.data = data;
|
||||||
public static class SlowInputStream extends InputStream {
|
}
|
||||||
private Random rnd = new Random();
|
|
||||||
private byte[] data;
|
/**
|
||||||
private int chunkSize;
|
* 75% of the time, claim there's no data available
|
||||||
private int pos = 0;
|
*/
|
||||||
|
private boolean claimNoData() {
|
||||||
public SlowInputStream(byte[] data, int chunkSize) {
|
if(rnd.nextFloat() < 0.25f) {
|
||||||
this.chunkSize = chunkSize;
|
return false;
|
||||||
this.data = data;
|
}
|
||||||
}
|
return true;
|
||||||
|
}
|
||||||
/**
|
|
||||||
* 75% of the time, claim there's no data available
|
public int read() {
|
||||||
*/
|
|
||||||
private boolean claimNoData() {
|
|
||||||
if(rnd.nextFloat() < 0.25f) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int read() throws IOException {
|
|
||||||
if(pos >= data.length) {
|
if(pos >= data.length) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
int ret = data[pos];
|
int ret = data[pos];
|
||||||
pos++;
|
pos++;
|
||||||
|
|
||||||
if(ret < 0) ret += 256;
|
if(ret < 0) ret += 256;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -253,7 +229,7 @@ public class TestRawDataBlock
|
|||||||
* size, whichever is lower.
|
* size, whichever is lower.
|
||||||
* Quite often will simply claim to have no data
|
* Quite often will simply claim to have no data
|
||||||
*/
|
*/
|
||||||
public int read(byte[] b, int off, int len) throws IOException {
|
public int read(byte[] b, int off, int len) {
|
||||||
// Keep the length within the chunk size
|
// Keep the length within the chunk size
|
||||||
if(len > chunkSize) {
|
if(len > chunkSize) {
|
||||||
len = chunkSize;
|
len = chunkSize;
|
||||||
@ -261,40 +237,26 @@ public class TestRawDataBlock
|
|||||||
// Don't read off the end of the data
|
// Don't read off the end of the data
|
||||||
if(pos + len > data.length) {
|
if(pos + len > data.length) {
|
||||||
len = data.length - pos;
|
len = data.length - pos;
|
||||||
|
|
||||||
// Spot when we're out of data
|
// Spot when we're out of data
|
||||||
if(len == 0) {
|
if(len == 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 75% of the time, claim there's no data
|
// 75% of the time, claim there's no data
|
||||||
if(claimNoData()) {
|
if(claimNoData()) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copy, and return what we read
|
// Copy, and return what we read
|
||||||
System.arraycopy(data, pos, b, off, len);
|
System.arraycopy(data, pos, b, off, len);
|
||||||
pos += len;
|
pos += len;
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int read(byte[] b) throws IOException {
|
public int read(byte[] b) {
|
||||||
return read(b, 0, b.length);
|
return read(b, 0, b.length);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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.storage.RawDataBlock");
|
|
||||||
junit.textui.TestRunner.run(TestRawDataBlock.class);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
/* ====================================================================
|
/* ====================================================================
|
||||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
contributor license agreements. See the NOTICE file distributed with
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
@ -15,27 +14,24 @@
|
|||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
==================================================================== */
|
==================================================================== */
|
||||||
|
|
||||||
|
|
||||||
package org.apache.poi.poifs.storage;
|
package org.apache.poi.poifs.storage;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.IOException;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
|
|
||||||
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
import org.apache.poi.poifs.common.POIFSConstants;
|
import org.apache.poi.poifs.common.POIFSConstants;
|
||||||
import org.apache.poi.util.DummyPOILogger;
|
import org.apache.poi.util.DummyPOILogger;
|
||||||
|
|
||||||
import junit.framework.*;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class to test RawDataBlockList functionality
|
* Class to test RawDataBlockList functionality
|
||||||
*
|
*
|
||||||
* @author Marc Johnson
|
* @author Marc Johnson
|
||||||
*/
|
*/
|
||||||
|
public final class TestRawDataBlockList extends TestCase {
|
||||||
public class TestRawDataBlockList
|
|
||||||
extends TestCase
|
|
||||||
{
|
|
||||||
static {
|
static {
|
||||||
// We always want to use our own
|
// We always want to use our own
|
||||||
// logger
|
// logger
|
||||||
@ -45,24 +41,10 @@ public class TestRawDataBlockList
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor TestRawDataBlockList
|
|
||||||
*
|
|
||||||
* @param name
|
|
||||||
*/
|
|
||||||
public TestRawDataBlockList(String name)
|
|
||||||
{
|
|
||||||
super(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test creating a normal RawDataBlockList
|
* Test creating a normal RawDataBlockList
|
||||||
*
|
|
||||||
* @exception IOException
|
|
||||||
*/
|
*/
|
||||||
public void testNormalConstructor()
|
public void testNormalConstructor() throws IOException {
|
||||||
throws IOException
|
|
||||||
{
|
|
||||||
byte[] data = new byte[ 2560 ];
|
byte[] data = new byte[ 2560 ];
|
||||||
|
|
||||||
for (int j = 0; j < 2560; j++)
|
for (int j = 0; j < 2560; j++)
|
||||||
@ -74,29 +56,22 @@ public class TestRawDataBlockList
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Test creating an empty RawDataBlockList
|
* Test creating an empty RawDataBlockList
|
||||||
*
|
|
||||||
* @exception IOException
|
|
||||||
*/
|
*/
|
||||||
|
public void testEmptyConstructor() throws IOException {
|
||||||
public void testEmptyConstructor()
|
|
||||||
throws IOException
|
|
||||||
{
|
|
||||||
new RawDataBlockList(new ByteArrayInputStream(new byte[ 0 ]), POIFSConstants.BIG_BLOCK_SIZE);
|
new RawDataBlockList(new ByteArrayInputStream(new byte[ 0 ]), POIFSConstants.BIG_BLOCK_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test creating a short RawDataBlockList
|
* Test creating a short RawDataBlockList
|
||||||
*/
|
*/
|
||||||
|
public void testShortConstructor() throws Exception {
|
||||||
public void testShortConstructor() throws Exception
|
|
||||||
{
|
|
||||||
// Get the logger to be used
|
// Get the logger to be used
|
||||||
DummyPOILogger logger = new DummyPOILogger();
|
DummyPOILogger logger = new DummyPOILogger();
|
||||||
Field fld = RawDataBlock.class.getDeclaredField("log");
|
Field fld = RawDataBlock.class.getDeclaredField("log");
|
||||||
fld.setAccessible(true);
|
fld.setAccessible(true);
|
||||||
fld.set(null, logger);
|
fld.set(null, logger);
|
||||||
assertEquals(0, logger.logged.size());
|
assertEquals(0, logger.logged.size());
|
||||||
|
|
||||||
// Test for various short sizes
|
// Test for various short sizes
|
||||||
for (int k = 2049; k < 2560; k++)
|
for (int k = 2049; k < 2560; k++)
|
||||||
{
|
{
|
||||||
@ -113,17 +88,4 @@ public class TestRawDataBlockList
|
|||||||
assertEquals(1, logger.logged.size());
|
assertEquals(1, logger.logged.size());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 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.storage.RawDataBlockList");
|
|
||||||
junit.textui.TestRunner.run(TestRawDataBlockList.class);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
/* ====================================================================
|
/* ====================================================================
|
||||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
contributor license agreements. See the NOTICE file distributed with
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
@ -15,15 +14,13 @@
|
|||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
==================================================================== */
|
==================================================================== */
|
||||||
|
|
||||||
|
|
||||||
package org.apache.poi.poifs.storage;
|
package org.apache.poi.poifs.storage;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
import java.util.*;
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
import junit.framework.*;
|
|
||||||
|
|
||||||
import org.apache.poi.poifs.common.POIFSConstants;
|
import org.apache.poi.poifs.common.POIFSConstants;
|
||||||
import org.apache.poi.poifs.property.PropertyTable;
|
import org.apache.poi.poifs.property.PropertyTable;
|
||||||
@ -34,35 +31,13 @@ import org.apache.poi.poifs.property.RootProperty;
|
|||||||
*
|
*
|
||||||
* @author Marc Johnson
|
* @author Marc Johnson
|
||||||
*/
|
*/
|
||||||
|
public final class TestSmallBlockTableReader extends TestCase {
|
||||||
|
|
||||||
public class TestSmallBlockTableReader
|
public void testReadingConstructor() throws IOException {
|
||||||
extends TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor TestSmallBlockTableReader
|
|
||||||
*
|
|
||||||
* @param name
|
|
||||||
*/
|
|
||||||
|
|
||||||
public TestSmallBlockTableReader(String name)
|
|
||||||
{
|
|
||||||
super(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* test reading constructor
|
|
||||||
*
|
|
||||||
* @exception IOException
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testReadingConstructor()
|
|
||||||
throws IOException
|
|
||||||
{
|
|
||||||
|
|
||||||
// first, we need the raw data blocks
|
// first, we need the raw data blocks
|
||||||
byte[] raw_data_array =
|
byte[] raw_data_array =
|
||||||
{
|
{ // TODO - put this raw data in a better format
|
||||||
( byte ) 0x52, ( byte ) 0x00, ( byte ) 0x6F, ( byte ) 0x00,
|
( byte ) 0x52, ( byte ) 0x00, ( byte ) 0x6F, ( byte ) 0x00,
|
||||||
( byte ) 0x6F, ( byte ) 0x00, ( byte ) 0x74, ( byte ) 0x00,
|
( byte ) 0x6F, ( byte ) 0x00, ( byte ) 0x74, ( byte ) 0x00,
|
||||||
( byte ) 0x20, ( byte ) 0x00, ( byte ) 0x45, ( byte ) 0x00,
|
( byte ) 0x20, ( byte ) 0x00, ( byte ) 0x45, ( byte ) 0x00,
|
||||||
@ -2130,17 +2105,4 @@ public class TestSmallBlockTableReader
|
|||||||
SmallBlockTableReader.getSmallDocumentBlocks(data_blocks, root,
|
SmallBlockTableReader.getSmallDocumentBlocks(data_blocks, root,
|
||||||
14);
|
14);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 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.storage.SmallBlockTableReader");
|
|
||||||
junit.textui.TestRunner.run(TestSmallBlockTableReader.class);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
/* ====================================================================
|
/* ====================================================================
|
||||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
contributor license agreements. See the NOTICE file distributed with
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
@ -15,15 +14,15 @@
|
|||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
==================================================================== */
|
==================================================================== */
|
||||||
|
|
||||||
|
|
||||||
package org.apache.poi.poifs.storage;
|
package org.apache.poi.poifs.storage;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import java.util.*;
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
import junit.framework.*;
|
|
||||||
|
|
||||||
import org.apache.poi.poifs.filesystem.POIFSDocument;
|
import org.apache.poi.poifs.filesystem.POIFSDocument;
|
||||||
import org.apache.poi.poifs.property.PropertyTable;
|
import org.apache.poi.poifs.property.PropertyTable;
|
||||||
@ -34,32 +33,10 @@ import org.apache.poi.poifs.property.RootProperty;
|
|||||||
*
|
*
|
||||||
* @author Marc Johnson
|
* @author Marc Johnson
|
||||||
*/
|
*/
|
||||||
|
public final class TestSmallBlockTableWriter extends TestCase {
|
||||||
|
|
||||||
public class TestSmallBlockTableWriter
|
public void testWritingConstructor() throws IOException {
|
||||||
extends TestCase
|
List<POIFSDocument> documents = new ArrayList<POIFSDocument>();
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor TestSmallBlockTableWriter
|
|
||||||
*
|
|
||||||
* @param name
|
|
||||||
*/
|
|
||||||
|
|
||||||
public TestSmallBlockTableWriter(String name)
|
|
||||||
{
|
|
||||||
super(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* test writing constructor
|
|
||||||
*
|
|
||||||
* @exception IOException
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testWritingConstructor()
|
|
||||||
throws IOException
|
|
||||||
{
|
|
||||||
List documents = new ArrayList();
|
|
||||||
|
|
||||||
documents.add(
|
documents.add(
|
||||||
new POIFSDocument(
|
new POIFSDocument(
|
||||||
@ -113,17 +90,4 @@ public class TestSmallBlockTableWriter
|
|||||||
sbtw.setStartBlock(start_block);
|
sbtw.setStartBlock(start_block);
|
||||||
assertEquals(start_block, root.getStartBlock());
|
assertEquals(start_block, root.getStartBlock());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 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.storage.SmallBlockTableWriter");
|
|
||||||
junit.textui.TestRunner.run(TestSmallBlockTableWriter.class);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
/* ====================================================================
|
/* ====================================================================
|
||||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
contributor license agreements. See the NOTICE file distributed with
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
@ -15,44 +14,22 @@
|
|||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
==================================================================== */
|
==================================================================== */
|
||||||
|
|
||||||
|
|
||||||
package org.apache.poi.poifs.storage;
|
package org.apache.poi.poifs.storage;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
import junit.framework.*;
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class to test SmallDocumentBlockList functionality
|
* Class to test SmallDocumentBlockList functionality
|
||||||
*
|
*
|
||||||
* @author Marc Johnson
|
* @author Marc Johnson
|
||||||
*/
|
*/
|
||||||
|
public final class TestSmallDocumentBlockList extends TestCase {
|
||||||
|
|
||||||
public class TestSmallDocumentBlockList
|
public void testConstructor() throws IOException {
|
||||||
extends TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor TestSmallDocumentBlockList
|
|
||||||
*
|
|
||||||
* @param name
|
|
||||||
*/
|
|
||||||
|
|
||||||
public TestSmallDocumentBlockList(String name)
|
|
||||||
{
|
|
||||||
super(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test creating a SmallDocumentBlockList
|
|
||||||
*
|
|
||||||
* @exception IOException
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testConstructor()
|
|
||||||
throws IOException
|
|
||||||
{
|
|
||||||
byte[] data = new byte[ 2560 ];
|
byte[] data = new byte[ 2560 ];
|
||||||
|
|
||||||
for (int j = 0; j < 2560; j++)
|
for (int j = 0; j < 2560; j++)
|
||||||
@ -85,17 +62,4 @@ public class TestSmallDocumentBlockList
|
|||||||
// it better have thrown one!!
|
// it better have thrown one!!
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 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.storage.SmallDocumentBlockList");
|
|
||||||
junit.textui.TestRunner.run(TestSmallDocumentBlockList.class);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
==================================================================== */
|
==================================================================== */
|
||||||
|
|
||||||
|
|
||||||
package org.apache.poi.util;
|
package org.apache.poi.util;
|
||||||
|
|
||||||
@ -28,28 +27,9 @@ import java.util.*;
|
|||||||
*
|
*
|
||||||
* @author Marc Johnson (mjohnson at apache dot org)
|
* @author Marc Johnson (mjohnson at apache dot org)
|
||||||
*/
|
*/
|
||||||
|
public final class TestBinaryTree extends TestCase {
|
||||||
|
|
||||||
public class TestBinaryTree
|
public void testSize() {
|
||||||
extends TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* constructor
|
|
||||||
*
|
|
||||||
* @param name
|
|
||||||
*/
|
|
||||||
|
|
||||||
public TestBinaryTree(final String name)
|
|
||||||
{
|
|
||||||
super(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* test size() method
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testSize()
|
|
||||||
{
|
|
||||||
Map m = new BinaryTree();
|
Map m = new BinaryTree();
|
||||||
|
|
||||||
assertEquals(0, m.size());
|
assertEquals(0, m.size());
|
||||||
@ -74,12 +54,7 @@ public class TestBinaryTree
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void testIsEmpty() {
|
||||||
* test IsEmpty() method
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testIsEmpty()
|
|
||||||
{
|
|
||||||
Map m = new BinaryTree();
|
Map m = new BinaryTree();
|
||||||
|
|
||||||
assertTrue(m.isEmpty());
|
assertTrue(m.isEmpty());
|
||||||
@ -118,12 +93,7 @@ public class TestBinaryTree
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void testContainsKey() {
|
||||||
* test containsKey() method
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testContainsKey()
|
|
||||||
{
|
|
||||||
Map m = new BinaryTree();
|
Map m = new BinaryTree();
|
||||||
|
|
||||||
try
|
try
|
||||||
@ -166,12 +136,7 @@ public class TestBinaryTree
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void testContainsValue() {
|
||||||
* test containsValue() method
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testContainsValue()
|
|
||||||
{
|
|
||||||
Map m = new BinaryTree();
|
Map m = new BinaryTree();
|
||||||
LocalTestNode nodes[] = makeLocalNodes();
|
LocalTestNode nodes[] = makeLocalNodes();
|
||||||
|
|
||||||
@ -187,12 +152,7 @@ public class TestBinaryTree
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void testGet() {
|
||||||
* test get() method
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testGet()
|
|
||||||
{
|
|
||||||
Map m = new BinaryTree();
|
Map m = new BinaryTree();
|
||||||
|
|
||||||
try
|
try
|
||||||
@ -236,12 +196,7 @@ public class TestBinaryTree
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void testPut() {
|
||||||
* test put() method
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testPut()
|
|
||||||
{
|
|
||||||
Map m = new BinaryTree();
|
Map m = new BinaryTree();
|
||||||
|
|
||||||
try
|
try
|
||||||
@ -291,12 +246,7 @@ public class TestBinaryTree
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void testRemove() {
|
||||||
* test remove() method
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testRemove()
|
|
||||||
{
|
|
||||||
BinaryTree m = new BinaryTree();
|
BinaryTree m = new BinaryTree();
|
||||||
LocalTestNode nodes[] = makeLocalNodes();
|
LocalTestNode nodes[] = makeLocalNodes();
|
||||||
|
|
||||||
@ -350,12 +300,7 @@ public class TestBinaryTree
|
|||||||
assertTrue(m.isEmpty());
|
assertTrue(m.isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void testPutAll() {
|
||||||
* Method testPutAll
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testPutAll()
|
|
||||||
{
|
|
||||||
Map m = new BinaryTree();
|
Map m = new BinaryTree();
|
||||||
LocalTestNode nodes[] = makeLocalNodes();
|
LocalTestNode nodes[] = makeLocalNodes();
|
||||||
|
|
||||||
@ -419,12 +364,7 @@ public class TestBinaryTree
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void testClear() {
|
||||||
* test clear() method
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testClear()
|
|
||||||
{
|
|
||||||
Map m = new BinaryTree();
|
Map m = new BinaryTree();
|
||||||
LocalTestNode nodes[] = makeLocalNodes();
|
LocalTestNode nodes[] = makeLocalNodes();
|
||||||
|
|
||||||
@ -448,12 +388,7 @@ public class TestBinaryTree
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void testKeySet() {
|
||||||
* test keySet() method
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testKeySet()
|
|
||||||
{
|
|
||||||
testKeySet(new BinaryTree());
|
testKeySet(new BinaryTree());
|
||||||
Map m = new BinaryTree();
|
Map m = new BinaryTree();
|
||||||
LocalTestNode nodes[] = makeLocalNodes();
|
LocalTestNode nodes[] = makeLocalNodes();
|
||||||
@ -600,12 +535,7 @@ public class TestBinaryTree
|
|||||||
assertTrue(m.size() == 0);
|
assertTrue(m.size() == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void testValues() {
|
||||||
* test values() method
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testValues()
|
|
||||||
{
|
|
||||||
testValues(new BinaryTree());
|
testValues(new BinaryTree());
|
||||||
Map m = new BinaryTree();
|
Map m = new BinaryTree();
|
||||||
LocalTestNode nodes[] = makeLocalNodes();
|
LocalTestNode nodes[] = makeLocalNodes();
|
||||||
@ -741,12 +671,7 @@ public class TestBinaryTree
|
|||||||
assertEquals(0, m.size());
|
assertEquals(0, m.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void testEntrySet() {
|
||||||
* test entrySet() method
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testEntrySet()
|
|
||||||
{
|
|
||||||
testEntrySet(new BinaryTree());
|
testEntrySet(new BinaryTree());
|
||||||
Map m = new BinaryTree();
|
Map m = new BinaryTree();
|
||||||
LocalTestNode nodes[] = makeLocalNodes();
|
LocalTestNode nodes[] = makeLocalNodes();
|
||||||
@ -820,12 +745,7 @@ public class TestBinaryTree
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void testEquals() {
|
||||||
* Method testEquals
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testEquals()
|
|
||||||
{
|
|
||||||
Map m = new BinaryTree();
|
Map m = new BinaryTree();
|
||||||
LocalTestNode nodes[] = makeLocalNodes();
|
LocalTestNode nodes[] = makeLocalNodes();
|
||||||
|
|
||||||
@ -871,12 +791,7 @@ public class TestBinaryTree
|
|||||||
assertEquals(m, m1);
|
assertEquals(m, m1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void testHashCode() {
|
||||||
* test hashCode() method
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testHashCode()
|
|
||||||
{
|
|
||||||
Map m = new BinaryTree();
|
Map m = new BinaryTree();
|
||||||
LocalTestNode nodes[] = makeLocalNodes();
|
LocalTestNode nodes[] = makeLocalNodes();
|
||||||
|
|
||||||
@ -893,12 +808,7 @@ public class TestBinaryTree
|
|||||||
assertTrue(m.hashCode() == m1.hashCode());
|
assertTrue(m.hashCode() == m1.hashCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void testConstructors() {
|
||||||
* test constructors
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testConstructors()
|
|
||||||
{
|
|
||||||
BinaryTree m = new BinaryTree();
|
BinaryTree m = new BinaryTree();
|
||||||
|
|
||||||
assertTrue(m.isEmpty());
|
assertTrue(m.isEmpty());
|
||||||
@ -995,12 +905,7 @@ public class TestBinaryTree
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void testGetKeyForValue() {
|
||||||
* test getKeyForValue() method
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testGetKeyForValue()
|
|
||||||
{
|
|
||||||
BinaryTree m = new BinaryTree();
|
BinaryTree m = new BinaryTree();
|
||||||
|
|
||||||
try
|
try
|
||||||
@ -1044,12 +949,7 @@ public class TestBinaryTree
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void testRemoveValue() {
|
||||||
* test removeValue() method
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testRemoveValue()
|
|
||||||
{
|
|
||||||
BinaryTree m = new BinaryTree();
|
BinaryTree m = new BinaryTree();
|
||||||
LocalTestNode nodes[] = makeLocalNodes();
|
LocalTestNode nodes[] = makeLocalNodes();
|
||||||
|
|
||||||
@ -1099,12 +999,7 @@ public class TestBinaryTree
|
|||||||
assertTrue(m.isEmpty());
|
assertTrue(m.isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void testEntrySetByValue() {
|
||||||
* test entrySetByValue() method
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testEntrySetByValue()
|
|
||||||
{
|
|
||||||
testEntrySetByValue(new BinaryTree());
|
testEntrySetByValue(new BinaryTree());
|
||||||
BinaryTree m = new BinaryTree();
|
BinaryTree m = new BinaryTree();
|
||||||
LocalTestNode nodes[] = makeLocalNodes();
|
LocalTestNode nodes[] = makeLocalNodes();
|
||||||
@ -1178,12 +1073,7 @@ public class TestBinaryTree
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void testKeySetByValue() {
|
||||||
* test keySetByValue() method
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testKeySetByValue()
|
|
||||||
{
|
|
||||||
testKeySetByValue(new BinaryTree());
|
testKeySetByValue(new BinaryTree());
|
||||||
BinaryTree m = new BinaryTree();
|
BinaryTree m = new BinaryTree();
|
||||||
LocalTestNode nodes[] = makeLocalNodes();
|
LocalTestNode nodes[] = makeLocalNodes();
|
||||||
@ -1330,12 +1220,7 @@ public class TestBinaryTree
|
|||||||
assertTrue(m.size() == 0);
|
assertTrue(m.size() == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void testValuesByValue() {
|
||||||
* test valuesByValue() method
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testValuesByValue()
|
|
||||||
{
|
|
||||||
testValuesByValue(new BinaryTree());
|
testValuesByValue(new BinaryTree());
|
||||||
BinaryTree m = new BinaryTree();
|
BinaryTree m = new BinaryTree();
|
||||||
LocalTestNode nodes[] = makeLocalNodes();
|
LocalTestNode nodes[] = makeLocalNodes();
|
||||||
@ -1472,8 +1357,7 @@ public class TestBinaryTree
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* ********** START helper methods ********** */
|
/* ********** START helper methods ********** */
|
||||||
private void testKeySet(final Map m)
|
private static void testKeySet(final Map m) {
|
||||||
{
|
|
||||||
Set s = m.keySet();
|
Set s = m.keySet();
|
||||||
|
|
||||||
assertEquals(m.size(), s.size());
|
assertEquals(m.size(), s.size());
|
||||||
@ -1699,8 +1583,7 @@ public class TestBinaryTree
|
|||||||
assertTrue(s.hashCode() == hs.hashCode());
|
assertTrue(s.hashCode() == hs.hashCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void testKeySetByValue(final BinaryTree m)
|
private static void testKeySetByValue(final BinaryTree m) {
|
||||||
{
|
|
||||||
Set s = m.keySetByValue();
|
Set s = m.keySetByValue();
|
||||||
|
|
||||||
assertEquals(m.size(), s.size());
|
assertEquals(m.size(), s.size());
|
||||||
@ -1922,8 +1805,7 @@ public class TestBinaryTree
|
|||||||
assertTrue(s.hashCode() == hs.hashCode());
|
assertTrue(s.hashCode() == hs.hashCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void testValues(Map m)
|
private static void testValues(Map m) {
|
||||||
{
|
|
||||||
Collection s = m.values();
|
Collection s = m.values();
|
||||||
|
|
||||||
assertEquals(m.size(), s.size());
|
assertEquals(m.size(), s.size());
|
||||||
@ -2140,8 +2022,7 @@ public class TestBinaryTree
|
|||||||
assertTrue(!hs.equals(s));
|
assertTrue(!hs.equals(s));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void testValuesByValue(BinaryTree m)
|
private static void testValuesByValue(BinaryTree m) {
|
||||||
{
|
|
||||||
Collection s = m.valuesByValue();
|
Collection s = m.valuesByValue();
|
||||||
|
|
||||||
assertEquals(m.size(), s.size());
|
assertEquals(m.size(), s.size());
|
||||||
@ -2325,8 +2206,7 @@ public class TestBinaryTree
|
|||||||
assertTrue(!hs.equals(s));
|
assertTrue(!hs.equals(s));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void testEntrySet(Map m)
|
private static void testEntrySet(Map m) {
|
||||||
{
|
|
||||||
Set s = m.entrySet();
|
Set s = m.entrySet();
|
||||||
|
|
||||||
assertEquals(m.size(), s.size());
|
assertEquals(m.size(), s.size());
|
||||||
@ -2539,8 +2419,7 @@ public class TestBinaryTree
|
|||||||
assertTrue(s.hashCode() == hs.hashCode());
|
assertTrue(s.hashCode() == hs.hashCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void testEntrySetByValue(BinaryTree m)
|
private static void testEntrySetByValue(BinaryTree m) {
|
||||||
{
|
|
||||||
Set s = m.entrySetByValue();
|
Set s = m.entrySetByValue();
|
||||||
|
|
||||||
assertEquals(m.size(), s.size());
|
assertEquals(m.size(), s.size());
|
||||||
@ -2763,17 +2642,4 @@ public class TestBinaryTree
|
|||||||
}
|
}
|
||||||
return nodes;
|
return nodes;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ********** END helper methods ********** */
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Method main
|
|
||||||
*
|
|
||||||
* @param unused_args
|
|
||||||
*/
|
|
||||||
|
|
||||||
public static void main(final String unused_args[])
|
|
||||||
{
|
|
||||||
junit.textui.TestRunner.run(TestBinaryTree.class);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
/* ====================================================================
|
/* ====================================================================
|
||||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
contributor license agreements. See the NOTICE file distributed with
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
@ -15,7 +14,6 @@
|
|||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
==================================================================== */
|
==================================================================== */
|
||||||
|
|
||||||
|
|
||||||
package org.apache.poi.util;
|
package org.apache.poi.util;
|
||||||
|
|
||||||
@ -27,66 +25,32 @@ import junit.framework.*;
|
|||||||
* @author Marc Johnson
|
* @author Marc Johnson
|
||||||
* @author Glen Stampoultzis (gstamp@iprimus.com.au)
|
* @author Glen Stampoultzis (gstamp@iprimus.com.au)
|
||||||
*/
|
*/
|
||||||
|
public final class TestBitField extends TestCase {
|
||||||
public class TestBitField
|
|
||||||
extends TestCase
|
|
||||||
{
|
|
||||||
private static BitField bf_multi = BitFieldFactory.getInstance(0x3F80);
|
private static BitField bf_multi = BitFieldFactory.getInstance(0x3F80);
|
||||||
private static BitField bf_single = BitFieldFactory.getInstance(0x4000);
|
private static BitField bf_single = BitFieldFactory.getInstance(0x4000);
|
||||||
|
|
||||||
/**
|
public void testGetValue() {
|
||||||
* Constructor TestBitField
|
|
||||||
*
|
|
||||||
* @param name
|
|
||||||
*/
|
|
||||||
|
|
||||||
public TestBitField(String name)
|
|
||||||
{
|
|
||||||
super(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* test the getValue() method
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testGetValue()
|
|
||||||
{
|
|
||||||
assertEquals(bf_multi.getValue(-1), 127);
|
assertEquals(bf_multi.getValue(-1), 127);
|
||||||
assertEquals(bf_multi.getValue(0), 0);
|
assertEquals(bf_multi.getValue(0), 0);
|
||||||
assertEquals(bf_single.getValue(-1), 1);
|
assertEquals(bf_single.getValue(-1), 1);
|
||||||
assertEquals(bf_single.getValue(0), 0);
|
assertEquals(bf_single.getValue(0), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void testGetShortValue() {
|
||||||
* test the getShortValue() method
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testGetShortValue()
|
|
||||||
{
|
|
||||||
assertEquals(bf_multi.getShortValue(( short ) -1), ( short ) 127);
|
assertEquals(bf_multi.getShortValue(( short ) -1), ( short ) 127);
|
||||||
assertEquals(bf_multi.getShortValue(( short ) 0), ( short ) 0);
|
assertEquals(bf_multi.getShortValue(( short ) 0), ( short ) 0);
|
||||||
assertEquals(bf_single.getShortValue(( short ) -1), ( short ) 1);
|
assertEquals(bf_single.getShortValue(( short ) -1), ( short ) 1);
|
||||||
assertEquals(bf_single.getShortValue(( short ) 0), ( short ) 0);
|
assertEquals(bf_single.getShortValue(( short ) 0), ( short ) 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void testGetRawValue() {
|
||||||
* test the getRawValue() method
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testGetRawValue()
|
|
||||||
{
|
|
||||||
assertEquals(bf_multi.getRawValue(-1), 0x3F80);
|
assertEquals(bf_multi.getRawValue(-1), 0x3F80);
|
||||||
assertEquals(bf_multi.getRawValue(0), 0);
|
assertEquals(bf_multi.getRawValue(0), 0);
|
||||||
assertEquals(bf_single.getRawValue(-1), 0x4000);
|
assertEquals(bf_single.getRawValue(-1), 0x4000);
|
||||||
assertEquals(bf_single.getRawValue(0), 0);
|
assertEquals(bf_single.getRawValue(0), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void testGetShortRawValue() {
|
||||||
* test the getShortRawValue() method
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testGetShortRawValue()
|
|
||||||
{
|
|
||||||
assertEquals(bf_multi.getShortRawValue(( short ) -1),
|
assertEquals(bf_multi.getShortRawValue(( short ) -1),
|
||||||
( short ) 0x3F80);
|
( short ) 0x3F80);
|
||||||
assertEquals(bf_multi.getShortRawValue(( short ) 0), ( short ) 0);
|
assertEquals(bf_multi.getShortRawValue(( short ) 0), ( short ) 0);
|
||||||
@ -95,12 +59,7 @@ public class TestBitField
|
|||||||
assertEquals(bf_single.getShortRawValue(( short ) 0), ( short ) 0);
|
assertEquals(bf_single.getShortRawValue(( short ) 0), ( short ) 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void testIsSet() {
|
||||||
* test the isSet() method
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testIsSet()
|
|
||||||
{
|
|
||||||
assertTrue(!bf_multi.isSet(0));
|
assertTrue(!bf_multi.isSet(0));
|
||||||
for (int j = 0x80; j <= 0x3F80; j += 0x80)
|
for (int j = 0x80; j <= 0x3F80; j += 0x80)
|
||||||
{
|
{
|
||||||
@ -110,12 +69,7 @@ public class TestBitField
|
|||||||
assertTrue(bf_single.isSet(0x4000));
|
assertTrue(bf_single.isSet(0x4000));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void testIsAllSet() {
|
||||||
* test the isAllSet() method
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testIsAllSet()
|
|
||||||
{
|
|
||||||
for (int j = 0; j < 0x3F80; j += 0x80)
|
for (int j = 0; j < 0x3F80; j += 0x80)
|
||||||
{
|
{
|
||||||
assertTrue(!bf_multi.isAllSet(j));
|
assertTrue(!bf_multi.isAllSet(j));
|
||||||
@ -125,12 +79,7 @@ public class TestBitField
|
|||||||
assertTrue(bf_single.isAllSet(0x4000));
|
assertTrue(bf_single.isAllSet(0x4000));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void testSetValue() {
|
||||||
* test the setValue() method
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testSetValue()
|
|
||||||
{
|
|
||||||
for (int j = 0; j < 128; j++)
|
for (int j = 0; j < 128; j++)
|
||||||
{
|
{
|
||||||
assertEquals(bf_multi.getValue(bf_multi.setValue(0, j)), j);
|
assertEquals(bf_multi.getValue(bf_multi.setValue(0, j)), j);
|
||||||
@ -149,12 +98,7 @@ public class TestBitField
|
|||||||
assertEquals(bf_single.setValue(0x4000, 2), 0);
|
assertEquals(bf_single.setValue(0x4000, 2), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void testSetShortValue() {
|
||||||
* test the setShortValue() method
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testSetShortValue()
|
|
||||||
{
|
|
||||||
for (int j = 0; j < 128; j++)
|
for (int j = 0; j < 128; j++)
|
||||||
{
|
{
|
||||||
assertEquals(bf_multi
|
assertEquals(bf_multi
|
||||||
@ -181,8 +125,7 @@ public class TestBitField
|
|||||||
( short ) 0);
|
( short ) 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testByte()
|
public void testByte() {
|
||||||
{
|
|
||||||
assertEquals(1, BitFieldFactory.getInstance(1).setByteBoolean(( byte ) 0, true));
|
assertEquals(1, BitFieldFactory.getInstance(1).setByteBoolean(( byte ) 0, true));
|
||||||
assertEquals(2, BitFieldFactory.getInstance(2).setByteBoolean(( byte ) 0, true));
|
assertEquals(2, BitFieldFactory.getInstance(2).setByteBoolean(( byte ) 0, true));
|
||||||
assertEquals(4, BitFieldFactory.getInstance(4).setByteBoolean(( byte ) 0, true));
|
assertEquals(4, BitFieldFactory.getInstance(4).setByteBoolean(( byte ) 0, true));
|
||||||
@ -208,64 +151,34 @@ public class TestBitField
|
|||||||
assertEquals(false, BitFieldFactory.getInstance(0x40).isSet(clearedBit));
|
assertEquals(false, BitFieldFactory.getInstance(0x40).isSet(clearedBit));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void testClear() {
|
||||||
* test the clear() method
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testClear()
|
|
||||||
{
|
|
||||||
assertEquals(bf_multi.clear(-1), 0xFFFFC07F);
|
assertEquals(bf_multi.clear(-1), 0xFFFFC07F);
|
||||||
assertEquals(bf_single.clear(-1), 0xFFFFBFFF);
|
assertEquals(bf_single.clear(-1), 0xFFFFBFFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void testClearShort() {
|
||||||
* test the clearShort() method
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testClearShort()
|
|
||||||
{
|
|
||||||
assertEquals(bf_multi.clearShort(( short ) -1), ( short ) 0xC07F);
|
assertEquals(bf_multi.clearShort(( short ) -1), ( short ) 0xC07F);
|
||||||
assertEquals(bf_single.clearShort(( short ) -1), ( short ) 0xBFFF);
|
assertEquals(bf_single.clearShort(( short ) -1), ( short ) 0xBFFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void testSet() {
|
||||||
* test the set() method
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testSet()
|
|
||||||
{
|
|
||||||
assertEquals(bf_multi.set(0), 0x3F80);
|
assertEquals(bf_multi.set(0), 0x3F80);
|
||||||
assertEquals(bf_single.set(0), 0x4000);
|
assertEquals(bf_single.set(0), 0x4000);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void testSetShort() {
|
||||||
* test the setShort() method
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testSetShort()
|
|
||||||
{
|
|
||||||
assertEquals(bf_multi.setShort(( short ) 0), ( short ) 0x3F80);
|
assertEquals(bf_multi.setShort(( short ) 0), ( short ) 0x3F80);
|
||||||
assertEquals(bf_single.setShort(( short ) 0), ( short ) 0x4000);
|
assertEquals(bf_single.setShort(( short ) 0), ( short ) 0x4000);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void testSetBoolean() {
|
||||||
* test the setBoolean() method
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testSetBoolean()
|
|
||||||
{
|
|
||||||
assertEquals(bf_multi.set(0), bf_multi.setBoolean(0, true));
|
assertEquals(bf_multi.set(0), bf_multi.setBoolean(0, true));
|
||||||
assertEquals(bf_single.set(0), bf_single.setBoolean(0, true));
|
assertEquals(bf_single.set(0), bf_single.setBoolean(0, true));
|
||||||
assertEquals(bf_multi.clear(-1), bf_multi.setBoolean(-1, false));
|
assertEquals(bf_multi.clear(-1), bf_multi.setBoolean(-1, false));
|
||||||
assertEquals(bf_single.clear(-1), bf_single.setBoolean(-1, false));
|
assertEquals(bf_single.clear(-1), bf_single.setBoolean(-1, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void testSetShortBoolean() {
|
||||||
* test the setShortBoolean() method
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testSetShortBoolean()
|
|
||||||
{
|
|
||||||
assertEquals(bf_multi.setShort(( short ) 0),
|
assertEquals(bf_multi.setShort(( short ) 0),
|
||||||
bf_multi.setShortBoolean(( short ) 0, true));
|
bf_multi.setShortBoolean(( short ) 0, true));
|
||||||
assertEquals(bf_single.setShort(( short ) 0),
|
assertEquals(bf_single.setShort(( short ) 0),
|
||||||
@ -275,16 +188,4 @@ public class TestBitField
|
|||||||
assertEquals(bf_single.clearShort(( short ) -1),
|
assertEquals(bf_single.clearShort(( short ) -1),
|
||||||
bf_single.setShortBoolean(( short ) -1, false));
|
bf_single.setShortBoolean(( short ) -1, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* main method to run the unit tests
|
|
||||||
*
|
|
||||||
* @param ignored_args
|
|
||||||
*/
|
|
||||||
|
|
||||||
public static void main(String [] ignored_args)
|
|
||||||
{
|
|
||||||
System.out.println("Testing util.BitField functionality");
|
|
||||||
junit.textui.TestRunner.run(TestBitField.class);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -15,46 +15,27 @@
|
|||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
==================================================================== */
|
==================================================================== */
|
||||||
|
|
||||||
|
|
||||||
package org.apache.poi.util;
|
package org.apache.poi.util;
|
||||||
|
|
||||||
import junit.framework.*;
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
import java.io.*;
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Title: Unit test for ByteField class
|
* Title: Unit test for ByteField class
|
||||||
* Description: Unit test for ByteField class
|
* Description: Unit test for ByteField class
|
||||||
* @author Marc Johnson (mjohnson at apache dot org)
|
* @author Marc Johnson (mjohnson at apache dot org)
|
||||||
*/
|
*/
|
||||||
|
public final class TestByteField extends TestCase {
|
||||||
|
|
||||||
public class TestByteField
|
private static final byte[] _test_array =
|
||||||
extends TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor
|
|
||||||
*
|
|
||||||
* @param name
|
|
||||||
*/
|
|
||||||
|
|
||||||
public TestByteField(String name)
|
|
||||||
{
|
|
||||||
super(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
static private final byte[] _test_array =
|
|
||||||
{
|
{
|
||||||
Byte.MIN_VALUE, ( byte ) -1, ( byte ) 0, ( byte ) 1, Byte.MAX_VALUE
|
Byte.MIN_VALUE, ( byte ) -1, ( byte ) 0, ( byte ) 1, Byte.MAX_VALUE
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
public void testConstructors() {
|
||||||
* Test constructors.
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testConstructors()
|
|
||||||
{
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
new ByteField(-1);
|
new ByteField(-1);
|
||||||
@ -114,12 +95,7 @@ public class TestByteField
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void testSet() {
|
||||||
* Test set() methods
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testSet()
|
|
||||||
{
|
|
||||||
ByteField field = new ByteField(0);
|
ByteField field = new ByteField(0);
|
||||||
byte[] array = new byte[ 1 ];
|
byte[] array = new byte[ 1 ];
|
||||||
|
|
||||||
@ -134,12 +110,7 @@ public class TestByteField
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void testReadFromBytes() {
|
||||||
* Test readFromBytes
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testReadFromBytes()
|
|
||||||
{
|
|
||||||
ByteField field = new ByteField(1);
|
ByteField field = new ByteField(1);
|
||||||
byte[] array = new byte[ 1 ];
|
byte[] array = new byte[ 1 ];
|
||||||
|
|
||||||
@ -162,15 +133,7 @@ public class TestByteField
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void testReadFromStream() throws IOException {
|
||||||
* Test readFromStream
|
|
||||||
*
|
|
||||||
* @exception IOException
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testReadFromStream()
|
|
||||||
throws IOException
|
|
||||||
{
|
|
||||||
ByteField field = new ByteField(0);
|
ByteField field = new ByteField(0);
|
||||||
byte[] buffer = new byte[ _test_array.length ];
|
byte[] buffer = new byte[ _test_array.length ];
|
||||||
|
|
||||||
@ -184,12 +147,7 @@ public class TestByteField
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void testWriteToBytes() {
|
||||||
* test writeToBytes
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testWriteToBytes()
|
|
||||||
{
|
|
||||||
ByteField field = new ByteField(0);
|
ByteField field = new ByteField(0);
|
||||||
byte[] array = new byte[ 1 ];
|
byte[] array = new byte[ 1 ];
|
||||||
|
|
||||||
@ -200,16 +158,4 @@ public class TestByteField
|
|||||||
assertEquals("testing ", _test_array[ j ], array[ 0 ]);
|
assertEquals("testing ", _test_array[ j ], array[ 0 ]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Main
|
|
||||||
*
|
|
||||||
* @param ignored_args
|
|
||||||
*/
|
|
||||||
|
|
||||||
public static void main(String [] ignored_args)
|
|
||||||
{
|
|
||||||
System.out.println("Testing util.ByteField functionality");
|
|
||||||
junit.textui.TestRunner.run(TestByteField.class);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
/* ====================================================================
|
/* ====================================================================
|
||||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
contributor license agreements. See the NOTICE file distributed with
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
@ -15,39 +14,19 @@
|
|||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
==================================================================== */
|
==================================================================== */
|
||||||
|
|
||||||
|
|
||||||
package org.apache.poi.util;
|
package org.apache.poi.util;
|
||||||
|
|
||||||
import junit.framework.*;
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class to test IntList
|
* Class to test IntList
|
||||||
*
|
*
|
||||||
* @author Marc Johnson
|
* @author Marc Johnson
|
||||||
*/
|
*/
|
||||||
|
public final class TestIntList extends TestCase {
|
||||||
|
|
||||||
public class TestIntList
|
public void testConstructors() {
|
||||||
extends TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor TestIntList
|
|
||||||
*
|
|
||||||
* @param name
|
|
||||||
*/
|
|
||||||
|
|
||||||
public TestIntList(String name)
|
|
||||||
{
|
|
||||||
super(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* test the various IntListconstructors
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testConstructors()
|
|
||||||
{
|
|
||||||
IntList list = new IntList();
|
IntList list = new IntList();
|
||||||
|
|
||||||
assertTrue(list.isEmpty());
|
assertTrue(list.isEmpty());
|
||||||
@ -61,12 +40,7 @@ public class TestIntList
|
|||||||
assertTrue(list3.isEmpty());
|
assertTrue(list3.isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void testAdd() {
|
||||||
* test the add method
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testAdd()
|
|
||||||
{
|
|
||||||
IntList list = new IntList();
|
IntList list = new IntList();
|
||||||
int[] testArray =
|
int[] testArray =
|
||||||
{
|
{
|
||||||
@ -144,12 +118,7 @@ public class TestIntList
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void testAddAll() {
|
||||||
* test the addAll method
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testAddAll()
|
|
||||||
{
|
|
||||||
IntList list = new IntList();
|
IntList list = new IntList();
|
||||||
|
|
||||||
for (int j = 0; j < 5; j++)
|
for (int j = 0; j < 5; j++)
|
||||||
@ -223,12 +192,7 @@ public class TestIntList
|
|||||||
assertEquals(list.get(4), empty.get(14));
|
assertEquals(list.get(4), empty.get(14));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void testClear() {
|
||||||
* test the clear method
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testClear()
|
|
||||||
{
|
|
||||||
IntList list = new IntList();
|
IntList list = new IntList();
|
||||||
|
|
||||||
for (int j = 0; j < 500; j++)
|
for (int j = 0; j < 500; j++)
|
||||||
@ -249,12 +213,7 @@ public class TestIntList
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void testContains() {
|
||||||
* test the contains method
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testContains()
|
|
||||||
{
|
|
||||||
IntList list = new IntList();
|
IntList list = new IntList();
|
||||||
|
|
||||||
for (int j = 0; j < 1000; j += 2)
|
for (int j = 0; j < 1000; j += 2)
|
||||||
@ -274,12 +233,7 @@ public class TestIntList
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void testContainsAll() {
|
||||||
* test the containsAll method
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testContainsAll()
|
|
||||||
{
|
|
||||||
IntList list = new IntList();
|
IntList list = new IntList();
|
||||||
|
|
||||||
assertTrue(list.containsAll(list));
|
assertTrue(list.containsAll(list));
|
||||||
@ -299,12 +253,7 @@ public class TestIntList
|
|||||||
assertTrue(!list.containsAll(list2));
|
assertTrue(!list.containsAll(list2));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void testEquals() {
|
||||||
* test the equals method
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testEquals()
|
|
||||||
{
|
|
||||||
IntList list = new IntList();
|
IntList list = new IntList();
|
||||||
|
|
||||||
assertEquals(list, list);
|
assertEquals(list, list);
|
||||||
@ -328,12 +277,7 @@ public class TestIntList
|
|||||||
assertTrue(!list2.equals(list));
|
assertTrue(!list2.equals(list));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void testGet() {
|
||||||
* test the get method
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testGet()
|
|
||||||
{
|
|
||||||
IntList list = new IntList();
|
IntList list = new IntList();
|
||||||
|
|
||||||
for (int j = 0; j < 1000; j++)
|
for (int j = 0; j < 1000; j++)
|
||||||
@ -360,12 +304,7 @@ public class TestIntList
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void testIndexOf() {
|
||||||
* test the indexOf method
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testIndexOf()
|
|
||||||
{
|
|
||||||
IntList list = new IntList();
|
IntList list = new IntList();
|
||||||
|
|
||||||
for (int j = 0; j < 1000; j++)
|
for (int j = 0; j < 1000; j++)
|
||||||
@ -385,12 +324,7 @@ public class TestIntList
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void testIsEmpty() {
|
||||||
* test the isEmpty method
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testIsEmpty()
|
|
||||||
{
|
|
||||||
IntList list1 = new IntList();
|
IntList list1 = new IntList();
|
||||||
IntList list2 = new IntList(1000);
|
IntList list2 = new IntList(1000);
|
||||||
IntList list3 = new IntList(list1);
|
IntList list3 = new IntList(list1);
|
||||||
@ -412,12 +346,7 @@ public class TestIntList
|
|||||||
assertTrue(list3.isEmpty());
|
assertTrue(list3.isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void testLastIndexOf() {
|
||||||
* test the lastIndexOf method
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testLastIndexOf()
|
|
||||||
{
|
|
||||||
IntList list = new IntList();
|
IntList list = new IntList();
|
||||||
|
|
||||||
for (int j = 0; j < 1000; j++)
|
for (int j = 0; j < 1000; j++)
|
||||||
@ -437,12 +366,7 @@ public class TestIntList
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void testRemove() {
|
||||||
* test the remove method
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testRemove()
|
|
||||||
{
|
|
||||||
IntList list = new IntList();
|
IntList list = new IntList();
|
||||||
|
|
||||||
for (int j = 0; j < 1000; j++)
|
for (int j = 0; j < 1000; j++)
|
||||||
@ -475,12 +399,7 @@ public class TestIntList
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void testRemoveValue() {
|
||||||
* test the removeValue method
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testRemoveValue()
|
|
||||||
{
|
|
||||||
IntList list = new IntList();
|
IntList list = new IntList();
|
||||||
|
|
||||||
for (int j = 0; j < 1000; j++)
|
for (int j = 0; j < 1000; j++)
|
||||||
@ -498,12 +417,7 @@ public class TestIntList
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void testRemoveAll() {
|
||||||
* test the removeAll method
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testRemoveAll()
|
|
||||||
{
|
|
||||||
IntList list = new IntList();
|
IntList list = new IntList();
|
||||||
|
|
||||||
for (int j = 0; j < 1000; j++)
|
for (int j = 0; j < 1000; j++)
|
||||||
@ -535,12 +449,7 @@ public class TestIntList
|
|||||||
assertTrue(listCopy.isEmpty());
|
assertTrue(listCopy.isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void testRetainAll() {
|
||||||
* test the retainAll method
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testRetainAll()
|
|
||||||
{
|
|
||||||
IntList list = new IntList();
|
IntList list = new IntList();
|
||||||
|
|
||||||
for (int j = 0; j < 1000; j++)
|
for (int j = 0; j < 1000; j++)
|
||||||
@ -572,12 +481,7 @@ public class TestIntList
|
|||||||
assertTrue(listCopy.isEmpty());
|
assertTrue(listCopy.isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void testSet() {
|
||||||
* test the set method
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testSet()
|
|
||||||
{
|
|
||||||
IntList list = new IntList();
|
IntList list = new IntList();
|
||||||
|
|
||||||
for (int j = 0; j < 1000; j++)
|
for (int j = 0; j < 1000; j++)
|
||||||
@ -605,12 +509,7 @@ public class TestIntList
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void testSize() {
|
||||||
* test the size method
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testSize()
|
|
||||||
{
|
|
||||||
IntList list = new IntList();
|
IntList list = new IntList();
|
||||||
|
|
||||||
for (int j = 0; j < 1000; j++)
|
for (int j = 0; j < 1000; j++)
|
||||||
@ -627,12 +526,7 @@ public class TestIntList
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void testToArray() {
|
||||||
* test the toArray method
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testToArray()
|
|
||||||
{
|
|
||||||
IntList list = new IntList();
|
IntList list = new IntList();
|
||||||
|
|
||||||
for (int j = 0; j < 1000; j++)
|
for (int j = 0; j < 1000; j++)
|
||||||
@ -672,16 +566,4 @@ public class TestIntList
|
|||||||
assertEquals(a5[ j ], list.get(j));
|
assertEquals(a5[ j ], list.get(j));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* main method to run the unit tests
|
|
||||||
*
|
|
||||||
* @param unused_args
|
|
||||||
*/
|
|
||||||
|
|
||||||
public static void main(String [] unused_args)
|
|
||||||
{
|
|
||||||
System.out.println("Testing util.IntList functionality");
|
|
||||||
junit.textui.TestRunner.run(TestIntList.class);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
/* ====================================================================
|
/* ====================================================================
|
||||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
contributor license agreements. See the NOTICE file distributed with
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
@ -15,46 +14,27 @@
|
|||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
==================================================================== */
|
==================================================================== */
|
||||||
|
|
||||||
|
|
||||||
package org.apache.poi.util;
|
package org.apache.poi.util;
|
||||||
|
|
||||||
import junit.framework.*;
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
import java.io.*;
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test IntegerField code
|
* Test IntegerField code
|
||||||
*
|
*
|
||||||
* @author Marc Johnson (mjohnson at apache dot org)
|
* @author Marc Johnson (mjohnson at apache dot org)
|
||||||
*/
|
*/
|
||||||
|
public final class TestIntegerField extends TestCase {
|
||||||
|
|
||||||
public class TestIntegerField
|
private static final int[] _test_array =
|
||||||
extends TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor
|
|
||||||
*
|
|
||||||
* @param name
|
|
||||||
*/
|
|
||||||
|
|
||||||
public TestIntegerField(String name)
|
|
||||||
{
|
|
||||||
super(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
static private final int[] _test_array =
|
|
||||||
{
|
{
|
||||||
Integer.MIN_VALUE, -1, 0, 1, Integer.MAX_VALUE
|
Integer.MIN_VALUE, -1, 0, 1, Integer.MAX_VALUE
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
public void testConstructors() {
|
||||||
* Test constructors.
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testConstructors()
|
|
||||||
{
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
new IntegerField(-1);
|
new IntegerField(-1);
|
||||||
@ -117,12 +97,7 @@ public class TestIntegerField
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void testSet() {
|
||||||
* Test set() methods
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testSet()
|
|
||||||
{
|
|
||||||
IntegerField field = new IntegerField(0);
|
IntegerField field = new IntegerField(0);
|
||||||
byte[] array = new byte[ 4 ];
|
byte[] array = new byte[ 4 ];
|
||||||
|
|
||||||
@ -147,12 +122,7 @@ public class TestIntegerField
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void testReadFromBytes() {
|
||||||
* Test readFromBytes
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testReadFromBytes()
|
|
||||||
{
|
|
||||||
IntegerField field = new IntegerField(1);
|
IntegerField field = new IntegerField(1);
|
||||||
byte[] array = new byte[ 4 ];
|
byte[] array = new byte[ 4 ];
|
||||||
|
|
||||||
@ -178,15 +148,7 @@ public class TestIntegerField
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void testReadFromStream() throws IOException {
|
||||||
* Test readFromStream
|
|
||||||
*
|
|
||||||
* @exception IOException
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testReadFromStream()
|
|
||||||
throws IOException
|
|
||||||
{
|
|
||||||
IntegerField field = new IntegerField(0);
|
IntegerField field = new IntegerField(0);
|
||||||
byte[] buffer = new byte[ _test_array.length * 4 ];
|
byte[] buffer = new byte[ _test_array.length * 4 ];
|
||||||
|
|
||||||
@ -206,12 +168,7 @@ public class TestIntegerField
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void testWriteToBytes() {
|
||||||
* test writeToBytes
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testWriteToBytes()
|
|
||||||
{
|
|
||||||
IntegerField field = new IntegerField(0);
|
IntegerField field = new IntegerField(0);
|
||||||
byte[] array = new byte[ 4 ];
|
byte[] array = new byte[ 4 ];
|
||||||
|
|
||||||
@ -228,16 +185,4 @@ public class TestIntegerField
|
|||||||
assertEquals("testing ", _test_array[ j ], val);
|
assertEquals("testing ", _test_array[ j ], val);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Main
|
|
||||||
*
|
|
||||||
* @param args
|
|
||||||
*/
|
|
||||||
|
|
||||||
public static void main(String [] args)
|
|
||||||
{
|
|
||||||
System.out.println("Testing util.IntegerField functionality");
|
|
||||||
junit.textui.TestRunner.run(TestIntegerField.class);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
/* ====================================================================
|
/* ====================================================================
|
||||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
contributor license agreements. See the NOTICE file distributed with
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
@ -15,43 +14,23 @@
|
|||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
==================================================================== */
|
==================================================================== */
|
||||||
|
|
||||||
|
|
||||||
package org.apache.poi.util;
|
package org.apache.poi.util;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Marc Johnson (mjohnson at apache dot org)
|
* @author Marc Johnson (mjohnson at apache dot org)
|
||||||
* @author Glen Stampoultzis (glens at apache.org)
|
* @author Glen Stampoultzis (glens at apache.org)
|
||||||
* @author Nicola Ken Barozzi (nicolaken at apache.org)
|
* @author Nicola Ken Barozzi (nicolaken at apache.org)
|
||||||
*/
|
*/
|
||||||
|
public final class TestPOILogFactory extends TestCase {
|
||||||
|
|
||||||
public class TestPOILogFactory
|
|
||||||
extends TestCase
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Creates new TestPOILogFactory
|
|
||||||
*
|
|
||||||
* @param name
|
|
||||||
*/
|
|
||||||
|
|
||||||
public TestPOILogFactory( String name )
|
|
||||||
{
|
|
||||||
super( name );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* test log creation
|
* test log creation
|
||||||
*
|
|
||||||
* @exception IOException
|
|
||||||
*/
|
*/
|
||||||
|
public void testLog() {
|
||||||
public void testLog()
|
|
||||||
throws IOException
|
|
||||||
{
|
|
||||||
//NKB Testing only that logging classes use gives no exception
|
//NKB Testing only that logging classes use gives no exception
|
||||||
// Since logging can be disabled, no checking of logging
|
// Since logging can be disabled, no checking of logging
|
||||||
// output is done.
|
// output is done.
|
||||||
@ -72,16 +51,4 @@ public class TestPOILogFactory
|
|||||||
l2.log( POILogger.DEBUG, "testing cat org.apache.poi.hdf.*:DEBUG" );
|
l2.log( POILogger.DEBUG, "testing cat org.apache.poi.hdf.*:DEBUG" );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* main method to run the unit tests
|
|
||||||
*
|
|
||||||
* @param ignored_args
|
|
||||||
*/
|
|
||||||
|
|
||||||
public static void main( String[] ignored_args )
|
|
||||||
{
|
|
||||||
System.out.println( "Testing basic util.POILogFactory functionality" );
|
|
||||||
junit.textui.TestRunner.run( TestPOILogFactory.class );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
==================================================================== */
|
==================================================================== */
|
||||||
|
|
||||||
|
|
||||||
package org.apache.poi.util;
|
package org.apache.poi.util;
|
||||||
|
|
||||||
@ -28,31 +27,12 @@ import junit.framework.TestCase;
|
|||||||
* @author Marc Johnson (mjohnson at apache dot org)
|
* @author Marc Johnson (mjohnson at apache dot org)
|
||||||
* @author Nicola Ken Barozzi (nicolaken at apache.org)
|
* @author Nicola Ken Barozzi (nicolaken at apache.org)
|
||||||
*/
|
*/
|
||||||
|
public final class TestPOILogger extends TestCase {
|
||||||
public class TestPOILogger
|
|
||||||
extends TestCase
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Constructor TestPOILogger
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @param s
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
public TestPOILogger( String s )
|
|
||||||
{
|
|
||||||
super( s );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test different types of log output.
|
* Test different types of log output.
|
||||||
*
|
|
||||||
* @exception Exception
|
|
||||||
*/
|
*/
|
||||||
public void testVariousLogTypes()
|
public void testVariousLogTypes() {
|
||||||
throws Exception
|
|
||||||
{
|
|
||||||
//NKB Testing only that logging classes use gives no exception
|
//NKB Testing only that logging classes use gives no exception
|
||||||
// Since logging can be disabled, no checking of logging
|
// Since logging can be disabled, no checking of logging
|
||||||
// output is done.
|
// output is done.
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
/* ====================================================================
|
/* ====================================================================
|
||||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
contributor license agreements. See the NOTICE file distributed with
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
@ -15,7 +14,6 @@
|
|||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
==================================================================== */
|
==================================================================== */
|
||||||
|
|
||||||
|
|
||||||
package org.apache.poi.util;
|
package org.apache.poi.util;
|
||||||
|
|
||||||
@ -28,34 +26,15 @@ import java.io.*;
|
|||||||
*
|
*
|
||||||
* @author Marc Johnson (mjohnson at apache dot org)
|
* @author Marc Johnson (mjohnson at apache dot org)
|
||||||
*/
|
*/
|
||||||
|
public final class TestShortField extends TestCase {
|
||||||
|
|
||||||
public class TestShortField
|
private static final short[] _test_array =
|
||||||
extends TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor
|
|
||||||
*
|
|
||||||
* @param name
|
|
||||||
*/
|
|
||||||
|
|
||||||
public TestShortField(String name)
|
|
||||||
{
|
|
||||||
super(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
static private final short[] _test_array =
|
|
||||||
{
|
{
|
||||||
Short.MIN_VALUE, ( short ) -1, ( short ) 0, ( short ) 1,
|
Short.MIN_VALUE, ( short ) -1, ( short ) 0, ( short ) 1,
|
||||||
Short.MAX_VALUE
|
Short.MAX_VALUE
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
public void testConstructors() {
|
||||||
* Test constructors.
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testConstructors()
|
|
||||||
{
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
new ShortField(-1);
|
new ShortField(-1);
|
||||||
@ -116,12 +95,7 @@ public class TestShortField
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void testSet() {
|
||||||
* Test set() methods
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testSet()
|
|
||||||
{
|
|
||||||
ShortField field = new ShortField(0);
|
ShortField field = new ShortField(0);
|
||||||
byte[] array = new byte[ 2 ];
|
byte[] array = new byte[ 2 ];
|
||||||
|
|
||||||
@ -140,12 +114,7 @@ public class TestShortField
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void testReadFromBytes() {
|
||||||
* Test readFromBytes
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testReadFromBytes()
|
|
||||||
{
|
|
||||||
ShortField field = new ShortField(1);
|
ShortField field = new ShortField(1);
|
||||||
byte[] array = new byte[ 2 ];
|
byte[] array = new byte[ 2 ];
|
||||||
|
|
||||||
@ -169,15 +138,7 @@ public class TestShortField
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void testReadFromStream() throws IOException {
|
||||||
* Test readFromStream
|
|
||||||
*
|
|
||||||
* @exception IOException
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testReadFromStream()
|
|
||||||
throws IOException
|
|
||||||
{
|
|
||||||
ShortField field = new ShortField(0);
|
ShortField field = new ShortField(0);
|
||||||
byte[] buffer = new byte[ _test_array.length * 2 ];
|
byte[] buffer = new byte[ _test_array.length * 2 ];
|
||||||
|
|
||||||
@ -195,12 +156,7 @@ public class TestShortField
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void testWriteToBytes() {
|
||||||
* test writeToBytes
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testWriteToBytes()
|
|
||||||
{
|
|
||||||
ShortField field = new ShortField(0);
|
ShortField field = new ShortField(0);
|
||||||
byte[] array = new byte[ 2 ];
|
byte[] array = new byte[ 2 ];
|
||||||
|
|
||||||
@ -215,16 +171,4 @@ public class TestShortField
|
|||||||
assertEquals("testing ", _test_array[ j ], val);
|
assertEquals("testing ", _test_array[ j ], val);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Main
|
|
||||||
*
|
|
||||||
* @param args
|
|
||||||
*/
|
|
||||||
|
|
||||||
public static void main(String [] args)
|
|
||||||
{
|
|
||||||
System.out.println("Testing util.ShortField functionality");
|
|
||||||
junit.textui.TestRunner.run(TestShortField.class);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
/* ====================================================================
|
/* ====================================================================
|
||||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
contributor license agreements. See the NOTICE file distributed with
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
@ -15,39 +14,19 @@
|
|||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
==================================================================== */
|
==================================================================== */
|
||||||
|
|
||||||
|
|
||||||
package org.apache.poi.util;
|
package org.apache.poi.util;
|
||||||
|
|
||||||
import junit.framework.*;
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class to test ShortList
|
* Class to test ShortList
|
||||||
*
|
*
|
||||||
* @author Marc Johnson
|
* @author Marc Johnson
|
||||||
*/
|
*/
|
||||||
|
public final class TestShortList extends TestCase {
|
||||||
|
|
||||||
public class TestShortList
|
public void testConstructors() {
|
||||||
extends TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor TestShortList
|
|
||||||
*
|
|
||||||
* @param name
|
|
||||||
*/
|
|
||||||
|
|
||||||
public TestShortList(String name)
|
|
||||||
{
|
|
||||||
super(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* test the various ShortListconstructors
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testConstructors()
|
|
||||||
{
|
|
||||||
ShortList list = new ShortList();
|
ShortList list = new ShortList();
|
||||||
|
|
||||||
assertTrue(list.isEmpty());
|
assertTrue(list.isEmpty());
|
||||||
@ -61,12 +40,7 @@ public class TestShortList
|
|||||||
assertTrue(list3.isEmpty());
|
assertTrue(list3.isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void testAdd() {
|
||||||
* test the add method
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testAdd()
|
|
||||||
{
|
|
||||||
ShortList list = new ShortList();
|
ShortList list = new ShortList();
|
||||||
short[] testArray =
|
short[] testArray =
|
||||||
{
|
{
|
||||||
@ -144,12 +118,7 @@ public class TestShortList
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void testAddAll() {
|
||||||
* test the addAll method
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testAddAll()
|
|
||||||
{
|
|
||||||
ShortList list = new ShortList();
|
ShortList list = new ShortList();
|
||||||
|
|
||||||
for (short j = 0; j < 5; j++)
|
for (short j = 0; j < 5; j++)
|
||||||
@ -223,12 +192,7 @@ public class TestShortList
|
|||||||
assertEquals(list.get(4), empty.get(14));
|
assertEquals(list.get(4), empty.get(14));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void testClear() {
|
||||||
* test the clear method
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testClear()
|
|
||||||
{
|
|
||||||
ShortList list = new ShortList();
|
ShortList list = new ShortList();
|
||||||
|
|
||||||
for (short j = 0; j < 500; j++)
|
for (short j = 0; j < 500; j++)
|
||||||
@ -249,12 +213,7 @@ public class TestShortList
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void testContains() {
|
||||||
* test the contains method
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testContains()
|
|
||||||
{
|
|
||||||
ShortList list = new ShortList();
|
ShortList list = new ShortList();
|
||||||
|
|
||||||
for (short j = 0; j < 1000; j += 2)
|
for (short j = 0; j < 1000; j += 2)
|
||||||
@ -274,12 +233,7 @@ public class TestShortList
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void testContainsAll() {
|
||||||
* test the containsAll method
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testContainsAll()
|
|
||||||
{
|
|
||||||
ShortList list = new ShortList();
|
ShortList list = new ShortList();
|
||||||
|
|
||||||
assertTrue(list.containsAll(list));
|
assertTrue(list.containsAll(list));
|
||||||
@ -299,12 +253,7 @@ public class TestShortList
|
|||||||
assertTrue(!list.containsAll(list2));
|
assertTrue(!list.containsAll(list2));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void testEquals() {
|
||||||
* test the equals method
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testEquals()
|
|
||||||
{
|
|
||||||
ShortList list = new ShortList();
|
ShortList list = new ShortList();
|
||||||
|
|
||||||
assertEquals(list, list);
|
assertEquals(list, list);
|
||||||
@ -328,12 +277,7 @@ public class TestShortList
|
|||||||
assertTrue(!list2.equals(list));
|
assertTrue(!list2.equals(list));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void testGet() {
|
||||||
* test the get method
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testGet()
|
|
||||||
{
|
|
||||||
ShortList list = new ShortList();
|
ShortList list = new ShortList();
|
||||||
|
|
||||||
for (short j = 0; j < 1000; j++)
|
for (short j = 0; j < 1000; j++)
|
||||||
@ -360,12 +304,7 @@ public class TestShortList
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void testIndexOf() {
|
||||||
* test the indexOf method
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testIndexOf()
|
|
||||||
{
|
|
||||||
ShortList list = new ShortList();
|
ShortList list = new ShortList();
|
||||||
|
|
||||||
for (short j = 0; j < 1000; j++)
|
for (short j = 0; j < 1000; j++)
|
||||||
@ -385,12 +324,7 @@ public class TestShortList
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void testIsEmpty() {
|
||||||
* test the isEmpty method
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testIsEmpty()
|
|
||||||
{
|
|
||||||
ShortList list1 = new ShortList();
|
ShortList list1 = new ShortList();
|
||||||
ShortList list2 = new ShortList(1000);
|
ShortList list2 = new ShortList(1000);
|
||||||
ShortList list3 = new ShortList(list1);
|
ShortList list3 = new ShortList(list1);
|
||||||
@ -412,12 +346,7 @@ public class TestShortList
|
|||||||
assertTrue(list3.isEmpty());
|
assertTrue(list3.isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void testLastIndexOf() {
|
||||||
* test the lastIndexOf method
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testLastIndexOf()
|
|
||||||
{
|
|
||||||
ShortList list = new ShortList();
|
ShortList list = new ShortList();
|
||||||
|
|
||||||
for (short j = 0; j < 1000; j++)
|
for (short j = 0; j < 1000; j++)
|
||||||
@ -437,12 +366,7 @@ public class TestShortList
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void testRemove() {
|
||||||
* test the remove method
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testRemove()
|
|
||||||
{
|
|
||||||
ShortList list = new ShortList();
|
ShortList list = new ShortList();
|
||||||
|
|
||||||
for (short j = 0; j < 1000; j++)
|
for (short j = 0; j < 1000; j++)
|
||||||
@ -476,12 +400,7 @@ public class TestShortList
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void testRemoveValue() {
|
||||||
* test the removeValue method
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testRemoveValue()
|
|
||||||
{
|
|
||||||
ShortList list = new ShortList();
|
ShortList list = new ShortList();
|
||||||
|
|
||||||
for (short j = 0; j < 1000; j++)
|
for (short j = 0; j < 1000; j++)
|
||||||
@ -499,12 +418,7 @@ public class TestShortList
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void testRemoveAll() {
|
||||||
* test the removeAll method
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testRemoveAll()
|
|
||||||
{
|
|
||||||
ShortList list = new ShortList();
|
ShortList list = new ShortList();
|
||||||
|
|
||||||
for (short j = 0; j < 1000; j++)
|
for (short j = 0; j < 1000; j++)
|
||||||
@ -536,12 +450,7 @@ public class TestShortList
|
|||||||
assertTrue(listCopy.isEmpty());
|
assertTrue(listCopy.isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void testRetainAll() {
|
||||||
* test the retainAll method
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testRetainAll()
|
|
||||||
{
|
|
||||||
ShortList list = new ShortList();
|
ShortList list = new ShortList();
|
||||||
|
|
||||||
for (short j = 0; j < 1000; j++)
|
for (short j = 0; j < 1000; j++)
|
||||||
@ -573,12 +482,7 @@ public class TestShortList
|
|||||||
assertTrue(listCopy.isEmpty());
|
assertTrue(listCopy.isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void testSet() {
|
||||||
* test the set method
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testSet()
|
|
||||||
{
|
|
||||||
ShortList list = new ShortList();
|
ShortList list = new ShortList();
|
||||||
|
|
||||||
for (short j = 0; j < 1000; j++)
|
for (short j = 0; j < 1000; j++)
|
||||||
@ -606,12 +510,7 @@ public class TestShortList
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void testSize() {
|
||||||
* test the size method
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testSize()
|
|
||||||
{
|
|
||||||
ShortList list = new ShortList();
|
ShortList list = new ShortList();
|
||||||
|
|
||||||
for (short j = 0; j < 1000; j++)
|
for (short j = 0; j < 1000; j++)
|
||||||
@ -628,12 +527,7 @@ public class TestShortList
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void testToArray() {
|
||||||
* test the toArray method
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void testToArray()
|
|
||||||
{
|
|
||||||
ShortList list = new ShortList();
|
ShortList list = new ShortList();
|
||||||
|
|
||||||
for (short j = 0; j < 1000; j++)
|
for (short j = 0; j < 1000; j++)
|
||||||
@ -673,16 +567,4 @@ public class TestShortList
|
|||||||
assertEquals(a5[ j ], list.get(j));
|
assertEquals(a5[ j ], list.get(j));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* main method to run the unit tests
|
|
||||||
*
|
|
||||||
* @param unused_args
|
|
||||||
*/
|
|
||||||
|
|
||||||
public static void main(String [] unused_args)
|
|
||||||
{
|
|
||||||
System.out.println("Testing util.ShortList functionality");
|
|
||||||
junit.textui.TestRunner.run(TestShortList.class);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
/* ====================================================================
|
/* ====================================================================
|
||||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
contributor license agreements. See the NOTICE file distributed with
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
@ -15,13 +14,14 @@
|
|||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
==================================================================== */
|
==================================================================== */
|
||||||
|
|
||||||
package org.apache.poi.util;
|
package org.apache.poi.util;
|
||||||
|
|
||||||
import junit.framework.*;
|
import java.io.UnsupportedEncodingException;
|
||||||
|
|
||||||
import java.text.NumberFormat;
|
import java.text.NumberFormat;
|
||||||
|
|
||||||
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unit test for StringUtil
|
* Unit test for StringUtil
|
||||||
*
|
*
|
||||||
@ -29,26 +29,12 @@ import java.text.NumberFormat;
|
|||||||
* @author Glen Stampoultzis (glens at apache.org)
|
* @author Glen Stampoultzis (glens at apache.org)
|
||||||
* @author Sergei Kozello (sergeikozello at mail.ru)
|
* @author Sergei Kozello (sergeikozello at mail.ru)
|
||||||
*/
|
*/
|
||||||
public class TestStringUtil
|
public final class TestStringUtil extends TestCase {
|
||||||
extends TestCase
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Creates new TestStringUtil
|
|
||||||
*
|
|
||||||
* @param name
|
|
||||||
*/
|
|
||||||
public TestStringUtil( String name )
|
|
||||||
{
|
|
||||||
super( name );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* test getFromUnicodeHigh for symbols with code below and more 127
|
* test getFromUnicodeHigh for symbols with code below and more 127
|
||||||
*/
|
*/
|
||||||
public void testGetFromUnicodeHighSymbolsWithCodesMoreThan127()
|
public void testGetFromUnicodeHighSymbolsWithCodesMoreThan127() {
|
||||||
{
|
|
||||||
byte[] test_data = new byte[]{0x22, 0x04,
|
byte[] test_data = new byte[]{0x22, 0x04,
|
||||||
0x35, 0x04,
|
0x35, 0x04,
|
||||||
0x41, 0x04,
|
0x41, 0x04,
|
||||||
@ -65,13 +51,7 @@ public class TestStringUtil
|
|||||||
StringUtil.getFromUnicodeLE( test_data ) );
|
StringUtil.getFromUnicodeLE( test_data ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testPutCompressedUnicode() {
|
||||||
|
|
||||||
/**
|
|
||||||
* Test putCompressedUnicode
|
|
||||||
*/
|
|
||||||
public void testPutCompressedUnicode() throws Exception
|
|
||||||
{
|
|
||||||
byte[] output = new byte[100];
|
byte[] output = new byte[100];
|
||||||
byte[] expected_output =
|
byte[] expected_output =
|
||||||
{
|
{
|
||||||
@ -79,7 +59,12 @@ public class TestStringUtil
|
|||||||
(byte) 'o', (byte) ' ', (byte) 'W', (byte) 'o',
|
(byte) 'o', (byte) ' ', (byte) 'W', (byte) 'o',
|
||||||
(byte) 'r', (byte) 'l', (byte) 'd', (byte) 0xAE
|
(byte) 'r', (byte) 'l', (byte) 'd', (byte) 0xAE
|
||||||
};
|
};
|
||||||
String input = new String( expected_output, StringUtil.getPreferredEncoding() );
|
String input;
|
||||||
|
try {
|
||||||
|
input = new String( expected_output, StringUtil.getPreferredEncoding() );
|
||||||
|
} catch (UnsupportedEncodingException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
|
||||||
StringUtil.putCompressedUnicode( input, output, 0 );
|
StringUtil.putCompressedUnicode( input, output, 0 );
|
||||||
for ( int j = 0; j < expected_output.length; j++ )
|
for ( int j = 0; j < expected_output.length; j++ )
|
||||||
@ -106,11 +91,7 @@ public class TestStringUtil
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void testPutUncompressedUnicode() {
|
||||||
* Test putUncompressedUnicode
|
|
||||||
*/
|
|
||||||
public void testPutUncompressedUnicode()
|
|
||||||
{
|
|
||||||
byte[] output = new byte[100];
|
byte[] output = new byte[100];
|
||||||
String input = "Hello World";
|
String input = "Hello World";
|
||||||
byte[] expected_output =
|
byte[] expected_output =
|
||||||
@ -147,10 +128,7 @@ public class TestStringUtil
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testFormat() {
|
||||||
public void testFormat()
|
|
||||||
throws Exception
|
|
||||||
{
|
|
||||||
assertEquals( "This is a test " + fmt( 1.2345, 2, 2 ),
|
assertEquals( "This is a test " + fmt( 1.2345, 2, 2 ),
|
||||||
StringUtil.format( "This is a test %2.2", new Object[]
|
StringUtil.format( "This is a test %2.2", new Object[]
|
||||||
{
|
{
|
||||||
@ -192,8 +170,7 @@ public class TestStringUtil
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private String fmt( double num, int minIntDigits, int maxFracDigitis )
|
private static String fmt(double num, int minIntDigits, int maxFracDigitis) {
|
||||||
{
|
|
||||||
NumberFormat nf = NumberFormat.getInstance();
|
NumberFormat nf = NumberFormat.getInstance();
|
||||||
|
|
||||||
if ( minIntDigits != -1 )
|
if ( minIntDigits != -1 )
|
||||||
@ -207,28 +184,5 @@ public class TestStringUtil
|
|||||||
|
|
||||||
return nf.format( num );
|
return nf.format( num );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* main
|
|
||||||
*
|
|
||||||
* @param ignored_args
|
|
||||||
*/
|
|
||||||
public static void main( String[] ignored_args )
|
|
||||||
{
|
|
||||||
System.out.println( "Testing util.StringUtil functionality" );
|
|
||||||
junit.textui.TestRunner.run( TestStringUtil.class );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see junit.framework.TestCase#setUp()
|
|
||||||
*/
|
|
||||||
protected void setUp() throws Exception
|
|
||||||
{
|
|
||||||
super.setUp();
|
|
||||||
|
|
||||||
// System.setProperty()
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user