Propchange: 
sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/context/SlingContextImplTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/context/SlingContextImplTest.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Mon Oct 13 11:54:39 2014
@@ -0,0 +1 @@
+LastChangedDate LastChangedRevision LastChangedBy HeadURL Id Author

Propchange: 
sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/context/SlingContextImplTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 
sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/jcrmock/loader/ContentLoaderBinaryTest.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/jcrmock/loader/ContentLoaderBinaryTest.java?rev=1631356&view=auto
==============================================================================
--- 
sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/jcrmock/loader/ContentLoaderBinaryTest.java
 (added)
+++ 
sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/jcrmock/loader/ContentLoaderBinaryTest.java
 Mon Oct 13 11:54:39 2014
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.testing.mock.sling.jcrmock.loader;
+
+import org.apache.sling.testing.mock.sling.ResourceResolverType;
+import 
org.apache.sling.testing.mock.sling.loader.AbstractContentLoaderBinaryTest;
+import org.junit.runner.RunWith;
+import org.mockito.runners.MockitoJUnitRunner;
+
+@RunWith(MockitoJUnitRunner.class)
+public class ContentLoaderBinaryTest extends AbstractContentLoaderBinaryTest {
+
+    protected ResourceResolverType getResourceResolverType() {
+        return ResourceResolverType.JCR_MOCK;
+    }
+
+}

Propchange: 
sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/jcrmock/loader/ContentLoaderBinaryTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/jcrmock/loader/ContentLoaderBinaryTest.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Mon Oct 13 11:54:39 2014
@@ -0,0 +1 @@
+LastChangedDate LastChangedRevision LastChangedBy HeadURL Id Author

Propchange: 
sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/jcrmock/loader/ContentLoaderBinaryTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 
sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/jcrmock/loader/ContentLoaderJsonDamTest.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/jcrmock/loader/ContentLoaderJsonDamTest.java?rev=1631356&view=auto
==============================================================================
--- 
sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/jcrmock/loader/ContentLoaderJsonDamTest.java
 (added)
+++ 
sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/jcrmock/loader/ContentLoaderJsonDamTest.java
 Mon Oct 13 11:54:39 2014
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.testing.mock.sling.jcrmock.loader;
+
+import org.apache.sling.testing.mock.sling.ResourceResolverType;
+import 
org.apache.sling.testing.mock.sling.loader.AbstractContentLoaderJsonDamTest;
+
+public class ContentLoaderJsonDamTest extends AbstractContentLoaderJsonDamTest 
{
+
+    protected ResourceResolverType getResourceResolverType() {
+        return ResourceResolverType.JCR_MOCK;
+    }
+
+}

Propchange: 
sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/jcrmock/loader/ContentLoaderJsonDamTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/jcrmock/loader/ContentLoaderJsonDamTest.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Mon Oct 13 11:54:39 2014
@@ -0,0 +1 @@
+LastChangedDate LastChangedRevision LastChangedBy HeadURL Id Author

Propchange: 
sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/jcrmock/loader/ContentLoaderJsonDamTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 
sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/jcrmock/loader/ContentLoaderJsonTest.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/jcrmock/loader/ContentLoaderJsonTest.java?rev=1631356&view=auto
==============================================================================
--- 
sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/jcrmock/loader/ContentLoaderJsonTest.java
 (added)
+++ 
sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/jcrmock/loader/ContentLoaderJsonTest.java
 Mon Oct 13 11:54:39 2014
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.testing.mock.sling.jcrmock.loader;
+
+import org.apache.sling.testing.mock.sling.ResourceResolverType;
+import 
org.apache.sling.testing.mock.sling.loader.AbstractContentLoaderJsonTest;
+
+public class ContentLoaderJsonTest extends AbstractContentLoaderJsonTest {
+
+    protected ResourceResolverType getResourceResolverType() {
+        return ResourceResolverType.JCR_MOCK;
+    }
+
+}

Propchange: 
sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/jcrmock/loader/ContentLoaderJsonTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/jcrmock/loader/ContentLoaderJsonTest.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Mon Oct 13 11:54:39 2014
@@ -0,0 +1 @@
+LastChangedDate LastChangedRevision LastChangedBy HeadURL Id Author

Propchange: 
sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/jcrmock/loader/ContentLoaderJsonTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 
sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/jcrmock/resource/JcrResourceResolverTest.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/jcrmock/resource/JcrResourceResolverTest.java?rev=1631356&view=auto
==============================================================================
--- 
sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/jcrmock/resource/JcrResourceResolverTest.java
 (added)
+++ 
sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/jcrmock/resource/JcrResourceResolverTest.java
 Mon Oct 13 11:54:39 2014
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.testing.mock.sling.jcrmock.resource;
+
+import org.apache.sling.testing.mock.sling.ResourceResolverType;
+import 
org.apache.sling.testing.mock.sling.resource.AbstractJcrResourceResolverTest;
+
+/**
+ * Implements simple write and read resource and values test. JCR API is used 
to
+ * create the test data.
+ */
+public class JcrResourceResolverTest extends AbstractJcrResourceResolverTest {
+
+    protected ResourceResolverType getResourceResolverType() {
+        return ResourceResolverType.JCR_MOCK;
+    }
+
+}

Propchange: 
sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/jcrmock/resource/JcrResourceResolverTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/jcrmock/resource/JcrResourceResolverTest.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Mon Oct 13 11:54:39 2014
@@ -0,0 +1 @@
+LastChangedDate LastChangedRevision LastChangedBy HeadURL Id Author

Propchange: 
sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/jcrmock/resource/JcrResourceResolverTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 
sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/jcrmock/resource/SlingCrudResourceResolverTest.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/jcrmock/resource/SlingCrudResourceResolverTest.java?rev=1631356&view=auto
==============================================================================
--- 
sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/jcrmock/resource/SlingCrudResourceResolverTest.java
 (added)
+++ 
sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/jcrmock/resource/SlingCrudResourceResolverTest.java
 Mon Oct 13 11:54:39 2014
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.testing.mock.sling.jcrmock.resource;
+
+import org.apache.sling.testing.mock.sling.ResourceResolverType;
+import 
org.apache.sling.testing.mock.sling.resource.AbstractSlingCrudResourceResolverTest;
+
+/**
+ * Implements simple write and read resource and values test. Sling CRUD API is
+ * used to create the test data.
+ */
+public class SlingCrudResourceResolverTest extends 
AbstractSlingCrudResourceResolverTest {
+
+    protected ResourceResolverType getResourceResolverType() {
+        return ResourceResolverType.JCR_MOCK;
+    }
+
+}

Propchange: 
sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/jcrmock/resource/SlingCrudResourceResolverTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/jcrmock/resource/SlingCrudResourceResolverTest.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Mon Oct 13 11:54:39 2014
@@ -0,0 +1 @@
+LastChangedDate LastChangedRevision LastChangedBy HeadURL Id Author

Propchange: 
sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/jcrmock/resource/SlingCrudResourceResolverTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 
sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/junit/SlingContextTest.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/junit/SlingContextTest.java?rev=1631356&view=auto
==============================================================================
--- 
sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/junit/SlingContextTest.java
 (added)
+++ 
sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/junit/SlingContextTest.java
 Mon Oct 13 11:54:39 2014
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.testing.mock.sling.junit;
+
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.reset;
+import static org.mockito.Mockito.verify;
+
+import java.io.IOException;
+
+import org.apache.sling.api.resource.PersistenceException;
+import org.apache.sling.testing.mock.sling.ResourceResolverType;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.runners.MockitoJUnitRunner;
+
+@RunWith(MockitoJUnitRunner.class)
+public class SlingContextTest {
+
+    private final SlingContextCallback contextSetup = 
mock(SlingContextCallback.class);
+    private final SlingContextCallback contextTeardown = 
mock(SlingContextCallback.class);
+
+    // Run all unit tests for each resource resolver types listed here
+    @Rule
+    public SlingContext context = new SlingContext(contextSetup, 
contextTeardown,
+            ResourceResolverType.RESOURCERESOLVER_MOCK);
+
+    @Before
+    public void setUp() throws IOException, PersistenceException {
+        verify(contextSetup).execute(context);
+    }
+
+    @Test
+    public void testRequest() {
+        assertNotNull(context.request());
+    }
+
+    @After
+    public void tearDown() {
+        // reset required because mockito gets puzzled with the parameterized
+        // JUnit rule
+        // TODO: better solution?
+        reset(contextSetup);
+    }
+
+}

Propchange: 
sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/junit/SlingContextTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/junit/SlingContextTest.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Mon Oct 13 11:54:39 2014
@@ -0,0 +1 @@
+LastChangedDate LastChangedRevision LastChangedBy HeadURL Id Author

Propchange: 
sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/junit/SlingContextTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 
sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/loader/AbstractContentLoaderBinaryTest.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/loader/AbstractContentLoaderBinaryTest.java?rev=1631356&view=auto
==============================================================================
--- 
sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/loader/AbstractContentLoaderBinaryTest.java
 (added)
+++ 
sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/loader/AbstractContentLoaderBinaryTest.java
 Mon Oct 13 11:54:39 2014
@@ -0,0 +1,121 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.testing.mock.sling.loader;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Mockito.when;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Hashtable;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.jackrabbit.JcrConstants;
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.api.resource.ResourceResolver;
+import org.apache.sling.api.resource.ResourceUtil;
+import org.apache.sling.commons.mime.MimeTypeService;
+import org.apache.sling.testing.mock.osgi.MockOsgi;
+import org.apache.sling.testing.mock.sling.MockSling;
+import org.apache.sling.testing.mock.sling.ResourceResolverType;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.runners.MockitoJUnitRunner;
+import org.osgi.framework.BundleContext;
+
+@RunWith(MockitoJUnitRunner.class)
+public abstract class AbstractContentLoaderBinaryTest {
+
+    private static final int SAMPLE_IMAGE_FILESIZE = 62;
+
+    private BundleContext bundleContext;
+    private ResourceResolver resourceResolver;
+    private ContentLoader contentLoader;
+
+    @Mock
+    private MimeTypeService mimeTypeService;
+
+    protected abstract ResourceResolverType getResourceResolverType();
+
+    protected ResourceResolver newResourceResolver() {
+        return MockSling.newResourceResolver(getResourceResolverType());
+    }
+
+    @Before
+    public final void setUp() {
+        bundleContext = MockOsgi.newBundleContext();
+        bundleContext.registerService(MimeTypeService.class.getName(), 
mimeTypeService, new Hashtable());
+        resourceResolver = newResourceResolver();
+        contentLoader = new ContentLoader(this.resourceResolver, 
this.bundleContext);
+
+        when(mimeTypeService.getMimeType("gif")).thenReturn("image/gif");
+    }
+
+    @Test
+    public void testBinaryFile() throws IOException {
+        contentLoader.binaryFile("/sample-image.gif", 
"/content/binary/sample-image.gif");
+
+        Resource fileResource = 
resourceResolver.getResource("/content/binary/sample-image.gif");
+        assertSampleImageFileSize(fileResource);
+        assertMimeType(fileResource.getChild(JcrConstants.JCR_CONTENT), 
"image/gif");
+    }
+
+    @Test
+    public void testBinaryFileWithMimeType() throws IOException {
+        contentLoader.binaryFile("/sample-image.gif", 
"/content/binary/sample-image.gif", "mime/test");
+
+        Resource fileResource = 
resourceResolver.getResource("/content/binary/sample-image.gif");
+        assertSampleImageFileSize(fileResource);
+        assertMimeType(fileResource.getChild(JcrConstants.JCR_CONTENT), 
"mime/test");
+    }
+
+    @Test
+    public void testBinaryResource() throws IOException {
+        contentLoader.binaryResource("/sample-image.gif", 
"/content/binary/sample-image.gif");
+
+        Resource fileResource = 
resourceResolver.getResource("/content/binary/sample-image.gif");
+        assertSampleImageFileSize(fileResource);
+        assertMimeType(fileResource, "image/gif");
+    }
+
+    @Test
+    public void testBinaryResourceWithMimeType() throws IOException {
+        contentLoader.binaryResource("/sample-image.gif", 
"/content/binary/sample-image.gif", "mime/test");
+
+        Resource fileResource = 
resourceResolver.getResource("/content/binary/sample-image.gif");
+        assertSampleImageFileSize(fileResource);
+        assertMimeType(fileResource, "mime/test");
+    }
+
+    private void assertSampleImageFileSize(Resource resource) throws 
IOException {
+        InputStream is = resource.adaptTo(InputStream.class);
+        assertNotNull("InputSteam is null for " + resource.getPath(), is);
+        byte[] binaryData = IOUtils.toByteArray(is);
+        assertEquals(SAMPLE_IMAGE_FILESIZE, binaryData.length);
+    }
+
+    private void assertMimeType(Resource resource, String mimeType) {
+        assertNotNull(resource);
+        assertEquals(mimeType, 
ResourceUtil.getValueMap(resource).get(JcrConstants.JCR_MIMETYPE, 
String.class));
+    }
+
+}

Propchange: 
sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/loader/AbstractContentLoaderBinaryTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/loader/AbstractContentLoaderBinaryTest.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Mon Oct 13 11:54:39 2014
@@ -0,0 +1 @@
+LastChangedDate LastChangedRevision LastChangedBy HeadURL Id Author

Propchange: 
sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/loader/AbstractContentLoaderBinaryTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 
sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/loader/AbstractContentLoaderJsonDamTest.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/loader/AbstractContentLoaderJsonDamTest.java?rev=1631356&view=auto
==============================================================================
--- 
sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/loader/AbstractContentLoaderJsonDamTest.java
 (added)
+++ 
sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/loader/AbstractContentLoaderJsonDamTest.java
 Mon Oct 13 11:54:39 2014
