sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sseif...@apache.org
Subject svn commit: r1794387 - in /sling/trunk/testing/mocks/sling-mock/src: main/java/org/apache/sling/testing/mock/sling/context/SlingContextImpl.java test/java/org/apache/sling/testing/mock/sling/context/AbstractSlingContextImplTest.java
Date Mon, 08 May 2017 14:47:51 GMT
Author: sseifert
Date: Mon May  8 14:47:50 2017
New Revision: 1794387

URL: http://svn.apache.org/viewvc?rev=1794387&view=rev
Log:
SLING-6841 Sling Mocks should inject ResourceResolverFactory by default

Modified:
    sling/trunk/testing/mocks/sling-mock/src/main/java/org/apache/sling/testing/mock/sling/context/SlingContextImpl.java
    sling/trunk/testing/mocks/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/context/AbstractSlingContextImplTest.java

Modified: sling/trunk/testing/mocks/sling-mock/src/main/java/org/apache/sling/testing/mock/sling/context/SlingContextImpl.java
URL: http://svn.apache.org/viewvc/sling/trunk/testing/mocks/sling-mock/src/main/java/org/apache/sling/testing/mock/sling/context/SlingContextImpl.java?rev=1794387&r1=1794386&r2=1794387&view=diff
==============================================================================
--- sling/trunk/testing/mocks/sling-mock/src/main/java/org/apache/sling/testing/mock/sling/context/SlingContextImpl.java
(original)
+++ sling/trunk/testing/mocks/sling-mock/src/main/java/org/apache/sling/testing/mock/sling/context/SlingContextImpl.java
Mon May  8 14:47:50 2017
@@ -118,6 +118,12 @@ public class SlingContextImpl extends Os
             MockOsgi.setConfigForPid(bundleContext(), RESOURCERESOLVERFACTORYACTIVATOR_PID,
this.resourceResolverFactoryActivatorProps);
         }
         
+        // automatically register resource resolver factory when ResourceResolverType !=
NONE,
+        // so the ResourceResolverFactory is available as OSGi service immediately
+        if (resourceResolverType != ResourceResolverType.NONE) {
+            resourceResolverFactory();
+        }
+        
         registerDefaultServices();
     }
     

Modified: sling/trunk/testing/mocks/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/context/AbstractSlingContextImplTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/testing/mocks/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/context/AbstractSlingContextImplTest.java?rev=1794387&r1=1794386&r2=1794387&view=diff
==============================================================================
--- sling/trunk/testing/mocks/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/context/AbstractSlingContextImplTest.java
(original)
+++ sling/trunk/testing/mocks/sling-mock/src/test/java/org/apache/sling/testing/mock/sling/context/AbstractSlingContextImplTest.java
Mon May  8 14:47:50 2017
@@ -48,6 +48,9 @@ public abstract class AbstractSlingConte
 
     @Before
     public void setUp() throws Exception {
+        // make sure ResourceResolverFactory is available immediately and not lazily
+        assertEquals(1, context.getServices(ResourceResolverFactory.class, null).length);
+
         context.addModelsForPackage("org.apache.sling.testing.mock.sling.context.models");
         
         ContentLoader contentLoader = this.context.load();
@@ -138,10 +141,4 @@ public abstract class AbstractSlingConte
         assertTrue(newRunModes.contains("mode2"));
     }
     
-    @Test
-    public void testResourceResolverFactory() {
-        ResourceResolverFactory[] factories = context.getServices(ResourceResolverFactory.class,
null);
-        assertEquals(1, factories.length);
-    }
-
 }



Mime
View raw message