add linkedfile and mixin support
diff --git a/pom.xml b/pom.xml
index 1126712..6f98cd6 100644
--- a/pom.xml
+++ b/pom.xml
@@ -37,7 +37,7 @@
<properties>
<oak.version>1.8.9</oak.version>
<jackrabbit.version>2.16.3</jackrabbit.version>
- <sling-mock.version>2.3.2</sling-mock.version>
+ <sling-mock.version>2.3.11-SNAPSHOT</sling-mock.version>
</properties>
<scm>
diff --git a/src/test/java/org/apache/sling/testing/mock/sling/oak/contentimport/ContentLoaderJsonTest.java b/src/test/java/org/apache/sling/testing/mock/sling/oak/contentimport/ContentLoaderJsonTest.java
index fdacb1a..3a00285 100644
--- a/src/test/java/org/apache/sling/testing/mock/sling/oak/contentimport/ContentLoaderJsonTest.java
+++ b/src/test/java/org/apache/sling/testing/mock/sling/oak/contentimport/ContentLoaderJsonTest.java
@@ -18,8 +18,17 @@
*/
package org.apache.sling.testing.mock.sling.oak.contentimport;
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+import javax.jcr.nodetype.NodeType;
+import java.util.ArrayList;
+import java.util.Arrays;
+
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.collections.Predicate;
import org.apache.jackrabbit.JcrConstants;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceUtil;
@@ -28,6 +37,8 @@
import org.apache.sling.testing.mock.sling.loader.AbstractContentLoaderJsonTest;
import org.junit.Test;
+import com.google.common.collect.Lists;
+
@SuppressWarnings("null")
public class ContentLoaderJsonTest extends AbstractContentLoaderJsonTest {
@@ -45,4 +56,51 @@
assertNotNull(props.get(JcrConstants.JCR_UUID));
}
+ @Test
+ public void testMixinNodeType() throws Exception {
+ Resource resource = context.resourceResolver().getResource(path + "/sample/en/jcr:content/par/image/ntLinkedFileTargetWithMixin/" + JcrConstants.JCR_CONTENT);
+
+ assertMixinNodeType(resource, "app:TestMixin");
+ }
+
+ @Test
+ public void testReferenceable() throws Exception {
+ Resource resource = context.resourceResolver().getResource(path + "/sample/en/jcr:content/par/image/ntLinkedFileTargetWithMixin/" + JcrConstants.JCR_CONTENT);
+ ValueMap props = ResourceUtil.getValueMap(resource);
+
+ assertMixinNodeType(resource, "mix:referenceable");
+ assertNotNull(props.get(JcrConstants.JCR_UUID));
+ }
+
+ @Test
+ public void testLinkedFile() throws Exception {
+ Resource resource = context.resourceResolver().getResource(path + "/sample/en/jcr:content/par/image/ntLinkedFile");
+ Resource targetResource = context.resourceResolver().getResource(path + "/sample/en/jcr:content/par/image/ntLinkedFileTargetWithMixin/" + JcrConstants.JCR_CONTENT);
+ Node node = resource.adaptTo(Node.class);
+ Node target = node.getProperty(JcrConstants.JCR_CONTENT).getNode();
+
+ assertEquals(targetResource.getPath(), target.getPath());
+ assertEquals(targetResource.getValueMap().get(JcrConstants.JCR_UUID), target.getProperty(JcrConstants.JCR_UUID).getString());
+ }
+
+ private void assertMixinNodeType(final Resource resource, final String mixinNodeType) throws RepositoryException {
+ ArrayList<NodeType> mixinNodeTypes = Lists.newArrayList();
+ Node node = resource.adaptTo(Node.class);
+ if (node != null) {
+ mixinNodeTypes.addAll(Arrays.asList(node.getMixinNodeTypes()));
+ } else {
+ ValueMap props = ResourceUtil.getValueMap(resource);
+ mixinNodeTypes.addAll(Arrays.asList((NodeType[]) props.get(JcrConstants.JCR_MIXINTYPES)));
+ }
+
+ Object hit = CollectionUtils.find(mixinNodeTypes, new Predicate() {
+ @Override
+ public boolean evaluate(Object o) {
+ NodeType nodeType = (NodeType) o;
+ return nodeType.getName().equals(mixinNodeType);
+ }
+ });
+ assertNotNull(hit);
+ }
+
}