You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2017/11/07 10:28:26 UTC
[sling-org-apache-sling-testing-sling-mock] 23/28: SLING-5088
control SlingRepository resources via activate/deactivate methods;
make sure all oak ExecutorServices are shutdown properly
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.testing.sling-mock-jackrabbit-1.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-testing-sling-mock.git
commit 3c2c0330331926d2d25db0ca781509e409bf9f7a
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Fri Oct 2 23:31:40 2015 +0000
SLING-5088 control SlingRepository resources via activate/deactivate methods; make sure all oak ExecutorServices are shutdown properly
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/testing/mocks/sling-mock-jackrabbit@1706505 13f79535-47bb-0310-9956-ffa450edef68
---
.../JackrabbitMockResourceResolverAdapter.java | 10 +-
.../jackrabbit/JackrabbitMockSlingRepository.java | 105 +++++++++++++++++++++
.../mock/sling/jackrabbit/package-info.java | 2 +-
3 files changed, 107 insertions(+), 10 deletions(-)
diff --git a/src/main/java/org/apache/sling/testing/mock/sling/jackrabbit/JackrabbitMockResourceResolverAdapter.java b/src/main/java/org/apache/sling/testing/mock/sling/jackrabbit/JackrabbitMockResourceResolverAdapter.java
index a484774..9256c01 100644
--- a/src/main/java/org/apache/sling/testing/mock/sling/jackrabbit/JackrabbitMockResourceResolverAdapter.java
+++ b/src/main/java/org/apache/sling/testing/mock/sling/jackrabbit/JackrabbitMockResourceResolverAdapter.java
@@ -18,10 +18,7 @@
*/
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;
@@ -37,12 +34,7 @@ public class JackrabbitMockResourceResolverAdapter implements ResourceResolverTy
@Override
public SlingRepository newSlingRepository() {
- try {
- return RepositoryProvider.instance().getRepository();
- }
- catch (RepositoryException ex) {
- throw new RuntimeException("Unable to get jackrabbit SlingRepository instance.", ex);
- }
+ return new JackrabbitMockSlingRepository();
}
}
diff --git a/src/main/java/org/apache/sling/testing/mock/sling/jackrabbit/JackrabbitMockSlingRepository.java b/src/main/java/org/apache/sling/testing/mock/sling/jackrabbit/JackrabbitMockSlingRepository.java
new file mode 100644
index 0000000..90ab384
--- /dev/null
+++ b/src/main/java/org/apache/sling/testing/mock/sling/jackrabbit/JackrabbitMockSlingRepository.java
@@ -0,0 +1,105 @@
+/*
+ * 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.Credentials;
+import javax.jcr.LoginException;
+import javax.jcr.NoSuchWorkspaceException;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.Value;
+
+import org.apache.felix.scr.annotations.Activate;
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Service;
+import org.apache.sling.commons.testing.jcr.RepositoryProvider;
+import org.apache.sling.jcr.api.SlingRepository;
+import org.osgi.service.component.ComponentContext;
+
+@Component
+@Service(SlingRepository.class)
+public final class JackrabbitMockSlingRepository implements SlingRepository {
+
+ private SlingRepository delegate;
+
+ @Activate
+ protected void activate(ComponentContext componentContext) {
+ try {
+ this.delegate = RepositoryProvider.instance().getRepository();
+ }
+ catch (RepositoryException ex) {
+ throw new RuntimeException("Unable to get jackrabbit SlingRepository instance.", ex);
+ }
+ }
+
+ public String getDefaultWorkspace() {
+ return delegate.getDefaultWorkspace();
+ }
+
+ @SuppressWarnings("deprecation")
+ public Session loginAdministrative(String workspace) throws LoginException, RepositoryException {
+ return delegate.loginAdministrative(workspace);
+ }
+
+ public Session loginService(String subServiceName, String workspace) throws LoginException, RepositoryException {
+ return delegate.loginService(subServiceName, workspace);
+ }
+
+ public String[] getDescriptorKeys() {
+ return delegate.getDescriptorKeys();
+ }
+
+ public boolean isStandardDescriptor(String key) {
+ return delegate.isStandardDescriptor(key);
+ }
+
+ public boolean isSingleValueDescriptor(String key) {
+ return delegate.isSingleValueDescriptor(key);
+ }
+
+ public Value getDescriptorValue(String key) {
+ return delegate.getDescriptorValue(key);
+ }
+
+ public Value[] getDescriptorValues(String key) {
+ return delegate.getDescriptorValues(key);
+ }
+
+ public String getDescriptor(String key) {
+ return delegate.getDescriptor(key);
+ }
+
+ public Session login(Credentials credentials, String workspaceName) throws LoginException,
+ NoSuchWorkspaceException, RepositoryException {
+ return delegate.login(credentials, workspaceName);
+ }
+
+ public Session login(Credentials credentials) throws LoginException, RepositoryException {
+ return delegate.login(credentials);
+ }
+
+ public Session login(String workspaceName) throws LoginException, NoSuchWorkspaceException, RepositoryException {
+ return delegate.login(workspaceName);
+ }
+
+ public Session login() throws LoginException, RepositoryException {
+ return delegate.login();
+ }
+
+}
diff --git a/src/main/java/org/apache/sling/testing/mock/sling/jackrabbit/package-info.java b/src/main/java/org/apache/sling/testing/mock/sling/jackrabbit/package-info.java
index e22b13e..88f7843 100644
--- a/src/main/java/org/apache/sling/testing/mock/sling/jackrabbit/package-info.java
+++ b/src/main/java/org/apache/sling/testing/mock/sling/jackrabbit/package-info.java
@@ -19,5 +19,5 @@
/**
* Sling Mock Jackrabbit-based Resource Resolver
*/
-@aQute.bnd.annotation.Version("0.1")
+@aQute.bnd.annotation.Version("1.0")
package org.apache.sling.testing.mock.sling.jackrabbit;
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.