TestExHyperlinkpublic class TestExHyperlink extends TestCase Tests that ExHyperlink works properly. |
Fields Summary |
---|
private byte[] | data_a |
Methods Summary |
---|
public void | testDetails()
ExHyperlink eh = new ExHyperlink(data_a, 0, data_a.length);
assertEquals("http://jakarta.apache.org/poi/hssf/", eh._getDetailsA());
assertEquals("http://jakarta.apache.org/poi/hssf/", eh._getDetailsB());
| public void | testLinkURL()
ExHyperlink eh = new ExHyperlink(data_a, 0, data_a.length);
assertEquals("http://jakarta.apache.org/poi/hssf/", eh.getLinkURL());
| public void | testNumber()
ExHyperlink eh = new ExHyperlink(data_a, 0, data_a.length);
assertEquals(3, eh.getExHyperlinkAtom().getNumber());
| public void | testRealFile()
String dirname = System.getProperty("HSLF.testdata.path");
HSLFSlideShow hss = new HSLFSlideShow(dirname + File.separator + "WithLinks.ppt");
SlideShow ss = new SlideShow(hss);
// Get the document
Document doc = ss.getDocumentRecord();
// Get the ExObjList
ExObjList exObjList = null;
for(int i=0; i<doc._children.length; i++) {
if(doc._children[i] instanceof ExObjList) {
exObjList = (ExObjList)doc._children[i];
}
}
assertNotNull(exObjList);
// Within that, grab out the Hyperlink atoms
ArrayList linksA = new ArrayList();
for(int i=0; i<exObjList._children.length; i++) {
if(exObjList._children[i] instanceof ExHyperlink) {
linksA.add(exObjList._children[i]);
}
}
// Should be 4 of them
assertEquals(4, linksA.size());
ExHyperlink[] links = new ExHyperlink[linksA.size()];
linksA.toArray(links);
assertEquals(4, exObjList.getExHyperlinks().length);
// Check the other way
// Check they have what we expect in them
assertEquals(1, links[0].getExHyperlinkAtom().getNumber());
assertEquals("http://jakarta.apache.org/poi/", links[0].getLinkURL());
assertEquals(2, links[1].getExHyperlinkAtom().getNumber());
assertEquals("http://slashdot.org/", links[1].getLinkURL());
assertEquals(3, links[2].getExHyperlinkAtom().getNumber());
assertEquals("http://jakarta.apache.org/poi/hssf/", links[2].getLinkURL());
assertEquals(4, links[3].getExHyperlinkAtom().getNumber());
assertEquals("http://jakarta.apache.org/hslf/", links[3].getLinkURL());
| public void | testRecordType()
ExHyperlink eh = new ExHyperlink(data_a, 0, data_a.length);
assertEquals(4055l, eh.getRecordType());
| public void | testWrite()
ExHyperlink eh = new ExHyperlink(data_a, 0, data_a.length);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
eh.writeOut(baos);
byte[] b = baos.toByteArray();
assertEquals(data_a.length, b.length);
for(int i=0; i<data_a.length; i++) {
assertEquals(data_a[i],b[i]);
}
|
|