You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2017/11/07 10:18:09 UTC

[sling-org-apache-sling-testing-jcr-mock] 13/27: SLING-4695 - MockNode.getProperties() does not contain jcr:primaryType

This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.testing.jcr-mock-1.1.10
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-testing-jcr-mock.git

commit d82271f02873073f50c195d651130fb0f51ed840
Author: Julian Sedding <js...@apache.org>
AuthorDate: Wed May 6 12:36:25 2015 +0000

    SLING-4695 - MockNode.getProperties() does not contain jcr:primaryType
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/testing/mocks/jcr-mock@1677969 13f79535-47bb-0310-9956-ffa450edef68
---
 .../java/org/apache/sling/testing/mock/jcr/MockNode.java |  1 +
 .../org/apache/sling/testing/mock/jcr/MockNodeTest.java  | 16 ++++++++++++++++
 2 files changed, 17 insertions(+)

diff --git a/src/main/java/org/apache/sling/testing/mock/jcr/MockNode.java b/src/main/java/org/apache/sling/testing/mock/jcr/MockNode.java
index f06c3a9..9e49ced 100644
--- a/src/main/java/org/apache/sling/testing/mock/jcr/MockNode.java
+++ b/src/main/java/org/apache/sling/testing/mock/jcr/MockNode.java
@@ -65,6 +65,7 @@ class MockNode extends AbstractItem implements Node {
         ItemData itemData = ItemData.newNode(path, new MockNodeType(primaryNodeTypeName));
         Node node = new MockNode(itemData, getSession());
         getMockedSession().addItem(itemData);
+        node.setProperty(JcrConstants.JCR_PRIMARYTYPE, primaryNodeTypeName);
         
         // special handling for some node types
         if (StringUtils.equals(primaryNodeTypeName, JcrConstants.NT_FILE)) {
diff --git a/src/test/java/org/apache/sling/testing/mock/jcr/MockNodeTest.java b/src/test/java/org/apache/sling/testing/mock/jcr/MockNodeTest.java
index fc8ad9a..bf5f0d3 100644
--- a/src/test/java/org/apache/sling/testing/mock/jcr/MockNodeTest.java
+++ b/src/test/java/org/apache/sling/testing/mock/jcr/MockNodeTest.java
@@ -22,6 +22,7 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 
 import javax.jcr.ItemNotFoundException;
 import javax.jcr.Node;
@@ -31,6 +32,7 @@ import javax.jcr.PropertyIterator;
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
 
+import com.google.common.collect.Iterables;
 import org.apache.jackrabbit.JcrConstants;
 import org.junit.Before;
 import org.junit.Test;
@@ -90,6 +92,20 @@ public class MockNodeTest {
     }
 
     @Test
+    public void testPrimaryType() throws RepositoryException {
+        assertEquals("nt:unstructured", this.node1.getPrimaryNodeType().getName());
+        assertEquals("nt:unstructured", this.node1.getProperty("jcr:primaryType").getString());
+        final PropertyIterator properties = this.node1.getProperties();
+        while (properties.hasNext()) {
+            final Property property = properties.nextProperty();
+            if (JcrConstants.JCR_PRIMARYTYPE.equals(property.getName())) {
+                return;
+            }
+        }
+        fail("Properties did not include jcr:primaryType");
+    }
+
+    @Test
     public void testIsNode() {
         assertTrue(this.node1.isNode());
         assertFalse(this.prop1.isNode());

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.