@@ -0,0 +1,85 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.testing.mock.sling.loader;
+
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+
+import javax.jcr.NamespaceRegistry;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.api.resource.ResourceResolver;
+import org.apache.sling.api.resource.ResourceUtil;
+import org.apache.sling.api.resource.ValueMap;
+import org.apache.sling.testing.mock.sling.MockSling;
+import org.apache.sling.testing.mock.sling.ResourceResolverType;
+import org.junit.Before;
+import org.junit.Test;
+
+public abstract class AbstractContentLoaderJsonDamTest {
+
+    private ResourceResolver resourceResolver;
+
+    protected abstract ResourceResolverType getResourceResolverType();
+
+    protected ResourceResolver newResourceResolver() {
+        ResourceResolver resolver = 
MockSling.newResourceResolver(getResourceResolverType());
+
+        if (getResourceResolverType() == ResourceResolverType.JCR_MOCK) {
+            try {
+                // dummy namespace registrations to make sure sling JCR 
resolver
+                // does not get mixed up with the prefixes
+                NamespaceRegistry namespaceRegistry = 
resolver.adaptTo(Session.class).getWorkspace()
+                        .getNamespaceRegistry();
+                namespaceRegistry.registerNamespace("sling", 
"http://mock/sling";);
+                namespaceRegistry.registerNamespace("app", "http://mock/app";);
+                namespaceRegistry.registerNamespace("dam", "http://mock/dam";);
+            } catch (RepositoryException ex) {
+                throw new RuntimeException("Unable to register namespaces.", 
ex);
+            }
+        }
+
+        return resolver;
+    }
+
+    @Before
+    public final void setUp() {
+        this.resourceResolver = newResourceResolver();
+        ContentLoader contentLoader = new ContentLoader(this.resourceResolver);
+        contentLoader.json("/json-import-samples/dam.json", 
"/content/dam/sample");
+    }
+
+    @Test
+    public void testDamAssetMetadata() {
+        Resource assetMetadata = this.resourceResolver
+                
.getResource("/content/dam/sample/portraits/scott_reynolds.jpg/jcr:content/metadata");
+        ValueMap props = ResourceUtil.getValueMap(assetMetadata);
+
+        assertEquals("Canon\u0000", props.get("tiff:Make", String.class));
+        assertEquals((Long) 807L, props.get("tiff:ImageWidth", Long.class));
+        assertEquals((Integer) 595, props.get("tiff:ImageLength", 
Integer.class));
+        assertEquals(4.64385986328125d, props.get("dam:ApertureValue", 
Double.class), 0.00000000001d);
+
+        assertArrayEquals(new String[] { 
"stockphotography:business/business_people", "properties:style/color",
+                "properties:orientation/landscape" }, props.get("app:tags", 
String[].class));
+    }
+
+}

Propchange: 
sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/loader/AbstractContentLoaderJsonDamTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/loader/AbstractContentLoaderJsonDamTest.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Mon Oct 13 11:54:39 2014
@@ -0,0 +1 @@
+LastChangedDate LastChangedRevision LastChangedBy HeadURL Id Author

Propchange: 
sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/loader/AbstractContentLoaderJsonDamTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 
sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/loader/AbstractContentLoaderJsonTest.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/loader/AbstractContentLoaderJsonTest.java?rev=1631356&view=auto
==============================================================================
--- 
sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/loader/AbstractContentLoaderJsonTest.java
 (added)
+++ 
sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/loader/AbstractContentLoaderJsonTest.java
 Mon Oct 13 11:54:39 2014
@@ -0,0 +1,182 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.testing.mock.sling.loader;
+
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.util.Calendar;
+import java.util.TimeZone;
+
+import javax.jcr.NamespaceRegistry;
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+
+import org.apache.jackrabbit.JcrConstants;
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.api.resource.ResourceResolver;
+import org.apache.sling.api.resource.ResourceUtil;
+import org.apache.sling.api.resource.ValueMap;
+import org.apache.sling.testing.mock.sling.MockSling;
+import org.apache.sling.testing.mock.sling.ResourceResolverType;
+import org.junit.Before;
+import org.junit.Test;
+
+public abstract class AbstractContentLoaderJsonTest {
+
+    private ResourceResolver resourceResolver;
+
+    protected abstract ResourceResolverType getResourceResolverType();
+
+    protected ResourceResolver newResourceResolver() {
+        ResourceResolver resolver = 
MockSling.newResourceResolver(getResourceResolverType());
+
+        if (getResourceResolverType() == ResourceResolverType.JCR_MOCK) {
+            try {
+                // dummy namespace registrations to make sure sling JCR 
resolver
+                // does not get mixed up with the prefixes
+                NamespaceRegistry namespaceRegistry = 
resolver.adaptTo(Session.class).getWorkspace()
+                        .getNamespaceRegistry();
+                namespaceRegistry.registerNamespace("sling", 
"http://mock/sling";);
+                namespaceRegistry.registerNamespace("app", "http://mock/app";);
+                namespaceRegistry.registerNamespace("dam", "http://mock/dam";);
+            } catch (RepositoryException ex) {
+                throw new RuntimeException("Unable to register namespaces.", 
ex);
+            }
+        }
+
+        return resolver;
+    }
+
+    @Before
+    public final void setUp() {
+        this.resourceResolver = newResourceResolver();
+        ContentLoader contentLoader = new ContentLoader(this.resourceResolver);
+        contentLoader.json("/json-import-samples/content.json", 
"/content/sample/en");
+    }
+
+    @Test
+    public void testPageResourceType() {
+        Resource resource = 
this.resourceResolver.getResource("/content/sample/en");
+        assertEquals("app:Page", resource.getResourceType());
+    }
+
+    @Test
+    public void testPageJcrPrimaryType() throws RepositoryException {
+        Resource resource = 
this.resourceResolver.getResource("/content/sample/en");
+        assertPrimaryNodeType(resource, "app:Page");
+    }
+
+    @Test
+    public void testPageContentResourceType() {
+        Resource resource = 
this.resourceResolver.getResource("/content/sample/en/toolbar/profiles/jcr:content");
+        assertEquals("sample/components/contentpage", 
resource.getResourceType());
+    }
+
+    @Test
+    public void testPageContentJcrPrimaryType() throws RepositoryException {
+        Resource resource = 
this.resourceResolver.getResource("/content/sample/en/toolbar/profiles/jcr:content");
+        assertPrimaryNodeType(resource, "app:PageContent");
+    }
+
+    @Test
+    public void testPageContentProperties() {
+        Resource resource = 
this.resourceResolver.getResource("/content/sample/en/toolbar/profiles/jcr:content");
+        ValueMap props = ResourceUtil.getValueMap(resource);
+        assertEquals(true, props.get("hideInNav", Boolean.class));
+
+        assertEquals((Long) 1234567890123L, props.get("longProp", Long.class));
+        assertEquals(1.2345d, props.get("decimalProp", Double.class), 
0.00001d);
+        assertEquals(true, props.get("booleanProp", Boolean.class));
+
+        assertArrayEquals(new Long[] { 1234567890123L, 55L }, 
props.get("longPropMulti", Long[].class));
+        assertArrayEquals(new Double[] { 1.2345d, 1.1d }, 
props.get("decimalPropMulti", Double[].class));
+        assertArrayEquals(new Boolean[] { true, false }, 
props.get("booleanPropMulti", Boolean[].class));
+    }
+
+    @Test
+    public void testContentResourceType() {
+        Resource resource = 
this.resourceResolver.getResource("/content/sample/en/jcr:content/header");
+        assertEquals("sample/components/header", resource.getResourceType());
+    }
+
+    @Test
+    public void testContentJcrPrimaryType() throws RepositoryException {
+        Resource resource = 
this.resourceResolver.getResource("/content/sample/en/jcr:content/header");
+        assertPrimaryNodeType(resource, JcrConstants.NT_UNSTRUCTURED);
+    }
+
+    @Test
+    public void testContentProperties() {
+        Resource resource = 
this.resourceResolver.getResource("/content/sample/en/jcr:content/header");
+        ValueMap props = ResourceUtil.getValueMap(resource);
+        assertEquals("/content/dam/sample/header.png", 
props.get("imageReference", String.class));
+    }
+
+    private void assertPrimaryNodeType(final Resource resource, final String 
nodeType) throws RepositoryException {
+        Node node = resource.adaptTo(Node.class);
+        if (node != null) {
+            assertEquals(nodeType, node.getPrimaryNodeType().getName());
+        } else {
+            ValueMap props = ResourceUtil.getValueMap(resource);
+            assertEquals(nodeType, props.get(JcrConstants.JCR_PRIMARYTYPE));
+        }
+    }
+
+    @Test
+    public void testCalendarEcmaFormat() {
+        Resource resource = 
this.resourceResolver.getResource("/content/sample/en/jcr:content");
+        ValueMap props = ResourceUtil.getValueMap(resource);
+
+        Calendar calendar = props.get("app:lastModified", Calendar.class);
+        assertNotNull(calendar);
+
+        calendar.setTimeZone(TimeZone.getTimeZone("GMT+2"));
+
+        assertEquals(2014, calendar.get(Calendar.YEAR));
+        assertEquals(4, calendar.get(Calendar.MONTH) + 1);
+        assertEquals(22, calendar.get(Calendar.DAY_OF_MONTH));
+
+        assertEquals(15, calendar.get(Calendar.HOUR_OF_DAY));
+        assertEquals(11, calendar.get(Calendar.MINUTE));
+        assertEquals(24, calendar.get(Calendar.SECOND));
+    }
+    
+    @Test
+    public void testCalendarISO8601Format() {
+        Resource resource = 
this.resourceResolver.getResource("/content/sample/en/jcr:content");
+        ValueMap props = ResourceUtil.getValueMap(resource);
+
+        Calendar calendar = props.get("dateISO8601String", Calendar.class);
+        assertNotNull(calendar);
+
+        calendar.setTimeZone(TimeZone.getTimeZone("GMT+2"));
+        
+        assertEquals(2014, calendar.get(Calendar.YEAR));
+        assertEquals(4, calendar.get(Calendar.MONTH) + 1);
+        assertEquals(22, calendar.get(Calendar.DAY_OF_MONTH));
+
+        assertEquals(15, calendar.get(Calendar.HOUR_OF_DAY));
+        assertEquals(11, calendar.get(Calendar.MINUTE));
+        assertEquals(24, calendar.get(Calendar.SECOND));
+    }
+    
+}

