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 2017/11/06 16:16:34 UTC

[sling-org-apache-sling-testing-sling-mock-oak] 01/01: import branch for 1.x from svn

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

sseifert pushed a commit to branch release/1.x
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-testing-sling-mock-oak.git

commit bca1826ec674f3762fdd8b57b9bf13ffabc231be
Author: sseifert <ss...@pro-vision.de>
AuthorDate: Mon Nov 6 17:15:54 2017 +0100

    import branch for 1.x from svn
---
 pom.xml                                            | 121 ++++++++++++---------
 .../mock/sling/oak/OakMockSlingRepository.java     |  27 ++---
 .../sling/testing/mock/sling/oak/package-info.java |   2 +-
 3 files changed, 84 insertions(+), 66 deletions(-)

diff --git a/pom.xml b/pom.xml
index 2196868..e0df266 100644
--- a/pom.xml
+++ b/pom.xml
@@ -23,21 +23,21 @@
     <parent>
         <groupId>org.apache.sling</groupId>
         <artifactId>sling</artifactId>
-        <version>30</version>
+        <version>26</version>
         <relativePath />
     </parent>
 
     <artifactId>org.apache.sling.testing.sling-mock-oak</artifactId>
-    <version>2.0.3-SNAPSHOT</version>
+    <version>1.0.3-SNAPSHOT</version>
     <packaging>bundle</packaging>
   
-    <name>Apache Sling Testing Sling Mock Jackrabbit Oak-based Resource Resolver</name>
+    <name>Apache Sling Testing Sling Mock Oak-based Resource Resolver</name>
     <description>Implements a resource resolver type for Jackrabbit Oak that can be used in unit tests based on Sling Mocks.</description>
   
     <properties>
-        <oak.version>1.4.1</oak.version>
-        <jackrabbit.version>2.12.1</jackrabbit.version>
-        <sling-mock.version>2.2.12</sling-mock.version>
+        <oak.version>1.2.2</oak.version>
+        <jackrabbit.version>2.10.1</jackrabbit.version>
+        <sling-mock.version>1.9.6</sling-mock.version>
     </properties>
 
     <scm>
@@ -83,15 +83,10 @@
             <version>${jackrabbit.version}</version>
         </dependency>
 
-        <!-- those two compile dependencies are requires to avoid "Dependency-reduced POM written" endless loop in maven-shade-plugin -->
         <dependency>
             <groupId>javax.jcr</groupId>
             <artifactId>jcr</artifactId>
-            <scope>compile</scope>
-        </dependency>
-        <dependency>
-            <groupId>javax.servlet</groupId>
-            <artifactId>javax.servlet-api</artifactId>
+            <version>2.0</version>
             <scope>compile</scope>
         </dependency>
 
@@ -109,7 +104,7 @@
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.testing.logging-mock</artifactId>
-            <version>2.0.0</version>
+            <version>1.0.0</version>
             <scope>test</scope>
         </dependency>
   
@@ -118,42 +113,68 @@
     <build>
         <plugins>
     
-            <plugin>
-                <groupId>org.apache.felix</groupId>
-                <artifactId>maven-bundle-plugin</artifactId>
-                <extensions>true</extensions>
-            </plugin>
-      
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-shade-plugin</artifactId>
-                <version>2.4.3</version>
-                <configuration>
-                    <!--
-                        embed all jackrabbit artifacts to prevent classpath clashes
-                        also include selected Sling bundles which are required
-                        at runtime. Note that we don't relocate the packages
-                        since org.apache.sling.jcr.resource already embeds some
-                        jackrabbit classes which lead to a non-working jar
-                    -->
-                    <artifactSet>
-                        <includes>
-                            <include>org.apache.jackrabbit:*</include>
-                        </includes>
-                    </artifactSet>
-                    <createSourcesJar>true</createSourcesJar>
-                </configuration>
-                <executions>
-                    <execution>
-                        <phase>package</phase>
-                        <goals>
-                            <goal>shade</goal>
-                        </goals>
-                    </execution>
-                </executions>
-            </plugin>
-  
-            <plugin>
+          <!-- Publish test artifact -->
+          <plugin>
+            <groupId>org.apache.maven.plugins</groupId>
+            <artifactId>maven-jar-plugin</artifactId>
+            <executions>
+              <execution>
+                <goals>
+                  <goal>test-jar</goal>
+                </goals>
+              </execution>
+            </executions>
+          </plugin>
+    
+          <plugin>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>maven-bundle-plugin</artifactId>
+            <extensions>true</extensions>
+          </plugin>
+    
+          <plugin>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>maven-scr-plugin</artifactId>
+            <executions>
+              <execution>
+                <id>generate-scr-scrdescriptor</id>
+                <goals>
+                  <goal>scr</goal>
+                </goals>
+              </execution>
+            </executions>
+          </plugin>
+
+          <plugin>
+              <groupId>org.apache.maven.plugins</groupId>
+              <artifactId>maven-shade-plugin</artifactId>
+              <version>2.4.1</version>
+              <configuration>
+                <!--
+                    embed all jackrabbit artifacts to prevent classpath clashes
+                    also include selected Sling bundles which are required
+                    at runtime. Note that we don't relocate the packages
+                    since org.apache.sling.jcr.resource already embeds some
+                    jackrabbit classes which lead to a non-working jar
+                -->
+                <artifactSet>
+                    <includes>
+                        <include>org.apache.jackrabbit:*</include>
+                    </includes>
+                </artifactSet>
+                <createSourcesJar>true</createSourcesJar>
+              </configuration>
+              <executions>
+                <execution>
+                    <phase>package</phase>
+                    <goals>
+                        <goal>shade</goal>
+                    </goals>
+                </execution>
+              </executions>
+          </plugin>
+
+          <plugin>
                 <groupId>org.apache.rat</groupId>
                 <artifactId>apache-rat-plugin</artifactId>
                 <configuration>
