sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From romb...@apache.org
Subject [sling-org-apache-sling-testing-jcr-mock] 09/27: SLING-4362 make sure JCR namespaces are correctly registered in JCR mock on initialization through sling mock
Date Tue, 07 Nov 2017 10:18:05 GMT
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.testing.jcr-mock-1.1.10
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-testing-jcr-mock.git

commit 9d528c00ff6d71bcf074fe95b25d6f038ecf40d2
Author: Stefan Seifert <sseifert@apache.org>
AuthorDate: Mon Feb 2 11:25:43 2015 +0000

    SLING-4362 make sure JCR namespaces are correctly registered in JCR mock on initialization
through sling mock
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/testing/mocks/jcr-mock@1656442
13f79535-47bb-0310-9956-ffa450edef68
---
 .../apache/sling/testing/mock/jcr/MockRepository.java | 19 +++++++++++++++++++
 .../apache/sling/testing/mock/jcr/MockSession.java    |  6 +++---
 .../apache/sling/testing/mock/jcr/MockWorkspace.java  | 13 ++++++-------
 3 files changed, 28 insertions(+), 10 deletions(-)

diff --git a/src/main/java/org/apache/sling/testing/mock/jcr/MockRepository.java b/src/main/java/org/apache/sling/testing/mock/jcr/MockRepository.java
index 377ede6..12c6790 100644
--- a/src/main/java/org/apache/sling/testing/mock/jcr/MockRepository.java
+++ b/src/main/java/org/apache/sling/testing/mock/jcr/MockRepository.java
@@ -22,11 +22,14 @@ import java.util.LinkedHashMap;
 import java.util.Map;
 
 import javax.jcr.Credentials;
+import javax.jcr.NamespaceRegistry;
 import javax.jcr.Repository;
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
 import javax.jcr.SimpleCredentials;
 import javax.jcr.Value;
+import javax.jcr.nodetype.NodeTypeManager;
+import javax.jcr.observation.ObservationManager;
 
 import org.apache.commons.lang3.ArrayUtils;
 import org.apache.commons.lang3.StringUtils;
@@ -40,6 +43,10 @@ class MockRepository implements Repository {
 
     // Use linked hashmap to ensure ordering when adding items is preserved.
     private final Map<String, ItemData> items = new LinkedHashMap<String, ItemData>();
+
+    private final NamespaceRegistry namespaceRegistry = new MockNamespaceRegistry();
+    private final ObservationManager observationManager = new MockObservationManager();
+    private final NodeTypeManager nodeTypeManager = new MockNodeTypeManager();
     
     public MockRepository() {
         this.items.put("/", ItemData.newNode("/", MockNodeTypes.NT_UNSTRUCTURED));
@@ -101,4 +108,16 @@ class MockRepository implements Repository {
         return null;
     }
 
+    NamespaceRegistry getNamespaceRegistry() {
+        return namespaceRegistry;
+    }
+
+    ObservationManager getObservationManager() {
+        return observationManager;
+    }
+
+    NodeTypeManager getNodeTypeManager() {
+        return nodeTypeManager;
+    }
+
 }
diff --git a/src/main/java/org/apache/sling/testing/mock/jcr/MockSession.java b/src/main/java/org/apache/sling/testing/mock/jcr/MockSession.java
index 2e7e062..3fd661d 100644
--- a/src/main/java/org/apache/sling/testing/mock/jcr/MockSession.java
+++ b/src/main/java/org/apache/sling/testing/mock/jcr/MockSession.java
@@ -51,15 +51,15 @@ import org.xml.sax.ContentHandler;
  */
 class MockSession implements Session {
 
-    private final Repository repository;
+    private final MockRepository repository;
     private final Workspace workspace;
     private final Map<String, ItemData> items;
     private final String userId;
 
-    public MockSession(Repository repository, Map<String,ItemData> items,
+    public MockSession(MockRepository repository, Map<String,ItemData> items,
             String userId, String workspaceName) {
         this.repository = repository;
-        this.workspace = new MockWorkspace(this, workspaceName);
+        this.workspace = new MockWorkspace(repository, this, workspaceName);
         this.items = items;
         this.userId = userId;
     }
diff --git a/src/main/java/org/apache/sling/testing/mock/jcr/MockWorkspace.java b/src/main/java/org/apache/sling/testing/mock/jcr/MockWorkspace.java
index 0e71284..dad0c6b 100644
--- a/src/main/java/org/apache/sling/testing/mock/jcr/MockWorkspace.java
+++ b/src/main/java/org/apache/sling/testing/mock/jcr/MockWorkspace.java
@@ -38,17 +38,16 @@ import org.xml.sax.ContentHandler;
  */
 class MockWorkspace implements Workspace {
 
+    private final MockRepository repository;
     private final Session session;
     private final String workspaceName;
-    private final NamespaceRegistry namespaceRegistry = new MockNamespaceRegistry();
-    private final ObservationManager observationManager = new MockObservationManager();
-    private final NodeTypeManager nodeTypeManager = new MockNodeTypeManager();
     private final QueryManager queryManager = new MockQueryManager();
 
     /**
      * @param session JCR session
      */
-    public MockWorkspace(Session session, String workspaceName) {
+    public MockWorkspace(MockRepository repository, Session session, String workspaceName)
{
+        this.repository = repository;
         this.session = session;
         this.workspaceName = workspaceName;
     }
@@ -65,17 +64,17 @@ class MockWorkspace implements Workspace {
 
     @Override
     public NamespaceRegistry getNamespaceRegistry() throws RepositoryException {
-        return this.namespaceRegistry;
+        return repository.getNamespaceRegistry();
     }
 
     @Override
     public ObservationManager getObservationManager() throws RepositoryException {
-        return this.observationManager;
+        return repository.getObservationManager();
     }
 
     @Override
     public NodeTypeManager getNodeTypeManager() throws RepositoryException {
-        return this.nodeTypeManager;
+        return repository.getNodeTypeManager();
     }
 
     @Override

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

Mime
View raw message