Propchange: 
sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/loader/AbstractContentLoaderJsonTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/loader/AbstractContentLoaderJsonTest.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Mon Oct 13 11:54:39 2014
@@ -0,0 +1 @@
+LastChangedDate LastChangedRevision LastChangedBy HeadURL Id Author

Propchange: 
sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/loader/AbstractContentLoaderJsonTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 
sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/resource/AbstractJcrResourceResolverTest.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/resource/AbstractJcrResourceResolverTest.java?rev=1631356&view=auto
==============================================================================
--- 
sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/resource/AbstractJcrResourceResolverTest.java
 (added)
+++ 
sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/resource/AbstractJcrResourceResolverTest.java
 Mon Oct 13 11:54:39 2014
@@ -0,0 +1,168 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.testing.mock.sling.resource;
+
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.List;
+
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang3.time.DateUtils;
+import org.apache.jackrabbit.JcrConstants;
+import org.apache.sling.api.resource.PersistenceException;
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.api.resource.ResourceResolver;
+import org.apache.sling.api.resource.ResourceUtil;
+import org.apache.sling.api.resource.ValueMap;
+import org.apache.sling.testing.mock.sling.MockSling;
+import org.apache.sling.testing.mock.sling.ResourceResolverType;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+
+/**
+ * Implements simple write and read resource and values test.
+ * JCR API is used to create the test data.
+ */
+public abstract class AbstractJcrResourceResolverTest {
+
+    private static final String STRING_VALUE = "value1";
+    private static final String[] STRING_ARRAY_VALUE = new String[] { 
"value1", "value2" };
+    private static final int INTEGER_VALUE = 25;
+    private static final double DOUBLE_VALUE = 3.555d;
+    private static final boolean BOOLEAN_VALUE = true;
+    private static final Date DATE_VALUE = new Date(10000);
+    private static final Calendar CALENDAR_VALUE = Calendar.getInstance();
+    private static final byte[] BINARY_VALUE = new byte[] { 0x01, 0x02, 0x03, 
0x04, 0x05, 0x06 };
+
+    private ResourceResolver resourceResolver;
+    private Session session;
+    protected Node testRoot;
+    private static volatile long rootNodeCounter;
+
+    protected abstract ResourceResolverType getResourceResolverType();
+
+    protected ResourceResolver newResourceResolver() {
+        return MockSling.newResourceResolver(getResourceResolverType());
+    }
+
+    @Before
+    public final void setUp() throws RepositoryException {
+        resourceResolver = newResourceResolver();
+        session = resourceResolver.adaptTo(Session.class);
+
+        // prepare some test data using JCR API
+        Node rootNode = getTestRootNode();
+        Node node1 = rootNode.addNode("node1", JcrConstants.NT_UNSTRUCTURED);
+
+        node1.setProperty("stringProp", STRING_VALUE);
+        node1.setProperty("stringArrayProp", STRING_ARRAY_VALUE);
+        node1.setProperty("integerProp", INTEGER_VALUE);
+        node1.setProperty("doubleProp", DOUBLE_VALUE);
+        node1.setProperty("booleanProp", BOOLEAN_VALUE);
+        node1.setProperty("dateProp", DateUtils.toCalendar(DATE_VALUE));
+        node1.setProperty("calendarProp", CALENDAR_VALUE);
+        node1.setProperty("binaryProp", 
session.getValueFactory().createBinary(new ByteArrayInputStream(BINARY_VALUE)));
+
+        node1.addNode("node11", JcrConstants.NT_UNSTRUCTURED);
+        node1.addNode("node12", JcrConstants.NT_UNSTRUCTURED);
+
+        session.save();
+    }
+
+    @After
+    public final void tearDown() {
+        testRoot = null;
+    }
+
+    /**
+     * Return a test root node, created on demand, with a unique path
+     */
+    private Node getTestRootNode() throws RepositoryException {
+        if (testRoot == null) {
+            final Node root = session.getRootNode();
+            if (getResourceResolverType() == 
ResourceResolverType.JCR_JACKRABBIT) {
+                final Node classRoot = 
root.addNode(getClass().getSimpleName());
+                testRoot = classRoot.addNode(System.currentTimeMillis() + "_" 
+ (rootNodeCounter++));
+            } else {
+                testRoot = root.addNode("test", JcrConstants.NT_UNSTRUCTURED);
+            }
+        }
+        return testRoot;
+    }
+
+    @Test
+    public void testGetResourcesAndValues() throws IOException, 
RepositoryException {
+        Resource resource1 = 
resourceResolver.getResource(getTestRootNode().getPath() + "/node1");
+        assertNotNull(resource1);
+        assertEquals("node1", resource1.getName());
+
+        ValueMap props = ResourceUtil.getValueMap(resource1);
+        assertEquals(STRING_VALUE, props.get("stringProp", String.class));
+        assertArrayEquals(STRING_ARRAY_VALUE, props.get("stringArrayProp", 
String[].class));
+        assertEquals((Integer) INTEGER_VALUE, props.get("integerProp", 
Integer.class));
+        assertEquals(DOUBLE_VALUE, props.get("doubleProp", Double.class), 
0.0001);
+        assertEquals(BOOLEAN_VALUE, props.get("booleanProp", Boolean.class));
+        assertEquals(DATE_VALUE, props.get("dateProp", Date.class));
+        assertEquals(CALENDAR_VALUE.getTime(), props.get("calendarProp", 
Calendar.class).getTime());
+
+        Resource binaryPropResource = resource1.getChild("binaryProp");
+        InputStream is = binaryPropResource.adaptTo(InputStream.class);
+        byte[] dataFromResource = IOUtils.toByteArray(is);
+        is.close();
+        assertArrayEquals(BINARY_VALUE, dataFromResource);
+
+        // read second time to ensure not the original input stream was 
returned
+        InputStream is2 = binaryPropResource.adaptTo(InputStream.class);
+        byte[] dataFromResource2 = IOUtils.toByteArray(is2);
+        is2.close();
+        assertArrayEquals(BINARY_VALUE, dataFromResource2);
+
+        List<Resource> children = 
ImmutableList.copyOf(resource1.listChildren());
+        assertEquals(2, children.size());
+        assertEquals("node11", children.get(0).getName());
+        assertEquals("node12", children.get(1).getName());
+    }
+
+    @Test
+    public void testCreateNodeType() throws RepositoryException, 
PersistenceException {
+        Resource parent = 
resourceResolver.getResource(getTestRootNode().getPath());
+
+        Resource child = resourceResolver.create(parent, "nodeTypeResource", 
ImmutableMap.<String, Object> builder()
+                .put("sling:resourceType", 
JcrConstants.NT_UNSTRUCTURED).build());
+        assertNotNull(child);
+        assertEquals(JcrConstants.NT_UNSTRUCTURED, child.getResourceType());
+        assertEquals(JcrConstants.NT_UNSTRUCTURED, 
child.adaptTo(Node.class).getPrimaryNodeType().getName());
+    }
+
+}

Propchange: 
sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/resource/AbstractJcrResourceResolverTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/resource/AbstractJcrResourceResolverTest.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Mon Oct 13 11:54:39 2014
@@ -0,0 +1 @@
+LastChangedDate LastChangedRevision LastChangedBy HeadURL Id Author

Propchange: 
sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/resource/AbstractJcrResourceResolverTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 
sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/resource/AbstractSlingCrudResourceResolverTest.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/resource/AbstractSlingCrudResourceResolverTest.java?rev=1631356&view=auto
==============================================================================
--- 
sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/resource/AbstractSlingCrudResourceResolverTest.java
 (added)
+++ 
sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/resource/AbstractSlingCrudResourceResolverTest.java
 Mon Oct 13 11:54:39 2014
@@ -0,0 +1,214 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.testing.mock.sling.resource;
+
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.jackrabbit.JcrConstants;
+import org.apache.sling.api.resource.PersistenceException;
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.api.resource.ResourceResolver;
+import org.apache.sling.api.resource.ResourceUtil;
+import org.apache.sling.api.resource.ValueMap;
+import org.apache.sling.testing.mock.sling.MockSling;
+import org.apache.sling.testing.mock.sling.ResourceResolverType;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import com.google.common.collect.ImmutableList;
+
+/**
+ * Implements simple write and read resource and values test. Sling CRUD API is
+ * used to create the test data.
+ */
+public abstract class AbstractSlingCrudResourceResolverTest {
+
+    private static final String STRING_VALUE = "value1";
+    private static final String[] STRING_ARRAY_VALUE = new String[] { 
"value1", "value2" };
+    private static final int INTEGER_VALUE = 25;
+    private static final double DOUBLE_VALUE = 3.555d;
+    private static final boolean BOOLEAN_VALUE = true;
+    private static final Date DATE_VALUE = new Date(10000);
+    private static final Calendar CALENDAR_VALUE = Calendar.getInstance();
+    private static final byte[] BINARY_VALUE = new byte[] { 0x01, 0x02, 0x03, 
0x04, 0x05, 0x06 };
+
+    private ResourceResolver resourceResolver;
+    protected Resource testRoot;
+    private static volatile long rootNodeCounter;
+
+    protected abstract ResourceResolverType getResourceResolverType();
+
+    protected ResourceResolver newResourceResolver() {
+        return MockSling.newResourceResolver(getResourceResolverType());
+    }
+
+    @Before
+    public final void setUp() throws IOException {
+        this.resourceResolver = newResourceResolver();
+
+        // prepare some test data using Sling CRUD API
+        Resource rootNode = getTestRootResource();
+
+        Map<String, Object> props = new HashMap<String, Object>();
+        props.put(JcrConstants.JCR_PRIMARYTYPE, JcrConstants.NT_UNSTRUCTURED);
+        props.put("stringProp", STRING_VALUE);
+        props.put("stringArrayProp", STRING_ARRAY_VALUE);
+        props.put("integerProp", INTEGER_VALUE);
+        props.put("doubleProp", DOUBLE_VALUE);
+        props.put("booleanProp", BOOLEAN_VALUE);
+        props.put("dateProp", DATE_VALUE);
+        props.put("calendarProp", CALENDAR_VALUE);
+        props.put("binaryProp", new ByteArrayInputStream(BINARY_VALUE));
+        Resource node1 = this.resourceResolver.create(rootNode, "node1", 
props);
+
+        this.resourceResolver.create(node1, "node11", ValueMap.EMPTY);
+        this.resourceResolver.create(node1, "node12", ValueMap.EMPTY);
+
+        this.resourceResolver.commit();
+    }
+
+    @After
+    public final void tearDown() {
+        this.testRoot = null;
+    }
+
+    /**
+     * Return a test root resource, created on demand, with a unique path
+     * @throws PersistenceException
+     */
+    private Resource getTestRootResource() throws PersistenceException {
+        if (this.testRoot == null) {
+            Map<String, Object> props = new HashMap<String, Object>();
+            props.put(JcrConstants.JCR_PRIMARYTYPE, 
JcrConstants.NT_UNSTRUCTURED);
+            final Resource root = this.resourceResolver.getResource("/");
+            if (getResourceResolverType() == 
ResourceResolverType.JCR_JACKRABBIT) {
+                final Resource classRoot = this.resourceResolver.create(root, 
getClass().getSimpleName(), props);
+                this.testRoot = this.resourceResolver.create(classRoot, 
System.currentTimeMillis() + "_"
+                        + (rootNodeCounter++), props);
+            } else {
+                this.testRoot = this.resourceResolver.create(root, "test", 
props);
+            }
+        }
+        return this.testRoot;
+    }
+
+    @Test
+    public void testSimpleProperties() throws IOException {
+        Resource resource1 = 
this.resourceResolver.getResource(getTestRootResource().getPath() + "/node1");
+        assertNotNull(resource1);
+        assertEquals("node1", resource1.getName());
+
+        ValueMap props = ResourceUtil.getValueMap(resource1);
+        assertEquals(STRING_VALUE, props.get("stringProp", String.class));
+        assertArrayEquals(STRING_ARRAY_VALUE, props.get("stringArrayProp", 
String[].class));
+        assertEquals((Integer) INTEGER_VALUE, props.get("integerProp", 
Integer.class));
+        assertEquals(DOUBLE_VALUE, props.get("doubleProp", Double.class), 
0.0001);
+        assertEquals(BOOLEAN_VALUE, props.get("booleanProp", Boolean.class));
+    }
+
+    @Test
+    public void testDateProperty() throws IOException {
+        Resource resource1 = 
this.resourceResolver.getResource(getTestRootResource().getPath() + "/node1");
+        ValueMap props = ResourceUtil.getValueMap(resource1);
+        // TODO: enable this test when JCR resource implementation supports
+        // writing Date objects (SLING-3846)
+        if (getResourceResolverType() != ResourceResolverType.JCR_MOCK
+                && getResourceResolverType() != 
ResourceResolverType.JCR_JACKRABBIT) {
+            assertEquals(DATE_VALUE, props.get("dateProp", Date.class));
+        }
+    }
+
+    @Test
+    public void testDatePropertyToCalendar() throws IOException {
+        Resource resource1 = 
this.resourceResolver.getResource(getTestRootResource().getPath() + "/node1");
+        ValueMap props = ResourceUtil.getValueMap(resource1);
+        // TODO: enable this test when JCR resource implementation supports
+        // writing Date objects (SLING-3846)
+        if (getResourceResolverType() != ResourceResolverType.JCR_MOCK
+                && getResourceResolverType() != 
ResourceResolverType.JCR_JACKRABBIT) {
+            Calendar calendarValue = props.get("dateProp", Calendar.class);
+            assertNotNull(calendarValue);
+            assertEquals(DATE_VALUE, calendarValue.getTime());
+        }
+    }
+
+    @Test
+    public void testCalendarProperty() throws IOException {
+        Resource resource1 = 
this.resourceResolver.getResource(getTestRootResource().getPath() + "/node1");
+        ValueMap props = ResourceUtil.getValueMap(resource1);
+        assertEquals(CALENDAR_VALUE.getTime(), props.get("calendarProp", 
Calendar.class).getTime());
+    }
+
+    @Test
+    public void testCalendarPropertyToDate() throws IOException {
+        Resource resource1 = 
this.resourceResolver.getResource(getTestRootResource().getPath() + "/node1");
+        ValueMap props = ResourceUtil.getValueMap(resource1);
+        Date dateValue = props.get("calendarProp", Date.class);
+        assertNotNull(dateValue);
+        assertEquals(CALENDAR_VALUE.getTime(), dateValue);
+    }
+
+    @Test
+    public void testListChildren() throws IOException {
+        Resource resource1 = 
this.resourceResolver.getResource(getTestRootResource().getPath() + "/node1");
+
+        List<Resource> children = 
ImmutableList.copyOf(resource1.listChildren());
+        assertEquals(2, children.size());
+        assertEquals("node11", children.get(0).getName());
+        assertEquals("node12", children.get(1).getName());
+    }
+
+    @Test
+    public void testBinaryData() throws IOException {
+        Resource resource1 = 
this.resourceResolver.getResource(getTestRootResource().getPath() + "/node1");
+
+        Resource binaryPropResource = resource1.getChild("binaryProp");
+        InputStream is = binaryPropResource.adaptTo(InputStream.class);
+        byte[] dataFromResource = IOUtils.toByteArray(is);
+        is.close();
+        assertArrayEquals(BINARY_VALUE, dataFromResource);
+
+        // read second time to ensure not the original input stream was 
returned
+        // and this time using another syntax
+        InputStream is2 = 
ResourceUtil.getValueMap(resource1).get("binaryProp", InputStream.class);
+        byte[] dataFromResource2 = IOUtils.toByteArray(is2);
+        is2.close();
+        assertArrayEquals(BINARY_VALUE, dataFromResource2);
+    }
+
+    @Test
+    public void testPrimaryTypeResourceType() throws PersistenceException {
+        Resource resource = 
this.resourceResolver.getResource(getTestRootResource().getPath());
+        assertEquals(JcrConstants.NT_UNSTRUCTURED, resource.getResourceType());
+    }
+
+}

