aboutsummaryrefslogtreecommitdiffstats
path: root/src/ooxml/testcases/org/apache/poi
diff options
context:
space:
mode:
authorJosh Micich <josh@apache.org>2009-08-22 05:50:32 +0000
committerJosh Micich <josh@apache.org>2009-08-22 05:50:32 +0000
commite8b5f3670405426c04e3e2fb12400fceb375c8d2 (patch)
treecf89077ca9ec6fee830a93173cf2abf63a294840 /src/ooxml/testcases/org/apache/poi
parentf8a0d4bb517fb0302f8ac3823e9bd65a303ffea2 (diff)
downloadpoi-e8b5f3670405426c04e3e2fb12400fceb375c8d2.tar.gz
poi-e8b5f3670405426c04e3e2fb12400fceb375c8d2.zip
fixing compiler warnings - unused imports, declared exceptions not thrown
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@806789 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/ooxml/testcases/org/apache/poi')
-rwxr-xr-xsrc/ooxml/testcases/org/apache/poi/TestPOIXMLProperties.java10
-rw-r--r--src/ooxml/testcases/org/apache/poi/xssf/eventusermodel/TestXSSFReader.java5
-rw-r--r--src/ooxml/testcases/org/apache/poi/xssf/model/TestCommentsTable.java31
-rw-r--r--src/ooxml/testcases/org/apache/poi/xssf/model/TestStylesTable.java8
-rw-r--r--src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFHyperlink.java14
-rw-r--r--src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java2
-rw-r--r--src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java2
-rw-r--r--src/ooxml/testcases/org/apache/poi/xwpf/TestXWPFDocument.java14
-rw-r--r--src/ooxml/testcases/org/apache/poi/xwpf/extractor/TestXWPFWordExtractor.java27
-rw-r--r--src/ooxml/testcases/org/apache/poi/xwpf/model/TestXWPFHeaderFooterPolicy.java21
-rw-r--r--src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFHeader.java48
-rw-r--r--src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFParagraph.java3
12 files changed, 84 insertions, 101 deletions
diff --git a/src/ooxml/testcases/org/apache/poi/TestPOIXMLProperties.java b/src/ooxml/testcases/org/apache/poi/TestPOIXMLProperties.java
index 3a3dc27d72..ba9cfe92af 100755
--- a/src/ooxml/testcases/org/apache/poi/TestPOIXMLProperties.java
+++ b/src/ooxml/testcases/org/apache/poi/TestPOIXMLProperties.java
@@ -15,10 +15,8 @@
limitations under the License.
==================================================================== */
-
package org.apache.poi;
-import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Date;
@@ -27,8 +25,8 @@ import junit.framework.TestCase;
import org.apache.poi.POIXMLProperties.CoreProperties;
import org.apache.poi.xssf.XSSFTestDataSamples;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
-import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.apache.poi.xwpf.XWPFTestDataSamples;
+import org.apache.poi.xwpf.usermodel.XWPFDocument;
/**
* Test setting extended and custom OOXML properties
@@ -37,8 +35,8 @@ public final class TestPOIXMLProperties extends TestCase {
private POIXMLProperties _props;
private CoreProperties _coreProperties;
- public void setUp() throws Exception{
- XWPFDocument sampleDoc = XWPFTestDataSamples.openSampleDocument("documentProperties.docx");
+ public void setUp() {
+ XWPFDocument sampleDoc = XWPFTestDataSamples.openSampleDocument("documentProperties.docx");
_props = sampleDoc.getProperties();
_coreProperties = _props.getCoreProperties();
assertNotNull(_props);
@@ -168,7 +166,7 @@ public final class TestPOIXMLProperties extends TestCase {
public void testGetSetRevision() {
String revision = _coreProperties.getRevision();
- assertTrue("Revision number is 1", new Integer(revision)> 1);
+ assertTrue("Revision number is 1", Integer.parseInt(revision) > 1);
_coreProperties.setRevision("20");
assertEquals("20", _coreProperties.getRevision());
_coreProperties.setRevision("20xx");
diff --git a/src/ooxml/testcases/org/apache/poi/xssf/eventusermodel/TestXSSFReader.java b/src/ooxml/testcases/org/apache/poi/xssf/eventusermodel/TestXSSFReader.java
index 7e6281e757..0ace7c3f63 100644
--- a/src/ooxml/testcases/org/apache/poi/xssf/eventusermodel/TestXSSFReader.java
+++ b/src/ooxml/testcases/org/apache/poi/xssf/eventusermodel/TestXSSFReader.java
@@ -17,16 +17,15 @@
package org.apache.poi.xssf.eventusermodel;
-import java.io.File;
import java.io.InputStream;
import java.util.Iterator;
import junit.framework.TestCase;
+import org.apache.poi.openxml4j.opc.OPCPackage;
import org.apache.poi.util.IOUtils;
-import org.apache.poi.xssf.usermodel.XSSFRichTextString;
import org.apache.poi.xssf.XSSFTestDataSamples;
-import org.apache.poi.openxml4j.opc.OPCPackage;
+import org.apache.poi.xssf.usermodel.XSSFRichTextString;
/**
* Tests for {@link XSSFReader}
diff --git a/src/ooxml/testcases/org/apache/poi/xssf/model/TestCommentsTable.java b/src/ooxml/testcases/org/apache/poi/xssf/model/TestCommentsTable.java
index 14dde090e2..6555d65938 100644
--- a/src/ooxml/testcases/org/apache/poi/xssf/model/TestCommentsTable.java
+++ b/src/ooxml/testcases/org/apache/poi/xssf/model/TestCommentsTable.java
@@ -21,21 +21,24 @@ import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.util.List;
+import junit.framework.AssertionFailedError;
+import junit.framework.TestCase;
+
+import org.apache.poi.POIXMLDocumentPart;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Comment;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
+import org.apache.poi.xssf.XSSFTestDataSamples;
import org.apache.poi.xssf.usermodel.XSSFComment;
import org.apache.poi.xssf.usermodel.XSSFRichTextString;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
-import org.apache.poi.xssf.XSSFTestDataSamples;
-import org.apache.poi.POIXMLDocumentPart;
-import org.apache.poi.openxml4j.opc.OPCPackage;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.*;
-
-import junit.framework.AssertionFailedError;
-import junit.framework.TestCase;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTComment;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCommentList;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTComments;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTRst;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CommentsDocument;
public class TestCommentsTable extends TestCase {
@@ -118,7 +121,7 @@ public class TestCommentsTable extends TestCase {
assertEquals("Another Author", comment.getAuthor());
}
- public void testDontLoostNewLines() throws Exception {
+ public void testDontLoostNewLines() {
XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("WithVariousData.xlsx");
List<POIXMLDocumentPart> rels = wb.getSheetAt(0).getRelations();
CommentsTable ct = null;
@@ -162,8 +165,8 @@ public class TestCommentsTable extends TestCase {
assertEquals("Nick Burch:\nThis is a comment", comment.getString().getString());
}
- public void testExisting() throws Exception {
- XSSFWorkbook workbook = XSSFTestDataSamples.openSampleWorkbook("WithVariousData.xlsx");
+ public void testExisting() {
+ XSSFWorkbook workbook = XSSFTestDataSamples.openSampleWorkbook("WithVariousData.xlsx");
Sheet sheet1 = workbook.getSheetAt(0);
Sheet sheet2 = workbook.getSheetAt(1);
@@ -192,8 +195,8 @@ public class TestCommentsTable extends TestCase {
assertEquals(2, cc7.getColumn());
}
- public void testWriteRead() throws Exception {
- XSSFWorkbook workbook = XSSFTestDataSamples.openSampleWorkbook("WithVariousData.xlsx");
+ public void testWriteRead() {
+ XSSFWorkbook workbook = XSSFTestDataSamples.openSampleWorkbook("WithVariousData.xlsx");
XSSFSheet sheet1 = workbook.getSheetAt(0);
XSSFSheet sheet2 = workbook.getSheetAt(1);
@@ -239,8 +242,8 @@ public class TestCommentsTable extends TestCase {
sheet1.getRow(4).getCell(2).getCellComment().getString().getString());
}
- public void testReadWriteMultipleAuthors() throws Exception {
- XSSFWorkbook workbook = XSSFTestDataSamples.openSampleWorkbook("WithMoreVariousData.xlsx");
+ public void testReadWriteMultipleAuthors() {
+ XSSFWorkbook workbook = XSSFTestDataSamples.openSampleWorkbook("WithMoreVariousData.xlsx");
XSSFSheet sheet1 = workbook.getSheetAt(0);
XSSFSheet sheet2 = workbook.getSheetAt(1);
diff --git a/src/ooxml/testcases/org/apache/poi/xssf/model/TestStylesTable.java b/src/ooxml/testcases/org/apache/poi/xssf/model/TestStylesTable.java
index 7adfdd0f5c..73ec1d005f 100644
--- a/src/ooxml/testcases/org/apache/poi/xssf/model/TestStylesTable.java
+++ b/src/ooxml/testcases/org/apache/poi/xssf/model/TestStylesTable.java
@@ -53,7 +53,7 @@ public final class TestStylesTable extends TestCase {
assertEquals(0, st._getNumberFormatSize());
}
- public void testLoadExisting() throws Exception {
+ public void testLoadExisting() {
XSSFWorkbook workbook = XSSFTestDataSamples.openSampleWorkbook(testFile);
assertNotNull(workbook.getStylesSource());
@@ -61,7 +61,7 @@ public final class TestStylesTable extends TestCase {
doTestExisting(st);
}
- public void testLoadSaveLoad() throws Exception {
+ public void testLoadSaveLoad() {
XSSFWorkbook workbook = XSSFTestDataSamples.openSampleWorkbook(testFile);
assertNotNull(workbook.getStylesSource());
@@ -125,7 +125,7 @@ public final class TestStylesTable extends TestCase {
assertEquals(nf2, st.putNumberFormat("yyyy-mm-DD"));
}
- public void testPopulateExisting() throws Exception {
+ public void testPopulateExisting() {
XSSFWorkbook workbook = XSSFTestDataSamples.openSampleWorkbook(testFile);
assertNotNull(workbook.getStylesSource());
@@ -138,7 +138,7 @@ public final class TestStylesTable extends TestCase {
int nf2 = st.putNumberFormat("YYYY-mm-DD");
assertEquals(nf1, st.putNumberFormat("YYYY-mm-dd"));
- st = XSSFTestDataSamples.writeOutAndReadBack(workbook).getStylesSource();
+ st = XSSFTestDataSamples.writeOutAndReadBack(workbook).getStylesSource();
assertEquals(11, st._getXfsSize());
assertEquals(1, st._getStyleXfsSize());
diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFHyperlink.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFHyperlink.java
index e6d6e97952..7c0d01b3a3 100644
--- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFHyperlink.java
+++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFHyperlink.java
@@ -17,11 +17,13 @@
package org.apache.poi.xssf.usermodel;
-import java.io.File;
-
-import org.apache.poi.ss.usermodel.*;
-import org.apache.poi.xssf.XSSFTestDataSamples;
+import org.apache.poi.ss.usermodel.BaseTestHyperlink;
+import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.CreationHelper;
+import org.apache.poi.ss.usermodel.Hyperlink;
+import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.xssf.XSSFITestDataProvider;
+import org.apache.poi.xssf.XSSFTestDataSamples;
public final class TestXSSFHyperlink extends BaseTestHyperlink {
@Override
@@ -38,7 +40,7 @@ public final class TestXSSFHyperlink extends BaseTestHyperlink {
);
}
- public void testLoadExisting() throws Exception {
+ public void testLoadExisting() {
XSSFWorkbook workbook = XSSFTestDataSamples.openSampleWorkbook("WithMoreVariousData.xlsx");
assertEquals(3, workbook.getNumberOfSheets());
@@ -49,7 +51,7 @@ public final class TestXSSFHyperlink extends BaseTestHyperlink {
doTestHyperlinkContents(sheet);
}
- public void testLoadSave() throws Exception {
+ public void testLoadSave() {
XSSFWorkbook workbook = XSSFTestDataSamples.openSampleWorkbook("WithMoreVariousData.xlsx");
CreationHelper createHelper = workbook.getCreationHelper();
assertEquals(3, workbook.getNumberOfSheets());
diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java
index fa3d42d387..7bcf9c1cb4 100644
--- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java
+++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java
@@ -51,7 +51,7 @@ public class TestXSSFSheet extends BaseTestSheet {
baseTestGetSetMargin(new double[]{0.7, 0.7, 0.75, 0.75, 0.3, 0.3});
}
- public void testExistingHeaderFooter() throws Exception {
+ public void testExistingHeaderFooter() {
XSSFWorkbook workbook = XSSFTestDataSamples.openSampleWorkbook("45540_classic_Header.xlsx");
XSSFOddHeader hdr;
XSSFOddFooter ftr;
diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java
index 3014bcf904..9db76c04f9 100644
--- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java
+++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java
@@ -168,8 +168,6 @@ public final class TestXSSFWorkbook extends BaseTestWorkbook {
short i = workbook.getNumCellStyles();
//get default cellStyles
assertEquals(1, i);
- //get wrong value
- assertNotSame(2, i);
}
public void testLoadSave() {
diff --git a/src/ooxml/testcases/org/apache/poi/xwpf/TestXWPFDocument.java b/src/ooxml/testcases/org/apache/poi/xwpf/TestXWPFDocument.java
index f55e7f5081..d25d22a483 100644
--- a/src/ooxml/testcases/org/apache/poi/xwpf/TestXWPFDocument.java
+++ b/src/ooxml/testcases/org/apache/poi/xwpf/TestXWPFDocument.java
@@ -17,11 +17,8 @@
package org.apache.poi.xwpf;
-import java.io.File;
-
import junit.framework.TestCase;
-import org.apache.poi.POIXMLDocument;
import org.apache.poi.POIXMLProperties;
import org.apache.poi.openxml4j.opc.OPCPackage;
import org.apache.poi.openxml4j.opc.PackagePart;
@@ -32,7 +29,7 @@ public final class TestXWPFDocument extends TestCase {
public void testContainsMainContentType() throws Exception {
XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("sample.docx");
- OPCPackage pack = doc.getPackage();
+ OPCPackage pack = doc.getPackage();
boolean found = false;
for(PackagePart part : pack.getParts()) {
@@ -55,14 +52,14 @@ public final class TestXWPFDocument extends TestCase {
assertNotNull(xml.getStyle());
// Complex file
- xml = XWPFTestDataSamples.openSampleDocument("IllustrativeCases.docx");
+ xml = XWPFTestDataSamples.openSampleDocument("IllustrativeCases.docx");
assertNotNull(xml.getDocument());
assertNotNull(xml.getDocument().getBody());
assertNotNull(xml.getStyle());
}
- public void testMetadataBasics() throws Exception {
- XWPFDocument xml = XWPFTestDataSamples.openSampleDocument("sample.docx");
+ public void testMetadataBasics() {
+ XWPFDocument xml = XWPFTestDataSamples.openSampleDocument("sample.docx");
assertNotNull(xml.getProperties().getCoreProperties());
assertNotNull(xml.getProperties().getExtendedProperties());
@@ -74,7 +71,7 @@ public final class TestXWPFDocument extends TestCase {
assertEquals(null, xml.getProperties().getCoreProperties().getUnderlyingProperties().getSubjectProperty().getValue());
}
- public void testMetadataComplex() throws Exception {
+ public void testMetadataComplex() {
XWPFDocument xml = XWPFTestDataSamples.openSampleDocument("IllustrativeCases.docx");
assertNotNull(xml.getProperties().getCoreProperties());
assertNotNull(xml.getProperties().getExtendedProperties());
@@ -93,5 +90,4 @@ public final class TestXWPFDocument extends TestCase {
assertNotNull(props);
assertEquals("Apache POI", props.getExtendedProperties().getUnderlyingProperties().getApplication());
}
-
}
diff --git a/src/ooxml/testcases/org/apache/poi/xwpf/extractor/TestXWPFWordExtractor.java b/src/ooxml/testcases/org/apache/poi/xwpf/extractor/TestXWPFWordExtractor.java
index cffdaec9ab..29b2a1643b 100644
--- a/src/ooxml/testcases/org/apache/poi/xwpf/extractor/TestXWPFWordExtractor.java
+++ b/src/ooxml/testcases/org/apache/poi/xwpf/extractor/TestXWPFWordExtractor.java
@@ -14,16 +14,13 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
+
package org.apache.poi.xwpf.extractor;
-import java.io.File;
-import java.io.IOException;
+import junit.framework.TestCase;
-import org.apache.poi.POIXMLDocument;
-import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.apache.poi.xwpf.XWPFTestDataSamples;
-
-import junit.framework.TestCase;
+import org.apache.poi.xwpf.usermodel.XWPFDocument;
/**
* Tests for HXFWordExtractor
@@ -33,7 +30,7 @@ public class TestXWPFWordExtractor extends TestCase {
/**
* Get text out of the simple file
*/
- public void testGetSimpleText() throws Exception {
+ public void testGetSimpleText() {
XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("sample.docx");
XWPFWordExtractor extractor = new XWPFWordExtractor(doc);
@@ -62,7 +59,7 @@ public class TestXWPFWordExtractor extends TestCase {
/**
* Tests getting the text out of a complex file
*/
- public void testGetComplexText() throws Exception {
+ public void testGetComplexText() {
XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("IllustrativeCases.docx");
XWPFWordExtractor extractor = new XWPFWordExtractor(doc);
@@ -94,7 +91,7 @@ public class TestXWPFWordExtractor extends TestCase {
assertEquals(103, ps);
}
- public void testGetWithHyperlinks() throws Exception {
+ public void testGetWithHyperlinks() {
XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("TestDocument.docx");
XWPFWordExtractor extractor = new XWPFWordExtractor(doc);
@@ -119,7 +116,7 @@ public class TestXWPFWordExtractor extends TestCase {
);
}
- public void testHeadersFooters() throws Exception {
+ public void testHeadersFooters() {
XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("ThreeColHeadFoot.docx");
XWPFWordExtractor extractor = new XWPFWordExtractor(doc);
@@ -162,7 +159,7 @@ public class TestXWPFWordExtractor extends TestCase {
);
}
- public void testFootnotes() throws Exception {
+ public void testFootnotes() {
XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("footnotes.docx");
XWPFWordExtractor extractor = new XWPFWordExtractor(doc);
@@ -170,14 +167,14 @@ public class TestXWPFWordExtractor extends TestCase {
}
- public void testTableFootnotes() throws Exception {
+ public void testTableFootnotes() {
XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("table_footnotes.docx");
XWPFWordExtractor extractor = new XWPFWordExtractor(doc);
assertTrue(extractor.getText().contains("snoska"));
}
- public void testFormFootnotes() throws Exception {
+ public void testFormFootnotes() {
XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("form_footnotes.docx");
XWPFWordExtractor extractor = new XWPFWordExtractor(doc);
@@ -186,14 +183,14 @@ public class TestXWPFWordExtractor extends TestCase {
assertTrue("Unable to find expected word in text\n" + text, text.contains("test phrase"));
}
- public void testEndnotes() throws Exception {
+ public void testEndnotes() {
XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("endnotes.docx");
XWPFWordExtractor extractor = new XWPFWordExtractor(doc);
assertTrue(extractor.getText().contains("XXX"));
}
- public void testInsertedDeletedText() throws Exception {
+ public void testInsertedDeletedText() {
XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("delins.docx");
XWPFWordExtractor extractor = new XWPFWordExtractor(doc);
diff --git a/src/ooxml/testcases/org/apache/poi/xwpf/model/TestXWPFHeaderFooterPolicy.java b/src/ooxml/testcases/org/apache/poi/xwpf/model/TestXWPFHeaderFooterPolicy.java
index 13c04b0193..d30503b0a8 100644
--- a/src/ooxml/testcases/org/apache/poi/xwpf/model/TestXWPFHeaderFooterPolicy.java
+++ b/src/ooxml/testcases/org/apache/poi/xwpf/model/TestXWPFHeaderFooterPolicy.java
@@ -14,15 +14,13 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
+
package org.apache.poi.xwpf.model;
-import java.io.File;
+import junit.framework.TestCase;
-import org.apache.poi.POIXMLDocument;
-import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.apache.poi.xwpf.XWPFTestDataSamples;
-
-import junit.framework.TestCase;
+import org.apache.poi.xwpf.usermodel.XWPFDocument;
/**
* Tests for XWPF Header Footer Stuff
@@ -35,15 +33,14 @@ public class TestXWPFHeaderFooterPolicy extends TestCase {
private XWPFDocument oddEven;
private XWPFDocument diffFirst;
- protected void setUp() throws Exception {
- super.setUp();
+ protected void setUp() {
noHeader = XWPFTestDataSamples.openSampleDocument("NoHeadFoot.docx");
- header = XWPFTestDataSamples.openSampleDocument("ThreeColHead.docx");
- headerFooter = XWPFTestDataSamples.openSampleDocument("SimpleHeadThreeColFoot.docx");
- footer = XWPFTestDataSamples.openSampleDocument("FancyFoot.docx");
- oddEven = XWPFTestDataSamples.openSampleDocument("PageSpecificHeadFoot.docx");
- diffFirst = XWPFTestDataSamples.openSampleDocument("DiffFirstPageHeadFoot.docx");
+ header = XWPFTestDataSamples.openSampleDocument("ThreeColHead.docx");
+ headerFooter = XWPFTestDataSamples.openSampleDocument("SimpleHeadThreeColFoot.docx");
+ footer = XWPFTestDataSamples.openSampleDocument("FancyFoot.docx");
+ oddEven = XWPFTestDataSamples.openSampleDocument("PageSpecificHeadFoot.docx");
+ diffFirst = XWPFTestDataSamples.openSampleDocument("DiffFirstPageHeadFoot.docx");
}
public void testPolicy() {
diff --git a/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFHeader.java b/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFHeader.java
index 478f622b2d..edd72ce295 100644
--- a/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFHeader.java
+++ b/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFHeader.java
@@ -14,42 +14,37 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
+
package org.apache.poi.xwpf.usermodel;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
import java.io.IOException;
-import java.io.OutputStream;
import junit.framework.TestCase;
-import org.apache.poi.POIXMLDocument;
-import org.apache.poi.xwpf.model.XWPFHeaderFooterPolicy;
import org.apache.poi.xwpf.XWPFTestDataSamples;
-import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTHdrFtr;
+import org.apache.poi.xwpf.model.XWPFHeaderFooterPolicy;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTP;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTR;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTText;
-public class TestXWPFHeader extends TestCase {
-
- public void testSimpleHeader() throws IOException {
+public final class TestXWPFHeader extends TestCase {
+
+ public void testSimpleHeader() {
XWPFDocument sampleDoc = XWPFTestDataSamples.openSampleDocument("headerFooter.docx");
XWPFHeaderFooterPolicy policy = sampleDoc.getHeaderFooterPolicy();
-
-
+
+
XWPFHeader header = policy.getDefaultHeader();
XWPFFooter footer = policy.getDefaultFooter();
assertNotNull(header);
assertNotNull(footer);
-
+
// TODO verify if the following is correct
assertNull(header.toString());
-
+
}
-
+
public void testSetHeader() throws IOException {
XWPFDocument sampleDoc = XWPFTestDataSamples.openSampleDocument("SampleDoc.docx");
// no header is set (yet)
@@ -57,17 +52,17 @@ public class TestXWPFHeader extends TestCase {
assertNull(policy.getDefaultHeader());
assertNull(policy.getFirstPageHeader());
assertNull(policy.getDefaultFooter());
-
+
CTP ctP1 = CTP.Factory.newInstance();
CTR ctR1 = ctP1.addNewR();
CTText t = ctR1.addNewT();
- t.set("Paragraph in header");
-
+ t.setStringValue("Paragraph in header");
+
CTP ctP2 = CTP.Factory.newInstance();
CTR ctR2 = ctP2.addNewR();
CTText t2 = ctR2.addNewT();
- t2.set("Second paragraph.. for footer");
-
+ t2.setStringValue("Second paragraph.. for footer");
+
XWPFParagraph p1 = new XWPFParagraph(ctP1);
XWPFParagraph[] pars = new XWPFParagraph[1];
pars[0] = p1;
@@ -75,30 +70,29 @@ public class TestXWPFHeader extends TestCase {
XWPFParagraph p2 = new XWPFParagraph(ctP2);
XWPFParagraph[] pars2 = new XWPFParagraph[1];
pars2[0] = p2;
-
+
// set a default header and test it is not null
policy.createHeader(policy.DEFAULT, pars);
policy.createHeader(policy.FIRST);
policy.createFooter(policy.DEFAULT, pars2);
-
+
assertNotNull(policy.getDefaultHeader());
assertNotNull(policy.getFirstPageHeader());
assertNotNull(policy.getDefaultFooter());
}
-
- public void testSetWatermark() throws IOException {
+
+ public void testSetWatermark() {
XWPFDocument sampleDoc = XWPFTestDataSamples.openSampleDocument("SampleDoc.docx");
// no header is set (yet)
XWPFHeaderFooterPolicy policy = sampleDoc.getHeaderFooterPolicy();
assertNull(policy.getDefaultHeader());
assertNull(policy.getFirstPageHeader());
assertNull(policy.getDefaultFooter());
-
+
policy.createWatermark("DRAFT");
-
+
assertNotNull(policy.getDefaultHeader());
assertNotNull(policy.getFirstPageHeader());
assertNotNull(policy.getEvenPageHeader());
}
-
}
diff --git a/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFParagraph.java b/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFParagraph.java
index 12405fb4a7..3c826ba255 100644
--- a/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFParagraph.java
+++ b/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFParagraph.java
@@ -14,14 +14,13 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
+
package org.apache.poi.xwpf.usermodel;
-import java.io.File;
import java.math.BigInteger;
import junit.framework.TestCase;
-import org.apache.poi.POIXMLDocument;
import org.apache.poi.xwpf.XWPFTestDataSamples;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTBorder;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTInd;