You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by jo...@apache.org on 2009/08/18 04:41:50 UTC
svn commit: r805262 [6/6] - in /poi/trunk/src: java/org/apache/poi/hssf/dev/
java/org/apache/poi/hssf/model/ java/org/apache/poi/hssf/record/
java/org/apache/poi/hssf/record/formula/
java/org/apache/poi/hssf/record/formula/atp/ java/org/apache/poi/hssf...
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestBugs.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestBugs.java?rev=805262&r1=805261&r2=805262&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestBugs.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestBugs.java Tue Aug 18 02:41:45 2009
@@ -17,17 +17,33 @@
package org.apache.poi.hslf.usermodel;
+import java.io.File;
+import java.io.FileInputStream;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import junit.framework.AssertionFailedError;
import junit.framework.TestCase;
+
import org.apache.poi.hslf.HSLFSlideShow;
import org.apache.poi.hslf.exceptions.OldPowerPointFormatException;
-import org.apache.poi.hslf.model.*;
+import org.apache.poi.hslf.model.Background;
+import org.apache.poi.hslf.model.Fill;
+import org.apache.poi.hslf.model.MasterSheet;
+import org.apache.poi.hslf.model.Notes;
+import org.apache.poi.hslf.model.Picture;
import org.apache.poi.hslf.model.Shape;
-
-import java.io.*;
-import java.util.HashSet;
-import java.util.HashMap;
-import java.util.ArrayList;
-import java.awt.*;
+import org.apache.poi.hslf.model.ShapeGroup;
+import org.apache.poi.hslf.model.Slide;
+import org.apache.poi.hslf.model.SlideMaster;
+import org.apache.poi.hslf.model.TextBox;
+import org.apache.poi.hslf.model.TextRun;
+import org.apache.poi.hslf.model.TextShape;
+import org.apache.poi.hslf.model.TitleMaster;
/**
* Testcases for bugs entered in bugzilla
@@ -99,7 +115,7 @@
SlideShow ppt = new SlideShow(hslf);
//map slide number and starting phrase of its notes
- HashMap notesMap = new HashMap();
+ Map<Integer, String> notesMap = new HashMap<Integer, String>();
notesMap.put(new Integer(4), "For decades before calculators");
notesMap.put(new Integer(5), "Several commercial applications");
notesMap.put(new Integer(6), "There are three variations of LNS that are discussed here");
@@ -113,7 +129,7 @@
if (notesMap.containsKey(slideNumber)){
assertNotNull(notes);
String text = notes.getTextRuns()[0].getRawText();
- String startingPhrase = (String)notesMap.get(slideNumber);
+ String startingPhrase = notesMap.get(slideNumber);
assertTrue("Notes for slide " + slideNumber + " must start with " +
startingPhrase , text.startsWith(startingPhrase));
}
@@ -287,7 +303,7 @@
TextRun[] runs = slide[0].getTextRuns();
assertEquals(4, runs.length);
- HashSet txt = new HashSet();
+ Set<String> txt = new HashSet<String>();
txt.add("\u201CHAPPY BIRTHDAY SCOTT\u201D");
txt.add("Have a HAPPY DAY");
txt.add("PS Nobody is allowed to hassle Scott TODAY\u2026");
@@ -314,12 +330,14 @@
Slide slide = ppt.getSlides()[0];
TextRun[] tr1 = slide.getTextRuns();
- ArrayList lst = new ArrayList();
+ List<TextRun> lst = new ArrayList<TextRun>();
Shape[] shape = slide.getShapes();
for (int i = 0; i < shape.length; i++) {
if( shape[i] instanceof TextShape){
TextRun textRun = ((TextShape)shape[i]).getTextRun();
- if(textRun != null) lst.add(textRun);
+ if(textRun != null) {
+ lst.add(textRun);
+ }
}
}
@@ -356,10 +374,15 @@
*/
public void test44770() throws Exception {
FileInputStream is = new FileInputStream(new File(cwd, "44770.ppt"));
- SlideShow ppt = new SlideShow(is);
+ try {
+ new SlideShow(is);
+ } catch (RuntimeException e) {
+ if (e.getMessage().equals("Couldn't instantiate the class for type with id 1036 on class class org.apache.poi.hslf.record.PPDrawing")) {
+ throw new AssertionFailedError("Identified bug 44770");
+ }
+ throw e;
+ }
is.close();
-
- assertTrue("No Exceptions while reading file", true);
}
/**
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestRecordSetup.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestRecordSetup.java?rev=805262&r1=805261&r2=805262&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestRecordSetup.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestRecordSetup.java Tue Aug 18 02:41:45 2009
@@ -20,7 +20,6 @@
import junit.framework.TestCase;
import org.apache.poi.hslf.*;
-import org.apache.poi.hslf.model.*;
import org.apache.poi.hslf.record.ParentAwareRecord;
import org.apache.poi.hslf.record.Record;
import org.apache.poi.hslf.record.RecordContainer;
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestSoundData.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestSoundData.java?rev=805262&r1=805261&r2=805262&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestSoundData.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestSoundData.java Tue Aug 18 02:41:45 2009
@@ -17,15 +17,12 @@
package org.apache.poi.hslf.usermodel;
-import org.apache.poi.hslf.*;
-import org.apache.poi.hslf.exceptions.HSLFException;
-import org.apache.poi.hslf.blip.*;
-import org.apache.poi.hslf.model.*;
-import junit.framework.TestCase;
-
-import java.io.*;
+import java.io.File;
+import java.io.FileInputStream;
import java.util.Arrays;
+import junit.framework.TestCase;
+
/**
* Test reading sound data from a ppt
*
@@ -35,7 +32,7 @@
protected File cwd;
- public void setUp() throws Exception {
+ public void setUp() {
cwd = new File(System.getProperty("HSLF.testdata.path"));
}
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestSavedByTable.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestSavedByTable.java?rev=805262&r1=805261&r2=805262&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestSavedByTable.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestSavedByTable.java Tue Aug 18 02:41:45 2009
@@ -18,12 +18,12 @@
package org.apache.poi.hwpf.model;
import java.io.*;
-import java.util.*;
-import junit.framework.*;
+import java.util.Arrays;
+import java.util.List;
-import org.apache.poi.hwpf.*;
-import org.apache.poi.hwpf.model.*;
-import org.apache.poi.util.*;
+import junit.framework.TestCase;
+
+import org.apache.poi.hwpf.HWPFDocument;
/**
* Unit test for {@link SavedByTable} and {@link SavedByEntry}.
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestPictures.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestPictures.java?rev=805262&r1=805261&r2=805262&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestPictures.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestPictures.java Tue Aug 18 02:41:45 2009
@@ -35,132 +35,128 @@
public final class TestPictures extends TestCase {
private String dirname = System.getProperty("HWPF.testdata.path");
- protected void setUp() throws Exception {
- }
- /**
- * two jpegs
- */
- public void testTwoImages() throws Exception {
- HWPFDocument doc = new HWPFDocument(new FileInputStream(dirname + "/two_images.doc"));
- List pics = doc.getPicturesTable().getAllPictures();
-
- assertNotNull(pics);
- assertEquals(pics.size(), 2);
- for(int i=0; i<pics.size(); i++) {
- Object p = pics.get(i);
- assertTrue(p instanceof Picture);
-
- Picture pic = (Picture)p;
- assertNotNull(pic.suggestFileExtension());
- assertNotNull(pic.suggestFullFileName());
- }
-
- Picture picA = (Picture)pics.get(0);
- Picture picB = (Picture)pics.get(1);
- assertEquals("jpg", picA.suggestFileExtension());
- assertEquals("jpg", picA.suggestFileExtension());
- }
-
- /**
- * pngs and jpegs
- */
- public void testDifferentImages() throws Exception {
- HWPFDocument doc = new HWPFDocument(new FileInputStream(dirname + "/testPictures.doc"));
- List pics = doc.getPicturesTable().getAllPictures();
-
- assertNotNull(pics);
- assertEquals(7, pics.size());
- for(int i=0; i<pics.size(); i++) {
- Object p = pics.get(i);
- assertTrue(p instanceof Picture);
-
- Picture pic = (Picture)p;
- assertNotNull(pic.suggestFileExtension());
- assertNotNull(pic.suggestFullFileName());
- }
-
- assertEquals("jpg", ((Picture)pics.get(0)).suggestFileExtension());
- assertEquals("jpg", ((Picture)pics.get(1)).suggestFileExtension());
- assertEquals("png", ((Picture)pics.get(3)).suggestFileExtension());
- assertEquals("png", ((Picture)pics.get(4)).suggestFileExtension());
- assertEquals("wmf", ((Picture)pics.get(5)).suggestFileExtension());
- assertEquals("jpg", ((Picture)pics.get(6)).suggestFileExtension());
- }
-
- /**
- * emf image, nice and simple
- */
- public void testEmfImage() throws Exception {
- HWPFDocument doc = new HWPFDocument(new FileInputStream(dirname + "/vector_image.doc"));
- List pics = doc.getPicturesTable().getAllPictures();
-
- assertNotNull(pics);
- assertEquals(1, pics.size());
-
- Picture pic = (Picture)pics.get(0);
- assertNotNull(pic.suggestFileExtension());
- assertNotNull(pic.suggestFullFileName());
- assertTrue(pic.getSize() > 128);
-
- // Check right contents
- byte[] emf = loadImage("vector_image.emf");
- byte[] pemf = pic.getContent();
- assertEquals(emf.length, pemf.length);
- for(int i=0; i<emf.length; i++) {
- assertEquals(emf[i], pemf[i]);
- }
- }
-
- /**
- * emf image, with a crazy offset
- */
- public void testEmfComplexImage() throws Exception {
- /*
-
- Commenting out this test case temporarily. The file emf_2003_image does not contain any
- pictures. Instead it has an office drawing object. Need to rewrite this test after
- revisiting the implementation of office drawing objects.
-
- HWPFDocument doc = new HWPFDocument(new FileInputStream(dirname + "/emf_2003_image.doc"));
- List pics = doc.getPicturesTable().getAllPictures();
-
- assertNotNull(pics);
- assertEquals(1, pics.size());
-
- Picture pic = (Picture)pics.get(0);
- assertNotNull(pic.suggestFileExtension());
- assertNotNull(pic.suggestFullFileName());
-
- // This one's tricky
- // TODO: Fix once we've sorted bug #41898
- assertNotNull(pic.getContent());
- assertNotNull(pic.getRawContent());
-
- // These are probably some sort of offset, need to figure them out
- assertEquals(4, pic.getSize());
- assertEquals(0x80000000l, LittleEndian.getUInt(pic.getContent()));
- assertEquals(0x80000000l, LittleEndian.getUInt(pic.getRawContent()));
- */
- }
-
- public void testPicturesWithTable() throws Exception {
- HWPFDocument doc = new HWPFDocument(new FileInputStream(
- new File(dirname, "Bug44603.doc")));
-
- List pics = doc.getPicturesTable().getAllPictures();
- assertEquals(pics.size(), 2);
- }
-
- private byte[] loadImage(String filename) throws Exception {
- ByteArrayOutputStream b = new ByteArrayOutputStream();
- FileInputStream fis = new FileInputStream(dirname + "/" + filename);
-
- byte[] buf = new byte[4096];
- int read = 0;
- while( (read = fis.read(buf)) > -1 ) {
- b.write(buf, 0, read);
- }
- return b.toByteArray();
- }
+ /**
+ * two jpegs
+ */
+ public void testTwoImages() throws Exception {
+ HWPFDocument doc = new HWPFDocument(new FileInputStream(dirname + "/two_images.doc"));
+ List pics = doc.getPicturesTable().getAllPictures();
+
+ assertNotNull(pics);
+ assertEquals(pics.size(), 2);
+ for(int i=0; i<pics.size(); i++) {
+ Object p = pics.get(i);
+ assertTrue(p instanceof Picture);
+
+ Picture pic = (Picture)p;
+ assertNotNull(pic.suggestFileExtension());
+ assertNotNull(pic.suggestFullFileName());
+ }
+
+ Picture picA = (Picture)pics.get(0);
+ Picture picB = (Picture)pics.get(1);
+ assertEquals("jpg", picA.suggestFileExtension());
+ assertEquals("jpg", picA.suggestFileExtension());
+ }
+
+ /**
+ * pngs and jpegs
+ */
+ public void testDifferentImages() throws Exception {
+ HWPFDocument doc = new HWPFDocument(new FileInputStream(dirname + "/testPictures.doc"));
+ List pics = doc.getPicturesTable().getAllPictures();
+
+ assertNotNull(pics);
+ assertEquals(7, pics.size());
+ for(int i=0; i<pics.size(); i++) {
+ Object p = pics.get(i);
+ assertTrue(p instanceof Picture);
+
+ Picture pic = (Picture)p;
+ assertNotNull(pic.suggestFileExtension());
+ assertNotNull(pic.suggestFullFileName());
+ }
+
+ assertEquals("jpg", ((Picture)pics.get(0)).suggestFileExtension());
+ assertEquals("jpg", ((Picture)pics.get(1)).suggestFileExtension());
+ assertEquals("png", ((Picture)pics.get(3)).suggestFileExtension());
+ assertEquals("png", ((Picture)pics.get(4)).suggestFileExtension());
+ assertEquals("wmf", ((Picture)pics.get(5)).suggestFileExtension());
+ assertEquals("jpg", ((Picture)pics.get(6)).suggestFileExtension());
+ }
+
+ /**
+ * emf image, nice and simple
+ */
+ public void testEmfImage() throws Exception {
+ HWPFDocument doc = new HWPFDocument(new FileInputStream(dirname + "/vector_image.doc"));
+ List pics = doc.getPicturesTable().getAllPictures();
+
+ assertNotNull(pics);
+ assertEquals(1, pics.size());
+
+ Picture pic = (Picture)pics.get(0);
+ assertNotNull(pic.suggestFileExtension());
+ assertNotNull(pic.suggestFullFileName());
+ assertTrue(pic.getSize() > 128);
+
+ // Check right contents
+ byte[] emf = loadImage("vector_image.emf");
+ byte[] pemf = pic.getContent();
+ assertEquals(emf.length, pemf.length);
+ for(int i=0; i<emf.length; i++) {
+ assertEquals(emf[i], pemf[i]);
+ }
+ }
+
+ /**
+ * emf image, with a crazy offset
+ */
+ public void disabled_testEmfComplexImage() throws Exception {
+
+ // Commenting out this test case temporarily. The file emf_2003_image does not contain any
+ // pictures. Instead it has an office drawing object. Need to rewrite this test after
+ // revisiting the implementation of office drawing objects.
+
+ HWPFDocument doc = new HWPFDocument(new FileInputStream(dirname + "/emf_2003_image.doc"));
+ List pics = doc.getPicturesTable().getAllPictures();
+
+ assertNotNull(pics);
+ assertEquals(1, pics.size());
+
+ Picture pic = (Picture)pics.get(0);
+ assertNotNull(pic.suggestFileExtension());
+ assertNotNull(pic.suggestFullFileName());
+
+ // This one's tricky
+ // TODO: Fix once we've sorted bug #41898
+ assertNotNull(pic.getContent());
+ assertNotNull(pic.getRawContent());
+
+ // These are probably some sort of offset, need to figure them out
+ assertEquals(4, pic.getSize());
+ assertEquals(0x80000000l, LittleEndian.getUInt(pic.getContent()));
+ assertEquals(0x80000000l, LittleEndian.getUInt(pic.getRawContent()));
+ }
+
+ public void testPicturesWithTable() throws Exception {
+ HWPFDocument doc = new HWPFDocument(new FileInputStream(
+ new File(dirname, "Bug44603.doc")));
+
+ List pics = doc.getPicturesTable().getAllPictures();
+ assertEquals(pics.size(), 2);
+ }
+
+ private byte[] loadImage(String filename) throws Exception {
+ ByteArrayOutputStream b = new ByteArrayOutputStream();
+ FileInputStream fis = new FileInputStream(dirname + "/" + filename);
+
+ byte[] buf = new byte[4096];
+ int read = 0;
+ while( (read = fis.read(buf)) > -1 ) {
+ b.write(buf, 0, read);
+ }
+ return b.toByteArray();
+ }
}
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestShapes.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestShapes.java?rev=805262&r1=805261&r2=805262&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestShapes.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestShapes.java Tue Aug 18 02:41:45 2009
@@ -19,7 +19,6 @@
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
-import java.io.File;
import java.io.FileInputStream;
import java.util.List;
@@ -33,11 +32,11 @@
public final class TestShapes extends TestCase {
private String dirname = System.getProperty("HWPF.testdata.path");
- /**
- * two shapes, second is a group
- */
- public void testShapes() throws Exception {
- HWPFDocument doc = new HWPFDocument(new FileInputStream(dirname + "/WithArtShapes.doc"));
+ /**
+ * two shapes, second is a group
+ */
+ public void testShapes() throws Exception {
+ HWPFDocument doc = new HWPFDocument(new FileInputStream(dirname + "/WithArtShapes.doc"));
List shapes = doc.getShapesTable().getAllShapes();
List vshapes = doc.getShapesTable().getVisibleShapes();
@@ -79,6 +78,5 @@
assertEquals(4817, s2.getWidth());
assertEquals(2164, s2.getHeight());
assertEquals(true, s2.isWithinDocument());
-
- }
+ }
}
Modified: poi/trunk/src/testcases/org/apache/poi/ddf/TestEscherOptRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ddf/TestEscherOptRecord.java?rev=805262&r1=805261&r2=805262&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/ddf/TestEscherOptRecord.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/ddf/TestEscherOptRecord.java Tue Aug 18 02:41:45 2009
@@ -1,4 +1,3 @@
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
@@ -15,18 +14,16 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
package org.apache.poi.ddf;
import junit.framework.TestCase;
import org.apache.poi.util.HexRead;
import org.apache.poi.util.HexDump;
-import java.io.IOException;
import java.util.Arrays;
-public class TestEscherOptRecord extends TestCase
-{
+public final class TestEscherOptRecord extends TestCase {
public void testFillFields() {
checkFillFieldsSimple();
@@ -151,93 +148,93 @@
}
/**
- * Test serialisation of a particually complex example
+ * Test serialisation of a particually complex example
* This test is currently broken!
*/
public void testComplexSerialise() {
byte[] data = {
- 0x53, 0x01, 0x0B, 0xF0-256, 0x9C-256, 0x01, 0x00, 0x00,
+ 0x53, 0x01, 0x0B, 0xF0-256, 0x9C-256, 0x01, 0x00, 0x00,
// Simple data follows
0x42, 0x01, 0x49, 0x00, 0x00, 0x00, // SP @ 8
0x43, 0x01, 0x85-256, 0x00, 0x00, 0x00, // SP @ 14
0x44, 0x01, 0x04, 0x00, 0x00, 0x00, // SP @ 20
0x45, 0xC1-256, 0x88-256, 0x00, 0x00, 0x00, // SP @ 26
0x46, 0xC1-256, 0x90-256, 0x00, 0x00, 0x00, // SP @ 32
- 0x7F, 0x01, 0x01, 0x00, 0x01, 0x00,
- 0x80-256, 0x01, 0x00, 0x00, 0x00, 0x00,
- 0x81-256, 0x01, 0x02, 0x00, 0x00, 0x08,
- 0xBF-256, 0x01, 0x10, 0x00, 0x10, 0x00,
- 0xC0-256, 0x01, 0x01, 0x00, 0x00, 0x08, // SP 10
+ 0x7F, 0x01, 0x01, 0x00, 0x01, 0x00,
+ 0x80-256, 0x01, 0x00, 0x00, 0x00, 0x00,
+ 0x81-256, 0x01, 0x02, 0x00, 0x00, 0x08,
+ 0xBF-256, 0x01, 0x10, 0x00, 0x10, 0x00,
+ 0xC0-256, 0x01, 0x01, 0x00, 0x00, 0x08, // SP 10
0xC1-256, 0x01, 0x00, 0x00, 0x01, 0x00,
- 0xC4-256, 0x01, 0x00, 0x00, 0x00, 0x00,
- 0xCB-256, 0x01, 0x38, 0x63, 0x00, 0x00,
- 0xCD-256, 0x01, 0x00, 0x00, 0x00, 0x00,
+ 0xC4-256, 0x01, 0x00, 0x00, 0x00, 0x00,
+ 0xCB-256, 0x01, 0x38, 0x63, 0x00, 0x00,
+ 0xCD-256, 0x01, 0x00, 0x00, 0x00, 0x00,
0xCE-256, 0x01, 0x00, 0x00, 0x00, 0x00, // SP 15
- 0xD0-256, 0x01, 0x00, 0x00, 0x00, 0x00,
- 0xD1-256, 0x01, 0x00, 0x00, 0x00, 0x00,
- 0xD7-256, 0x01, 0x00, 0x00, 0x00, 0x00,
+ 0xD0-256, 0x01, 0x00, 0x00, 0x00, 0x00,
+ 0xD1-256, 0x01, 0x00, 0x00, 0x00, 0x00,
+ 0xD7-256, 0x01, 0x00, 0x00, 0x00, 0x00,
0xFF-256, 0x01, 0x18, 0x00, 0x18, 0x00,
- 0x01, 0x02, 0x02, 0x00, 0x00, 0x08,
+ 0x01, 0x02, 0x02, 0x00, 0x00, 0x08,
0x3F, 0x02, 0x00, 0x00, 0x02, 0x00, // SP 21
-
+
// Complex data follows
-
+
// Complex data for Array #325
// Array header
- 0x22, 0x00, 0x22, 0x00, 0xF0-256, 0xFF-256,
+ 0x22, 0x00, 0x22, 0x00, 0xF0-256, 0xFF-256,
// Array data
- 0x18, 0x00, 0x28, 0x00, 0x04, 0x00, 0x34,
+ 0x18, 0x00, 0x28, 0x00, 0x04, 0x00, 0x34,
0x00, 0x04, 0x00, 0x28, 0x00, 0x04, 0x00,
- 0x1C, 0x00, 0x04, 0x00, 0x10, 0x00, 0x04, 0x00, 0x04, 0x00, 0x10,
+ 0x1C, 0x00, 0x04, 0x00, 0x10, 0x00, 0x04, 0x00, 0x04, 0x00, 0x10,
0x00, 0x00, 0x00, 0x1C, 0x00,
- 0x04, 0x00, 0x28, 0x00, 0x10, 0x00, 0x34, 0x00, 0x18, 0x00, 0x3C,
+ 0x04, 0x00, 0x28, 0x00, 0x10, 0x00, 0x34, 0x00, 0x18, 0x00, 0x3C,
0x00, 0x24, 0x00, 0x44, 0x00,
- 0x30, 0x00, 0x48, 0x00, 0x3C, 0x00, 0x44, 0x00, 0x48, 0x00, 0x3C,
+ 0x30, 0x00, 0x48, 0x00, 0x3C, 0x00, 0x44, 0x00, 0x48, 0x00, 0x3C,
0x00, 0x54, 0x00, 0x38, 0x00,
- 0x60, 0x00, 0x2C, 0x00, 0x70, 0x00, 0x20, 0x00, 0x78, 0x00,
+ 0x60, 0x00, 0x2C, 0x00, 0x70, 0x00, 0x20, 0x00, 0x78, 0x00,
0x14, 0x00, 0x80-256, 0x00, 0x08, 0x00,
- 0x84-256, 0x00, 0x04, 0x00, 0x78, 0x00, 0x04, 0x00, 0x6C, 0x00,
+ 0x84-256, 0x00, 0x04, 0x00, 0x78, 0x00, 0x04, 0x00, 0x6C, 0x00,
0x04, 0x00, 0x60, 0x00, 0x04, 0x00,
- 0x54, 0x00, 0x08, 0x00, 0x48, 0x00, 0x0C, 0x00, 0x3C, 0x00, 0x0C,
+ 0x54, 0x00, 0x08, 0x00, 0x48, 0x00, 0x0C, 0x00, 0x3C, 0x00, 0x0C,
0x00, 0x30, 0x00, 0x08, 0x00,
- 0x3C, 0x00, 0x08, 0x00, 0x48, 0x00, 0x08, 0x00, 0x54, 0x00, 0x00,
+ 0x3C, 0x00, 0x08, 0x00, 0x48, 0x00, 0x08, 0x00, 0x54, 0x00, 0x00,
0x00, 0x48, 0x00, 0x00, 0x00,
0x3C, 0x00, 0x00, 0x00, 0x30, 0x00, 0x04, 0x00, 0x24, 0x00,
// Complex data for Array #326
// Array header
- 0x45, 0x00, 0x48, 0x00, 0x02, 0x00,
+ 0x45, 0x00, 0x48, 0x00, 0x02, 0x00,
// Array data
- 0x00, 0x40, 0x00, 0xB0-256, 0x01, 0x00, 0x00, 0xB0-256, 0x01, 0x00,
+ 0x00, 0x40, 0x00, 0xB0-256, 0x01, 0x00, 0x00, 0xB0-256, 0x01, 0x00,
0x00, 0xB0-256, 0x01, 0x00, 0x00, 0xB0-256,
- 0x01, 0x00, 0x00, 0xB0-256, 0x01, 0x00, 0x00, 0xB0-256, 0x01, 0x00,
+ 0x01, 0x00, 0x00, 0xB0-256, 0x01, 0x00, 0x00, 0xB0-256, 0x01, 0x00,
0x00, 0xB0-256, 0x01, 0x00, 0x00, 0xB0-256,
- 0x01, 0x00, 0x00, 0xB0-256, 0x01, 0x00, 0x00, 0xB0-256, 0x01, 0x00,
+ 0x01, 0x00, 0x00, 0xB0-256, 0x01, 0x00, 0x00, 0xB0-256, 0x01, 0x00,
0x00, 0xB0-256, 0x01, 0x00, 0x00, 0xB0-256,
- 0x01, 0x00, 0x00, 0xB0-256, 0x01, 0x00, 0x00, 0xB0-256, 0x01, 0x00,
+ 0x01, 0x00, 0x00, 0xB0-256, 0x01, 0x00, 0x00, 0xB0-256, 0x01, 0x00,
0x00, 0xB0-256, 0x01, 0x00, 0x00, 0xB0-256,
- 0x01, 0x00, 0x00, 0xB0-256, 0x01, 0x00, 0x00, 0xB0-256, 0x01, 0x00,
+ 0x01, 0x00, 0x00, 0xB0-256, 0x01, 0x00, 0x00, 0xB0-256, 0x01, 0x00,
0x00, 0xB0-256, 0x01, 0x00, 0x00, 0xB0-256,
- 0x01, 0x00, 0x00, 0xB0-256, 0x01, 0x00, 0x00, 0xB0-256, 0x01, 0x00,
+ 0x01, 0x00, 0x00, 0xB0-256, 0x01, 0x00, 0x00, 0xB0-256, 0x01, 0x00,
0x00, 0xB0-256, 0x01, 0x00, 0x00, 0xB0-256,
- 0x01, 0x00, 0x00, 0xB0-256, 0x01, 0x00, 0x00, 0xB0-256, 0x01, 0x00,
+ 0x01, 0x00, 0x00, 0xB0-256, 0x01, 0x00, 0x00, 0xB0-256, 0x01, 0x00,
0x00, 0xB0-256, 0x01, 0x00, 0x00, 0xB0-256,
- 0x01, 0x00, 0x00, 0xB0-256, 0x01, 0x00, 0x00, 0xB0-256, 0x01, 0x00,
+ 0x01, 0x00, 0x00, 0xB0-256, 0x01, 0x00, 0x00, 0xB0-256, 0x01, 0x00,
0x00, 0xB0-256, 0x01, 0x00, 0x00, 0xB0-256,
0x01, 0x00, 0x00, 0xB0-256, 0x01, 0x00, 0x00, 0xB0-256, 0x00, 0x80-256
};
-
+
// Create the record
EscherOptRecord r = new EscherOptRecord();
int filled = r.fillFields( data, new DefaultEscherRecordFactory() );
-
+
// Check it's the right length
assertEquals(data.length, filled);
assertEquals(data.length, r.getRecordSize());
-
+
// Serialise it
byte[] dest = new byte[data.length];
int written = r.serialize(0, dest);
-
+
// Check it serialised it back to the same data
assertEquals(data.length, written);
for(int i=0; i<data.length; i++) {
Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestDrawingRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestDrawingRecord.java?rev=805262&r1=805261&r2=805262&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestDrawingRecord.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestDrawingRecord.java Tue Aug 18 02:41:45 2009
@@ -17,18 +17,13 @@
package org.apache.poi.hssf.record;
-import junit.framework.TestCase;
-import org.apache.poi.ddf.EscherContainerRecord;
-import org.apache.poi.ddf.EscherSpRecord;
-import org.apache.poi.util.HexDump;
-import org.apache.poi.util.HexRead;
-import org.apache.poi.util.LittleEndianOutput;
-import org.apache.poi.util.LittleEndianOutputStream;
-import org.apache.poi.hssf.HSSFTestDataSamples;
-
-import java.io.*;
-import java.util.List;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
import java.util.Arrays;
+import java.util.List;
+
+import junit.framework.TestCase;
public final class TestDrawingRecord extends TestCase {
@@ -68,4 +63,4 @@
}
-}
\ No newline at end of file
+}
Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestTextObjectBaseRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestTextObjectBaseRecord.java?rev=805262&r1=805261&r2=805262&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestTextObjectBaseRecord.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestTextObjectBaseRecord.java Tue Aug 18 02:41:45 2009
@@ -18,8 +18,6 @@
package org.apache.poi.hssf.record;
-import java.io.ByteArrayInputStream;
-
import org.apache.poi.hssf.usermodel.HSSFRichTextString;
import org.apache.poi.util.HexRead;
@@ -48,11 +46,11 @@
"00 " + // unicode compressed
"41 42 " + // 'AB'
"3C 00 " + // ContinueRecord.sid
- "10 00 " + // size 16
+ "10 00 " + // size 16
"00 00 18 00 00 00 00 00 " +
- "02 00 00 00 00 00 00 00 "
+ "02 00 00 00 00 00 00 00 "
);
-
+
public void testLoad() {
RecordInputStream in = TestcaseRecordInputStream.create(data);
Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/aggregates/TestSharedValueManager.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/aggregates/TestSharedValueManager.java?rev=805262&r1=805261&r2=805262&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/aggregates/TestSharedValueManager.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/aggregates/TestSharedValueManager.java Tue Aug 18 02:41:45 2009
@@ -17,9 +17,6 @@
package org.apache.poi.hssf.record.aggregates;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
import java.util.Collection;
import java.util.HashMap;
@@ -35,7 +32,7 @@
/**
* Tests for {@link SharedValueManager}
- *
+ *
* @author Josh Micich
*/
public final class TestSharedValueManager extends TestCase {
@@ -46,19 +43,19 @@
* The second sheet has two column shared formula ranges - one contained within the other.
* These shared formula ranges were created by fill-dragging a single cell formula across the
* desired region. The larger shared formula ranges were placed first.<br/>
- *
+ *
* There are probably many ways to produce similar effects, but it should be noted that Excel
* is quite temperamental in this regard. Slight variations in technique can cause the shared
* formulas to spill out into plain formula records (which would make these tests pointless).
- *
+ *
*/
private static final String SAMPLE_FILE_NAME = "overlapSharedFormula.xls";
/**
- * Some of these bugs are intermittent, and the test author couldn't think of a way to write
+ * Some of these bugs are intermittent, and the test author couldn't think of a way to write
* test code to hit them bug deterministically. The reason for the unpredictability is that
* the bugs depended on the {@link SharedFormulaRecord}s being searched in a particular order.
- * At the time of writing of the test, the order was being determined by the call to {@link
- * Collection#toArray(Object[])} on {@link HashMap#values()} where the items in the map were
+ * At the time of writing of the test, the order was being determined by the call to {@link
+ * Collection#toArray(Object[])} on {@link HashMap#values()} where the items in the map were
* using default {@link Object#hashCode()}<br/>
*/
private static final int MAX_ATTEMPTS=5;
@@ -67,24 +64,24 @@
* This bug happened when there were two or more shared formula ranges that overlapped. POI
* would sometimes associate formulas in the overlapping region with the wrong shared formula
*/
- public void testPartiallyOverlappingRanges() throws IOException {
+ public void testPartiallyOverlappingRanges() {
Record[] records;
int attempt=1;
do {
- HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook(SAMPLE_FILE_NAME);
-
- HSSFSheet sheet = wb.getSheetAt(0);
- RecordInspector.getRecords(sheet, 0);
- assertEquals("1+1", sheet.getRow(2).getCell(0).getCellFormula());
- if ("1+1".equals(sheet.getRow(3).getCell(0).getCellFormula())) {
- throw new AssertionFailedError("Identified bug - wrong shared formula record chosen"
- + " (attempt " + attempt + ")");
- }
- assertEquals("2+2", sheet.getRow(3).getCell(0).getCellFormula());
- records = RecordInspector.getRecords(sheet, 0);
+ HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook(SAMPLE_FILE_NAME);
+
+ HSSFSheet sheet = wb.getSheetAt(0);
+ RecordInspector.getRecords(sheet, 0);
+ assertEquals("1+1", sheet.getRow(2).getCell(0).getCellFormula());
+ if ("1+1".equals(sheet.getRow(3).getCell(0).getCellFormula())) {
+ throw new AssertionFailedError("Identified bug - wrong shared formula record chosen"
+ + " (attempt " + attempt + ")");
+ }
+ assertEquals("2+2", sheet.getRow(3).getCell(0).getCellFormula());
+ records = RecordInspector.getRecords(sheet, 0);
} while (attempt++ < MAX_ATTEMPTS);
-
+
int count=0;
for (int i = 0; i < records.length; i++) {
if (records[i] instanceof SharedFormulaRecord) {
@@ -93,28 +90,28 @@
}
assertEquals(2, count);
}
-
+
/**
* This bug occurs for similar reasons to the bug in {@link #testPartiallyOverlappingRanges()}
* but the symptoms are much uglier - serialization fails with {@link NullPointerException}.<br/>
*/
- public void testCompletelyOverlappedRanges() throws IOException {
+ public void testCompletelyOverlappedRanges() {
Record[] records;
int attempt=1;
do {
- HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook(SAMPLE_FILE_NAME);
-
- HSSFSheet sheet = wb.getSheetAt(1);
- try {
- records = RecordInspector.getRecords(sheet, 0);
- } catch (NullPointerException e) {
- throw new AssertionFailedError("Identified bug " +
- "- cannot reserialize completely overlapped shared formula"
- + " (attempt " + attempt + ")");
- }
+ HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook(SAMPLE_FILE_NAME);
+
+ HSSFSheet sheet = wb.getSheetAt(1);
+ try {
+ records = RecordInspector.getRecords(sheet, 0);
+ } catch (NullPointerException e) {
+ throw new AssertionFailedError("Identified bug " +
+ "- cannot reserialize completely overlapped shared formula"
+ + " (attempt " + attempt + ")");
+ }
} while (attempt++ < MAX_ATTEMPTS);
-
+
int count=0;
for (int i = 0; i < records.length; i++) {
if (records[i] instanceof SharedFormulaRecord) {
Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/formula/AbstractPtgTestCase.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/formula/AbstractPtgTestCase.java?rev=805262&r1=805261&r2=805262&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/formula/AbstractPtgTestCase.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/formula/AbstractPtgTestCase.java Tue Aug 18 02:41:45 2009
@@ -17,18 +17,10 @@
package org.apache.poi.hssf.record.formula;
-import java.io.BufferedInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-
import junit.framework.TestCase;
import org.apache.poi.hssf.HSSFTestDataSamples;
-import org.apache.poi.hssf.model.Workbook;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
-import org.apache.poi.poifs.filesystem.POIFSFileSystem;
/**
* Convenient abstract class to reduce the amount of boilerplate code needed
Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/formula/TestArrayPtg.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/formula/TestArrayPtg.java?rev=805262&r1=805261&r2=805262&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/formula/TestArrayPtg.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/formula/TestArrayPtg.java Tue Aug 18 02:41:45 2009
@@ -19,26 +19,24 @@
import java.util.Arrays;
+import junit.framework.AssertionFailedError;
+import junit.framework.TestCase;
+
import org.apache.poi.hssf.HSSFTestDataSamples;
-import org.apache.poi.hssf.record.RecordInputStream;
import org.apache.poi.hssf.record.TestcaseRecordInputStream;
-import org.apache.poi.hssf.record.UnicodeString;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.util.LittleEndianByteArrayOutputStream;
import org.apache.poi.util.LittleEndianInput;
-
-import junit.framework.AssertionFailedError;
-import junit.framework.TestCase;
/**
* Tests for <tt>ArrayPtg</tt>
- *
+ *
* @author Josh Micich
*/
public final class TestArrayPtg extends TestCase {
private static final byte[] ENCODED_PTG_DATA = {
0x40,
- 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0,
};
private static final byte[] ENCODED_CONSTANT_DATA = {
2, // 3 columns
@@ -52,28 +50,28 @@
};
/**
- * Lots of problems with ArrayPtg's encoding of
+ * Lots of problems with ArrayPtg's encoding of
*/
public void testReadWriteTokenValueBytes() {
-
+
ArrayPtg ptg = new ArrayPtg(TestcaseRecordInputStream.createLittleEndian(ENCODED_PTG_DATA));
-
+
ptg.readTokenValues(TestcaseRecordInputStream.createLittleEndian(ENCODED_CONSTANT_DATA));
assertEquals(3, ptg.getColumnCount());
assertEquals(2, ptg.getRowCount());
Object[][] values = ptg.getTokenArrayValues();
assertEquals(2, values.length);
-
-
+
+
assertEquals(Boolean.TRUE, values[0][0]);
assertEquals("ABCD", values[0][1]);
assertEquals(new Double(0), values[1][0]);
assertEquals(Boolean.FALSE, values[1][1]);
assertEquals("FG", values[1][2]);
-
+
byte[] outBuf = new byte[ENCODED_CONSTANT_DATA.length];
ptg.writeTokenValueBytes(new LittleEndianByteArrayOutputStream(outBuf, 0));
-
+
if(outBuf[0] == 4) {
throw new AssertionFailedError("Identified bug 42564b");
}
@@ -88,7 +86,7 @@
ptg.readTokenValues(TestcaseRecordInputStream.createLittleEndian(ENCODED_CONSTANT_DATA));
assertEquals(3, ptg.getColumnCount());
assertEquals(2, ptg.getRowCount());
-
+
assertEquals(0, ptg.getValueIndex(0, 0));
assertEquals(1, ptg.getValueIndex(1, 0));
assertEquals(2, ptg.getValueIndex(2, 0));
@@ -96,7 +94,7 @@
assertEquals(4, ptg.getValueIndex(1, 1));
assertEquals(5, ptg.getValueIndex(2, 1));
}
-
+
/**
* Test for a bug which was temporarily introduced by the fix for bug 42564.
* A spreadsheet was added to make the ordering clearer.
@@ -104,7 +102,7 @@
public void testElementOrderingInSpreadsheet() {
HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("ex42564-elementOrder.xls");
- // The formula has an array with 3 rows and 5 columns
+ // The formula has an array with 3 rows and 5 columns
String formula = wb.getSheetAt(0).getRow(0).getCell(0).getCellFormula();
// TODO - These number literals should not have '.0'. Excel has different number rendering rules
@@ -116,9 +114,9 @@
public void testToFormulaString() {
ArrayPtg ptg = new ArrayPtg(TestcaseRecordInputStream.createLittleEndian(ENCODED_PTG_DATA));
-
+
ptg.readTokenValues(TestcaseRecordInputStream.createLittleEndian(ENCODED_CONSTANT_DATA));
-
+
String actualFormula;
try {
actualFormula = ptg.toFormulaString();
@@ -130,7 +128,7 @@
}
assertEquals("{TRUE,\"ABCD\",\"E\";0.0,FALSE,\"FG\"}", actualFormula);
}
-
+
/**
* worth checking since AttrPtg.sid=0x20 and Ptg.CLASS_* = (0x00, 0x20, and 0x40)
*/
@@ -145,11 +143,11 @@
System.arraycopy(ENCODED_PTG_DATA, 0, fullData, 0, ENCODED_PTG_DATA.length);
System.arraycopy(ENCODED_CONSTANT_DATA, 0, fullData, ENCODED_PTG_DATA.length, ENCODED_CONSTANT_DATA.length);
- // Force encoded operand class for tArray
+ // Force encoded operand class for tArray
fullData[0] = (byte) (ArrayPtg.sid + operandClass);
-
+
LittleEndianInput in = TestcaseRecordInputStream.createLittleEndian(fullData);
-
+
Ptg[] ptgs = Ptg.readTokens(ENCODED_PTG_DATA.length, in);
assertEquals(1, ptgs.length);
ArrayPtg aPtg = (ArrayPtg) ptgs[0];
Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/formula/eval/TestCircularReferences.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/formula/eval/TestCircularReferences.java?rev=805262&r1=805261&r2=805262&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/formula/eval/TestCircularReferences.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/formula/eval/TestCircularReferences.java Tue Aug 18 02:41:45 2009
@@ -27,10 +27,9 @@
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellValue;
-import org.apache.poi.ss.usermodel.ErrorConstants;
/**
* Tests HSSFFormulaEvaluator for its handling of cell formula circular references.
- *
+ *
* @author Josh Micich
*/
public final class TestCircularReferences extends TestCase {
@@ -53,17 +52,17 @@
assertTrue(cellValue.getCellType() == HSSFCell.CELL_TYPE_ERROR);
assertEquals(ErrorEval.CIRCULAR_REF_ERROR.getErrorCode(), cellValue.getErrorValue());
}
-
-
+
+
/**
- * ASF Bugzilla Bug 44413
- * "INDEX() formula cannot contain its own location in the data array range"
+ * ASF Bugzilla Bug 44413
+ * "INDEX() formula cannot contain its own location in the data array range"
*/
public void testIndexFormula() {
-
+
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet = wb.createSheet("Sheet1");
-
+
int colB = 1;
sheet.createRow(0).createCell(colB).setCellValue(1);
sheet.createRow(1).createCell(colB).setCellValue(2);
@@ -73,13 +72,13 @@
// This formula should evaluate to the contents of B2,
testCell.setCellFormula("INDEX(A1:B4,2,2)");
// However the range A1:B4 also includes the current cell A4. If the other parameters
- // were 4 and 1, this would represent a circular reference. Prior to v3.2 POI would
+ // were 4 and 1, this would represent a circular reference. Prior to v3.2 POI would
// 'fully' evaluate ref arguments before invoking operators, which raised the possibility of
// cycles / StackOverflowErrors.
-
+
CellValue cellValue = evaluateWithCycles(wb, testCell);
-
+
assertTrue(cellValue.getCellType() == HSSFCell.CELL_TYPE_NUMERIC);
assertEquals(2, cellValue.getNumberValue(), 0);
}
@@ -88,16 +87,16 @@
* Cell A1 has formula "=A1"
*/
public void testSimpleCircularReference() {
-
+
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet = wb.createSheet("Sheet1");
-
+
HSSFRow row = sheet.createRow(0);
HSSFCell testCell = row.createCell(0);
testCell.setCellFormula("A1");
CellValue cellValue = evaluateWithCycles(wb, testCell);
-
+
confirmCycleErrorCode(cellValue);
}
@@ -105,10 +104,10 @@
* A1=B1, B1=C1, C1=D1, D1=A1
*/
public void testMultiLevelCircularReference() {
-
+
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet = wb.createSheet("Sheet1");
-
+
HSSFRow row = sheet.createRow(0);
row.createCell(0).setCellFormula("B1");
row.createCell(1).setCellFormula("C1");
@@ -117,39 +116,39 @@
testCell.setCellFormula("A1");
CellValue cellValue = evaluateWithCycles(wb, testCell);
-
+
confirmCycleErrorCode(cellValue);
}
-
+
public void testIntermediateCircularReferenceResults_bug46898() {
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet = wb.createSheet("Sheet1");
-
+
HSSFRow row = sheet.createRow(0);
-
+
HSSFCell cellA1 = row.createCell(0);
HSSFCell cellB1 = row.createCell(1);
HSSFCell cellC1 = row.createCell(2);
HSSFCell cellD1 = row.createCell(3);
HSSFCell cellE1 = row.createCell(4);
-
+
cellA1.setCellFormula("IF(FALSE, 1+B1, 42)");
cellB1.setCellFormula("1+C1");
cellC1.setCellFormula("1+D1");
cellD1.setCellFormula("1+E1");
cellE1.setCellFormula("1+A1");
-
+
HSSFFormulaEvaluator fe = new HSSFFormulaEvaluator(wb);
CellValue cv;
-
- // Happy day flow - evaluate A1 first
+
+ // Happy day flow - evaluate A1 first
cv = fe.evaluate(cellA1);
assertEquals(Cell.CELL_TYPE_NUMERIC, cv.getCellType());
assertEquals(42.0, cv.getNumberValue(), 0.0);
cv = fe.evaluate(cellB1); // no circ-ref-error because A1 result is cached
assertEquals(Cell.CELL_TYPE_NUMERIC, cv.getCellType());
assertEquals(46.0, cv.getNumberValue(), 0.0);
-
+
// Show the bug - evaluate another cell from the loop first
fe.clearAllCachedResultValues();
cv = fe.evaluate(cellB1);
@@ -164,7 +163,7 @@
cv = fe.evaluate(cellE1);
assertEquals(Cell.CELL_TYPE_NUMERIC, cv.getCellType());
assertEquals(43.0, cv.getNumberValue(), 0.0);
-
-
+
+
}
}
Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/formula/functions/NumericFunctionInvoker.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/formula/functions/NumericFunctionInvoker.java?rev=805262&r1=805261&r2=805262&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/formula/functions/NumericFunctionInvoker.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/formula/functions/NumericFunctionInvoker.java Tue Aug 18 02:41:45 2009
@@ -20,7 +20,6 @@
import junit.framework.AssertionFailedError;
import org.apache.poi.hssf.record.formula.eval.ErrorEval;
-import org.apache.poi.hssf.record.formula.eval.ValueEval;
import org.apache.poi.hssf.record.formula.eval.NumericValueEval;
import org.apache.poi.hssf.record.formula.eval.OperationEval;
import org.apache.poi.hssf.record.formula.eval.ValueEval;
Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestCloneSheet.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestCloneSheet.java?rev=805262&r1=805261&r2=805262&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestCloneSheet.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestCloneSheet.java Tue Aug 18 02:41:45 2009
@@ -1,4 +1,3 @@
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
@@ -15,19 +14,17 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
package org.apache.poi.hssf.usermodel;
import junit.framework.TestCase;
import org.apache.poi.ss.util.CellRangeAddress;
-import org.apache.poi.ss.util.Region;
/**
- * Test the ability to clone a sheet.
+ * Test the ability to clone a sheet.
* If adding new records that belong to a sheet (as opposed to a book)
- * add that record to the sheet in the testCloneSheetBasic method.
+ * add that record to the sheet in the testCloneSheetBasic method.
* @author avik
*/
public final class TestCloneSheet extends TestCase {
@@ -37,26 +34,25 @@
HSSFSheet s = b.createSheet("Test");
s.addMergedRegion(new CellRangeAddress(0, 1, 0, 1));
HSSFSheet clonedSheet = b.cloneSheet(0);
-
+
assertEquals("One merged area", 1, clonedSheet.getNumMergedRegions());
}
- /**
- * Ensures that pagebreak cloning works properly
- *
- */
- public void testPageBreakClones() {
- HSSFWorkbook b = new HSSFWorkbook();
- HSSFSheet s = b.createSheet("Test");
- s.setRowBreak(3);
- s.setColumnBreak((short)6);
-
- HSSFSheet clone = b.cloneSheet(0);
- assertTrue("Row 3 not broken", clone.isRowBroken(3));
- assertTrue("Column 6 not broken", clone.isColumnBroken((short)6));
-
- s.removeRowBreak(3);
-
- assertTrue("Row 3 still should be broken", clone.isRowBroken(3));
- }
+ /**
+ * Ensures that pagebreak cloning works properly
+ */
+ public void testPageBreakClones() {
+ HSSFWorkbook b = new HSSFWorkbook();
+ HSSFSheet s = b.createSheet("Test");
+ s.setRowBreak(3);
+ s.setColumnBreak((short) 6);
+
+ HSSFSheet clone = b.cloneSheet(0);
+ assertTrue("Row 3 not broken", clone.isRowBroken(3));
+ assertTrue("Column 6 not broken", clone.isColumnBroken((short) 6));
+
+ s.removeRowBreak(3);
+
+ assertTrue("Row 3 still should be broken", clone.isRowBroken(3));
+ }
}
Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFConditionalFormatting.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFConditionalFormatting.java?rev=805262&r1=805261&r2=805262&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFConditionalFormatting.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFConditionalFormatting.java Tue Aug 18 02:41:45 2009
@@ -23,10 +23,9 @@
import org.apache.poi.hssf.record.CFRuleRecord.ComparisonOperator;
import org.apache.poi.hssf.util.HSSFColor;
import org.apache.poi.ss.util.CellRangeAddress;
-import org.apache.poi.ss.util.Region;
/**
- *
+ *
* @author Dmitriy Kumshayev
*/
public final class TestHSSFConditionalFormatting extends TestCase {
@@ -36,7 +35,7 @@
String formula = "7";
HSSFSheetConditionalFormatting sheetCF = sheet.getSheetConditionalFormatting();
-
+
HSSFConditionalFormattingRule rule1 = sheetCF.createConditionalFormattingRule(formula);
HSSFFontFormatting fontFmt = rule1.createFontFormatting();
fontFmt.setFontStyle(true, false);
@@ -50,7 +49,7 @@
HSSFPatternFormatting patternFmt = rule1.createPatternFormatting();
patternFmt.setFillBackgroundColor(HSSFColor.YELLOW.index);
-
+
HSSFConditionalFormattingRule rule2 = sheetCF.createConditionalFormattingRule(ComparisonOperator.BETWEEN, "1", "2");
HSSFConditionalFormattingRule [] cfRules =
{
@@ -84,12 +83,12 @@
assertEquals(2, cf.getNumberOfRules());
rule1 = cf.getRule(0);
- assertEquals("7",rule1.getFormula1());
+ assertEquals("7",rule1.getFormula1());
assertNull(rule1.getFormula2());
-
+
HSSFFontFormatting r1fp = rule1.getFontFormatting();
assertNotNull(r1fp);
-
+
assertTrue(r1fp.isItalic());
assertFalse(r1fp.isBold());
@@ -102,13 +101,13 @@
HSSFPatternFormatting r1pf = rule1.getPatternFormatting();
assertNotNull(r1pf);
- assertEquals(HSSFColor.YELLOW.index,r1pf.getFillBackgroundColor());
+ assertEquals(HSSFColor.YELLOW.index,r1pf.getFillBackgroundColor());
rule2 = cf.getRule(1);
- assertEquals("2",rule2.getFormula2());
- assertEquals("1",rule2.getFormula1());
+ assertEquals("2",rule2.getFormula2());
+ assertEquals("1",rule2.getFormula1());
}
-
+
public void testClone() {
HSSFWorkbook wb = new HSSFWorkbook();
@@ -116,7 +115,7 @@
String formula = "7";
HSSFSheetConditionalFormatting sheetCF = sheet.getSheetConditionalFormatting();
-
+
HSSFConditionalFormattingRule rule1 = sheetCF.createConditionalFormattingRule(formula);
HSSFFontFormatting fontFmt = rule1.createFontFormatting();
fontFmt.setFontStyle(true, false);
@@ -124,7 +123,7 @@
HSSFPatternFormatting patternFmt = rule1.createPatternFormatting();
patternFmt.setFillBackgroundColor(HSSFColor.YELLOW.index);
-
+
HSSFConditionalFormattingRule rule2 = sheetCF.createConditionalFormattingRule(ComparisonOperator.BETWEEN, "1", "2");
HSSFConditionalFormattingRule [] cfRules =
{
@@ -137,7 +136,7 @@
};
sheetCF.addConditionalFormatting(regions, cfRules);
-
+
try {
wb.cloneSheet(0);
} catch (RuntimeException e) {
Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFDateUtil.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFDateUtil.java?rev=805262&r1=805261&r2=805262&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFDateUtil.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFDateUtil.java Tue Aug 18 02:41:45 2009
@@ -1,4 +1,3 @@
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
@@ -442,7 +441,7 @@
* Ensure that date values *with* a fractional portion get the right time of day
*/
public void testConvertDateTime() {
- // Excel day 30000 is date 18-Feb-1982
+ // Excel day 30000 is date 18-Feb-1982
// 0.7 corresponds to time 16:48:00
Date actual = HSSFDateUtil.getJavaDate(30000.7);
Date expected = createDate(1982, 1, 18, 16, 48, 0);
Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFFont.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFFont.java?rev=805262&r1=805261&r2=805262&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFFont.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFFont.java Tue Aug 18 02:41:45 2009
@@ -17,26 +17,9 @@
package org.apache.poi.hssf.usermodel;
-import java.util.Date;
-import java.util.GregorianCalendar;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-
-import junit.framework.AssertionFailedError;
import org.apache.poi.hssf.HSSFITestDataProvider;
-import org.apache.poi.hssf.HSSFTestDataSamples;
-import org.apache.poi.hssf.model.Sheet;
-import org.apache.poi.hssf.model.HSSFFormulaParser;
-import org.apache.poi.hssf.record.DBCellRecord;
-import org.apache.poi.hssf.record.FormulaRecord;
-import org.apache.poi.hssf.record.Record;
-import org.apache.poi.hssf.record.StringRecord;
-import org.apache.poi.hssf.record.formula.Ptg;
-import org.apache.poi.ss.usermodel.*;
-import org.apache.poi.ss.util.AreaReference;
-import org.apache.poi.ss.util.CellReference;
-import org.apache.poi.ss.formula.FormulaType;
+import org.apache.poi.ss.usermodel.BaseTestFont;
+import org.apache.poi.ss.usermodel.Font;
/**
* Tests various functionality having to do with {@link org.apache.poi.ss.usermodel.Name}.
@@ -53,4 +36,4 @@
public void testDefaultFont() {
baseTestDefaultFont(HSSFFont.FONT_ARIAL, (short)200, Font.COLOR_NORMAL);
}
-}
\ No newline at end of file
+}
Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFOptimiser.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFOptimiser.java?rev=805262&r1=805261&r2=805262&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFOptimiser.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFOptimiser.java Tue Aug 18 02:41:45 2009
@@ -16,133 +16,126 @@
==================================================================== */
package org.apache.poi.hssf.usermodel;
-import org.apache.poi.hssf.model.Workbook;
-
import junit.framework.TestCase;
-public class TestHSSFOptimiser extends TestCase {
- public void testDoesNoHarmIfNothingToDo() throws Exception {
+public final class TestHSSFOptimiser extends TestCase {
+ public void testDoesNoHarmIfNothingToDo() {
HSSFWorkbook wb = new HSSFWorkbook();
-
+
HSSFFont f = wb.createFont();
f.setFontName("Testing");
HSSFCellStyle s = wb.createCellStyle();
s.setFont(f);
-
+
assertEquals(5, wb.getNumberOfFonts());
assertEquals(22, wb.getNumCellStyles());
-
+
// Optimise fonts
HSSFOptimiser.optimiseFonts(wb);
-
+
assertEquals(5, wb.getNumberOfFonts());
assertEquals(22, wb.getNumCellStyles());
-
+
assertEquals(f, s.getFont(wb));
-
+
// Optimise styles
HSSFOptimiser.optimiseCellStyles(wb);
-
+
assertEquals(5, wb.getNumberOfFonts());
assertEquals(22, wb.getNumCellStyles());
-
+
assertEquals(f, s.getFont(wb));
}
-
- public void testOptimiseFonts() throws Exception {
+
+ public void testOptimiseFonts() {
HSSFWorkbook wb = new HSSFWorkbook();
-
+
// Add 6 fonts, some duplicates
HSSFFont f1 = wb.createFont();
- f1.setFontHeight((short)11);
+ f1.setFontHeight((short) 11);
f1.setFontName("Testing");
-
+
HSSFFont f2 = wb.createFont();
- f2.setFontHeight((short)22);
+ f2.setFontHeight((short) 22);
f2.setFontName("Also Testing");
-
+
HSSFFont f3 = wb.createFont();
- f3.setFontHeight((short)33);
+ f3.setFontHeight((short) 33);
f3.setFontName("Unique");
-
+
HSSFFont f4 = wb.createFont();
- f4.setFontHeight((short)11);
+ f4.setFontHeight((short) 11);
f4.setFontName("Testing");
-
+
HSSFFont f5 = wb.createFont();
- f5.setFontHeight((short)22);
+ f5.setFontHeight((short) 22);
f5.setFontName("Also Testing");
-
+
HSSFFont f6 = wb.createFont();
- f6.setFontHeight((short)66);
+ f6.setFontHeight((short) 66);
f6.setFontName("Also Unique");
-
-
-
+
// Use all three of the four in cell styles
assertEquals(21, wb.getNumCellStyles());
-
+
HSSFCellStyle cs1 = wb.createCellStyle();
cs1.setFont(f1);
assertEquals(5, cs1.getFontIndex());
-
+
HSSFCellStyle cs2 = wb.createCellStyle();
cs2.setFont(f4);
assertEquals(8, cs2.getFontIndex());
-
+
HSSFCellStyle cs3 = wb.createCellStyle();
cs3.setFont(f5);
assertEquals(9, cs3.getFontIndex());
-
+
HSSFCellStyle cs4 = wb.createCellStyle();
cs4.setFont(f6);
assertEquals(10, cs4.getFontIndex());
-
+
assertEquals(25, wb.getNumCellStyles());
-
-
+
// And three in rich text
HSSFSheet s = wb.createSheet();
HSSFRow r = s.createRow(0);
-
+
HSSFRichTextString rtr1 = new HSSFRichTextString("Test");
rtr1.applyFont(0, 2, f1);
rtr1.applyFont(3, 4, f2);
r.createCell(0).setCellValue(rtr1);
-
+
HSSFRichTextString rtr2 = new HSSFRichTextString("AlsoTest");
rtr2.applyFont(0, 2, f3);
rtr2.applyFont(3, 5, f5);
rtr2.applyFont(6, 8, f6);
r.createCell(1).setCellValue(rtr2);
-
-
+
// Check what we have now
assertEquals(10, wb.getNumberOfFonts());
assertEquals(25, wb.getNumCellStyles());
-
+
// Optimise
HSSFOptimiser.optimiseFonts(wb);
-
+
// Check font count
assertEquals(8, wb.getNumberOfFonts());
assertEquals(25, wb.getNumCellStyles());
-
+
// Check font use in cell styles
assertEquals(5, cs1.getFontIndex());
assertEquals(5, cs2.getFontIndex()); // duplicate of 1
assertEquals(6, cs3.getFontIndex()); // duplicate of 2
assertEquals(8, cs4.getFontIndex()); // two have gone
-
-
+
// And in rich text
-
- // RTR 1 had f1 and f2, unchanged
+
+ // RTR 1 had f1 and f2, unchanged
assertEquals(5, r.getCell(0).getRichStringCellValue().getFontAtIndex(0));
assertEquals(5, r.getCell(0).getRichStringCellValue().getFontAtIndex(1));
assertEquals(6, r.getCell(0).getRichStringCellValue().getFontAtIndex(3));
assertEquals(6, r.getCell(0).getRichStringCellValue().getFontAtIndex(4));
-
+
// RTR 2 had f3 (unchanged), f5 (=f2) and f6 (moved down)
assertEquals(7, r.getCell(1).getRichStringCellValue().getFontAtIndex(0));
assertEquals(7, r.getCell(1).getRichStringCellValue().getFontAtIndex(1));
@@ -151,54 +144,52 @@
assertEquals(8, r.getCell(1).getRichStringCellValue().getFontAtIndex(6));
assertEquals(8, r.getCell(1).getRichStringCellValue().getFontAtIndex(7));
}
-
- public void testOptimiseStyles() throws Exception {
+
+ public void testOptimiseStyles() {
HSSFWorkbook wb = new HSSFWorkbook();
// Two fonts
assertEquals(4, wb.getNumberOfFonts());
-
+
HSSFFont f1 = wb.createFont();
- f1.setFontHeight((short)11);
+ f1.setFontHeight((short) 11);
f1.setFontName("Testing");
-
+
HSSFFont f2 = wb.createFont();
- f2.setFontHeight((short)22);
+ f2.setFontHeight((short) 22);
f2.setFontName("Also Testing");
assertEquals(6, wb.getNumberOfFonts());
-
-
+
// Several styles
assertEquals(21, wb.getNumCellStyles());
-
+
HSSFCellStyle cs1 = wb.createCellStyle();
cs1.setFont(f1);
-
+
HSSFCellStyle cs2 = wb.createCellStyle();
cs2.setFont(f2);
-
+
HSSFCellStyle cs3 = wb.createCellStyle();
cs3.setFont(f1);
-
+
HSSFCellStyle cs4 = wb.createCellStyle();
cs4.setFont(f1);
- cs4.setAlignment((short)22);
-
+ cs4.setAlignment((short) 22);
+
HSSFCellStyle cs5 = wb.createCellStyle();
cs5.setFont(f2);
- cs5.setAlignment((short)111);
-
+ cs5.setAlignment((short) 111);
+
HSSFCellStyle cs6 = wb.createCellStyle();
cs6.setFont(f2);
-
+
assertEquals(27, wb.getNumCellStyles());
-
-
+
// Use them
HSSFSheet s = wb.createSheet();
HSSFRow r = s.createRow(0);
-
+
r.createCell(0).setCellStyle(cs1);
r.createCell(1).setCellStyle(cs2);
r.createCell(2).setCellStyle(cs3);
@@ -207,20 +198,18 @@
r.createCell(5).setCellStyle(cs6);
r.createCell(6).setCellStyle(cs1);
r.createCell(7).setCellStyle(cs2);
-
+
assertEquals(21, r.getCell(0).getCellValueRecord().getXFIndex());
assertEquals(26, r.getCell(5).getCellValueRecord().getXFIndex());
assertEquals(21, r.getCell(6).getCellValueRecord().getXFIndex());
-
-
+
// Optimise
HSSFOptimiser.optimiseCellStyles(wb);
-
-
+
// Check
assertEquals(6, wb.getNumberOfFonts());
assertEquals(25, wb.getNumCellStyles());
-
+
// cs1 -> 21
assertEquals(21, r.getCell(0).getCellValueRecord().getXFIndex());
// cs2 -> 22
Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFPicture.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFPicture.java?rev=805262&r1=805261&r2=805262&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFPicture.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFPicture.java Tue Aug 18 02:41:45 2009
@@ -1,22 +1,21 @@
-/*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements. See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You under the Apache License, Version 2.0
-* (the "License"); you may not use this file except in compliance with
-* the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.apache.poi.hssf.usermodel;
+/* ====================================================================
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+==================================================================== */
-import junit.framework.TestCase;
+package org.apache.poi.hssf.usermodel;
import org.apache.poi.hssf.HSSFTestDataSamples;
import org.apache.poi.hssf.HSSFITestDataProvider;
Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFRow.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFRow.java?rev=805262&r1=805261&r2=805262&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFRow.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFRow.java Tue Aug 18 02:41:45 2009
@@ -18,9 +18,7 @@
package org.apache.poi.hssf.usermodel;
import junit.framework.AssertionFailedError;
-import junit.framework.TestCase;
-import org.apache.poi.hssf.HSSFTestDataSamples;
import org.apache.poi.hssf.HSSFITestDataProvider;
import org.apache.poi.hssf.record.BlankRecord;
import org.apache.poi.hssf.record.RowRecord;
@@ -87,8 +85,8 @@
assertEquals(-1, row.getLastCellNum());
assertEquals(-1, row.getFirstCellNum());
HSSFCell cellB2 = row.createCell(1);
- HSSFCell cellB3 = row.createCell(2);
- HSSFCell cellB4 = row.createCell(3);
+ row.createCell(2); // C2
+ row.createCell(3); // D2
assertEquals(1, row.getFirstCellNum());
assertEquals(4, row.getLastCellNum());
Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFWorkbook.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFWorkbook.java?rev=805262&r1=805261&r2=805262&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFWorkbook.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFWorkbook.java Tue Aug 18 02:41:45 2009
@@ -23,7 +23,6 @@
import java.util.List;
import junit.framework.AssertionFailedError;
-import junit.framework.TestCase;
import org.apache.poi.hssf.HSSFTestDataSamples;
import org.apache.poi.hssf.HSSFITestDataProvider;
@@ -68,7 +67,7 @@
fail("WindowOneRecord in Workbook is probably not initialized");
}
}
-
+
/**
* Tests for {@link HSSFWorkbook#isHidden()} etc
*/
Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestPOIFSProperties.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestPOIFSProperties.java?rev=805262&r1=805261&r2=805262&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestPOIFSProperties.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestPOIFSProperties.java Tue Aug 18 02:41:45 2009
@@ -19,8 +19,6 @@
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
import java.io.InputStream;
import junit.framework.TestCase;
Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestWorkbook.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestWorkbook.java?rev=805262&r1=805261&r2=805262&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestWorkbook.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestWorkbook.java Tue Aug 18 02:41:45 2009
@@ -32,7 +32,6 @@
import org.apache.poi.hssf.record.aggregates.RecordAggregate.RecordVisitor;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
import org.apache.poi.ss.util.CellRangeAddress;
-import org.apache.poi.ss.util.Region;
import org.apache.poi.util.TempFile;
/**
@@ -428,7 +427,7 @@
s.addMergedRegion(new CellRangeAddress(30, 40, 5, 15));
sanityChecker.checkHSSFWorkbook(wb);
wb = HSSFTestDataSamples.writeOutAndReadBack(wb);
-
+
s = wb.getSheetAt(0);
CellRangeAddress r1 = s.getMergedRegion(0);
CellRangeAddress r2 = s.getMergedRegion(1);
@@ -473,7 +472,7 @@
}
}
}
-
+
/**
* This tests is for bug [ #506658 ] Repeating output.
*
Modified: poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestPropertySorter.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestPropertySorter.java?rev=805262&r1=805261&r2=805262&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestPropertySorter.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestPropertySorter.java Tue Aug 18 02:41:45 2009
@@ -1,4 +1,3 @@
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
@@ -20,14 +19,13 @@
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Iterator;
+import java.util.List;
import junit.framework.ComparisonFailure;
import junit.framework.TestCase;
@@ -62,7 +60,7 @@
throw new RuntimeException(e);
}
}
-
+
/**
* Test sorting of properties in <code>DirectoryProperty</code>
*/
@@ -125,22 +123,22 @@
DirectoryNode vba = (DirectoryNode)vba_project.getEntry(VBA);
DirectoryProperty p = (DirectoryProperty)vba.getProperty();
- ArrayList lst = new ArrayList();
- for (Iterator it = p.getChildren(); it.hasNext();){
- Property ch = (Property)it.next();
+ List<Property> lst = new ArrayList<Property>();
+ for (Iterator<Property> it = p.getChildren(); it.hasNext();){
+ Property ch = it.next();
lst.add(ch);
}
- return (Property [])lst.toArray(new Property[ 0 ]);
+ return lst.toArray(new Property[ 0 ]);
}
/**
* Old version of case-sensitive PropertyComparator to demonstrate the problem
*/
- private static final Comparator OldCaseSensitivePropertyComparator = new Comparator() {
+ private static final Comparator<Property> OldCaseSensitivePropertyComparator = new Comparator<Property>() {
- public int compare(Object o1, Object o2) {
- String name1 = (( Property ) o1).getName();
- String name2 = (( Property ) o2).getName();
+ public int compare(Property o1, Property o2) {
+ String name1 = o1.getName();
+ String name2 = o2.getName();
int result = name1.length() - name2.length();
if (result == 0) {
Modified: poi/trunk/src/testcases/org/apache/poi/poifs/storage/LocalRawDataBlockList.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/poifs/storage/LocalRawDataBlockList.java?rev=805262&r1=805261&r2=805262&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/poifs/storage/LocalRawDataBlockList.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/poifs/storage/LocalRawDataBlockList.java Tue Aug 18 02:41:45 2009
@@ -1,4 +1,3 @@
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
@@ -15,42 +14,32 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
package org.apache.poi.poifs.storage;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
import org.apache.poi.poifs.common.POIFSConstants;
-import org.apache.poi.poifs.filesystem.POIFSFileSystem;
import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.LittleEndianConsts;
-import java.io.*;
-
-import java.util.*;
-
/**
* Class LocalRawDataBlockList
*
* @author Marc Johnson(mjohnson at apache dot org)
*/
-
-public class LocalRawDataBlockList
- extends RawDataBlockList
-{
- private List _list;
+public final class LocalRawDataBlockList extends RawDataBlockList {
+ private List<RawDataBlock> _list;
private RawDataBlock[] _array;
- /**
- * Constructor LocalRawDataBlockList
- *
- * @exception IOException
- */
-
public LocalRawDataBlockList()
throws IOException
{
super(new ByteArrayInputStream(new byte[ 0 ]), POIFSConstants.BIG_BLOCK_SIZE);
- _list = new ArrayList();
+ _list = new ArrayList<RawDataBlock>();
_array = null;
}
@@ -60,10 +49,7 @@
* @param start index of first BAT block
* @param end index of last BAT block
* @param chain index of next XBAT block
- *
- * @exception IOException
*/
-
public void createNewXBATBlock(final int start, final int end,
final int chain)
throws IOException
@@ -89,10 +75,7 @@
* create a BAT block and add it to the list
*
* @param start_index initial index for the block list
- *
- * @exception IOException
*/
-
public void createNewBATBlock(final int start_index)
throws IOException
{
@@ -124,10 +107,7 @@
* fill the list with dummy blocks
*
* @param count of blocks
- *
- * @exception IOException
*/
-
public void fill(final int count)
throws IOException
{
@@ -144,7 +124,6 @@
*
* @param block new block to add
*/
-
public void add(RawDataBlock block)
{
_list.add(block);
@@ -156,10 +135,7 @@
* @param index of block to be removed
*
* @return desired block
- *
- * @exception IOException
*/
-
public ListManagedBlock remove(final int index)
throws IOException
{
@@ -189,7 +165,6 @@
* @param index the index of the specified block; if the index is
* out of range, that's ok
*/
-
public void zap(final int index)
{
ensureArrayExists();
@@ -203,7 +178,7 @@
{
if (_array == null)
{
- _array = ( RawDataBlock [] ) _list.toArray(new RawDataBlock[ 0 ]);
+ _array = _list.toArray(new RawDataBlock[ 0 ]);
}
}
}
Modified: poi/trunk/src/testcases/org/apache/poi/poifs/storage/TestBlockListImpl.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/poifs/storage/TestBlockListImpl.java?rev=805262&r1=805261&r2=805262&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/poifs/storage/TestBlockListImpl.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/poifs/storage/TestBlockListImpl.java Tue Aug 18 02:41:45 2009
@@ -34,9 +34,17 @@
* @author Marc Johnson
*/
public final class TestBlockListImpl extends TestCase {
+ private static final class BlockListTestImpl extends BlockListImpl {
+ public BlockListTestImpl() {
+ // no extra initialisation
+ }
+ }
+ private static BlockListImpl create() {
+ return new BlockListTestImpl();
+ }
public void testZap() throws IOException {
- BlockListImpl list = new BlockListImpl();
+ BlockListImpl list = create();
// verify that you can zap anything
for (int j = -2; j < 10; j++)
@@ -70,8 +78,9 @@
}
}
+
public void testRemove() throws IOException {
- BlockListImpl list = new BlockListImpl();
+ BlockListImpl list = create();
RawDataBlock[] blocks = new RawDataBlock[ 5 ];
byte[] data = new byte[ 512 * 5 ];
@@ -130,7 +139,7 @@
}
public void testSetBAT() throws IOException {
- BlockListImpl list = new BlockListImpl();
+ BlockListImpl list = create();
list.setBAT(null);
list.setBAT(new BlockAllocationTableReader());
@@ -158,7 +167,7 @@
// document, one that includes a reserved (BAT) block, one
// that includes a reserved (XBAT) block, and one that
// points off into space somewhere
- BlockListImpl list = new BlockListImpl();
+ BlockListImpl list = create();
List raw_blocks = new ArrayList();
byte[] data = new byte[ 512 ];
int offset = 0;
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org