mirror of https://github.com/apache/poi.git
update tests
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1917164 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
ee525b6477
commit
d87ffbc1b0
|
@ -232,9 +232,14 @@ public class POIXMLDocumentPart {
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns the list of child relations for this POIXMLDocumentPart
|
||||
* Returns the list of child relations for this POIXMLDocumentPart.
|
||||
*
|
||||
* <p>
|
||||
* Since POI 5.2.6, Reference Relationships are stored separately from other child relations.
|
||||
* </p>
|
||||
*
|
||||
* @return child relations
|
||||
* @see #getReferenceRelationships() for reference relationships (e.g. hyperlinks)
|
||||
*/
|
||||
public final List<RelationPart> getRelationParts() {
|
||||
List<RelationPart> l = new ArrayList<>(relations.values());
|
||||
|
@ -746,7 +751,7 @@ public class POIXMLDocumentPart {
|
|||
* @return true, if the relation was removed
|
||||
* @since POI 5.2.6
|
||||
*/
|
||||
public boolean removeReferenceRelationship(String relId) {
|
||||
public final boolean removeReferenceRelationship(String relId) {
|
||||
ReferenceRelationship existing = referenceRelationships.remove(relId);
|
||||
if (existing != null) {
|
||||
packagePart.removeRelationship(relId);
|
||||
|
@ -763,7 +768,7 @@ public class POIXMLDocumentPart {
|
|||
* @return the reference relationship or {@code null} if not found
|
||||
* @since POI 5.2.6
|
||||
*/
|
||||
public ReferenceRelationship getReferenceRelationship(String relId) {
|
||||
public final ReferenceRelationship getReferenceRelationship(String relId) {
|
||||
return referenceRelationships.get(relId);
|
||||
}
|
||||
|
||||
|
@ -776,7 +781,7 @@ public class POIXMLDocumentPart {
|
|||
* @return the created reference relationship
|
||||
* @since POI 5.2.6
|
||||
*/
|
||||
public HyperlinkRelationship createHyperlink(URI uri, boolean isExternal, String relId) {
|
||||
public final HyperlinkRelationship createHyperlink(URI uri, boolean isExternal, String relId) {
|
||||
PackageRelationship pr = packagePart.addRelationship(uri, isExternal ? TargetMode.EXTERNAL : TargetMode.INTERNAL,
|
||||
PackageRelationshipTypes.HYPERLINK_PART, relId);
|
||||
HyperlinkRelationship hyperlink = new HyperlinkRelationship(this, uri, isExternal, relId);
|
||||
|
@ -789,8 +794,9 @@ public class POIXMLDocumentPart {
|
|||
*
|
||||
* @return reference relationships
|
||||
* @since POI 5.2.6
|
||||
* @see #getRelationParts() for child relations
|
||||
*/
|
||||
public List<ReferenceRelationship> getReferenceRelationships() {
|
||||
public final List<ReferenceRelationship> getReferenceRelationships() {
|
||||
List<ReferenceRelationship> list = new ArrayList<>(referenceRelationships.values());
|
||||
return Collections.unmodifiableList(list);
|
||||
}
|
||||
|
|
|
@ -326,10 +326,12 @@ class TestRelationships {
|
|||
assertNotNull(rId1);
|
||||
URI parent = drawingPart.getPartName().getURI();
|
||||
// Hyperlink is not a target of relativize() because it is not resolved based on sourceURI in getTargetURI()
|
||||
// URI rel1 = parent.relativize(rId1.getTargetURI());
|
||||
// URI rel11 = PackagingURIHelper.relativizeURI(drawingPart.getPartName().getURI(), rId1.getTargetURI());
|
||||
// assertEquals("'Another Sheet'!A1", rel1.getFragment());
|
||||
// assertEquals("'Another Sheet'!A1", rel11.getFragment());
|
||||
URI rel1 = parent.relativize(rId1.getTargetURI());
|
||||
assertEquals("'Another Sheet'!A1", rel1.getFragment());
|
||||
URI rel11 = PackagingURIHelper.relativizeURI(drawingPart.getPartName().getURI(), rId1.getTargetURI());
|
||||
// the following changed with https://github.com/apache/poi/pull/617
|
||||
//assertEquals("'Another Sheet'!A1", rel11.getFragment());
|
||||
assertNull(rel11.getFragment());
|
||||
|
||||
PackageRelationship rId2 = drawingPart.getRelationship("rId2");
|
||||
URI rel2 = PackagingURIHelper.relativizeURI(drawingPart.getPartName().getURI(), rId2.getTargetURI());
|
||||
|
|
|
@ -17,13 +17,6 @@
|
|||
|
||||
package org.apache.poi.xssf;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertInstanceOf;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import org.apache.poi.ooxml.ReferenceRelationship;
|
||||
import org.apache.poi.openxml4j.opc.PackageRelationship;
|
||||
import org.apache.poi.openxml4j.opc.PackageRelationshipTypes;
|
||||
|
@ -47,6 +40,8 @@ import org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTPictureNo
|
|||
|
||||
import java.io.IOException;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
class TestXSSFCloneSheet extends BaseTestCloneSheet {
|
||||
public TestXSSFCloneSheet() {
|
||||
super(XSSFITestDataProvider.instance);
|
||||
|
@ -208,6 +203,10 @@ class TestXSSFCloneSheet extends BaseTestCloneSheet {
|
|||
PackageRelationship imageRel2 = drawing2.getRelationPartById(imageRelId2).getRelationship();
|
||||
assertEquals(imageRelationType, imageRel2.getRelationshipType());
|
||||
assertEquals(imageTargetUrl, imageRel2.getTargetURI().toString());
|
||||
|
||||
assertTrue(drawing2.removeReferenceRelationship(linkRelId2));
|
||||
assertFalse(drawing2.removeReferenceRelationship(linkRelId2));
|
||||
assertNull(drawing2.getReferenceRelationship(linkRelId2));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue