==================================================================== */
package org.apache.poi.xssf.eventusermodel;
-import java.util.Comparator;
import java.util.LinkedList;
import java.util.Queue;
import org.apache.poi.ss.usermodel.BuiltinFormats;
import org.apache.poi.ss.usermodel.DataFormatter;
import org.apache.poi.ss.util.CellAddress;
-import org.apache.poi.ss.util.CellReference;
import org.apache.poi.util.POILogFactory;
import org.apache.poi.util.POILogger;
import org.apache.poi.xssf.model.CommentsTable;
/**
* Tests for XWPF Run
*/
+@SuppressWarnings("deprecation")
public class TestXWPFRun extends TestCase {
- public CTR ctRun;
- public XWPFParagraph p;
+ private CTR ctRun;
+ private XWPFParagraph p;
+ private XWPFDocument doc;
protected void setUp() {
- XWPFDocument doc = new XWPFDocument();
+ doc = new XWPFDocument();
p = doc.createParagraph();
this.ctRun = CTR.Factory.newInstance();
}
+
+ protected void tearDown() throws Exception {
+ doc.close();
+ }
public void testSetGetText() {
ctRun.addNewT().setStringValue("TEST STRING");
assertEquals(1, doc.getAllPictures().size());
assertEquals(1, r.getEmbeddedPictures().size());
+
+ XWPFDocument docBack = XWPFTestDataSamples.writeOutAndReadBack(doc);
+ XWPFParagraph pBack = docBack.getParagraphArray(2);
+ XWPFRun rBack = pBack.getRuns().get(0);
+
+ assertEquals(1, docBack.getAllPictures().size());
+ assertEquals(1, rBack.getEmbeddedPictures().size());
}
/**
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
import org.apache.poi.POIDataSamples;
+import java.io.IOException;
+
public final class HWPFDocFixture
{
_testFile = testFile;
}
- public void setUp()
- {
- try
- {
+ public void setUp() throws IOException {
POIFSFileSystem filesystem = new POIFSFileSystem(
POIDataSamples.getDocumentInstance().openResourceAsStream(_testFile));
filesystem.createDocumentInputStream(name).read(_tableStream);
_fib.fillVariableFields(_mainStream, _tableStream);
- }
- catch (Throwable t)
- {
- t.printStackTrace();
- }
}
public void tearDown()
* Setup is used to get the document ready. Gets the DocumentSummaryInformation and the
* SummaryInformation to reasonable values
*/
- public void setUp() {
+ public void setUp() throws Exception {
bout = new ByteArrayOutputStream();
poifs = new POIFSFileSystem();
dir = poifs.getRoot();
*/
dsi = PropertySetFactory.newDocumentSummaryInformation();
assertNotNull(dsi);
- } catch (Exception e) {
- e.printStackTrace();
- fail();
}
assertNotNull(dsi);
try {
*/
si = PropertySetFactory.newSummaryInformation();
assertNotNull(si);
- } catch (Exception e) {
- e.printStackTrace();
- fail();
}
assertNotNull(dsi);
}
si = null;
dsi = null;
- try {
- poifs.writeFilesystem(bout);
- bout.flush();
- } catch (IOException e) {
- e.printStackTrace();
- fail();
- }
+ poifs.writeFilesystem(bout);
+ bout.flush();
InputStream is = new ByteArrayInputStream(bout.toByteArray());
assertNotNull(is);
}
catch (Exception ex)
{
- ex.printStackTrace();
- throw new RuntimeException(ex.toString());
- /* FIXME (2): Replace the previous line by the following
- * one once we no longer need JDK 1.3 compatibility. */
- // throw new RuntimeException(ex);
+ throw new RuntimeException(ex);
}
}
},
/**
- * <p>Performs the check described in {@link #testRecreate()} for a single
+ * <p>Performs the check described in {@link #recreate()} for a single
* POI filesystem.</p>
*
* @param f the POI filesystem to check
}
catch (IOException ex)
{
- ex.printStackTrace();
- throw new RuntimeException(ex.getMessage());
+ throw new RuntimeException(ex);
}
}
};
}
catch (Exception ex)
{
- ex.printStackTrace();
- throw new RuntimeException(ex.getMessage());
+ throw new RuntimeException(ex);
}
}
};
import org.apache.poi.hssf.usermodel.HSSFFormulaEvaluator;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
-import org.apache.poi.hssf.util.AreaReference;
-import org.apache.poi.hssf.util.CellReference;
import org.apache.poi.ss.formula.TwoDEval;
import org.apache.poi.ss.formula.ptg.AreaI;
import org.apache.poi.ss.formula.ptg.AreaI.OffsetArea;
import org.apache.poi.ss.usermodel.CellValue;
+import org.apache.poi.ss.util.AreaReference;
+import org.apache.poi.ss.util.CellReference;
/**
* Test for unary plus operator evaluator.
createRefEval(refA),
createRefEval(refB),
};
- AreaReference ar = new AreaReference(expectedAreaRef);
+ @SuppressWarnings("deprecation")
+ AreaReference ar = new AreaReference(expectedAreaRef);
ValueEval result = EvalInstances.Range.evaluate(args, 0, (short)0);
assertTrue(result instanceof AreaEval);
AreaEval ae = (AreaEval) result;