[java-metadata-aggregator] branch main updated: MDA-65 - Catch up on unit tests

Ian Young ian at iay.org.uk
Thu Nov 5 18:00:03 UTC 2020


This is an automated email from the git hooks/post-receive script.

iay pushed a commit to branch main
in repository java-metadata-aggregator.

View the commit online:
http://git.shibboleth.net/view/?p=java-metadata-aggregator.git;a=commit;h=3c4c6f554d0f643a4500c5edd99f2108aa871b13

The following commit(s) were added to refs/heads/main by this push:
       new  3c4c6f5   MDA-65 - Catch up on unit tests
3c4c6f5 is described below

commit 3c4c6f554d0f643a4500c5edd99f2108aa871b13
Author: Ian Young <ian at iay.org.uk>
AuthorDate: Thu Nov 5 18:00:00 2020 +0000

    MDA-65 - Catch up on unit tests
    
    https://issues.shibboleth.net/jira/browse/MDA-65
---
 .../metadata/dom/DOMElementItemTest.java           | 35 +++++++++++++++++++++-
 .../shibboleth/metadata/dom/DOMElementItem-in.xml  |  3 ++
 2 files changed, 37 insertions(+), 1 deletion(-)

diff --git a/aggregator-pipeline/src/test/java/net/shibboleth/metadata/dom/DOMElementItemTest.java b/aggregator-pipeline/src/test/java/net/shibboleth/metadata/dom/DOMElementItemTest.java
index 6af56bb..899ad8e 100644
--- a/aggregator-pipeline/src/test/java/net/shibboleth/metadata/dom/DOMElementItemTest.java
+++ b/aggregator-pipeline/src/test/java/net/shibboleth/metadata/dom/DOMElementItemTest.java
@@ -1,13 +1,20 @@
 
 package net.shibboleth.metadata.dom;
 
+import org.testng.Assert;
 import org.testng.annotations.Test;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 
+import net.shibboleth.metadata.Item;
+import net.shibboleth.metadata.ItemId;
 import net.shibboleth.utilities.java.support.logic.ConstraintViolationException;
 
-public class DOMElementItemTest {
+public class DOMElementItemTest extends BaseDOMTest {
+
+    protected DOMElementItemTest() {
+        super(DOMElementItem.class);
+    }
 
     @Test(expectedExceptions=ConstraintViolationException.class)
     public void testNullDocument() {
@@ -18,4 +25,30 @@ public class DOMElementItemTest {
     public void testNullElement() {
         new DOMElementItem((Element)null);
     }
+    
+    @Test
+    public void testCopy() throws Exception {
+        // Build an item with some metadata
+        final var e = readXMLData("in.xml");
+        final Item<Element> orig = new DOMElementItem(e);
+        final var origId = new ItemId("item");
+        orig.getItemMetadata().put(origId);
+
+        // Make a copy
+        final Item<Element> copy = orig.copy();
+
+        // The original and copy should be different, their metadata collections
+        // different, the actual metadata the same.
+        final var copyId = copy.getItemMetadata().get(ItemId.class).get(0);
+        Assert.assertNotNull(copyId);
+        Assert.assertSame(copyId, origId);
+        Assert.assertNotSame(copy, orig);
+        Assert.assertNotSame(copy.getItemMetadata(), orig.getItemMetadata());
+        
+        // Values should be identical
+        assertXMLIdentical(copy.unwrap(), orig.unwrap());
+        
+        // Values should be in different documents.
+        Assert.assertNotSame(copy.unwrap().getOwnerDocument(), orig.unwrap().getOwnerDocument());
+    }
 }
diff --git a/aggregator-pipeline/src/test/resources/net/shibboleth/metadata/dom/DOMElementItem-in.xml b/aggregator-pipeline/src/test/resources/net/shibboleth/metadata/dom/DOMElementItem-in.xml
new file mode 100644
index 0000000..56948c4
--- /dev/null
+++ b/aggregator-pipeline/src/test/resources/net/shibboleth/metadata/dom/DOMElementItem-in.xml
@@ -0,0 +1,3 @@
+<x>
+    <y>z</y>
+</x>

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list