poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n...@apache.org
Subject svn commit: r1172670 - /poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/TestXSLFBugs.java
Date Mon, 19 Sep 2011 15:38:59 GMT
Author: nick
Date: Mon Sep 19 15:38:59 2011
New Revision: 1172670

URL: http://svn.apache.org/viewvc?rev=1172670&view=rev
Log:
Test relating to TIKA-705 - XSLF internal hyperlinks

Modified:
    poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/TestXSLFBugs.java

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/TestXSLFBugs.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/TestXSLFBugs.java?rev=1172670&r1=1172669&r2=1172670&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/TestXSLFBugs.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/TestXSLFBugs.java Mon Sep 19 15:38:59
2011
@@ -16,11 +16,17 @@
 ==================================================================== */
 package org.apache.poi.xslf;
 
+import java.net.URI;
+import java.util.List;
+
 import junit.framework.TestCase;
 
+import org.apache.poi.POIXMLDocumentPart;
 import org.apache.poi.openxml4j.opc.PackagePart;
 import org.apache.poi.xslf.usermodel.XMLSlideShow;
+import org.apache.poi.xslf.usermodel.XSLFRelation;
 import org.apache.poi.xslf.usermodel.XSLFSlide;
+import org.apache.poi.xslf.usermodel.XSLFSlideLayout;
 
 public class TestXSLFBugs extends TestCase {
 
@@ -61,6 +67,43 @@ public class TestXSLFBugs extends TestCa
      */
     public void testTIKA705() {
        XMLSlideShow ss = XSLFTestDataSamples.openSampleDocument("with_japanese.pptx");
-       // TODO Check the details including the links
+       
+       // Should have one slide
+       assertEquals(1, ss.getSlides().length);
+       XSLFSlide slide = ss.getSlides()[0];
+       
+       // Check the relations from this
+       List<POIXMLDocumentPart> rels = slide.getRelations();
+       
+       // Should have 6 relations:
+       //   1 external hyperlink (skipped from list)
+       //   4 internal hyperlinks
+       //   1 slide layout
+       assertEquals(5, rels.size());
+       int layouts = 0;
+       int hyperlinks = 0;
+       for(POIXMLDocumentPart p : rels) {
+          if(p.getPackageRelationship().getRelationshipType().equals(XSLFRelation.HYPERLINK.getRelation()))
{
+             hyperlinks++;
+          } else if(p instanceof XSLFSlideLayout) {
+             layouts++;
+          }
+       }
+       assertEquals(1, layouts);
+       assertEquals(4, hyperlinks);
+       
+       // Hyperlinks should all be to #_ftn1 or #ftnref1
+       for(POIXMLDocumentPart p : rels) {
+          if(p.getPackageRelationship().getRelationshipType().equals(XSLFRelation.HYPERLINK.getRelation()))
{
+             URI target = p.getPackageRelationship().getTargetURI();
+             
+             if(target.getFragment().equals("_ftn1") ||
+                target.getFragment().equals("_ftnref1")) {
+                // Good
+             } else {
+                fail("Invalid target " + target.getFragment() + " on " + target);
+             }
+          }
+       }
     }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org


Mime
View raw message