Propchange: 
sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/resource/AbstractSlingCrudResourceResolverTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/resource/AbstractSlingCrudResourceResolverTest.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Mon Oct 13 11:54:39 2014
@@ -0,0 +1 @@
+LastChangedDate LastChangedRevision LastChangedBy HeadURL Id Author

Propchange: 
sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/resource/AbstractSlingCrudResourceResolverTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 
sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/rrmock/loader/ContentLoaderBinaryTest.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/rrmock/loader/ContentLoaderBinaryTest.java?rev=1631356&view=auto
==============================================================================
--- 
sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/rrmock/loader/ContentLoaderBinaryTest.java
 (added)
+++ 
sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/rrmock/loader/ContentLoaderBinaryTest.java
 Mon Oct 13 11:54:39 2014
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.testing.mock.sling.rrmock.loader;
+
+import org.apache.sling.api.resource.ResourceResolver;
+import org.apache.sling.testing.mock.sling.MockSling;
+import org.apache.sling.testing.mock.sling.ResourceResolverType;
+import 
org.apache.sling.testing.mock.sling.loader.AbstractContentLoaderBinaryTest;
+
+public class ContentLoaderBinaryTest extends AbstractContentLoaderBinaryTest {
+
+    @Override
+    protected ResourceResolverType getResourceResolverType() {
+        return ResourceResolverType.RESOURCERESOLVER_MOCK;
+    }
+
+    @Override
+    protected ResourceResolver newResourceResolver() {
+        return MockSling.newResourceResolver(getResourceResolverType());
+    }
+
+}

Propchange: 
sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/rrmock/loader/ContentLoaderBinaryTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/rrmock/loader/ContentLoaderBinaryTest.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Mon Oct 13 11:54:39 2014
@@ -0,0 +1 @@
+LastChangedDate LastChangedRevision LastChangedBy HeadURL Id Author

Propchange: 
sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/rrmock/loader/ContentLoaderBinaryTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 
sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/rrmock/loader/ContentLoaderJsonDamTest.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/rrmock/loader/ContentLoaderJsonDamTest.java?rev=1631356&view=auto
==============================================================================
--- 
sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/rrmock/loader/ContentLoaderJsonDamTest.java
 (added)
+++ 
sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/rrmock/loader/ContentLoaderJsonDamTest.java
 Mon Oct 13 11:54:39 2014
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.testing.mock.sling.rrmock.loader;
+
+import org.apache.sling.api.resource.ResourceResolver;
+import org.apache.sling.testing.mock.sling.MockSling;
+import org.apache.sling.testing.mock.sling.ResourceResolverType;
+import 
org.apache.sling.testing.mock.sling.loader.AbstractContentLoaderJsonDamTest;
+
+public class ContentLoaderJsonDamTest extends AbstractContentLoaderJsonDamTest 
{
+
+    @Override
+    protected ResourceResolverType getResourceResolverType() {
+        return ResourceResolverType.RESOURCERESOLVER_MOCK;
+    }
+
+    @Override
+    protected ResourceResolver newResourceResolver() {
+        return MockSling.newResourceResolver(getResourceResolverType());
+    }
+
+}

Propchange: 
sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/rrmock/loader/ContentLoaderJsonDamTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/rrmock/loader/ContentLoaderJsonDamTest.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Mon Oct 13 11:54:39 2014
@@ -0,0 +1 @@
+LastChangedDate LastChangedRevision LastChangedBy HeadURL Id Author

Propchange: 
sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/rrmock/loader/ContentLoaderJsonDamTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 
sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/rrmock/loader/ContentLoaderJsonTest.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/rrmock/loader/ContentLoaderJsonTest.java?rev=1631356&view=auto
==============================================================================
--- 
sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/rrmock/loader/ContentLoaderJsonTest.java
 (added)
+++ 
sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/rrmock/loader/ContentLoaderJsonTest.java
 Mon Oct 13 11:54:39 2014
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.testing.mock.sling.rrmock.loader;
+
+import org.apache.sling.api.resource.ResourceResolver;
+import org.apache.sling.testing.mock.sling.MockSling;
+import org.apache.sling.testing.mock.sling.ResourceResolverType;
+import 
org.apache.sling.testing.mock.sling.loader.AbstractContentLoaderJsonTest;
+
+public class ContentLoaderJsonTest extends AbstractContentLoaderJsonTest {
+
+    @Override
+    protected ResourceResolverType getResourceResolverType() {
+        return ResourceResolverType.RESOURCERESOLVER_MOCK;
+    }
+
+    @Override
+    protected ResourceResolver newResourceResolver() {
+        return MockSling.newResourceResolver(getResourceResolverType());
+    }
+
+}

Propchange: 
sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/rrmock/loader/ContentLoaderJsonTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/rrmock/loader/ContentLoaderJsonTest.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Mon Oct 13 11:54:39 2014
@@ -0,0 +1 @@
+LastChangedDate LastChangedRevision LastChangedBy HeadURL Id Author

Propchange: 
sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/rrmock/loader/ContentLoaderJsonTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 
sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/rrmock/resource/SlingCrudResourceResolverTest.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/rrmock/resource/SlingCrudResourceResolverTest.java?rev=1631356&view=auto
==============================================================================
--- 
sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/rrmock/resource/SlingCrudResourceResolverTest.java
 (added)
+++ 
sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/rrmock/resource/SlingCrudResourceResolverTest.java
 Mon Oct 13 11:54:39 2014
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.testing.mock.sling.rrmock.resource;
+
+import org.apache.sling.api.resource.ResourceResolver;
+import org.apache.sling.testing.mock.sling.MockSling;
+import org.apache.sling.testing.mock.sling.ResourceResolverType;
+import 
org.apache.sling.testing.mock.sling.resource.AbstractSlingCrudResourceResolverTest;
+
+public class SlingCrudResourceResolverTest extends 
AbstractSlingCrudResourceResolverTest {
+
+    @Override
+    protected ResourceResolverType getResourceResolverType() {
+        return ResourceResolverType.RESOURCERESOLVER_MOCK;
+    }
+
+    @Override
+    protected ResourceResolver newResourceResolver() {
+        return MockSling.newResourceResolver(getResourceResolverType());
+    }
+
+}

Propchange: 
sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/rrmock/resource/SlingCrudResourceResolverTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/rrmock/resource/SlingCrudResourceResolverTest.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Mon Oct 13 11:54:39 2014
@@ -0,0 +1 @@
+LastChangedDate LastChangedRevision LastChangedBy HeadURL Id Author

Propchange: 
sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/rrmock/resource/SlingCrudResourceResolverTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 
sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/services/MockMimeTypeServiceTest.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/services/MockMimeTypeServiceTest.java?rev=1631356&view=auto
==============================================================================
--- 
sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/services/MockMimeTypeServiceTest.java
 (added)
+++ 
sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/services/MockMimeTypeServiceTest.java
 Mon Oct 13 11:54:39 2014
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.testing.mock.sling.services;
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.sling.commons.mime.MimeTypeService;
+import org.junit.Before;
+import org.junit.Test;
+
+public class MockMimeTypeServiceTest {
+
+    private MimeTypeService mimeTypeService;
+
+    @Before
+    public void setUp() throws Exception {
+        this.mimeTypeService = new MockMimeTypeService();
+    }
+
+    @Test
+    public void testGetMimeType() {
+        assertEquals("text/html", this.mimeTypeService.getMimeType("html"));
+        assertEquals("application/json", 
this.mimeTypeService.getMimeType("json"));
+        assertEquals("image/jpeg", this.mimeTypeService.getMimeType("jpg"));
+        assertEquals("image/jpeg", this.mimeTypeService.getMimeType("jpeg"));
+    }
+
+    @Test
+    public void testGetExtension() {
+        assertEquals("html", this.mimeTypeService.getExtension("text/html"));
+        assertEquals("json", 
this.mimeTypeService.getExtension("application/json"));
+        assertEquals("jpeg", this.mimeTypeService.getExtension("image/jpeg"));
+    }
+
+}

Propchange: 
sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/services/MockMimeTypeServiceTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/services/MockMimeTypeServiceTest.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Mon Oct 13 11:54:39 2014
@@ -0,0 +1 @@
+LastChangedDate LastChangedRevision LastChangedBy HeadURL Id Author

Propchange: 
sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/services/MockMimeTypeServiceTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 
sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/services/MockModelAdapterFactoryTest.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/services/MockModelAdapterFactoryTest.java?rev=1631356&view=auto
==============================================================================
--- 
sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/services/MockModelAdapterFactoryTest.java
 (added)
