You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ss...@apache.org on 2014/10/13 13:54:43 UTC
svn commit: r1631356 [4/9] - in /sling/trunk: ./ testing/jcr-mock/
testing/jcr-mock/src/ testing/jcr-mock/src/main/
testing/jcr-mock/src/main/java/ testing/jcr-mock/src/main/java/org/
testing/jcr-mock/src/main/java/org/apache/ testing/jcr-mock/src/main...
Added: sling/trunk/testing/osgi-mock/src/test/java/org/apache/sling/testing/mock/osgi/MockBundleContextTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/testing/osgi-mock/src/test/java/org/apache/sling/testing/mock/osgi/MockBundleContextTest.java?rev=1631356&view=auto
==============================================================================
--- sling/trunk/testing/osgi-mock/src/test/java/org/apache/sling/testing/mock/osgi/MockBundleContextTest.java (added)
+++ sling/trunk/testing/osgi-mock/src/test/java/org/apache/sling/testing/mock/osgi/MockBundleContextTest.java Mon Oct 13 11:54:39 2014
@@ -0,0 +1,159 @@
+/*
+ * 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.osgi;
+
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertSame;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+
+import java.util.Dictionary;
+import java.util.Hashtable;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.runners.MockitoJUnitRunner;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleEvent;
+import org.osgi.framework.BundleListener;
+import org.osgi.framework.Constants;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceEvent;
+import org.osgi.framework.ServiceListener;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.ServiceRegistration;
+
+@RunWith(MockitoJUnitRunner.class)
+public class MockBundleContextTest {
+
+ private BundleContext bundleContext;
+
+ @Before
+ public void setUp() {
+ this.bundleContext = MockOsgi.newBundleContext();
+ }
+
+ @Test
+ public void testBundle() {
+ assertNotNull(this.bundleContext.getBundle());
+ }
+
+ @Test
+ public void testServiceRegistration() throws InvalidSyntaxException {
+ // prepare test services
+ String clazz1 = String.class.getName();
+ Object service1 = new Object();
+ Dictionary properties1 = getServiceProperties(null);
+ ServiceRegistration reg1 = this.bundleContext.registerService(clazz1, service1, properties1);
+
+ String[] clazzes2 = new String[] { String.class.getName(), Integer.class.getName() };
+ Object service2 = new Object();
+ Dictionary properties2 = getServiceProperties(null);
+ ServiceRegistration reg2 = this.bundleContext.registerService(clazzes2, service2, properties2);
+
+ String clazz3 = Integer.class.getName();
+ Object service3 = new Object();
+ Dictionary properties3 = getServiceProperties(100L);
+ ServiceRegistration reg3 = this.bundleContext.registerService(clazz3, service3, properties3);
+
+ // test get service references
+ ServiceReference refString = this.bundleContext.getServiceReference(String.class.getName());
+ assertSame(reg1.getReference(), refString);
+
+ ServiceReference refInteger = this.bundleContext.getServiceReference(Integer.class.getName());
+ assertSame(reg3.getReference(), refInteger);
+
+ ServiceReference[] refsString = this.bundleContext.getServiceReferences(String.class.getName(), null);
+ assertEquals(2, refsString.length);
+ assertSame(reg1.getReference(), refsString[0]);
+ assertSame(reg2.getReference(), refsString[1]);
+
+ ServiceReference[] refsInteger = this.bundleContext.getServiceReferences(Integer.class.getName(), null);
+ assertEquals(2, refsInteger.length);
+ assertSame(reg3.getReference(), refsInteger[0]);
+ assertSame(reg2.getReference(), refsInteger[1]);
+
+ ServiceReference[] allRefsString = this.bundleContext.getAllServiceReferences(String.class.getName(), null);
+ assertArrayEquals(refsString, allRefsString);
+
+ // test get services
+ assertSame(service1, this.bundleContext.getService(refsString[0]));
+ assertSame(service2, this.bundleContext.getService(refsString[1]));
+ assertSame(service3, this.bundleContext.getService(refInteger));
+
+ // unget does nothing
+ this.bundleContext.ungetService(refsString[0]);
+ this.bundleContext.ungetService(refsString[1]);
+ this.bundleContext.ungetService(refInteger);
+ }
+
+ private Dictionary getServiceProperties(final Long serviceRanking) {
+ Dictionary<String, Object> props = new Hashtable<String, Object>();
+ if (serviceRanking != null) {
+ props.put(Constants.SERVICE_RANKING, serviceRanking);
+ }
+ return props;
+ }
+
+ @Test
+ public void testGetBundles() throws Exception {
+ assertEquals(0, this.bundleContext.getBundles().length);
+ }
+
+ @Test
+ public void testServiceListener() throws Exception {
+ ServiceListener serviceListener = mock(ServiceListener.class);
+ bundleContext.addServiceListener(serviceListener);
+
+ // prepare test services
+ String clazz1 = String.class.getName();
+ Object service1 = new Object();
+ this.bundleContext.registerService(clazz1, service1, null);
+
+ verify(serviceListener).serviceChanged(any(ServiceEvent.class));
+
+ bundleContext.removeServiceListener(serviceListener);
+ }
+
+ @Test
+ public void testBundleListener() throws Exception {
+ BundleListener bundleListener = mock(BundleListener.class);
+ BundleEvent bundleEvent = mock(BundleEvent.class);
+
+ bundleContext.addBundleListener(bundleListener);
+
+ MockOsgi.sendBundleEvent(bundleContext, bundleEvent);
+ verify(bundleListener).bundleChanged(bundleEvent);
+
+ bundleContext.removeBundleListener(bundleListener);
+ }
+
+ @Test
+ public void testFrameworkListener() throws Exception {
+ // ensure that listeners can be called (although they are not expected
+ // to to anything)
+ this.bundleContext.addFrameworkListener(null);
+ this.bundleContext.removeFrameworkListener(null);
+ }
+
+}
Propchange: sling/trunk/testing/osgi-mock/src/test/java/org/apache/sling/testing/mock/osgi/MockBundleContextTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: sling/trunk/testing/osgi-mock/src/test/java/org/apache/sling/testing/mock/osgi/MockBundleContextTest.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/osgi-mock/src/test/java/org/apache/sling/testing/mock/osgi/MockBundleContextTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: sling/trunk/testing/osgi-mock/src/test/java/org/apache/sling/testing/mock/osgi/MockBundleTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/testing/osgi-mock/src/test/java/org/apache/sling/testing/mock/osgi/MockBundleTest.java?rev=1631356&view=auto
==============================================================================
--- sling/trunk/testing/osgi-mock/src/test/java/org/apache/sling/testing/mock/osgi/MockBundleTest.java (added)
+++ sling/trunk/testing/osgi-mock/src/test/java/org/apache/sling/testing/mock/osgi/MockBundleTest.java Mon Oct 13 11:54:39 2014
@@ -0,0 +1,60 @@
+/*
+ * 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.osgi;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.osgi.framework.Bundle;
+
+public class MockBundleTest {
+
+ private Bundle bundle;
+
+ @Before
+ public void setUp() {
+ this.bundle = MockOsgi.newBundleContext().getBundle();
+ }
+
+ @Test
+ public void testBundleId() {
+ assertTrue(this.bundle.getBundleId() > 0);
+ }
+
+ @Test
+ public void testBundleContxt() {
+ assertNotNull(this.bundle.getBundleContext());
+ }
+
+ @Test
+ public void testGetEntry() {
+ assertNotNull(this.bundle.getEntry("/META-INF/test.txt"));
+ assertNull(this.bundle.getEntry("/invalid"));
+ }
+
+ @Test
+ public void testGetStatie() {
+ assertEquals(Bundle.ACTIVE, bundle.getState());
+ }
+
+}
Propchange: sling/trunk/testing/osgi-mock/src/test/java/org/apache/sling/testing/mock/osgi/MockBundleTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: sling/trunk/testing/osgi-mock/src/test/java/org/apache/sling/testing/mock/osgi/MockBundleTest.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/osgi-mock/src/test/java/org/apache/sling/testing/mock/osgi/MockBundleTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: sling/trunk/testing/osgi-mock/src/test/java/org/apache/sling/testing/mock/osgi/MockComponentContextTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/testing/osgi-mock/src/test/java/org/apache/sling/testing/mock/osgi/MockComponentContextTest.java?rev=1631356&view=auto
==============================================================================
--- sling/trunk/testing/osgi-mock/src/test/java/org/apache/sling/testing/mock/osgi/MockComponentContextTest.java (added)
+++ sling/trunk/testing/osgi-mock/src/test/java/org/apache/sling/testing/mock/osgi/MockComponentContextTest.java Mon Oct 13 11:54:39 2014
@@ -0,0 +1,84 @@
+/*
+ * 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.osgi;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertSame;
+
+import java.util.Dictionary;
+import java.util.Hashtable;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.component.ComponentContext;
+
+public class MockComponentContextTest {
+
+ private ComponentContext underTest;
+
+ @Before
+ public void setUp() {
+ underTest = MockOsgi.newComponentContext();
+ }
+
+ @Test
+ public void testBundleContext() {
+ assertNotNull(underTest.getBundleContext());
+ }
+
+ @Test
+ public void testInitialProperties() {
+ assertEquals(0, underTest.getProperties().size());
+ }
+
+ @Test
+ public void testProvidedProperties() {
+ Dictionary<String, Object> props = new Hashtable<String, Object>();
+ props.put("prop1", "value1");
+ props.put("prop2", 25);
+ ComponentContext componentContextWithProperties = MockOsgi.newComponentContext(props);
+
+ Dictionary contextProps = componentContextWithProperties.getProperties();
+ assertEquals(2, contextProps.size());
+ assertEquals("value1", contextProps.get("prop1"));
+ assertEquals(25, contextProps.get("prop2"));
+ }
+
+ @Test
+ public void testLocateService() {
+ // prepare test service
+ String clazz = String.class.getName();
+ Object service = new Object();
+ underTest.getBundleContext().registerService(clazz, service, null);
+ ServiceReference ref = underTest.getBundleContext().getServiceReference(clazz);
+
+ // test locate service
+ Object locatedService = underTest.locateService(null, ref);
+ assertSame(service, locatedService);
+ }
+
+ @Test
+ public void testIgnoredMethods() {
+ underTest.enableComponent("myComponent");
+ underTest.disableComponent("myComponent");
+ }
+
+}
Propchange: sling/trunk/testing/osgi-mock/src/test/java/org/apache/sling/testing/mock/osgi/MockComponentContextTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: sling/trunk/testing/osgi-mock/src/test/java/org/apache/sling/testing/mock/osgi/MockComponentContextTest.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/osgi-mock/src/test/java/org/apache/sling/testing/mock/osgi/MockComponentContextTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: sling/trunk/testing/osgi-mock/src/test/java/org/apache/sling/testing/mock/osgi/MockFilterTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/testing/osgi-mock/src/test/java/org/apache/sling/testing/mock/osgi/MockFilterTest.java?rev=1631356&view=auto
==============================================================================
--- sling/trunk/testing/osgi-mock/src/test/java/org/apache/sling/testing/mock/osgi/MockFilterTest.java (added)
+++ sling/trunk/testing/osgi-mock/src/test/java/org/apache/sling/testing/mock/osgi/MockFilterTest.java Mon Oct 13 11:54:39 2014
@@ -0,0 +1,46 @@
+/*
+ * 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.osgi;
+
+import static org.junit.Assert.assertFalse;
+
+import java.util.Hashtable;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.osgi.framework.Filter;
+import org.osgi.framework.ServiceReference;
+
+public class MockFilterTest {
+
+ private Filter filter;
+
+ @Before
+ public void setUp() {
+ this.filter = new MockFilter();
+ }
+
+ @Test
+ public void testDenyAll() {
+ assertFalse(this.filter.match((ServiceReference) null));
+ assertFalse(this.filter.match((Hashtable) null));
+ assertFalse(this.filter.matchCase(null));
+ }
+
+}
Propchange: sling/trunk/testing/osgi-mock/src/test/java/org/apache/sling/testing/mock/osgi/MockFilterTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: sling/trunk/testing/osgi-mock/src/test/java/org/apache/sling/testing/mock/osgi/MockFilterTest.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/osgi-mock/src/test/java/org/apache/sling/testing/mock/osgi/MockFilterTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: sling/trunk/testing/osgi-mock/src/test/java/org/apache/sling/testing/mock/osgi/MockLogServiceTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/testing/osgi-mock/src/test/java/org/apache/sling/testing/mock/osgi/MockLogServiceTest.java?rev=1631356&view=auto
==============================================================================
--- sling/trunk/testing/osgi-mock/src/test/java/org/apache/sling/testing/mock/osgi/MockLogServiceTest.java (added)
+++ sling/trunk/testing/osgi-mock/src/test/java/org/apache/sling/testing/mock/osgi/MockLogServiceTest.java Mon Oct 13 11:54:39 2014
@@ -0,0 +1,70 @@
+/*
+ * 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.osgi;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.osgi.service.log.LogService;
+
+public class MockLogServiceTest {
+
+ private LogService logService;
+
+ @Before
+ public void setUp() throws Exception {
+ this.logService = new MockLogService(getClass());
+ }
+
+ @Test
+ public void testLog() {
+ this.logService.log(LogService.LOG_ERROR, "message 1");
+ this.logService.log(LogService.LOG_WARNING, "message 1");
+ this.logService.log(LogService.LOG_INFO, "message 1");
+ this.logService.log(LogService.LOG_DEBUG, "message 1");
+
+ this.logService.log(null, LogService.LOG_ERROR, "message 1");
+ this.logService.log(null, LogService.LOG_WARNING, "message 1");
+ this.logService.log(null, LogService.LOG_INFO, "message 1");
+ this.logService.log(null, LogService.LOG_DEBUG, "message 1");
+ }
+
+ @Test
+ public void testLogException() {
+ this.logService.log(LogService.LOG_ERROR, "message 2", new Exception());
+ this.logService.log(LogService.LOG_WARNING, "message 2", new Exception());
+ this.logService.log(LogService.LOG_INFO, "message 2", new Exception());
+ this.logService.log(LogService.LOG_DEBUG, "message 2", new Exception());
+
+ this.logService.log(null, LogService.LOG_ERROR, "message 2", new Exception());
+ this.logService.log(null, LogService.LOG_WARNING, "message 2", new Exception());
+ this.logService.log(null, LogService.LOG_INFO, "message 2", new Exception());
+ this.logService.log(null, LogService.LOG_DEBUG, "message 2", new Exception());
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testLogInvalidLevel() {
+ this.logService.log(0, "message 1");
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testLogExceptionInvalidLevel() {
+ this.logService.log(0, "message 2", new Exception());
+ }
+
+}
Propchange: sling/trunk/testing/osgi-mock/src/test/java/org/apache/sling/testing/mock/osgi/MockLogServiceTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: sling/trunk/testing/osgi-mock/src/test/java/org/apache/sling/testing/mock/osgi/MockLogServiceTest.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/osgi-mock/src/test/java/org/apache/sling/testing/mock/osgi/MockLogServiceTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: sling/trunk/testing/osgi-mock/src/test/java/org/apache/sling/testing/mock/osgi/MockServiceReferenceTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/testing/osgi-mock/src/test/java/org/apache/sling/testing/mock/osgi/MockServiceReferenceTest.java?rev=1631356&view=auto
==============================================================================
--- sling/trunk/testing/osgi-mock/src/test/java/org/apache/sling/testing/mock/osgi/MockServiceReferenceTest.java (added)
+++ sling/trunk/testing/osgi-mock/src/test/java/org/apache/sling/testing/mock/osgi/MockServiceReferenceTest.java Mon Oct 13 11:54:39 2014
@@ -0,0 +1,81 @@
+/*
+ * 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.osgi;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertSame;
+
+import java.util.Dictionary;
+import java.util.Hashtable;
+
+import org.apache.sling.testing.mock.osgi.OsgiMetadataUtilTest.ServiceWithMetadata;
+import org.junit.Before;
+import org.junit.Test;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.framework.ServiceReference;
+
+public class MockServiceReferenceTest {
+
+ private BundleContext bundleContext;
+ private ServiceReference serviceReference;
+ private Object service;
+
+ @Before
+ public void setUp() {
+ this.bundleContext = MockOsgi.newBundleContext();
+
+ this.service = new Object();
+ String clazz = String.class.getName();
+ Dictionary<String, Object> props = new Hashtable<String, Object>();
+ props.put("customProp1", "value1");
+
+ this.bundleContext.registerService(clazz, this.service, props);
+ this.serviceReference = this.bundleContext.getServiceReference(clazz);
+ }
+
+ @Test
+ public void testBundle() {
+ assertSame(this.bundleContext.getBundle(), this.serviceReference.getBundle());
+ }
+
+ @Test
+ public void testServiceId() {
+ assertNotNull(this.serviceReference.getProperty(Constants.SERVICE_ID));
+ }
+
+ @Test
+ public void testProperties() {
+ assertEquals(2, this.serviceReference.getPropertyKeys().length);
+ assertEquals("value1", this.serviceReference.getProperty("customProp1"));
+ }
+
+ @Test
+ public void testWithOsgiMetadata() {
+ ServiceWithMetadata serviceWithMetadata = new OsgiMetadataUtilTest.ServiceWithMetadata();
+ bundleContext.registerService((String) null, serviceWithMetadata, null);
+ ServiceReference reference = this.bundleContext.getServiceReference(Comparable.class.getName());
+
+ assertEquals(5000, reference.getProperty("service.ranking"));
+ assertEquals("The Apache Software Foundation", reference.getProperty("service.vendor"));
+ assertEquals("org.apache.sling.models.impl.injectors.OSGiServiceInjector", reference.getProperty("service.pid"));
+ }
+
+}
Propchange: sling/trunk/testing/osgi-mock/src/test/java/org/apache/sling/testing/mock/osgi/MockServiceReferenceTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: sling/trunk/testing/osgi-mock/src/test/java/org/apache/sling/testing/mock/osgi/MockServiceReferenceTest.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/osgi-mock/src/test/java/org/apache/sling/testing/mock/osgi/MockServiceReferenceTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: sling/trunk/testing/osgi-mock/src/test/java/org/apache/sling/testing/mock/osgi/OsgiMetadataUtilTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/testing/osgi-mock/src/test/java/org/apache/sling/testing/mock/osgi/OsgiMetadataUtilTest.java?rev=1631356&view=auto
==============================================================================
--- sling/trunk/testing/osgi-mock/src/test/java/org/apache/sling/testing/mock/osgi/OsgiMetadataUtilTest.java (added)
+++ sling/trunk/testing/osgi-mock/src/test/java/org/apache/sling/testing/mock/osgi/OsgiMetadataUtilTest.java Mon Oct 13 11:54:39 2014
@@ -0,0 +1,93 @@
+/*
+ * 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.osgi;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.felix.scr.annotations.ReferenceCardinality;
+import org.apache.sling.testing.mock.osgi.OsgiMetadataUtil.Reference;
+import org.junit.Test;
+import org.w3c.dom.Document;
+
+public class OsgiMetadataUtilTest {
+
+ @Test
+ public void testMetadata() {
+ Document doc = OsgiMetadataUtil.getMetadata(ServiceWithMetadata.class);
+
+ Set<String> serviceInterfaces = OsgiMetadataUtil.getServiceInterfaces(ServiceWithMetadata.class, doc);
+ assertEquals(3, serviceInterfaces.size());
+ assertTrue(serviceInterfaces.contains("org.apache.sling.models.spi.Injector"));
+ assertTrue(serviceInterfaces
+ .contains("org.apache.sling.models.spi.injectorspecific.InjectAnnotationProcessorFactory"));
+ assertTrue(serviceInterfaces.contains("java.lang.Comparable"));
+
+ Map<String, Object> props = OsgiMetadataUtil.getProperties(ServiceWithMetadata.class, doc);
+ assertEquals(3, props.size());
+ assertEquals(5000, props.get("service.ranking"));
+ assertEquals("The Apache Software Foundation", props.get("service.vendor"));
+ assertEquals("org.apache.sling.models.impl.injectors.OSGiServiceInjector", props.get("service.pid"));
+ }
+
+ @Test
+ public void testNoMetadata() {
+ Document doc = OsgiMetadataUtil.getMetadata(ServiceWithoutMetadata.class);
+
+ Set<String> serviceInterfaces = OsgiMetadataUtil.getServiceInterfaces(ServiceWithoutMetadata.class, doc);
+ assertEquals(0, serviceInterfaces.size());
+
+ Map<String, Object> props = OsgiMetadataUtil.getProperties(ServiceWithoutMetadata.class, doc);
+ assertEquals(0, props.size());
+ }
+
+ @Test
+ public void testReferences() {
+ Document doc = OsgiMetadataUtil.getMetadata(ReflectionServiceUtilTest.Service3.class);
+ List<Reference> references = OsgiMetadataUtil.getReferences(ReflectionServiceUtilTest.Service3.class, doc);
+ assertEquals(3, references.size());
+
+ Reference ref1 = references.get(0);
+ assertEquals("reference2", ref1.getName());
+ assertEquals("org.apache.sling.testing.mock.osgi.ReflectionServiceUtilTest$ServiceInterface2", ref1.getInterfaceType());
+ assertEquals(ReferenceCardinality.MANDATORY_MULTIPLE, ref1.getCardinality());
+ assertEquals("bindReference2", ref1.getBind());
+ assertEquals("unbindReference2", ref1.getUnbind());
+ }
+
+ @Test
+ public void testActivateMethodName() {
+ Document doc = OsgiMetadataUtil.getMetadata(ReflectionServiceUtilTest.Service3.class);
+ String methodName = OsgiMetadataUtil.getActivateMethodName(ReflectionServiceUtilTest.Service3.class, doc);
+ assertEquals("activate", methodName);
+ }
+
+ static class ServiceWithMetadata {
+ // empty class
+ }
+
+ static class ServiceWithoutMetadata {
+ // empty class
+ }
+
+}
Propchange: sling/trunk/testing/osgi-mock/src/test/java/org/apache/sling/testing/mock/osgi/OsgiMetadataUtilTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: sling/trunk/testing/osgi-mock/src/test/java/org/apache/sling/testing/mock/osgi/OsgiMetadataUtilTest.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/osgi-mock/src/test/java/org/apache/sling/testing/mock/osgi/OsgiMetadataUtilTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: sling/trunk/testing/osgi-mock/src/test/java/org/apache/sling/testing/mock/osgi/ReflectionServiceUtilTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/testing/osgi-mock/src/test/java/org/apache/sling/testing/mock/osgi/ReflectionServiceUtilTest.java?rev=1631356&view=auto
==============================================================================
--- sling/trunk/testing/osgi-mock/src/test/java/org/apache/sling/testing/mock/osgi/ReflectionServiceUtilTest.java (added)
+++ sling/trunk/testing/osgi-mock/src/test/java/org/apache/sling/testing/mock/osgi/ReflectionServiceUtilTest.java Mon Oct 13 11:54:39 2014
@@ -0,0 +1,226 @@
+/*
+ * 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.osgi;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+
+import java.util.ArrayList;
+import java.util.Dictionary;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.felix.scr.annotations.Activate;
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Deactivate;
+import org.apache.felix.scr.annotations.Property;
+import org.apache.felix.scr.annotations.Reference;
+import org.apache.felix.scr.annotations.ReferenceCardinality;
+import org.apache.felix.scr.annotations.References;
+import org.apache.felix.scr.annotations.Service;
+import org.junit.Before;
+import org.junit.Test;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.component.ComponentContext;
+
+public class ReflectionServiceUtilTest {
+
+ private BundleContext bundleContext = MockOsgi.newBundleContext();
+ private Service1 service1;
+ private Service2 service2;
+
+ @Before
+ public void setUp() {
+ service1 = new Service1();
+ service2 = new Service2();
+ bundleContext.registerService(ServiceInterface1.class.getName(), service1, null);
+ bundleContext.registerService(ServiceInterface2.class.getName(), service2, null);
+ }
+
+ @Test
+ public void testService3() {
+ Service3 service3 = new Service3();
+ assertTrue(MockOsgi.injectServices(service3, bundleContext));
+
+ Dictionary<String, Object> service3Config = new Hashtable<String, Object>();
+ service3Config.put("prop1", "value1");
+ assertTrue(MockOsgi.activate(service3, bundleContext, service3Config));
+
+ assertNotNull(service3.getComponentContext());
+ assertEquals(service3Config, service3.getComponentContext().getProperties());
+
+ assertSame(service1, service3.getReference1());
+
+ List<ServiceInterface2> references2 = service3.getReferences2();
+ assertEquals(1, references2.size());
+ assertSame(service2, references2.get(0));
+
+ List<ServiceInterface3> references3 = service3.getReferences3();
+ assertEquals(1, references3.size());
+ assertSame(service2, references3.get(0));
+
+ List<Map<String, Object>> reference3Configs = service3.getReference3Configs();
+ assertEquals(1, reference3Configs.size());
+ assertEquals(200, reference3Configs.get(0).get(Constants.SERVICE_RANKING));
+
+ assertTrue(MockOsgi.deactivate(service3));
+ assertNull(service3.getComponentContext());
+ }
+
+ @Test
+ public void testService4() {
+ Service4 service4 = new Service4();
+
+ assertTrue(MockOsgi.injectServices(service4, bundleContext));
+ assertFalse(MockOsgi.activate(service4));
+
+ assertSame(service1, service4.getReference1());
+ }
+
+ public interface ServiceInterface1 {
+ // no methods
+ }
+
+ public interface ServiceInterface2 {
+ // no methods
+ }
+
+ public interface ServiceInterface3 {
+ // no methods
+ }
+
+ @Component
+ @Service(ServiceInterface1.class)
+ @Property(name = Constants.SERVICE_RANKING, intValue = 100)
+ public static class Service1 implements ServiceInterface1 {
+ // dummy interface
+ }
+
+ @Component
+ @Service({ ServiceInterface2.class, ServiceInterface3.class })
+ @Property(name = Constants.SERVICE_RANKING, intValue = 200)
+ public static class Service2 implements ServiceInterface2, ServiceInterface3 {
+ // dummy interface
+ }
+
+ @Component
+ @References({ @Reference(name = "reference2", referenceInterface = ServiceInterface2.class, cardinality = ReferenceCardinality.MANDATORY_MULTIPLE) })
+ public static class Service3 {
+
+ @Reference
+ private ServiceInterface1 reference1;
+
+ private List<ServiceReference> references2 = new ArrayList<ServiceReference>();
+
+ @Reference(name = "reference3", referenceInterface = ServiceInterface3.class, cardinality = ReferenceCardinality.OPTIONAL_MULTIPLE)
+ private List<ServiceInterface3> references3 = new ArrayList<ServiceInterface3>();
+ private List<Map<String, Object>> reference3Configs = new ArrayList<Map<String, Object>>();
+
+ private ComponentContext componentContext;
+
+ @Activate
+ private void activate(ComponentContext ctx) {
+ this.componentContext = ctx;
+ }
+
+ @Deactivate
+ private void deactivate(ComponentContext ctx) {
+ this.componentContext = null;
+ }
+
+ public ServiceInterface1 getReference1() {
+ return this.reference1;
+ }
+
+ public List<ServiceInterface2> getReferences2() {
+ List<ServiceInterface2> services = new ArrayList<ServiceInterface2>();
+ for (ServiceReference serviceReference : references2) {
+ services.add((ServiceInterface2)componentContext.getBundleContext().getService(serviceReference));
+ }
+ return services;
+ }
+
+ public List<ServiceInterface3> getReferences3() {
+ return this.references3;
+ }
+
+ public List<Map<String, Object>> getReference3Configs() {
+ return this.reference3Configs;
+ }
+
+ public ComponentContext getComponentContext() {
+ return this.componentContext;
+ }
+
+ protected void bindReference1(ServiceInterface1 service) {
+ reference1 = service;
+ }
+
+ protected void unbindReference1(ServiceInterface1 service) {
+ reference1 = null;
+ }
+
+ protected void bindReference2(ServiceReference serviceReference) {
+ references2.add(serviceReference);
+ }
+
+ protected void unbindReference2(ServiceReference serviceReference) {
+ references2.remove(serviceReference);
+ }
+
+ protected void bindReference3(ServiceInterface3 service, Map<String, Object> serviceConfig) {
+ references3.add(service);
+ reference3Configs.add(serviceConfig);
+ }
+
+ protected void unbindReference3(ServiceInterface3 service, Map<String, Object> serviceConfig) {
+ references3.remove(service);
+ reference3Configs.remove(serviceConfig);
+ }
+
+ }
+
+ @Component
+ @Reference(referenceInterface = ServiceInterface1.class, name = "customName", bind = "customBind", unbind = "customUnbind")
+ public static class Service4 {
+
+ private ServiceInterface1 reference1;
+
+ public ServiceInterface1 getReference1() {
+ return this.reference1;
+ }
+
+ protected void customBind(ServiceInterface1 service) {
+ reference1 = service;
+ }
+
+ protected void customUnbind(ServiceInterface1 service) {
+ reference1 = null;
+ }
+
+ }
+
+}
Propchange: sling/trunk/testing/osgi-mock/src/test/java/org/apache/sling/testing/mock/osgi/ReflectionServiceUtilTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: sling/trunk/testing/osgi-mock/src/test/java/org/apache/sling/testing/mock/osgi/ReflectionServiceUtilTest.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/osgi-mock/src/test/java/org/apache/sling/testing/mock/osgi/ReflectionServiceUtilTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: sling/trunk/testing/osgi-mock/src/test/java/org/apache/sling/testing/mock/osgi/package-info.java
URL: http://svn.apache.org/viewvc/sling/trunk/testing/osgi-mock/src/test/java/org/apache/sling/testing/mock/osgi/package-info.java?rev=1631356&view=auto
==============================================================================
--- sling/trunk/testing/osgi-mock/src/test/java/org/apache/sling/testing/mock/osgi/package-info.java (added)
+++ sling/trunk/testing/osgi-mock/src/test/java/org/apache/sling/testing/mock/osgi/package-info.java Mon Oct 13 11:54:39 2014
@@ -0,0 +1,23 @@
+/*
+ * 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.
+ */
+/**
+ * Mock implementation of selected OSGi APIs.
+ */
+package org.apache.sling.testing.mock.osgi;
+
Propchange: sling/trunk/testing/osgi-mock/src/test/java/org/apache/sling/testing/mock/osgi/package-info.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: sling/trunk/testing/osgi-mock/src/test/java/org/apache/sling/testing/mock/osgi/package-info.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/osgi-mock/src/test/java/org/apache/sling/testing/mock/osgi/package-info.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: sling/trunk/testing/osgi-mock/src/test/resources/META-INF/test.txt
URL: http://svn.apache.org/viewvc/sling/trunk/testing/osgi-mock/src/test/resources/META-INF/test.txt?rev=1631356&view=auto
==============================================================================
--- sling/trunk/testing/osgi-mock/src/test/resources/META-INF/test.txt (added)
+++ sling/trunk/testing/osgi-mock/src/test/resources/META-INF/test.txt Mon Oct 13 11:54:39 2014
@@ -0,0 +1 @@
+This is a test file.
\ No newline at end of file
Propchange: sling/trunk/testing/osgi-mock/src/test/resources/META-INF/test.txt
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: sling/trunk/testing/osgi-mock/src/test/resources/META-INF/test.txt
------------------------------------------------------------------------------
--- 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/osgi-mock/src/test/resources/META-INF/test.txt
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: sling/trunk/testing/osgi-mock/src/test/resources/OSGI-INF/org.apache.sling.testing.mock.osgi.OsgiMetadataUtilTest.xml
URL: http://svn.apache.org/viewvc/sling/trunk/testing/osgi-mock/src/test/resources/OSGI-INF/org.apache.sling.testing.mock.osgi.OsgiMetadataUtilTest.xml?rev=1631356&view=auto
==============================================================================
--- sling/trunk/testing/osgi-mock/src/test/resources/OSGI-INF/org.apache.sling.testing.mock.osgi.OsgiMetadataUtilTest.xml (added)
+++ sling/trunk/testing/osgi-mock/src/test/resources/OSGI-INF/org.apache.sling.testing.mock.osgi.OsgiMetadataUtilTest.xml Mon Oct 13 11:54:39 2014
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<components xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0">
+ <scr:component name="org.apache.sling.testing.mock.osgi.OsgiMetadataUtilTest$ServiceWithMetadata" activate="activate">
+ <implementation class="org.apache.sling.testing.mock.osgi.OsgiMetadataUtilTest$ServiceWithMetadata"/>
+ <service servicefactory="false">
+ <provide interface="org.apache.sling.models.spi.Injector"/>
+ <provide interface="org.apache.sling.models.spi.injectorspecific.InjectAnnotationProcessorFactory"/>
+ <provide interface="java.lang.Comparable"/>
+ </service>
+ <property name="service.ranking" type="Integer" value="5000"/>
+ <property name="service.vendor" value="The Apache Software Foundation"/>
+ <property name="service.pid" value="org.apache.sling.models.impl.injectors.OSGiServiceInjector"/>
+ </scr:component>
+</components>
Propchange: sling/trunk/testing/osgi-mock/src/test/resources/OSGI-INF/org.apache.sling.testing.mock.osgi.OsgiMetadataUtilTest.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: sling/trunk/testing/osgi-mock/src/test/resources/OSGI-INF/org.apache.sling.testing.mock.osgi.OsgiMetadataUtilTest.xml
------------------------------------------------------------------------------
--- 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/osgi-mock/src/test/resources/OSGI-INF/org.apache.sling.testing.mock.osgi.OsgiMetadataUtilTest.xml
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: sling/trunk/testing/osgi-mock/src/test/resources/OSGI-INF/org.apache.sling.testing.mock.osgi.ReflectionServiceUtilTest.xml
URL: http://svn.apache.org/viewvc/sling/trunk/testing/osgi-mock/src/test/resources/OSGI-INF/org.apache.sling.testing.mock.osgi.ReflectionServiceUtilTest.xml?rev=1631356&view=auto
==============================================================================
--- sling/trunk/testing/osgi-mock/src/test/resources/OSGI-INF/org.apache.sling.testing.mock.osgi.ReflectionServiceUtilTest.xml (added)
+++ sling/trunk/testing/osgi-mock/src/test/resources/OSGI-INF/org.apache.sling.testing.mock.osgi.ReflectionServiceUtilTest.xml Mon Oct 13 11:54:39 2014
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<components xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0">
+ <scr:component name="org.apache.sling.testing.mock.osgi.ReflectionServiceUtilTest$Service1">
+ <implementation class="org.apache.sling.testing.mock.osgi.ReflectionServiceUtilTest$Service1"/>
+ <service servicefactory="false">
+ <provide interface="org.apache.sling.testing.mock.osgi.ReflectionServiceUtilTest$ServiceInterface1"/>
+ </service>
+ <property name="service.ranking" type="Integer" value="100"/>
+ <property name="service.pid" value="org.apache.sling.testing.mock.osgi.ReflectionServiceUtilTest$Service1"/>
+ </scr:component>
+ <scr:component name="org.apache.sling.testing.mock.osgi.ReflectionServiceUtilTest$Service2">
+ <implementation class="org.apache.sling.testing.mock.osgi.ReflectionServiceUtilTest$Service2"/>
+ <service servicefactory="false">
+ <provide interface="org.apache.sling.testing.mock.osgi.ReflectionServiceUtilTest$ServiceInterface2"/>
+ <provide interface="org.apache.sling.testing.mock.osgi.ReflectionServiceUtilTest$ServiceInterface3"/>
+ </service>
+ <property name="service.ranking" type="Integer" value="200"/>
+ <property name="service.pid" value="org.apache.sling.testing.mock.osgi.ReflectionServiceUtilTest$Service2"/>
+ </scr:component>
+ <scr:component name="org.apache.sling.testing.mock.osgi.ReflectionServiceUtilTest$Service3" activate="activate" deactivate="deactivate">
+ <implementation class="org.apache.sling.testing.mock.osgi.ReflectionServiceUtilTest$Service3"/>
+ <property name="service.pid" value="org.apache.sling.testing.mock.osgi.ReflectionServiceUtilTest$Service3"/>
+ <reference name="reference2" interface="org.apache.sling.testing.mock.osgi.ReflectionServiceUtilTest$ServiceInterface2" cardinality="1..n" policy="static" bind="bindReference2" unbind="unbindReference2"/>
+ <reference name="reference1" interface="org.apache.sling.testing.mock.osgi.ReflectionServiceUtilTest$ServiceInterface1" cardinality="1..1" policy="static" bind="bindReference1" unbind="unbindReference1"/>
+ <reference name="reference3" interface="org.apache.sling.testing.mock.osgi.ReflectionServiceUtilTest$ServiceInterface3" cardinality="0..n" policy="static" bind="bindReference3" unbind="unbindReference3"/>
+ </scr:component>
+ <scr:component name="org.apache.sling.testing.mock.osgi.ReflectionServiceUtilTest$Service4">
+ <implementation class="org.apache.sling.testing.mock.osgi.ReflectionServiceUtilTest$Service4"/>
+ <property name="service.pid" value="org.apache.sling.testing.mock.osgi.ReflectionServiceUtilTest$Service4"/>
+ <reference name="customName" interface="org.apache.sling.testing.mock.osgi.ReflectionServiceUtilTest$ServiceInterface1" cardinality="1..1" policy="static" bind="customBind" unbind="customUnbind"/>
+ </scr:component>
+</components>
Propchange: sling/trunk/testing/osgi-mock/src/test/resources/OSGI-INF/org.apache.sling.testing.mock.osgi.ReflectionServiceUtilTest.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: sling/trunk/testing/osgi-mock/src/test/resources/OSGI-INF/org.apache.sling.testing.mock.osgi.ReflectionServiceUtilTest.xml
------------------------------------------------------------------------------
--- 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/osgi-mock/src/test/resources/OSGI-INF/org.apache.sling.testing.mock.osgi.ReflectionServiceUtilTest.xml
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: sling/trunk/testing/osgi-mock/src/test/resources/simplelogger.properties
URL: http://svn.apache.org/viewvc/sling/trunk/testing/osgi-mock/src/test/resources/simplelogger.properties?rev=1631356&view=auto
==============================================================================
--- sling/trunk/testing/osgi-mock/src/test/resources/simplelogger.properties (added)
+++ sling/trunk/testing/osgi-mock/src/test/resources/simplelogger.properties Mon Oct 13 11:54:39 2014
@@ -0,0 +1,18 @@
+# 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.
+
+org.slf4j.simpleLogger.defaultLogLevel=error
Propchange: sling/trunk/testing/osgi-mock/src/test/resources/simplelogger.properties
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: sling/trunk/testing/osgi-mock/src/test/resources/simplelogger.properties
------------------------------------------------------------------------------
--- 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/osgi-mock/src/test/resources/simplelogger.properties
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: sling/trunk/testing/sling-mock-jackrabbit/pom.xml
URL: http://svn.apache.org/viewvc/sling/trunk/testing/sling-mock-jackrabbit/pom.xml?rev=1631356&view=auto
==============================================================================
--- sling/trunk/testing/sling-mock-jackrabbit/pom.xml (added)
+++ sling/trunk/testing/sling-mock-jackrabbit/pom.xml Mon Oct 13 11:54:39 2014
@@ -0,0 +1,95 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+ 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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>sling</artifactId>
+ <version>22</version>
+ <relativePath>../../../parent/pom.xml</relativePath>
+ </parent>
+
+ <artifactId>org.apache.sling.testing.sling-mock-jackrabbit</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <packaging>jar</packaging>
+
+ <name>Apache Sling Testing Sling Mock Jackrabbit-based Resource Resolver</name>
+ <description>Implements a resource resolver type for Jackrabbit that can be used in unit tests based on Sling Mocks.</description>
+
+ <properties>
+ <sling.java.version>6</sling.java.version>
+ </properties>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.testing.sling-mock</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.testing.sling-mock</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <classifier>tests</classifier>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.commons.testing</artifactId>
+ <version>2.0.16</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-simple</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.jmock</groupId>
+ <artifactId>jmock-junit4</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.jcr</groupId>
+ <artifactId>jcr</artifactId>
+ <version>2.0</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-all</artifactId>
+ <version>1.9.5</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+</project>
Propchange: sling/trunk/testing/sling-mock-jackrabbit/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: sling/trunk/testing/sling-mock-jackrabbit/pom.xml
------------------------------------------------------------------------------
--- 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-jackrabbit/pom.xml
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: sling/trunk/testing/sling-mock-jackrabbit/src/main/java/org/apache/sling/testing/mock/sling/jackrabbit/JackrabbitMockResourceResolverAdapter.java
URL: http://svn.apache.org/viewvc/sling/trunk/testing/sling-mock-jackrabbit/src/main/java/org/apache/sling/testing/mock/sling/jackrabbit/JackrabbitMockResourceResolverAdapter.java?rev=1631356&view=auto
==============================================================================
--- sling/trunk/testing/sling-mock-jackrabbit/src/main/java/org/apache/sling/testing/mock/sling/jackrabbit/JackrabbitMockResourceResolverAdapter.java (added)
+++ sling/trunk/testing/sling-mock-jackrabbit/src/main/java/org/apache/sling/testing/mock/sling/jackrabbit/JackrabbitMockResourceResolverAdapter.java Mon Oct 13 11:54:39 2014
@@ -0,0 +1,47 @@
+/*
+ * 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.jackrabbit;
+
+import javax.jcr.RepositoryException;
+
+import org.apache.sling.api.resource.ResourceResolverFactory;
+import org.apache.sling.commons.testing.jcr.RepositoryProvider;
+import org.apache.sling.jcr.api.SlingRepository;
+import org.apache.sling.testing.mock.sling.spi.ResourceResolverTypeAdapter;
+
+/**
+ * Resource resolver type adapter for Jackrabbit repository.
+ */
+public class JackrabbitMockResourceResolverAdapter implements ResourceResolverTypeAdapter {
+
+ @Override
+ public ResourceResolverFactory newResourceResolverFactory() {
+ return null;
+ }
+
+ @Override
+ public SlingRepository newSlingRepository() {
+ try {
+ return RepositoryProvider.instance().getRepository();
+ } catch (RepositoryException ex) {
+ throw new RuntimeException("Unable to get jackrabbit SlingRepository instance.", ex);
+ }
+ }
+
+}
Propchange: sling/trunk/testing/sling-mock-jackrabbit/src/main/java/org/apache/sling/testing/mock/sling/jackrabbit/JackrabbitMockResourceResolverAdapter.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: sling/trunk/testing/sling-mock-jackrabbit/src/main/java/org/apache/sling/testing/mock/sling/jackrabbit/JackrabbitMockResourceResolverAdapter.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-jackrabbit/src/main/java/org/apache/sling/testing/mock/sling/jackrabbit/JackrabbitMockResourceResolverAdapter.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: sling/trunk/testing/sling-mock-jackrabbit/src/test/java/org/apache/sling/testing/mock/sling/jackrabbit/contentimport/ContentLoaderBinaryTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/testing/sling-mock-jackrabbit/src/test/java/org/apache/sling/testing/mock/sling/jackrabbit/contentimport/ContentLoaderBinaryTest.java?rev=1631356&view=auto
==============================================================================
--- sling/trunk/testing/sling-mock-jackrabbit/src/test/java/org/apache/sling/testing/mock/sling/jackrabbit/contentimport/ContentLoaderBinaryTest.java (added)
+++ sling/trunk/testing/sling-mock-jackrabbit/src/test/java/org/apache/sling/testing/mock/sling/jackrabbit/contentimport/ContentLoaderBinaryTest.java Mon Oct 13 11:54:39 2014
@@ -0,0 +1,55 @@
+/*
+ * 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.jackrabbit.contentimport;
+
+import java.io.IOException;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+
+import org.apache.sling.api.resource.ResourceResolver;
+import org.apache.sling.commons.testing.jcr.RepositoryUtil;
+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.JCR_JACKRABBIT;
+ }
+
+ @Override
+ protected ResourceResolver newResourceResolver() {
+ ResourceResolver resolver = MockSling.newResourceResolver(getResourceResolverType());
+
+ // register sling node types
+ try {
+ RepositoryUtil.registerSlingNodeTypes(resolver.adaptTo(Session.class));
+ } catch (IOException ex) {
+ throw new RuntimeException("Unable to register sling node types.", ex);
+ } catch (RepositoryException ex) {
+ throw new RuntimeException("Unable to register sling node types.", ex);
+ }
+
+ return resolver;
+ }
+
+}
Propchange: sling/trunk/testing/sling-mock-jackrabbit/src/test/java/org/apache/sling/testing/mock/sling/jackrabbit/contentimport/ContentLoaderBinaryTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: sling/trunk/testing/sling-mock-jackrabbit/src/test/java/org/apache/sling/testing/mock/sling/jackrabbit/contentimport/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-jackrabbit/src/test/java/org/apache/sling/testing/mock/sling/jackrabbit/contentimport/ContentLoaderBinaryTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: sling/trunk/testing/sling-mock-jackrabbit/src/test/java/org/apache/sling/testing/mock/sling/jackrabbit/contentimport/ContentLoaderJsonDamTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/testing/sling-mock-jackrabbit/src/test/java/org/apache/sling/testing/mock/sling/jackrabbit/contentimport/ContentLoaderJsonDamTest.java?rev=1631356&view=auto
==============================================================================
--- sling/trunk/testing/sling-mock-jackrabbit/src/test/java/org/apache/sling/testing/mock/sling/jackrabbit/contentimport/ContentLoaderJsonDamTest.java (added)
+++ sling/trunk/testing/sling-mock-jackrabbit/src/test/java/org/apache/sling/testing/mock/sling/jackrabbit/contentimport/ContentLoaderJsonDamTest.java Mon Oct 13 11:54:39 2014
@@ -0,0 +1,58 @@
+/*
+ * 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.jackrabbit.contentimport;
+
+import java.io.IOException;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+
+import org.apache.sling.api.resource.ResourceResolver;
+import org.apache.sling.commons.testing.jcr.RepositoryUtil;
+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;
+import org.junit.Ignore;
+
+//TEST IS DISABLED currently, it does not work with jackrabbit repository yet
+@Ignore
+public class ContentLoaderJsonDamTest extends AbstractContentLoaderJsonDamTest {
+
+ @Override
+ protected ResourceResolverType getResourceResolverType() {
+ return ResourceResolverType.JCR_JACKRABBIT;
+ }
+
+ @Override
+ protected ResourceResolver newResourceResolver() {
+ ResourceResolver resolver = MockSling.newResourceResolver(getResourceResolverType());
+
+ // register sling node types
+ try {
+ RepositoryUtil.registerSlingNodeTypes(resolver.adaptTo(Session.class));
+ } catch (IOException ex) {
+ throw new RuntimeException("Unable to register sling node types.", ex);
+ } catch (RepositoryException ex) {
+ throw new RuntimeException("Unable to register sling node types.", ex);
+ }
+
+ return resolver;
+ }
+
+}
Propchange: sling/trunk/testing/sling-mock-jackrabbit/src/test/java/org/apache/sling/testing/mock/sling/jackrabbit/contentimport/ContentLoaderJsonDamTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: sling/trunk/testing/sling-mock-jackrabbit/src/test/java/org/apache/sling/testing/mock/sling/jackrabbit/contentimport/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-jackrabbit/src/test/java/org/apache/sling/testing/mock/sling/jackrabbit/contentimport/ContentLoaderJsonDamTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: sling/trunk/testing/sling-mock-jackrabbit/src/test/java/org/apache/sling/testing/mock/sling/jackrabbit/contentimport/ContentLoaderJsonTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/testing/sling-mock-jackrabbit/src/test/java/org/apache/sling/testing/mock/sling/jackrabbit/contentimport/ContentLoaderJsonTest.java?rev=1631356&view=auto
==============================================================================
--- sling/trunk/testing/sling-mock-jackrabbit/src/test/java/org/apache/sling/testing/mock/sling/jackrabbit/contentimport/ContentLoaderJsonTest.java (added)
+++ sling/trunk/testing/sling-mock-jackrabbit/src/test/java/org/apache/sling/testing/mock/sling/jackrabbit/contentimport/ContentLoaderJsonTest.java Mon Oct 13 11:54:39 2014
@@ -0,0 +1,58 @@
+/*
+ * 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.jackrabbit.contentimport;
+
+import java.io.IOException;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+
+import org.apache.sling.api.resource.ResourceResolver;
+import org.apache.sling.commons.testing.jcr.RepositoryUtil;
+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;
+import org.junit.Ignore;
+
+// TEST IS DISABLED currently, it does not work with jackrabbit repository yet
+@Ignore
+public class ContentLoaderJsonTest extends AbstractContentLoaderJsonTest {
+
+ @Override
+ protected ResourceResolverType getResourceResolverType() {
+ return ResourceResolverType.JCR_JACKRABBIT;
+ }
+
+ @Override
+ protected ResourceResolver newResourceResolver() {
+ ResourceResolver resolver = MockSling.newResourceResolver(getResourceResolverType());
+
+ // register sling node types
+ try {
+ RepositoryUtil.registerSlingNodeTypes(resolver.adaptTo(Session.class));
+ } catch (IOException ex) {
+ throw new RuntimeException("Unable to register sling node types.", ex);
+ } catch (RepositoryException ex) {
+ throw new RuntimeException("Unable to register sling node types.", ex);
+ }
+
+ return resolver;
+ }
+
+}
Propchange: sling/trunk/testing/sling-mock-jackrabbit/src/test/java/org/apache/sling/testing/mock/sling/jackrabbit/contentimport/ContentLoaderJsonTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: sling/trunk/testing/sling-mock-jackrabbit/src/test/java/org/apache/sling/testing/mock/sling/jackrabbit/contentimport/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-jackrabbit/src/test/java/org/apache/sling/testing/mock/sling/jackrabbit/contentimport/ContentLoaderJsonTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: sling/trunk/testing/sling-mock-jackrabbit/src/test/java/org/apache/sling/testing/mock/sling/jackrabbit/resource/JcrResourceResolverTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/testing/sling-mock-jackrabbit/src/test/java/org/apache/sling/testing/mock/sling/jackrabbit/resource/JcrResourceResolverTest.java?rev=1631356&view=auto
==============================================================================
--- sling/trunk/testing/sling-mock-jackrabbit/src/test/java/org/apache/sling/testing/mock/sling/jackrabbit/resource/JcrResourceResolverTest.java (added)
+++ sling/trunk/testing/sling-mock-jackrabbit/src/test/java/org/apache/sling/testing/mock/sling/jackrabbit/resource/JcrResourceResolverTest.java Mon Oct 13 11:54:39 2014
@@ -0,0 +1,55 @@
+/*
+ * 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.jackrabbit.resource;
+
+import java.io.IOException;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+
+import org.apache.sling.api.resource.ResourceResolver;
+import org.apache.sling.commons.testing.jcr.RepositoryUtil;
+import org.apache.sling.testing.mock.sling.MockSling;
+import org.apache.sling.testing.mock.sling.ResourceResolverType;
+import org.apache.sling.testing.mock.sling.resource.AbstractJcrResourceResolverTest;
+
+public class JcrResourceResolverTest extends AbstractJcrResourceResolverTest {
+
+ @Override
+ protected ResourceResolverType getResourceResolverType() {
+ return ResourceResolverType.JCR_JACKRABBIT;
+ }
+
+ @Override
+ protected ResourceResolver newResourceResolver() {
+ ResourceResolver resolver = MockSling.newResourceResolver(getResourceResolverType());
+
+ // register sling node types
+ try {
+ RepositoryUtil.registerSlingNodeTypes(resolver.adaptTo(Session.class));
+ } catch (IOException ex) {
+ throw new RuntimeException("Unable to register sling node types.", ex);
+ } catch (RepositoryException ex) {
+ throw new RuntimeException("Unable to register sling node types.", ex);
+ }
+
+ return resolver;
+ }
+
+}
Propchange: sling/trunk/testing/sling-mock-jackrabbit/src/test/java/org/apache/sling/testing/mock/sling/jackrabbit/resource/JcrResourceResolverTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: sling/trunk/testing/sling-mock-jackrabbit/src/test/java/org/apache/sling/testing/mock/sling/jackrabbit/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-jackrabbit/src/test/java/org/apache/sling/testing/mock/sling/jackrabbit/resource/JcrResourceResolverTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: sling/trunk/testing/sling-mock-jackrabbit/src/test/java/org/apache/sling/testing/mock/sling/jackrabbit/resource/SlingCrudResourceResolverTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/testing/sling-mock-jackrabbit/src/test/java/org/apache/sling/testing/mock/sling/jackrabbit/resource/SlingCrudResourceResolverTest.java?rev=1631356&view=auto
==============================================================================
--- sling/trunk/testing/sling-mock-jackrabbit/src/test/java/org/apache/sling/testing/mock/sling/jackrabbit/resource/SlingCrudResourceResolverTest.java (added)
+++ sling/trunk/testing/sling-mock-jackrabbit/src/test/java/org/apache/sling/testing/mock/sling/jackrabbit/resource/SlingCrudResourceResolverTest.java Mon Oct 13 11:54:39 2014
@@ -0,0 +1,55 @@
+/*
+ * 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.jackrabbit.resource;
+
+import java.io.IOException;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+
+import org.apache.sling.api.resource.ResourceResolver;
+import org.apache.sling.commons.testing.jcr.RepositoryUtil;
+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.JCR_JACKRABBIT;
+ }
+
+ @Override
+ protected ResourceResolver newResourceResolver() {
+ ResourceResolver resolver = MockSling.newResourceResolver(getResourceResolverType());
+
+ // register sling node types
+ try {
+ RepositoryUtil.registerSlingNodeTypes(resolver.adaptTo(Session.class));
+ } catch (IOException ex) {
+ throw new RuntimeException("Unable to register sling node types.", ex);
+ } catch (RepositoryException ex) {
+ throw new RuntimeException("Unable to register sling node types.", ex);
+ }
+
+ return resolver;
+ }
+
+}
Propchange: sling/trunk/testing/sling-mock-jackrabbit/src/test/java/org/apache/sling/testing/mock/sling/jackrabbit/resource/SlingCrudResourceResolverTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: sling/trunk/testing/sling-mock-jackrabbit/src/test/java/org/apache/sling/testing/mock/sling/jackrabbit/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-jackrabbit/src/test/java/org/apache/sling/testing/mock/sling/jackrabbit/resource/SlingCrudResourceResolverTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain