aboutsummaryrefslogtreecommitdiffstats
path: root/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFCell.java
diff options
context:
space:
mode:
authorNick Burch <nick@apache.org>2008-02-01 16:52:58 +0000
committerNick Burch <nick@apache.org>2008-02-01 16:52:58 +0000
commita755da02a84436d3ab38048e52e4e35806fc9e91 (patch)
tree051925c55601f167450ef0b98900c127a419b621 /src/testcases/org/apache/poi/hssf/usermodel/TestHSSFCell.java
parentfeeb8cca63644fa9da275979943748875c6dfb94 (diff)
downloadpoi-a755da02a84436d3ab38048e52e4e35806fc9e91.tar.gz
poi-a755da02a84436d3ab38048e52e4e35806fc9e91.zip
More Hyperlink support. Doesn't end up in HSSFCell just yet, as the records are in the wrong bit of the file, so don't get associated with the sheet. All tests still passing though
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@617555 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/testcases/org/apache/poi/hssf/usermodel/TestHSSFCell.java')
-rw-r--r--src/testcases/org/apache/poi/hssf/usermodel/TestHSSFCell.java90
1 files changed, 75 insertions, 15 deletions
diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFCell.java b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFCell.java
index 482ae7c6cd..76f1b9fba2 100644
--- a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFCell.java
+++ b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFCell.java
@@ -19,25 +19,20 @@
package org.apache.poi.hssf.usermodel;
-import junit.framework.TestCase;
-
-import org.apache.poi.poifs.filesystem.POIFSFileSystem;
-import org.apache.poi.hssf.model.Sheet;
-import org.apache.poi.hssf.record.Record;
-import org.apache.poi.hssf.record.BOFRecord;
-import org.apache.poi.hssf.record.EOFRecord;
-import org.apache.poi.hssf.util.CellReference;
-import org.apache.poi.hssf.util.HSSFColor;
-import org.apache.poi.util.TempFile;
-
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
-
-import java.util.List;
-import java.util.Iterator;
import java.util.Date;
import java.util.GregorianCalendar;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.apache.poi.hssf.model.Sheet;
+import org.apache.poi.hssf.record.HyperlinkRecord;
+import org.apache.poi.hssf.util.HSSFColor;
+import org.apache.poi.poifs.filesystem.POIFSFileSystem;
+import org.apache.poi.util.TempFile;
/**
* Tests various functionity having to do with HSSFCell. For instance support for
@@ -310,10 +305,75 @@ extends TestCase {
in.close();
}
- public void testWithHyperlinks() throws Exception {
+ public void BROKENtestWithHyperlink() throws Exception {
String dir = System.getProperty("HSSF.testdata.path");
File f = new File(dir, "WithHyperlink.xls");
HSSFWorkbook wb = new HSSFWorkbook(new FileInputStream(f));
+
+ assertEquals(3, wb.getNumberOfSheets());
+
+ // Find our hyperlink record, and check they're
+ // as we'd expect
+ List records = wb.getWorkbook().getHyperlinks();
+ assertEquals(1, records.size());
+
+ HyperlinkRecord link = (HyperlinkRecord)
+ records.get(0);
+ assertNotNull(link);
+
+ // Is in A5
+ assertEquals("Foo", link.getLabel());
+ assertEquals("http://poi.apache.org/", link.getUrlString());
+ assertEquals(4, link.getRow());
+ assertEquals(0, link.getColumn());
+
+ // Now check at the HSSFCell level
+ assertEquals(3, wb.getNumberOfSheets());
+
+ HSSFSheet s = wb.getSheetAt(1);
+ HSSFRow r = s.getRow(4);
+ assertNotNull(r);
+ HSSFCell c = r.getCell((short)0);
+ }
+
+ public void BROKENtestWithTwoHyperlinks() throws Exception {
+ String dir = System.getProperty("HSSF.testdata.path");
+ File f = new File(dir, "WithTwoHyperLinks.xls");
+ HSSFWorkbook wb = new HSSFWorkbook(new FileInputStream(f));
+
+ assertEquals(3, wb.getNumberOfSheets());
+
+ // Find our hyperlink record, and check they're
+ // as we'd expect
+ List records = wb.getWorkbook().getHyperlinks();
+ assertEquals(2, records.size());
+
+ HyperlinkRecord linkA = (HyperlinkRecord)
+ records.get(0);
+ HyperlinkRecord linkB = (HyperlinkRecord)
+ records.get(1);
+ assertNotNull(linkA);
+ assertNotNull(linkB);
+
+ // Is in A5
+ assertEquals("Foo", linkA.getLabel());
+ assertEquals("http://poi.apache.org/", linkA.getUrlString());
+ assertEquals(4, linkA.getRow());
+ assertEquals(0, linkA.getColumn());
+
+ // Is in B9
+ assertEquals("Bar", linkB.getLabel());
+ assertEquals("http://poi.apache.org/", linkB.getUrlString());
+ assertEquals(8, linkB.getRow());
+ assertEquals(1, linkB.getColumn());
+
+ // Now check at the HSSFCell level
+ assertEquals(3, wb.getNumberOfSheets());
+
+ HSSFSheet s = wb.getSheetAt(1);
+ HSSFRow r = s.getRow(4);
+ assertNotNull(r);
+ HSSFCell c = r.getCell((short)0);
}
/*tests the toString() method of HSSFCell*/