Fixed compiler warnings - unnecessary throws declaration

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@805552 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Josh Micich 2009-08-18 19:49:28 +00:00
parent c304173145
commit 9926c89006
122 changed files with 1723 additions and 1963 deletions

View File

@ -14,9 +14,9 @@
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
==================================================================== */ ==================================================================== */
package org.apache.poi.hpsf.extractor; package org.apache.poi.hpsf.extractor;
import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
import java.util.Iterator; import java.util.Iterator;
@ -123,7 +123,7 @@ public class HPSFPropertiesExtractor extends POITextExtractor {
} }
/** /**
* Return the text of all the properties defined in * @return the text of all the properties defined in
* the document. * the document.
*/ */
public String getText() { public String getText() {
@ -141,12 +141,12 @@ public class HPSFPropertiesExtractor extends POITextExtractor {
* So we can get at the properties of any * So we can get at the properties of any
* random OLE2 document. * random OLE2 document.
*/ */
private static class PropertiesOnlyDocument extends POIDocument { private static final class PropertiesOnlyDocument extends POIDocument {
private PropertiesOnlyDocument(POIFSFileSystem fs) { public PropertiesOnlyDocument(POIFSFileSystem fs) {
super(fs); super(fs);
} }
public void write(OutputStream out) throws IOException { public void write(OutputStream out) {
throw new IllegalStateException("Unable to write, only for properties!"); throw new IllegalStateException("Unable to write, only for properties!");
} }
} }

View File

@ -1,4 +1,3 @@
/* ==================================================================== /* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with contributor license agreements. See the NOTICE file distributed with
@ -16,7 +15,6 @@
limitations under the License. limitations under the License.
==================================================================== */ ==================================================================== */
package org.apache.poi.poifs.filesystem; package org.apache.poi.poifs.filesystem;
import java.io.*; import java.io.*;
@ -30,12 +28,10 @@ import java.util.*;
* @author Marc Johnson (mjohnson at apache dot org) * @author Marc Johnson (mjohnson at apache dot org)
*/ */
public class DocumentOutputStream public final class DocumentOutputStream extends OutputStream {
extends OutputStream private final OutputStream _stream;
{ private final int _limit;
private OutputStream stream; private int _written;
private int limit;
private int written;
/** /**
* Create a DocumentOutputStream * Create a DocumentOutputStream
@ -44,12 +40,10 @@ public class DocumentOutputStream
* read * read
* @param limit the maximum number of bytes that can be written * @param limit the maximum number of bytes that can be written
*/ */
DocumentOutputStream(OutputStream stream, int limit) {
DocumentOutputStream(final OutputStream stream, final int limit) _stream = stream;
{ _limit = limit;
this.stream = stream; _written = 0;
this.limit = limit;
this.written = 0;
} }
/** /**
@ -64,12 +58,11 @@ public class DocumentOutputStream
* output stream has been closed, or if the * output stream has been closed, or if the
* writer tries to write too much data. * writer tries to write too much data.
*/ */
public void write(int b)
public void write(final int b)
throws IOException throws IOException
{ {
limitCheck(1); limitCheck(1);
stream.write(b); _stream.write(b);
} }
/** /**
@ -79,8 +72,7 @@ public class DocumentOutputStream
* @param b the data. * @param b the data.
* @exception IOException if an I/O error occurs. * @exception IOException if an I/O error occurs.
*/ */
public void write(byte b[])
public void write(final byte b[])
throws IOException throws IOException
{ {
write(b, 0, b.length); write(b, 0, b.length);
@ -106,12 +98,11 @@ public class DocumentOutputStream
* output stream is closed or if the writer * output stream is closed or if the writer
* tries to write too many bytes. * tries to write too many bytes.
*/ */
public void write(byte b[], int off, int len)
public void write(final byte b[], final int off, final int len)
throws IOException throws IOException
{ {
limitCheck(len); limitCheck(len);
stream.write(b, off, len); _stream.write(b, off, len);
} }
/** /**
@ -120,11 +111,10 @@ public class DocumentOutputStream
* *
* @exception IOException if an I/O error occurs. * @exception IOException if an I/O error occurs.
*/ */
public void flush() public void flush()
throws IOException throws IOException
{ {
stream.flush(); _stream.flush();
} }
/** /**
@ -135,10 +125,7 @@ public class DocumentOutputStream
* *
* @exception IOException if an I/O error occurs. * @exception IOException if an I/O error occurs.
*/ */
public void close() {
public void close()
throws IOException
{
// ignore this call // ignore this call
} }
@ -152,27 +139,25 @@ public class DocumentOutputStream
* *
* @exception IOException on I/O error * @exception IOException on I/O error
*/ */
void writeFiller(int totalLimit, byte fill)
void writeFiller(final int totalLimit, final byte fill)
throws IOException throws IOException
{ {
if (totalLimit > written) if (totalLimit > _written)
{ {
byte[] filler = new byte[ totalLimit - written ]; byte[] filler = new byte[ totalLimit - _written ];
Arrays.fill(filler, fill); Arrays.fill(filler, fill);
stream.write(filler); _stream.write(filler);
} }
} }
private void limitCheck(final int toBeWritten) private void limitCheck(int toBeWritten)
throws IOException throws IOException
{ {
if ((written + toBeWritten) > limit) if ((_written + toBeWritten) > _limit)
{ {
throw new IOException("tried to write too much data"); throw new IOException("tried to write too much data");
} }
written += toBeWritten; _written += toBeWritten;
}
} }
} // end public class DocumentOutputStream

View File

@ -64,9 +64,8 @@ public final class SmallDocumentBlock implements BlockWritable, ListManagedBlock
* @return an array of SmallDocumentBlock instances, filled from * @return an array of SmallDocumentBlock instances, filled from
* the array * the array
*/ */
public static SmallDocumentBlock [] convert(byte [] array,
public static SmallDocumentBlock [] convert(final byte [] array, int size)
final int size)
{ {
SmallDocumentBlock[] rval = SmallDocumentBlock[] rval =
new SmallDocumentBlock[ (size + _block_size - 1) / _block_size ]; new SmallDocumentBlock[ (size + _block_size - 1) / _block_size ];
@ -103,8 +102,7 @@ public final class SmallDocumentBlock implements BlockWritable, ListManagedBlock
* *
* @return number of big blocks the list encompasses * @return number of big blocks the list encompasses
*/ */
public static int fill(List blocks)
public static int fill(final List blocks)
{ {
int count = blocks.size(); int count = blocks.size();
int big_block_count = (count + _blocks_per_big_block - 1) int big_block_count = (count + _blocks_per_big_block - 1)
@ -130,9 +128,8 @@ public final class SmallDocumentBlock implements BlockWritable, ListManagedBlock
* @exception ArrayIndexOutOfBoundsException if, somehow, the store * @exception ArrayIndexOutOfBoundsException if, somehow, the store
* contains less data than size indicates * contains less data than size indicates
*/ */
public static SmallDocumentBlock [] convert(BlockWritable [] store,
public static SmallDocumentBlock [] convert(final BlockWritable [] store, int size)
final int size)
throws IOException, ArrayIndexOutOfBoundsException throws IOException, ArrayIndexOutOfBoundsException
{ {
ByteArrayOutputStream stream = new ByteArrayOutputStream(); ByteArrayOutputStream stream = new ByteArrayOutputStream();
@ -159,10 +156,7 @@ public final class SmallDocumentBlock implements BlockWritable, ListManagedBlock
* data * data
* *
* @return a List of SmallDocumentBlock's extracted from the input * @return a List of SmallDocumentBlock's extracted from the input
*
* @exception IOException
*/ */
public static List extract(ListManagedBlock [] blocks) public static List extract(ListManagedBlock [] blocks)
throws IOException throws IOException
{ {
@ -193,7 +187,6 @@ public final class SmallDocumentBlock implements BlockWritable, ListManagedBlock
* *
* @return total size * @return total size
*/ */
public static int calcSize(int size) public static int calcSize(int size)
{ {
return size * _block_size; return size * _block_size;
@ -207,13 +200,11 @@ public final class SmallDocumentBlock implements BlockWritable, ListManagedBlock
return block; return block;
} }
private static int convertToBlockCount(final int size) private static int convertToBlockCount(int size)
{ {
return (size + _block_size - 1) / _block_size; return (size + _block_size - 1) / _block_size;
} }
/* ********** START implementation of BlockWritable ********** */
/** /**
* Write the storage to an OutputStream * Write the storage to an OutputStream
* *
@ -223,16 +214,12 @@ public final class SmallDocumentBlock implements BlockWritable, ListManagedBlock
* @exception IOException on problems writing to the specified * @exception IOException on problems writing to the specified
* stream * stream
*/ */
public void writeBlocks(OutputStream stream)
public void writeBlocks(final OutputStream stream)
throws IOException throws IOException
{ {
stream.write(_data); stream.write(_data);
} }
/* ********** END implementation of BlockWritable ********** */
/* ********** START implementation of ListManagedBlock ********** */
/** /**
* Get the data from the block * Get the data from the block
* *
@ -240,13 +227,7 @@ public final class SmallDocumentBlock implements BlockWritable, ListManagedBlock
* *
* @exception IOException if there is no data * @exception IOException if there is no data
*/ */
public byte [] getData() {
public byte [] getData()
throws IOException
{
return _data; return _data;
} }
}
/* ********** END implementation of ListManagedBlock ********** */
} // end public class SmallDocumentBlock

View File

@ -14,10 +14,10 @@
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
==================================================================== */ ==================================================================== */
package org.apache.poi.util; package org.apache.poi.util;
import java.io.File; import java.io.File;
import java.io.IOException;
import java.util.Random; import java.util.Random;
/** /**
@ -25,20 +25,18 @@ import java.util.Random;
* *
* @author Glen Stampoultzis * @author Glen Stampoultzis
*/ */
public class TempFile public final class TempFile {
{ private static File dir;
static File dir; private static final Random rnd = new Random();
static Random rnd = new Random();
/** /**
* Creates a temporary file. Files are collected into one directory and by default are * Creates a temporary file. Files are collected into one directory and by default are
* deleted on exit from the VM. Files can be kept by defining the system property * deleted on exit from the VM. Files can be kept by defining the system property
* <code>poi.keep.tmp.files</code>. * <code>poi.keep.tmp.files</code>.
* <p> * <p>
* Dont forget to close all files or it might not be possible to delete them. * Don't forget to close all files or it might not be possible to delete them.
*/ */
public static File createTempFile(String prefix, String suffix) throws IOException public static File createTempFile(String prefix, String suffix) {
{
if (dir == null) if (dir == null)
{ {
dir = new File(System.getProperty("java.io.tmpdir"), "poifiles"); dir = new File(System.getProperty("java.io.tmpdir"), "poifiles");
@ -52,7 +50,4 @@ public class TempFile
newFile.deleteOnExit(); newFile.deleteOnExit();
return newFile; return newFile;
} }
} }

View File

@ -94,7 +94,7 @@ public final class ZipPackage extends Package {
* @throws InvalidFormatException * @throws InvalidFormatException
* If the content type part parsing encounters an error. * If the content type part parsing encounters an error.
*/ */
ZipPackage(String path, PackageAccess access) throws InvalidFormatException { ZipPackage(String path, PackageAccess access) {
super(access); super(access);
ZipFile zipFile = ZipHelper.openZipFile(path); ZipFile zipFile = ZipHelper.openZipFile(path);

View File

@ -25,22 +25,21 @@ import java.io.OutputStream;
* Build an output stream for MemoryPackagePart. * Build an output stream for MemoryPackagePart.
* *
* @author Julien Chable * @author Julien Chable
* @version 1.0
*/ */
public final class MemoryPackagePartOutputStream extends OutputStream { public final class MemoryPackagePartOutputStream extends OutputStream {
private MemoryPackagePart part; private MemoryPackagePart _part;
private ByteArrayOutputStream buff; private ByteArrayOutputStream _buff;
public MemoryPackagePartOutputStream(MemoryPackagePart part) { public MemoryPackagePartOutputStream(MemoryPackagePart part) {
this.part = part; this._part = part;
buff = new ByteArrayOutputStream(); _buff = new ByteArrayOutputStream();
} }
@Override @Override
public void write(int b) throws IOException { public void write(int b) {
buff.write(b); _buff.write(b);
} }
/** /**
@ -59,38 +58,38 @@ public final class MemoryPackagePartOutputStream extends OutputStream {
*/ */
@Override @Override
public void flush() throws IOException { public void flush() throws IOException {
buff.flush(); _buff.flush();
if (part.data != null) { if (_part.data != null) {
byte[] newArray = new byte[part.data.length + buff.size()]; byte[] newArray = new byte[_part.data.length + _buff.size()];
// copy the previous contents of part.data in newArray // copy the previous contents of part.data in newArray
System.arraycopy(part.data, 0, newArray, 0, part.data.length); System.arraycopy(_part.data, 0, newArray, 0, _part.data.length);
// append the newly added data // append the newly added data
byte[] buffArr = buff.toByteArray(); byte[] buffArr = _buff.toByteArray();
System.arraycopy(buffArr, 0, newArray, part.data.length, System.arraycopy(buffArr, 0, newArray, _part.data.length,
buffArr.length); buffArr.length);
// save the result as new data // save the result as new data
part.data = newArray; _part.data = newArray;
} else { } else {
// was empty, just fill it // was empty, just fill it
part.data = buff.toByteArray(); _part.data = _buff.toByteArray();
} }
/* /*
* Clear this streams buffer, in case flush() is called a second time * Clear this streams buffer, in case flush() is called a second time
* Fix bug 1921637 - provided by Rainer Schwarze * Fix bug 1921637 - provided by Rainer Schwarze
*/ */
buff.reset(); _buff.reset();
} }
@Override @Override
public void write(byte[] b, int off, int len) throws IOException { public void write(byte[] b, int off, int len) {
buff.write(b, off, len); _buff.write(b, off, len);
} }
@Override @Override
public void write(byte[] b) throws IOException { public void write(byte[] b) throws IOException {
buff.write(b); _buff.write(b);
} }
} }

View File

@ -25,7 +25,6 @@ import java.util.Date;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException; import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.openxml4j.exceptions.InvalidOperationException; import org.apache.poi.openxml4j.exceptions.InvalidOperationException;
import org.apache.poi.openxml4j.exceptions.OpenXML4JException;
import org.apache.poi.openxml4j.opc.ContentTypes; import org.apache.poi.openxml4j.opc.ContentTypes;
import org.apache.poi.openxml4j.opc.OPCPackage; import org.apache.poi.openxml4j.opc.OPCPackage;
import org.apache.poi.openxml4j.opc.PackagePart; import org.apache.poi.openxml4j.opc.PackagePart;

View File

@ -97,7 +97,7 @@ public final class PackageHelper {
/** /**
* Creates an empty file in the default temporary-file directory, * Creates an empty file in the default temporary-file directory,
*/ */
public static File createTempFile() throws IOException { public static File createTempFile() {
File file = TempFile.createTempFile("poi-ooxml-", ".tmp"); File file = TempFile.createTempFile("poi-ooxml-", ".tmp");
//there is no way to pass an existing file to Package.create(file), //there is no way to pass an existing file to Package.create(file),
//delete first, the file will be re-created in Packe.create(file) //delete first, the file will be re-created in Packe.create(file)

View File

@ -1,4 +1,3 @@
/* ==================================================================== /* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with contributor license agreements. See the NOTICE file distributed with
@ -16,32 +15,29 @@
limitations under the License. limitations under the License.
==================================================================== */ ==================================================================== */
package org.apache.poi; package org.apache.poi;
import java.io.File; import java.io.File;
import java.io.IOException;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.util.List; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import junit.framework.TestCase;
import org.apache.poi.util.TempFile;
import org.apache.poi.openxml4j.opc.OPCPackage; import org.apache.poi.openxml4j.opc.OPCPackage;
import org.apache.poi.openxml4j.opc.PackagePart; import org.apache.poi.openxml4j.opc.PackagePart;
import org.apache.poi.openxml4j.opc.PackageRelationship; import org.apache.poi.openxml4j.opc.PackageRelationship;
import org.apache.poi.openxml4j.exceptions.OpenXML4JException; import org.apache.poi.util.TempFile;
import junit.framework.TestCase;
/** /**
* Test recursive read and write of OPC packages * Test recursive read and write of OPC packages
*/ */
public class TestPOIXMLDocument extends TestCase public final class TestPOIXMLDocument extends TestCase {
{
private static class OPCParser extends POIXMLDocument { private static class OPCParser extends POIXMLDocument {
public OPCParser(OPCPackage pkg) throws IOException { public OPCParser(OPCPackage pkg) {
super(pkg); super(pkg);
} }
@ -49,13 +45,16 @@ public class TestPOIXMLDocument extends TestCase
throw new RuntimeException("not supported"); throw new RuntimeException("not supported");
} }
public void parse(POIXMLFactory factory) throws OpenXML4JException, IOException{ public void parse(POIXMLFactory factory) throws IOException{
load(factory); load(factory);
} }
} }
private static class TestFactory extends POIXMLFactory { private static final class TestFactory extends POIXMLFactory {
public TestFactory() {
//
}
public POIXMLDocumentPart createDocumentPart(PackageRelationship rel, PackagePart part){ public POIXMLDocumentPart createDocumentPart(PackageRelationship rel, PackagePart part){
return new POIXMLDocumentPart(part, rel); return new POIXMLDocumentPart(part, rel);
} }

View File

@ -32,9 +32,9 @@ import org.apache.poi.xwpf.usermodel.XWPFDocument;
/** /**
* Test setting extended and custom OOXML properties * Test setting extended and custom OOXML properties
*/ */
public class TestPOIXMLProperties extends TestCase { public final class TestPOIXMLProperties extends TestCase {
POIXMLProperties props; private POIXMLProperties _props;
CoreProperties coreProperties; private CoreProperties _coreProperties;
public void setUp() throws Exception{ public void setUp() throws Exception{
File sampleFile = new File( File sampleFile = new File(
@ -46,12 +46,12 @@ public class TestPOIXMLProperties extends TestCase {
sampleDoc = new XWPFDocument( sampleDoc = new XWPFDocument(
POIXMLDocument.openPackage(sampleFile.toString()) POIXMLDocument.openPackage(sampleFile.toString())
); );
props = sampleDoc.getProperties(); _props = sampleDoc.getProperties();
coreProperties = props.getCoreProperties(); _coreProperties = _props.getCoreProperties();
assertNotNull(props); assertNotNull(_props);
} }
public void testWorkbookExtendedProperties() throws Exception { public void testWorkbookExtendedProperties() {
XSSFWorkbook workbook = new XSSFWorkbook(); XSSFWorkbook workbook = new XSSFWorkbook();
POIXMLProperties props = workbook.getProperties(); POIXMLProperties props = workbook.getProperties();
assertNotNull(props); assertNotNull(props);
@ -94,7 +94,7 @@ public class TestPOIXMLProperties extends TestCase {
} }
public void testWorkbookCustomProperties() throws Exception { public void testWorkbookCustomProperties() {
XSSFWorkbook workbook = new XSSFWorkbook(); XSSFWorkbook workbook = new XSSFWorkbook();
POIXMLProperties props = workbook.getProperties(); POIXMLProperties props = workbook.getProperties();
assertNotNull(props); assertNotNull(props);
@ -157,28 +157,28 @@ public class TestPOIXMLProperties extends TestCase {
} }
public void testDocumentProperties() { public void testDocumentProperties() {
String category = coreProperties.getCategory(); String category = _coreProperties.getCategory();
assertEquals("test", category); assertEquals("test", category);
String contentStatus = "Draft"; String contentStatus = "Draft";
coreProperties.setContentStatus(contentStatus); _coreProperties.setContentStatus(contentStatus);
assertEquals("Draft", contentStatus); assertEquals("Draft", contentStatus);
Date created = coreProperties.getCreated(); Date created = _coreProperties.getCreated();
SimpleDateFormat formatter = new SimpleDateFormat("EEE, MMM d, ''yy"); SimpleDateFormat formatter = new SimpleDateFormat("EEE, MMM d, ''yy");
assertEquals("Mon, Jul 20, '09", formatter.format(created)); assertEquals("Mon, Jul 20, '09", formatter.format(created));
String creator = coreProperties.getCreator(); String creator = _coreProperties.getCreator();
assertEquals("Paolo Mottadelli", creator); assertEquals("Paolo Mottadelli", creator);
String subject = coreProperties.getSubject(); String subject = _coreProperties.getSubject();
assertEquals("Greetings", subject); assertEquals("Greetings", subject);
String title = coreProperties.getTitle(); String title = _coreProperties.getTitle();
assertEquals("Hello World", title); assertEquals("Hello World", title);
} }
public void testGetSetRevision() { public void testGetSetRevision() {
String revision = coreProperties.getRevision(); String revision = _coreProperties.getRevision();
assertTrue("Revision number is 1", new Integer(coreProperties.getRevision()).intValue() > 1); assertTrue("Revision number is 1", new Integer(_coreProperties.getRevision()).intValue() > 1);
coreProperties.setRevision("20"); _coreProperties.setRevision("20");
assertEquals("20", coreProperties.getRevision()); assertEquals("20", _coreProperties.getRevision());
coreProperties.setRevision("20xx"); _coreProperties.setRevision("20xx");
assertEquals("20", coreProperties.getRevision()); assertEquals("20", _coreProperties.getRevision());
} }
} }

View File

@ -24,10 +24,10 @@ import org.apache.poi.openxml4j.opc.OPCPackage;
import junit.framework.TestCase; import junit.framework.TestCase;
public class TestXMLPropertiesTextExtractor extends TestCase { public final class TestXMLPropertiesTextExtractor extends TestCase {
private String dirname; private String dirname;
protected void setUp() throws Exception { protected void setUp() {
dirname = System.getProperty("OOXML.testdata.path"); dirname = System.getProperty("OOXML.testdata.path");
assertTrue( (new File(dirname)).exists() ); assertTrue( (new File(dirname)).exists() );
} }
@ -89,7 +89,7 @@ public class TestXMLPropertiesTextExtractor extends TestCase {
assertTrue(eText.contains("Company = Mera")); assertTrue(eText.contains("Company = Mera"));
} }
public void testCustom() throws Exception { public void testCustom() {
// TODO! // TODO!
} }
} }

View File

@ -19,7 +19,13 @@ package org.apache.poi.openxml4j.opc.internal;
import junit.framework.TestCase; import junit.framework.TestCase;
import org.apache.poi.openxml4j.OpenXML4JTestDataSamples;
import org.apache.poi.openxml4j.opc.OPCPackage;
import org.apache.poi.openxml4j.opc.PackageAccess;
import org.apache.poi.openxml4j.opc.PackagePart;
import org.apache.poi.openxml4j.opc.PackagePartName; import org.apache.poi.openxml4j.opc.PackagePartName;
import org.apache.poi.openxml4j.opc.PackageRelationship;
import org.apache.poi.openxml4j.opc.PackageRelationshipTypes;
import org.apache.poi.openxml4j.opc.PackagingURIHelper; import org.apache.poi.openxml4j.opc.PackagingURIHelper;
public final class TestContentTypeManager extends TestCase { public final class TestContentTypeManager extends TestCase {
@ -27,25 +33,21 @@ public final class TestContentTypeManager extends TestCase {
/** /**
* Test the properties part content parsing. * Test the properties part content parsing.
*/ */
public void testContentType() throws Exception { public void disabled_testContentType() throws Exception {
// File originalFile = new File(testCore.getTestRootPath() + String filepath = OpenXML4JTestDataSamples.getSampleFileName("sample.docx");
// File.separator +
// "sample.docx"); // Retrieves core properties part
// OPCPackage p = OPCPackage.open(filepath, PackageAccess.READ);
// // Retrieves core properties part PackageRelationship corePropertiesRelationship = p
// Package p = Package.open(originalFile.getAbsolutePath(), .getRelationshipsByType(
// PackageAccess.READ); PackageRelationshipTypes.CORE_PROPERTIES)
// PackageRelationship corePropertiesRelationship = p .getRelationship(0);
// .getRelationshipsByType( PackagePart coreDocument = p.getPart(corePropertiesRelationship);
// PackageRelationshipTypes.CORE_PROPERTIES)
// .getRelationship(0); ContentTypeManager ctm = new ZipContentTypeManager(coreDocument.getInputStream(), p);
// PackagePart coreDocument = p.getPart(corePropertiesRelationship);
// // TODO - finish writing this test
// ContentTypeManager ctm = new ZipContentTypeManager(coreDocument fail();
// .getInputStream());
//
// // TODO
//fail();
} }
/** /**
@ -54,14 +56,10 @@ public final class TestContentTypeManager extends TestCase {
public void testContentTypeAddition() throws Exception { public void testContentTypeAddition() throws Exception {
ContentTypeManager ctm = new ZipContentTypeManager(null, null); ContentTypeManager ctm = new ZipContentTypeManager(null, null);
PackagePartName name1 = PackagingURIHelper PackagePartName name1 = PackagingURIHelper.createPartName("/foo/foo.XML");
.createPartName("/foo/foo.XML"); PackagePartName name2 = PackagingURIHelper.createPartName("/foo/foo2.xml");
PackagePartName name2 = PackagingURIHelper PackagePartName name3 = PackagingURIHelper.createPartName("/foo/doc.rels");
.createPartName("/foo/foo2.xml"); PackagePartName name4 = PackagingURIHelper.createPartName("/foo/doc.RELS");
PackagePartName name3 = PackagingURIHelper
.createPartName("/foo/doc.rels");
PackagePartName name4 = PackagingURIHelper
.createPartName("/foo/doc.RELS");
// Add content types // Add content types
ctm.addContentType(name1, "foo-type1"); ctm.addContentType(name1, "foo-type1");
@ -81,14 +79,10 @@ public final class TestContentTypeManager extends TestCase {
public void testContentTypeRemoval() throws Exception { public void testContentTypeRemoval() throws Exception {
ContentTypeManager ctm = new ZipContentTypeManager(null, null); ContentTypeManager ctm = new ZipContentTypeManager(null, null);
PackagePartName name1 = PackagingURIHelper PackagePartName name1 = PackagingURIHelper.createPartName("/foo/foo.xml");
.createPartName("/foo/foo.xml"); PackagePartName name2 = PackagingURIHelper.createPartName("/foo/foo2.xml");
PackagePartName name2 = PackagingURIHelper PackagePartName name3 = PackagingURIHelper.createPartName("/foo/doc.rels");
.createPartName("/foo/foo2.xml"); PackagePartName name4 = PackagingURIHelper.createPartName("/foo/doc.RELS");
PackagePartName name3 = PackagingURIHelper
.createPartName("/foo/doc.rels");
PackagePartName name4 = PackagingURIHelper
.createPartName("/foo/doc.RELS");
// Add content types // Add content types
ctm.addContentType(name1, "foo-type1"); ctm.addContentType(name1, "foo-type1");
@ -110,7 +104,7 @@ public final class TestContentTypeManager extends TestCase {
/** /**
* Test the addition then removal of content types in a package. * Test the addition then removal of content types in a package.
*/ */
public void testContentTypeRemovalPackage() throws Exception { public void testContentTypeRemovalPackage() {
// TODO // TODO
} }
} }

View File

@ -14,6 +14,7 @@
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
==================================================================== */ ==================================================================== */
package org.apache.poi.ss; package org.apache.poi.ss;
import java.io.File; import java.io.File;
@ -28,12 +29,12 @@ import org.apache.poi.openxml4j.opc.OPCPackage;
import junit.framework.TestCase; import junit.framework.TestCase;
public class TestWorkbookFactory extends TestCase { public final class TestWorkbookFactory extends TestCase {
private File xls; private File xls;
private File xlsx; private File xlsx;
private File txt; private File txt;
protected void setUp() throws Exception { protected void setUp() {
xls = new File( xls = new File(
System.getProperty("HSSF.testdata.path") + System.getProperty("HSSF.testdata.path") +
File.separator + "SampleSS.xls" File.separator + "SampleSS.xls"

View File

@ -30,31 +30,20 @@ import org.apache.poi.xssf.usermodel.XSSFMap;
import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.apache.poi.xssf.usermodel.XSSFWorkbook;
/** /**
*
* @author Roberto Manicardi * @author Roberto Manicardi
*
*/ */
public class TestXSSFExportToXML extends TestCase{ public final class TestXSSFExportToXML extends TestCase {
public void testExportToXML() throws Exception { public void testExportToXML() throws Exception {
XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("CustomXMLMappings.xlsx"); XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("CustomXMLMappings.xlsx");
MapInfo mapInfo = null;
for (POIXMLDocumentPart p : wb.getRelations()) { for (POIXMLDocumentPart p : wb.getRelations()) {
if (!(p instanceof MapInfo)) {
if(p instanceof MapInfo){ continue;
mapInfo = (MapInfo) p; }
MapInfo mapInfo = (MapInfo) p;
XSSFMap map = mapInfo.getXSSFMapById(1); XSSFMap map = mapInfo.getXSSFMapById(1);
XSSFExportToXml exporter = new XSSFExportToXml(map); XSSFExportToXml exporter = new XSSFExportToXml(map);
@ -65,7 +54,6 @@ public class TestXSSFExportToXML extends TestCase{
assertNotNull(xml); assertNotNull(xml);
assertTrue(!xml.equals("")); assertTrue(!xml.equals(""));
String docente = xml.split("<DOCENTE>")[1].split("</DOCENTE>")[0].trim(); String docente = xml.split("<DOCENTE>")[1].split("</DOCENTE>")[0].trim();
String nome = xml.split("<NOME>")[1].split("</NOME>")[0].trim(); String nome = xml.split("<NOME>")[1].split("</NOME>")[0].trim();
String tutor = xml.split("<TUTOR>")[1].split("</TUTOR>")[0].trim(); String tutor = xml.split("<TUTOR>")[1].split("</TUTOR>")[0].trim();
@ -83,29 +71,23 @@ public class TestXSSFExportToXML extends TestCase{
assertEquals("gvvv", argomento); assertEquals("gvvv", argomento);
assertEquals("aaaa", progetto); assertEquals("aaaa", progetto);
assertEquals("aa", crediti); assertEquals("aa", crediti);
} }
} }
}
public void testExportToXMLInverseOrder() throws Exception { public void testExportToXMLInverseOrder() throws Exception {
XSSFWorkbook wb = XSSFTestDataSamples
.openSampleWorkbook("CustomXmlMappings-inverse-order.xlsx");
XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("CustomXmlMappings-inverse-order.xlsx");
MapInfo mapInfo = null; MapInfo mapInfo = null;
for (POIXMLDocumentPart p : wb.getRelations()) { for (POIXMLDocumentPart p : wb.getRelations()) {
if (!(p instanceof MapInfo)) {
if(p instanceof MapInfo){ continue;
}
mapInfo = (MapInfo) p; mapInfo = (MapInfo) p;
XSSFMap map = mapInfo.getXSSFMapById(1); XSSFMap map = mapInfo.getXSSFMapById(1);
XSSFExportToXml exporter = new XSSFExportToXml(map); XSSFExportToXml exporter = new XSSFExportToXml(map);
ByteArrayOutputStream os = new ByteArrayOutputStream(); ByteArrayOutputStream os = new ByteArrayOutputStream();
@ -132,26 +114,18 @@ public class TestXSSFExportToXML extends TestCase{
assertEquals("ds", argomento); assertEquals("ds", argomento);
assertEquals("ro", progetto); assertEquals("ro", progetto);
assertEquals("ro", crediti); assertEquals("ro", crediti);
}
} }
} public void testXPathOrdering() {
XSSFWorkbook wb = XSSFTestDataSamples
.openSampleWorkbook("CustomXmlMappings-inverse-order.xlsx");
}
public void testXPathOrdering() throws Exception{
XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("CustomXmlMappings-inverse-order.xlsx");
MapInfo mapInfo = null; MapInfo mapInfo = null;
for (POIXMLDocumentPart p : wb.getRelations()) { for (POIXMLDocumentPart p : wb.getRelations()) {
if (p instanceof MapInfo) { if (p instanceof MapInfo) {
mapInfo = (MapInfo) p; mapInfo = (MapInfo) p;
@ -159,25 +133,18 @@ public class TestXSSFExportToXML extends TestCase{
XSSFExportToXml exporter = new XSSFExportToXml(map); XSSFExportToXml exporter = new XSSFExportToXml(map);
assertEquals(1, exporter.compare("/CORSO/DOCENTE", "/CORSO/NOME")); assertEquals(1, exporter.compare("/CORSO/DOCENTE", "/CORSO/NOME"));
assertEquals(-1, exporter.compare("/CORSO/NOME", "/CORSO/DOCENTE")); assertEquals(-1, exporter.compare("/CORSO/NOME", "/CORSO/DOCENTE"));
} }
} }
} }
public void testMultiTable() throws Exception { public void testMultiTable() throws Exception {
XSSFWorkbook wb = XSSFTestDataSamples
XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("CustomXMLMappings-complex-type.xlsx"); .openSampleWorkbook("CustomXMLMappings-complex-type.xlsx");
for (POIXMLDocumentPart p : wb.getRelations()) { for (POIXMLDocumentPart p : wb.getRelations()) {
if (p instanceof MapInfo) { if (p instanceof MapInfo) {
MapInfo mapInfo = (MapInfo) p; MapInfo mapInfo = (MapInfo) p;
@ -192,14 +159,13 @@ public class TestXSSFExportToXML extends TestCase{
assertNotNull(xml); assertNotNull(xml);
String[] regexConditions = { "<MapInfo", String[] regexConditions = {
"</MapInfo>", "<MapInfo", "</MapInfo>",
"<Schema ID=\"1\" Namespace=\"\" SchemaRef=\"\"/>", "<Schema ID=\"1\" Namespace=\"\" SchemaRef=\"\"/>",
"<Schema ID=\"4\" Namespace=\"\" SchemaRef=\"\"/>", "<Schema ID=\"4\" Namespace=\"\" SchemaRef=\"\"/>",
"DataBinding", "DataBinding",
"Map Append=\"false\" AutoFit=\"false\" ID=\"1\"", "Map Append=\"false\" AutoFit=\"false\" ID=\"1\"",
"Map Append=\"false\" AutoFit=\"false\" ID=\"5\"" "Map Append=\"false\" AutoFit=\"false\" ID=\"5\"",
}; };
for (String condition : regexConditions) { for (String condition : regexConditions) {
@ -207,14 +173,7 @@ public class TestXSSFExportToXML extends TestCase{
Matcher matcher = pattern.matcher(xml); Matcher matcher = pattern.matcher(xml);
assertTrue(matcher.find()); assertTrue(matcher.find());
} }
} }
} }
} }
} }

View File

@ -24,9 +24,9 @@ import org.openxmlformats.schemas.spreadsheetml.x2006.main.*;
import junit.framework.TestCase; import junit.framework.TestCase;
public class TestCalculationChain extends TestCase { public final class TestCalculationChain extends TestCase {
public void test46535() throws Exception { public void test46535() {
XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("46535.xlsx"); XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("46535.xlsx");
CalculationChain chain = wb.getCalculationChain(); CalculationChain chain = wb.getCalculationChain();

View File

@ -30,11 +30,10 @@ import junit.framework.TestCase;
/** /**
* @author Roberto Manicardi * @author Roberto Manicardi
*/ */
public class TestMapInfo extends TestCase { public final class TestMapInfo extends TestCase {
public void testMapInfoExists() throws Exception { public void testMapInfoExists() {
XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("CustomXMLMappings.xlsx"); XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("CustomXMLMappings.xlsx");
@ -72,13 +71,7 @@ public class TestMapInfo extends TestCase {
} }
} }
assertNotNull(mapInfo); assertNotNull(mapInfo);
assertNotNull(singleXMLCells); assertNotNull(singleXMLCells);
} }
} }

View File

@ -25,10 +25,10 @@ import org.apache.poi.xssf.XSSFTestDataSamples;
import junit.framework.TestCase; import junit.framework.TestCase;
public class TestStylesTable extends TestCase { public final class TestStylesTable extends TestCase {
private File xml; private File xml;
protected void setUp() throws Exception { protected void setUp() {
xml = new File( xml = new File(
System.getProperty("HSSF.testdata.path") + System.getProperty("HSSF.testdata.path") +
File.separator + "Formatting.xlsx" File.separator + "Formatting.xlsx"
@ -36,7 +36,7 @@ public class TestStylesTable extends TestCase {
assertTrue(xml.exists()); assertTrue(xml.exists());
} }
public void testCreateNew() throws Exception { public void testCreateNew() {
StylesTable st = new StylesTable(); StylesTable st = new StylesTable();
// Check defaults // Check defaults
@ -46,7 +46,7 @@ public class TestStylesTable extends TestCase {
assertEquals(0, st._getNumberFormatSize()); assertEquals(0, st._getNumberFormatSize());
} }
public void testCreateSaveLoad() throws Exception { public void testCreateSaveLoad() {
XSSFWorkbook wb = new XSSFWorkbook(); XSSFWorkbook wb = new XSSFWorkbook();
StylesTable st = wb.getStylesSource(); StylesTable st = wb.getStylesSource();
@ -81,7 +81,7 @@ public class TestStylesTable extends TestCase {
st = XSSFTestDataSamples.writeOutAndReadBack(workbook).getStylesSource(); st = XSSFTestDataSamples.writeOutAndReadBack(workbook).getStylesSource();
doTestExisting(st); doTestExisting(st);
} }
public void doTestExisting(StylesTable st) throws Exception { public void doTestExisting(StylesTable st) {
// Check contents // Check contents
assertNotNull(st.getCTStylesheet()); assertNotNull(st.getCTStylesheet());
assertEquals(11, st._getXfsSize()); assertEquals(11, st._getXfsSize());
@ -107,7 +107,7 @@ public class TestStylesTable extends TestCase {
assertEquals("yyyy/mm/dd", st.getStyleAt(3).getDataFormatString()); assertEquals("yyyy/mm/dd", st.getStyleAt(3).getDataFormatString());
} }
public void testPopulateNew() throws Exception { public void testPopulateNew() {
XSSFWorkbook wb = new XSSFWorkbook(); XSSFWorkbook wb = new XSSFWorkbook();
StylesTable st = wb.getStylesSource(); StylesTable st = wb.getStylesSource();

View File

@ -37,7 +37,7 @@ public final class TestSheetHiding extends TestCase {
* with the right text on them, no matter what * with the right text on them, no matter what
* the hidden flags are * the hidden flags are
*/ */
public void testTextSheets() throws Exception { public void testTextSheets() {
// Both should have two sheets // Both should have two sheets
assertEquals(2, wbH.getNumberOfSheets()); assertEquals(2, wbH.getNumberOfSheets());
assertEquals(2, wbU.getNumberOfSheets()); assertEquals(2, wbU.getNumberOfSheets());
@ -65,7 +65,7 @@ public final class TestSheetHiding extends TestCase {
* Check that we can get and set the hidden flags * Check that we can get and set the hidden flags
* as expected * as expected
*/ */
public void testHideUnHideFlags() throws Exception { public void testHideUnHideFlags() {
assertTrue(wbH.isSheetHidden(0)); assertTrue(wbH.isSheetHidden(0));
assertFalse(wbH.isSheetHidden(1)); assertFalse(wbH.isSheetHidden(1));
assertFalse(wbU.isSheetHidden(0)); assertFalse(wbU.isSheetHidden(0));
@ -76,7 +76,7 @@ public final class TestSheetHiding extends TestCase {
* Turn the sheet with none hidden into the one with * Turn the sheet with none hidden into the one with
* one hidden * one hidden
*/ */
public void testHide() throws Exception { public void testHide() {
wbU.setSheetHidden(0, true); wbU.setSheetHidden(0, true);
assertTrue(wbU.isSheetHidden(0)); assertTrue(wbU.isSheetHidden(0));
assertFalse(wbU.isSheetHidden(1)); assertFalse(wbU.isSheetHidden(1));
@ -89,7 +89,7 @@ public final class TestSheetHiding extends TestCase {
* Turn the sheet with one hidden into the one with * Turn the sheet with one hidden into the one with
* none hidden * none hidden
*/ */
public void testUnHide() throws Exception { public void testUnHide() {
wbH.setSheetHidden(0, false); wbH.setSheetHidden(0, false);
assertFalse(wbH.isSheetHidden(0)); assertFalse(wbH.isSheetHidden(0));
assertFalse(wbH.isSheetHidden(1)); assertFalse(wbH.isSheetHidden(1));

View File

@ -45,7 +45,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
* Named ranges had the right reference, but * Named ranges had the right reference, but
* the wrong sheet name * the wrong sheet name
*/ */
public void test45430() throws Exception { public void test45430() {
XSSFWorkbook wb = getTestDataProvider().openSampleWorkbook("45430.xlsx"); XSSFWorkbook wb = getTestDataProvider().openSampleWorkbook("45430.xlsx");
assertFalse(wb.isMacroEnabled()); assertFalse(wb.isMacroEnabled());
assertEquals(3, wb.getNumberOfNames()); assertEquals(3, wb.getNumberOfNames());

View File

@ -35,7 +35,7 @@ public final class TestXSSFCell extends BaseTestCell {
* Bug 47026: trouble changing cell type when workbook doesn't contain * Bug 47026: trouble changing cell type when workbook doesn't contain
* Shared String Table * Shared String Table
*/ */
public void test47026_1() throws Exception { public void test47026_1() {
Workbook source = _testDataProvider.openSampleWorkbook("47026.xlsm"); Workbook source = _testDataProvider.openSampleWorkbook("47026.xlsm");
Sheet sheet = source.getSheetAt(0); Sheet sheet = source.getSheetAt(0);
Row row = sheet.getRow(0); Row row = sheet.getRow(0);
@ -44,7 +44,7 @@ public final class TestXSSFCell extends BaseTestCell {
cell.setCellValue("456"); cell.setCellValue("456");
} }
public void test47026_2() throws Exception { public void test47026_2() {
Workbook source = _testDataProvider.openSampleWorkbook("47026.xlsm"); Workbook source = _testDataProvider.openSampleWorkbook("47026.xlsm");
Sheet sheet = source.getSheetAt(0); Sheet sheet = source.getSheetAt(0);
Row row = sheet.getRow(0); Row row = sheet.getRow(0);
@ -60,7 +60,7 @@ public final class TestXSSFCell extends BaseTestCell {
* Some programs, for example, Microsoft Excel Driver for .xlsx insert inline string * Some programs, for example, Microsoft Excel Driver for .xlsx insert inline string
* instead of using the shared string table. See bug 47206 * instead of using the shared string table. See bug 47206
*/ */
public void testInlineString() throws Exception { public void testInlineString() {
XSSFWorkbook wb = (XSSFWorkbook)_testDataProvider.openSampleWorkbook("xlsx-jdbc.xlsx"); XSSFWorkbook wb = (XSSFWorkbook)_testDataProvider.openSampleWorkbook("xlsx-jdbc.xlsx");
XSSFSheet sheet = wb.getSheetAt(0); XSSFSheet sheet = wb.getSheetAt(0);
XSSFRow row = sheet.getRow(1); XSSFRow row = sheet.getRow(1);
@ -84,7 +84,7 @@ public final class TestXSSFCell extends BaseTestCell {
/** /**
* Bug 47278 - xsi:nil attribute for <t> tag caused Excel 2007 to fail to open workbook * Bug 47278 - xsi:nil attribute for <t> tag caused Excel 2007 to fail to open workbook
*/ */
public void test47278() throws Exception { public void test47278() {
XSSFWorkbook wb = (XSSFWorkbook)_testDataProvider.createWorkbook(); XSSFWorkbook wb = (XSSFWorkbook)_testDataProvider.createWorkbook();
XSSFSheet sheet = wb.createSheet(); XSSFSheet sheet = wb.createSheet();
XSSFRow row = sheet.createRow(0); XSSFRow row = sheet.createRow(0);
@ -105,5 +105,4 @@ public final class TestXSSFCell extends BaseTestCell {
assertEquals(0, sst.getCount()); assertEquals(0, sst.getCount());
assertEquals(XSSFCell.CELL_TYPE_BLANK, cell_1.getCellType()); assertEquals(XSSFCell.CELL_TYPE_BLANK, cell_1.getCellType());
} }
} }

View File

@ -585,13 +585,13 @@ public class TestXSSFCellStyle extends TestCase {
/** /**
* Cloning one XSSFCellStyle onto Another, same XSSFWorkbook * Cloning one XSSFCellStyle onto Another, same XSSFWorkbook
*/ */
public void testCloneStyleSameWB() throws Exception { public void testCloneStyleSameWB() {
// TODO // TODO
} }
/** /**
* Cloning one XSSFCellStyle onto Another, different XSSFWorkbooks * Cloning one XSSFCellStyle onto Another, different XSSFWorkbooks
*/ */
public void testCloneStyleDiffWB() throws Exception { public void testCloneStyleDiffWB() {
// TODO // TODO
} }
} }

View File

@ -140,7 +140,7 @@ public class TestXSSFComment extends TestCase {
* file, save, load, and still see them * file, save, load, and still see them
* @throws Exception * @throws Exception
*/ */
public void testCreateSave() throws Exception { public void testCreateSave() {
XSSFWorkbook wb = new XSSFWorkbook(); XSSFWorkbook wb = new XSSFWorkbook();
XSSFSheet s1 = wb.createSheet(); XSSFSheet s1 = wb.createSheet();
Row r1 = s1.createRow(0); Row r1 = s1.createRow(0);

View File

@ -31,10 +31,11 @@ public final class TestXSSFDataFormat extends BaseTestDataFormat {
protected ITestDataProvider getTestDataProvider() { protected ITestDataProvider getTestDataProvider() {
return XSSFITestDataProvider.getInstance(); return XSSFITestDataProvider.getInstance();
} }
/** /**
* Test setting and getting boolean values. * Test setting and getting boolean values.
*/ */
public void testBuiltinFormats() throws Exception { public void testBuiltinFormats() {
baseBuiltinFormats(); baseBuiltinFormats();
} }
} }

View File

@ -14,6 +14,7 @@
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
==================================================================== */ ==================================================================== */
package org.apache.poi.xwpf; package org.apache.poi.xwpf;
import java.io.File; import java.io.File;
@ -27,7 +28,7 @@ import org.apache.poi.openxml4j.opc.PackagePart;
import org.apache.poi.xwpf.usermodel.XWPFDocument; import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.apache.poi.xwpf.usermodel.XWPFRelation; import org.apache.poi.xwpf.usermodel.XWPFRelation;
public class TestXWPFDocument extends TestCase { public final class TestXWPFDocument extends TestCase {
private File sampleFile; private File sampleFile;
private File complexFile; private File complexFile;
@ -121,7 +122,7 @@ public class TestXWPFDocument extends TestCase {
assertEquals(" ", xml.getProperties().getCoreProperties().getUnderlyingProperties().getSubjectProperty().getValue()); assertEquals(" ", xml.getProperties().getCoreProperties().getUnderlyingProperties().getSubjectProperty().getValue());
} }
public void testWorkbookProperties() throws Exception { public void testWorkbookProperties() {
XWPFDocument doc = new XWPFDocument(); XWPFDocument doc = new XWPFDocument();
POIXMLProperties props = doc.getProperties(); POIXMLProperties props = doc.getProperties();
assertNotNull(props); assertNotNull(props);

View File

@ -81,7 +81,7 @@ public class TestXWPFHeaderFooterPolicy extends TestCase {
diffFirst = new XWPFDocument(POIXMLDocument.openPackage(file.toString())); diffFirst = new XWPFDocument(POIXMLDocument.openPackage(file.toString()));
} }
public void testPolicy() throws Exception { public void testPolicy() {
XWPFHeaderFooterPolicy policy; XWPFHeaderFooterPolicy policy;
policy = noHeader.getHeaderFooterPolicy(); policy = noHeader.getHeaderFooterPolicy();
@ -162,7 +162,7 @@ public class TestXWPFHeaderFooterPolicy extends TestCase {
assertEquals(policy.getDefaultFooter(), policy.getFooter(3)); assertEquals(policy.getDefaultFooter(), policy.getFooter(3));
} }
public void testContents() throws Exception { public void testContents() {
XWPFHeaderFooterPolicy policy; XWPFHeaderFooterPolicy policy;
// Test a few simple bits off a simple header // Test a few simple bits off a simple header

View File

@ -111,8 +111,7 @@ public final class NewOleFile extends RandomAccessFile
{ {
} }
} }
protected int[] readChain(int[] blockChain, int startBlock) throws IOException protected int[] readChain(int[] blockChain, int startBlock) {
{
int[] tempChain = new int[blockChain.length]; int[] tempChain = new int[blockChain.length];
tempChain[0] = startBlock; tempChain[0] = startBlock;

View File

@ -114,7 +114,7 @@ public final class HDGFDiagram extends POIDocument {
* Prints out some simple debug on the base contents of the file. * Prints out some simple debug on the base contents of the file.
* @see org.apache.poi.hdgf.dev.VSDDumper * @see org.apache.poi.hdgf.dev.VSDDumper
*/ */
public void debug() throws IOException { public void debug() {
System.err.println("Trailer is at " + trailerPointer.getOffset()); System.err.println("Trailer is at " + trailerPointer.getOffset());
System.err.println("Trailer has type " + trailerPointer.getType()); System.err.println("Trailer has type " + trailerPointer.getType());
System.err.println("Trailer has length " + trailerPointer.getLength()); System.err.println("Trailer has length " + trailerPointer.getLength());

View File

@ -32,8 +32,8 @@ import org.apache.poi.poifs.filesystem.DirectoryNode;
import org.apache.poi.poifs.filesystem.POIFSFileSystem; import org.apache.poi.poifs.filesystem.POIFSFileSystem;
/** /**
* This class can be used to extract text from a PowerPoint file. * This class can be used to extract text from a PowerPoint file. Can optionally
* Can optionally also get the notes from one. * also get the notes from one.
* *
* @author Nick Burch * @author Nick Burch
*/ */
@ -42,15 +42,14 @@ public final class PowerPointExtractor extends POIOLE2TextExtractor {
private SlideShow _show; private SlideShow _show;
private Slide[] _slides; private Slide[] _slides;
private boolean slidesByDefault = true; private boolean _slidesByDefault = true;
private boolean notesByDefault = false; private boolean _notesByDefault = false;
private boolean commentsByDefault = false; private boolean _commentsByDefault = false;
/** /**
* Basic extractor. Returns all the text, and optionally all the notes * Basic extractor. Returns all the text, and optionally all the notes
*/ */
public static void main(String args[]) throws IOException public static void main(String args[]) throws IOException {
{
if (args.length < 1) { if (args.length < 1) {
System.err.println("Useage:"); System.err.println("Useage:");
System.err.println("\tPowerPointExtractor [-notes] <file>"); System.err.println("\tPowerPointExtractor [-notes] <file>");
@ -76,34 +75,41 @@ public final class PowerPointExtractor extends POIOLE2TextExtractor {
/** /**
* Creates a PowerPointExtractor, from a file * Creates a PowerPointExtractor, from a file
*
* @param fileName The name of the file to extract from * @param fileName The name of the file to extract from
*/ */
public PowerPointExtractor(String fileName) throws IOException { public PowerPointExtractor(String fileName) throws IOException {
this(new FileInputStream(fileName)); this(new FileInputStream(fileName));
} }
/** /**
* Creates a PowerPointExtractor, from an Input Stream * Creates a PowerPointExtractor, from an Input Stream
*
* @param iStream The input stream containing the PowerPoint document * @param iStream The input stream containing the PowerPoint document
*/ */
public PowerPointExtractor(InputStream iStream) throws IOException { public PowerPointExtractor(InputStream iStream) throws IOException {
this(new POIFSFileSystem(iStream)); this(new POIFSFileSystem(iStream));
} }
/** /**
* Creates a PowerPointExtractor, from an open POIFSFileSystem * Creates a PowerPointExtractor, from an open POIFSFileSystem
*
* @param fs the POIFSFileSystem containing the PowerPoint document * @param fs the POIFSFileSystem containing the PowerPoint document
*/ */
public PowerPointExtractor(POIFSFileSystem fs) throws IOException { public PowerPointExtractor(POIFSFileSystem fs) throws IOException {
this(new HSLFSlideShow(fs)); this(new HSLFSlideShow(fs));
} }
public PowerPointExtractor(DirectoryNode dir, POIFSFileSystem fs) throws IOException { public PowerPointExtractor(DirectoryNode dir, POIFSFileSystem fs) throws IOException {
this(new HSLFSlideShow(dir, fs)); this(new HSLFSlideShow(dir, fs));
} }
/** /**
* Creates a PowerPointExtractor, from a HSLFSlideShow * Creates a PowerPointExtractor, from a HSLFSlideShow
*
* @param ss the HSLFSlideShow to extract text from * @param ss the HSLFSlideShow to extract text from
*/ */
public PowerPointExtractor(HSLFSlideShow ss) throws IOException { public PowerPointExtractor(HSLFSlideShow ss) {
super(ss); super(ss);
_hslfshow = ss; _hslfshow = ss;
_show = new SlideShow(_hslfshow); _show = new SlideShow(_hslfshow);
@ -111,35 +117,32 @@ public final class PowerPointExtractor extends POIOLE2TextExtractor {
} }
/** /**
* Should a call to getText() return slide text? * Should a call to getText() return slide text? Default is yes
* Default is yes
*/ */
public void setSlidesByDefault(boolean slidesByDefault) { public void setSlidesByDefault(boolean slidesByDefault) {
this.slidesByDefault = slidesByDefault; this._slidesByDefault = slidesByDefault;
}
/**
* Should a call to getText() return notes text?
* Default is no
*/
public void setNotesByDefault(boolean notesByDefault) {
this.notesByDefault = notesByDefault;
}
/**
* Should a call to getText() return comments text?
* Default is no
*/
public void setCommentsByDefault(boolean commentsByDefault) {
this.commentsByDefault = commentsByDefault;
} }
/** /**
* Fetches all the slide text from the slideshow, * Should a call to getText() return notes text? Default is no
* but not the notes, unless you've called */
* setSlidesByDefault() and setNotesByDefault() public void setNotesByDefault(boolean notesByDefault) {
* to change this this._notesByDefault = notesByDefault;
}
/**
* Should a call to getText() return comments text? Default is no
*/
public void setCommentsByDefault(boolean commentsByDefault) {
this._commentsByDefault = commentsByDefault;
}
/**
* Fetches all the slide text from the slideshow, but not the notes, unless
* you've called setSlidesByDefault() and setNotesByDefault() to change this
*/ */
public String getText() { public String getText() {
return getText(slidesByDefault,notesByDefault,commentsByDefault); return getText(_slidesByDefault, _notesByDefault, _commentsByDefault);
} }
/** /**
@ -167,15 +170,17 @@ public final class PowerPointExtractor extends POIOLE2TextExtractor {
} }
/** /**
* Fetches text from the slideshow, be it slide text or note text. * Fetches text from the slideshow, be it slide text or note text. Because
* Because the final block of text in a TextRun normally have their * the final block of text in a TextRun normally have their last \n
* last \n stripped, we add it back * stripped, we add it back
*
* @param getSlideText fetch slide text * @param getSlideText fetch slide text
* @param getNoteText fetch note text * @param getNoteText fetch note text
*/ */
public String getText(boolean getSlideText, boolean getNoteText) { public String getText(boolean getSlideText, boolean getNoteText) {
return getText(getSlideText, getNoteText, commentsByDefault); return getText(getSlideText, getNoteText, _commentsByDefault);
} }
public String getText(boolean getSlideText, boolean getNoteText, boolean getCommentText) { public String getText(boolean getSlideText, boolean getNoteText, boolean getCommentText) {
StringBuffer ret = new StringBuffer(); StringBuffer ret = new StringBuffer();
@ -211,12 +216,7 @@ public final class PowerPointExtractor extends POIOLE2TextExtractor {
if (getCommentText) { if (getCommentText) {
Comment[] comments = slide.getComments(); Comment[] comments = slide.getComments();
for (int j = 0; j < comments.length; j++) { for (int j = 0; j < comments.length; j++) {
ret.append( ret.append(comments[j].getAuthor() + " - " + comments[j].getText() + "\n");
comments[j].getAuthor() +
" - " +
comments[j].getText() +
"\n"
);
} }
} }
} }
@ -234,9 +234,13 @@ public final class PowerPointExtractor extends POIOLE2TextExtractor {
for (int i = 0; i < _slides.length; i++) { for (int i = 0; i < _slides.length; i++) {
Notes notes = _slides[i].getNotesSheet(); Notes notes = _slides[i].getNotesSheet();
if(notes == null) { continue; } if (notes == null) {
continue;
}
Integer id = new Integer(notes._getSheetNumber()); Integer id = new Integer(notes._getSheetNumber());
if(seenNotes.contains(id)) { continue; } if (seenNotes.contains(id)) {
continue;
}
seenNotes.add(id); seenNotes.add(id);
// Repeat the Notes header, if set // Repeat the Notes header, if set

View File

@ -91,7 +91,7 @@ public class MAPIMessage {
* @throws IOException * @throws IOException
* @throws ChunkNotFoundException * @throws ChunkNotFoundException
*/ */
public String getTextBody() throws IOException, ChunkNotFoundException { public String getTextBody() throws ChunkNotFoundException {
return getStringFromChunk(chunks.textBodyChunk); return getStringFromChunk(chunks.textBodyChunk);
} }

View File

@ -28,9 +28,9 @@ import org.apache.poi.hwpf.model.FileInformationBlock;
* use this program. * use this program.
*/ */
public final class HWPFLister { public final class HWPFLister {
private HWPFDocument doc; private final HWPFDocument _doc;
public HWPFLister(HWPFDocument doc) { public HWPFLister(HWPFDocument doc) {
this.doc = doc; _doc = doc;
} }
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
@ -46,8 +46,8 @@ public final class HWPFLister {
l.dumpFIB(); l.dumpFIB();
} }
public void dumpFIB() throws Exception { public void dumpFIB() {
FileInformationBlock fib = doc.getFileInformationBlock(); FileInformationBlock fib = _doc.getFileInformationBlock();
System.out.println(fib.toString()); System.out.println(fib.toString());
} }
} }

View File

@ -71,7 +71,7 @@ public final class WordExtractor extends POIOLE2TextExtractor {
* Create a new Word Extractor * Create a new Word Extractor
* @param doc The HWPFDocument to extract from * @param doc The HWPFDocument to extract from
*/ */
public WordExtractor(HWPFDocument doc) throws IOException { public WordExtractor(HWPFDocument doc) {
super(doc); super(doc);
this.doc = doc; this.doc = doc;
} }

View File

@ -17,8 +17,6 @@
package org.apache.poi.hwpf.model; package org.apache.poi.hwpf.model;
import java.io.IOException;
import org.apache.poi.util.LittleEndian; import org.apache.poi.util.LittleEndian;
/** /**
@ -78,9 +76,7 @@ public final class FIBLongHandler {
_longs[longCode] = value; _longs[longCode] = value;
} }
void serialize(byte[] mainStream, int offset) void serialize(byte[] mainStream, int offset) {
throws IOException
{
LittleEndian.putShort(mainStream, offset, (short)_longs.length); LittleEndian.putShort(mainStream, offset, (short)_longs.length);
offset += LittleEndian.SHORT_SIZE; offset += LittleEndian.SHORT_SIZE;

View File

@ -17,8 +17,6 @@
package org.apache.poi.hwpf.model; package org.apache.poi.hwpf.model;
import java.io.IOException;
import org.apache.poi.util.LittleEndian; import org.apache.poi.util.LittleEndian;
/** /**
@ -60,9 +58,7 @@ public final class FIBShortHandler {
return (_shorts.length * LittleEndian.SHORT_SIZE) + LittleEndian.SHORT_SIZE; return (_shorts.length * LittleEndian.SHORT_SIZE) + LittleEndian.SHORT_SIZE;
} }
void serialize(byte[] mainStream) void serialize(byte[] mainStream) {
throws IOException
{
int offset = START; int offset = START;
LittleEndian.putShort(mainStream, offset, (short)_shorts.length); LittleEndian.putShort(mainStream, offset, (short)_shorts.length);
offset += LittleEndian.SHORT_SIZE; offset += LittleEndian.SHORT_SIZE;

View File

@ -66,7 +66,7 @@ public final class TestPOIDocumentScratchpad extends TestCase {
doc2 = new HWPFDocument(pfs2); doc2 = new HWPFDocument(pfs2);
} }
public void testReadProperties() throws Exception { public void testReadProperties() {
// We should have both sets // We should have both sets
assertNotNull(doc.getDocumentSummaryInformation()); assertNotNull(doc.getDocumentSummaryInformation());
assertNotNull(doc.getSummaryInformation()); assertNotNull(doc.getSummaryInformation());
@ -76,7 +76,7 @@ public final class TestPOIDocumentScratchpad extends TestCase {
assertEquals(10598, doc.getDocumentSummaryInformation().getByteCount()); assertEquals(10598, doc.getDocumentSummaryInformation().getByteCount());
} }
public void testReadProperties2() throws Exception { public void testReadProperties2() {
// Check again on the word one // Check again on the word one
assertNotNull(doc2.getDocumentSummaryInformation()); assertNotNull(doc2.getDocumentSummaryInformation());
assertNotNull(doc2.getSummaryInformation()); assertNotNull(doc2.getSummaryInformation());
@ -92,12 +92,8 @@ public final class TestPOIDocumentScratchpad extends TestCase {
doc.writeProperties(outFS); doc.writeProperties(outFS);
// Should now hold them // Should now hold them
assertNotNull( assertNotNull(outFS.createDocumentInputStream("\005SummaryInformation"));
outFS.createDocumentInputStream("\005SummaryInformation") assertNotNull(outFS.createDocumentInputStream("\005DocumentSummaryInformation"));
);
assertNotNull(
outFS.createDocumentInputStream("\005DocumentSummaryInformation")
);
} }
public void testWriteReadProperties() throws Exception { public void testWriteReadProperties() throws Exception {

View File

@ -106,7 +106,7 @@ public final class TestHDGFLZW extends TestCase {
0, 0, 42, 1, 0, 0, 84, 0, 0, 0, 0, 0 0, 0, 42, 1, 0, 0, 84, 0, 0, 0, 0, 0
}; };
public void testFromToInt() throws Exception { public void testFromToInt() {
byte b255 = -1; byte b255 = -1;
assertEquals(255, HDGFLZW.fromByte(b255)); assertEquals(255, HDGFLZW.fromByte(b255));
assertEquals(-1, HDGFLZW.fromInt( HDGFLZW.fromByte(b255) )); assertEquals(-1, HDGFLZW.fromInt( HDGFLZW.fromByte(b255) ));

View File

@ -30,7 +30,7 @@ import org.apache.poi.poifs.filesystem.POIFSFileSystem;
public final class TestVisioExtractor extends TestCase { public final class TestVisioExtractor extends TestCase {
private String dirname; private String dirname;
private String defFilename; private String defFilename;
protected void setUp() throws Exception { protected void setUp() {
dirname = System.getProperty("HDGF.testdata.path"); dirname = System.getProperty("HDGF.testdata.path");
defFilename = dirname + "/Test_Visio-Some_Random_Text.vsd"; defFilename = dirname + "/Test_Visio-Some_Random_Text.vsd";
} }

View File

@ -40,7 +40,7 @@ public final class TestPointerFactory extends TestCase {
-1, 0, 0, 0, -84, -1, 79, 1, 0, 0, 0, 0, 0, 0, 0, 0, 96, 0 -1, 0, 0, 0, -84, -1, 79, 1, 0, 0, 0, 0, 0, 0, 0, 0, 96, 0
}; };
public void testCreateV4() throws Exception { public void testCreateV4() {
PointerFactory pf = new PointerFactory(4); PointerFactory pf = new PointerFactory(4);
try { try {
pf.createPointer(new byte[]{}, 0); pf.createPointer(new byte[]{}, 0);
@ -50,7 +50,7 @@ public final class TestPointerFactory extends TestCase {
} }
} }
public void testCreateV5() throws Exception { public void testCreateV5() {
PointerFactory pf = new PointerFactory(5); PointerFactory pf = new PointerFactory(5);
try { try {
pf.createPointer(new byte[]{}, 0); pf.createPointer(new byte[]{}, 0);
@ -61,7 +61,7 @@ public final class TestPointerFactory extends TestCase {
} }
} }
public void testCreateV6() throws Exception { public void testCreateV6() {
PointerFactory pf = new PointerFactory(6); PointerFactory pf = new PointerFactory(6);
Pointer a = pf.createPointer(vp6_a, 0); Pointer a = pf.createPointer(vp6_a, 0);
@ -117,7 +117,7 @@ public final class TestPointerFactory extends TestCase {
assertFalse(d.destinationHasPointers()); assertFalse(d.destinationHasPointers());
} }
public void testCreateV6FromMid() throws Exception { public void testCreateV6FromMid() {
PointerFactory pf = new PointerFactory(11); PointerFactory pf = new PointerFactory(11);
// Create a from part way down the byte stream // Create a from part way down the byte stream

View File

@ -52,17 +52,17 @@ public final class TestStreamBugs extends StreamTest {
filesystem.createDocumentInputStream("VisioDocument").read(contents); filesystem.createDocumentInputStream("VisioDocument").read(contents);
} }
public void testGetTrailer() throws Exception { public void testGetTrailer() {
Pointer trailerPointer = ptrFactory.createPointer(contents, 0x24); Pointer trailerPointer = ptrFactory.createPointer(contents, 0x24);
Stream.createStream(trailerPointer, contents, chunkFactory, ptrFactory); Stream.createStream(trailerPointer, contents, chunkFactory, ptrFactory);
} }
public void TOIMPLEMENTtestGetCertainChunks() throws Exception { public void TOIMPLEMENTtestGetCertainChunks() {
int offsetA = 3708; int offsetA = 3708;
int offsetB = 3744; int offsetB = 3744;
} }
public void testGetChildren() throws Exception { public void testGetChildren() {
Pointer trailerPointer = ptrFactory.createPointer(contents, 0x24); Pointer trailerPointer = ptrFactory.createPointer(contents, 0x24);
TrailerStream trailer = (TrailerStream) TrailerStream trailer = (TrailerStream)
Stream.createStream(trailerPointer, contents, chunkFactory, ptrFactory); Stream.createStream(trailerPointer, contents, chunkFactory, ptrFactory);

View File

@ -205,7 +205,7 @@ public final class TestStreamComplex extends StreamTest {
assertTrue(s8451.getPointedToStreams()[1] instanceof StringsStream); assertTrue(s8451.getPointedToStreams()[1] instanceof StringsStream);
} }
public void testChunkWithText() throws Exception { public void testChunkWithText() {
// Parent ChunkStream is at 0x7194 // Parent ChunkStream is at 0x7194
// This is one of the last children of the trailer // This is one of the last children of the trailer
Pointer trailerPtr = ptrFactory.createPointer(contents, trailerPointerAt); Pointer trailerPtr = ptrFactory.createPointer(contents, trailerPointerAt);

View File

@ -25,7 +25,7 @@ import junit.framework.TestCase;
public final class TestHPBFDocument extends TestCase { public final class TestHPBFDocument extends TestCase {
private String dir; private String dir;
protected void setUp() throws Exception { protected void setUp() {
dir = System.getProperty("HPBF.testdata.path"); dir = System.getProperty("HPBF.testdata.path");
} }

View File

@ -27,7 +27,7 @@ import junit.framework.TestCase;
public final class TextPublisherTextExtractor extends TestCase { public final class TextPublisherTextExtractor extends TestCase {
private String dir; private String dir;
protected void setUp() throws Exception { protected void setUp() {
dir = System.getProperty("HPBF.testdata.path"); dir = System.getProperty("HPBF.testdata.path");
} }

View File

@ -27,7 +27,7 @@ import junit.framework.TestCase;
public final class TestEscherParts extends TestCase { public final class TestEscherParts extends TestCase {
private String dir; private String dir;
protected void setUp() throws Exception { protected void setUp() {
dir = System.getProperty("HPBF.testdata.path"); dir = System.getProperty("HPBF.testdata.path");
} }

View File

@ -32,7 +32,7 @@ import junit.framework.TestCase;
public final class TestQuillContents extends TestCase { public final class TestQuillContents extends TestCase {
private String dir; private String dir;
protected void setUp() throws Exception { protected void setUp() {
dir = System.getProperty("HPBF.testdata.path"); dir = System.getProperty("HPBF.testdata.path");
} }

View File

@ -37,7 +37,7 @@ public final class TestRecordCounts extends TestCase {
ss = new HSLFSlideShow(filename); ss = new HSLFSlideShow(filename);
} }
public void testSheetsCount() throws Exception { public void testSheetsCount() {
// Top level // Top level
Record[] r = ss.getRecords(); Record[] r = ss.getRecords();
@ -51,7 +51,7 @@ public final class TestRecordCounts extends TestCase {
assertEquals(3,count); assertEquals(3,count);
} }
public void testNotesCount() throws Exception { public void testNotesCount() {
// Top level // Top level
Record[] r = ss.getRecords(); Record[] r = ss.getRecords();
@ -66,7 +66,7 @@ public final class TestRecordCounts extends TestCase {
assertEquals(3,count); assertEquals(3,count);
} }
public void testSlideListWithTextCount() throws Exception { public void testSlideListWithTextCount() {
// Second level // Second level
Record[] rt = ss.getRecords(); Record[] rt = ss.getRecords();
Record[] r = rt[0].getChildRecords(); Record[] r = rt[0].getChildRecords();

View File

@ -61,7 +61,7 @@ public final class TestCruddyExtractor extends TestCase {
te = new QuickButCruddyTextExtractor(filename); te = new QuickButCruddyTextExtractor(filename);
} }
public void testReadAsVector() throws Exception { public void testReadAsVector() {
// Extract the text from the file as a vector // Extract the text from the file as a vector
Vector foundTextV = te.getTextAsVector(); Vector foundTextV = te.getTextAsVector();
@ -73,7 +73,7 @@ public final class TestCruddyExtractor extends TestCase {
} }
} }
public void testReadAsString() throws Exception { public void testReadAsString() {
// Extract the text as a String // Extract the text as a String
String foundText = te.getTextAsString(); String foundText = te.getTextAsString();

View File

@ -35,7 +35,7 @@ public final class TestBackground extends TestCase {
/** /**
* Default background for slide, shape and slide master. * Default background for slide, shape and slide master.
*/ */
public void testDefaults() throws Exception { public void testDefaults() {
SlideShow ppt = new SlideShow(); SlideShow ppt = new SlideShow();
assertEquals(Fill.FILL_SOLID, ppt.getSlidesMasters()[0].getBackground().getFill().getFillType()); assertEquals(Fill.FILL_SOLID, ppt.getSlidesMasters()[0].getBackground().getFill().getFillType());

View File

@ -20,8 +20,6 @@ package org.apache.poi.hslf.model;
import junit.framework.TestCase; import junit.framework.TestCase;
import org.apache.poi.hslf.usermodel.SlideShow; import org.apache.poi.hslf.usermodel.SlideShow;
import java.io.IOException;
/** /**
* Test adding fonts to the presenataion resources * Test adding fonts to the presenataion resources
* *
@ -29,7 +27,7 @@ import java.io.IOException;
*/ */
public final class TestPPFont extends TestCase{ public final class TestPPFont extends TestCase{
public void testCreate() throws IOException { public void testCreate() {
SlideShow ppt = new SlideShow(); SlideShow ppt = new SlideShow();
assertEquals(1, ppt.getNumberOfFonts()); assertEquals(1, ppt.getNumberOfFonts());
assertEquals("Arial", ppt.getFont(0).getFontName()); assertEquals("Arial", ppt.getFont(0).getFontName());

View File

@ -21,7 +21,6 @@ import java.awt.Graphics2D;
import java.awt.Rectangle; import java.awt.Rectangle;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.io.File; import java.io.File;
import java.io.IOException;
import junit.framework.TestCase; import junit.framework.TestCase;

View File

@ -183,7 +183,7 @@ public final class TestShapes extends TestCase {
/** /**
* Test with an empty text box * Test with an empty text box
*/ */
public void testEmptyTextBox() throws Exception { public void testEmptyTextBox() {
assertEquals(2, pptB.getSlides().length); assertEquals(2, pptB.getSlides().length);
Slide s1 = pptB.getSlides()[0]; Slide s1 = pptB.getSlides()[0];
Slide s2 = pptB.getSlides()[1]; Slide s2 = pptB.getSlides()[1];
@ -310,7 +310,7 @@ public final class TestShapes extends TestCase {
assertEquals("expected 0 shaped in " + file, 0, sl.getShapes().length); assertEquals("expected 0 shaped in " + file, 0, sl.getShapes().length);
} }
public void testLineWidth() throws IOException { public void testLineWidth() {
SimpleShape sh = new AutoShape(ShapeTypes.RightTriangle); SimpleShape sh = new AutoShape(ShapeTypes.RightTriangle);
EscherOptRecord opt = (EscherOptRecord)SimpleShape.getEscherChild(sh.getSpContainer(), EscherOptRecord.RECORD_ID); EscherOptRecord opt = (EscherOptRecord)SimpleShape.getEscherChild(sh.getSpContainer(), EscherOptRecord.RECORD_ID);
@ -324,7 +324,7 @@ public final class TestShapes extends TestCase {
assertEquals(1.0, sh.getLineWidth()); assertEquals(1.0, sh.getLineWidth());
} }
public void testShapeId() throws IOException { public void testShapeId() {
SlideShow ppt = new SlideShow(); SlideShow ppt = new SlideShow();
Slide slide = ppt.createSlide(); Slide slide = ppt.createSlide();
Shape shape = null; Shape shape = null;

View File

@ -17,6 +17,7 @@
package org.apache.poi.hslf.model; package org.apache.poi.hslf.model;
import junit.framework.AssertionFailedError;
import junit.framework.TestCase; import junit.framework.TestCase;
import java.io.FileInputStream; import java.io.FileInputStream;
@ -59,7 +60,7 @@ public final class TestSheet extends TestCase{
} }
} }
private void doSlideShow(SlideShow ppt) throws Exception { private void doSlideShow(SlideShow ppt) {
Slide[] slide = ppt.getSlides(); Slide[] slide = ppt.getSlides();
for (int i = 0; i < slide.length; i++) { for (int i = 0; i < slide.length; i++) {
verify(slide[i]); verify(slide[i]);
@ -89,19 +90,22 @@ public final class TestSheet extends TestCase{
assertTrue(sheet._getSheetRefId() != 0); assertTrue(sheet._getSheetRefId() != 0);
TextRun[] txt = sheet.getTextRuns(); TextRun[] txt = sheet.getTextRuns();
assertTrue(txt != null); if (txt == null) {
throw new AssertionFailedError("no text runs");
}
for (int i = 0; i < txt.length; i++) { for (int i = 0; i < txt.length; i++) {
assertNotNull(txt[i].getSheet()); assertNotNull(txt[i].getSheet());
} }
Shape[] shape = sheet.getShapes(); Shape[] shape = sheet.getShapes();
assertTrue(shape != null); if (shape == null) {
throw new AssertionFailedError("no shapes");
}
for (int i = 0; i < shape.length; i++) { for (int i = 0; i < shape.length; i++) {
assertNotNull(shape[i].getSpContainer()); assertNotNull(shape[i].getSpContainer());
assertNotNull(shape[i].getSheet()); assertNotNull(shape[i].getSheet());
assertNotNull(shape[i].getShapeName()); assertNotNull(shape[i].getShapeName());
assertNotNull(shape[i].getAnchor()); assertNotNull(shape[i].getAnchor());
} }
} }
} }

View File

@ -18,6 +18,8 @@
package org.apache.poi.hslf.model; package org.apache.poi.hslf.model;
import java.io.IOException;
import junit.framework.TestCase; import junit.framework.TestCase;
import org.apache.poi.hslf.HSLFSlideShow; import org.apache.poi.hslf.HSLFSlideShow;
@ -37,27 +39,35 @@ public final class TestTextRun extends TestCase {
// SlideShow primed on the test data // SlideShow primed on the test data
private SlideShow ss; private SlideShow ss;
private SlideShow ssRich; private SlideShow ssRich;
private HSLFSlideShow hss;
private HSLFSlideShow hssRich;
protected void setUp() throws Exception { // TODO - use this or similar through rest of hslf tests
private static SlideShow openSampleSlideShow(String name) {
String dirname = System.getProperty("HSLF.testdata.path"); String dirname = System.getProperty("HSLF.testdata.path");
// Basic (non rich) test file // Basic (non rich) test file
String filename = dirname + "/basic_test_ppt_file.ppt"; String filename = dirname + "/" + name;
hss = new HSLFSlideShow(filename); HSLFSlideShow x;
ss = new SlideShow(hss); try {
x = new HSLFSlideShow(filename);
} catch (IOException e) {
throw new RuntimeException(e);
}
return new SlideShow(x);
}
protected void setUp() {
// Basic (non rich) test file
ss = openSampleSlideShow("basic_test_ppt_file.ppt");
// Rich test file // Rich test file
filename = dirname + "/Single_Coloured_Page.ppt"; ssRich = openSampleSlideShow("Single_Coloured_Page.ppt");
hssRich = new HSLFSlideShow(filename);
ssRich = new SlideShow(hssRich);
} }
/** /**
* Test to ensure that getting the text works correctly * Test to ensure that getting the text works correctly
*/ */
public void testGetText() throws Exception { public void testGetText() {
Slide slideOne = ss.getSlides()[0]; Slide slideOne = ss.getSlides()[0];
TextRun[] textRuns = slideOne.getTextRuns(); TextRun[] textRuns = slideOne.getTextRuns();
@ -86,7 +96,7 @@ public final class TestTextRun extends TestCase {
/** /**
* Test to ensure changing non rich text bytes->bytes works correctly * Test to ensure changing non rich text bytes->bytes works correctly
*/ */
public void testSetText() throws Exception { public void testSetText() {
Slide slideOne = ss.getSlides()[0]; Slide slideOne = ss.getSlides()[0];
TextRun[] textRuns = slideOne.getTextRuns(); TextRun[] textRuns = slideOne.getTextRuns();
TextRun run = textRuns[0]; TextRun run = textRuns[0];
@ -108,7 +118,7 @@ public final class TestTextRun extends TestCase {
* Test to ensure that changing non rich text between bytes and * Test to ensure that changing non rich text between bytes and
* chars works correctly * chars works correctly
*/ */
public void testAdvancedSetText() throws Exception { public void testAdvancedSetText() {
Slide slideOne = ss.getSlides()[0]; Slide slideOne = ss.getSlides()[0];
TextRun run = slideOne.getTextRuns()[0]; TextRun run = slideOne.getTextRuns()[0];
@ -169,7 +179,7 @@ public final class TestTextRun extends TestCase {
* Tests to ensure that non rich text has the right default rich text run * Tests to ensure that non rich text has the right default rich text run
* set up for it * set up for it
*/ */
public void testGetRichTextNonRich() throws Exception { public void testGetRichTextNonRich() {
Slide slideOne = ss.getSlides()[0]; Slide slideOne = ss.getSlides()[0];
TextRun[] textRuns = slideOne.getTextRuns(); TextRun[] textRuns = slideOne.getTextRuns();
@ -196,7 +206,7 @@ public final class TestTextRun extends TestCase {
/** /**
* Tests to ensure that the rich text runs are built up correctly * Tests to ensure that the rich text runs are built up correctly
*/ */
public void testGetRichText() throws Exception { public void testGetRichText() {
Slide slideOne = ssRich.getSlides()[0]; Slide slideOne = ssRich.getSlides()[0];
TextRun[] textRuns = slideOne.getTextRuns(); TextRun[] textRuns = slideOne.getTextRuns();
@ -242,7 +252,7 @@ public final class TestTextRun extends TestCase {
* Tests to ensure that setting the text where the text isn't rich, * Tests to ensure that setting the text where the text isn't rich,
* ensuring that everything stays with the same default styling * ensuring that everything stays with the same default styling
*/ */
public void testSetTextWhereNotRich() throws Exception { public void testSetTextWhereNotRich() {
Slide slideOne = ss.getSlides()[0]; Slide slideOne = ss.getSlides()[0];
TextRun[] textRuns = slideOne.getTextRuns(); TextRun[] textRuns = slideOne.getTextRuns();
TextRun trB = textRuns[1]; TextRun trB = textRuns[1];
@ -266,7 +276,7 @@ public final class TestTextRun extends TestCase {
* Tests to ensure that setting the text where the text is rich * Tests to ensure that setting the text where the text is rich
* sets everything to the same styling * sets everything to the same styling
*/ */
public void testSetTextWhereRich() throws Exception { public void testSetTextWhereRich() {
Slide slideOne = ssRich.getSlides()[0]; Slide slideOne = ssRich.getSlides()[0];
TextRun[] textRuns = slideOne.getTextRuns(); TextRun[] textRuns = slideOne.getTextRuns();
TextRun trB = textRuns[1]; TextRun trB = textRuns[1];
@ -314,7 +324,7 @@ public final class TestTextRun extends TestCase {
* Test to ensure the right stuff happens if we change the text * Test to ensure the right stuff happens if we change the text
* in a rich text run, that doesn't happen to actually be rich * in a rich text run, that doesn't happen to actually be rich
*/ */
public void testChangeTextInRichTextRunNonRich() throws Exception { public void testChangeTextInRichTextRunNonRich() {
Slide slideOne = ss.getSlides()[0]; Slide slideOne = ss.getSlides()[0];
TextRun[] textRuns = slideOne.getTextRuns(); TextRun[] textRuns = slideOne.getTextRuns();
TextRun trB = textRuns[1]; TextRun trB = textRuns[1];
@ -339,7 +349,7 @@ public final class TestTextRun extends TestCase {
* Tests to ensure changing the text within rich text runs works * Tests to ensure changing the text within rich text runs works
* correctly * correctly
*/ */
public void testChangeTextInRichTextRun() throws Exception { public void testChangeTextInRichTextRun() {
Slide slideOne = ssRich.getSlides()[0]; Slide slideOne = ssRich.getSlides()[0];
TextRun[] textRuns = slideOne.getTextRuns(); TextRun[] textRuns = slideOne.getTextRuns();
TextRun trB = textRuns[1]; TextRun trB = textRuns[1];
@ -419,10 +429,10 @@ public final class TestTextRun extends TestCase {
* of the wrong list of potential paragraph properties defined in StyleTextPropAtom. * of the wrong list of potential paragraph properties defined in StyleTextPropAtom.
* *
*/ */
public void testBug41015() throws Exception { public void testBug41015() {
RichTextRun[] rt; RichTextRun[] rt;
SlideShow ppt = new SlideShow(new HSLFSlideShow(System.getProperty("HSLF.testdata.path") + "/bug-41015.ppt")); SlideShow ppt = openSampleSlideShow("bug-41015.ppt");
Slide sl = ppt.getSlides()[0]; Slide sl = ppt.getSlides()[0];
TextRun[] txt = sl.getTextRuns(); TextRun[] txt = sl.getTextRuns();
assertEquals(2, txt.length); assertEquals(2, txt.length);
@ -446,7 +456,7 @@ public final class TestTextRun extends TestCase {
/** /**
* Test creation of TextRun objects. * Test creation of TextRun objects.
*/ */
public void testAddTextRun() throws Exception{ public void testAddTextRun() {
SlideShow ppt = new SlideShow(); SlideShow ppt = new SlideShow();
Slide slide = ppt.createSlide(); Slide slide = ppt.createSlide();

View File

@ -35,13 +35,13 @@ public final class TestCString extends TestCase {
0x43, 00, 0x6F, 00, 0x6D, 00, 0x6D, 00, 0x43, 00, 0x6F, 00, 0x6D, 00, 0x6D, 00,
0x65, 00, 0x6E, 00, 0x74, 00, 0x73, 00 }; 0x65, 00, 0x6E, 00, 0x74, 00, 0x73, 00 };
public void testRecordType() throws Exception { public void testRecordType() {
CString ca = new CString(data_a, 0, data_a.length); CString ca = new CString(data_a, 0, data_a.length);
assertEquals(4026l, ca.getRecordType()); assertEquals(4026l, ca.getRecordType());
CString cb = new CString(data_b, 0, data_a.length); CString cb = new CString(data_b, 0, data_a.length);
assertEquals(4026l, cb.getRecordType()); assertEquals(4026l, cb.getRecordType());
} }
public void testCount() throws Exception { public void testCount() {
CString ca = new CString(data_a, 0, data_a.length); CString ca = new CString(data_a, 0, data_a.length);
assertEquals(0, ca.getOptions()); assertEquals(0, ca.getOptions());
CString cb = new CString(data_b, 0, data_a.length); CString cb = new CString(data_b, 0, data_a.length);
@ -51,7 +51,7 @@ public final class TestCString extends TestCase {
assertEquals(28, ca.getOptions()); assertEquals(28, ca.getOptions());
} }
public void testText() throws Exception { public void testText() {
CString ca = new CString(data_a, 0, data_a.length); CString ca = new CString(data_a, 0, data_a.length);
assertEquals("Hogwarts", ca.getText()); assertEquals("Hogwarts", ca.getText());
CString cb = new CString(data_b, 0, data_a.length); CString cb = new CString(data_b, 0, data_a.length);

View File

@ -35,12 +35,12 @@ public final class TestColorSchemeAtom extends TestCase {
00, 0x99-256, 0x99-256, 00, 0x99-256, 0xCC-256, 00, 00 00, 0x99-256, 0x99-256, 00, 0x99-256, 0xCC-256, 00, 00
}; };
public void testRecordType() throws Exception { public void testRecordType() {
ColorSchemeAtom csa = new ColorSchemeAtom(data_a,0,data_a.length); ColorSchemeAtom csa = new ColorSchemeAtom(data_a,0,data_a.length);
assertEquals(2032l, csa.getRecordType()); assertEquals(2032l, csa.getRecordType());
} }
public void testToRGB() throws Exception { public void testToRGB() {
byte[] rgb = ColorSchemeAtom.splitRGB(3669760); byte[] rgb = ColorSchemeAtom.splitRGB(3669760);
assertEquals(3,rgb.length); assertEquals(3,rgb.length);
@ -49,7 +49,7 @@ public final class TestColorSchemeAtom extends TestCase {
assertEquals(55, rgb[2]); assertEquals(55, rgb[2]);
} }
public void testFromRGB() throws Exception { public void testFromRGB() {
byte[] rgb_a = new byte[] { 0, 255-256, 55 }; byte[] rgb_a = new byte[] { 0, 255-256, 55 };
byte[] rgb_b = new byte[] { 255-256, 127, 79 }; byte[] rgb_b = new byte[] { 255-256, 127, 79 };
@ -60,7 +60,7 @@ public final class TestColorSchemeAtom extends TestCase {
assertEquals( 5210111, ColorSchemeAtom.joinRGB( rgb_b[0], rgb_b[1], rgb_b[2] ) ); assertEquals( 5210111, ColorSchemeAtom.joinRGB( rgb_b[0], rgb_b[1], rgb_b[2] ) );
} }
public void testRGBs() throws Exception { public void testRGBs() {
ColorSchemeAtom csa = new ColorSchemeAtom(data_a,0,data_a.length); ColorSchemeAtom csa = new ColorSchemeAtom(data_a,0,data_a.length);
assertEquals( 16777215 , csa.getBackgroundColourRGB() ); assertEquals( 16777215 , csa.getBackgroundColourRGB() );

View File

@ -84,16 +84,16 @@ public final class TestComment2000 extends TestCase {
private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
public void testRecordType() throws Exception { public void testRecordType() {
Comment2000 ca = new Comment2000(data_a, 0, data_a.length); Comment2000 ca = new Comment2000(data_a, 0, data_a.length);
assertEquals(12000l, ca.getRecordType()); assertEquals(12000l, ca.getRecordType());
} }
public void testAuthor() throws Exception { public void testAuthor() {
Comment2000 ca = new Comment2000(data_a, 0, data_a.length); Comment2000 ca = new Comment2000(data_a, 0, data_a.length);
assertEquals("Dumbledore", ca.getAuthor()); assertEquals("Dumbledore", ca.getAuthor());
assertEquals("D", ca.getAuthorInitials()); assertEquals("D", ca.getAuthorInitials());
} }
public void testText() throws Exception { public void testText() {
Comment2000 ca = new Comment2000(data_a, 0, data_a.length); Comment2000 ca = new Comment2000(data_a, 0, data_a.length);
assertEquals("Yes, they certainly are, aren't they!", ca.getText()); assertEquals("Yes, they certainly are, aren't they!", ca.getText());
} }

View File

@ -47,7 +47,7 @@ public final class TestComment2000Atom extends TestCase {
private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
public void testRecordType() throws Exception { public void testRecordType() {
Comment2000Atom ca = new Comment2000Atom(data_a, 0, data_a.length); Comment2000Atom ca = new Comment2000Atom(data_a, 0, data_a.length);
assertEquals(12001l, ca.getRecordType()); assertEquals(12001l, ca.getRecordType());
} }
@ -65,7 +65,7 @@ public final class TestComment2000Atom extends TestCase {
assertEquals(exp_b, cb.getDate()); assertEquals(exp_b, cb.getDate());
} }
public void testGetNums() throws Exception { public void testGetNums() {
Comment2000Atom ca = new Comment2000Atom(data_a, 0, data_a.length); Comment2000Atom ca = new Comment2000Atom(data_a, 0, data_a.length);
Comment2000Atom cb = new Comment2000Atom(data_b, 0, data_b.length); Comment2000Atom cb = new Comment2000Atom(data_b, 0, data_b.length);
@ -75,7 +75,7 @@ public final class TestComment2000Atom extends TestCase {
assertEquals(5, cb.getNumber()); assertEquals(5, cb.getNumber());
} }
public void testGetPos() throws Exception { public void testGetPos() {
Comment2000Atom ca = new Comment2000Atom(data_a, 0, data_a.length); Comment2000Atom ca = new Comment2000Atom(data_a, 0, data_a.length);
Comment2000Atom cb = new Comment2000Atom(data_b, 0, data_b.length); Comment2000Atom cb = new Comment2000Atom(data_b, 0, data_b.length);

View File

@ -17,7 +17,6 @@
package org.apache.poi.hslf.record; package org.apache.poi.hslf.record;
import junit.framework.TestCase; import junit.framework.TestCase;
import java.io.*; import java.io.*;
@ -25,8 +24,7 @@ import org.apache.poi.hslf.HSLFSlideShow;
import org.apache.poi.poifs.filesystem.*; import org.apache.poi.poifs.filesystem.*;
/** /**
* Tests that Document works properly * Tests that Document works properly (Also tests Environment while we're at it)
* (Also tests Environment while we're at it)
* *
* @author Nick Burch (nick at torchbox dot com) * @author Nick Burch (nick at torchbox dot com)
*/ */
@ -54,36 +52,30 @@ public final class TestDocument extends TestCase {
throw new IllegalStateException("No Document record found"); throw new IllegalStateException("No Document record found");
} }
public void testRecordType() throws Exception { public void testRecordType() {
Document dr = getDocRecord(); Document dr = getDocRecord();
assertEquals(1000, dr.getRecordType()); assertEquals(1000, dr.getRecordType());
} }
public void testChildRecords() throws Exception { public void testChildRecords() {
Document dr = getDocRecord(); Document dr = getDocRecord();
assertNotNull(dr.getDocumentAtom()); assertNotNull(dr.getDocumentAtom());
assertTrue(dr.getDocumentAtom() instanceof DocumentAtom);
assertNotNull(dr.getEnvironment()); assertNotNull(dr.getEnvironment());
assertTrue(dr.getEnvironment() instanceof Environment);
assertNotNull(dr.getSlideListWithTexts()); assertNotNull(dr.getSlideListWithTexts());
assertEquals(3, dr.getSlideListWithTexts().length); assertEquals(3, dr.getSlideListWithTexts().length);
assertNotNull(dr.getSlideListWithTexts()[0]); assertNotNull(dr.getSlideListWithTexts()[0]);
assertTrue(dr.getSlideListWithTexts()[0] instanceof SlideListWithText);
assertNotNull(dr.getSlideListWithTexts()[1]); assertNotNull(dr.getSlideListWithTexts()[1]);
assertTrue(dr.getSlideListWithTexts()[1] instanceof SlideListWithText);
assertNotNull(dr.getSlideListWithTexts()[2]); assertNotNull(dr.getSlideListWithTexts()[2]);
assertTrue(dr.getSlideListWithTexts()[2] instanceof SlideListWithText);
} }
public void testEnvironment() throws Exception { public void testEnvironment() {
Document dr = getDocRecord(); Document dr = getDocRecord();
Environment env = dr.getEnvironment(); Environment env = dr.getEnvironment();
assertEquals(1010, env.getRecordType()); assertEquals(1010, env.getRecordType());
assertNotNull(env.getFontCollection()); assertNotNull(env.getFontCollection());
assertTrue(env.getFontCollection() instanceof FontCollection);
} }
// No need to check re-writing - hslf.TestReWrite does all that for us // No need to check re-writing - hslf.TestReWrite does all that for us

View File

@ -34,11 +34,11 @@ public final class TestDocumentAtom extends TestCase {
0x05, 0, 0, 0, 0x0A, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0x05, 0, 0, 0, 0x0A, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0,
1, 0, 0, 0, 0, 0, 0, 1 }; 1, 0, 0, 0, 0, 0, 0, 1 };
public void testRecordType() throws Exception { public void testRecordType() {
DocumentAtom da = new DocumentAtom(data_a, 0, data_a.length); DocumentAtom da = new DocumentAtom(data_a, 0, data_a.length);
assertEquals(1001l, da.getRecordType()); assertEquals(1001l, da.getRecordType());
} }
public void testSizeAndZoom() throws Exception { public void testSizeAndZoom() {
DocumentAtom da = new DocumentAtom(data_a, 0, data_a.length); DocumentAtom da = new DocumentAtom(data_a, 0, data_a.length);
assertEquals(5760l, da.getSlideSizeX()); assertEquals(5760l, da.getSlideSizeX());
assertEquals(4320l, da.getSlideSizeY()); assertEquals(4320l, da.getSlideSizeY());
@ -48,17 +48,17 @@ public final class TestDocumentAtom extends TestCase {
assertEquals(5l, da.getServerZoomFrom()); assertEquals(5l, da.getServerZoomFrom());
assertEquals(10l, da.getServerZoomTo()); assertEquals(10l, da.getServerZoomTo());
} }
public void testMasterPersist() throws Exception { public void testMasterPersist() {
DocumentAtom da = new DocumentAtom(data_a, 0, data_a.length); DocumentAtom da = new DocumentAtom(data_a, 0, data_a.length);
assertEquals(2l, da.getNotesMasterPersist()); assertEquals(2l, da.getNotesMasterPersist());
assertEquals(0l, da.getHandoutMasterPersist()); assertEquals(0l, da.getHandoutMasterPersist());
} }
public void testSlideDetails() throws Exception { public void testSlideDetails() {
DocumentAtom da = new DocumentAtom(data_a, 0, data_a.length); DocumentAtom da = new DocumentAtom(data_a, 0, data_a.length);
assertEquals(1, da.getFirstSlideNum()); assertEquals(1, da.getFirstSlideNum());
assertEquals(0, da.getSlideSizeType()); assertEquals(0, da.getSlideSizeType());
} }
public void testBooleans() throws Exception { public void testBooleans() {
DocumentAtom da = new DocumentAtom(data_a, 0, data_a.length); DocumentAtom da = new DocumentAtom(data_a, 0, data_a.length);
assertEquals(false, da.getSaveWithFonts()); assertEquals(false, da.getSaveWithFonts());
assertEquals(false, da.getOmitTitlePlace()); assertEquals(false, da.getOmitTitlePlace());

View File

@ -69,7 +69,7 @@ public final class TestExControl extends TestCase {
0x65, 0x00, 0x63, 0x00, 0x74, 0x00 0x65, 0x00, 0x63, 0x00, 0x74, 0x00
}; };
public void testRead() throws Exception { public void testRead() {
ExControl record = new ExControl(data, 0, data.length); ExControl record = new ExControl(data, 0, data.length);
assertEquals(RecordTypes.ExControl.typeID, record.getRecordType()); assertEquals(RecordTypes.ExControl.typeID, record.getRecordType());
@ -120,5 +120,4 @@ public final class TestExControl extends TestCase {
assertEquals(data.length, b.length); assertEquals(data.length, b.length);
assertTrue(Arrays.equals(data, b)); assertTrue(Arrays.equals(data, b));
} }
} }

View File

@ -48,7 +48,7 @@ public final class TestExVideoContainer extends TestCase {
public void testRead() throws Exception { public void testRead() {
ExVideoContainer record = new ExVideoContainer(data, 0, data.length); ExVideoContainer record = new ExVideoContainer(data, 0, data.length);
assertEquals(RecordTypes.ExVideoContainer.typeID, record.getRecordType()); assertEquals(RecordTypes.ExVideoContainer.typeID, record.getRecordType());

View File

@ -40,7 +40,7 @@ public final class TestFontCollection extends TestCase {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7C, 0xDA-256, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7C, 0xDA-256, 0x12, 0x00,
0x28, 0xDD-256, 0x0D, 0x30, 0x00, 0x00, 0x04, 0x00 }; 0x28, 0xDD-256, 0x0D, 0x30, 0x00, 0x00, 0x04, 0x00 };
public void testFonts() throws Exception { public void testFonts() {
FontCollection fonts = new FontCollection(data, 0, data.length); FontCollection fonts = new FontCollection(data, 0, data.length);
Record[] child = fonts.getChildRecords(); Record[] child = fonts.getChildRecords();
assertEquals(child.length, 1); assertEquals(child.length, 1);
@ -49,7 +49,7 @@ public final class TestFontCollection extends TestCase {
assertEquals(fnt.getFontName(), "Times New Roman"); assertEquals(fnt.getFontName(), "Times New Roman");
} }
public void testAddFont() throws Exception { public void testAddFont() {
FontCollection fonts = new FontCollection(data, 0, data.length); FontCollection fonts = new FontCollection(data, 0, data.length);
int idx = fonts.addFont("Times New Roman"); int idx = fonts.addFont("Times New Roman");
assertEquals(idx, 0); assertEquals(idx, 0);

View File

@ -33,7 +33,7 @@ public final class TestHeadersFootersAtom extends TestCase {
0x00, 0x00, (byte)0xDA, 0x0F, 0x04, 0x00, 0x00, 00, 0x00, 0x00, (byte)0xDA, 0x0F, 0x04, 0x00, 0x00, 00,
0x00, 0x00, 0x23, 0x00 }; 0x00, 0x00, 0x23, 0x00 };
public void testRead() throws Exception { public void testRead() {
HeadersFootersAtom record = new HeadersFootersAtom(data, 0, data.length); HeadersFootersAtom record = new HeadersFootersAtom(data, 0, data.length);
assertEquals(RecordTypes.HeadersFootersAtom.typeID, record.getRecordType()); assertEquals(RecordTypes.HeadersFootersAtom.typeID, record.getRecordType());
@ -70,7 +70,7 @@ public final class TestHeadersFootersAtom extends TestCase {
assertTrue(Arrays.equals(data, b)); assertTrue(Arrays.equals(data, b));
} }
public void testFlags() throws Exception { public void testFlags() {
HeadersFootersAtom record = new HeadersFootersAtom(); HeadersFootersAtom record = new HeadersFootersAtom();
//in a new record all the bits are 0 //in a new record all the bits are 0
@ -87,6 +87,5 @@ public final class TestHeadersFootersAtom extends TestCase {
record.setFlag(HeadersFootersAtom.fHasTodayDate, false); record.setFlag(HeadersFootersAtom.fHasTodayDate, false);
assertFalse(record.getFlag(HeadersFootersAtom.fHasTodayDate)); assertFalse(record.getFlag(HeadersFootersAtom.fHasTodayDate));
} }
} }

View File

@ -50,7 +50,7 @@ public final class TestHeadersFootersContainer extends TestCase {
0x6F, 0x00, 0x6F, 0x00, 0x74, 0x00, 0x65, 0x00, 0x72, 0x00 0x6F, 0x00, 0x6F, 0x00, 0x74, 0x00, 0x65, 0x00, 0x72, 0x00
}; };
public void testReadSlideHeadersFootersContainer() throws Exception { public void testReadSlideHeadersFootersContainer() {
HeadersFootersContainer record = new HeadersFootersContainer(slideData, 0, slideData.length); HeadersFootersContainer record = new HeadersFootersContainer(slideData, 0, slideData.length);
assertEquals(RecordTypes.HeadersFooters.typeID, record.getRecordType()); assertEquals(RecordTypes.HeadersFooters.typeID, record.getRecordType());
assertEquals(HeadersFootersContainer.SlideHeadersFootersContainer, record.getOptions()); assertEquals(HeadersFootersContainer.SlideHeadersFootersContainer, record.getOptions());
@ -103,7 +103,7 @@ public final class TestHeadersFootersContainer extends TestCase {
assertTrue(Arrays.equals(slideData, b)); assertTrue(Arrays.equals(slideData, b));
} }
public void testReadNotesHeadersFootersContainer() throws Exception { public void testReadNotesHeadersFootersContainer() {
HeadersFootersContainer record = new HeadersFootersContainer(notesData, 0, notesData.length); HeadersFootersContainer record = new HeadersFootersContainer(notesData, 0, notesData.length);
assertEquals(RecordTypes.HeadersFooters.typeID, record.getRecordType()); assertEquals(RecordTypes.HeadersFooters.typeID, record.getRecordType());
assertEquals(HeadersFootersContainer.NotesHeadersFootersContainer, record.getOptions()); assertEquals(HeadersFootersContainer.NotesHeadersFootersContainer, record.getOptions());

View File

@ -39,12 +39,12 @@ public class TestInteractiveInfo extends TestCase {
04, 00, 00, 00, 8, 00, 00, 00 04, 00, 00, 00, 8, 00, 00, 00
}; };
public void testRecordType() throws Exception { public void testRecordType() {
InteractiveInfo ii = new InteractiveInfo(data_a, 0, data_a.length); InteractiveInfo ii = new InteractiveInfo(data_a, 0, data_a.length);
assertEquals(4082, ii.getRecordType()); assertEquals(4082, ii.getRecordType());
} }
public void testGetChildDetails() throws Exception { public void testGetChildDetails() {
InteractiveInfo ii = new InteractiveInfo(data_a, 0, data_a.length); InteractiveInfo ii = new InteractiveInfo(data_a, 0, data_a.length);
InteractiveInfoAtom ia = ii.getInteractiveInfoAtom(); InteractiveInfoAtom ia = ii.getInteractiveInfoAtom();

View File

@ -31,11 +31,11 @@ public final class TestNotesAtom extends TestCase {
private byte[] data_a = new byte[] { 1, 0, 0xF1-256, 3, 8, 0, 0, 0, private byte[] data_a = new byte[] { 1, 0, 0xF1-256, 3, 8, 0, 0, 0,
0, 0, 0, 0x80-256, 0, 0, 0x0D, 0x30 }; 0, 0, 0, 0x80-256, 0, 0, 0x0D, 0x30 };
public void testRecordType() throws Exception { public void testRecordType() {
NotesAtom na = new NotesAtom(data_a, 0, data_a.length); NotesAtom na = new NotesAtom(data_a, 0, data_a.length);
assertEquals(1009l, na.getRecordType()); assertEquals(1009l, na.getRecordType());
} }
public void testFlags() throws Exception { public void testFlags() {
NotesAtom na = new NotesAtom(data_a, 0, data_a.length); NotesAtom na = new NotesAtom(data_a, 0, data_a.length);
assertEquals(0x80000000, na.getSlideID()); assertEquals(0x80000000, na.getSlideID());
assertEquals(false, na.getFollowMasterObjects()); assertEquals(false, na.getFollowMasterObjects());

View File

@ -26,19 +26,19 @@ import junit.framework.TestCase;
* @author Nick Burch (nick at torchbox dot com) * @author Nick Burch (nick at torchbox dot com)
*/ */
public final class TestRecordTypes extends TestCase { public final class TestRecordTypes extends TestCase {
public void testPPTNameLookups() throws Exception { public void testPPTNameLookups() {
assertEquals("MainMaster", RecordTypes.recordName(1016)); assertEquals("MainMaster", RecordTypes.recordName(1016));
assertEquals("TextBytesAtom", RecordTypes.recordName(4008)); assertEquals("TextBytesAtom", RecordTypes.recordName(4008));
assertEquals("VBAInfo", RecordTypes.recordName(1023)); assertEquals("VBAInfo", RecordTypes.recordName(1023));
} }
public void testEscherNameLookups() throws Exception { public void testEscherNameLookups() {
assertEquals("EscherDggContainer", RecordTypes.recordName(0xf000)); assertEquals("EscherDggContainer", RecordTypes.recordName(0xf000));
assertEquals("EscherClientTextbox", RecordTypes.recordName(0xf00d)); assertEquals("EscherClientTextbox", RecordTypes.recordName(0xf00d));
assertEquals("EscherSelection", RecordTypes.recordName(0xf119)); assertEquals("EscherSelection", RecordTypes.recordName(0xf119));
} }
public void testPPTClassLookups() throws Exception { public void testPPTClassLookups() {
assertEquals(Slide.class, RecordTypes.recordHandlingClass(1006)); assertEquals(Slide.class, RecordTypes.recordHandlingClass(1006));
assertEquals(TextCharsAtom.class, RecordTypes.recordHandlingClass(4000)); assertEquals(TextCharsAtom.class, RecordTypes.recordHandlingClass(4000));
assertEquals(TextBytesAtom.class, RecordTypes.recordHandlingClass(4008)); assertEquals(TextBytesAtom.class, RecordTypes.recordHandlingClass(4008));
@ -49,7 +49,7 @@ public final class TestRecordTypes extends TestCase {
assertEquals(UnknownRecordPlaceholder.class, RecordTypes.recordHandlingClass(2019)); assertEquals(UnknownRecordPlaceholder.class, RecordTypes.recordHandlingClass(2019));
} }
public void testEscherClassLookups() throws Exception { public void testEscherClassLookups() {
// Should all come back with null, as DDF handles them // Should all come back with null, as DDF handles them
assertEquals(null, RecordTypes.recordHandlingClass(0xf000)); assertEquals(null, RecordTypes.recordHandlingClass(0xf000));
assertEquals(null, RecordTypes.recordHandlingClass(0xf001)); assertEquals(null, RecordTypes.recordHandlingClass(0xf001));

View File

@ -33,11 +33,11 @@ public final class TestSlideAtom extends TestCase {
0, 0, 0, 0, 0x0F, 0x10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x80-256, 0, 0, 0, 0, 0x0F, 0x10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x80-256,
0, 1, 0, 0, 7, 0, 0x0C, 0x30 }; 0, 1, 0, 0, 7, 0, 0x0C, 0x30 };
public void testRecordType() throws Exception { public void testRecordType() {
SlideAtom sa = new SlideAtom(data_a, 0, data_a.length); SlideAtom sa = new SlideAtom(data_a, 0, data_a.length);
assertEquals(1007l, sa.getRecordType()); assertEquals(1007l, sa.getRecordType());
} }
public void testFlags() throws Exception { public void testFlags() {
SlideAtom sa = new SlideAtom(data_a, 0, data_a.length); SlideAtom sa = new SlideAtom(data_a, 0, data_a.length);
// First 12 bytes are a SSlideLayoutAtom, checked elsewhere // First 12 bytes are a SSlideLayoutAtom, checked elsewhere
@ -51,7 +51,7 @@ public final class TestSlideAtom extends TestCase {
assertEquals(true, sa.getFollowMasterScheme()); assertEquals(true, sa.getFollowMasterScheme());
assertEquals(true, sa.getFollowMasterBackground()); assertEquals(true, sa.getFollowMasterBackground());
} }
public void testSSlideLayoutAtom() throws Exception { public void testSSlideLayoutAtom() {
SlideAtom sa = new SlideAtom(data_a, 0, data_a.length); SlideAtom sa = new SlideAtom(data_a, 0, data_a.length);
SSlideLayoutAtom ssla = sa.getSSlideLayoutAtom(); SSlideLayoutAtom ssla = sa.getSSlideLayoutAtom();

View File

@ -32,11 +32,11 @@ public final class TestSlidePersistAtom extends TestCase {
4, 0, 0, 0, 4, 0, 0, 0, 2, 0, 0, 0, 0, 4, 0, 0, 0, 4, 0, 0, 0, 2, 0, 0, 0, 0,
1, 0, 0, 0, 0, 0, 0 }; 1, 0, 0, 0, 0, 0, 0 };
public void testRecordType() throws Exception { public void testRecordType() {
SlidePersistAtom spa = new SlidePersistAtom(data_a, 0, data_a.length); SlidePersistAtom spa = new SlidePersistAtom(data_a, 0, data_a.length);
assertEquals(1011l, spa.getRecordType()); assertEquals(1011l, spa.getRecordType());
} }
public void testFlags() throws Exception { public void testFlags() {
SlidePersistAtom spa = new SlidePersistAtom(data_a, 0, data_a.length); SlidePersistAtom spa = new SlidePersistAtom(data_a, 0, data_a.length);
assertEquals(4, spa.getRefID() ); assertEquals(4, spa.getRefID() );
assertEquals(true, spa.getHasShapesOtherThanPlaceholders() ); assertEquals(true, spa.getHasShapesOtherThanPlaceholders() );

View File

@ -36,7 +36,7 @@ import org.apache.poi.util.HexDump;
*/ */
public final class TestStyleTextPropAtom extends TestCase { public final class TestStyleTextPropAtom extends TestCase {
/** From a real file: a paragraph with 4 different styles */ /** From a real file: a paragraph with 4 different styles */
private byte[] data_a = new byte[] { private static final byte[] data_a = new byte[] {
0, 0, 0xA1-256, 0x0F, 0x2A, 0, 0, 0, 0, 0, 0xA1-256, 0x0F, 0x2A, 0, 0, 0,
0x36, 00, 00, 00, // paragraph is 54 long 0x36, 00, 00, 00, // paragraph is 54 long
00, 00, // (paragraph reserved field) 00, 00, // (paragraph reserved field)
@ -50,7 +50,7 @@ public final class TestStyleTextPropAtom extends TestCase {
00, 00, 0x04, 00, // font.color only 00, 00, 0x04, 00, // font.color only
0xFF-256, 0x33, 00, 0xFE-256 // red 0xFF-256, 0x33, 00, 0xFE-256 // red
}; };
private int data_a_text_len = 0x36-1; private static final int data_a_text_len = 0x36-1;
/** /**
* From a real file: 4 paragraphs with text in 4 different styles: * From a real file: 4 paragraphs with text in 4 different styles:
@ -60,7 +60,7 @@ public final class TestStyleTextPropAtom extends TestCase {
* left aligned+underlined+larger font size (96) * left aligned+underlined+larger font size (96)
* left aligned+underlined+larger font size+red (1) * left aligned+underlined+larger font size+red (1)
*/ */
private byte[] data_b = new byte[] { private static final byte[] data_b = new byte[] {
0, 0, 0xA1-256, 0x0F, 0x80-256, 0, 0, 0, 0, 0, 0xA1-256, 0x0F, 0x80-256, 0, 0, 0,
0x1E, 00, 00, 00, // paragraph is 30 long 0x1E, 00, 00, 00, // paragraph is 30 long
00, 00, // paragraph reserved field 00, 00, // paragraph reserved field
@ -108,14 +108,14 @@ public final class TestStyleTextPropAtom extends TestCase {
0x18, 00, // font size 24 0x18, 00, // font size 24
0xFF-256, 0x33, 00, 0xFE-256 // colour red 0xFF-256, 0x33, 00, 0xFE-256 // colour red
}; };
private int data_b_text_len = 0xB3; private static final int data_b_text_len = 0xB3;
/** /**
* From a real file. Has a mask with more bits * From a real file. Has a mask with more bits
* set than it actually has data for. Shouldn't do, * set than it actually has data for. Shouldn't do,
* but some real files do :( * but some real files do :(
*/ */
private byte[] data_c = new byte[] { private static final byte[] data_c = new byte[] {
0, 0, -95, 15, 62, 0, 0, 0, 0, 0, -95, 15, 62, 0, 0, 0,
123, 0, 0, 0, 0, 0, 48, 8, 123, 0, 0, 0, 0, 0, 48, 8,
10, 0, 1, 0, 0, 0, 0, 0, 10, 0, 1, 0, 0, 0, 0, 0,
@ -131,15 +131,15 @@ public final class TestStyleTextPropAtom extends TestCase {
/** /**
* From a real file supplied for Bug 40143 by tales@great.ufc.br * From a real file supplied for Bug 40143 by tales@great.ufc.br
*/ */
private byte[] data_d = { private static final byte[] data_d = {
0x00, 0x00, 0xA1-256, 0x0F, 0x1E, 0x00, 0x00, 0x00, //header 0x00, 0x00, 0xA1-256, 0x0F, 0x1E, 0x00, 0x00, 0x00, //header
(byte)0xA0, 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x08 , 0x00 , 0x00 , (byte)0xA0, 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x08 , 0x00 , 0x00 ,
0x01 , 0x00, (byte)0xA0 , 0x00 , 0x00 , 0x00 , 0x01 , 0x00 , 0x63 , 0x00 , 0x01 , 0x00, (byte)0xA0 , 0x00 , 0x00 , 0x00 , 0x01 , 0x00 , 0x63 , 0x00 ,
0x01 , 0x00, 0x01 , 0x00 , 0x00, 0x00 , 0x01 , 0x00 , 0x14 , 0x00 0x01 , 0x00, 0x01 , 0x00 , 0x00, 0x00 , 0x01 , 0x00 , 0x14 , 0x00
}; };
private int data_d_text_len = 0xA0-1; private static final int data_d_text_len = 0xA0-1;
public void testRecordType() throws Exception { public void testRecordType() {
StyleTextPropAtom stpa = new StyleTextPropAtom(data_a,0,data_a.length); StyleTextPropAtom stpa = new StyleTextPropAtom(data_a,0,data_a.length);
StyleTextPropAtom stpb = new StyleTextPropAtom(data_b,0,data_b.length); StyleTextPropAtom stpb = new StyleTextPropAtom(data_b,0,data_b.length);
StyleTextPropAtom stpc = new StyleTextPropAtom(data_c,0,data_c.length); StyleTextPropAtom stpc = new StyleTextPropAtom(data_c,0,data_c.length);
@ -149,7 +149,7 @@ public final class TestStyleTextPropAtom extends TestCase {
} }
public void testCharacterStyleCounts() throws Exception { public void testCharacterStyleCounts() {
StyleTextPropAtom stpa = new StyleTextPropAtom(data_a,0,data_a.length); StyleTextPropAtom stpa = new StyleTextPropAtom(data_a,0,data_a.length);
StyleTextPropAtom stpb = new StyleTextPropAtom(data_b,0,data_b.length); StyleTextPropAtom stpb = new StyleTextPropAtom(data_b,0,data_b.length);
@ -223,7 +223,6 @@ public final class TestStyleTextPropAtom extends TestCase {
TextProp tp_1_1 = (TextProp)b_ch_1.getTextPropList().get(0); TextProp tp_1_1 = (TextProp)b_ch_1.getTextPropList().get(0);
TextProp tp_1_2 = (TextProp)b_ch_1.getTextPropList().get(1); TextProp tp_1_2 = (TextProp)b_ch_1.getTextPropList().get(1);
assertEquals(true, tp_1_1 instanceof CharFlagsTextProp); assertEquals(true, tp_1_1 instanceof CharFlagsTextProp);
assertEquals(true, tp_1_2 instanceof TextProp);
assertEquals("font.size", tp_1_2.getName()); assertEquals("font.size", tp_1_2.getName());
assertEquals(20, tp_1_2.getValue()); assertEquals(20, tp_1_2.getValue());
@ -233,8 +232,6 @@ public final class TestStyleTextPropAtom extends TestCase {
TextProp tp_2_2 = (TextProp)b_ch_2.getTextPropList().get(1); TextProp tp_2_2 = (TextProp)b_ch_2.getTextPropList().get(1);
TextProp tp_2_3 = (TextProp)b_ch_2.getTextPropList().get(2); TextProp tp_2_3 = (TextProp)b_ch_2.getTextPropList().get(2);
assertEquals(true, tp_2_1 instanceof CharFlagsTextProp); assertEquals(true, tp_2_1 instanceof CharFlagsTextProp);
assertEquals(true, tp_2_2 instanceof TextProp);
assertEquals(true, tp_2_3 instanceof TextProp);
assertEquals("font.size", tp_2_2.getName()); assertEquals("font.size", tp_2_2.getName());
assertEquals("font.color", tp_2_3.getName()); assertEquals("font.color", tp_2_3.getName());
assertEquals(20, tp_2_2.getValue()); assertEquals(20, tp_2_2.getValue());
@ -243,8 +240,6 @@ public final class TestStyleTextPropAtom extends TestCase {
assertEquals(2,b_ch_3.getTextPropList().size()); assertEquals(2,b_ch_3.getTextPropList().size());
TextProp tp_3_1 = (TextProp)b_ch_3.getTextPropList().get(0); TextProp tp_3_1 = (TextProp)b_ch_3.getTextPropList().get(0);
TextProp tp_3_2 = (TextProp)b_ch_3.getTextPropList().get(1); TextProp tp_3_2 = (TextProp)b_ch_3.getTextPropList().get(1);
assertEquals(true, tp_3_1 instanceof TextProp);
assertEquals(true, tp_3_2 instanceof TextProp);
assertEquals("font.size", tp_3_1.getName()); assertEquals("font.size", tp_3_1.getName());
assertEquals("font.color", tp_3_2.getName()); assertEquals("font.color", tp_3_2.getName());
assertEquals(20, tp_3_1.getValue()); assertEquals(20, tp_3_1.getValue());
@ -255,8 +250,6 @@ public final class TestStyleTextPropAtom extends TestCase {
TextProp tp_4_2 = (TextProp)b_ch_4.getTextPropList().get(1); TextProp tp_4_2 = (TextProp)b_ch_4.getTextPropList().get(1);
TextProp tp_4_3 = (TextProp)b_ch_4.getTextPropList().get(2); TextProp tp_4_3 = (TextProp)b_ch_4.getTextPropList().get(2);
assertEquals(true, tp_4_1 instanceof CharFlagsTextProp); assertEquals(true, tp_4_1 instanceof CharFlagsTextProp);
assertEquals(true, tp_4_2 instanceof TextProp);
assertEquals(true, tp_4_3 instanceof TextProp);
assertEquals("font.index", tp_4_2.getName()); assertEquals("font.index", tp_4_2.getName());
assertEquals("font.size", tp_4_3.getName()); assertEquals("font.size", tp_4_3.getName());
assertEquals(24, tp_4_3.getValue()); assertEquals(24, tp_4_3.getValue());
@ -276,8 +269,6 @@ public final class TestStyleTextPropAtom extends TestCase {
assertEquals(2,b_p_1.getTextPropList().size()); assertEquals(2,b_p_1.getTextPropList().size());
TextProp tp_1_1 = (TextProp)b_p_1.getTextPropList().get(0); TextProp tp_1_1 = (TextProp)b_p_1.getTextPropList().get(0);
TextProp tp_1_2 = (TextProp)b_p_1.getTextPropList().get(1); TextProp tp_1_2 = (TextProp)b_p_1.getTextPropList().get(1);
assertEquals(true, tp_1_1 instanceof TextProp);
assertEquals(true, tp_1_2 instanceof TextProp);
assertEquals("alignment", tp_1_1.getName()); assertEquals("alignment", tp_1_1.getName());
assertEquals("linespacing", tp_1_2.getName()); assertEquals("linespacing", tp_1_2.getName());
assertEquals(0, tp_1_1.getValue()); assertEquals(0, tp_1_1.getValue());
@ -286,8 +277,6 @@ public final class TestStyleTextPropAtom extends TestCase {
// 2nd is centre aligned (default) + normal line spacing // 2nd is centre aligned (default) + normal line spacing
assertEquals(1,b_p_2.getTextPropList().size()); assertEquals(1,b_p_2.getTextPropList().size());
TextProp tp_2_1 = (TextProp)b_p_2.getTextPropList().get(0); TextProp tp_2_1 = (TextProp)b_p_2.getTextPropList().get(0);
assertEquals(true, tp_2_1 instanceof TextProp);
assertEquals(true, tp_1_2 instanceof TextProp);
assertEquals("linespacing", tp_2_1.getName()); assertEquals("linespacing", tp_2_1.getName());
assertEquals(80, tp_2_1.getValue()); assertEquals(80, tp_2_1.getValue());
@ -295,8 +284,6 @@ public final class TestStyleTextPropAtom extends TestCase {
assertEquals(2,b_p_3.getTextPropList().size()); assertEquals(2,b_p_3.getTextPropList().size());
TextProp tp_3_1 = (TextProp)b_p_3.getTextPropList().get(0); TextProp tp_3_1 = (TextProp)b_p_3.getTextPropList().get(0);
TextProp tp_3_2 = (TextProp)b_p_3.getTextPropList().get(1); TextProp tp_3_2 = (TextProp)b_p_3.getTextPropList().get(1);
assertEquals(true, tp_3_1 instanceof TextProp);
assertEquals(true, tp_3_2 instanceof TextProp);
assertEquals("alignment", tp_3_1.getName()); assertEquals("alignment", tp_3_1.getName());
assertEquals("linespacing", tp_3_2.getName()); assertEquals("linespacing", tp_3_2.getName());
assertEquals(2, tp_3_1.getValue()); assertEquals(2, tp_3_1.getValue());
@ -306,8 +293,6 @@ public final class TestStyleTextPropAtom extends TestCase {
assertEquals(2,b_p_4.getTextPropList().size()); assertEquals(2,b_p_4.getTextPropList().size());
TextProp tp_4_1 = (TextProp)b_p_4.getTextPropList().get(0); TextProp tp_4_1 = (TextProp)b_p_4.getTextPropList().get(0);
TextProp tp_4_2 = (TextProp)b_p_4.getTextPropList().get(1); TextProp tp_4_2 = (TextProp)b_p_4.getTextPropList().get(1);
assertEquals(true, tp_4_1 instanceof TextProp);
assertEquals(true, tp_4_2 instanceof TextProp);
assertEquals("alignment", tp_4_1.getName()); assertEquals("alignment", tp_4_1.getName());
assertEquals("linespacing", tp_4_2.getName()); assertEquals("linespacing", tp_4_2.getName());
assertEquals(0, tp_4_1.getValue()); assertEquals(0, tp_4_1.getValue());

View File

@ -38,16 +38,16 @@ public final class TestTextBytesAtom extends TestCase {
0x74, 0x65, 0x73, 0x74, 0x20, 0x74, 0x69, 0x74, 0x6C, 0x65 }; 0x74, 0x65, 0x73, 0x74, 0x20, 0x74, 0x69, 0x74, 0x6C, 0x65 };
private String alt_text = "This is a test title"; private String alt_text = "This is a test title";
public void testRecordType() throws Exception { public void testRecordType() {
TextBytesAtom tba = new TextBytesAtom(data,0,data.length); TextBytesAtom tba = new TextBytesAtom(data,0,data.length);
assertEquals(4008l, tba.getRecordType()); assertEquals(4008l, tba.getRecordType());
} }
public void testTextA() throws Exception { public void testTextA() {
TextBytesAtom tba = new TextBytesAtom(data,0,data.length); TextBytesAtom tba = new TextBytesAtom(data,0,data.length);
assertEquals(data_text, tba.getText()); assertEquals(data_text, tba.getText());
} }
public void testTextB() throws Exception { public void testTextB() {
TextBytesAtom tba = new TextBytesAtom(alt_data,0,alt_data.length); TextBytesAtom tba = new TextBytesAtom(alt_data,0,alt_data.length);
assertEquals(alt_text, tba.getText()); assertEquals(alt_text, tba.getText());
} }

View File

@ -35,16 +35,16 @@ public final class TestTextCharsAtom extends TestCase {
0x54, 0x00, 0x68, 0x00, 0x69, 0x00, 0x73, 0x00, 0xa3-256, 0x01 }; 0x54, 0x00, 0x68, 0x00, 0x69, 0x00, 0x73, 0x00, 0xa3-256, 0x01 };
private String alt_text = "This\u01A3"; private String alt_text = "This\u01A3";
public void testRecordType() throws Exception { public void testRecordType() {
TextCharsAtom tca = new TextCharsAtom(data,0,data.length); TextCharsAtom tca = new TextCharsAtom(data,0,data.length);
assertEquals(4000l, tca.getRecordType()); assertEquals(4000l, tca.getRecordType());
} }
public void testTextA() throws Exception { public void testTextA() {
TextCharsAtom tca = new TextCharsAtom(data,0,data.length); TextCharsAtom tca = new TextCharsAtom(data,0,data.length);
assertEquals(data_text, tca.getText()); assertEquals(data_text, tca.getText());
} }
public void testTextB() throws Exception { public void testTextB() {
TextCharsAtom tca = new TextCharsAtom(alt_data,0,alt_data.length); TextCharsAtom tca = new TextCharsAtom(alt_data,0,alt_data.length);
assertEquals(alt_text, tca.getText()); assertEquals(alt_text, tca.getText());
} }

View File

@ -32,11 +32,11 @@ public final class TestTextHeaderAtom extends TestCase {
private byte[] title_data = new byte[] { 0, 0, 0x9f-256, 0x0f, 4, 0, 0, 0, 0, 0, 0, 0 }; private byte[] title_data = new byte[] { 0, 0, 0x9f-256, 0x0f, 4, 0, 0, 0, 0, 0, 0, 0 };
private byte[] body_data = new byte[] { 0, 0, 0x9f-256, 0x0f, 4, 0, 0, 0, 1, 0, 0, 0 }; private byte[] body_data = new byte[] { 0, 0, 0x9f-256, 0x0f, 4, 0, 0, 0, 1, 0, 0, 0 };
public void testRecordType() throws Exception { public void testRecordType() {
TextHeaderAtom tha = new TextHeaderAtom(notes_data,0,12); TextHeaderAtom tha = new TextHeaderAtom(notes_data,0,12);
assertEquals(3999l, tha.getRecordType()); assertEquals(3999l, tha.getRecordType());
} }
public void testTypes() throws Exception { public void testTypes() {
TextHeaderAtom n_tha = new TextHeaderAtom(notes_data,0,12); TextHeaderAtom n_tha = new TextHeaderAtom(notes_data,0,12);
TextHeaderAtom t_tha = new TextHeaderAtom(title_data,0,12); TextHeaderAtom t_tha = new TextHeaderAtom(title_data,0,12);
TextHeaderAtom b_tha = new TextHeaderAtom(body_data,0,12); TextHeaderAtom b_tha = new TextHeaderAtom(body_data,0,12);

View File

@ -33,11 +33,11 @@ public final class TestUserEditAtom extends TestCase {
00, 00, 00, 00, 00, 0x18, 00, 00, 01, 00, 00, 00, 00, 00, 00, 00, 00, 0x18, 00, 00, 01, 00, 00, 00,
05, 00, 00, 00, 01, 00, 0xF6-256, 77 }; 05, 00, 00, 00, 01, 00, 0xF6-256, 77 };
public void testRecordType() throws Exception { public void testRecordType() {
UserEditAtom uea = new UserEditAtom(data_a, 0, data_a.length); UserEditAtom uea = new UserEditAtom(data_a, 0, data_a.length);
assertEquals(4085l, uea.getRecordType()); assertEquals(4085l, uea.getRecordType());
} }
public void testFlags() throws Exception { public void testFlags() {
UserEditAtom uea = new UserEditAtom(data_a, 0, data_a.length); UserEditAtom uea = new UserEditAtom(data_a, 0, data_a.length);
assertEquals(256, uea.getLastViewedSlideID() ); assertEquals(256, uea.getLastViewedSlideID() );

View File

@ -38,9 +38,9 @@ public final class TestCounts extends TestCase {
ss = new SlideShow(hss); ss = new SlideShow(hss);
} }
public void testSheetsCount() throws Exception { public void testSheetsCount() {
Slide[] slides = ss.getSlides(); Slide[] slides = ss.getSlides();
// Two sheets - master sheet is seperate // Two sheets - master sheet is separate
assertEquals(2, slides.length); assertEquals(2, slides.length);
// They are slides 1+2 // They are slides 1+2
@ -56,7 +56,7 @@ public final class TestCounts extends TestCase {
assertEquals(257, slides[1]._getSheetNumber()); assertEquals(257, slides[1]._getSheetNumber());
} }
public void testNotesCount() throws Exception { public void testNotesCount() {
Notes[] notes = ss.getNotes(); Notes[] notes = ss.getNotes();
// Two sheets -> two notes // Two sheets -> two notes
// Note: there are also notes on the slide master // Note: there are also notes on the slide master

View File

@ -40,7 +40,7 @@ public final class TestMostRecentRecords extends TestCase {
ss = new SlideShow(hss); ss = new SlideShow(hss);
} }
public void testCount() throws Exception { public void testCount() {
// Most recent core records // Most recent core records
Record[] mrcr = ss.getMostRecentCoreRecords(); Record[] mrcr = ss.getMostRecentCoreRecords();
@ -48,7 +48,7 @@ public final class TestMostRecentRecords extends TestCase {
assertEquals(7, mrcr.length); assertEquals(7, mrcr.length);
} }
public void testRightRecordTypes() throws Exception { public void testRightRecordTypes() {
// Most recent core records // Most recent core records
Record[] mrcr = ss.getMostRecentCoreRecords(); Record[] mrcr = ss.getMostRecentCoreRecords();
@ -69,7 +69,7 @@ public final class TestMostRecentRecords extends TestCase {
assertEquals(1008, mrcr[6].getRecordType()); assertEquals(1008, mrcr[6].getRecordType());
} }
public void testCorrectRecords() throws Exception { public void testCorrectRecords() {
// Most recent core records // Most recent core records
Record[] mrcr = ss.getMostRecentCoreRecords(); Record[] mrcr = ss.getMostRecentCoreRecords();

View File

@ -38,7 +38,7 @@ public final class TestNotesText extends TestCase {
ss = new SlideShow(hss); ss = new SlideShow(hss);
} }
public void testNotesOne() throws Exception { public void testNotesOne() {
Notes notes = ss.getNotes()[0]; Notes notes = ss.getNotes()[0];
String[] expectText = new String[] {"These are the notes for page 1"}; String[] expectText = new String[] {"These are the notes for page 1"};
@ -48,7 +48,7 @@ public final class TestNotesText extends TestCase {
} }
} }
public void testNotesTwo() throws Exception { public void testNotesTwo() {
Notes notes = ss.getNotes()[1]; Notes notes = ss.getNotes()[1];
String[] expectText = new String[] {"These are the notes on page two, again lacking formatting"}; String[] expectText = new String[] {"These are the notes on page two, again lacking formatting"};
assertEquals(expectText.length, notes.getTextRuns().length); assertEquals(expectText.length, notes.getTextRuns().length);

View File

@ -34,7 +34,7 @@ public final class TestPictures extends TestCase{
protected File cwd; protected File cwd;
public void setUp() throws Exception { public void setUp() {
cwd = new File(System.getProperty("HSLF.testdata.path")); cwd = new File(System.getProperty("HSLF.testdata.path"));
} }

View File

@ -43,7 +43,7 @@ public final class TestRecordSetup extends TestCase {
ss = new SlideShow(hss); ss = new SlideShow(hss);
} }
public void testHandleParentAwareRecords() throws Exception { public void testHandleParentAwareRecords() {
Record[] records = hss.getRecords(); Record[] records = hss.getRecords();
for(int i=0; i<records.length; i++) { for(int i=0; i<records.length; i++) {
ensureParentAware(records[i],null); ensureParentAware(records[i],null);

View File

@ -38,7 +38,7 @@ public final class TestSheetText extends TestCase {
ss = new SlideShow(hss); ss = new SlideShow(hss);
} }
public void testSheetOne() throws Exception { public void testSheetOne() {
Sheet slideOne = ss.getSlides()[0]; Sheet slideOne = ss.getSlides()[0];
String[] expectText = new String[] {"This is a test title","This is a test subtitle\nThis is on page 1"}; String[] expectText = new String[] {"This is a test title","This is a test subtitle\nThis is on page 1"};
@ -48,7 +48,7 @@ public final class TestSheetText extends TestCase {
} }
} }
public void testSheetTwo() throws Exception { public void testSheetTwo() {
Sheet slideTwo = ss.getSlides()[1]; Sheet slideTwo = ss.getSlides()[1];
String[] expectText = new String[] {"This is the title on page 2","This is page two\nIt has several blocks of text\nNone of them have formatting"}; String[] expectText = new String[] {"This is the title on page 2","This is page two\nIt has several blocks of text\nNone of them have formatting"};
assertEquals(expectText.length, slideTwo.getTextRuns().length); assertEquals(expectText.length, slideTwo.getTextRuns().length);
@ -80,7 +80,7 @@ public final class TestSheetText extends TestCase {
"Can they co-exist?\n\n" + "Can they co-exist?\n\n" +
"Gay Harley\n" + "Gay Harley\n" +
"Clean Development Alliance\n" + "Clean Development Alliance\n" +
"COP 11 \u2013 MOP 1\n" + // special long hyphon "COP 11 \u2013 MOP 1\n" + // special long hyphen
"December 5, 2005\n"; "December 5, 2005\n";
assertEquals(1, s.getTextRuns().length); assertEquals(1, s.getTextRuns().length);

View File

@ -17,7 +17,6 @@
package org.apache.poi.hslf.usermodel; package org.apache.poi.hslf.usermodel;
import junit.framework.TestCase; import junit.framework.TestCase;
import org.apache.poi.hslf.*; import org.apache.poi.hslf.*;
import org.apache.poi.hslf.model.*; import org.apache.poi.hslf.model.*;
@ -48,16 +47,13 @@ public final class TestSlideOrdering extends TestCase {
/** /**
* Test the simple case - record order matches slide order * Test the simple case - record order matches slide order
*/ */
public void testSimpleCase() throws Exception { public void testSimpleCase() {
assertEquals(2, ssA.getSlides().length); assertEquals(2, ssA.getSlides().length);
Slide s1 = ssA.getSlides()[0]; Slide s1 = ssA.getSlides()[0];
Slide s2 = ssA.getSlides()[1]; Slide s2 = ssA.getSlides()[1];
String[] firstTRs = new String[] { String[] firstTRs = new String[] { "This is a test title", "This is the title on page 2" };
"This is a test title",
"This is the title on page 2"
};
assertEquals(firstTRs[0], s1.getTextRuns()[0].getText()); assertEquals(firstTRs[0], s1.getTextRuns()[0].getText());
assertEquals(firstTRs[1], s2.getTextRuns()[0].getText()); assertEquals(firstTRs[1], s2.getTextRuns()[0].getText());
@ -66,18 +62,14 @@ public final class TestSlideOrdering extends TestCase {
/** /**
* Test the complex case - record order differs from slide order * Test the complex case - record order differs from slide order
*/ */
public void testComplexCase() throws Exception { public void testComplexCase() {
assertEquals(3, ssB.getSlides().length); assertEquals(3, ssB.getSlides().length);
Slide s1 = ssB.getSlides()[0]; Slide s1 = ssB.getSlides()[0];
Slide s2 = ssB.getSlides()[1]; Slide s2 = ssB.getSlides()[1];
Slide s3 = ssB.getSlides()[2]; Slide s3 = ssB.getSlides()[2];
String[] firstTRs = new String[] { String[] firstTRs = new String[] { "Slide 1", "Slide 2", "Slide 3" };
"Slide 1",
"Slide 2",
"Slide 3"
};
assertEquals(firstTRs[0], s1.getTextRuns()[0].getText()); assertEquals(firstTRs[0], s1.getTextRuns()[0].getText());
assertEquals(firstTRs[1], s2.getTextRuns()[0].getText()); assertEquals(firstTRs[1], s2.getTextRuns()[0].getText());
@ -87,8 +79,10 @@ public final class TestSlideOrdering extends TestCase {
/** /**
* Assert that the order of slides is correct. * Assert that the order of slides is correct.
* *
* @param filename file name of the slide show to assert * @param filename
* @param titles array of reference slide titles * file name of the slide show to assert
* @param titles
* array of reference slide titles
*/ */
protected void assertSlideOrdering(String filename, String[] titles) throws Exception { protected void assertSlideOrdering(String filename, String[] titles) throws Exception {
SlideShow ppt = new SlideShow(new HSLFSlideShow(filename)); SlideShow ppt = new SlideShow(new HSLFSlideShow(filename));
@ -104,36 +98,23 @@ public final class TestSlideOrdering extends TestCase {
public void testTitles() throws Exception { public void testTitles() throws Exception {
String dirname = System.getProperty("HSLF.testdata.path"); String dirname = System.getProperty("HSLF.testdata.path");
assertSlideOrdering(dirname + "/basic_test_ppt_file.ppt", assertSlideOrdering(dirname + "/basic_test_ppt_file.ppt", new String[] {
new String[]{ "This is a test title", "This is the title on page 2" });
"This is a test title",
"This is the title on page 2"
});
assertSlideOrdering(dirname + "/incorrect_slide_order.ppt", assertSlideOrdering(dirname + "/incorrect_slide_order.ppt", new String[] { "Slide 1",
new String[]{ "Slide 2", "Slide 3" });
"Slide 1",
"Slide 2",
"Slide 3"
});
assertSlideOrdering(dirname + "/next_test_ppt_file.ppt", assertSlideOrdering(dirname + "/next_test_ppt_file.ppt", new String[] {
new String[]{ "This is a test title", "This is the title on page 2" });
"This is a test title",
"This is the title on page 2"
});
assertSlideOrdering(dirname + "/Single_Coloured_Page.ppt", assertSlideOrdering(dirname + "/Single_Coloured_Page.ppt",
new String[]{ new String[] { "This is a title, it" + (char) 0x2019 + "s in black" });
"This is a title, it" + (char)0x2019 +"s in black"
});
assertSlideOrdering(dirname + "/Single_Coloured_Page_With_Fonts_and_Alignments.ppt", assertSlideOrdering(dirname + "/Single_Coloured_Page_With_Fonts_and_Alignments.ppt",
new String[]{ new String[] { "This is a title, it" + (char) 0x2019 + "s in black" });
"This is a title, it"+ (char)0x2019 +"s in black"
});
assertSlideOrdering(dirname + "/ParagraphStylesShorterThanCharStyles.ppt", assertSlideOrdering(
dirname + "/ParagraphStylesShorterThanCharStyles.ppt",
new String[] { new String[] {
"ROMANCE: AN ANALYSIS", "ROMANCE: AN ANALYSIS",
"AGENDA", "AGENDA",
@ -148,7 +129,6 @@ public final class TestSlideOrdering extends TestCase {
"In summary we can say that we are on the right track, but we must remain aware of possible roadblocks ", "In summary we can say that we are on the right track, but we must remain aware of possible roadblocks ",
"THE ANSWER", "THE ANSWER",
"Unfortunately a huge disconnect exists between my needs and your existing service", "Unfortunately a huge disconnect exists between my needs and your existing service",
"SUMMARY", "SUMMARY", });
});
} }
} }

View File

@ -31,12 +31,11 @@ import junit.framework.TestCase;
* @author Travis Ferguson * @author Travis Ferguson
* *
*/ */
public class TestBlankFileRead extends TestCase { public final class TestBlankFileRead extends TestCase {
private MAPIMessage mapiMessage; private MAPIMessage mapiMessage;
/** /**
* Initialize this test, load up the blank.msg mapi message. * Initialize this test, load up the blank.msg mapi message.
* @throws IOException
*/ */
public TestBlankFileRead() throws IOException { public TestBlankFileRead() throws IOException {
String dirname = System.getProperty("HSMF.testdata.path"); String dirname = System.getProperty("HSMF.testdata.path");
@ -45,8 +44,6 @@ public class TestBlankFileRead extends TestCase {
/** /**
* Check if we can read the body of the blank message, we expect "". * Check if we can read the body of the blank message, we expect "".
*
* @throws Exception
*/ */
public void testReadBody() throws Exception { public void testReadBody() throws Exception {
try { try {
@ -61,8 +58,6 @@ public class TestBlankFileRead extends TestCase {
/** /**
* Test to see if we can read the CC Chunk. * Test to see if we can read the CC Chunk.
* @throws ChunkNotFoundException
*
*/ */
public void testReadDisplayCC() throws ChunkNotFoundException { public void testReadDisplayCC() throws ChunkNotFoundException {
String obtained = mapiMessage.getDisplayCC(); String obtained = mapiMessage.getDisplayCC();
@ -73,8 +68,6 @@ public class TestBlankFileRead extends TestCase {
/** /**
* Test to see if we can read the CC Chunk. * Test to see if we can read the CC Chunk.
* @throws ChunkNotFoundException
*
*/ */
public void testReadDisplayTo() throws ChunkNotFoundException { public void testReadDisplayTo() throws ChunkNotFoundException {
String obtained = mapiMessage.getDisplayTo(); String obtained = mapiMessage.getDisplayTo();
@ -85,10 +78,8 @@ public class TestBlankFileRead extends TestCase {
/** /**
* Test to see if we can read the FROM Chunk. * Test to see if we can read the FROM Chunk.
* @throws ChunkNotFoundException
*
*/ */
public void testReadDisplayFrom() throws ChunkNotFoundException { public void testReadDisplayFrom() {
try { try {
mapiMessage.getDisplayFrom(); mapiMessage.getDisplayFrom();
} catch(ChunkNotFoundException exp) { } catch(ChunkNotFoundException exp) {
@ -100,8 +91,6 @@ public class TestBlankFileRead extends TestCase {
/** /**
* Test to see if we can read the CC Chunk. * Test to see if we can read the CC Chunk.
* @throws ChunkNotFoundException
*
*/ */
public void testReadDisplayBCC() throws ChunkNotFoundException { public void testReadDisplayBCC() throws ChunkNotFoundException {
String obtained = mapiMessage.getDisplayBCC(); String obtained = mapiMessage.getDisplayBCC();
@ -127,7 +116,7 @@ public class TestBlankFileRead extends TestCase {
* *
* @throws Exception * @throws Exception
*/ */
public void testReadConversationTopic() throws Exception { public void testReadConversationTopic() {
try { try {
mapiMessage.getConversationTopic(); mapiMessage.getConversationTopic();
} catch(ChunkNotFoundException exp) { } catch(ChunkNotFoundException exp) {

View File

@ -19,13 +19,14 @@ package org.apache.poi.hwpf;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.IOException;
import java.util.List; import java.util.List;
import junit.framework.TestCase;
import org.apache.poi.hwpf.model.PicturesTable; import org.apache.poi.hwpf.model.PicturesTable;
import org.apache.poi.hwpf.usermodel.Picture; import org.apache.poi.hwpf.usermodel.Picture;
import junit.framework.TestCase;
/** /**
* Test picture support in HWPF * Test picture support in HWPF
* @author nick * @author nick
@ -41,7 +42,7 @@ public final class TestHWPFPictures extends TestCase {
private String imgCFile; private String imgCFile;
private String imgDFile; private String imgDFile;
protected void setUp() throws Exception { protected void setUp() {
String dirname = System.getProperty("HWPF.testdata.path"); String dirname = System.getProperty("HWPF.testdata.path");
docAFile = dirname + "/testPictures.doc"; docAFile = dirname + "/testPictures.doc";
@ -134,8 +135,7 @@ public final class TestHWPFPictures extends TestCase {
* Pending the missing files being uploaded to * Pending the missing files being uploaded to
* bug #44937 * bug #44937
*/ */
public void BROKENtestEscherDrawing() throws Exception public void BROKENtestEscherDrawing() throws Exception {
{
HWPFDocument docD = new HWPFDocument(new FileInputStream(docDFile)); HWPFDocument docD = new HWPFDocument(new FileInputStream(docDFile));
List allPictures = docD.getPicturesTable().getAllPictures(); List allPictures = docD.getPicturesTable().getAllPictures();
@ -157,8 +157,9 @@ public final class TestHWPFPictures extends TestCase {
} }
} }
private byte[] readFile(String file) throws Exception { private static byte[] readFile(String file) {
ByteArrayOutputStream baos = new ByteArrayOutputStream(); ByteArrayOutputStream baos = new ByteArrayOutputStream();
try {
FileInputStream fis = new FileInputStream(file); FileInputStream fis = new FileInputStream(file);
byte[] buffer = new byte[1024]; byte[] buffer = new byte[1024];
@ -169,6 +170,10 @@ public final class TestHWPFPictures extends TestCase {
baos.write(buffer,0,read); baos.write(buffer,0,read);
} }
} }
fis.close();
} catch (IOException e) {
throw new RuntimeException(e);
}
return baos.toByteArray(); return baos.toByteArray();
} }

View File

@ -109,7 +109,7 @@ public final class TestHWPFRangeParts extends TestCase {
); );
} }
public void testBasics() throws Exception { public void testBasics() {
// First check the start and end bits // First check the start and end bits
assertEquals( assertEquals(
0, 0,
@ -142,7 +142,7 @@ public final class TestHWPFRangeParts extends TestCase {
); );
} }
public void testContents() throws Exception { public void testContents() {
Range r; Range r;
// Now check the real ranges // Now check the real ranges
@ -179,7 +179,7 @@ public final class TestHWPFRangeParts extends TestCase {
); );
} }
public void testBasicsUnicode() throws Exception { public void testBasicsUnicode() {
// First check the start and end bits // First check the start and end bits
assertEquals( assertEquals(
0, 0,
@ -213,7 +213,7 @@ public final class TestHWPFRangeParts extends TestCase {
); );
} }
public void testContentsUnicode() throws Exception { public void testContentsUnicode() {
Range r; Range r;
// Now check the real ranges // Now check the real ranges

View File

@ -111,7 +111,7 @@ public final class TestWordExtractor extends TestCase {
/** /**
* Test textPieces based extraction * Test textPieces based extraction
*/ */
public void testExtractFromTextPieces() throws Exception { public void testExtractFromTextPieces() {
String text = extractor.getTextFromPieces(); String text = extractor.getTextFromPieces();
assertEquals(p_text1_block, text); assertEquals(p_text1_block, text);
} }

View File

@ -28,7 +28,7 @@ import junit.framework.TestCase;
*/ */
public final class TestWordExtractorBugs extends TestCase { public final class TestWordExtractorBugs extends TestCase {
private String dirname; private String dirname;
protected void setUp() throws Exception { protected void setUp() {
dirname = System.getProperty("HWPF.testdata.path"); dirname = System.getProperty("HWPF.testdata.path");
} }
@ -42,5 +42,4 @@ public final class TestWordExtractorBugs extends TestCase {
extractor.getParagraphText(); extractor.getParagraphText();
extractor.getTextFromPieces(); extractor.getTextFromPieces();
} }
} }

View File

@ -29,7 +29,7 @@ import org.apache.poi.hwpf.HWPFDocument;
public class TestBug46610 extends TestCase { public class TestBug46610 extends TestCase {
private String dirname; private String dirname;
protected void setUp() throws Exception { protected void setUp() {
dirname = System.getProperty("HWPF.testdata.path"); dirname = System.getProperty("HWPF.testdata.path");
} }

View File

@ -25,8 +25,7 @@ import junit.framework.TestCase;
import org.apache.poi.hwpf.HWPFDocument; import org.apache.poi.hwpf.HWPFDocument;
/** /**
* Tests for the handling of header stories into * Tests for the handling of header stories into headers, footers etc
* headers, footers etc
*/ */
public final class TestHeaderStories extends TestCase { public final class TestHeaderStories extends TestCase {
private HWPFDocument none; private HWPFDocument none;
@ -41,40 +40,29 @@ public final class TestHeaderStories extends TestCase {
protected void setUp() throws Exception { protected void setUp() throws Exception {
String dirname = System.getProperty("HWPF.testdata.path"); String dirname = System.getProperty("HWPF.testdata.path");
none = new HWPFDocument( none = new HWPFDocument(new FileInputStream(new File(dirname, "NoHeadFoot.doc")));
new FileInputStream(new File(dirname, "NoHeadFoot.doc")) header = new HWPFDocument(new FileInputStream(new File(dirname, "ThreeColHead.doc")));
); footer = new HWPFDocument(new FileInputStream(new File(dirname, "ThreeColFoot.doc")));
header = new HWPFDocument( headerFooter = new HWPFDocument(new FileInputStream(new File(dirname,
new FileInputStream(new File(dirname, "ThreeColHead.doc")) "SimpleHeadThreeColFoot.doc")));
); oddEven = new HWPFDocument(new FileInputStream(
footer = new HWPFDocument( new File(dirname, "PageSpecificHeadFoot.doc")));
new FileInputStream(new File(dirname, "ThreeColFoot.doc")) diffFirst = new HWPFDocument(new FileInputStream(new File(dirname,
); "DiffFirstPageHeadFoot.doc")));
headerFooter = new HWPFDocument(
new FileInputStream(new File(dirname, "SimpleHeadThreeColFoot.doc"))
);
oddEven = new HWPFDocument(
new FileInputStream(new File(dirname, "PageSpecificHeadFoot.doc"))
);
diffFirst = new HWPFDocument(
new FileInputStream(new File(dirname, "DiffFirstPageHeadFoot.doc"))
);
unicode = new HWPFDocument( unicode = new HWPFDocument(
new FileInputStream(new File(dirname, "HeaderFooterUnicode.doc")) new FileInputStream(new File(dirname, "HeaderFooterUnicode.doc")));
);
withFields = new HWPFDocument( withFields = new HWPFDocument(
new FileInputStream(new File(dirname, "HeaderWithMacros.doc")) new FileInputStream(new File(dirname, "HeaderWithMacros.doc")));
);
} }
public void testNone() throws Exception { public void testNone() {
HeaderStories hs = new HeaderStories(none); HeaderStories hs = new HeaderStories(none);
assertNull(hs.getPlcfHdd()); assertNull(hs.getPlcfHdd());
assertEquals(0, hs.getRange().text().length()); assertEquals(0, hs.getRange().text().length());
} }
public void testHeader() throws Exception { public void testHeader() {
HeaderStories hs = new HeaderStories(header); HeaderStories hs = new HeaderStories(header);
assertEquals(60, hs.getRange().text().length()); assertEquals(60, hs.getRange().text().length());
@ -113,63 +101,65 @@ public final class TestHeaderStories extends TestCase {
assertEquals("", hs.getEvenHeader()); assertEquals("", hs.getEvenHeader());
assertEquals("First header column!\tMid header Right header!\r\r", hs.getOddHeader()); assertEquals("First header column!\tMid header Right header!\r\r", hs.getOddHeader());
assertEquals("", hs.getFirstFooter()); assertEquals("", hs.getFirstFooter());
assertEquals("", hs.getEvenFooter()); assertEquals("", hs.getEvenFooter());
assertEquals("", hs.getOddFooter()); assertEquals("", hs.getOddFooter());
} }
public void testFooter() throws Exception { public void testFooter() {
HeaderStories hs = new HeaderStories(footer); HeaderStories hs = new HeaderStories(footer);
assertEquals("", hs.getFirstHeader()); assertEquals("", hs.getFirstHeader());
assertEquals("", hs.getEvenHeader()); assertEquals("", hs.getEvenHeader());
assertEquals("", hs.getOddHeader()); // Was \r\r but gets emptied assertEquals("", hs.getOddHeader()); // Was \r\r but gets emptied
assertEquals("", hs.getFirstFooter()); assertEquals("", hs.getFirstFooter());
assertEquals("", hs.getEvenFooter()); assertEquals("", hs.getEvenFooter());
assertEquals("Footer Left\tFooter Middle Footer Right\r\r", hs.getOddFooter()); assertEquals("Footer Left\tFooter Middle Footer Right\r\r", hs.getOddFooter());
} }
public void testHeaderFooter() throws Exception { public void testHeaderFooter() {
HeaderStories hs = new HeaderStories(headerFooter); HeaderStories hs = new HeaderStories(headerFooter);
assertEquals("", hs.getFirstHeader()); assertEquals("", hs.getFirstHeader());
assertEquals("", hs.getEvenHeader()); assertEquals("", hs.getEvenHeader());
assertEquals("I am some simple header text here\r\r\r", hs.getOddHeader()); assertEquals("I am some simple header text here\r\r\r", hs.getOddHeader());
assertEquals("", hs.getFirstFooter()); assertEquals("", hs.getFirstFooter());
assertEquals("", hs.getEvenFooter()); assertEquals("", hs.getEvenFooter());
assertEquals("Footer Left\tFooter Middle Footer Right\r\r", hs.getOddFooter()); assertEquals("Footer Left\tFooter Middle Footer Right\r\r", hs.getOddFooter());
} }
public void testOddEven() throws Exception { public void testOddEven() {
HeaderStories hs = new HeaderStories(oddEven); HeaderStories hs = new HeaderStories(oddEven);
assertEquals("", hs.getFirstHeader()); assertEquals("", hs.getFirstHeader());
assertEquals("[This is an Even Page, with a Header]\u0007August 20, 2008\u0007\u0007\r\r", hs.getEvenHeader()); assertEquals("[This is an Even Page, with a Header]\u0007August 20, 2008\u0007\u0007\r\r",
assertEquals("August 20, 2008\u0007[ODD Page Header text]\u0007\u0007\r\r", hs.getOddHeader()); hs.getEvenHeader());
assertEquals("August 20, 2008\u0007[ODD Page Header text]\u0007\u0007\r\r", hs
.getOddHeader());
assertEquals("", hs.getFirstFooter()); assertEquals("", hs.getFirstFooter());
assertEquals("\u0007Page \u0013 PAGE \\* MERGEFORMAT \u00142\u0015\u0007\u0007\u0007\u0007\u0007\u0007\u0007This is a simple footer on the second page\r\r", hs.getEvenFooter()); assertEquals(
"\u0007Page \u0013 PAGE \\* MERGEFORMAT \u00142\u0015\u0007\u0007\u0007\u0007\u0007\u0007\u0007This is a simple footer on the second page\r\r",
hs.getEvenFooter());
assertEquals("Footer Left\tFooter Middle Footer Right\r\r", hs.getOddFooter()); assertEquals("Footer Left\tFooter Middle Footer Right\r\r", hs.getOddFooter());
assertEquals("Footer Left\tFooter Middle Footer Right\r\r", hs.getFooter(1)); assertEquals("Footer Left\tFooter Middle Footer Right\r\r", hs.getFooter(1));
assertEquals("\u0007Page \u0013 PAGE \\* MERGEFORMAT \u00142\u0015\u0007\u0007\u0007\u0007\u0007\u0007\u0007This is a simple footer on the second page\r\r", hs.getFooter(2)); assertEquals(
"\u0007Page \u0013 PAGE \\* MERGEFORMAT \u00142\u0015\u0007\u0007\u0007\u0007\u0007\u0007\u0007This is a simple footer on the second page\r\r",
hs.getFooter(2));
assertEquals("Footer Left\tFooter Middle Footer Right\r\r", hs.getFooter(3)); assertEquals("Footer Left\tFooter Middle Footer Right\r\r", hs.getFooter(3));
} }
public void testFirst() throws Exception { public void testFirst() {
HeaderStories hs = new HeaderStories(diffFirst); HeaderStories hs = new HeaderStories(diffFirst);
assertEquals("I am the header on the first page, and I\u2019m nice and simple\r\r", hs.getFirstHeader()); assertEquals("I am the header on the first page, and I\u2019m nice and simple\r\r", hs
.getFirstHeader());
assertEquals("", hs.getEvenHeader()); assertEquals("", hs.getEvenHeader());
assertEquals("First header column!\tMid header Right header!\r\r", hs.getOddHeader()); assertEquals("First header column!\tMid header Right header!\r\r", hs.getOddHeader());
assertEquals("The footer of the first page\r\r", hs.getFirstFooter()); assertEquals("The footer of the first page\r\r", hs.getFirstFooter());
assertEquals("", hs.getEvenFooter()); assertEquals("", hs.getEvenFooter());
assertEquals("Footer Left\tFooter Middle Footer Right\r\r", hs.getOddFooter()); assertEquals("Footer Left\tFooter Middle Footer Right\r\r", hs.getOddFooter());
@ -179,24 +169,26 @@ public final class TestHeaderStories extends TestCase {
assertEquals("Footer Left\tFooter Middle Footer Right\r\r", hs.getFooter(3)); assertEquals("Footer Left\tFooter Middle Footer Right\r\r", hs.getFooter(3));
} }
public void testUnicode() throws Exception { public void testUnicode() {
HeaderStories hs = new HeaderStories(unicode); HeaderStories hs = new HeaderStories(unicode);
assertEquals("", hs.getFirstHeader()); assertEquals("", hs.getFirstHeader());
assertEquals("", hs.getEvenHeader()); assertEquals("", hs.getEvenHeader());
assertEquals("This is a simple header, with a \u20ac euro symbol in it.\r\r\r", hs.getOddHeader()); assertEquals("This is a simple header, with a \u20ac euro symbol in it.\r\r\r", hs
.getOddHeader());
assertEquals("", hs.getFirstFooter()); assertEquals("", hs.getFirstFooter());
assertEquals("", hs.getEvenFooter()); assertEquals("", hs.getEvenFooter());
assertEquals("The footer, with Moli\u00e8re, has Unicode in it.\r\r", hs.getOddFooter()); assertEquals("The footer, with Moli\u00e8re, has Unicode in it.\r\r", hs.getOddFooter());
} }
public void testWithFields() throws Exception { public void testWithFields() {
HeaderStories hs = new HeaderStories(withFields); HeaderStories hs = new HeaderStories(withFields);
assertFalse(hs.areFieldsStripped()); assertFalse(hs.areFieldsStripped());
assertEquals("HEADER GOES HERE. 8/12/2008 \u0013 AUTHOR \\* MERGEFORMAT \u0014Eric Roch\u0015\r\r\r", hs.getOddHeader()); assertEquals(
"HEADER GOES HERE. 8/12/2008 \u0013 AUTHOR \\* MERGEFORMAT \u0014Eric Roch\u0015\r\r\r",
hs.getOddHeader());
// Now turn on stripping // Now turn on stripping
hs.setAreFieldsStripped(true); hs.setAreFieldsStripped(true);

View File

@ -24,7 +24,7 @@ import junit.framework.TestCase;
* text replacement or textual contents * text replacement or textual contents
*/ */
public final class TestRange extends TestCase { public final class TestRange extends TestCase {
public void testFieldStripping() throws Exception { public void testFieldStripping() {
String exp = "This is some text."; String exp = "This is some text.";
String single = "This is some \u0013Blah!\u0015text."; String single = "This is some \u0013Blah!\u0015text.";

View File

@ -47,7 +47,7 @@ public final class TestRangeDelete extends TestCase {
private String illustrativeDocFile; private String illustrativeDocFile;
protected void setUp() throws Exception { protected void setUp() {
String dirname = System.getProperty("HWPF.testdata.path"); String dirname = System.getProperty("HWPF.testdata.path");

View File

@ -39,7 +39,7 @@ public final class TestRangeInsertion extends TestCase {
private String illustrativeDocFile; private String illustrativeDocFile;
protected void setUp() throws Exception { protected void setUp() {
String dirname = System.getProperty("HWPF.testdata.path"); String dirname = System.getProperty("HWPF.testdata.path");

View File

@ -79,7 +79,7 @@ public final class TestRangeProperties extends TestCase {
} }
public void testAsciiTextParagraphs() throws Exception { public void testAsciiTextParagraphs() {
Range r = a.getRange(); Range r = a.getRange();
assertEquals( assertEquals(
a_page_1 + a_page_1 +
@ -138,7 +138,7 @@ public final class TestRangeProperties extends TestCase {
); );
} }
public void testAsciiStyling() throws Exception { public void testAsciiStyling() {
Range r = a.getRange(); Range r = a.getRange();
Paragraph p1 = r.getParagraph(0); Paragraph p1 = r.getParagraph(0);
@ -160,7 +160,7 @@ public final class TestRangeProperties extends TestCase {
* Tests the raw definitions of the paragraphs of * Tests the raw definitions of the paragraphs of
* a unicode document * a unicode document
*/ */
public void testUnicodeParagraphDefinitions() throws Exception { public void testUnicodeParagraphDefinitions() {
Range r = u.getRange(); Range r = u.getRange();
String[] p1_parts = u_page_1.split("\r"); String[] p1_parts = u_page_1.split("\r");
String[] p2_parts = u_page_2.split("\r"); String[] p2_parts = u_page_2.split("\r");
@ -251,7 +251,7 @@ public final class TestRangeProperties extends TestCase {
/** /**
* Tests the paragraph text of a unicode document * Tests the paragraph text of a unicode document
*/ */
public void testUnicodeTextParagraphs() throws Exception { public void testUnicodeTextParagraphs() {
Range r = u.getRange(); Range r = u.getRange();
assertEquals( assertEquals(
u_page_1 + u_page_1 +
@ -281,7 +281,7 @@ public final class TestRangeProperties extends TestCase {
assertEquals(page_break + "\r", r.getParagraph(10).text()); assertEquals(page_break + "\r", r.getParagraph(10).text());
assertEquals(p2_parts[0] + "\r", r.getParagraph(11).text()); assertEquals(p2_parts[0] + "\r", r.getParagraph(11).text());
} }
public void testUnicodeStyling() throws Exception { public void testUnicodeStyling() {
Range r = u.getRange(); Range r = u.getRange();
String[] p1_parts = u_page_1.split("\r"); String[] p1_parts = u_page_1.split("\r");

View File

@ -42,7 +42,7 @@ public final class TestRangeReplacement extends TestCase {
private String illustrativeDocFile; private String illustrativeDocFile;
protected void setUp() throws Exception { protected void setUp() {
String dirname = System.getProperty("HWPF.testdata.path"); String dirname = System.getProperty("HWPF.testdata.path");

View File

@ -1,4 +1,3 @@
/* ==================================================================== /* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with contributor license agreements. See the NOTICE file distributed with
@ -50,7 +49,7 @@ public final class TestPOIDocumentMain extends TestCase {
doc2 = HSSFTestDataSamples.openSampleWorkbook("StringFormulas.xls"); doc2 = HSSFTestDataSamples.openSampleWorkbook("StringFormulas.xls");
} }
public void testReadProperties() throws Exception { public void testReadProperties() {
// We should have both sets // We should have both sets
assertNotNull(doc.getDocumentSummaryInformation()); assertNotNull(doc.getDocumentSummaryInformation());
assertNotNull(doc.getSummaryInformation()); assertNotNull(doc.getSummaryInformation());
@ -60,7 +59,7 @@ public final class TestPOIDocumentMain extends TestCase {
assertEquals(0, doc.getDocumentSummaryInformation().getByteCount()); assertEquals(0, doc.getDocumentSummaryInformation().getByteCount());
} }
public void testReadProperties2() throws Exception { public void testReadProperties2() {
// Check again on the word one // Check again on the word one
assertNotNull(doc2.getDocumentSummaryInformation()); assertNotNull(doc2.getDocumentSummaryInformation());
assertNotNull(doc2.getSummaryInformation()); assertNotNull(doc2.getSummaryInformation());

View File

@ -21,13 +21,11 @@ import junit.framework.TestCase;
import org.apache.poi.util.HexDump; import org.apache.poi.util.HexDump;
import org.apache.poi.util.HexRead; import org.apache.poi.util.HexRead;
public class TestEscherBlipWMFRecord extends TestCase public final class TestEscherBlipWMFRecord extends TestCase {
{
private String dataStr; private String dataStr;
private byte[] data; private byte[] data;
protected void setUp() throws Exception protected void setUp() {
{
dataStr = "2C 15 18 F0 34 00 00 00 01 01 01 01 01 01 01 01 " + dataStr = "2C 15 18 F0 34 00 00 00 01 01 01 01 01 01 01 01 " +
"01 01 01 01 01 01 01 01 06 00 00 00 03 00 00 00 " + "01 01 01 01 01 01 01 01 06 00 00 00 03 00 00 00 " +
"01 00 00 00 04 00 00 00 02 00 00 00 0A 00 00 00 " + "01 00 00 00 04 00 00 00 02 00 00 00 0A 00 00 00 " +

View File

@ -1,4 +1,3 @@
/* ==================================================================== /* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with contributor license agreements. See the NOTICE file distributed with
@ -20,12 +19,9 @@ package org.apache.poi.ddf;
import junit.framework.TestCase; import junit.framework.TestCase;
public class TestEscherBoolProperty extends TestCase public final class TestEscherBoolProperty extends TestCase {
{ public void testToString() {
public void testToString() throws Exception
{
EscherBoolProperty p = new EscherBoolProperty((short)1, 1); EscherBoolProperty p = new EscherBoolProperty((short)1, 1);
assertEquals("propNum: 1, RAW: 0x0001, propName: unknown, complex: false, blipId: false, value: 1 (0x00000001)", p.toString()); assertEquals("propNum: 1, RAW: 0x0001, propName: unknown, complex: false, blipId: false, value: 1 (0x00000001)", p.toString());
} }
} }

View File

@ -21,8 +21,7 @@ import junit.framework.TestCase;
import org.apache.poi.util.HexDump; import org.apache.poi.util.HexDump;
import org.apache.poi.util.HexRead; import org.apache.poi.util.HexRead;
public class TestEscherChildAnchorRecord extends TestCase public final class TestEscherChildAnchorRecord extends TestCase {
{
public void testSerialize() { public void testSerialize() {
EscherChildAnchorRecord r = createRecord(); EscherChildAnchorRecord r = createRecord();
@ -38,8 +37,7 @@ public class TestEscherChildAnchorRecord extends TestCase
"04, 00, 00, 00]", HexDump.toHex( data ) ); "04, 00, 00, 00]", HexDump.toHex( data ) );
} }
public void testFillFields() throws Exception public void testFillFields() {
{
String hexData = "01 00 " + String hexData = "01 00 " +
"0F F0 " + "0F F0 " +
"10 00 00 00 " + "10 00 00 00 " +
@ -73,8 +71,7 @@ public class TestEscherChildAnchorRecord extends TestCase
assertEquals( expected, createRecord().toString() ); assertEquals( expected, createRecord().toString() );
} }
private static EscherChildAnchorRecord createRecord() private static EscherChildAnchorRecord createRecord() {
{
EscherChildAnchorRecord r = new EscherChildAnchorRecord(); EscherChildAnchorRecord r = new EscherChildAnchorRecord();
r.setRecordId( EscherChildAnchorRecord.RECORD_ID ); r.setRecordId( EscherChildAnchorRecord.RECORD_ID );
r.setOptions( (short) 0x0001 ); r.setOptions( (short) 0x0001 );

View File

@ -14,29 +14,30 @@
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
==================================================================== */ ==================================================================== */
package org.apache.poi.hpsf.extractor; package org.apache.poi.hpsf.extractor;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.IOException;
import junit.framework.TestCase;
import org.apache.poi.hssf.extractor.ExcelExtractor; import org.apache.poi.hssf.extractor.ExcelExtractor;
import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.poifs.filesystem.POIFSFileSystem; import org.apache.poi.poifs.filesystem.POIFSFileSystem;
import junit.framework.TestCase; public final class TestHPSFPropertiesExtractor extends TestCase {
public class TestHPSFPropertiesExtractor extends TestCase {
private String dir; private String dir;
protected void setUp() throws Exception { protected void setUp() {
dir = System.getProperty("HPSF.testdata.path"); dir = System.getProperty("HPSF.testdata.path");
assertNotNull("HPSF.testdata.path not set", dir); assertNotNull("HPSF.testdata.path not set", dir);
} }
public void testNormalProperties() throws Exception { public void testNormalProperties() throws Exception {
POIFSFileSystem fs = new POIFSFileSystem( POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream(
new FileInputStream(new File(dir, "TestMickey.doc")) new File(dir, "TestMickey.doc")));
);
HPSFPropertiesExtractor ext = new HPSFPropertiesExtractor(fs); HPSFPropertiesExtractor ext = new HPSFPropertiesExtractor(fs);
ext.getText(); ext.getText();
@ -56,10 +57,10 @@ public class TestHPSFPropertiesExtractor extends TestCase {
assertTrue(text.indexOf("MANAGER = sample manager") > -1); assertTrue(text.indexOf("MANAGER = sample manager") > -1);
assertTrue(text.indexOf("COMPANY = sample company") > -1); assertTrue(text.indexOf("COMPANY = sample company") > -1);
} }
public void testNormalUnicodeProperties() throws Exception { public void testNormalUnicodeProperties() throws Exception {
POIFSFileSystem fs = new POIFSFileSystem( POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream(new File(dir,
new FileInputStream(new File(dir, "TestUnicode.xls")) "TestUnicode.xls")));
);
HPSFPropertiesExtractor ext = new HPSFPropertiesExtractor(fs); HPSFPropertiesExtractor ext = new HPSFPropertiesExtractor(fs);
ext.getText(); ext.getText();
@ -79,10 +80,10 @@ public class TestHPSFPropertiesExtractor extends TestCase {
assertTrue(text.indexOf("COMPANY = Schreiner") > -1); assertTrue(text.indexOf("COMPANY = Schreiner") > -1);
assertTrue(text.indexOf("SCALE = false") > -1); assertTrue(text.indexOf("SCALE = false") > -1);
} }
public void testCustomProperties() throws Exception { public void testCustomProperties() throws Exception {
POIFSFileSystem fs = new POIFSFileSystem( POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream(
new FileInputStream(new File(dir, "TestMickey.doc")) new File(dir, "TestMickey.doc")));
);
HPSFPropertiesExtractor ext = new HPSFPropertiesExtractor(fs); HPSFPropertiesExtractor ext = new HPSFPropertiesExtractor(fs);
// Custom properties are part of the document info stream // Custom properties are part of the document info stream
@ -95,11 +96,15 @@ public class TestHPSFPropertiesExtractor extends TestCase {
assertTrue(text.indexOf("Division = sample division") > -1); assertTrue(text.indexOf("Division = sample division") > -1);
} }
public void testConstructors() throws Exception { public void testConstructors() {
POIFSFileSystem fs = new POIFSFileSystem( POIFSFileSystem fs;
new FileInputStream(new File(dir, "TestUnicode.xls")) HSSFWorkbook wb;
); try {
HSSFWorkbook wb = new HSSFWorkbook(fs); fs = new POIFSFileSystem(new FileInputStream(new File(dir, "TestUnicode.xls")));
wb = new HSSFWorkbook(fs);
} catch (IOException e) {
throw new RuntimeException(e);
}
ExcelExtractor excelExt = new ExcelExtractor(wb); ExcelExtractor excelExt = new ExcelExtractor(wb);
String fsText = (new HPSFPropertiesExtractor(fs)).getText(); String fsText = (new HPSFPropertiesExtractor(fs)).getText();

View File

@ -14,16 +14,15 @@
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
==================================================================== */ ==================================================================== */
package org.apache.poi.hssf.model; package org.apache.poi.hssf.model;
import junit.framework.TestCase; import junit.framework.TestCase;
import org.apache.poi.ddf.EscherDggRecord; import org.apache.poi.ddf.EscherDggRecord;
import org.apache.poi.ddf.EscherDgRecord; import org.apache.poi.ddf.EscherDgRecord;
public class TestDrawingManager extends TestCase public final class TestDrawingManager extends TestCase {
{ public void testFindFreeSPIDBlock() {
public void testFindFreeSPIDBlock() throws Exception
{
EscherDggRecord dgg = new EscherDggRecord(); EscherDggRecord dgg = new EscherDggRecord();
DrawingManager dm = new DrawingManager( dgg ); DrawingManager dm = new DrawingManager( dgg );
dgg.setShapeIdMax( 1024 ); dgg.setShapeIdMax( 1024 );
@ -34,8 +33,7 @@ public class TestDrawingManager extends TestCase
assertEquals( 2048, dm.findFreeSPIDBlock() ); assertEquals( 2048, dm.findFreeSPIDBlock() );
} }
public void testFindNewDrawingGroupId() throws Exception public void testFindNewDrawingGroupId() {
{
EscherDggRecord dgg = new EscherDggRecord(); EscherDggRecord dgg = new EscherDggRecord();
dgg.setDrawingsSaved( 1 ); dgg.setDrawingsSaved( 1 );
dgg.setFileIdClusters( new EscherDggRecord.FileIdCluster[]{ dgg.setFileIdClusters( new EscherDggRecord.FileIdCluster[]{
@ -48,8 +46,7 @@ public class TestDrawingManager extends TestCase
assertEquals( 3, dm.findNewDrawingGroupId() ); assertEquals( 3, dm.findNewDrawingGroupId() );
} }
public void testDrawingGroupExists() throws Exception public void testDrawingGroupExists() {
{
EscherDggRecord dgg = new EscherDggRecord(); EscherDggRecord dgg = new EscherDggRecord();
dgg.setDrawingsSaved( 1 ); dgg.setDrawingsSaved( 1 );
dgg.setFileIdClusters( new EscherDggRecord.FileIdCluster[]{ dgg.setFileIdClusters( new EscherDggRecord.FileIdCluster[]{
@ -60,8 +57,7 @@ public class TestDrawingManager extends TestCase
assertFalse( dm.drawingGroupExists( (short) 3 ) ); assertFalse( dm.drawingGroupExists( (short) 3 ) );
} }
public void testCreateDgRecord() throws Exception public void testCreateDgRecord() {
{
EscherDggRecord dgg = new EscherDggRecord(); EscherDggRecord dgg = new EscherDggRecord();
dgg.setDrawingsSaved( 0 ); dgg.setDrawingsSaved( 0 );
dgg.setFileIdClusters( new EscherDggRecord.FileIdCluster[]{} ); dgg.setFileIdClusters( new EscherDggRecord.FileIdCluster[]{} );
@ -76,8 +72,7 @@ public class TestDrawingManager extends TestCase
assertEquals( 0, dm.getDgg().getFileIdClusters()[0].getNumShapeIdsUsed() ); assertEquals( 0, dm.getDgg().getFileIdClusters()[0].getNumShapeIdsUsed() );
} }
public void testAllocateShapeId() throws Exception public void testAllocateShapeId() {
{
EscherDggRecord dgg = new EscherDggRecord(); EscherDggRecord dgg = new EscherDggRecord();
dgg.setDrawingsSaved( 0 ); dgg.setDrawingsSaved( 0 );
dgg.setFileIdClusters( new EscherDggRecord.FileIdCluster[]{} ); dgg.setFileIdClusters( new EscherDggRecord.FileIdCluster[]{} );
@ -93,5 +88,4 @@ public class TestDrawingManager extends TestCase
assertEquals( 1024, dg.getLastMSOSPID() ); assertEquals( 1024, dg.getLastMSOSPID() );
assertEquals( 1, dg.getNumShapes() ); assertEquals( 1, dg.getNumShapes() );
} }
} }

View File

@ -1,40 +1,37 @@
/* /* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one or more Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0 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 not use this file except in compliance with
* the License. You may obtain a copy of the License at the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0 http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and See the License for the specific language governing permissions and
* limitations under the License. limitations under the License.
*/ ==================================================================== */
package org.apache.poi.hssf.model; package org.apache.poi.hssf.model;
import junit.framework.TestCase; import junit.framework.TestCase;
import org.apache.poi.ddf.EscherDggRecord; import org.apache.poi.ddf.EscherDggRecord;
import org.apache.poi.ddf.EscherDgRecord; import org.apache.poi.ddf.EscherDgRecord;
public class TestDrawingManager2 extends TestCase public final class TestDrawingManager2 extends TestCase {
{
private DrawingManager2 drawingManager2; private DrawingManager2 drawingManager2;
private EscherDggRecord dgg; private EscherDggRecord dgg;
protected void setUp() throws Exception protected void setUp() {
{
super.setUp();
dgg = new EscherDggRecord(); dgg = new EscherDggRecord();
dgg.setFileIdClusters( new EscherDggRecord.FileIdCluster[0] ); dgg.setFileIdClusters( new EscherDggRecord.FileIdCluster[0] );
drawingManager2 = new DrawingManager2( dgg ); drawingManager2 = new DrawingManager2( dgg );
} }
public void testCreateDgRecord() throws Exception public void testCreateDgRecord() {
{
EscherDgRecord dgRecord1 = drawingManager2.createDgRecord(); EscherDgRecord dgRecord1 = drawingManager2.createDgRecord();
assertEquals( 1, dgRecord1.getDrawingGroupId() ); assertEquals( 1, dgRecord1.getDrawingGroupId() );
assertEquals( -1, dgRecord1.getLastMSOSPID() ); assertEquals( -1, dgRecord1.getLastMSOSPID() );
@ -49,8 +46,7 @@ public class TestDrawingManager2 extends TestCase
assertEquals( 0, dgg.getNumShapesSaved() ); assertEquals( 0, dgg.getNumShapesSaved() );
} }
public void testAllocateShapeId() throws Exception public void testAllocateShapeId() {
{
EscherDgRecord dgRecord1 = drawingManager2.createDgRecord(); EscherDgRecord dgRecord1 = drawingManager2.createDgRecord();
EscherDgRecord dgRecord2 = drawingManager2.createDgRecord(); EscherDgRecord dgRecord2 = drawingManager2.createDgRecord();

View File

@ -42,7 +42,7 @@ public final class TestFormulaParserIf extends TestCase {
return TestFormulaParser.parseFormula(formula); return TestFormulaParser.parseFormula(formula);
} }
private static Ptg[] confirmTokenClasses(String formula, Class[] expectedClasses) { private static Ptg[] confirmTokenClasses(String formula, Class<?>[] expectedClasses) {
return TestFormulaParser.confirmTokenClasses(formula, expectedClasses); return TestFormulaParser.confirmTokenClasses(formula, expectedClasses);
} }
@ -57,7 +57,7 @@ public final class TestFormulaParserIf extends TestCase {
public void testSimpleIf() { public void testSimpleIf() {
Class[] expClss; Class<?>[] expClss;
expClss = new Class[] { expClss = new Class[] {
RefPtg.class, RefPtg.class,
@ -78,7 +78,7 @@ public final class TestFormulaParserIf extends TestCase {
public void testSimpleIfNoFalseParam() { public void testSimpleIfNoFalseParam() {
Class[] expClss; Class<?>[] expClss;
expClss = new Class[] { expClss = new Class[] {
RefPtg.class, RefPtg.class,
@ -96,7 +96,7 @@ public final class TestFormulaParserIf extends TestCase {
public void testIfWithLargeParams() { public void testIfWithLargeParams() {
Class[] expClss; Class<?>[] expClss;
expClss = new Class[] { expClss = new Class[] {
RefPtg.class, RefPtg.class,
@ -128,7 +128,7 @@ public final class TestFormulaParserIf extends TestCase {
public void testNestedIf() { public void testNestedIf() {
Class[] expClss; Class<?>[] expClss;
expClss = new Class[] { expClss = new Class[] {

View File

@ -28,7 +28,7 @@ import junit.framework.TestCase;
* @author Glen Stampoultzis (glens at apache.org) * @author Glen Stampoultzis (glens at apache.org)
*/ */
public final class TestWorkbook extends TestCase { public final class TestWorkbook extends TestCase {
public void testFontStuff() throws Exception { public void testFontStuff() {
Workbook wb = (new HW()).getWorkbook(); Workbook wb = (new HW()).getWorkbook();
assertEquals(4, wb.getNumberOfFontRecords()); assertEquals(4, wb.getNumberOfFontRecords());
@ -83,8 +83,8 @@ public final class TestWorkbook extends TestCase {
assertEquals(n7, wb.getFontRecordAt(6)); assertEquals(n7, wb.getFontRecordAt(6));
} }
private class HW extends HSSFWorkbook { private static final class HW extends HSSFWorkbook {
private HW() { public HW() {
super(); super();
} }
protected Workbook getWorkbook() { protected Workbook getWorkbook() {

Some files were not shown because too many files have changed in this diff Show More