From 8b89688ddb2c098177e578ef653dd906964e1e11 Mon Sep 17 00:00:00 2001 From: Nick Burch Date: Thu, 7 Jan 2010 16:47:09 +0000 Subject: [PATCH] Shuffle where some of the HSMF tests live to better match package names, and stub out a few more tests git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@896923 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/org/apache/poi/hsmf/MAPIMessage.java | 2 - .../poi/hsmf/datatypes/AttachmentChunks.java | 14 +++++ .../poi/hsmf/parsers/POIFSChunkParser.java | 2 +- .../org/apache/poi/hsmf/AllHSMFTests.java | 9 ++- .../hsmf/{model => }/TestBlankFileRead.java | 2 +- .../TestFileWithAttachmentsRead.java | 2 +- .../{model => }/TestOutlook30FileRead.java | 2 +- .../hsmf/{model => }/TestSimpleFileRead.java | 2 +- .../{model => datatypes}/TestChunkData.java | 2 +- .../hsmf/{model => datatypes}/TestTypes.java | 2 +- .../hsmf/parsers/TestPOIFSChunkParser.java | 56 +++++++++++++++++++ 11 files changed, 84 insertions(+), 11 deletions(-) rename src/scratchpad/testcases/org/apache/poi/hsmf/{model => }/TestBlankFileRead.java (98%) rename src/scratchpad/testcases/org/apache/poi/hsmf/{model => }/TestFileWithAttachmentsRead.java (98%) rename src/scratchpad/testcases/org/apache/poi/hsmf/{model => }/TestOutlook30FileRead.java (99%) rename src/scratchpad/testcases/org/apache/poi/hsmf/{model => }/TestSimpleFileRead.java (99%) rename src/scratchpad/testcases/org/apache/poi/hsmf/{model => datatypes}/TestChunkData.java (98%) rename src/scratchpad/testcases/org/apache/poi/hsmf/{model => datatypes}/TestTypes.java (97%) create mode 100644 src/scratchpad/testcases/org/apache/poi/hsmf/parsers/TestPOIFSChunkParser.java diff --git a/src/scratchpad/src/org/apache/poi/hsmf/MAPIMessage.java b/src/scratchpad/src/org/apache/poi/hsmf/MAPIMessage.java index 7bb482d7c4..6e6cee08cd 100644 --- a/src/scratchpad/src/org/apache/poi/hsmf/MAPIMessage.java +++ b/src/scratchpad/src/org/apache/poi/hsmf/MAPIMessage.java @@ -22,10 +22,8 @@ import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; -import java.util.Map; import org.apache.poi.hsmf.datatypes.AttachmentChunks; -import org.apache.poi.hsmf.datatypes.Chunk; import org.apache.poi.hsmf.datatypes.ChunkGroup; import org.apache.poi.hsmf.datatypes.Chunks; import org.apache.poi.hsmf.datatypes.NameIdChunks; diff --git a/src/scratchpad/src/org/apache/poi/hsmf/datatypes/AttachmentChunks.java b/src/scratchpad/src/org/apache/poi/hsmf/datatypes/AttachmentChunks.java index c169e5f22f..c7ad005e74 100644 --- a/src/scratchpad/src/org/apache/poi/hsmf/datatypes/AttachmentChunks.java +++ b/src/scratchpad/src/org/apache/poi/hsmf/datatypes/AttachmentChunks.java @@ -37,10 +37,20 @@ public class AttachmentChunks implements ChunkGroup { public StringChunk attachFileName; public StringChunk attachLongFileName; public StringChunk attachMimeTag; + + /** + * What the POIFS name of this attachment is. + */ + private String poifsName; /** Holds all the chunks that were found. */ private List allChunks = new ArrayList(); + + public AttachmentChunks(String poifsName) { + this.poifsName = poifsName; + } + public Chunk[] getAll() { return allChunks.toArray(new Chunk[allChunks.size()]); } @@ -48,6 +58,10 @@ public class AttachmentChunks implements ChunkGroup { return getAll(); } + public String getPOIFSName() { + return poifsName; + } + /** * Called by the parser whenever a chunk is found. */ diff --git a/src/scratchpad/src/org/apache/poi/hsmf/parsers/POIFSChunkParser.java b/src/scratchpad/src/org/apache/poi/hsmf/parsers/POIFSChunkParser.java index 48bd7550a9..adbe1a7ac9 100644 --- a/src/scratchpad/src/org/apache/poi/hsmf/parsers/POIFSChunkParser.java +++ b/src/scratchpad/src/org/apache/poi/hsmf/parsers/POIFSChunkParser.java @@ -60,7 +60,7 @@ public final class POIFSChunkParser { // Do we know what to do with it? if(dir.getName().startsWith(AttachmentChunks.PREFIX)) { - group = new AttachmentChunks(); + group = new AttachmentChunks(dir.getName()); } if(dir.getName().startsWith(NameIdChunks.PREFIX)) { group = new NameIdChunks(); diff --git a/src/scratchpad/testcases/org/apache/poi/hsmf/AllHSMFTests.java b/src/scratchpad/testcases/org/apache/poi/hsmf/AllHSMFTests.java index 81daab2f23..260b658fce 100644 --- a/src/scratchpad/testcases/org/apache/poi/hsmf/AllHSMFTests.java +++ b/src/scratchpad/testcases/org/apache/poi/hsmf/AllHSMFTests.java @@ -20,7 +20,8 @@ package org.apache.poi.hsmf; import junit.framework.Test; import junit.framework.TestSuite; -import org.apache.poi.hsmf.model.*; +import org.apache.poi.hsmf.datatypes.*; +import org.apache.poi.hsmf.parsers.*; public final class AllHSMFTests { @@ -29,9 +30,13 @@ public final class AllHSMFTests { suite.addTestSuite(TestBlankFileRead.class); suite.addTestSuite(TestSimpleFileRead.class); suite.addTestSuite(TestOutlook30FileRead.class); - suite.addTestSuite(TestChunkData.class); suite.addTestSuite(TestFileWithAttachmentsRead.class); + + suite.addTestSuite(TestChunkData.class); + suite.addTestSuite(TestTypes.class); + suite.addTestSuite(TestPOIFSChunkParser.class); + return suite; } } diff --git a/src/scratchpad/testcases/org/apache/poi/hsmf/model/TestBlankFileRead.java b/src/scratchpad/testcases/org/apache/poi/hsmf/TestBlankFileRead.java similarity index 98% rename from src/scratchpad/testcases/org/apache/poi/hsmf/model/TestBlankFileRead.java rename to src/scratchpad/testcases/org/apache/poi/hsmf/TestBlankFileRead.java index fb21c5e86e..430c1b8e7a 100644 --- a/src/scratchpad/testcases/org/apache/poi/hsmf/model/TestBlankFileRead.java +++ b/src/scratchpad/testcases/org/apache/poi/hsmf/TestBlankFileRead.java @@ -15,7 +15,7 @@ limitations under the License. ==================================================================== */ -package org.apache.poi.hsmf.model; +package org.apache.poi.hsmf; import java.io.IOException; diff --git a/src/scratchpad/testcases/org/apache/poi/hsmf/model/TestFileWithAttachmentsRead.java b/src/scratchpad/testcases/org/apache/poi/hsmf/TestFileWithAttachmentsRead.java similarity index 98% rename from src/scratchpad/testcases/org/apache/poi/hsmf/model/TestFileWithAttachmentsRead.java rename to src/scratchpad/testcases/org/apache/poi/hsmf/TestFileWithAttachmentsRead.java index 8762ef415c..c3fcda741f 100644 --- a/src/scratchpad/testcases/org/apache/poi/hsmf/model/TestFileWithAttachmentsRead.java +++ b/src/scratchpad/testcases/org/apache/poi/hsmf/TestFileWithAttachmentsRead.java @@ -15,7 +15,7 @@ limitations under the License. ==================================================================== */ -package org.apache.poi.hsmf.model; +package org.apache.poi.hsmf; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; diff --git a/src/scratchpad/testcases/org/apache/poi/hsmf/model/TestOutlook30FileRead.java b/src/scratchpad/testcases/org/apache/poi/hsmf/TestOutlook30FileRead.java similarity index 99% rename from src/scratchpad/testcases/org/apache/poi/hsmf/model/TestOutlook30FileRead.java rename to src/scratchpad/testcases/org/apache/poi/hsmf/TestOutlook30FileRead.java index 12cc44c42b..113a214eb0 100644 --- a/src/scratchpad/testcases/org/apache/poi/hsmf/model/TestOutlook30FileRead.java +++ b/src/scratchpad/testcases/org/apache/poi/hsmf/TestOutlook30FileRead.java @@ -15,7 +15,7 @@ limitations under the License. ==================================================================== */ -package org.apache.poi.hsmf.model; +package org.apache.poi.hsmf; import java.io.IOException; diff --git a/src/scratchpad/testcases/org/apache/poi/hsmf/model/TestSimpleFileRead.java b/src/scratchpad/testcases/org/apache/poi/hsmf/TestSimpleFileRead.java similarity index 99% rename from src/scratchpad/testcases/org/apache/poi/hsmf/model/TestSimpleFileRead.java rename to src/scratchpad/testcases/org/apache/poi/hsmf/TestSimpleFileRead.java index 672d94e8ff..3f261f4d8f 100644 --- a/src/scratchpad/testcases/org/apache/poi/hsmf/model/TestSimpleFileRead.java +++ b/src/scratchpad/testcases/org/apache/poi/hsmf/TestSimpleFileRead.java @@ -15,7 +15,7 @@ limitations under the License. ==================================================================== */ -package org.apache.poi.hsmf.model; +package org.apache.poi.hsmf; import java.io.IOException; diff --git a/src/scratchpad/testcases/org/apache/poi/hsmf/model/TestChunkData.java b/src/scratchpad/testcases/org/apache/poi/hsmf/datatypes/TestChunkData.java similarity index 98% rename from src/scratchpad/testcases/org/apache/poi/hsmf/model/TestChunkData.java rename to src/scratchpad/testcases/org/apache/poi/hsmf/datatypes/TestChunkData.java index 6a9fae44e2..39440d13b6 100644 --- a/src/scratchpad/testcases/org/apache/poi/hsmf/model/TestChunkData.java +++ b/src/scratchpad/testcases/org/apache/poi/hsmf/datatypes/TestChunkData.java @@ -15,7 +15,7 @@ limitations under the License. ==================================================================== */ -package org.apache.poi.hsmf.model; +package org.apache.poi.hsmf.datatypes; import org.apache.poi.hsmf.datatypes.Chunk; import org.apache.poi.hsmf.datatypes.Chunks; diff --git a/src/scratchpad/testcases/org/apache/poi/hsmf/model/TestTypes.java b/src/scratchpad/testcases/org/apache/poi/hsmf/datatypes/TestTypes.java similarity index 97% rename from src/scratchpad/testcases/org/apache/poi/hsmf/model/TestTypes.java rename to src/scratchpad/testcases/org/apache/poi/hsmf/datatypes/TestTypes.java index 2b99af5309..0a2de38ac3 100644 --- a/src/scratchpad/testcases/org/apache/poi/hsmf/model/TestTypes.java +++ b/src/scratchpad/testcases/org/apache/poi/hsmf/datatypes/TestTypes.java @@ -15,7 +15,7 @@ limitations under the License. ==================================================================== */ -package org.apache.poi.hsmf.model; +package org.apache.poi.hsmf.datatypes; import org.apache.poi.hsmf.datatypes.Types; diff --git a/src/scratchpad/testcases/org/apache/poi/hsmf/parsers/TestPOIFSChunkParser.java b/src/scratchpad/testcases/org/apache/poi/hsmf/parsers/TestPOIFSChunkParser.java new file mode 100644 index 0000000000..06bc5f9e30 --- /dev/null +++ b/src/scratchpad/testcases/org/apache/poi/hsmf/parsers/TestPOIFSChunkParser.java @@ -0,0 +1,56 @@ +/* ==================================================================== + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +==================================================================== */ + +package org.apache.poi.hsmf.parsers; + +import java.io.FileInputStream; +import java.io.IOException; + +import org.apache.poi.poifs.filesystem.POIFSFileSystem; +import org.apache.poi.POIDataSamples; + +import junit.framework.TestCase; + +/** + * Tests to verify that the chunk parser works properly + */ +public final class TestPOIFSChunkParser extends TestCase { + private POIDataSamples samples; + + public TestPOIFSChunkParser() throws IOException { + samples = POIDataSamples.getHSMFInstance(); + } + + public void testFindsRecips() throws IOException { + + } + + public void testFindsAttachments() throws IOException { + POIFSFileSystem with = new POIFSFileSystem( + new FileInputStream(samples.getFile("attachment_test_msg.msg")) + ); + POIFSFileSystem without = new POIFSFileSystem( + new FileInputStream(samples.getFile("simple_test_msg.msg")) + ); + + // Check details on the one with + + // One with, from the top + + // One without, from the top + } +} -- 2.39.5