Add TODOs for the next set of NPOIFS write tests we need
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1589868 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
a94f150450
commit
950c10faf4
@ -47,6 +47,18 @@ import org.junit.Test;
|
|||||||
public final class TestNPOIFSFileSystem {
|
public final class TestNPOIFSFileSystem {
|
||||||
private static final POIDataSamples _inst = POIDataSamples.getPOIFSInstance();
|
private static final POIDataSamples _inst = POIDataSamples.getPOIFSInstance();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns test files with 512 byte and 4k block sizes, loaded
|
||||||
|
* both from InputStreams and Files
|
||||||
|
*/
|
||||||
|
protected NPOIFSFileSystem[] get512and4kFileAndInput() throws Exception {
|
||||||
|
NPOIFSFileSystem fsA = new NPOIFSFileSystem(_inst.getFile("BlockSize512.zvi"));
|
||||||
|
NPOIFSFileSystem fsB = new NPOIFSFileSystem(_inst.openResourceAsStream("BlockSize512.zvi"));
|
||||||
|
NPOIFSFileSystem fsC = new NPOIFSFileSystem(_inst.getFile("BlockSize4096.zvi"));
|
||||||
|
NPOIFSFileSystem fsD = new NPOIFSFileSystem(_inst.openResourceAsStream("BlockSize4096.zvi"));
|
||||||
|
return new NPOIFSFileSystem[] {fsA,fsB,fsC,fsD};
|
||||||
|
}
|
||||||
|
|
||||||
protected static void assertBATCount(NPOIFSFileSystem fs, int expectedBAT, int expectedXBAT) throws IOException {
|
protected static void assertBATCount(NPOIFSFileSystem fs, int expectedBAT, int expectedXBAT) throws IOException {
|
||||||
int foundBAT = 0;
|
int foundBAT = 0;
|
||||||
int foundXBAT = 0;
|
int foundXBAT = 0;
|
||||||
@ -515,7 +527,14 @@ public final class TestNPOIFSFileSystem {
|
|||||||
// Check that it is seen correctly
|
// Check that it is seen correctly
|
||||||
fs = new NPOIFSFileSystem(new ByteArrayInputStream(baos.toByteArray()));
|
fs = new NPOIFSFileSystem(new ByteArrayInputStream(baos.toByteArray()));
|
||||||
assertBATCount(fs, 237, 2);
|
assertBATCount(fs, 237, 2);
|
||||||
// TODO Do some more checks
|
|
||||||
|
assertEquals(false, fs.getBATBlockAndIndex(236*128-1).getBlock().hasFreeSectors());
|
||||||
|
assertEquals(true, fs.getBATBlockAndIndex(237*128-1).getBlock().hasFreeSectors());
|
||||||
|
try {
|
||||||
|
assertEquals(false, fs.getBATBlockAndIndex(237*128).getBlock().hasFreeSectors());
|
||||||
|
fail("Should only be 237 BATs");
|
||||||
|
} catch(IndexOutOfBoundsException e) {}
|
||||||
|
|
||||||
|
|
||||||
// All done
|
// All done
|
||||||
fs.close();
|
fs.close();
|
||||||
@ -527,11 +546,7 @@ public final class TestNPOIFSFileSystem {
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void listEntries() throws Exception {
|
public void listEntries() throws Exception {
|
||||||
NPOIFSFileSystem fsA = new NPOIFSFileSystem(_inst.getFile("BlockSize512.zvi"));
|
for(NPOIFSFileSystem fs : get512and4kFileAndInput()) {
|
||||||
NPOIFSFileSystem fsB = new NPOIFSFileSystem(_inst.openResourceAsStream("BlockSize512.zvi"));
|
|
||||||
NPOIFSFileSystem fsC = new NPOIFSFileSystem(_inst.getFile("BlockSize4096.zvi"));
|
|
||||||
NPOIFSFileSystem fsD = new NPOIFSFileSystem(_inst.openResourceAsStream("BlockSize4096.zvi"));
|
|
||||||
for(NPOIFSFileSystem fs : new NPOIFSFileSystem[] {fsA,fsB,fsC,fsD}) {
|
|
||||||
DirectoryEntry root = fs.getRoot();
|
DirectoryEntry root = fs.getRoot();
|
||||||
assertEquals(5, root.getEntryCount());
|
assertEquals(5, root.getEntryCount());
|
||||||
|
|
||||||
@ -568,11 +583,7 @@ public final class TestNPOIFSFileSystem {
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void getDocumentEntry() throws Exception {
|
public void getDocumentEntry() throws Exception {
|
||||||
NPOIFSFileSystem fsA = new NPOIFSFileSystem(_inst.getFile("BlockSize512.zvi"));
|
for(NPOIFSFileSystem fs : get512and4kFileAndInput()) {
|
||||||
NPOIFSFileSystem fsB = new NPOIFSFileSystem(_inst.openResourceAsStream("BlockSize512.zvi"));
|
|
||||||
NPOIFSFileSystem fsC = new NPOIFSFileSystem(_inst.getFile("BlockSize4096.zvi"));
|
|
||||||
NPOIFSFileSystem fsD = new NPOIFSFileSystem(_inst.openResourceAsStream("BlockSize4096.zvi"));
|
|
||||||
for(NPOIFSFileSystem fs : new NPOIFSFileSystem[] {fsA,fsB,fsC,fsD}) {
|
|
||||||
DirectoryEntry root = fs.getRoot();
|
DirectoryEntry root = fs.getRoot();
|
||||||
Entry si = root.getEntry("\u0005SummaryInformation");
|
Entry si = root.getEntry("\u0005SummaryInformation");
|
||||||
|
|
||||||
@ -583,6 +594,7 @@ public final class TestNPOIFSFileSystem {
|
|||||||
NDocumentInputStream inp = new NDocumentInputStream(doc);
|
NDocumentInputStream inp = new NDocumentInputStream(doc);
|
||||||
byte[] contents = new byte[doc.getSize()];
|
byte[] contents = new byte[doc.getSize()];
|
||||||
assertEquals(doc.getSize(), inp.read(contents));
|
assertEquals(doc.getSize(), inp.read(contents));
|
||||||
|
inp.close();
|
||||||
|
|
||||||
// Now try to build the property set
|
// Now try to build the property set
|
||||||
inp = new NDocumentInputStream(doc);
|
inp = new NDocumentInputStream(doc);
|
||||||
@ -605,8 +617,40 @@ public final class TestNPOIFSFileSystem {
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void readWriteRead() throws Exception {
|
public void readWriteRead() throws Exception {
|
||||||
// TODO
|
for(NPOIFSFileSystem fs : get512and4kFileAndInput()) {
|
||||||
// TODO
|
// Check we can find the entries we expect
|
||||||
|
// TODO Add check
|
||||||
|
|
||||||
|
// Write out, re-load
|
||||||
|
// TODO Add check
|
||||||
|
|
||||||
|
// Check they're still there
|
||||||
|
// TODO Add check
|
||||||
|
|
||||||
|
// Check the first few and last few bytes of a few
|
||||||
|
// TODO Add check
|
||||||
|
|
||||||
|
// Add a test mini stream
|
||||||
|
// TODO Add check
|
||||||
|
|
||||||
|
// Write out, re-load
|
||||||
|
// TODO Add check
|
||||||
|
|
||||||
|
// Check old and new are there
|
||||||
|
// TODO Add check
|
||||||
|
|
||||||
|
// Add a full stream, delete a full stream
|
||||||
|
// TODO Add check
|
||||||
|
|
||||||
|
// Write out, re-load
|
||||||
|
// TODO Add check
|
||||||
|
|
||||||
|
// Check it's all there
|
||||||
|
// TODO Add check
|
||||||
|
|
||||||
|
// All done
|
||||||
|
fs.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -667,5 +711,5 @@ public final class TestNPOIFSFileSystem {
|
|||||||
assertThat(wbDataExp, equalTo(wbDataAct));
|
assertThat(wbDataExp, equalTo(wbDataAct));
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO Directory/Document write tests
|
// TODO Directory/Document create/write/read/delete/change tests
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user