You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by jo...@apache.org on 2009/05/21 20:15:01 UTC
svn commit: r777204 [20/21] - in /poi/trunk/src/scratchpad:
examples/src/org/apache/poi/hslf/examples/
examples/src/org/apache/poi/hwpf/ src/org/apache/poi/hdf/event/
src/org/apache/poi/hdf/extractor/ src/org/apache/poi/hdf/extractor/data/
src/org/apac...
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestReOrderingSlides.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestReOrderingSlides.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestReOrderingSlides.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestReOrderingSlides.java Thu May 21 18:12:22 2009
@@ -1,4 +1,3 @@
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
@@ -15,8 +14,6 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
-
package org.apache.poi.hslf.usermodel;
@@ -33,33 +30,33 @@
*
* @author Nick Burch (nick at torchbox dot com)
*/
-public class TestReOrderingSlides extends TestCase {
+public final class TestReOrderingSlides extends TestCase {
// A SlideShow with one slide
private HSLFSlideShow hss_one;
private SlideShow ss_one;
-
+
// A SlideShow with two slides
private HSLFSlideShow hss_two;
private SlideShow ss_two;
-
+
// A SlideShow with three slides
private HSLFSlideShow hss_three;
private SlideShow ss_three;
-
+
/**
* Create/open the slideshows
*/
public void setUp() throws Exception {
String dirname = System.getProperty("HSLF.testdata.path");
-
+
String filename = dirname + "/Single_Coloured_Page.ppt";
hss_one = new HSLFSlideShow(filename);
ss_one = new SlideShow(hss_one);
-
+
filename = dirname + "/basic_test_ppt_file.ppt";
hss_two = new HSLFSlideShow(filename);
ss_two = new SlideShow(hss_two);
-
+
filename = dirname + "/incorrect_slide_order.ppt";
hss_three = new HSLFSlideShow(filename);
ss_three = new SlideShow(hss_three);
@@ -72,33 +69,33 @@
// Has one slide
assertEquals(1, ss_one.getSlides().length);
Slide s1 = ss_one.getSlides()[0];
-
+
// Check slide 1 is as expected
assertEquals(256, s1._getSheetNumber());
assertEquals(3, s1._getSheetRefId());
assertEquals(1, s1.getSlideNumber());
-
+
// Now move it to one
ss_one.reorderSlide(1, 1);
-
+
// Write out, and read back in
ByteArrayOutputStream baos = new ByteArrayOutputStream();
hss_one.write(baos);
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
-
+
HSLFSlideShow hss_read = new HSLFSlideShow(bais);
SlideShow ss_read = new SlideShow(hss_read);
-
+
// Check it still has 1 slide
assertEquals(1, ss_read.getSlides().length);
-
+
// And check it's as expected
s1 = ss_read.getSlides()[0];
assertEquals(256, s1._getSheetNumber());
assertEquals(3, s1._getSheetRefId());
assertEquals(1, s1.getSlideNumber());
}
-
+
/**
* Test doing a dummy re-order on a slideshow with
* two slides in it
@@ -108,7 +105,7 @@
assertEquals(2, ss_two.getSlides().length);
Slide s1 = ss_two.getSlides()[0];
Slide s2 = ss_two.getSlides()[1];
-
+
// Check slide 1 is as expected
assertEquals(256, s1._getSheetNumber());
assertEquals(4, s1._getSheetRefId()); // master has notes
@@ -117,21 +114,21 @@
assertEquals(257, s2._getSheetNumber());
assertEquals(6, s2._getSheetRefId()); // master and 1 have notes
assertEquals(2, s2.getSlideNumber());
-
+
// Don't swap them around
ss_two.reorderSlide(2, 2);
-
+
// Write out, and read back in
ByteArrayOutputStream baos = new ByteArrayOutputStream();
hss_two.write(baos);
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
-
+
HSLFSlideShow hss_read = new HSLFSlideShow(bais);
SlideShow ss_read = new SlideShow(hss_read);
-
+
// Check it still has 2 slides
assertEquals(2, ss_read.getSlides().length);
-
+
// And check it's as expected
s1 = ss_read.getSlides()[0];
s2 = ss_read.getSlides()[1];
@@ -142,7 +139,7 @@
assertEquals(6, s2._getSheetRefId());
assertEquals(2, s2.getSlideNumber());
}
-
+
/**
* Test re-ordering slides in a slideshow with 2 slides on it
*/
@@ -151,7 +148,7 @@
assertEquals(2, ss_two.getSlides().length);
Slide s1 = ss_two.getSlides()[0];
Slide s2 = ss_two.getSlides()[1];
-
+
// Check slide 1 is as expected
assertEquals(256, s1._getSheetNumber());
assertEquals(4, s1._getSheetRefId()); // master has notes
@@ -160,21 +157,21 @@
assertEquals(257, s2._getSheetNumber());
assertEquals(6, s2._getSheetRefId()); // master and 1 have notes
assertEquals(2, s2.getSlideNumber());
-
+
// Swap them around
ss_two.reorderSlide(2, 1);
-
+
// Write out, and read back in
ByteArrayOutputStream baos = new ByteArrayOutputStream();
hss_two.write(baos);
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
-
+
HSLFSlideShow hss_read = new HSLFSlideShow(bais);
SlideShow ss_read = new SlideShow(hss_read);
-
+
// Check it still has 2 slides
assertEquals(2, ss_read.getSlides().length);
-
+
// And check it's as expected
s1 = ss_read.getSlides()[0];
s2 = ss_read.getSlides()[1];
@@ -185,7 +182,7 @@
assertEquals(4, s2._getSheetRefId());
assertEquals(2, s2.getSlideNumber());
}
-
+
/**
* Test doing a dummy re-order on a slideshow with
* three slides in it
@@ -196,7 +193,7 @@
Slide s1 = ss_three.getSlides()[0];
Slide s2 = ss_three.getSlides()[1];
Slide s3 = ss_three.getSlides()[2];
-
+
// Check slide 1 is as expected
assertEquals(256, s1._getSheetNumber());
assertEquals(3, s1._getSheetRefId()); // no notes on master
@@ -209,26 +206,26 @@
assertEquals(257, s3._getSheetNumber());
assertEquals(4, s3._getSheetRefId()); // no notes on slide
assertEquals(3, s3.getSlideNumber());
-
+
// Don't swap them around
ss_three.reorderSlide(2, 2);
-
+
// Write out, and read back in
ByteArrayOutputStream baos = new ByteArrayOutputStream();
hss_three.write(baos);
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
-
+
HSLFSlideShow hss_read = new HSLFSlideShow(bais);
SlideShow ss_read = new SlideShow(hss_read);
-
+
// Check it still has 3 slides
assertEquals(3, ss_read.getSlides().length);
-
+
// And check it's as expected
s1 = ss_read.getSlides()[0];
s2 = ss_read.getSlides()[1];
s3 = ss_read.getSlides()[2];
-
+
assertEquals(256, s1._getSheetNumber());
assertEquals(3, s1._getSheetRefId());
assertEquals(1, s1.getSlideNumber());
@@ -239,7 +236,7 @@
assertEquals(4, s3._getSheetRefId());
assertEquals(3, s3.getSlideNumber());
}
-
+
/**
* Test re-ordering slides in a slideshow with 3 slides on it
*/
@@ -249,7 +246,7 @@
Slide s1 = ss_three.getSlides()[0];
Slide s2 = ss_three.getSlides()[1];
Slide s3 = ss_three.getSlides()[2];
-
+
// Check slide 1 is as expected
assertEquals(256, s1._getSheetNumber());
assertEquals(3, s1._getSheetRefId()); // no notes on master
@@ -262,22 +259,22 @@
assertEquals(257, s3._getSheetNumber());
assertEquals(4, s3._getSheetRefId()); // no notes on slide
assertEquals(3, s3.getSlideNumber());
-
+
// Put 3 in place of 1
// (1 -> 2, 2 -> 3)
ss_three.reorderSlide(3, 1);
-
+
// Write out, and read back in
ByteArrayOutputStream baos = new ByteArrayOutputStream();
hss_three.write(baos);
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
-
+
HSLFSlideShow hss_read = new HSLFSlideShow(bais);
SlideShow ss_read = new SlideShow(hss_read);
-
+
// Check it still has 3 slides
assertEquals(3, ss_read.getSlides().length);
-
+
// And check it's as expected
Slide _s1 = ss_read.getSlides()[0];
Slide _s2 = ss_read.getSlides()[1];
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestRecordSetup.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestRecordSetup.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestRecordSetup.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestRecordSetup.java Thu May 21 18:12:22 2009
@@ -1,4 +1,3 @@
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
@@ -15,8 +14,6 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
-
package org.apache.poi.hslf.usermodel;
@@ -29,13 +26,13 @@
import org.apache.poi.hslf.record.RecordContainer;
/**
- * Tests that the record setup done by SlideShow
+ * Tests that the record setup done by SlideShow
* has worked correctly
* Note: most recent record stuff has its own test
*
* @author Nick Burch (nick at torchbox dot com)
*/
-public class TestRecordSetup extends TestCase {
+public final class TestRecordSetup extends TestCase {
// SlideShow primed on the test data
private SlideShow ss;
private HSLFSlideShow hss;
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestRichTextRun.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestRichTextRun.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestRichTextRun.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestRichTextRun.java Thu May 21 18:12:22 2009
@@ -37,7 +37,7 @@
* (model.TestTextRun tests the other functionality)
* @author Nick Burch (nick at torchbox dot com)
*/
-public class TestRichTextRun extends TestCase {
+public final class TestRichTextRun extends TestCase {
// SlideShow primed on the test data
private SlideShow ss;
private SlideShow ssRichA;
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestSheetText.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestSheetText.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestSheetText.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestSheetText.java Thu May 21 18:12:22 2009
@@ -1,4 +1,3 @@
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
@@ -15,8 +14,6 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
-
package org.apache.poi.hslf.usermodel;
@@ -30,7 +27,7 @@
*
* @author Nick Burch (nick at torchbox dot com)
*/
-public class TestSheetText extends TestCase {
+public final class TestSheetText extends TestCase {
// SlideShow primed on the test data
private SlideShow ss;
@@ -59,7 +56,7 @@
assertEquals(expectText[i], slideTwo.getTextRuns()[i].getText());
}
}
-
+
/**
* Check we can still get the text from a file where the
* TextProps don't have enough data.
@@ -70,14 +67,14 @@
String filename = dirname + "/iisd_report.ppt";
HSLFSlideShow hss = new HSLFSlideShow(filename);
SlideShow sss = new SlideShow(hss);
-
+
// Should come out with 10 slides, no notes
assertEquals(10, sss.getSlides().length);
assertEquals(0, sss.getNotes().length);
-
+
// Check text on first slide
Slide s = sss.getSlides()[0];
- String exp =
+ String exp =
"Realizing the Development Dividend:\n" +
"Community Capacity Building and CDM.\n" +
"Can they co-exist?\n\n" +
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestSlideOrdering.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestSlideOrdering.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestSlideOrdering.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestSlideOrdering.java Thu May 21 18:12:22 2009
@@ -1,4 +1,3 @@
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
@@ -15,8 +14,6 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
-
package org.apache.poi.hslf.usermodel;
@@ -30,7 +27,7 @@
*
* @author Nick Burch (nick at torchbox dot com)
*/
-public class TestSlideOrdering extends TestCase {
+public final class TestSlideOrdering extends TestCase {
// Simple slideshow, record order matches slide order
private SlideShow ssA;
// Complex slideshow, record order doesn't match slide order
@@ -38,11 +35,11 @@
public TestSlideOrdering() throws Exception {
String dirname = System.getProperty("HSLF.testdata.path");
-
+
String filenameA = dirname + "/basic_test_ppt_file.ppt";
HSLFSlideShow hssA = new HSLFSlideShow(filenameA);
ssA = new SlideShow(hssA);
-
+
String filenameB = dirname + "/incorrect_slide_order.ppt";
HSLFSlideShow hssB = new HSLFSlideShow(filenameB);
ssB = new SlideShow(hssB);
@@ -53,15 +50,15 @@
*/
public void testSimpleCase() throws Exception {
assertEquals(2, ssA.getSlides().length);
-
+
Slide s1 = ssA.getSlides()[0];
Slide s2 = ssA.getSlides()[1];
-
+
String[] firstTRs = new String[] {
"This is a test title",
"This is the title on page 2"
};
-
+
assertEquals(firstTRs[0], s1.getTextRuns()[0].getText());
assertEquals(firstTRs[1], s2.getTextRuns()[0].getText());
}
@@ -71,17 +68,17 @@
*/
public void testComplexCase() throws Exception {
assertEquals(3, ssB.getSlides().length);
-
+
Slide s1 = ssB.getSlides()[0];
Slide s2 = ssB.getSlides()[1];
Slide s3 = ssB.getSlides()[2];
-
+
String[] firstTRs = new String[] {
"Slide 1",
"Slide 2",
"Slide 3"
};
-
+
assertEquals(firstTRs[0], s1.getTextRuns()[0].getText());
assertEquals(firstTRs[1], s2.getTextRuns()[0].getText());
assertEquals(firstTRs[2], s3.getTextRuns()[0].getText());
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestSoundData.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestSoundData.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestSoundData.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestSoundData.java Thu May 21 18:12:22 2009
@@ -1,63 +1,63 @@
-/* ====================================================================
- 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.hslf.usermodel;
-
-import org.apache.poi.hslf.*;
-import org.apache.poi.hslf.exceptions.HSLFException;
-import org.apache.poi.hslf.blip.*;
-import org.apache.poi.hslf.model.*;
-import junit.framework.TestCase;
-
-import java.io.*;
-import java.util.Arrays;
-
-/**
- * Test reading sound data from a ppt
- *
- * @author Yegor Kozlov
- */
-public class TestSoundData extends TestCase{
-
- protected File cwd;
-
- public void setUp() throws Exception {
- cwd = new File(System.getProperty("HSLF.testdata.path"));
- }
-
- /**
- * Read a reference sound file from disk and compare it from the data extracted from the slide show
- */
- public void testSounds() throws Exception {
- //read the reference sound file
- File f = new File(cwd, "ringin.wav");
- int length = (int)f.length();
- byte[] ref_data = new byte[length];
- FileInputStream is = new FileInputStream(f);
- is.read(ref_data);
- is.close();
-
- is = new FileInputStream(new File(cwd, "sound.ppt"));
- SlideShow ppt = new SlideShow(is);
- is.close();
-
- SoundData[] sound = ppt.getSoundData();
- assertEquals("Expected 1 sound", 1, sound.length);
-
- assertTrue(Arrays.equals(ref_data, sound[0].getData()));
- }
-}
+/* ====================================================================
+ 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.hslf.usermodel;
+
+import org.apache.poi.hslf.*;
+import org.apache.poi.hslf.exceptions.HSLFException;
+import org.apache.poi.hslf.blip.*;
+import org.apache.poi.hslf.model.*;
+import junit.framework.TestCase;
+
+import java.io.*;
+import java.util.Arrays;
+
+/**
+ * Test reading sound data from a ppt
+ *
+ * @author Yegor Kozlov
+ */
+public final class TestSoundData extends TestCase{
+
+ protected File cwd;
+
+ public void setUp() throws Exception {
+ cwd = new File(System.getProperty("HSLF.testdata.path"));
+ }
+
+ /**
+ * Read a reference sound file from disk and compare it from the data extracted from the slide show
+ */
+ public void testSounds() throws Exception {
+ //read the reference sound file
+ File f = new File(cwd, "ringin.wav");
+ int length = (int)f.length();
+ byte[] ref_data = new byte[length];
+ FileInputStream is = new FileInputStream(f);
+ is.read(ref_data);
+ is.close();
+
+ is = new FileInputStream(new File(cwd, "sound.ppt"));
+ SlideShow ppt = new SlideShow(is);
+ is.close();
+
+ SoundData[] sound = ppt.getSoundData();
+ assertEquals("Expected 1 sound", 1, sound.length);
+
+ assertTrue(Arrays.equals(ref_data, sound[0].getData()));
+ }
+}
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/util/TestSystemTimeUtils.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/util/TestSystemTimeUtils.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/util/TestSystemTimeUtils.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/util/TestSystemTimeUtils.java Thu May 21 18:12:22 2009
@@ -1,4 +1,3 @@
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
@@ -15,8 +14,6 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
-
package org.apache.poi.hslf.util;
@@ -31,26 +28,26 @@
*
* @author Nick Burch (nick at torchbox dot com)
*/
-public class TestSystemTimeUtils extends TestCase {
+public final class TestSystemTimeUtils extends TestCase {
// From real files
- private byte[] data_a = new byte[] {
+ private byte[] data_a = new byte[] {
0xD6-256, 07, 01, 00,
- 02, 00, 0x18, 00, 0x0A, 00, 0x1A, 00,
+ 02, 00, 0x18, 00, 0x0A, 00, 0x1A, 00,
0x0F, 00, 0xCD-256, 00
};
private byte[] data_b = new byte[] {
00, 00, 0xE1-256, 0x2E, 0x1C, 00, 00, 00,
- 01, 00, 00, 00, 0xD6-256, 0x07, 01, 00,
+ 01, 00, 00, 00, 0xD6-256, 0x07, 01, 00,
02, 00, 0x18, 00, 0x15, 00, 0x19, 00, 03,
- 00, 0xD5-256, 02, 0x0A, 00, 00, 00,
+ 00, 0xD5-256, 02, 0x0A, 00, 00, 00,
0x0A, 00, 00, 00
};
-
+
private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss.SSS");
public void testGetDateA() throws Exception {
Date date = SystemTimeUtils.getDate(data_a);
-
+
// Is 2006-01-24 (2nd day of week) 10:26:15.205
Date exp = sdf.parse("2006-01-24 10:26:15.205");
assertEquals(exp.getTime(), date.getTime());
@@ -59,32 +56,32 @@
public void testGetDateB() throws Exception {
Date date = SystemTimeUtils.getDate(data_b, 8+4);
-
+
// Is 2006-01-24 (2nd day of week) 21:25:03.725
Date exp = sdf.parse("2006-01-24 21:25:03.725");
assertEquals(exp.getTime(), date.getTime());
assertEquals(exp, date);
}
-
+
public void testWriteDateA() throws Exception {
byte[] out_a = new byte[data_a.length];
Date date = sdf.parse("2006-01-24 10:26:15.205");
SystemTimeUtils.storeDate(date, out_a);
-
+
for(int i=0; i<out_a.length; i++) {
assertEquals(data_a[i], out_a[i]);
}
}
-
+
public void testWriteDateB() throws Exception {
byte[] out_b = new byte[data_b.length];
// Copy over start and end, ignoring the 16 byte date field in the middle
System.arraycopy(data_b, 0, out_b, 0, 12);
System.arraycopy(data_b, 12+16, out_b, 12+16, data_b.length-12-16);
-
+
Date date = sdf.parse("2006-01-24 21:25:03.725");
SystemTimeUtils.storeDate(date, out_b, 12);
-
+
for(int i=0; i<out_b.length; i++) {
assertEquals(data_b[i], out_b[i]);
}
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hsmf/model/TestChunkData.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hsmf/model/TestChunkData.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hsmf/model/TestChunkData.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hsmf/model/TestChunkData.java Thu May 21 18:12:22 2009
@@ -26,28 +26,28 @@
/**
* Verifies that the Chunks class is actually setup properly and hasn't been changed in ways
* that will break the library.
- *
+ *
* @author Travis Ferguson
*
*/
-public class TestChunkData extends TestCase {
+public final class TestChunkData extends TestCase {
private Chunks chunks = Chunks.getInstance(false);
-
+
public void testChunkCreate() {
StringChunk chunk = new StringChunk(0x0200, false);
TestCase.assertEquals("__substg1.0_0200001E", chunk.getEntryName());
-
+
/* test the lower and upper limits of the chunk ids */
chunk = new StringChunk(0x0000, false);
TestCase.assertEquals("__substg1.0_0000001E", chunk.getEntryName());
-
+
chunk = new StringChunk(0xFFFF, false);
TestCase.assertEquals("__substg1.0_FFFF001E", chunk.getEntryName());
-
+
chunk = new StringChunk(0xFFFF, true);
TestCase.assertEquals("__substg1.0_FFFF001F", chunk.getEntryName());
}
-
+
public void testTextBodyChunk() {
StringChunk chunk = new StringChunk(0x1000, false);
TestCase.assertEquals(chunk.getEntryName(), chunks.textBodyChunk.getEntryName());
@@ -57,7 +57,7 @@
StringChunk chunk = new StringChunk(0x0E04, false);
TestCase.assertEquals(chunk.getEntryName(), chunks.displayToChunk.getEntryName());
}
-
+
public void testDisplayCCChunk() {
StringChunk chunk = new StringChunk(0x0E03, false);
@@ -68,10 +68,10 @@
StringChunk chunk = new StringChunk(0x0E02, false);
TestCase.assertEquals(chunk.getEntryName(), chunks.displayBCCChunk.getEntryName());
}
-
+
public void testSubjectChunk() {
Chunk chunk = new StringChunk(0x0037, false);
TestCase.assertEquals(chunk.getEntryName(), chunks.subjectChunk.getEntryName());
}
-
+
}
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hsmf/model/TestOutlook30FileRead.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hsmf/model/TestOutlook30FileRead.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hsmf/model/TestOutlook30FileRead.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hsmf/model/TestOutlook30FileRead.java Thu May 21 18:12:22 2009
@@ -27,109 +27,109 @@
/**
* Tests to verify that we can still work on the newer Outlook 3.0 files.
*/
-public class TestOutlook30FileRead extends TestCase {
+public final class TestOutlook30FileRead extends TestCase {
private MAPIMessage mapiMessage;
-
+
/**
* Initialize this test, load up the blank.msg mapi message.
- * @throws Exception
+ * @throws Exception
*/
public TestOutlook30FileRead() throws IOException {
String dirname = System.getProperty("HSMF.testdata.path");
this.mapiMessage = new MAPIMessage(dirname + "/outlook_30_msg.msg");
}
-
+
/**
* Test to see if we can read the CC Chunk.
- * @throws ChunkNotFoundException
- *
+ * @throws ChunkNotFoundException
+ *
*/
public void testReadDisplayCC() throws ChunkNotFoundException {
String obtained = mapiMessage.getDisplayCC();
String expected = "";
-
+
TestCase.assertEquals(obtained, expected);
}
-
+
/**
* Test to see if we can read the CC Chunk.
- * @throws ChunkNotFoundException
- *
+ * @throws ChunkNotFoundException
+ *
*/
public void testReadDisplayTo() throws ChunkNotFoundException {
String obtained = mapiMessage.getDisplayTo();
-
+
assertTrue(obtained.startsWith("Bohn, Shawn"));
}
-
+
/**
* Test to see if we can read the From Chunk.
- * @throws ChunkNotFoundException
- *
+ * @throws ChunkNotFoundException
+ *
*/
public void testReadDisplayFrom() throws ChunkNotFoundException {
String obtained = mapiMessage.getDisplayFrom();
String expected = "Cramer, Nick";
-
+
TestCase.assertEquals(obtained, expected);
}
-
+
/**
* Test to see if we can read the CC Chunk.
- * @throws ChunkNotFoundException
- *
+ * @throws ChunkNotFoundException
+ *
*/
public void testReadDisplayBCC() throws ChunkNotFoundException {
String obtained = mapiMessage.getDisplayBCC();
String expected = "";
-
+
TestCase.assertEquals(obtained, expected);
}
-
-
- /**
+
+
+ /**
* Check if we can read the body of the blank message, we expect "".
- *
+ *
* @throws Exception
*/
public void testReadBody() throws Exception {
String obtained = mapiMessage.getTextBody();
assertTrue(obtained.startsWith("I am shutting down"));
}
-
+
/**
* Check if we can read the subject line of the blank message, we expect ""
- *
+ *
* @throws Exception
*/
public void testReadSubject() throws Exception {
String obtained = mapiMessage.getSubject();
String expected = "IN-SPIRE servers going down for a bit, back up around 8am";
-
+
TestCase.assertEquals(expected, obtained);
}
/**
* Check if we can read the subject line of the blank message, we expect ""
- *
+ *
* @throws Exception
*/
public void testReadConversationTopic() throws Exception {
String obtained = mapiMessage.getConversationTopic();
TestCase.assertEquals("IN-SPIRE servers going down for a bit, back up around 8am", obtained);
}
-
+
/**
* Check if we can read the subject line of the blank message, we expect ""
- *
+ *
* @throws Exception
*/
public void testReadMessageClass() throws Exception {
String obtained = mapiMessage.getMessageClass();
TestCase.assertEquals("IPM.Note", obtained);
}
-
-
-
+
+
+
}
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hsmf/model/TestSimpleFileRead.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hsmf/model/TestSimpleFileRead.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hsmf/model/TestSimpleFileRead.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hsmf/model/TestSimpleFileRead.java Thu May 21 18:12:22 2009
@@ -27,115 +27,115 @@
/**
* Tests to verify that we can read a simple msg file, that is in plain/text format with no attachments
* or extra recipents.
- *
+ *
* @author Travis Ferguson
*/
-public class TestSimpleFileRead extends TestCase {
+public final class TestSimpleFileRead extends TestCase {
private MAPIMessage mapiMessage;
-
+
/**
* Initialize this test, load up the blank.msg mapi message.
- * @throws Exception
+ * @throws Exception
*/
public TestSimpleFileRead() throws IOException {
String dirname = System.getProperty("HSMF.testdata.path");
this.mapiMessage = new MAPIMessage(dirname + "/simple_test_msg.msg");
}
-
+
/**
* Test to see if we can read the CC Chunk.
- * @throws ChunkNotFoundException
- *
+ * @throws ChunkNotFoundException
+ *
*/
public void testReadDisplayCC() throws ChunkNotFoundException {
String obtained = mapiMessage.getDisplayCC();
String expected = "";
-
+
TestCase.assertEquals(obtained, expected);
}
-
+
/**
* Test to see if we can read the CC Chunk.
- * @throws ChunkNotFoundException
- *
+ * @throws ChunkNotFoundException
+ *
*/
public void testReadDisplayTo() throws ChunkNotFoundException {
String obtained = mapiMessage.getDisplayTo();
String expected = "travis@overwrittenstack.com";
-
+
TestCase.assertEquals(obtained, expected);
}
-
+
/**
* Test to see if we can read the From Chunk.
- * @throws ChunkNotFoundException
- *
+ * @throws ChunkNotFoundException
+ *
*/
public void testReadDisplayFrom() throws ChunkNotFoundException {
String obtained = mapiMessage.getDisplayFrom();
String expected = "Travis Ferguson";
-
+
TestCase.assertEquals(obtained, expected);
}
-
+
/**
* Test to see if we can read the CC Chunk.
- * @throws ChunkNotFoundException
- *
+ * @throws ChunkNotFoundException
+ *
*/
public void testReadDisplayBCC() throws ChunkNotFoundException {
String obtained = mapiMessage.getDisplayBCC();
String expected = "";
-
+
TestCase.assertEquals(obtained, expected);
}
-
-
- /**
+
+
+ /**
* Check if we can read the body of the blank message, we expect "".
- *
+ *
* @throws Exception
*/
public void testReadBody() throws Exception {
String obtained = mapiMessage.getTextBody();
String expected = "This is a test message.";
-
+
TestCase.assertEquals(obtained, expected);
}
-
+
/**
* Check if we can read the subject line of the blank message, we expect ""
- *
+ *
* @throws Exception
*/
public void testReadSubject() throws Exception {
String obtained = mapiMessage.getSubject();
String expected = "test message";
-
+
TestCase.assertEquals(expected, obtained);
}
/**
* Check if we can read the subject line of the blank message, we expect ""
- *
+ *
* @throws Exception
*/
public void testReadConversationTopic() throws Exception {
String obtained = mapiMessage.getConversationTopic();
TestCase.assertEquals("test message", obtained);
}
-
+
/**
* Check if we can read the subject line of the blank message, we expect ""
- *
+ *
* @throws Exception
*/
public void testReadMessageClass() throws Exception {
String obtained = mapiMessage.getMessageClass();
TestCase.assertEquals("IPM.Note", obtained);
}
-
-
-
+
+
+
}
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hssf/usermodel/TestHSSFChart.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hssf/usermodel/TestHSSFChart.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hssf/usermodel/TestHSSFChart.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hssf/usermodel/TestHSSFChart.java Thu May 21 18:12:22 2009
@@ -29,26 +29,26 @@
public void testSingleChart() {
HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("WithChart.xls");
-
+
HSSFSheet s1 = wb.getSheetAt(0);
HSSFSheet s2 = wb.getSheetAt(1);
HSSFSheet s3 = wb.getSheetAt(2);
-
+
assertEquals(0, HSSFChart.getSheetCharts(s1).length);
assertEquals(1, HSSFChart.getSheetCharts(s2).length);
assertEquals(0, HSSFChart.getSheetCharts(s3).length);
-
+
HSSFChart[] charts;
-
+
// Check the chart on the 2nd sheet
charts = HSSFChart.getSheetCharts(s2);
assertEquals(1, charts.length);
-
+
assertEquals(2, charts[0].getSeries().length);
assertEquals("1st Column", charts[0].getSeries()[0].getSeriesTitle());
assertEquals("2nd Column", charts[0].getSeries()[1].getSeriesTitle());
assertEquals(null, charts[0].getChartTitle());
-
+
// Check x, y, width, height
assertEquals(0, charts[0].getChartX());
assertEquals(0, charts[0].getChartY());
@@ -58,53 +58,53 @@
public void testTwoCharts() {
HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("WithTwoCharts.xls");
-
+
HSSFSheet s1 = wb.getSheetAt(0);
HSSFSheet s2 = wb.getSheetAt(1);
HSSFSheet s3 = wb.getSheetAt(2);
-
+
assertEquals(0, HSSFChart.getSheetCharts(s1).length);
assertEquals(1, HSSFChart.getSheetCharts(s2).length);
assertEquals(1, HSSFChart.getSheetCharts(s3).length);
-
+
HSSFChart[] charts;
-
+
// Check the chart on the 2nd sheet
charts = HSSFChart.getSheetCharts(s2);
assertEquals(1, charts.length);
-
+
assertEquals(2, charts[0].getSeries().length);
assertEquals("1st Column", charts[0].getSeries()[0].getSeriesTitle());
assertEquals("2nd Column", charts[0].getSeries()[1].getSeriesTitle());
assertEquals(null, charts[0].getChartTitle());
-
+
// And the third sheet
charts = HSSFChart.getSheetCharts(s3);
assertEquals(1, charts.length);
-
+
assertEquals(2, charts[0].getSeries().length);
assertEquals("Squares", charts[0].getSeries()[0].getSeriesTitle());
assertEquals("Base Numbers", charts[0].getSeries()[1].getSeriesTitle());
assertEquals(null, charts[0].getChartTitle());
}
-
+
public void testThreeCharts() {
HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("WithThreeCharts.xls");
-
+
HSSFSheet s1 = wb.getSheetAt(0);
HSSFSheet s2 = wb.getSheetAt(1);
HSSFSheet s3 = wb.getSheetAt(2);
-
+
assertEquals(0, HSSFChart.getSheetCharts(s1).length);
assertEquals(2, HSSFChart.getSheetCharts(s2).length);
assertEquals(1, HSSFChart.getSheetCharts(s3).length);
-
+
HSSFChart[] charts;
-
+
// Check the charts on the 2nd sheet
charts = HSSFChart.getSheetCharts(s2);
assertEquals(2, charts.length);
-
+
assertEquals(2, charts[0].getSeries().length);
assertEquals("1st Column", charts[0].getSeries()[0].getSeriesTitle());
assertEquals("2nd Column", charts[0].getSeries()[1].getSeriesTitle());
@@ -113,15 +113,15 @@
assertEquals(SeriesRecord.CATEGORY_DATA_TYPE_NUMERIC, charts[0].getSeries()[0].getValueType());
assertEquals(SeriesRecord.CATEGORY_DATA_TYPE_NUMERIC, charts[0].getSeries()[1].getValueType());
assertEquals(null, charts[0].getChartTitle());
-
+
assertEquals(1, charts[1].getSeries().length);
assertEquals(null, charts[1].getSeries()[0].getSeriesTitle());
assertEquals("Pie Chart Title Thingy", charts[1].getChartTitle());
-
+
// And the third sheet
charts = HSSFChart.getSheetCharts(s3);
assertEquals(1, charts.length);
-
+
assertEquals(2, charts[0].getSeries().length);
assertEquals("Squares", charts[0].getSeries()[0].getSeriesTitle());
assertEquals("Base Numbers", charts[0].getSeries()[1].getSeriesTitle());
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/AllTests.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/AllTests.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/AllTests.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/AllTests.java Thu May 21 18:12:22 2009
@@ -1,4 +1,3 @@
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
@@ -15,13 +14,12 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
package org.apache.poi.hwpf;
import junit.framework.*;
-public class AllTests
+public final class AllTests
extends TestCase
{
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/HWPFDocFixture.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/HWPFDocFixture.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/HWPFDocFixture.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/HWPFDocFixture.java Thu May 21 18:12:22 2009
@@ -1,4 +1,3 @@
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
@@ -15,7 +14,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
package org.apache.poi.hwpf;
import java.io.FileInputStream;
@@ -27,7 +26,7 @@
import java.io.File;
-public class HWPFDocFixture
+public final class HWPFDocFixture
{
public byte[] _tableStream;
public byte[] _mainStream;
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/HWPFTestCase.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/HWPFTestCase.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/HWPFTestCase.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/HWPFTestCase.java Thu May 21 18:12:22 2009
@@ -1,4 +1,3 @@
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
@@ -15,7 +14,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
package org.apache.poi.hwpf;
import java.io.ByteArrayInputStream;
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/TestHWPFPictures.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/TestHWPFPictures.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/TestHWPFPictures.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/TestHWPFPictures.java Thu May 21 18:12:22 2009
@@ -1,4 +1,3 @@
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
@@ -15,7 +14,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
package org.apache.poi.hwpf;
import java.io.ByteArrayOutputStream;
@@ -31,31 +30,31 @@
* Test picture support in HWPF
* @author nick
*/
-public class TestHWPFPictures extends TestCase {
+public final class TestHWPFPictures extends TestCase {
private String docAFile;
private String docBFile;
private String docCFile;
private String docDFile;
-
+
private String imgAFile;
private String imgBFile;
private String imgCFile;
private String imgDFile;
-
+
protected void setUp() throws Exception {
String dirname = System.getProperty("HWPF.testdata.path");
-
+
docAFile = dirname + "/testPictures.doc";
docBFile = dirname + "/two_images.doc";
docCFile = dirname + "/vector_image.doc";
docDFile = dirname + "/GaiaTest.doc";
-
+
imgAFile = dirname + "/simple_image.jpg";
imgBFile = dirname + "/simple_image.png";
imgCFile = dirname + "/vector_image.emf";
imgDFile = dirname + "/GaiaTestImg.png";
}
-
+
/**
* Test just opening the files
*/
@@ -63,27 +62,27 @@
HWPFDocument docA = new HWPFDocument(new FileInputStream(docAFile));
HWPFDocument docB = new HWPFDocument(new FileInputStream(docBFile));
}
-
+
/**
* Test that we have the right numbers of images in each file
*/
public void testImageCount() throws Exception {
HWPFDocument docA = new HWPFDocument(new FileInputStream(docAFile));
HWPFDocument docB = new HWPFDocument(new FileInputStream(docBFile));
-
+
assertNotNull(docA.getPicturesTable());
assertNotNull(docB.getPicturesTable());
-
+
PicturesTable picA = docA.getPicturesTable();
PicturesTable picB = docB.getPicturesTable();
-
+
List picturesA = picA.getAllPictures();
List picturesB = picB.getAllPictures();
-
+
assertEquals(7, picturesA.size());
assertEquals(2, picturesB.size());
}
-
+
/**
* Test that we have the right images in at least one file
*/
@@ -91,26 +90,26 @@
HWPFDocument docB = new HWPFDocument(new FileInputStream(docBFile));
PicturesTable picB = docB.getPicturesTable();
List picturesB = picB.getAllPictures();
-
+
assertEquals(2, picturesB.size());
-
+
Picture pic1 = (Picture)picturesB.get(0);
Picture pic2 = (Picture)picturesB.get(1);
-
+
assertNotNull(pic1);
assertNotNull(pic2);
-
+
// Check the same
byte[] pic1B = readFile(imgAFile);
byte[] pic2B = readFile(imgBFile);
-
+
assertEquals(pic1B.length, pic1.getContent().length);
assertEquals(pic2B.length, pic2.getContent().length);
assertBytesSame(pic1B, pic1.getContent());
assertBytesSame(pic2B, pic2.getContent());
}
-
+
/**
* Test that compressed image data is correctly returned.
*/
@@ -118,19 +117,19 @@
HWPFDocument docC = new HWPFDocument(new FileInputStream(docCFile));
PicturesTable picC = docC.getPicturesTable();
List picturesC = picC.getAllPictures();
-
+
assertEquals(1, picturesC.size());
-
+
Picture pic = (Picture)picturesC.get(0);
assertNotNull(pic);
-
+
// Check the same
byte[] picBytes = readFile(imgCFile);
-
+
assertEquals(picBytes.length, pic.getContent().length);
assertBytesSame(picBytes, pic.getContent());
}
-
+
/**
* Pending the missing files being uploaded to
* bug #44937
@@ -139,30 +138,30 @@
{
HWPFDocument docD = new HWPFDocument(new FileInputStream(docDFile));
List allPictures = docD.getPicturesTable().getAllPictures();
-
+
assertEquals(1, allPictures.size());
-
+
Picture pic = (Picture) allPictures.get(0);
assertNotNull(pic);
byte[] picD = readFile(imgDFile);
-
+
assertEquals(picD.length, pic.getContent().length);
-
+
assertBytesSame(picD, pic.getContent());
}
-
+
private void assertBytesSame(byte[] a, byte[] b) {
assertEquals(a.length, b.length);
for(int i=0; i<a.length; i++) {
assertEquals(a[i],b[i]);
}
}
-
+
private byte[] readFile(String file) throws Exception {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
FileInputStream fis = new FileInputStream(file);
byte[] buffer = new byte[1024];
-
+
int read = 0;
while(read > -1) {
read = fis.read(buffer);
@@ -170,7 +169,7 @@
baos.write(buffer,0,read);
}
}
-
+
return baos.toByteArray();
}
}
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/TestHWPFRangeParts.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/TestHWPFRangeParts.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/TestHWPFRangeParts.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/TestHWPFRangeParts.java Thu May 21 18:12:22 2009
@@ -1,4 +1,3 @@
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
@@ -15,7 +14,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
package org.apache.poi.hwpf;
import java.io.FileInputStream;
@@ -28,9 +27,9 @@
* Test that we pull out the right bits of a file into
* the different ranges
*/
-public class TestHWPFRangeParts extends TestCase {
+public final class TestHWPFRangeParts extends TestCase {
private static final char page_break = (char)12;
- private static final String headerDef =
+ private static final String headerDef =
"\u0003\r\r" +
"\u0004\r\r" +
"\u0003\r\r" +
@@ -39,11 +38,11 @@
private static final String footerDef = "\r";
private static final String endHeaderFooter = "\r\r";
-
+
private static final String a_page_1 =
"This is a sample word document. It has two pages. It has a three column heading, and a three column footer\r" +
"\r" +
- "HEADING TEXT\r" +
+ "HEADING TEXT\r" +
"\r" +
"More on page one\r" +
"\r\r" +
@@ -52,15 +51,15 @@
private static final String a_page_2 =
"This is page two. It also has a three column heading, and a three column footer.\r"
;
-
+
private static final String a_header =
"First header column!\tMid header Right header!\r"
;
private static final String a_footer =
"Footer Left\tFooter Middle Footer Right\r"
;
-
-
+
+
private static final String u_page_1 =
"This is a fairly simple word document, over two pages, with headers and footers.\r" +
"The trick with this one is that it contains some Unicode based strings in it.\r" +
@@ -76,7 +75,7 @@
private static final String u_page_2 =
"This is page two. Les Pr\u00e9cieuses ridicules. The end.\r"
;
-
+
private static final String u_header =
"\r\r" +
"This is a simple header, with a \u20ac euro symbol in it.\r"
@@ -86,7 +85,7 @@
"The footer, with Moli\u00e8re, has Unicode in it.\r" +
"\r\r\r\r"
;
-
+
/**
* A document made up only of basic ASCII text
*/
@@ -95,21 +94,21 @@
* A document with some unicode in it too
*/
private HWPFDocument docUnicode;
-
+
public void setUp() throws Exception {
String dirname = System.getProperty("HWPF.testdata.path");
-
+
String filename = dirname + "/HeaderFooterUnicode.doc";
docUnicode = new HWPFDocument(
new FileInputStream(filename)
);
-
+
filename = dirname + "/ThreeColHeadFoot.doc";
docAscii = new HWPFDocument(
new FileInputStream(filename)
);
}
-
+
public void testBasics() throws Exception {
// First check the start and end bits
assertEquals(
@@ -122,7 +121,7 @@
a_page_2.length(),
docAscii._cpSplit.getMainDocumentEnd()
);
-
+
assertEquals(
238,
docAscii._cpSplit.getFootnoteStart()
@@ -131,7 +130,7 @@
238,
docAscii._cpSplit.getFootnoteEnd()
);
-
+
assertEquals(
238,
docAscii._cpSplit.getHeaderStoryStart()
@@ -142,10 +141,10 @@
docAscii._cpSplit.getHeaderStoryEnd()
);
}
-
+
public void testContents() throws Exception {
Range r;
-
+
// Now check the real ranges
r = docAscii.getRange();
assertEquals(
@@ -154,32 +153,32 @@
a_page_2,
r.text()
);
-
+
r = docAscii.getHeaderStoryRange();
assertEquals(
headerDef +
a_header +
footerDef +
- a_footer +
+ a_footer +
endHeaderFooter,
r.text()
);
-
+
r = docAscii.getOverallRange();
assertEquals(
a_page_1 +
page_break + "\r" +
- a_page_2 +
+ a_page_2 +
headerDef +
a_header +
footerDef +
- a_footer +
+ a_footer +
endHeaderFooter +
"\r",
r.text()
);
}
-
+
public void testBasicsUnicode() throws Exception {
// First check the start and end bits
assertEquals(
@@ -192,7 +191,7 @@
u_page_2.length(),
docUnicode._cpSplit.getMainDocumentEnd()
);
-
+
assertEquals(
408,
docUnicode._cpSplit.getFootnoteStart()
@@ -201,7 +200,7 @@
408,
docUnicode._cpSplit.getFootnoteEnd()
);
-
+
assertEquals(
408,
docUnicode._cpSplit.getHeaderStoryStart()
@@ -213,10 +212,10 @@
docUnicode._cpSplit.getHeaderStoryEnd()
);
}
-
+
public void testContentsUnicode() throws Exception {
Range r;
-
+
// Now check the real ranges
r = docUnicode.getRange();
assertEquals(
@@ -225,26 +224,26 @@
u_page_2,
r.text()
);
-
+
r = docUnicode.getHeaderStoryRange();
assertEquals(
headerDef +
u_header +
footerDef +
- u_footer +
+ u_footer +
endHeaderFooter,
r.text()
);
-
+
r = docUnicode.getOverallRange();
assertEquals(
u_page_1 +
page_break + "\r" +
- u_page_2 +
+ u_page_2 +
headerDef +
u_header +
footerDef +
- u_footer +
+ u_footer +
endHeaderFooter +
"\r",
r.text()
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/extractor/TestDifferentRoutes.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/extractor/TestDifferentRoutes.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/extractor/TestDifferentRoutes.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/extractor/TestDifferentRoutes.java Thu May 21 18:12:22 2009
@@ -1,19 +1,20 @@
-/*
-* 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.
-*/
+/* ====================================================================
+ 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.hwpf.extractor;
import java.io.FileInputStream;
@@ -31,7 +32,7 @@
*
* @author Nick Burch (nick at torchbox dot com)
*/
-public class TestDifferentRoutes extends TestCase {
+public final class TestDifferentRoutes extends TestCase {
private String[] p_text = new String[] {
"This is a simple word document\r",
"\r",
@@ -48,40 +49,40 @@
"\r",
"It is otherwise very very boring.\r"
};
-
+
private HWPFDocument doc;
-
+
protected void setUp() throws Exception {
String dirname = System.getProperty("HWPF.testdata.path");
-
+
String filename = dirname + "/test2.doc";
doc = new HWPFDocument(new FileInputStream(filename));
- }
-
+ }
+
/**
* Test model based extraction
*/
public void testExtractFromModel() {
Range r = doc.getRange();
-
+
String[] text = new String[r.numParagraphs()];
for(int i=0; i < r.numParagraphs(); i++) {
Paragraph p = r.getParagraph(i);
text[i] = p.text();
}
-
+
assertEquals(p_text.length, text.length);
for(int i=0; i<p_text.length; i++) {
assertEquals(p_text[i], text[i]);
}
}
-
+
/**
* Test textPieces based extraction
*/
public void testExtractFromTextPieces() throws Exception {
StringBuffer textBuf = new StringBuffer();
-
+
Iterator textPieces = doc.getTextTable().getTextPieces().iterator();
while (textPieces.hasNext()) {
TextPiece piece = (TextPiece) textPieces.next();
@@ -93,7 +94,7 @@
String text = new String(piece.getRawBytes(), encoding);
textBuf.append(text);
}
-
+
StringBuffer exp = new StringBuffer();
for(int i=0; i<p_text.length; i++) {
exp.append(p_text[i]);
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/extractor/TestWordExtractor.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/extractor/TestWordExtractor.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/extractor/TestWordExtractor.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/extractor/TestWordExtractor.java Thu May 21 18:12:22 2009
@@ -1,19 +1,20 @@
-/*
-* 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.
-*/
+/* ====================================================================
+ 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.hwpf.extractor;
import java.io.FileInputStream;
@@ -29,7 +30,7 @@
*
* @author Nick Burch (nick at torchbox dot com)
*/
-public class TestWordExtractor extends TestCase {
+public final class TestWordExtractor extends TestCase {
private String[] p_text1 = new String[] {
"This is a simple word document\r\n",
"\r\n",
@@ -47,63 +48,63 @@
"It is otherwise very very boring.\r\n"
};
private String p_text1_block = new String();
-
+
// Well behaved document
private WordExtractor extractor;
// Corrupted document - can't do paragraph based stuff
private WordExtractor extractor2;
// A word doc embeded in an excel file
private String filename3;
-
+
// With header and footer
private String filename4;
// With unicode header and footer
private String filename5;
-
+
protected void setUp() throws Exception {
String dirname = System.getProperty("HWPF.testdata.path");
String pdirname = System.getProperty("POIFS.testdata.path");
-
+
String filename = dirname + "/test2.doc";
String filename2 = dirname + "/test.doc";
filename3 = pdirname + "/excel_with_embeded.xls";
filename4 = dirname + "/ThreeColHeadFoot.doc";
filename5 = dirname + "/HeaderFooterUnicode.doc";
-
+
extractor = new WordExtractor(new FileInputStream(filename));
extractor2 = new WordExtractor(new FileInputStream(filename2));
-
+
// Build splat'd out text version
for(int i=0; i<p_text1.length; i++) {
p_text1_block += p_text1[i];
}
- }
-
+ }
+
/**
* Test paragraph based extraction
*/
public void testExtractFromParagraphs() {
String[] text = extractor.getParagraphText();
-
+
assertEquals(p_text1.length, text.length);
for(int i=0; i<p_text1.length; i++) {
assertEquals(p_text1[i], text[i]);
}
-
+
// On second one, should fall back
assertEquals(1, extractor2.getParagraphText().length);
}
-
+
/**
* Test the paragraph -> flat extraction
*/
public void testGetText() {
assertEquals(p_text1_block, extractor.getText());
-
+
// On second one, should fall back to text piece
assertEquals(extractor2.getTextFromPieces(), extractor2.getText());
}
-
+
/**
* Test textPieces based extraction
*/
@@ -111,8 +112,8 @@
String text = extractor.getTextFromPieces();
assertEquals(p_text1_block, text);
}
-
-
+
+
/**
* Test that we can get data from two different
* embeded word documents
@@ -122,23 +123,23 @@
POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream(filename3));
HWPFDocument doc;
WordExtractor extractor3;
-
+
DirectoryNode dirA = (DirectoryNode)
fs.getRoot().getEntry("MBD0000A3B7");
DirectoryNode dirB = (DirectoryNode)
fs.getRoot().getEntry("MBD0000A3B2");
-
+
// Should have WordDocument and 1Table
assertNotNull(dirA.getEntry("1Table"));
assertNotNull(dirA.getEntry("WordDocument"));
-
+
assertNotNull(dirB.getEntry("1Table"));
assertNotNull(dirB.getEntry("WordDocument"));
-
+
// Check each in turn
doc = new HWPFDocument(dirA, fs);
extractor3 = new WordExtractor(doc);
-
+
assertNotNull(extractor3.getText());
assertTrue(extractor3.getText().length() > 20);
assertEquals("I am a sample document\r\nNot much on me\r\nI am document 1\r\n",
@@ -146,42 +147,42 @@
assertEquals("Sample Doc 1", extractor3.getSummaryInformation().getTitle());
assertEquals("Sample Test", extractor3.getSummaryInformation().getSubject());
-
+
doc = new HWPFDocument(dirB, fs);
extractor3 = new WordExtractor(doc);
-
+
assertNotNull(extractor3.getText());
assertTrue(extractor3.getText().length() > 20);
- assertEquals("I am another sample document\r\nNot much on me\r\nI am document 2\r\n",
+ assertEquals("I am another sample document\r\nNot much on me\r\nI am document 2\r\n",
extractor3.getText());
assertEquals("Sample Doc 2", extractor3.getSummaryInformation().getTitle());
assertEquals("Another Sample Test", extractor3.getSummaryInformation().getSubject());
}
-
+
public void testWithHeader() throws Exception {
// Non-unicode
HWPFDocument doc = new HWPFDocument(
new FileInputStream(filename4)
);
extractor = new WordExtractor(doc);
-
+
assertEquals(
"First header column!\tMid header Right header!\n",
extractor.getHeaderText()
);
-
+
String text = extractor.getText();
assertTrue(
text.indexOf("First header column!") > -1
);
-
-
+
+
// Unicode
doc = new HWPFDocument(
new FileInputStream(filename5)
);
extractor = new WordExtractor(doc);
-
+
assertEquals(
"This is a simple header, with a \u20ac euro symbol in it.\n\n",
extractor.getHeaderText()
@@ -191,31 +192,31 @@
text.indexOf("This is a simple header") > -1
);
}
-
+
public void testWithFooter() throws Exception {
// Non-unicode
HWPFDocument doc = new HWPFDocument(
new FileInputStream(filename4)
);
extractor = new WordExtractor(doc);
-
+
assertEquals(
"Footer Left\tFooter Middle Footer Right\n",
extractor.getFooterText()
);
-
+
String text = extractor.getText();
assertTrue(
text.indexOf("Footer Left") > -1
);
-
-
+
+
// Unicode
doc = new HWPFDocument(
new FileInputStream(filename5)
);
extractor = new WordExtractor(doc);
-
+
assertEquals(
"The footer, with Moli\u00e8re, has Unicode in it.\n",
extractor.getFooterText()
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/extractor/TestWordExtractorBugs.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/extractor/TestWordExtractorBugs.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/extractor/TestWordExtractorBugs.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/extractor/TestWordExtractorBugs.java Thu May 21 18:12:22 2009
@@ -1,19 +1,20 @@
-/*
-* 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.
-*/
+/* ====================================================================
+ 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.hwpf.extractor;
import java.io.FileInputStream;
@@ -25,21 +26,21 @@
*
* @author Nick Burch (nick at torchbox dot com)
*/
-public class TestWordExtractorBugs extends TestCase {
+public final class TestWordExtractorBugs extends TestCase {
private String dirname;
protected void setUp() throws Exception {
dirname = System.getProperty("HWPF.testdata.path");
}
-
+
public void testProblemMetadata() throws Exception {
String filename = dirname + "/ProblemExtracting.doc";
- WordExtractor extractor =
+ WordExtractor extractor =
new WordExtractor(new FileInputStream(filename));
-
+
// Check it gives text without error
extractor.getText();
extractor.getParagraphText();
extractor.getTextFromPieces();
- }
-
+ }
+
}
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestCHPBinTable.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestCHPBinTable.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestCHPBinTable.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestCHPBinTable.java Thu May 21 18:12:22 2009
@@ -1,4 +1,3 @@
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
@@ -15,7 +14,6 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
package org.apache.poi.hwpf.model;
@@ -27,12 +25,12 @@
import org.apache.poi.hwpf.*;
import org.apache.poi.hwpf.model.io.*;
-public class TestCHPBinTable
+public final class TestCHPBinTable
extends TestCase
{
private CHPBinTable _cHPBinTable = null;
private HWPFDocFixture _hWPFDocFixture;
-
+
private TextPieceTable fakeTPT = new TextPieceTable();
public TestCHPBinTable(String name)
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestDocumentProperties.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestDocumentProperties.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestDocumentProperties.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestDocumentProperties.java Thu May 21 18:12:22 2009
@@ -1,4 +1,3 @@
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
@@ -15,7 +14,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
package org.apache.poi.hwpf.model;
import junit.framework.*;
@@ -24,7 +23,7 @@
import java.lang.reflect.*;
import java.util.Arrays;
-public class TestDocumentProperties
+public final class TestDocumentProperties
extends TestCase
{
private DocumentProperties _documentProperties = null;
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestFileInformationBlock.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestFileInformationBlock.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestFileInformationBlock.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestFileInformationBlock.java Thu May 21 18:12:22 2009
@@ -1,4 +1,3 @@
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
@@ -15,7 +14,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
package org.apache.poi.hwpf.model;
import junit.framework.*;
@@ -23,7 +22,7 @@
import java.lang.reflect.*;
-public class TestFileInformationBlock
+public final class TestFileInformationBlock
extends TestCase
{
private FileInformationBlock _fileInformationBlock = null;
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestFontTable.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestFontTable.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestFontTable.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestFontTable.java Thu May 21 18:12:22 2009
@@ -1,4 +1,3 @@
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
@@ -15,7 +14,6 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
package org.apache.poi.hwpf.model;
@@ -23,7 +21,7 @@
import org.apache.poi.hwpf.*;
import org.apache.poi.hwpf.model.io.*;
-public class TestFontTable
+public final class TestFontTable
extends TestCase
{
private FontTable _fontTable = null;
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestListTables.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestListTables.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestListTables.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestListTables.java Thu May 21 18:12:22 2009
@@ -1,4 +1,3 @@
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
@@ -15,14 +14,14 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
package org.apache.poi.hwpf.model;
import org.apache.poi.hwpf.*;
import org.apache.poi.hwpf.model.io.*;
-public class TestListTables
+public final class TestListTables
extends HWPFTestCase
{
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestPAPBinTable.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestPAPBinTable.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestPAPBinTable.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestPAPBinTable.java Thu May 21 18:12:22 2009
@@ -1,4 +1,3 @@
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
@@ -15,7 +14,6 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
package org.apache.poi.hwpf.model;
@@ -26,7 +24,7 @@
import java.io.*;
import java.util.*;
-public class TestPAPBinTable
+public final class TestPAPBinTable
extends TestCase
{
private PAPBinTable _pAPBinTable = null;
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestPlexOfCps.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestPlexOfCps.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestPlexOfCps.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestPlexOfCps.java Thu May 21 18:12:22 2009
@@ -1,4 +1,3 @@
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
@@ -15,7 +14,6 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
package org.apache.poi.hwpf.model;
@@ -24,7 +22,7 @@
import org.apache.poi.util.LittleEndian;
-public class TestPlexOfCps
+public final class TestPlexOfCps
extends TestCase
{
private PlexOfCps _plexOfCps = null;
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestSavedByTable.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestSavedByTable.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestSavedByTable.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestSavedByTable.java Thu May 21 18:12:22 2009
@@ -1,4 +1,3 @@
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
@@ -16,7 +15,6 @@
limitations under the License.
==================================================================== */
-
package org.apache.poi.hwpf.model;
import java.io.*;
@@ -32,7 +30,7 @@
*
* @author Daniel Noll
*/
-public class TestSavedByTable
+public final class TestSavedByTable
extends TestCase
{
/** Data dir */
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestSectionTable.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestSectionTable.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestSectionTable.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestSectionTable.java Thu May 21 18:12:22 2009
@@ -1,4 +1,3 @@
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
@@ -15,7 +14,6 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
package org.apache.poi.hwpf.model;
@@ -27,7 +25,7 @@
import org.apache.poi.hwpf.*;
import org.apache.poi.hwpf.model.io.*;
-public class TestSectionTable
+public final class TestSectionTable
extends TestCase
{
private HWPFDocFixture _hWPFDocFixture;
@@ -46,7 +44,7 @@
int fcMin = fib.getFcMin();
CPSplitCalculator cps = new CPSplitCalculator(fib);
-
+
ComplexFileTable cft = new ComplexFileTable(mainStream, tableStream, fib.getFcClx(), fcMin);
TextPieceTable tpt = cft.getTextPieceTable();
@@ -64,7 +62,7 @@
byte[] newMainStream = mainOut.toByteArray();
SectionTable newSectionTable = new SectionTable(
- newMainStream, newTableStream, 0,
+ newMainStream, newTableStream, 0,
newTableStream.length, 0, tpt, cps);
ArrayList oldSections = sectionTable.getSections();
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestStyleSheet.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestStyleSheet.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestStyleSheet.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestStyleSheet.java Thu May 21 18:12:22 2009
@@ -1,4 +1,3 @@
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
@@ -15,7 +14,6 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
package org.apache.poi.hwpf.model;
@@ -24,7 +22,7 @@
import org.apache.poi.hwpf.*;
import org.apache.poi.hwpf.model.io.*;
-public class TestStyleSheet
+public final class TestStyleSheet
extends TestCase
{
private StyleSheet _styleSheet = null;
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestTextPieceTable.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestTextPieceTable.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestTextPieceTable.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestTextPieceTable.java Thu May 21 18:12:22 2009
@@ -1,4 +1,3 @@
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
@@ -15,7 +14,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
package org.apache.poi.hwpf.model;
import java.io.ByteArrayInputStream;
@@ -30,7 +29,7 @@
import org.apache.poi.hwpf.model.io.HWPFFileSystem;
-public class TestTextPieceTable extends TestCase {
+public final class TestTextPieceTable extends TestCase {
private HWPFDocFixture _hWPFDocFixture;
private String dirname;
@@ -76,25 +75,25 @@
new FileInputStream(new File(dirname, "ThreeColHeadFoot.doc"))
);
TextPieceTable tbl = doc.getTextTable();
-
+
// All ascii, so stored in one big lump
assertEquals(1, tbl.getTextPieces().size());
TextPiece tp = (TextPiece)tbl.getTextPieces().get(0);
-
+
assertEquals(0, tp.getStart());
assertEquals(339, tp.getEnd());
assertEquals(339, tp.characterLength());
assertEquals(339, tp.bytesLength());
assertTrue(tp.getStringBuffer().toString().startsWith("This is a sample word document"));
-
+
// Save and re-load
HWPFDocument docB = saveAndReload(doc);
tbl = docB.getTextTable();
-
+
assertEquals(1, tbl.getTextPieces().size());
tp = (TextPiece)tbl.getTextPieces().get(0);
-
+
assertEquals(0, tp.getStart());
assertEquals(339, tp.getEnd());
assertEquals(339, tp.characterLength());
@@ -111,54 +110,54 @@
new FileInputStream(new File(dirname, "HeaderFooterUnicode.doc"))
);
TextPieceTable tbl = doc.getTextTable();
-
+
// In three bits, split every 512 bytes
assertEquals(3, tbl.getTextPieces().size());
TextPiece tpA = (TextPiece)tbl.getTextPieces().get(0);
TextPiece tpB = (TextPiece)tbl.getTextPieces().get(1);
TextPiece tpC = (TextPiece)tbl.getTextPieces().get(2);
-
+
assertTrue(tpA.isUnicode());
assertTrue(tpB.isUnicode());
assertTrue(tpC.isUnicode());
-
+
assertEquals(256, tpA.characterLength());
assertEquals(256, tpB.characterLength());
assertEquals(19, tpC.characterLength());
-
+
assertEquals(512, tpA.bytesLength());
assertEquals(512, tpB.bytesLength());
assertEquals(38, tpC.bytesLength());
-
+
assertEquals(0, tpA.getStart());
assertEquals(256, tpA.getEnd());
assertEquals(256, tpB.getStart());
assertEquals(512, tpB.getEnd());
assertEquals(512, tpC.getStart());
assertEquals(531, tpC.getEnd());
-
-
+
+
// Save and re-load
HWPFDocument docB = saveAndReload(doc);
tbl = docB.getTextTable();
-
+
assertEquals(3, tbl.getTextPieces().size());
tpA = (TextPiece)tbl.getTextPieces().get(0);
tpB = (TextPiece)tbl.getTextPieces().get(1);
tpC = (TextPiece)tbl.getTextPieces().get(2);
-
+
assertTrue(tpA.isUnicode());
assertTrue(tpB.isUnicode());
assertTrue(tpC.isUnicode());
-
+
assertEquals(256, tpA.characterLength());
assertEquals(256, tpB.characterLength());
assertEquals(19, tpC.characterLength());
-
+
assertEquals(512, tpA.bytesLength());
assertEquals(512, tpB.bytesLength());
assertEquals(38, tpC.bytesLength());
-
+
assertEquals(0, tpA.getStart());
assertEquals(256, tpA.getEnd());
assertEquals(256, tpB.getStart());
@@ -170,12 +169,12 @@
protected HWPFDocument saveAndReload(HWPFDocument doc) throws Exception {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
doc.write(baos);
-
+
return new HWPFDocument(
new ByteArrayInputStream(baos.toByteArray())
);
}
-
+
protected void setUp()
throws Exception
{
@@ -183,7 +182,7 @@
_hWPFDocFixture = new HWPFDocFixture(this);
_hWPFDocFixture.setUp();
-
+
dirname = System.getProperty("HWPF.testdata.path");
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org