+++ 
sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/services/MockModelAdapterFactoryTest.java
 Mon Oct 13 11:54:39 2014
@@ -0,0 +1,142 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.testing.mock.sling.services;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+import javax.inject.Inject;
+
+import org.apache.sling.api.SlingHttpServletRequest;
+import org.apache.sling.api.adapter.AdapterFactory;
+import org.apache.sling.api.resource.ResourceResolver;
+import org.apache.sling.commons.mime.MimeTypeService;
+import org.apache.sling.models.annotations.Model;
+import org.apache.sling.models.impl.FirstImplementationPicker;
+import org.apache.sling.models.impl.injectors.OSGiServiceInjector;
+import org.apache.sling.models.impl.injectors.RequestAttributeInjector;
+import org.apache.sling.models.spi.ImplementationPicker;
+import org.apache.sling.models.spi.Injector;
+import org.apache.sling.testing.mock.osgi.MockOsgi;
+import org.apache.sling.testing.mock.sling.MockSling;
+import org.apache.sling.testing.mock.sling.servlet.MockSlingHttpServletRequest;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.osgi.framework.BundleContext;
+import org.osgi.service.component.ComponentContext;
+
+public class MockModelAdapterFactoryTest {
+
+    private ComponentContext componentContext;
+    private BundleContext bundleContext;
+
+    @Before
+    public void setUp() throws Exception {
+        componentContext = MockOsgi.newComponentContext();
+        bundleContext = componentContext.getBundleContext();
+        MockSling.setAdapterManagerBundleContext(bundleContext);
+
+        // register sling models adapter factory
+        MockModelAdapterFactory mockModelAdapterFactory = new 
MockModelAdapterFactory(componentContext);
+        bundleContext.registerService(AdapterFactory.class.getName(), 
mockModelAdapterFactory, null);
+
+        // register some injectors
+        bundleContext.registerService(Injector.class.getName(), new 
RequestAttributeInjector(), null);
+        OSGiServiceInjector osgiServiceInjector = new OSGiServiceInjector();
+        osgiServiceInjector.activate(componentContext);
+        bundleContext.registerService(Injector.class.getName(), 
osgiServiceInjector, null);
+
+        // register implementation pickers
+        bundleContext.registerService(ImplementationPicker.class.getName(), 
new FirstImplementationPicker(), null);
+
+        // scan for @Model classes
+        
mockModelAdapterFactory.addModelsForPackage("org.apache.sling.testing.mock.sling.services");
+    }
+
+    @After
+    public void tearDown() throws Exception {
+        MockSling.clearAdapterManagerBundleContext();
+    }
+
+    @Test
+    public void testRequestAttribute() {
+        MockSlingHttpServletRequest request = new 
MockSlingHttpServletRequest();
+        request.setAttribute("prop1", "myValue");
+        RequestAttributeModel model = 
request.adaptTo(RequestAttributeModel.class);
+        assertNotNull(model);
+        assertEquals("myValue", model.getProp1());
+    }
+
+    @Test
+    public void testOsgiService() {
+        bundleContext.registerService(MimeTypeService.class.getName(), new 
MockMimeTypeService(), null);
+
+        ResourceResolver resolver = MockSling.newResourceResolver();
+        OsgiServiceModel model = resolver.adaptTo(OsgiServiceModel.class);
+        assertNotNull(model);
+        assertNotNull(model.getMimeTypeService());
+        assertEquals("text/html", 
model.getMimeTypeService().getMimeType("html"));
+    }
+
+    @Test
+    public void testInvalidAdapt() {
+        MockSlingHttpServletRequest request = new 
MockSlingHttpServletRequest();
+        OsgiServiceModel model = request.adaptTo(OsgiServiceModel.class);
+        assertNull(model);
+    }
+
+    @Test
+    public void testAdaptToInterface() {
+        MockSlingHttpServletRequest request = new 
MockSlingHttpServletRequest();
+        request.setAttribute("prop1", "myValue");
+        ServiceInterface model = request.adaptTo(ServiceInterface.class);
+        assertNotNull(model);
+        assertEquals("myValue", model.getPropValue());
+    }
+
+    @Model(adaptables = SlingHttpServletRequest.class)
+    public interface RequestAttributeModel {
+        @Inject
+        String getProp1();
+    }
+
+    @Model(adaptables = ResourceResolver.class)
+    public interface OsgiServiceModel {
+        @Inject
+        MimeTypeService getMimeTypeService();
+    }
+
+    public interface ServiceInterface {
+        String getPropValue();
+    }
+
+    @Model(adaptables = SlingHttpServletRequest.class, adapters = 
ServiceInterface.class)
+    public static class ServiceInterfaceImpl implements ServiceInterface {
+        @Inject
+        private String prop1;
+
+        @Override
+        public String getPropValue() {
+            return this.prop1;
+        }
+    }
+
+}

Propchange: 
sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/services/MockModelAdapterFactoryTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/services/MockModelAdapterFactoryTest.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Mon Oct 13 11:54:39 2014
@@ -0,0 +1 @@
+LastChangedDate LastChangedRevision LastChangedBy HeadURL Id Author

Propchange: 
sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/services/MockModelAdapterFactoryTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 
sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/services/MockSlingSettingServiceTest.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/services/MockSlingSettingServiceTest.java?rev=1631356&view=auto
==============================================================================
--- 
sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/services/MockSlingSettingServiceTest.java
 (added)
+++ 
sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/services/MockSlingSettingServiceTest.java
 Mon Oct 13 11:54:39 2014
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.testing.mock.sling.services;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Set;
+
+import org.junit.Test;
+
+import com.google.common.collect.ImmutableSet;
+
+public class MockSlingSettingServiceTest {
+
+    @Test
+    public void testDefaultRunModes() {
+        Set<String> defaultRunModes = ImmutableSet.<String> 
builder().add("mode0").build();
+        MockSlingSettingService underTest = new 
MockSlingSettingService(defaultRunModes);
+        assertEquals(defaultRunModes, underTest.getRunModes());
+
+        Set<String> newRunModes = ImmutableSet.<String> 
builder().add("mode1").add("mode2").build();
+        underTest.setRunModes(newRunModes);
+        assertEquals(newRunModes, underTest.getRunModes());
+    }
+
+    @Test
+    public void testNoDefaultRunModes() {
+        MockSlingSettingService underTest = new MockSlingSettingService();
+        assertTrue(underTest.getRunModes().isEmpty());
+
+        Set<String> newRunModes = ImmutableSet.<String> 
builder().add("mode1").add("mode2").build();
+        underTest.setRunModes(newRunModes);
+        assertEquals(newRunModes, underTest.getRunModes());
+    }
+
+}

Propchange: 
sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/services/MockSlingSettingServiceTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/services/MockSlingSettingServiceTest.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Mon Oct 13 11:54:39 2014
@@ -0,0 +1 @@
+LastChangedDate LastChangedRevision LastChangedBy HeadURL Id Author

Propchange: 
sling/trunk/testing/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/services/MockSlingSettingServiceTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain


Reply via email to