@@ -161,7 +182,7 @@
                         <exclude>dependency-reduced-pom.xml</exclude>
                     </excludes>
                 </configuration>
-            </plugin>
+          </plugin>
         </plugins>
     </build>
   
diff --git a/src/main/java/org/apache/sling/testing/mock/sling/oak/OakMockSlingRepository.java b/src/main/java/org/apache/sling/testing/mock/sling/oak/OakMockSlingRepository.java
index c78bf00..f786e6c 100644
--- a/src/main/java/org/apache/sling/testing/mock/sling/oak/OakMockSlingRepository.java
+++ b/src/main/java/org/apache/sling/testing/mock/sling/oak/OakMockSlingRepository.java
@@ -33,19 +33,21 @@ import javax.jcr.Session;
 import javax.jcr.SimpleCredentials;
 import javax.jcr.Value;
 
+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.Service;
 import org.apache.jackrabbit.api.JackrabbitRepository;
 import org.apache.jackrabbit.oak.Oak;
 import org.apache.jackrabbit.oak.jcr.Jcr;
 import org.apache.sling.jcr.api.SlingRepository;
 import org.osgi.framework.BundleContext;
 import org.osgi.service.component.ComponentContext;
-import org.osgi.service.component.annotations.Activate;
-import org.osgi.service.component.annotations.Component;
-import org.osgi.service.component.annotations.Deactivate;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-@Component(service = SlingRepository.class)
+@Component
+@Service(SlingRepository.class)
 public final class OakMockSlingRepository implements SlingRepository {
 
     private static final String ADMIN_NAME = "admin";
@@ -58,12 +60,13 @@ public final class OakMockSlingRepository implements SlingRepository {
     private static final Logger log = LoggerFactory.getLogger(OakMockSlingRepository.class);
     
     @Activate
-    protected void activate(BundleContext bundleContext) {
+    protected void activate(ComponentContext componentContext) {
         executor = Executors.newSingleThreadExecutor();
         scheduledExecutor = Executors.newSingleThreadScheduledExecutor();
         
-        if (bundleContext.getServiceReference(Executor.class) == null) {
-            bundleContext.registerService(Executor.class, executor, null);
+        BundleContext bundleContext = componentContext.getBundleContext();
+        if (bundleContext.getServiceReference(Executor.class.getName()) == null) {
+            bundleContext.registerService(Executor.class.getName(), executor, null);
         }
         
         Oak oak = new Oak()
@@ -89,7 +92,7 @@ public final class OakMockSlingRepository implements SlingRepository {
         // shutdown OAK JCR repository
         ((JackrabbitRepository)repository).shutdown();
     }
-
+    
     private void shutdownExecutorService(Object instance, String fieldName) {
         try {
             Field executorField = instance.getClass().getDeclaredField(fieldName); 
@@ -101,7 +104,7 @@ public final class OakMockSlingRepository implements SlingRepository {
             log.error("Potential Memory leak: Unable to shutdown executor service from field '" + fieldName + "' in " + instance, ex);
         }
     }
-    
+
     public String getDescriptor(String key) {
         return repository.getDescriptor(key);
     }
@@ -161,10 +164,4 @@ public final class OakMockSlingRepository implements SlingRepository {
         return repository.isStandardDescriptor(key);
     }
 
-    @Override
-    public Session impersonateFromService(String subServiceName, Credentials credentials, String workspaceName)
-            throws LoginException, RepositoryException {
-        return repository.login(credentials, (workspaceName == null ? getDefaultWorkspace() : workspaceName));
-    }
-
 }
diff --git a/src/main/java/org/apache/sling/testing/mock/sling/oak/package-info.java b/src/main/java/org/apache/sling/testing/mock/sling/oak/package-info.java
index 2d527c4..b4e676f 100644
--- a/src/main/java/org/apache/sling/testing/mock/sling/oak/package-info.java
+++ b/src/main/java/org/apache/sling/testing/mock/sling/oak/package-info.java
@@ -19,5 +19,5 @@
 /**
  * Sling Mock Jackrabbit Oak-based Resource Resolver
  */
-@org.osgi.annotation.versioning.Version("2.0.1")
+@aQute.bnd.annotation.Version("1.0")
 package org.apache.sling.testing.mock.sling.oak;

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