remove some unused imports and some useless TODOs, slightly more

coverage, @Overrides, more info on failing test, fix some Eclipse
warnings

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1554535 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Dominik Stadler 2013-12-31 15:12:30 +00:00
parent 2c7fff15e1
commit 62ec8b719b
9 changed files with 65 additions and 72 deletions

View File

@ -25,8 +25,8 @@ import java.util.TreeMap;
import org.apache.poi.hssf.model.RecordStream; import org.apache.poi.hssf.model.RecordStream;
import org.apache.poi.hssf.record.*; import org.apache.poi.hssf.record.*;
import org.apache.poi.ss.formula.FormulaShifter;
import org.apache.poi.ss.SpreadsheetVersion; import org.apache.poi.ss.SpreadsheetVersion;
import org.apache.poi.ss.formula.FormulaShifter;
/** /**
* *
@ -237,14 +237,15 @@ public final class RowRecordsAggregate extends RecordAggregate {
rowIterator.next(); rowIterator.next();
int result = 0; int result = 0;
while(rowIterator.hasNext() && (i++ < endIndex)) { while(rowIterator.hasNext() && (i++ < endIndex)) {
Record rec = (Record)rowIterator.next(); Record rec = rowIterator.next();
result += rec.getRecordSize(); result += rec.getRecordSize();
rv.visitRecord(rec); rv.visitRecord(rec);
} }
return result; return result;
} }
public void visitContainedRecords(RecordVisitor rv) { @Override
public void visitContainedRecords(RecordVisitor rv) {
PositionTrackingVisitor stv = new PositionTrackingVisitor(rv, 0); PositionTrackingVisitor stv = new PositionTrackingVisitor(rv, 0);
//DBCells are serialized before row records. //DBCells are serialized before row records.

View File

@ -17,10 +17,11 @@
package org.apache.poi.ss.formula.functions; package org.apache.poi.ss.formula.functions;
import org.apache.poi.ss.formula.OperationEvaluationContext; import org.apache.poi.ss.formula.eval.ErrorEval;
import org.apache.poi.ss.formula.eval.*; import org.apache.poi.ss.formula.eval.EvaluationException;
import org.apache.poi.ss.formula.eval.OperandResolver;
import java.math.BigDecimal; import org.apache.poi.ss.formula.eval.StringEval;
import org.apache.poi.ss.formula.eval.ValueEval;
/** /**
* Implementation for Excel REPT () function.<p/> * Implementation for Excel REPT () function.<p/>

View File

@ -41,38 +41,29 @@ public final class DigitalCertificatePart extends PackagePart {
@Override @Override
public void close() { public void close() {
// TODO Auto-generated method stub
} }
@Override @Override
public void flush() { public void flush() {
// TODO Auto-generated method stub
} }
@Override @Override
protected InputStream getInputStreamImpl() throws IOException { protected InputStream getInputStreamImpl() throws IOException {
// TODO Auto-generated method stub
return null; return null;
} }
@Override @Override
protected OutputStream getOutputStreamImpl() { protected OutputStream getOutputStreamImpl() {
// TODO Auto-generated method stub
return null; return null;
} }
@Override @Override
public boolean load(InputStream ios) throws InvalidFormatException { public boolean load(InputStream ios) throws InvalidFormatException {
// TODO Auto-generated method stub
return false; return false;
} }
@Override @Override
public boolean save(OutputStream zos) throws OpenXML4JException { public boolean save(OutputStream zos) throws OpenXML4JException {
// TODO Auto-generated method stub
return false; return false;
} }
} }

View File

@ -34,37 +34,29 @@ public final class PackageDigitalSignature extends PackagePart {
@Override @Override
public void close() { public void close() {
// TODO Auto-generated method stub
} }
@Override @Override
public void flush() { public void flush() {
// TODO Auto-generated method stub
} }
@Override @Override
protected InputStream getInputStreamImpl() throws IOException { protected InputStream getInputStreamImpl() throws IOException {
// TODO Auto-generated method stub
return null; return null;
} }
@Override @Override
protected OutputStream getOutputStreamImpl() { protected OutputStream getOutputStreamImpl() {
// TODO Auto-generated method stub
return null; return null;
} }
@Override @Override
public boolean load(InputStream ios) throws InvalidFormatException { public boolean load(InputStream ios) throws InvalidFormatException {
// TODO Auto-generated method stub
return false; return false;
} }
@Override @Override
public boolean save(OutputStream zos) throws OpenXML4JException { public boolean save(OutputStream zos) throws OpenXML4JException {
// TODO Auto-generated method stub
return false; return false;
} }
} }

View File

@ -16,6 +16,10 @@
==================================================================== */ ==================================================================== */
package org.apache.poi.xslf; package org.apache.poi.xslf;
import java.io.IOException;
import java.util.LinkedList;
import java.util.List;
import org.apache.poi.POIXMLDocument; import org.apache.poi.POIXMLDocument;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException; import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.openxml4j.exceptions.OpenXML4JException; import org.apache.poi.openxml4j.exceptions.OpenXML4JException;
@ -27,24 +31,7 @@ import org.apache.poi.util.Internal;
import org.apache.poi.xslf.usermodel.XMLSlideShow; import org.apache.poi.xslf.usermodel.XMLSlideShow;
import org.apache.poi.xslf.usermodel.XSLFRelation; import org.apache.poi.xslf.usermodel.XSLFRelation;
import org.apache.xmlbeans.XmlException; import org.apache.xmlbeans.XmlException;
import org.openxmlformats.schemas.presentationml.x2006.main.CTCommentList; import org.openxmlformats.schemas.presentationml.x2006.main.*;
import org.openxmlformats.schemas.presentationml.x2006.main.CTNotesSlide;
import org.openxmlformats.schemas.presentationml.x2006.main.CTPresentation;
import org.openxmlformats.schemas.presentationml.x2006.main.CTSlide;
import org.openxmlformats.schemas.presentationml.x2006.main.CTSlideIdList;
import org.openxmlformats.schemas.presentationml.x2006.main.CTSlideIdListEntry;
import org.openxmlformats.schemas.presentationml.x2006.main.CTSlideMaster;
import org.openxmlformats.schemas.presentationml.x2006.main.CTSlideMasterIdList;
import org.openxmlformats.schemas.presentationml.x2006.main.CTSlideMasterIdListEntry;
import org.openxmlformats.schemas.presentationml.x2006.main.CmLstDocument;
import org.openxmlformats.schemas.presentationml.x2006.main.NotesDocument;
import org.openxmlformats.schemas.presentationml.x2006.main.PresentationDocument;
import org.openxmlformats.schemas.presentationml.x2006.main.SldDocument;
import org.openxmlformats.schemas.presentationml.x2006.main.SldMasterDocument;
import java.io.IOException;
import java.util.LinkedList;
import java.util.List;
/** /**
* Experimental class to do low level processing of pptx files. * Experimental class to do low level processing of pptx files.
@ -253,6 +240,7 @@ public class XSLFSlideShow extends POIXMLDocument {
/** /**
* Get the document's embedded files. * Get the document's embedded files.
*/ */
@Override
public List<PackagePart> getAllEmbedds() throws OpenXML4JException { public List<PackagePart> getAllEmbedds() throws OpenXML4JException {
return embedds; return embedds;
} }

View File

@ -22,15 +22,17 @@ import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet;
import java.util.List; import java.util.List;
import junit.framework.TestCase; import junit.framework.TestCase;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
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.util.TempFile;
import org.apache.poi.util.PackageHelper; import org.apache.poi.util.PackageHelper;
import org.apache.poi.util.TempFile;
/** /**
* Test recursive read and write of OPC packages * Test recursive read and write of OPC packages
@ -43,6 +45,7 @@ public final class TestPOIXMLDocument extends TestCase {
super(pkg); super(pkg);
} }
@Override
public List<PackagePart> getAllEmbedds() { public List<PackagePart> getAllEmbedds() {
throw new RuntimeException("not supported"); throw new RuntimeException("not supported");
} }
@ -57,10 +60,12 @@ public final class TestPOIXMLDocument extends TestCase {
public TestFactory() { public TestFactory() {
// //
} }
@Override
public POIXMLDocumentPart createDocumentPart(POIXMLDocumentPart parent, PackageRelationship rel, PackagePart part){ public POIXMLDocumentPart createDocumentPart(POIXMLDocumentPart parent, PackageRelationship rel, PackagePart part){
return new POIXMLDocumentPart(part, rel); return new POIXMLDocumentPart(part, rel);
} }
@Override
public POIXMLDocumentPart newDocumentPart(POIXMLRelation descriptor){ public POIXMLDocumentPart newDocumentPart(POIXMLRelation descriptor){
throw new RuntimeException("not supported"); throw new RuntimeException("not supported");
} }
@ -73,6 +78,8 @@ public final class TestPOIXMLDocument extends TestCase {
private static void traverse(POIXMLDocumentPart part, HashMap<String,POIXMLDocumentPart> context) throws IOException{ private static void traverse(POIXMLDocumentPart part, HashMap<String,POIXMLDocumentPart> context) throws IOException{
context.put(part.getPackageRelationship().getTargetURI().toString(), part); context.put(part.getPackageRelationship().getTargetURI().toString(), part);
for(POIXMLDocumentPart p : part.getRelations()){ for(POIXMLDocumentPart p : part.getRelations()){
assertNotNull(p.toString());
String uri = p.getPackageRelationship().getTargetURI().toString(); String uri = p.getPackageRelationship().getTargetURI().toString();
if (!context.containsKey(uri)) { if (!context.containsKey(uri)) {
traverse(p, context); traverse(p, context);
@ -152,4 +159,19 @@ public final class TestPOIXMLDocument extends TestCase {
} }
} }
public void testCommitNullPart() throws IOException, InvalidFormatException {
POIXMLDocumentPart part = new POIXMLDocumentPart();
part.prepareForCommit();
part.commit();
part.onSave(new HashSet<PackagePart>());
assertNull(part.getRelationById(null));
assertNull(part.getRelationId(null));
assertFalse(part.removeRelation(null, true));
part.removeRelation(null);
assertNull(part.toString());
part.onDocumentCreate();
//part.getTargetPart(null);
}
} }

View File

@ -18,7 +18,12 @@
*/ */
package org.apache.poi.xslf.usermodel; package org.apache.poi.xslf.usermodel;
import java.io.OutputStream;
import java.util.LinkedHashMap;
import java.util.Map;
import junit.framework.TestCase; import junit.framework.TestCase;
import org.apache.poi.POIXMLDocumentPart; import org.apache.poi.POIXMLDocumentPart;
import org.apache.poi.ss.util.CellRangeAddress; import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.ss.util.CellReference; import org.apache.poi.ss.util.CellReference;
@ -27,13 +32,6 @@ import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet; import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.openxmlformats.schemas.drawingml.x2006.chart.*; import org.openxmlformats.schemas.drawingml.x2006.chart.*;
import org.openxmlformats.schemas.drawingml.x2006.main.*;
import org.openxmlformats.schemas.presentationml.x2006.main.CTConnector;
import java.awt.*;
import java.io.*;
import java.util.LinkedHashMap;
import java.util.Map;
/** /**
* @author Yegor Kozlov * @author Yegor Kozlov

View File

@ -63,6 +63,7 @@ public class TestExcelConverterSuite
final String name = child.getName(); final String name = child.getName();
suite.addTest( new TestCase( name + " [FO]" ) suite.addTest( new TestCase( name + " [FO]" )
{ {
@Override
public void runTest() throws Exception public void runTest() throws Exception
{ {
testFo( child ); testFo( child );
@ -70,6 +71,7 @@ public class TestExcelConverterSuite
} ); } );
suite.addTest( new TestCase( name + " [HTML]" ) suite.addTest( new TestCase( name + " [HTML]" )
{ {
@Override
public void runTest() throws Exception public void runTest() throws Exception
{ {
testHtml( child ); testHtml( child );

View File

@ -16,28 +16,6 @@
==================================================================== */ ==================================================================== */
package org.apache.poi.hssf.model; package org.apache.poi.hssf.model;
import junit.framework.TestCase;
import org.apache.poi.ddf.*;
import org.apache.poi.hssf.HSSFTestDataSamples;
import org.apache.poi.hssf.record.ContinueRecord;
import org.apache.poi.hssf.record.DrawingRecord;
import org.apache.poi.hssf.record.EOFRecord;
import org.apache.poi.hssf.record.EscherAggregate;
import org.apache.poi.hssf.record.NoteRecord;
import org.apache.poi.hssf.record.ObjRecord;
import org.apache.poi.hssf.record.Record;
import org.apache.poi.hssf.record.RecordBase;
import org.apache.poi.hssf.record.RecordFactory;
import org.apache.poi.hssf.record.TextObjectRecord;
import org.apache.poi.hssf.record.WindowTwoRecord;
import org.apache.poi.hssf.record.aggregates.RowRecordsAggregate;
import org.apache.poi.hssf.usermodel.HSSFPatriarch;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFTestHelper;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.util.HexDump;
import org.apache.poi.util.HexRead;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.File; import java.io.File;
@ -49,6 +27,23 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import junit.framework.TestCase;
import org.apache.poi.ddf.DefaultEscherRecordFactory;
import org.apache.poi.ddf.EscherContainerRecord;
import org.apache.poi.ddf.EscherDggRecord;
import org.apache.poi.ddf.EscherRecord;
import org.apache.poi.ddf.EscherRecordFactory;
import org.apache.poi.hssf.HSSFTestDataSamples;
import org.apache.poi.hssf.record.*;
import org.apache.poi.hssf.record.aggregates.RowRecordsAggregate;
import org.apache.poi.hssf.usermodel.HSSFPatriarch;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFTestHelper;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.util.HexDump;
import org.apache.poi.util.HexRead;
/** /**
* @author Yegor Kozlov * @author Yegor Kozlov
* @author Evgeniy Berlog * @author Evgeniy Berlog
@ -179,6 +174,9 @@ public class TestDrawingAggregate extends TestCase {
} }
} }
); );
assertNotNull(
"Need to find files in test-data path, had path: " + new File(System.getProperty("POI.testdata.path"), "spreadsheet"),
xls);
for(File file : xls) { for(File file : xls) {
HSSFWorkbook wb; HSSFWorkbook wb;
try { try {